2 * ROX-Filer, filer for the ROX desktop project
3 * Copyright (C) 2006, Thomas Leonard and others (see changelog for details).
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the Free
7 * Software Foundation; either version 2 of the License, or (at your option)
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
17 * Place, Suite 330, Boston, MA 02111-1307 USA
20 /* toolbar.c - for the button bars that go along the tops of windows */
41 #include "view_iface.h"
42 #include "bookmarks.h"
43 #include "gui_support.h"
45 typedef struct _Tool Tool
;
47 typedef enum {DROP_NONE
, DROP_TO_PARENT
, DROP_TO_HOME
, DROP_BOOKMARK
} DropDest
;
52 const gchar
*tip
; /* Tooltip */
53 void (*clicked
)(GtkWidget
*w
, FilerWindow
*filer_window
);
56 gboolean menu
; /* Activate on button-press */
59 Option o_toolbar
, o_toolbar_info
, o_toolbar_disable
;
60 Option o_toolbar_min_width
;
62 static FilerWindow
*filer_window_being_counted
;
64 /* TRUE if the button presses (or released) should open a new window,
65 * rather than reusing the existing one.
67 #define NEW_WIN_BUTTON(button_event) \
68 (o_new_button_1.int_value \
69 ? ((GdkEventButton *) button_event)->button == 1 \
70 : ((GdkEventButton *) button_event)->button != 1)
72 /* Static prototypes */
73 static void toolbar_close_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
74 static void toolbar_up_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
75 static void toolbar_home_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
76 static void toolbar_bookmarks_clicked(GtkWidget
*widget
,
77 FilerWindow
*filer_window
);
78 static void toolbar_help_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
79 static void toolbar_refresh_clicked(GtkWidget
*widget
,
80 FilerWindow
*filer_window
);
81 static void toolbar_size_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
82 static void toolbar_autosize_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
);
83 static void toolbar_details_clicked(GtkWidget
*widget
,
84 FilerWindow
*filer_window
);
85 static void toolbar_hidden_clicked(GtkWidget
*widget
,
86 FilerWindow
*filer_window
);
87 static void toolbar_select_clicked(GtkWidget
*widget
,
88 FilerWindow
*filer_window
);
89 static void toolbar_sort_clicked(GtkWidget
*widget
,
90 FilerWindow
*filer_window
);
91 static GtkWidget
*add_button(GtkWidget
*bar
, Tool
*tool
,
92 FilerWindow
*filer_window
);
93 static GtkWidget
*create_toolbar(FilerWindow
*filer_window
);
94 static gboolean
drag_motion(GtkWidget
*widget
,
95 GdkDragContext
*context
,
99 FilerWindow
*filer_window
);
100 static void drag_leave(GtkWidget
*widget
,
101 GdkDragContext
*context
,
103 FilerWindow
*filer_window
);
104 static void handle_drops(FilerWindow
*filer_window
,
107 static void toggle_selected(GtkToggleButton
*widget
, gpointer data
);
108 static void option_notify(void);
109 static GList
*build_tool_options(Option
*option
, xmlNode
*node
, guchar
*label
);
110 static void tally_items(gpointer key
, gpointer value
, gpointer data
);
112 static Tool all_tools
[] = {
113 {N_("Close"), GTK_STOCK_CLOSE
, N_("Close filer window"),
114 toolbar_close_clicked
, DROP_NONE
, FALSE
,
117 {N_("Up"), GTK_STOCK_GO_UP
, N_("Change to parent directory"),
118 toolbar_up_clicked
, DROP_TO_PARENT
, TRUE
,
121 {N_("Home"), GTK_STOCK_HOME
, N_("Change to home directory"),
122 toolbar_home_clicked
, DROP_TO_HOME
, TRUE
,
125 {N_("Bookmarks"), ROX_STOCK_BOOKMARKS
, N_("Bookmarks menu"),
126 toolbar_bookmarks_clicked
, DROP_BOOKMARK
, FALSE
,
129 {N_("Scan"), GTK_STOCK_REFRESH
, N_("Rescan directory contents"),
130 toolbar_refresh_clicked
, DROP_NONE
, TRUE
,
133 {N_("Size"), GTK_STOCK_ZOOM_IN
, N_("Change icon size"),
134 toolbar_size_clicked
, DROP_NONE
, TRUE
,
137 {N_("Size"), GTK_STOCK_ZOOM_FIT
, N_("Automatic size mode"),
138 toolbar_autosize_clicked
, DROP_NONE
, TRUE
,
141 {N_("Details"), ROX_STOCK_SHOW_DETAILS
, N_("Show extra details"),
142 toolbar_details_clicked
, DROP_NONE
, TRUE
,
145 {N_("Sort"), GTK_STOCK_SORT_ASCENDING
, N_("Change sort criteria"),
146 toolbar_sort_clicked
, DROP_NONE
, FALSE
,
149 {N_("Hidden"), ROX_STOCK_SHOW_HIDDEN
, N_("Left: Show/hide hidden files\n"
150 "Right: Show/hide thumbnails"),
151 toolbar_hidden_clicked
, DROP_NONE
, TRUE
,
154 {N_("Select"), ROX_STOCK_SELECT
, N_("Select all/invert selection"),
155 toolbar_select_clicked
, DROP_NONE
, FALSE
,
158 {N_("Help"), GTK_STOCK_HELP
, N_("Show ROX-Filer help"),
159 toolbar_help_clicked
, DROP_NONE
, TRUE
,
164 /****************************************************************
165 * EXTERNAL INTERFACE *
166 ****************************************************************/
168 void toolbar_init(void)
170 option_add_int(&o_toolbar
, "toolbar_type", TOOLBAR_NORMAL
);
171 option_add_int(&o_toolbar_info
, "toolbar_show_info", 1);
172 option_add_string(&o_toolbar_disable
, "toolbar_disable",
174 option_add_int(&o_toolbar_min_width
, "toolbar_min_width", 1);
175 option_add_notify(option_notify
);
177 option_register_widget("tool-options", build_tool_options
);
180 void toolbar_update_info(FilerWindow
*filer_window
)
186 g_return_if_fail(filer_window
!= NULL
);
188 if (o_toolbar
.int_value
== TOOLBAR_NONE
|| !o_toolbar_info
.int_value
)
189 return; /* Not showing info */
191 if (filer_window
->target_cb
)
194 view
= filer_window
->view
;
196 n_selected
= view_count_selected(view
);
203 if (filer_window
->scanning
)
206 GTK_LABEL(filer_window
->toolbar_text
), "");
210 if (!(filer_window
->show_hidden
||
211 filer_window
->temp_show_hidden
) ||
212 filer_window
->filter
!=FILER_SHOW_ALL
)
214 GHashTable
*hash
= filer_window
->directory
->known_items
;
217 filer_window_being_counted
=filer_window
;
218 g_hash_table_foreach(hash
, tally_items
, &tally
);
221 s
= g_strdup_printf(_(" (%u hidden)"), tally
);
224 n_items
= view_count_items(view
);
227 label
= g_strdup_printf("%d %s%s",
229 n_items
!= 1 ? _("items") : _("item"),
231 else /* (French plurals work differently for zero) */
232 label
= g_strdup_printf(_("No items%s"),
242 view_get_iter(filer_window
->view
, &iter
, VIEW_ITER_SELECTED
);
244 while ((item
= iter
.next(&iter
)))
246 if (item
->base_type
!= TYPE_DIRECTORY
&&
247 item
->base_type
!= TYPE_UNKNOWN
)
248 size
+= (double) item
->size
;
251 label
= g_strdup_printf(_("%u selected (%s)"),
252 n_selected
, format_double_size(size
));
255 gtk_label_set_text(GTK_LABEL(filer_window
->toolbar_text
), label
);
259 /* Create, destroy or recreate toolbar for this window so that it
260 * matches the option setting.
262 void toolbar_update_toolbar(FilerWindow
*filer_window
)
264 g_return_if_fail(filer_window
!= NULL
);
266 if (filer_window
->toolbar
)
268 gtk_widget_destroy(filer_window
->toolbar
);
269 filer_window
->toolbar
= NULL
;
270 filer_window
->toolbar_text
= NULL
;
273 if (o_toolbar
.int_value
!= TOOLBAR_NONE
)
275 filer_window
->toolbar
= create_toolbar(filer_window
);
276 gtk_box_pack_start(filer_window
->toplevel_vbox
,
277 filer_window
->toolbar
, FALSE
, TRUE
, 0);
278 gtk_box_reorder_child(filer_window
->toplevel_vbox
,
279 filer_window
->toolbar
, 0);
280 gtk_widget_show_all(filer_window
->toolbar
);
283 filer_target_mode(filer_window
, NULL
, NULL
, NULL
);
284 toolbar_update_info(filer_window
);
287 /****************************************************************
288 * INTERNAL FUNCTIONS *
289 ****************************************************************/
291 static void toolbar_help_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
295 event
= gtk_get_current_event();
296 if (event
->type
== GDK_BUTTON_RELEASE
&&
297 ((GdkEventButton
*) event
)->button
!= 1)
298 menu_rox_help(NULL
, HELP_MANUAL
, NULL
);
300 filer_opendir(make_path(app_dir
, "Help"), NULL
, NULL
);
301 gdk_event_free(event
);
304 static void toolbar_refresh_clicked(GtkWidget
*widget
,
305 FilerWindow
*filer_window
)
309 event
= gtk_get_current_event();
310 if (event
->type
== GDK_BUTTON_RELEASE
&&
311 ((GdkEventButton
*) event
)->button
!= 1)
313 filer_opendir(filer_window
->sym_path
, filer_window
, NULL
);
316 filer_refresh(filer_window
);
317 gdk_event_free(event
);
320 static void toolbar_home_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
324 event
= gtk_get_current_event();
325 if (event
->type
== GDK_BUTTON_RELEASE
&& NEW_WIN_BUTTON(event
))
327 filer_opendir(home_dir
, filer_window
, NULL
);
330 filer_change_to(filer_window
, home_dir
, NULL
);
331 gdk_event_free(event
);
334 static void toolbar_bookmarks_clicked(GtkWidget
*widget
,
335 FilerWindow
*filer_window
)
339 g_return_if_fail(filer_window
!= NULL
);
341 event
= gtk_get_current_event();
342 if (event
->type
== GDK_BUTTON_PRESS
&&
343 ((GdkEventButton
*) event
)->button
== 1)
345 bookmarks_show_menu(filer_window
);
347 else if (event
->type
== GDK_BUTTON_RELEASE
&&
348 ((GdkEventButton
*) event
)->button
!= 1)
352 gdk_event_free(event
);
355 static void toolbar_close_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
359 g_return_if_fail(filer_window
!= NULL
);
361 event
= gtk_get_current_event();
362 if (event
->type
== GDK_BUTTON_RELEASE
&&
363 ((GdkEventButton
*) event
)->button
!= 1)
365 filer_opendir(filer_window
->sym_path
, filer_window
, NULL
);
367 else if (!filer_window_delete(filer_window
->window
, NULL
, filer_window
))
368 gtk_widget_destroy(filer_window
->window
);
369 gdk_event_free(event
);
372 static void toolbar_up_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
376 event
= gtk_get_current_event();
377 if (event
->type
== GDK_BUTTON_RELEASE
&& NEW_WIN_BUTTON(event
))
379 filer_open_parent(filer_window
);
382 change_to_parent(filer_window
);
383 gdk_event_free(event
);
386 static void toolbar_autosize_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
390 bev
= (GdkEventButton
*) gtk_get_current_event();
391 if (bev
->type
== GDK_BUTTON_RELEASE
)
393 display_set_layout(filer_window
, AUTO_SIZE_ICONS
, filer_window
->details_type
,
396 gdk_event_free((GdkEvent
*) bev
);
399 static void toolbar_size_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
403 bev
= (GdkEventButton
*) gtk_get_current_event();
404 if (bev
->type
== GDK_BUTTON_RELEASE
)
405 display_change_size(filer_window
, bev
->button
== 1);
406 gdk_event_free((GdkEvent
*) bev
);
409 static void toolbar_sort_clicked(GtkWidget
*widget
,
410 FilerWindow
*filer_window
)
413 int i
, current
, next
, next_wrapped
;
418 static const SortType sorts
[]={
419 SORT_NAME
, SORT_TYPE
, SORT_DATE
, SORT_SIZE
,
420 SORT_OWNER
, SORT_GROUP
,
422 static const char *sort_names
[] = {
423 N_("Sort by name"), N_("Sort by type"), N_("Sort by date"),
424 N_("Sort by size"), N_("Sort by owner"), N_("Sort by group"),
427 bev
= (GdkEventButton
*) gtk_get_current_event();
428 adjust
= (bev
->button
!= 1) && bev
->type
== GDK_BUTTON_RELEASE
;
429 gdk_event_free((GdkEvent
*) bev
);
432 dir
= filer_window
->sort_order
;
433 for (i
=0; i
< G_N_ELEMENTS(sort_names
); i
++)
435 if (filer_window
->sort_type
== sorts
[i
])
449 next_wrapped
= next
% G_N_ELEMENTS(sorts
);
451 if (next_wrapped
!= next
)
452 dir
= (dir
== GTK_SORT_ASCENDING
)
453 ? GTK_SORT_DESCENDING
: GTK_SORT_ASCENDING
;
455 display_set_sort_type(filer_window
, sorts
[next_wrapped
], dir
);
456 tip
= g_strconcat(_(sort_names
[next_wrapped
]), ", ",
457 dir
== GTK_SORT_ASCENDING
458 ? _("ascending") : _("descending"),
464 static void toolbar_details_clicked(GtkWidget
*widget
,
465 FilerWindow
*filer_window
)
467 if (filer_window
->view_type
== VIEW_TYPE_DETAILS
)
468 filer_set_view_type(filer_window
, VIEW_TYPE_COLLECTION
);
470 filer_set_view_type(filer_window
, VIEW_TYPE_DETAILS
);
473 static void toolbar_hidden_clicked(GtkWidget
*widget
,
474 FilerWindow
*filer_window
)
478 event
= gtk_get_current_event();
479 if (event
->type
== GDK_BUTTON_RELEASE
&&
480 ((GdkEventButton
*) event
)->button
== 1)
482 display_set_hidden(filer_window
, !filer_window
->show_hidden
);
486 display_set_thumbs(filer_window
, !filer_window
->show_thumbs
);
490 static gboolean
invert_cb(ViewIter
*iter
, gpointer data
)
492 return !view_get_selected((ViewIface
*) data
, iter
);
495 static void toolbar_select_clicked(GtkWidget
*widget
, FilerWindow
*filer_window
)
499 event
= gtk_get_current_event();
500 if (event
->type
== GDK_BUTTON_RELEASE
)
502 if (((GdkEventButton
*) event
)->button
== 1)
503 view_select_all(filer_window
->view
);
505 view_select_if(filer_window
->view
, invert_cb
,
508 filer_window
->temp_item_selected
= FALSE
;
509 gdk_event_free(event
);
512 /* If filer_window is NULL, the toolbar is for the options window */
513 static GtkWidget
*create_toolbar(FilerWindow
*filer_window
)
520 bar
= gtk_toolbar_new();
522 if (o_toolbar
.int_value
== TOOLBAR_NORMAL
|| !filer_window
)
523 gtk_toolbar_set_style(GTK_TOOLBAR(bar
), GTK_TOOLBAR_ICONS
);
524 else if (o_toolbar
.int_value
== TOOLBAR_HORIZONTAL
)
525 gtk_toolbar_set_style(GTK_TOOLBAR(bar
), GTK_TOOLBAR_BOTH_HORIZ
);
527 gtk_toolbar_set_style(GTK_TOOLBAR(bar
), GTK_TOOLBAR_BOTH
);
530 for (i
= 0; i
< sizeof(all_tools
) / sizeof(*all_tools
); i
++)
532 Tool
*tool
= &all_tools
[i
];
535 if (filer_window
&& !tool
->enabled
)
538 b
= add_button(bar
, tool
, filer_window
);
540 gtk_widget_size_request(b
, &req
);
543 if (filer_window
&& tool
->drop_action
!= DROP_NONE
)
544 handle_drops(filer_window
, b
, tool
->drop_action
);
549 if(o_toolbar_min_width
.int_value
)
551 /* Make the toolbar wide enough for all icons to be
552 seen, plus a little for the (start of the) text
554 gtk_widget_set_size_request(bar
, width
+32, -1);
556 gtk_widget_set_size_request(bar
, 100, -1);
559 filer_window
->toolbar_text
= gtk_label_new("");
560 gtk_misc_set_alignment(GTK_MISC(filer_window
->toolbar_text
),
562 gtk_toolbar_append_widget(GTK_TOOLBAR(bar
),
563 filer_window
->toolbar_text
, NULL
, NULL
);
569 /* This is used to simulate a click when button 3 is used (GtkButton
570 * normally ignores this).
572 static gint toolbar_other_button
= 0;
573 static gint
toolbar_button_pressed(GtkButton
*button
,
574 GdkEventButton
*event
,
575 FilerWindow
*filer_window
)
577 gint b
= event
->button
;
580 tool
= g_object_get_data(G_OBJECT(button
), "rox-tool");
581 g_return_val_if_fail(tool
!= NULL
, TRUE
);
583 if (tool
->menu
&& b
== 1)
585 tool
->clicked((GtkWidget
*) button
, filer_window
);
589 if ((b
== 2 || b
== 3) && toolbar_other_button
== 0)
591 toolbar_other_button
= event
->button
;
592 gtk_grab_add(GTK_WIDGET(button
));
593 gtk_button_pressed(button
);
601 static gint
toolbar_button_released(GtkButton
*button
,
602 GdkEventButton
*event
,
603 FilerWindow
*filer_window
)
605 if (event
->button
== toolbar_other_button
)
607 toolbar_other_button
= 0;
608 gtk_grab_remove(GTK_WIDGET(button
));
609 gtk_button_released(button
);
617 /* If filer_window is NULL, the toolbar is for the options window */
618 static GtkWidget
*add_button(GtkWidget
*bar
, Tool
*tool
,
619 FilerWindow
*filer_window
)
621 GtkWidget
*button
, *icon_widget
;
623 icon_widget
= gtk_image_new_from_stock(tool
->name
,
624 GTK_ICON_SIZE_LARGE_TOOLBAR
);
626 button
= gtk_toolbar_insert_element(GTK_TOOLBAR(bar
),
627 filer_window
? GTK_TOOLBAR_CHILD_BUTTON
628 : GTK_TOOLBAR_CHILD_TOGGLEBUTTON
,
633 NULL
, NULL
, /* CB, userdata */
634 GTK_TOOLBAR(bar
)->num_children
);
635 GTK_WIDGET_UNSET_FLAGS(button
, GTK_CAN_FOCUS
);
637 if (o_toolbar
.int_value
== TOOLBAR_HORIZONTAL
)
639 GtkWidget
*hbox
, *label
;
641 hbox
= GTK_BIN(button
)->child
;
642 kids
= gtk_container_get_children(GTK_CONTAINER(hbox
));
643 label
= g_list_nth_data(kids
, 1);
648 gtk_box_set_child_packing(GTK_BOX(hbox
), label
,
649 TRUE
, TRUE
, 0, GTK_PACK_END
);
650 gtk_misc_set_alignment(GTK_MISC(label
), 0, 0.5);
654 g_object_set_data(G_OBJECT(button
), "rox-tool", tool
);
658 g_signal_connect(button
, "clicked",
659 G_CALLBACK(tool
->clicked
), filer_window
);
660 g_signal_connect(button
, "button_press_event",
661 G_CALLBACK(toolbar_button_pressed
), filer_window
);
662 g_signal_connect(button
, "button_release_event",
663 G_CALLBACK(toolbar_button_released
), filer_window
);
667 g_signal_connect(button
, "clicked",
668 G_CALLBACK(toggle_selected
), NULL
);
669 g_object_set_data(G_OBJECT(button
), "tool_name",
670 (gpointer
) tool
->name
);
676 static void toggle_selected(GtkToggleButton
*widget
, gpointer data
)
678 option_check_widget(&o_toolbar_disable
);
681 /* Called during the drag when the mouse is in a widget registered
682 * as a drop target. Returns TRUE if we can accept the drop.
684 static gboolean
drag_motion(GtkWidget
*widget
,
685 GdkDragContext
*context
,
689 FilerWindow
*filer_window
)
691 GdkDragAction action
= context
->suggested_action
;
693 gpointer type
= (gpointer
) drop_dest_dir
;
695 dest
= (DropDest
) g_object_get_data(G_OBJECT(widget
), "toolbar_dest");
697 if ((context
->actions
& GDK_ACTION_ASK
) && o_dnd_left_menu
.int_value
&&
698 dest
!= DROP_BOOKMARK
)
701 gdk_window_get_pointer(NULL
, NULL
, NULL
, &state
);
702 if (state
& GDK_BUTTON1_MASK
)
703 action
= GDK_ACTION_ASK
;
706 if (dest
== DROP_TO_HOME
)
707 g_dataset_set_data(context
, "drop_dest_path",
709 else if (dest
== DROP_BOOKMARK
)
710 type
= (gpointer
) drop_dest_bookmark
;
712 g_dataset_set_data_full(context
, "drop_dest_path",
713 g_path_get_dirname(filer_window
->sym_path
),
716 g_dataset_set_data(context
, "drop_dest_type", type
);
717 gdk_drag_status(context
, action
, time
);
719 dnd_spring_load(context
, filer_window
);
720 gtk_button_set_relief(GTK_BUTTON(widget
), GTK_RELIEF_NORMAL
);
725 static void drag_leave(GtkWidget
*widget
,
726 GdkDragContext
*context
,
728 FilerWindow
*filer_window
)
730 gtk_button_set_relief(GTK_BUTTON(widget
), GTK_RELIEF_NONE
);
734 static void handle_drops(FilerWindow
*filer_window
,
738 make_drop_target(button
, 0);
739 g_signal_connect(button
, "drag_motion",
740 G_CALLBACK(drag_motion
), filer_window
);
741 g_signal_connect(button
, "drag_leave",
742 G_CALLBACK(drag_leave
), filer_window
);
743 g_object_set_data(G_OBJECT(button
), "toolbar_dest", (gpointer
) dest
);
746 static void tally_items(gpointer key
, gpointer value
, gpointer data
)
748 DirItem
*item
= (DirItem
*) value
;
749 int *tally
= (int *) data
;
751 if (!filer_match_filter(filer_window_being_counted
, item
))
755 static void option_notify(void)
758 gboolean changed
= FALSE
;
759 guchar
*list
= o_toolbar_disable
.value
;
761 for (i
= 0; i
< sizeof(all_tools
) / sizeof(*all_tools
); i
++)
763 Tool
*tool
= &all_tools
[i
];
764 gboolean old
= tool
->enabled
;
766 tool
->enabled
= !in_list(tool
->name
, list
);
768 if (old
!= tool
->enabled
)
772 if (changed
|| o_toolbar
.has_changed
|| o_toolbar_info
.has_changed
)
776 for (next
= all_filer_windows
; next
; next
= next
->next
)
778 FilerWindow
*filer_window
= (FilerWindow
*) next
->data
;
780 toolbar_update_toolbar(filer_window
);
785 static void update_tools(Option
*option
)
789 kids
= gtk_container_get_children(GTK_CONTAINER(option
->widget
));
791 for (next
= kids
; next
; next
= next
->next
)
793 GtkToggleButton
*kid
= (GtkToggleButton
*) next
->data
;
796 name
= g_object_get_data(G_OBJECT(kid
), "tool_name");
798 g_return_if_fail(name
!= NULL
);
800 gtk_toggle_button_set_active(kid
,
801 !in_list(name
, option
->value
));
807 static guchar
*read_tools(Option
*option
)
813 list
= g_string_new(NULL
);
815 kids
= gtk_container_get_children(GTK_CONTAINER(option
->widget
));
817 for (next
= kids
; next
; next
= next
->next
)
819 GtkToggleButton
*kid
= (GtkToggleButton
*) next
->data
;
822 if (!gtk_toggle_button_get_active(kid
))
824 name
= g_object_get_data(G_OBJECT(kid
), "tool_name");
825 g_return_val_if_fail(name
!= NULL
, list
->str
);
828 g_string_append(list
, ", ");
829 g_string_append(list
, name
);
835 g_string_free(list
, FALSE
);
840 static GList
*build_tool_options(Option
*option
, xmlNode
*node
, guchar
*label
)
844 g_return_val_if_fail(option
!= NULL
, NULL
);
846 bar
= create_toolbar(NULL
);
848 option
->update_widget
= update_tools
;
849 option
->read_widget
= read_tools
;
850 option
->widget
= bar
;
852 return g_list_append(NULL
, bar
);