2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2002 Hiroyuki Yamamoto & the Sylpheed-Claws team
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,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU 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, USA.
21 * General functions for accessing address book files.
32 #include <gtk/gtkoptionmenu.h>
33 #include <gdk/gdkkeysyms.h>
38 #include "stock_pixmap.h"
39 #include "manage_window.h"
41 #include "mainwindow.h"
42 #include "alertpanel.h"
43 #include "prefs_common.h"
48 #include "prefs_toolbar.h"
56 } DisplayedItemsColumnPos;
58 # define N_DISPLAYED_ITEMS_COLS 4
60 static struct _Toolbar {
63 GtkWidget *clist_icons;
65 GtkWidget *combo_action;
66 GtkWidget *combo_entry;
67 GtkWidget *combo_list;
68 GtkWidget *label_icon_text;
69 GtkWidget *label_action_sel;
70 GtkWidget *entry_icon_text;
71 GtkWidget *combo_syl_action;
72 GtkWidget *combo_syl_list;
73 GtkWidget *combo_syl_entry;
77 #define CELL_SPACING 24
78 #define ERROR_MSG _("Selected Action already set.\nPlease choose another Action from List")
80 static void prefs_toolbar_open (void);
81 static void prefs_toolbar_populate (void);
82 static gboolean is_duplicate (gchar *chosen_action);
83 static void prefs_toolbar_save (void);
85 static void prefs_toolbar_ok (GtkButton *button,
87 static void prefs_toolbar_cancel (GtkButton *button,
89 static void prefs_toolbar_default (GtkButton *button,
92 static void prefs_toolbar_register (GtkButton *button,
94 static void prefs_toolbar_substitute (GtkButton *button,
96 static void prefs_toolbar_delete (GtkButton *button,
99 static void prefs_toolbar_up (GtkButton *button,
102 static void prefs_toolbar_down (GtkButton *button,
105 static void prefs_toolbar_select_row_set (GtkCList *clist,
111 static void prefs_toolbar_select_row_icons (GtkCList *clist,
117 static void prefs_toolbar_create (void);
119 static void prefs_toolbar_selection_changed (GtkList *list,
122 static gint prefs_toolbar_key_pressed (GtkWidget *widget,
126 void prefs_toolbar(void)
128 toolbar_read_config_file();
129 prefs_toolbar_open();
132 static void prefs_toolbar_open(void)
134 if (!mtoolbar.window)
135 prefs_toolbar_create();
137 manage_window_set_transient(GTK_WINDOW(mtoolbar.window));
138 prefs_toolbar_populate();
139 gtk_widget_show(mtoolbar.window);
142 void prefs_toolbar_close(void)
144 main_window_reflect_prefs_all_real(TRUE);
145 gtk_widget_hide(mtoolbar.window);
148 static void prefs_toolbar_set_displayed(void)
154 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
156 gtk_clist_clear(clist_set);
157 gtk_clist_freeze(clist_set);
159 /* set currently active toolbar entries */
160 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
161 ToolbarItem *item = (ToolbarItem*) cur->data;
163 if (g_strcasecmp(item->file, SEPARATOR) != 0) {
165 StockPixmap icon = stock_pixmap_get_icon(item->file);
167 stock_pixmap_gdk(mtoolbar.clist_set, icon,
169 activ[0] = g_strdup("");
170 activ[1] = g_strdup(item->file);
171 activ[2] = g_strdup(item->text);
172 activ[3] = g_strdup(toolbar_ret_descr_from_val(item->action));
173 row_num = gtk_clist_append(clist_set, activ);
174 gtk_clist_set_pixmap(clist_set,
175 row_num, 0, xpm, xpmmask);
178 activ[0] = g_strdup(SEPARATOR_PIXMAP);
179 activ[1] = g_strdup(item->file);
180 activ[2] = g_strdup("");
181 activ[3] = g_strdup("");
182 gtk_clist_append(clist_set, activ);
191 gtk_clist_thaw(clist_set);
192 gtk_clist_columns_autosize(clist_set);
193 gtk_clist_set_row_height(clist_set, CELL_SPACING);
194 gtk_clist_select_row(clist_set, 0, 0);
197 static void prefs_toolbar_populate(void)
201 GList *combo_action_items;
202 GList *syl_actions = NULL;
203 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
209 gtk_clist_clear(clist_icons);
210 gtk_clist_freeze(clist_icons);
212 /* set available icons */
213 avail[0] = g_strdup(SEPARATOR_PIXMAP);
214 avail[1] = g_strdup(SEPARATOR);
215 gtk_clist_append(clist_icons, avail);
219 combo_action_items = toolbar_get_action_items();
220 gtk_combo_set_popdown_strings(GTK_COMBO(mtoolbar.combo_action), combo_action_items);
221 gtk_combo_set_value_in_list(GTK_COMBO(mtoolbar.combo_action), 0, FALSE);
222 gtk_entry_set_text(GTK_ENTRY(mtoolbar.combo_entry), combo_action_items->data);
223 g_list_free(combo_action_items);
225 /* get currently defined sylpheed actions */
226 if (prefs_common.actions_list != NULL) {
228 for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
229 act = (gchar *)cur->data;
230 syl_actions = g_list_append(syl_actions, act);
233 gtk_combo_set_popdown_strings(GTK_COMBO(mtoolbar.combo_syl_action), syl_actions);
234 gtk_combo_set_value_in_list(GTK_COMBO(mtoolbar.combo_syl_action), 0, FALSE);
235 gtk_entry_set_text(GTK_ENTRY(mtoolbar.combo_syl_entry), syl_actions->data);
236 prefs_toolbar_selection_changed(GTK_LIST(mtoolbar.combo_syl_list), NULL);
237 g_list_free(syl_actions);
240 for (i = 0; i < N_STOCK_PIXMAPS; i++) {
241 avail[0] = g_strdup("");
242 avail[1] = g_strdup(stock_pixmap_get_name((StockPixmap)i));
244 stock_pixmap_gdk(mtoolbar.clist_icons, i,
246 gtk_clist_append(clist_icons, avail);
247 gtk_clist_set_pixmap(clist_icons,
248 i + 1, 0, xpm, xpmmask);
254 gtk_clist_thaw(clist_icons);
255 gtk_clist_columns_autosize(clist_icons);
256 gtk_clist_set_row_height(clist_icons, CELL_SPACING);
257 gtk_clist_select_row(clist_icons, 0, 0);
259 prefs_toolbar_set_displayed();
261 toolbar_clear_list();
264 static gboolean is_duplicate(gchar *chosen_action)
266 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
269 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
271 g_return_val_if_fail(chosen_action != NULL, TRUE);
272 if (clist->rows == 0)
275 /* allow duplicate entries (A_SYL_ACTIONS) */
276 if (g_strcasecmp(syl_act, chosen_action) == 0)
280 gtk_clist_get_text(clist, row, 3, &entry);
281 if ( g_strcasecmp(chosen_action, entry) == 0)
284 } while ((gtk_clist_get_text(clist, row, 3, &entry)) && (row <= clist->rows));
289 static void prefs_toolbar_save(void)
292 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
295 toolbar_clear_list();
297 if (clist->rows == 0) {
298 toolbar_set_default_toolbar();
302 ToolbarItem *toolbar_item = g_new0(ToolbarItem, 1);
304 gtk_clist_get_text(clist, row, 1, &entry);
305 toolbar_item->file = g_strdup(entry);
307 gtk_clist_get_text(clist, row, 2, &entry);
308 toolbar_item->text = g_strdup(entry);
310 gtk_clist_get_text(clist, row, 3, &entry);
311 toolbar_item->action = toolbar_ret_val_from_descr(entry);
313 /* TODO: save A_SYL_ACTIONS only if they are still active */
315 toolbar_list = g_slist_append(toolbar_list, toolbar_item);
318 } while(gtk_clist_get_text(clist, row, 3, &entry));
321 toolbar_save_config_file();
324 static void prefs_toolbar_ok(GtkButton *button, gpointer data)
326 prefs_toolbar_save();
327 prefs_toolbar_close();
330 static void prefs_toolbar_cancel(GtkButton *button, gpointer data)
332 prefs_toolbar_close();
335 static void prefs_toolbar_default(GtkButton *button, gpointer data)
337 toolbar_clear_list();
338 toolbar_set_default_toolbar();
339 prefs_toolbar_set_displayed();
342 static void get_action_name(gchar *entry, gchar **menu)
346 if (prefs_common.actions_list != NULL) {
348 act = g_strdup(entry);
349 act_p = strstr(act, ": ");
352 /* freed by calling func */
357 static void prefs_toolbar_register(GtkButton *button, gpointer data)
359 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
360 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
361 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
366 gchar *item[4] = {NULL, NULL, NULL, NULL};
368 if (clist_icons->rows == 0) return;
370 if (clist_icons->selection) {
371 if (clist_icons->selection->data)
372 row_icons = GPOINTER_TO_INT(clist_icons->selection->data);
376 gtk_clist_get_text(clist_icons, row_icons, 1, &item[1]);
377 item[3] = g_strdup(gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_entry)));
379 /* SEPARATOR or other ? */
380 if (g_strcasecmp(item[1], SEPARATOR) == 0) {
381 item[0] = g_strdup(SEPARATOR_PIXMAP);
382 item[2] = g_strdup("");
383 item[3] = g_strdup("");
385 row_set = gtk_clist_append(GTK_CLIST(mtoolbar.clist_set), item);
390 if (is_duplicate(item[3])) {
391 alertpanel_error(ERROR_MSG);
396 stock_pixmap_gdk(mtoolbar.clist_set, stock_pixmap_get_icon(item[1]),
399 if (g_strcasecmp(item[3], syl_act) == 0) {
401 gchar *entry = gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_syl_entry));
402 get_action_name(entry, &item[2]);
405 item[2] = g_strdup(gtk_entry_get_text(GTK_ENTRY(mtoolbar.entry_icon_text)));
408 row_set = gtk_clist_append(GTK_CLIST(mtoolbar.clist_set), item);
409 gtk_clist_set_pixmap(clist_set, row_set, 0, xpm, xpmmask);
412 gtk_clist_moveto(clist_set, row_set, 0, row_set/clist_set->rows, 0);
413 gtk_clist_select_row(clist_set, row_set, 0);
419 static void prefs_toolbar_substitute(GtkButton *button, gpointer data)
421 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
422 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
423 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
428 gchar *item[4] = {NULL, NULL, NULL, NULL};
431 /* no rows or nothing selected */
432 if ((clist_set->rows == 0) || (clist_set->selection == 0)) return;
434 if (clist_icons->selection) {
435 if (clist_icons->selection->data)
436 row_icons = GPOINTER_TO_INT(clist_icons->selection->data);
440 if (clist_set->selection) {
441 if (clist_set->selection->data)
442 row_set = GPOINTER_TO_INT(clist_set->selection->data);
446 gtk_clist_get_text(clist_icons, row_icons, 1, &item[1]);
447 gtk_clist_get_text(clist_set, row_set, 3, &ac_set);
448 item[3] = g_strdup(gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_entry)));
450 if (g_strcasecmp(item[1], SEPARATOR) == 0) {
451 item[0] = g_strdup(SEPARATOR_PIXMAP);
452 item[2] = g_strdup("");
453 item[3] = g_strdup("");
455 gtk_clist_remove(clist_set, row_set);
456 row_set = gtk_clist_insert(clist_set, row_set, item);
461 if ((is_duplicate(item[3])) && (g_strcasecmp(item[3], ac_set) != 0)){
462 alertpanel_error(ERROR_MSG);
467 stock_pixmap_gdk(mtoolbar.clist_set, stock_pixmap_get_icon(item[1]),
470 if (g_strcasecmp(item[3], syl_act) == 0) {
472 gchar *entry = gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_syl_entry));
473 get_action_name(entry, &item[2]);
475 item[2] = g_strdup(gtk_entry_get_text(GTK_ENTRY(mtoolbar.entry_icon_text)));
478 gtk_clist_remove(clist_set, row_set);
479 row_set = gtk_clist_insert(clist_set, row_set, item);
480 gtk_clist_set_pixmap(clist_set, row_set, 0, xpm, xpmmask);
483 gtk_clist_moveto(clist_set, row_set, 0, row_set/clist_set->rows, 0);
484 gtk_clist_select_row(clist_set, row_set, 0);
490 static void prefs_toolbar_delete(GtkButton *button, gpointer data)
492 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
495 if (clist_set->rows == 0) return;
496 if (clist_set->selection) {
497 if (clist_set->selection->data)
498 row_set = GPOINTER_TO_INT(clist_set->selection->data);
502 if (clist_set->row_list != NULL) {
504 row_set = GPOINTER_TO_INT(clist_set->selection->data);
505 gtk_clist_remove(clist_set, row_set);
506 gtk_clist_columns_autosize(clist_set);
508 if (clist_set->rows > 0)
509 gtk_clist_select_row(clist_set,(row_set == 0) ? 0:row_set - 1, 0);
513 static void prefs_toolbar_up(GtkButton *button, gpointer data)
515 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
518 if (!clist->selection) return;
519 if (clist->selection->data)
520 row = GPOINTER_TO_INT(clist->selection->data);
523 gtk_clist_row_move(clist, row, row - 1);
524 if(gtk_clist_row_is_visible(clist, row - 1) != GTK_VISIBILITY_FULL) {
525 gtk_clist_moveto(clist, row - 1, 0, 0, 0);
530 static void prefs_toolbar_down(GtkButton *button, gpointer data)
532 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
535 if (!clist->selection) return;
536 if (clist->selection->data)
537 row = GPOINTER_TO_INT(clist->selection->data);
539 if (row >= 0 && row < clist->rows - 1) {
540 gtk_clist_row_move(clist, row, row + 1);
541 if(gtk_clist_row_is_visible(clist, row + 1) != GTK_VISIBILITY_FULL) {
542 gtk_clist_moveto(clist, row + 1, 0, 1, 0);
547 static void prefs_toolbar_select_row_set(GtkCList *clist, gint row, gint column,
548 GdkEvent *event, gpointer user_data)
550 GtkCList *clist_ico = GTK_CLIST(mtoolbar.clist_icons);
551 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
554 gchar *file, *icon_text, *descr, *entry;
556 if (clist->selection->data)
557 row_set = GPOINTER_TO_INT(clist->selection->data);
559 gtk_clist_get_text(clist, row_set, 1, &file);
560 gtk_clist_get_text(clist, row_set, 2, &icon_text);
561 gtk_clist_get_text(clist, row_set, 3, &descr);
563 if (g_strcasecmp(descr, syl_act) != 0)
564 gtk_entry_set_text(GTK_ENTRY(mtoolbar.entry_icon_text), icon_text);
566 gtk_list_select_item(GTK_LIST(mtoolbar.combo_list),
567 toolbar_ret_val_from_descr(descr));
569 gtk_clist_get_text(clist_ico, row_ico, 1, &entry);
571 } while(g_strcasecmp(entry, file) != 0);
573 gtk_clist_select_row(clist_ico, row_ico - 1, 0);
574 gtk_clist_moveto(clist_ico, row_ico - 1, 0, row_ico/clist_ico->rows, 0);
577 static void prefs_toolbar_select_row_icons(GtkCList *clist, gint row, gint column,
578 GdkEvent *event, gpointer user_data)
580 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
583 gtk_clist_get_text(clist_icons, row, 1, &text);
588 if (g_strcasecmp(SEPARATOR, text) == 0) {
589 gtk_widget_set_sensitive(mtoolbar.combo_action, FALSE);
590 gtk_widget_set_sensitive(mtoolbar.entry_icon_text, FALSE);
591 gtk_widget_set_sensitive(mtoolbar.combo_syl_action, FALSE);
593 gtk_widget_set_sensitive(mtoolbar.combo_action, TRUE);
594 gtk_widget_set_sensitive(mtoolbar.entry_icon_text, TRUE);
595 gtk_widget_set_sensitive(mtoolbar.combo_syl_action, TRUE);
599 static void prefs_toolbar_selection_changed(GtkList *list,
603 gchar *cur_entry = g_strdup(gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_entry)));
604 gchar *actions_entry = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
606 gtk_widget_set_sensitive(mtoolbar.combo_syl_action, TRUE);
608 if (g_strcasecmp(cur_entry, actions_entry) == 0) {
609 gtk_widget_hide(mtoolbar.entry_icon_text);
610 gtk_widget_show(mtoolbar.combo_syl_action);
611 gtk_label_set_text(GTK_LABEL(mtoolbar.label_icon_text), _("Sylpheed Action"));
613 if (prefs_common.actions_list == NULL) {
614 gtk_widget_set_sensitive(mtoolbar.combo_syl_action, FALSE);
618 gtk_widget_hide(mtoolbar.combo_syl_action);
619 gtk_widget_show(mtoolbar.entry_icon_text);
620 gtk_label_set_text(GTK_LABEL(mtoolbar.label_icon_text), _("Toolbar text"));
623 gtk_misc_set_alignment(GTK_MISC(mtoolbar.label_icon_text), 1, 0.5);
624 gtk_widget_show(mtoolbar.label_icon_text);
628 static gint prefs_toolbar_key_pressed(GtkWidget *widget,
632 if (event && event->keyval == GDK_Escape) {
633 prefs_toolbar_close();
639 static void prefs_toolbar_create(void)
642 GtkWidget *main_vbox;
644 GtkWidget *compose_frame;
649 GtkWidget *subst_btn;
651 GtkWidget *vbox_frame;
653 GtkWidget *scrolledwindow_clist_icon;
654 GtkWidget *clist_icons;
655 GtkWidget *label_icon_text;
656 GtkWidget *entry_icon_text;
657 GtkWidget *label_action_sel;
658 GtkWidget *empty_label;
659 GtkWidget *combo_action;
660 GtkWidget *combo_entry;
661 GtkWidget *combo_list;
662 GtkWidget *combo_syl_action;
663 GtkWidget *combo_syl_entry;
664 GtkWidget *combo_syl_list;
665 GtkWidget *frame_toolbar_items;
666 GtkWidget *hbox_bottom;
667 GtkWidget *scrolledwindow_clist_set;
668 GtkWidget *clist_set;
674 GtkWidget *confirm_area;
676 GtkWidget *cancel_btn;
677 GtkWidget *default_btn;
679 gchar *titles[N_DISPLAYED_ITEMS_COLS];
681 debug_print("Creating custom toolbar window...\n");
683 window = gtk_window_new(GTK_WINDOW_DIALOG);
684 gtk_widget_set_usize(window, 450, -1);
685 gtk_container_set_border_width(GTK_CONTAINER(window), 8);
686 gtk_window_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
687 gtk_window_set_title(GTK_WINDOW(window), _("Customize toolbar"));
688 gtk_window_set_modal(GTK_WINDOW(window), TRUE);
689 gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, TRUE);
690 gtk_signal_connect(GTK_OBJECT(window), "delete_event",
691 GTK_SIGNAL_FUNC(prefs_toolbar_cancel),
693 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
694 GTK_SIGNAL_FUNC(prefs_toolbar_key_pressed),
696 MANAGE_WINDOW_SIGNALS_CONNECT(window);
697 gtk_widget_realize(window);
699 main_vbox = gtk_vbox_new(FALSE, 0);
700 gtk_widget_show(main_vbox);
701 gtk_container_add(GTK_CONTAINER(window), main_vbox);
703 top_hbox = gtk_hbox_new(FALSE, 0);
704 gtk_box_pack_start(GTK_BOX(main_vbox), top_hbox, TRUE, TRUE, 0);
706 compose_frame = gtk_frame_new(_("Available toolbar items"));
707 gtk_box_pack_start(GTK_BOX(top_hbox), compose_frame, TRUE, TRUE, 0);
708 gtk_container_set_border_width(GTK_CONTAINER(compose_frame), 5);
710 vbox_frame = gtk_vbox_new(FALSE, 0);
711 gtk_container_add(GTK_CONTAINER(compose_frame), vbox_frame);
713 /* available icons */
714 scrolledwindow_clist_icon = gtk_scrolled_window_new(NULL, NULL);
715 gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow_clist_icon), 5);
716 gtk_container_add(GTK_CONTAINER(vbox_frame), scrolledwindow_clist_icon);
717 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_clist_icon),
718 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
720 clist_icons = gtk_clist_new(2);
721 gtk_container_add(GTK_CONTAINER(scrolledwindow_clist_icon), clist_icons);
722 gtk_container_set_border_width(GTK_CONTAINER(clist_icons), 1);
723 gtk_clist_set_column_width(GTK_CLIST(clist_icons), 0, 35);
724 gtk_clist_set_column_width(GTK_CLIST(clist_icons), 1, 200);
725 gtk_clist_column_titles_hide(GTK_CLIST(clist_icons));
726 gtk_widget_set_usize(clist_icons, 225, 108);
728 table = gtk_table_new (2, 3, FALSE);
729 gtk_container_add (GTK_CONTAINER (vbox_frame), table);
730 gtk_container_set_border_width (GTK_CONTAINER (table), 8);
731 gtk_table_set_row_spacings (GTK_TABLE (table), 8);
732 gtk_table_set_col_spacings (GTK_TABLE (table), 8);
734 /* icon description */
735 label_icon_text = gtk_label_new("");
736 gtk_misc_set_alignment(GTK_MISC(label_icon_text), 0, 0.5);
737 gtk_widget_show (label_icon_text);
738 gtk_table_attach (GTK_TABLE (table), label_icon_text, 0, 1, 0, 1,
739 (GtkAttachOptions) (GTK_FILL),
740 (GtkAttachOptions) (0), 0, 0);
742 entry_icon_text = gtk_entry_new();
743 gtk_table_attach (GTK_TABLE (table), entry_icon_text, 1, 2, 0, 1,
744 (GtkAttachOptions) (/*GTK_EXPAND | */GTK_FILL),
745 (GtkAttachOptions) (0), 0, 0);
747 /* Sylpheed Action Combo Box */
748 combo_syl_action = gtk_combo_new();
749 combo_syl_list = GTK_COMBO(combo_syl_action)->list;
750 combo_syl_entry = GTK_COMBO(combo_syl_action)->entry;
751 gtk_entry_set_editable(GTK_ENTRY(combo_syl_entry), FALSE);
752 gtk_table_attach (GTK_TABLE (table), combo_syl_action, 1, 2, 0, 1,
753 (GtkAttachOptions) (/*GTK_EXPAND | */GTK_FILL),
754 (GtkAttachOptions) (0), 0, 0);
756 empty_label = gtk_label_new("");
757 gtk_table_attach (GTK_TABLE (table), empty_label, 2, 3, 0, 1,
758 (GtkAttachOptions) (GTK_EXPAND),
759 (GtkAttachOptions) (0), 0, 0);
760 /* available actions */
761 label_action_sel = gtk_label_new(_("Event executed on click"));
762 gtk_misc_set_alignment(GTK_MISC(label_action_sel), 0, 0.5);
763 gtk_table_attach (GTK_TABLE (table), label_action_sel, 0, 1, 1, 2,
764 (GtkAttachOptions) (GTK_FILL),
765 (GtkAttachOptions) (0), 0, 0);
767 combo_action = gtk_combo_new();
768 gtk_table_attach (GTK_TABLE (table), combo_action, 1, 2, 1, 2,
769 (GtkAttachOptions) (GTK_FILL),
770 (GtkAttachOptions) (0), 0, 0);
772 combo_list = GTK_COMBO(combo_action)->list;
773 combo_entry = GTK_COMBO(combo_action)->entry;
774 gtk_entry_set_editable(GTK_ENTRY(combo_entry), FALSE);
776 empty_label = gtk_label_new("");
777 gtk_table_attach (GTK_TABLE (table), empty_label, 2, 3, 1, 2,
778 (GtkAttachOptions) (GTK_EXPAND),
779 (GtkAttachOptions) (0), 0, 0);
781 /* register / substitute / delete */
782 reg_hbox = gtk_hbox_new(FALSE, 4);
783 gtk_box_pack_start(GTK_BOX(main_vbox), reg_hbox, FALSE, FALSE, 0);
784 gtk_container_set_border_width(GTK_CONTAINER(reg_hbox), 10);
786 arrow = gtk_arrow_new(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
787 gtk_box_pack_start(GTK_BOX(reg_hbox), arrow, FALSE, FALSE, 0);
788 gtk_widget_set_usize(arrow, -1, 16);
790 btn_hbox = gtk_hbox_new(TRUE, 4);
791 gtk_box_pack_start(GTK_BOX(reg_hbox), btn_hbox, FALSE, FALSE, 0);
793 reg_btn = gtk_button_new_with_label(_("Register"));
794 gtk_box_pack_start(GTK_BOX(btn_hbox), reg_btn, FALSE, TRUE, 0);
795 gtk_signal_connect(GTK_OBJECT(reg_btn), "clicked",
796 GTK_SIGNAL_FUNC(prefs_toolbar_register),
799 subst_btn = gtk_button_new_with_label(_(" Substitute "));
800 gtk_box_pack_start(GTK_BOX(btn_hbox), subst_btn, FALSE, TRUE, 0);
801 gtk_signal_connect(GTK_OBJECT(subst_btn), "clicked",
802 GTK_SIGNAL_FUNC(prefs_toolbar_substitute),
805 del_btn = gtk_button_new_with_label(_("Delete"));
806 gtk_box_pack_start(GTK_BOX(btn_hbox), del_btn, FALSE, TRUE, 0);
807 gtk_signal_connect(GTK_OBJECT(del_btn), "clicked",
808 GTK_SIGNAL_FUNC(prefs_toolbar_delete),
811 /* currently active toolbar items */
812 frame_toolbar_items = gtk_frame_new(_("Displayed toolbar items"));
813 gtk_box_pack_start(GTK_BOX(main_vbox), frame_toolbar_items, TRUE, TRUE, 0);
814 gtk_container_set_border_width(GTK_CONTAINER(frame_toolbar_items), 5);
816 hbox_bottom = gtk_hbox_new(FALSE, 0);
817 gtk_container_add(GTK_CONTAINER(frame_toolbar_items), hbox_bottom);
819 scrolledwindow_clist_set = gtk_scrolled_window_new(NULL, NULL);
820 gtk_box_pack_start(GTK_BOX(hbox_bottom), scrolledwindow_clist_set, TRUE, TRUE, 0);
821 gtk_container_set_border_width(GTK_CONTAINER(scrolledwindow_clist_set), 1);
822 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow_clist_icon),
823 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
825 titles[COL_ICON] = _("Icon");
826 titles[COL_FILENAME] = _("File name");
827 titles[COL_TEXT] = _("Icon text");
828 titles[COL_EVENT] = _("Mapped event");
830 clist_set = gtk_clist_new_with_titles(N_DISPLAYED_ITEMS_COLS, titles);
831 gtk_widget_show(clist_set);
832 gtk_container_add(GTK_CONTAINER(scrolledwindow_clist_set), clist_set);
833 gtk_clist_set_column_width(GTK_CLIST(clist_set), COL_ICON , 80);
834 gtk_clist_set_column_width(GTK_CLIST(clist_set), COL_FILENAME, 80);
835 gtk_clist_set_column_width(GTK_CLIST(clist_set), COL_TEXT , 80);
836 gtk_clist_set_column_width(GTK_CLIST(clist_set), COL_EVENT , 80);
837 gtk_clist_column_titles_show(GTK_CLIST(clist_set));
838 gtk_widget_set_usize(clist_set, 225, 120);
840 btn_vbox = gtk_vbox_new(FALSE, 8);
841 gtk_widget_show(btn_vbox);
842 gtk_box_pack_start(GTK_BOX(hbox_bottom), btn_vbox, FALSE, FALSE, 5);
844 up_btn = gtk_button_new_with_label(_("Up"));
845 gtk_widget_show(up_btn);
846 gtk_box_pack_start(GTK_BOX(btn_vbox), up_btn, FALSE, FALSE, 2);
848 down_btn = gtk_button_new_with_label(_("Down"));
849 gtk_widget_show(down_btn);
850 gtk_box_pack_start(GTK_BOX(btn_vbox), down_btn, FALSE, FALSE, 0);
852 gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
853 &cancel_btn, _("Cancel"), &default_btn, _("Set default"));
854 gtk_box_pack_end(GTK_BOX(main_vbox), confirm_area, FALSE, FALSE, 0);
855 gtk_container_set_border_width(GTK_CONTAINER(confirm_area), 5);
856 gtk_widget_grab_default(ok_btn);
858 gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
859 GTK_SIGNAL_FUNC(prefs_toolbar_ok), NULL);
860 gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
861 GTK_SIGNAL_FUNC(prefs_toolbar_cancel), NULL);
862 gtk_signal_connect(GTK_OBJECT(default_btn), "clicked",
863 GTK_SIGNAL_FUNC(prefs_toolbar_default), NULL);
864 gtk_signal_connect(GTK_OBJECT(clist_set), "select_row",
865 GTK_SIGNAL_FUNC(prefs_toolbar_select_row_set),
867 gtk_signal_connect(GTK_OBJECT(clist_icons), "select_row",
868 GTK_SIGNAL_FUNC(prefs_toolbar_select_row_icons),
870 gtk_signal_connect(GTK_OBJECT(combo_list), "selection-changed",
871 GTK_SIGNAL_FUNC(prefs_toolbar_selection_changed),
873 gtk_signal_connect(GTK_OBJECT(up_btn), "clicked",
874 GTK_SIGNAL_FUNC(prefs_toolbar_up), NULL);
875 gtk_signal_connect(GTK_OBJECT(down_btn), "clicked",
876 GTK_SIGNAL_FUNC(prefs_toolbar_down), NULL);
878 mtoolbar.window = window;
879 mtoolbar.clist_icons = clist_icons;
880 mtoolbar.clist_set = clist_set;
881 mtoolbar.combo_action = combo_action;
882 mtoolbar.combo_entry = combo_entry;
883 mtoolbar.combo_list = combo_list;
884 mtoolbar.entry_icon_text = entry_icon_text;
885 mtoolbar.combo_syl_action = combo_syl_action;
886 mtoolbar.combo_syl_list = combo_syl_list;
887 mtoolbar.combo_syl_entry = combo_syl_entry;
889 mtoolbar.label_icon_text = label_icon_text;
890 mtoolbar.label_action_sel = label_action_sel;
892 gtk_widget_show_all(window);