+
+/** @brief Add a checkbox for a three-right group
+ * @param table Containing table
+ * @param rowp Pointer to row number, incremented
+ * @param title Label for this row
+ * @param bits Rights bits (not masked or normalized)
+ * @param mask Mask for this group (must be 7.2^n)
+ * @param checks Where to store triple of check widgets
+ * @return Checkbox widget
+ */
+static void users_add_right_group(GtkWidget *table,
+ int *rowp,
+ const char *title,
+ rights_type bits,
+ rights_type mask,
+ GtkWidget *checks[3]) {
+ GtkWidget *any = gtk_check_button_new_with_label("Any");
+ GtkWidget *mine = gtk_check_button_new_with_label("Own");
+ GtkWidget *random = gtk_check_button_new_with_label("Random");
+ GtkWidget *hbox = gtk_hbox_new(FALSE, 2);
+
+ /* Discard irrelevant bits */
+ bits &= mask;
+ /* Shift down to bits 0-2; the mask is always 3 contiguous bits */
+ bits /= (mask / 7);
+ /* If _ANY is set then the other two are implied; we'll take them out when we
+ * set. */
+ if(bits & 1)
+ bits = 7;
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(any), !!(bits & 1));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mine), !!(bits & 2));
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(random), !!(bits & 4));
+ gtk_box_pack_start(GTK_BOX(hbox), any, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), mine, FALSE, FALSE, 0);
+ gtk_box_pack_start(GTK_BOX(hbox), random, FALSE, FALSE, 0);
+ if(checks) {
+ checks[0] = any;
+ checks[1] = mine;
+ checks[2] = random;
+ }
+ users_detail_generic(table, rowp, title, hbox);
+}