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 * - escape and enter keys should work
39 * - should have a cancel or close button, consistent with properties and login
42 #include "disobedience.h"
46 static void users_details_sensitize_all(void);
47 static void users_set_report(const char *msg
);
49 static GtkWidget
*users_window
;
50 static GtkListStore
*users_list
;
51 static GtkTreeSelection
*users_selection
;
53 static GtkWidget
*users_details_table
;
54 static GtkWidget
*users_apply_button
;
55 static GtkWidget
*users_delete_button
;
56 static GtkWidget
*users_details_name
;
57 static GtkWidget
*users_details_email
;
58 static GtkWidget
*users_details_password
;
59 static GtkWidget
*users_details_password2
;
60 static GtkWidget
*users_details_rights
[32];
61 static GtkWidget
*users_reporter
;
62 static int users_details_row
;
63 static const char *users_selected
;
64 static const char *users_deferred_select
;
66 static int users_mode
;
71 #define mode(X) do { \
72 users_mode = MODE_##X; \
73 if(0) fprintf(stderr, "%s:%d: %s(): mode -> %s\n", \
74 __FILE__, __LINE__, __FUNCTION__, #X); \
75 users_details_sensitize_all(); \
78 static const char *users_email
, *users_rights
, *users_password
;
80 /** @brief qsort() callback for username comparison */
81 static int usercmp(const void *a
, const void *b
) {
82 return strcmp(*(char **)a
, *(char **)b
);
85 /** @brief Find a user
86 * @param user User to find
87 * @param iter Iterator to point at user
88 * @return 0 on success, -1 if not found
90 static int users_find_user(const char *user
,
95 if(!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(users_list
), iter
))
98 gtk_tree_model_get(GTK_TREE_MODEL(users_list
), iter
,
100 if(!strcmp(who
, user
)) {
105 } while(gtk_tree_model_iter_next(GTK_TREE_MODEL(users_list
), iter
));
109 /** @brief Called with the list of users
112 * - at startup to populate the initial list
113 * - when we add a user
114 * - maybe in the future when we delete a user
116 * If users_deferred_select is set then that user is selected.
118 static void users_got_list(void attribute((unused
)) *v
,
120 int nvec
, char **vec
) {
125 popup_protocol_error(0, err
);
128 /* Present users in alphabetical order */
129 qsort(vec
, nvec
, sizeof (char *), usercmp
);
130 /* Set the list contents */
131 gtk_list_store_clear(users_list
);
132 for(n
= 0; n
< nvec
; ++n
)
133 gtk_list_store_insert_with_values(users_list
, &iter
, n
/*position*/,
134 0, vec
[n
], /* column 0 */
135 -1); /* no more columns */
136 /* Only show the window when the list is populated */
137 gtk_widget_show_all(users_window
);
138 if(users_deferred_select
) {
139 if(!users_find_user(users_deferred_select
, &iter
))
140 gtk_tree_selection_select_iter(users_selection
, &iter
);
141 users_deferred_select
= 0;
145 /** @brief Text should be visible */
146 #define DETAIL_VISIBLE 1
148 /** @brief Text should be editable */
149 #define DETAIL_EDITABLE 2
151 /** @brief Add a row to the user detail table */
152 static void users_detail_generic(const char *title
,
153 GtkWidget
*selector
) {
154 const int row
= users_details_row
++;
155 GtkWidget
*const label
= gtk_label_new(title
);
156 gtk_misc_set_alignment(GTK_MISC(label
), 1, 0);
157 gtk_table_attach(GTK_TABLE(users_details_table
),
159 0, 1, /* left/right_attach */
160 row
, row
+1, /* top/bottom_attach */
161 GTK_FILL
, /* xoptions */
163 1, 1); /* x/ypadding */
164 gtk_table_attach(GTK_TABLE(users_details_table
),
166 1, 2, /* left/right_attach */
167 row
, row
+ 1, /* top/bottom_attach */
168 GTK_EXPAND
|GTK_FILL
, /* xoptions */
169 GTK_FILL
, /* yoptions */
170 1, 1); /* x/ypadding */
173 static void users_entry_changed(GtkEditable
attribute((unused
)) *editable
,
174 gpointer
attribute((unused
)) user_data
) {
175 users_details_sensitize_all();
178 /** @brief Add a row to the user details table
179 * @param entryp Where to put GtkEntry
180 * @param title Label for this row
181 * @param value Initial value or NULL
182 * @param flags Flags word
184 static void users_add_detail(GtkWidget
**entryp
,
190 if(!(entry
= *entryp
)) {
191 *entryp
= entry
= gtk_entry_new();
192 g_signal_connect(entry
, "changed",
193 G_CALLBACK(users_entry_changed
), 0);
194 users_detail_generic(title
, entry
);
196 gtk_entry_set_visibility(GTK_ENTRY(entry
),
197 !!(flags
& DETAIL_VISIBLE
));
198 gtk_editable_set_editable(GTK_EDITABLE(entry
),
199 !!(flags
& DETAIL_EDITABLE
));
200 gtk_entry_set_text(GTK_ENTRY(entry
), value ? value
: "");
203 /** @brief Add a checkbox for a right
204 * @param title Label for this row
205 * @param value Current value
206 * @param right Right bit
208 static void users_add_right(const char *title
,
212 GtkWidget
**checkp
= &users_details_rights
[leftmost_bit(right
)];
214 if(!(check
= *checkp
)) {
215 *checkp
= check
= gtk_check_button_new_with_label("");
216 users_detail_generic(title
, check
);
218 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check
), !!(value
& right
));
221 /** @brief Set sensitivity of particular mine/random rights bits */
222 static void users_details_sensitize(rights_type r
) {
223 const int bit
= leftmost_bit(r
);
224 const GtkWidget
*all
= users_details_rights
[bit
];
225 const int sensitive
= (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(all
))
226 && users_mode
!= MODE_NONE
);
228 gtk_widget_set_sensitive(users_details_rights
[bit
+ 1], sensitive
);
229 gtk_widget_set_sensitive(users_details_rights
[bit
+ 2], sensitive
);
232 /** @brief Set sensitivity of everything in sight */
233 static void users_details_sensitize_all(void) {
235 const char *report
= 0;
237 for(n
= 0; n
< 32; ++n
)
238 if(users_details_rights
[n
])
239 gtk_widget_set_sensitive(users_details_rights
[n
], users_mode
!= MODE_NONE
);
240 gtk_widget_set_sensitive(users_details_name
, users_mode
!= MODE_NONE
);
241 gtk_widget_set_sensitive(users_details_email
, users_mode
!= MODE_NONE
);
242 gtk_widget_set_sensitive(users_details_password
, users_mode
!= MODE_NONE
);
243 gtk_widget_set_sensitive(users_details_password2
, users_mode
!= MODE_NONE
);
244 users_details_sensitize(RIGHT_MOVE_ANY
);
245 users_details_sensitize(RIGHT_REMOVE_ANY
);
246 users_details_sensitize(RIGHT_SCRATCH_ANY
);
247 int apply_sensitive
= 1;
248 if(users_mode
== MODE_NONE
)
251 const char *name
= gtk_entry_get_text(GTK_ENTRY(users_details_name
));
252 const char *email
= gtk_entry_get_text(GTK_ENTRY(users_details_email
));
253 const char *pw
= gtk_entry_get_text(GTK_ENTRY(users_details_password
));
254 const char *pw2
= gtk_entry_get_text(GTK_ENTRY(users_details_password2
));
255 /* Username must be filled in */
259 report
= "Must fill in username";
261 /* Passwords must be nontrivial and match */
265 report
= "Must fill in password";
267 if(strcmp(pw
, pw2
)) {
270 report
= "Passwords must match";
272 /* Email address must be somewhat valid */
274 if(!email_valid(email
)) {
276 report
= "Invalid email address";
280 gtk_widget_set_sensitive(users_apply_button
, apply_sensitive
);
281 gtk_widget_set_sensitive(users_delete_button
, !!users_selected
);
282 users_set_report(report
);
285 /** @brief Called when an _ALL widget is toggled
287 * Modifies sensitivity of the corresponding _MINE and _RANDOM widgets. We
288 * just do the lot rather than trying to figure out which one changed,
290 static void users_any_toggled(GtkToggleButton
attribute((unused
)) *togglebutton
,
291 gpointer
attribute((unused
)) user_data
) {
292 users_details_sensitize_all();
295 /** @brief Add a checkbox for a three-right group
296 * @param title Label for this row
297 * @param bits Rights bits (not masked or normalized)
298 * @param mask Mask for this group (must be 7*2^n)
300 static void users_add_right_group(const char *title
,
303 const uint32_t first
= mask
/ 7;
304 const int bit
= leftmost_bit(first
);
305 GtkWidget
**widgets
= &users_details_rights
[bit
], *any
, *mine
, *rnd
;
308 GtkWidget
*hbox
= gtk_hbox_new(FALSE
, 2);
310 any
= widgets
[0] = gtk_check_button_new_with_label("Any");
311 mine
= widgets
[1] = gtk_check_button_new_with_label("Own");
312 rnd
= widgets
[2] = gtk_check_button_new_with_label("Random");
313 gtk_box_pack_start(GTK_BOX(hbox
), any
, FALSE
, FALSE
, 0);
314 gtk_box_pack_start(GTK_BOX(hbox
), mine
, FALSE
, FALSE
, 0);
315 gtk_box_pack_start(GTK_BOX(hbox
), rnd
, FALSE
, FALSE
, 0);
316 users_detail_generic(title
, hbox
);
317 g_signal_connect(any
, "toggled", G_CALLBACK(users_any_toggled
), NULL
);
318 users_details_rights
[bit
] = any
;
319 users_details_rights
[bit
+ 1] = mine
;
320 users_details_rights
[bit
+ 2] = rnd
;
326 /* Discard irrelevant bits */
328 /* Shift down to bits 0-2; the mask is always 3 contiguous bits */
330 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(any
), !!(bits
& 1));
331 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(mine
), !!(bits
& 2));
332 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(rnd
), !!(bits
& 4));
335 /** @brief Called when the details table is destroyed */
336 static void users_details_destroyed(GtkWidget
attribute((unused
)) *widget
,
337 GtkWidget
attribute((unused
)) **wp
) {
338 users_details_table
= 0;
339 g_object_unref(users_list
);
341 users_details_name
= 0;
342 users_details_email
= 0;
343 users_details_password
= 0;
344 users_details_password2
= 0;
345 memset(users_details_rights
, 0, sizeof users_details_rights
);
346 /* also users_selection? Not AFAICT; _get_selection does upref */
349 /** @brief Create or modify the user details table
350 * @param name User name (users_edit()) or NULL (users_add())
351 * @param email Email address
352 * @param rights User rights string
353 * @param password Password
355 static void users_makedetails(const char *name
,
358 const char *password
,
363 /* Create the table if it doesn't already exist */
364 if(!users_details_table
) {
365 users_details_table
= gtk_table_new(4, 2, FALSE
/*!homogeneous*/);
366 g_signal_connect(users_details_table
, "destroy",
367 G_CALLBACK(users_details_destroyed
), 0);
370 /* Create or update the widgets */
371 users_add_detail(&users_details_name
, "Username", name
,
372 (DETAIL_EDITABLE
|DETAIL_VISIBLE
) & nameflags
);
374 users_add_detail(&users_details_email
, "Email", email
,
375 (DETAIL_EDITABLE
|DETAIL_VISIBLE
) & flags
);
377 users_add_detail(&users_details_password
, "Password", password
,
378 DETAIL_EDITABLE
& flags
);
379 users_add_detail(&users_details_password2
, "Password", password
,
380 DETAIL_EDITABLE
& flags
);
382 parse_rights(rights
, &r
, 0);
383 users_add_right("Read operations", r
, RIGHT_READ
);
384 users_add_right("Play track", r
, RIGHT_PLAY
);
385 users_add_right_group("Move", r
, RIGHT_MOVE__MASK
);
386 users_add_right_group("Remove", r
, RIGHT_REMOVE__MASK
);
387 users_add_right_group("Scratch", r
, RIGHT_SCRATCH__MASK
);
388 users_add_right("Set volume", r
, RIGHT_VOLUME
);
389 users_add_right("Admin operations", r
, RIGHT_ADMIN
);
390 users_add_right("Rescan", r
, RIGHT_RESCAN
);
391 users_add_right("Register new users", r
, RIGHT_REGISTER
);
392 users_add_right("Modify own userinfo", r
, RIGHT_USERINFO
);
393 users_add_right("Modify track preferences", r
, RIGHT_PREFS
);
394 users_add_right("Modify global preferences", r
, RIGHT_GLOBAL_PREFS
);
395 users_add_right("Pause/resume tracks", r
, RIGHT_PAUSE
);
396 users_details_sensitize_all();
399 /** @brief Called when the 'add' button is pressed */
400 static void users_add(GtkButton
attribute((unused
)) *button
,
401 gpointer
attribute((unused
)) userdata
) {
402 /* Unselect whatever is selected */
403 gtk_tree_selection_unselect_all(users_selection
);
405 /* TODO it would be better to use the server default_rights if there's no
407 users_makedetails("",
409 config
->default_rights
,
411 DETAIL_EDITABLE
|DETAIL_VISIBLE
,
412 DETAIL_EDITABLE
|DETAIL_VISIBLE
);
413 /* Remember we're adding a user */
417 static rights_type
users_get_rights(void) {
421 /* Extract the rights value */
422 for(n
= 0; n
< 32; ++n
) {
423 if(users_details_rights
[n
])
424 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(users_details_rights
[n
])))
427 /* Throw out redundant bits */
428 if(r
& RIGHT_REMOVE_ANY
)
429 r
&= ~(rights_type
)(RIGHT_REMOVE_MINE
|RIGHT_REMOVE_RANDOM
);
430 if(r
& RIGHT_MOVE_ANY
)
431 r
&= ~(rights_type
)(RIGHT_MOVE_MINE
|RIGHT_MOVE_RANDOM
);
432 if(r
& RIGHT_SCRATCH_ANY
)
433 r
&= ~(rights_type
)(RIGHT_SCRATCH_MINE
|RIGHT_SCRATCH_RANDOM
);
437 /** @brief Called when a user setting has been edited */
438 static void users_edituser_completed(void attribute((unused
)) *v
,
441 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
444 /** @brief Called when a new user has been created */
445 static void users_adduser_completed(void *v
,
448 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
449 mode(ADD
); /* Let the user try again */
451 const struct kvp
*const kvp
= v
;
452 const char *user
= kvp_get(kvp
, "user");
453 const char *email
= kvp_get(kvp
, "email"); /* maybe NULL */
455 /* Now the user is created we can go ahead and set the email address */
457 disorder_eclient_edituser(client
, users_edituser_completed
, user
,
458 "email", email
, NULL
);
459 /* Refresh the list of users */
460 disorder_eclient_users(client
, users_got_list
, 0);
461 /* We'll select the newly created user */
462 users_deferred_select
= user
;
466 /** @brief Called when the 'Apply' button is pressed */
467 static void users_apply(GtkButton
attribute((unused
)) *button
,
468 gpointer
attribute((unused
)) userdata
) {
469 const char *password
;
470 const char *password2
;
478 name
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_name
)));
479 email
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_email
)));
480 password
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password
)));
481 password2
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password2
)));
483 /* No username. Really we wanted to desensitize the Apply button when
484 * there's no userame but there doesn't seem to be a signal to detect
485 * changes to the entry text. Consequently we have error messages
487 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Must enter a username");
490 if(strcmp(password
, password2
)) {
491 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Passwords do not match");
494 if(*email
&& !strchr(email
, '@')) {
495 /* The server will complain about this but we can give a better error
496 * message this way */
497 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Invalid email address");
500 disorder_eclient_adduser(client
,
501 users_adduser_completed
,
504 rights_string(users_get_rights()),
505 kvp_make("user", name
,
508 /* We switch to no-op mode while creating the user */
512 /* Ugh, can we de-dupe with above? */
513 email
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_email
)));
514 password
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password
)));
515 password2
= xstrdup(gtk_entry_get_text(GTK_ENTRY(users_details_password2
)));
516 if(strcmp(password
, password2
)) {
517 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Passwords do not match");
520 if(*email
&& !strchr(email
, '@')) {
521 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, "Invalid email address");
524 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
525 "email", email
, NULL
);
526 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
527 "password", password
, NULL
);
528 disorder_eclient_edituser(client
, users_edituser_completed
, users_selected
,
529 "rights", rights_string(users_get_rights()), NULL
);
530 /* We remain in edit mode */
535 /** @brief Called when a user has been deleted */
536 static void users_delete_completed(void *v
,
539 popup_submsg(users_window
, GTK_MESSAGE_ERROR
, err
);
541 const struct kvp
*const kvp
= v
;
542 const char *const user
= kvp_get(kvp
, "user");
545 if(!users_find_user(user
, iter
)) /* Find the user... */
546 gtk_list_store_remove(users_list
, iter
); /* ...and remove them */
550 /** @brief Called when the 'Delete' button is pressed */
551 static void users_delete(GtkButton
attribute((unused
)) *button
,
552 gpointer
attribute((unused
)) userdata
) {
558 yesno
= gtk_message_dialog_new(GTK_WINDOW(users_window
),
560 GTK_MESSAGE_QUESTION
,
562 "Do you really want to delete user %s?"
563 " This action cannot be undone.",
565 res
= gtk_dialog_run(GTK_DIALOG(yesno
));
566 gtk_widget_destroy(yesno
);
567 if(res
== GTK_RESPONSE_YES
) {
568 disorder_eclient_deluser(client
, users_delete_completed
, users_selected
,
569 kvp_make("user", users_selected
,
574 static void users_got_email(void attribute((unused
)) *v
,
578 popup_protocol_error(0, err
);
582 static void users_got_rights(void attribute((unused
)) *v
,
586 popup_protocol_error(0, err
);
587 users_rights
= value
;
590 static void users_got_password(void attribute((unused
)) *v
,
594 popup_protocol_error(0, err
);
595 /* TODO if an error occurred gathering user info, we should react in some
597 users_password
= value
;
598 users_makedetails(users_selected
,
603 DETAIL_EDITABLE
|DETAIL_VISIBLE
);
607 /** @brief Called when the selection MIGHT have changed */
608 static void users_selection_changed(GtkTreeSelection
attribute((unused
)) *treeselection
,
609 gpointer
attribute((unused
)) user_data
) {
611 char *gselected
, *selected
;
613 /* Identify the current selection */
614 if(gtk_tree_selection_get_selected(users_selection
, 0, &iter
)) {
615 gtk_tree_model_get(GTK_TREE_MODEL(users_list
), &iter
,
617 selected
= xstrdup(gselected
);
621 /* Eliminate no-change cases */
622 if(!selected
&& !users_selected
)
624 if(selected
&& users_selected
&& !strcmp(selected
, users_selected
))
626 /* There's been a change; junk the old data and fetch new data in
628 users_selected
= selected
;
629 users_makedetails("", "", "", "",
633 disorder_eclient_userinfo(client
, users_got_email
, users_selected
,
635 disorder_eclient_userinfo(client
, users_got_rights
, users_selected
,
637 disorder_eclient_userinfo(client
, users_got_password
, users_selected
,
640 mode(NONE
); /* not editing *yet* */
643 static GtkWidget
*users_make_reporter() {
644 if(!users_reporter
) {
645 users_reporter
= gtk_label_new("");
646 gtk_label_set_ellipsize(GTK_LABEL(users_reporter
), PANGO_ELLIPSIZE_END
);
647 gtk_misc_set_alignment(GTK_MISC(users_reporter
), 0.99, 0);
648 g_signal_connect(users_reporter
, "destroy",
649 G_CALLBACK(gtk_widget_destroyed
), &users_reporter
);
651 return users_reporter
;
654 static void users_set_report(const char *msg
) {
655 gtk_label_set_text(GTK_LABEL(users_make_reporter()), msg ? msg
: "");
658 /** @brief Table of buttons below the user list */
659 static struct button users_buttons
[] = {
673 #define NUSERS_BUTTONS (sizeof users_buttons / sizeof *users_buttons)
675 /** @brief Pop up the user management window */
676 void manage_users(void) {
677 GtkWidget
*tree
, *buttons
, *hbox
, *hbox2
, *vbox
, *vbox2
;
679 GtkTreeViewColumn
*col
;
681 /* If the window already exists just raise it */
683 gtk_window_present(GTK_WINDOW(users_window
));
686 /* Destroy old widgets */
688 gtk_widget_destroy(users_reporter
);
689 /* Create the window */
690 users_window
= gtk_window_new(GTK_WINDOW_TOPLEVEL
);
691 gtk_widget_set_style(users_window
, tool_style
);
692 g_signal_connect(users_window
, "destroy",
693 G_CALLBACK(gtk_widget_destroyed
), &users_window
);
694 gtk_window_set_title(GTK_WINDOW(users_window
), "User Management");
695 /* default size is too small */
696 gtk_window_set_default_size(GTK_WINDOW(users_window
), 240, 240);
698 /* Create the list of users and populate it asynchronously */
699 users_list
= gtk_list_store_new(1, G_TYPE_STRING
);
700 disorder_eclient_users(client
, users_got_list
, 0);
701 /* Create the view */
702 tree
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(users_list
));
703 /* ...and the renderers for it */
704 cr
= gtk_cell_renderer_text_new();
705 col
= gtk_tree_view_column_new_with_attributes("Username",
709 gtk_tree_view_append_column(GTK_TREE_VIEW(tree
), col
);
710 /* Get the selection for the view; set its mode; arrange for a callback when
712 users_selection
= gtk_tree_view_get_selection(GTK_TREE_VIEW(tree
));
713 gtk_tree_selection_set_mode(users_selection
, GTK_SELECTION_BROWSE
);
714 g_signal_connect(users_selection
, "changed",
715 G_CALLBACK(users_selection_changed
), NULL
);
717 /* Create the control buttons */
718 buttons
= create_buttons_box(users_buttons
,
720 gtk_hbox_new(FALSE
, 1));
721 users_delete_button
= users_buttons
[1].widget
;
723 /* Buttons live below the list */
724 vbox
= gtk_vbox_new(FALSE
, 0);
725 gtk_box_pack_start(GTK_BOX(vbox
), scroll_widget(tree
), TRUE
/*expand*/, TRUE
/*fill*/, 0);
726 gtk_box_pack_start(GTK_BOX(vbox
), buttons
, FALSE
/*expand*/, FALSE
, 0);
728 /* Create an empty user details table, and put an apply button below it */
729 users_apply_button
= gtk_button_new_from_stock(GTK_STOCK_APPLY
);
730 users_makedetails("", "", "", "",
733 g_signal_connect(users_apply_button
, "clicked",
734 G_CALLBACK(users_apply
), NULL
);
735 hbox2
= gtk_hbox_new(FALSE
, 0);
736 gtk_box_pack_end(GTK_BOX(hbox2
), users_apply_button
,
737 FALSE
/*expand*/, FALSE
, 0);
739 vbox2
= gtk_vbox_new(FALSE
, 0);
740 gtk_box_pack_start(GTK_BOX(vbox2
), users_details_table
,
741 TRUE
/*expand*/, TRUE
/*fill*/, 0);
742 gtk_box_pack_start(GTK_BOX(vbox2
), gtk_hseparator_new(),
743 FALSE
/*expand*/, FALSE
, 0);
744 gtk_box_pack_start(GTK_BOX(vbox2
), users_make_reporter(),
745 FALSE
/*expand*/, FALSE
, 0);
746 gtk_box_pack_start(GTK_BOX(vbox2
), hbox2
,
747 FALSE
/*expand*/, FALSE
, 0);
749 /* User details are to the right of the list. We put in a pointless event
750 * box as as spacer, so that the longest label in the user details isn't
751 * cuddled up to the user list. */
752 hbox
= gtk_hbox_new(FALSE
, 0);
753 gtk_box_pack_start(GTK_BOX(hbox
), vbox
, FALSE
/*expand*/, FALSE
, 0);
754 gtk_box_pack_start(GTK_BOX(hbox
), gtk_event_box_new(), FALSE
/*expand*/, FALSE
, 2);
755 gtk_box_pack_start(GTK_BOX(hbox
), vbox2
, TRUE
/*expand*/, TRUE
/*fill*/, 0);
756 gtk_container_add(GTK_CONTAINER(users_window
), frame_widget(hbox
, NULL
));