2 * This file is part of DisOrder
3 * Copyright (C) 2008 Richard Kettlewell
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 /** @file disobedience/users.c
21 * @brief User management for Disobedience
23 * The user management window contains:
24 * - a list of all the users
27 * - a user details panel
30 * When you select a user that user's details are displayed to the right of the
31 * list. Hit the Apply button and any changes are applied.
33 * When you select 'add' a new empty set of details are displayed to be edited.
34 * Again Apply will commit them.
37 * - enter new username in the GtkTreeView
38 * - should have a cancel or close button, consistent with properties and login
41 #include "disobedience.h"
45 static void users_details_sensitize_all(void);
46 static void users_set_report(const char *msg
);
48 static GtkWidget
*users_window
;
49 static GtkListStore
*users_list
;
50 static GtkTreeSelection
*users_selection
;
52 static GtkWidget
*users_details_table
;
53 static GtkWidget
*users_apply_button
;
54 static GtkWidget
*users_delete_button
;
55 static GtkWidget
*users_details_name
;
56 static GtkWidget
*users_details_email
;
57 static GtkWidget
*users_details_password
;
58 static GtkWidget
*users_details_password2
;
59 static GtkWidget
*users_details_rights
[32];
60 static GtkWidget
*users_reporter
;
61 static int users_details_row
;
62 static const char *users_selected
;
63 static const char *users_deferred_select
;
65 static int users_mode
;
70 #define mode(X) do { \
71 users_mode = MODE_##X; \
72 if(0) fprintf(stderr, "%s:%d: %s(): mode -> %s\n", \
73 __FILE__, __LINE__, __FUNCTION__, #X); \
74 users_details_sensitize_all(); \
77 static const char *users_email
, *users_rights
, *users_password
;
79 /** @brief qsort() callback for username comparison */
80 static int usercmp(const void *a
, const void *b
) {
81 return strcmp(*(char **)a
, *(char **)b
);
84 /** @brief Find a user
85 * @param user User to find
86 * @param iter Iterator to point at user
87 * @return 0 on success, -1 if not found
89 static int users_find_user(const char *user
,
94 if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(users_list
), iter
))
97 gtk_tree_model_get(GTK_TREE_MODEL(users_list
), iter
,
99 if(!strcmp(who
, user
)) {
104 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(users_list
), iter
));
108 /** @brief Called with the list of users
111 * - at startup to populate the initial list
112 * - when we add a user
113 * - maybe in the future when we delete a user
115 * If users_deferred_select is set then that user is selected.
117 static void users_got_list(void attribute((unused
)) *v
,
119 int nvec
, char **vec
) {
124 popup_protocol_error(0, err
);
127 /* Present users in alphabetical order */
128 qsort(vec
, nvec
, sizeof (char *), usercmp
);
129 /* Set the list contents */
130 gtk_list_store_clear(users_list
);
131 for(n
= 0; n
< nvec
; ++n
)
132 gtk_list_store_insert_with_values(users_list
, &iter
, n
/*position*/,
133 0, vec
[n
], /* column 0 */
134 -1); /* no more columns */
135 /* Only show the window when the list is populated */
136 gtk_widget_show_all(users_window
);
137 if(users_deferred_select
) {
138 if(!users_find_user(users_deferred_select
, &iter
))
139 gtk_tree_selection_select_iter(users_selection
, &iter
);
140 users_deferred_select
= 0;
144 /** @brief Text should be visible */
145 #define DETAIL_VISIBLE 1
147 /** @brief Text should be editable */
148 #define DETAIL_EDITABLE 2
150 /** @brief Add a row to the user detail table */
151 static void users_detail_generic(const char *title
,
152 GtkWidget
*selector
) {
153 const int row
= users_details_row
++;
154 GtkWidget
*const label
= gtk_label_new(title
);
155 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0);
156 gtk_table_attach(GTK_TABLE(users_details_table
),
158 0, 1, /* left/right_attach */
159 row
, row
+1, /* top/bottom_attach */
160 GTK_FILL
, /* xoptions */
162 1, 1); /* x/ypadding */
163 gtk_table_attach(GTK_TABLE(users_details_table
),
165 1, 2, /* left/right_attach */
166 row
, row
+ 1, /* top/bottom_attach */
167 GTK_EXPAND
|GTK_FILL
, /* xoptions */
168 GTK_FILL
, /* yoptions */
169 1, 1); /* x/ypadding */
172 static void users_entry_changed(GtkEditable
attribute((unused
)) *editable
,
173 gpointer
attribute((unused
)) user_data
) {
174 users_details_sensitize_all();
177 /** @brief Add a row to the user details table
178 * @param entryp Where to put GtkEntry
179 * @param title Label for this row
180 * @param value Initial value or NULL
181 * @param flags Flags word
183 static void users_add_detail(GtkWidget
**entryp
,
189 if(!(entry
= *entryp
)) {
190 *entryp
= entry
= gtk_entry_new();
191 g_signal_connect(entry
, "changed",
192 G_CALLBACK(users_entry_changed
), 0);
193 users_detail_generic(title
, entry
);
195 gtk_entry_set_visibility(GTK_ENTRY(entry
),
196 !!(flags
& DETAIL_VISIBLE
));
197 gtk_editable_set_editable(GTK_EDITABLE(entry
),
198 !!(flags
& DETAIL_EDITABLE
));
199 gtk_entry_set_text(GTK_ENTRY(entry
), value ? value
: "");
202 /** @brief Add a checkbox for a right
203 * @param title Label for this row
204 * @param value Current value
205 * @param right Right bit
207 static void users_add_right(const char *title
,
211 GtkWidget
**checkp
= &users_details_rights
[leftmost_bit(right
)];
213 if(!(check
= *checkp
)) {
214 *checkp
= check
= gtk_check_button_new_with_label("");
215 users_detail_generic(title
, check
);
217 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check
), !!(value
& right
));
220 /** @brief Set sensitivity of particular mine/random rights bits */
221 static void users_details_sensitize(rights_type r
) {
222 const int bit
= leftmost_bit(r
);
223 const GtkWidget
*all
= users_details_rights
[bit
];
224 const int sensitive
= (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(all
))
225 && users_mode
!= MODE_NONE
);
227 gtk_widget_set_sensitive(users_details_rights
[bit
+ 1], sensitive
);
228 gtk_widget_set_sensitive(users_details_rights
[bit
+ 2], sensitive
);
231 /** @brief Set sensitivity of everything in sight */
232 static void users_details_sensitize_all(void) {
234 const char *report
= 0;
236 for(n
= 0; n
< 32; ++n
)
237 if(users_details_rights
[n
])
238 gtk_widget_set_sensitive(users_details_rights
[n
], users_mode
!= MODE_NONE
);
239 gtk_widget_set_sensitive(users_details_name
, users_mode
!= MODE_NONE
);
240 gtk_widget_set_sensitive(users_details_email
, users_mode
!= MODE_NONE
);
241 gtk_widget_set_sensitive(users_details_password
, users_mode
!= MODE_NONE
);
242 gtk_widget_set_sensitive(users_details_password2
, users_mode
!= MODE_NONE
);
243 users_details_sensitize(RIGHT_MOVE_ANY
);
244 users_details_sensitize(RIGHT_REMOVE_ANY
);
245 users_details_sensitize(RIGHT_SCRATCH_ANY
);
246 int apply_sensitive
= 1;
247 if(users_mode
== MODE_NONE
)
250 const char *name
= gtk_entry_get_text(GTK_ENTRY(users_details_name
));
251 const char *email
= gtk_entry_get_text(GTK_ENTRY(users_details_email
));
252 const char *pw
= gtk_entry_get_text(GTK_ENTRY(users_details_password
));
253 const char *pw2
= gtk_entry_get_text(GTK_ENTRY(users_details_password2
));
254 /* Username must be filled in */
258 report
= "Must fill in username";
260 /* Passwords must be nontrivial and match */
264 report
= "Must fill in password";
266 if(strcmp(pw
, pw2
)) {
269 report
= "Passwords must match";
271 /* Email address must be somewhat valid */
273 if(!email_valid(email
)) {
275 report
= "Invalid email address";
279 gtk_widget_set_sensitive(users_apply_button
, apply_sensitive
);
280 gtk_widget_set_sensitive(users_delete_button
, !!users_selected
);
281 users_set_report(report
);
284 /** @brief Called when an _ALL widget is toggled
286 * Modifies sensitivity of the corresponding _MINE and _RANDOM widgets. We
287 * just do the lot rather than trying to figure out which one changed,
289 static void users_any_toggled(GtkToggleButton
attribute((unused
)) *togglebutton
,
290 gpointer
attribute((unused
)) user_data
) {
291 users_details_sensitize_all();
294 /** @brief Add a checkbox for a three-right group
295 * @param title Label for this row
296 * @param bits Rights bits (not masked or normalized)
297 * @param mask Mask for this group (must be 7*2^n)
299 static void users_add_right_group(const char *title
,
302 const uint32_t first
= mask
/ 7;
303 const int bit
= leftmost_bit(first
);
304 GtkWidget
**widgets
= &users_details_rights
[bit
], *any
, *mine
, *rnd
;
307 GtkWidget
*hbox
= gtk_hbox_new(FALSE
, 2);
309 any
= widgets
[0] = gtk_check_button_new_with_label("Any");
310 mine
= widgets
[1] = gtk_check_button_new_with_label("Own");
311 rnd
= widgets
[2] = gtk_check_button_new_with_label("Random");
312 gtk_box_pack_start(GTK_BOX(hbox
), any
, FALSE
, FALSE
, 0);
313 gtk_box_pack_start(GTK_BOX(hbox
), mine
, FALSE
, FALSE
, 0);
314 gtk_box_pack_start(GTK_BOX(hbox
), rnd
, FALSE
, FALSE
, 0);
315 users_detail_generic(title
, hbox
);
316 g_signal_connect(any
, "toggled", G_CALLBACK(users_any_toggled
), NULL
);
317 users_details_rights
[bit
] = any
;
318 users_details_rights
[bit
+ 1] = mine
;
319 users_details_rights
[bit
+ 2] = rnd
;
325 /* Discard irrelevant bits */
327 /* Shift down to bits 0-2; the mask is always 3 contiguous bits */
329 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(any
), !!(bits
& 1));
330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mine
), !!(bits
& 2));
331 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rnd
), !!(bits
& 4));
334 /** @brief Called when the details table is destroyed */
335 static void users_details_destroyed(GtkWidget
attribute((unused
)) *widget
,
336 GtkWidget
attribute((unused
)) **wp
) {
337 users_details_table
= 0;
338 g_object_unref(users_list
);
340 users_details_name
= 0;
341 users_details_email
= 0;
342 users_details_password
= 0;
343 users_details_password2
= 0;
344 memset(users_details_rights
, 0, sizeof users_details_rights
);
345 /* also users_selection? Not AFAICT; _get_selection does upref */
348 /** @brief Create or modify the user details table
349 * @param name User name (users_edit()) or NULL (users_add())
350 * @param email Email address
351 * @param rights User rights string
352 * @param password Password
354 static void users_makedetails(const char *name
,
357 const char *password
,
362 /* Create the table if it doesn't already exist */
363 if(!users_details_table
) {
364 users_details_table
= gtk_table_new(4, 2, FALSE
/*!homogeneous*/);
365 g_signal_connect(users_details_table
, "destroy",
366 G_CALLBACK(users_details_destroyed
), 0);
369 /* Create or update the widgets */
370 users_add_detail(&users_details_name
, "Username", name
,
371 (DETAIL_EDITABLE
|DETAIL_VISIBLE
) & nameflags
);
373 users_add_detail(&users_details_email
, "Email", email
,
374 (DETAIL_EDITABLE
|DETAIL_VISIBLE
) & flags
);
376 users_add_detail(&users_details_password
, "Password", password
,
377 DETAIL_EDITABLE
& flags
);
378 users_add_detail(&users_details_password2
, "Password", password
,
379 DETAIL_EDITABLE
& flags
);
381 parse_rights(rights
, &r
, 0);
382 users_add_right("Read operations", r
, RIGHT_READ
);
383 users_add_right("Play track", r
, RIGHT_PLAY
);
384 users_add_right_group("Move", r
, RIGHT_MOVE__MASK
);
385 users_add_right_group("Remove", r
, RIGHT_REMOVE__MASK
);
386 users_add_right_group("Scratch", r
, RIGHT_SCRATCH__MASK
);
387 users_add_right("Set volume", r
, RIGHT_VOLUME
);
388 users_add_right("Admin operations", r
, RIGHT_ADMIN
);
389 users_add_right("Rescan", r
, RIGHT_RESCAN
);
390 users_add_right("Register new users", r
, RIGHT_REGISTER
);
391 users_add_right("Modify own userinfo", r
, RIGHT_USERINFO
);
392 users_add_right("Modify track preferences", r
, RIGHT_PREFS
);
393 users_add_right("Modify global preferences", r
, RIGHT_GLOBAL_PREFS
);
394 users_add_right("Pause/resume tracks", r
, RIGHT_PAUSE
);
395 users_details_sensitize_all();
398 /** @brief Called when the 'add' button is pressed */
399 static void users_add(GtkButton
attribute((unused
)) *button
,
400 gpointer
attribute((unused
)) userdata
) {
401 /* Unselect whatever is selected */
402 gtk_tree_selection_unselect_all(users_selection
);
404 /* TODO it would be better to use the server default_rights if there's no
406 users_makedetails("",
408 config
->default_rights
,
410 DETAIL_EDITABLE
|DETAIL_VISIBLE
,
411 DETAIL_EDITABLE
|DETAIL_VISIBLE
);
412 /* Remember we're adding a user */
416 static rights_type
users_get_rights(void) {
420 /* Extract the rights value */
421 for(n
= 0; n
< 32; ++n
) {
422 if(users_details_rights
[n
])
423 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(users_details_rights
[n
])))
426 /* Throw out redundant bits */
427 if(r
& RIGHT_REMOVE_ANY
)
428 r
&= ~(rights_type
)(RIGHT_REMOVE_MINE
|RIGHT_REMOVE_RANDOM
);
429 if(r
& RIGHT_MOVE_ANY
)
430 r
&= ~(rights_type
)(RIGHT_MOVE_MINE
|RIGHT_MOVE_RANDOM
);
431 if(r
& RIGHT_SCRATCH_ANY
)
432 r
&= ~(rights_type
)(RIGHT_SCRATCH_MINE
|RIGHT_SCRATCH_RANDOM
);
436 /** @brief Called when a user setting has been edited */
437 static void users_edituser_completed(void attribute((unused
)) *v
,
440 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
443 /** @brief Called when a new user has been created */
444 static void users_adduser_completed(void *v
,
447 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
448 mode(ADD
); /* Let the user try again */
450 const struct kvp
*const kvp
= v
;
451 const char *user
= kvp_get(kvp
, "user");
452 const char *email
= kvp_get(kvp
, "email"); /* maybe NULL */
454 /* Now the user is created we can go ahead and set the email address */
456 disorder_eclient_edituser(client
, users_edituser_completed
, user
,
457 "email", email
, NULL
);
458 /* Refresh the list of users */
459 disorder_eclient_users(client
, users_got_list
, 0);
460 /* We'll select the newly created user */
461 users_deferred_select
= user
;
465 /** @brief Called when the 'Apply' button is pressed */
466 static void users_apply(GtkButton
attribute((unused
)) *button
,
467 gpointer
attribute((unused
)) userdata
) {
468 const char *password
;
469 const char *password2
;
477 name
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_name
)));
478 email
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_email
)));
479 password
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password
)));
480 password2
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password2
)));
482 /* No username. Really we wanted to desensitize the Apply button when
483 * there's no userame but there doesn't seem to be a signal to detect
484 * changes to the entry text. Consequently we have error messages
486 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Must enter a username");
489 if(strcmp(password
, password2
)) {
490 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Passwords do not match");
493 if(*email
&& !strchr(email
, '@')) {
494 /* The server will complain about this but we can give a better error
495 * message this way */
496 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Invalid email address");
499 disorder_eclient_adduser(client
,
500 users_adduser_completed
,
503 rights_string(users_get_rights()),
504 kvp_make("user", name
,
507 /* We switch to no-op mode while creating the user */
511 /* Ugh, can we de-dupe with above? */
512 email
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_email
)));
513 password
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password
)));
514 password2
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password2
)));
515 if(strcmp(password
, password2
)) {
516 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Passwords do not match");
519 if(*email
&& !strchr(email
, '@')) {
520 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Invalid email address");
523 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
524 "email", email
, NULL
);
525 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
526 "password", password
, NULL
);
527 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
528 "rights", rights_string(users_get_rights()), NULL
);
529 /* We remain in edit mode */
534 /** @brief Called when a user has been deleted */
535 static void users_delete_completed(void *v
,
538 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
540 const struct kvp
*const kvp
= v
;
541 const char *const user
= kvp_get(kvp
, "user");
544 if(!users_find_user(user
, iter
)) /* Find the user... */
545 gtk_list_store_remove(users_list
, iter
); /* ...and remove them */
549 /** @brief Called when the 'Delete' button is pressed */
550 static void users_delete(GtkButton
attribute((unused
)) *button
,
551 gpointer
attribute((unused
)) userdata
) {
557 yesno
= gtk_message_dialog_new(GTK_WINDOW(users_window
),
559 GTK_MESSAGE_QUESTION
,
561 "Do you really want to delete user %s?"
562 " This action cannot be undone.",
564 res
= gtk_dialog_run(GTK_DIALOG(yesno
));
565 gtk_widget_destroy(yesno
);
566 if(res
== GTK_RESPONSE_YES
) {
567 disorder_eclient_deluser(client
, users_delete_completed
, users_selected
,
568 kvp_make("user", users_selected
,
573 static void users_got_email(void attribute((unused
)) *v
,
577 popup_protocol_error(0, err
);
581 static void users_got_rights(void attribute((unused
)) *v
,
585 popup_protocol_error(0, err
);
586 users_rights
= value
;
589 static void users_got_password(void attribute((unused
)) *v
,
593 popup_protocol_error(0, err
);
594 /* TODO if an error occurred gathering user info, we should react in some
596 users_password
= value
;
597 users_makedetails(users_selected
,
602 DETAIL_EDITABLE
|DETAIL_VISIBLE
);
606 /** @brief Called when the selection MIGHT have changed */
607 static void users_selection_changed(GtkTreeSelection
attribute((unused
)) *treeselection
,
608 gpointer
attribute((unused
)) user_data
) {
610 char *gselected
, *selected
;
612 /* Identify the current selection */
613 if(gtk_tree_selection_get_selected(users_selection
, 0, &iter
)) {
614 gtk_tree_model_get(GTK_TREE_MODEL(users_list
), &iter
,
616 selected
= xstrdup(gselected
);
620 /* Eliminate no-change cases */
621 if(!selected
&& !users_selected
)
623 if(selected
&& users_selected
&& !strcmp(selected
, users_selected
))
625 /* There's been a change; junk the old data and fetch new data in
627 users_selected
= selected
;
628 users_makedetails("", "", "", "",
632 disorder_eclient_userinfo(client
, users_got_email
, users_selected
,
634 disorder_eclient_userinfo(client
, users_got_rights
, users_selected
,
636 disorder_eclient_userinfo(client
, users_got_password
, users_selected
,
639 mode(NONE
); /* not editing *yet* */
642 static GtkWidget
*users_make_reporter() {
643 if(!users_reporter
) {
644 users_reporter
= gtk_label_new("");
645 gtk_label_set_ellipsize(GTK_LABEL(users_reporter
), PANGO_ELLIPSIZE_END
);
646 gtk_misc_set_alignment(GTK_MISC(users_reporter
), 0.99, 0);
647 g_signal_connect(users_reporter
, "destroy",
648 G_CALLBACK(gtk_widget_destroyed
), &users_reporter
);
650 return users_reporter
;
653 static void users_set_report(const char *msg
) {
654 gtk_label_set_text(GTK_LABEL(users_make_reporter()), msg ? msg
: "");
657 /** @brief Table of buttons below the user list */
658 static struct button users_buttons
[] = {
672 #define NUSERS_BUTTONS (sizeof users_buttons / sizeof *users_buttons)
674 /** @brief Keypress handler */
675 static gboolean
users_keypress(GtkWidget
attribute((unused
)) *widget
,
677 gpointer
attribute((unused
)) user_data
) {
680 switch(event
->keyval
) {
682 gtk_widget_destroy(users_window
);
689 /** @brief Pop up the user management window */
690 void manage_users(void) {
691 GtkWidget
*tree
, *buttons
, *hbox
, *hbox2
, *vbox
, *vbox2
;
693 GtkTreeViewColumn
*col
;
695 /* If the window already exists just raise it */
697 gtk_window_present(GTK_WINDOW(users_window
));
700 /* Destroy old widgets */
702 gtk_widget_destroy(users_reporter
);
703 /* Create the window */
704 users_window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
705 gtk_widget_set_style(users_window
, tool_style
);
706 g_signal_connect(users_window
, "destroy",
707 G_CALLBACK(gtk_widget_destroyed
), &users_window
);
708 gtk_window_set_title(GTK_WINDOW(users_window
), "User Management");
709 /* Keyboard shortcuts */
710 g_signal_connect(users_window
, "key-press-event",
711 G_CALLBACK(users_keypress
), 0);
712 /* default size is too small */
713 gtk_window_set_default_size(GTK_WINDOW(users_window
), 240, 240);
715 /* Create the list of users and populate it asynchronously */
716 users_list
= gtk_list_store_new(1, G_TYPE_STRING
);
717 disorder_eclient_users(client
, users_got_list
, 0);
718 /* Create the view */
719 tree
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(users_list
));
720 /* ...and the renderers for it */
721 cr
= gtk_cell_renderer_text_new();
722 col
= gtk_tree_view_column_new_with_attributes("Username",
726 gtk_tree_view_append_column(GTK_TREE_VIEW(tree
), col
);
727 /* Get the selection for the view; set its mode; arrange for a callback when
729 users_selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree
));
730 gtk_tree_selection_set_mode(users_selection
, GTK_SELECTION_BROWSE
);
731 g_signal_connect(users_selection
, "changed",
732 G_CALLBACK(users_selection_changed
), NULL
);
734 /* Create the control buttons */
735 buttons
= create_buttons_box(users_buttons
,
737 gtk_hbox_new(FALSE
, 1));
738 users_delete_button
= users_buttons
[1].widget
;
740 /* Buttons live below the list */
741 vbox
= gtk_vbox_new(FALSE
, 0);
742 gtk_box_pack_start(GTK_BOX(vbox
), scroll_widget(tree
), TRUE
/*expand*/, TRUE
/*fill*/, 0);
743 gtk_box_pack_start(GTK_BOX(vbox
), buttons
, FALSE
/*expand*/, FALSE
, 0);
745 /* Create an empty user details table, and put an apply button below it */
746 users_apply_button
= gtk_button_new_from_stock(GTK_STOCK_APPLY
);
747 users_makedetails("", "", "", "",
750 g_signal_connect(users_apply_button
, "clicked",
751 G_CALLBACK(users_apply
), NULL
);
752 hbox2
= gtk_hbox_new(FALSE
, 0);
753 gtk_box_pack_end(GTK_BOX(hbox2
), users_apply_button
,
754 FALSE
/*expand*/, FALSE
, 0);
756 vbox2
= gtk_vbox_new(FALSE
, 0);
757 gtk_box_pack_start(GTK_BOX(vbox2
), users_details_table
,
758 TRUE
/*expand*/, TRUE
/*fill*/, 0);
759 gtk_box_pack_start(GTK_BOX(vbox2
), gtk_hseparator_new(),
760 FALSE
/*expand*/, FALSE
, 0);
761 gtk_box_pack_start(GTK_BOX(vbox2
), users_make_reporter(),
762 FALSE
/*expand*/, FALSE
, 0);
763 gtk_box_pack_start(GTK_BOX(vbox2
), hbox2
,
764 FALSE
/*expand*/, FALSE
, 0);
766 /* User details are to the right of the list. We put in a pointless event
767 * box as as spacer, so that the longest label in the user details isn't
768 * cuddled up to the user list. */
769 hbox
= gtk_hbox_new(FALSE
, 0);
770 gtk_box_pack_start(GTK_BOX(hbox
), vbox
, FALSE
/*expand*/, FALSE
, 0);
771 gtk_box_pack_start(GTK_BOX(hbox
), gtk_event_box_new(), FALSE
/*expand*/, FALSE
, 2);
772 gtk_box_pack_start(GTK_BOX(hbox
), vbox2
, TRUE
/*expand*/, TRUE
/*fill*/, 0);
773 gtk_container_add(GTK_CONTAINER(users_window
), frame_widget(hbox
, NULL
));