2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001 Hiroyuki Yamamoto
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"
50 static struct _Toolbar {
53 GtkWidget *clist_icons;
55 GtkWidget *combo_action;
56 GtkWidget *combo_entry;
57 GtkWidget *combo_list;
58 GtkWidget *label_icon_text;
59 GtkWidget *entry_icon_text;
60 GtkWidget *combo_syl_action;
61 GtkWidget *combo_syl_list;
62 GtkWidget *combo_syl_entry;
66 #define CELL_SPACING 30
67 #define ERROR_MSG _("Selected Action already set.\nPlease choose another Action from List")
69 static void prefs_toolbar_open (void);
70 static void prefs_toolbar_populate (void);
71 static gboolean is_duplicate (gchar *chosen_action);
72 static void prefs_toolbar_save (void);
73 static void prefs_toolbar_ok (void);
74 static void prefs_toolbar_cancel (void);
76 static gint prefs_toolbar_register (void);
77 static gint prefs_toolbar_substitute (void);
78 static gint prefs_toolbar_delete (void);
80 static void prefs_toolbar_up (void);
82 static void prefs_toolbar_down (void);
84 static void prefs_toolbar_select_row_set (GtkCList *clist,
90 static void prefs_toolbar_select_row_icons (GtkCList *clist,
96 static void prefs_toolbar_create (void);
98 static void prefs_toolbar_selection_changed (GtkList *list,
101 static gint prefs_toolbar_key_pressed (GtkWidget *widget,
105 void prefs_toolbar(void)
107 toolbar_read_config_file();
108 prefs_toolbar_open ();
111 static void prefs_toolbar_open(void)
113 if (!mtoolbar.window)
114 prefs_toolbar_create ();
116 manage_window_set_transient (GTK_WINDOW (mtoolbar.window));
117 prefs_toolbar_populate ();
118 gtk_widget_show(mtoolbar.window);
121 void prefs_toolbar_close(void)
123 gtk_widget_hide (mtoolbar.window);
126 static void prefs_toolbar_populate(void)
130 GList *combo_action_items;
131 GList *syl_actions = NULL;
132 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
133 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
137 gchar *activ[5] = {0};
140 gtk_clist_clear (clist_icons);
141 gtk_clist_clear (clist_set);
143 gtk_clist_freeze (clist_icons);
144 gtk_clist_freeze (clist_set);
146 /* set available icons */
147 avail[0] = g_strdup (SEPARATOR_PIXMAP);
148 avail[1] = g_strdup (SEPARATOR);
149 gtk_clist_append (clist_icons, avail);
153 combo_action_items = toolbar_get_action_items ();
154 gtk_combo_set_popdown_strings (GTK_COMBO (mtoolbar.combo_action), combo_action_items);
155 gtk_combo_set_value_in_list (GTK_COMBO (mtoolbar.combo_action), 0, FALSE);
156 gtk_entry_set_text (GTK_ENTRY (mtoolbar.combo_entry), combo_action_items->data);
157 g_list_free (combo_action_items);
159 /* get currently defined sylpheed actions */
160 if (prefs_common.actions_list != NULL) {
162 for (cur = prefs_common.actions_list; cur != NULL; cur = cur->next) {
163 act = (gchar *)cur->data;
164 syl_actions = g_list_append (syl_actions, act);
167 gtk_combo_set_popdown_strings (GTK_COMBO (mtoolbar.combo_syl_action), syl_actions);
168 gtk_combo_set_value_in_list (GTK_COMBO (mtoolbar.combo_syl_action), 0, FALSE);
169 gtk_entry_set_text (GTK_ENTRY (mtoolbar.combo_syl_entry), syl_actions->data);
170 prefs_toolbar_selection_changed(GTK_LIST(mtoolbar.combo_syl_list), NULL);
171 g_list_free (syl_actions);
174 for (i = 0; i < N_STOCK_PIXMAPS; i++) {
175 avail[0] = g_strdup ("");
176 avail[1] = g_strdup (stock_pixmap_get_name ((StockPixmap)i));
178 stock_pixmap_gdk (mtoolbar.clist_icons, i,
180 gtk_clist_append (clist_icons, avail);
181 gtk_clist_set_pixmap (clist_icons,
182 i + 1, 0, xpm, xpmmask);
188 /* set currently active toolbar entries */
189 for (cur = toolbar_list; cur != NULL; cur = cur->next) {
190 ToolbarItem *item = (ToolbarItem*) cur->data;
192 if (g_strcasecmp (item->file, SEPARATOR) != 0) {
194 StockPixmap icon = stock_pixmap_get_icon (item->file);
196 stock_pixmap_gdk (mtoolbar.clist_set, icon,
198 activ[0] = g_strdup ("");
199 activ[1] = g_strdup (item->file);
200 activ[2] = g_strdup (item->text);
201 activ[3] = g_strdup (toolbar_ret_descr_from_val (item->action));
202 row_num = gtk_clist_append (clist_set, activ);
203 gtk_clist_set_pixmap (clist_set,
204 row_num, 0, xpm, xpmmask);
207 activ[0] = g_strdup (SEPARATOR_PIXMAP);
208 activ[1] = g_strdup (item->file);
209 activ[2] = g_strdup ("");
210 activ[3] = g_strdup ("");
211 gtk_clist_append (clist_set, activ);
220 gtk_clist_thaw(clist_icons);
221 gtk_clist_thaw(clist_set);
223 gtk_clist_columns_autosize(clist_icons);
224 gtk_clist_columns_autosize(clist_set);
226 gtk_clist_set_row_height(clist_icons, CELL_SPACING);
227 gtk_clist_set_row_height(clist_set, CELL_SPACING);
229 gtk_clist_select_row(clist_icons, 0, 0);
230 gtk_clist_select_row(clist_set, 0, 0);
232 toolbar_clear_list();
235 static gboolean is_duplicate(gchar *chosen_action)
237 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
240 gchar *syl_act = toolbar_ret_descr_from_val (A_SYL_ACTIONS);
242 g_return_val_if_fail (chosen_action != NULL, TRUE);
243 if (clist->rows == 0)
246 /* allow duplicate entries (A_SYL_ACTIONS) */
247 if (g_strcasecmp(syl_act, chosen_action) == 0)
251 gtk_clist_get_text (clist, row, 3, &entry);
252 if ( g_strcasecmp (chosen_action, entry) == 0)
255 } while ((gtk_clist_get_text(clist, row, 3, &entry)) && (row <= clist->rows));
260 static void prefs_toolbar_save(void)
263 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
266 toolbar_clear_list();
268 if (clist->rows == 0) {
269 toolbar_set_default_toolbar();
273 ToolbarItem *toolbar_item = g_new0 (ToolbarItem, 1);
275 gtk_clist_get_text (clist, row, 1, &entry);
276 toolbar_item->file = g_strdup (entry);
278 gtk_clist_get_text (clist, row, 2, &entry);
279 toolbar_item->text = g_strdup (entry);
281 gtk_clist_get_text (clist, row, 3, &entry);
282 toolbar_item->action = toolbar_ret_val_from_descr (entry);
284 /* TODO: save A_SYL_ACTIONS only if they are still active */
286 toolbar_list = g_slist_append (toolbar_list, toolbar_item);
289 } while (gtk_clist_get_text (clist, row, 3, &entry));
292 toolbar_save_config_file ();
293 toolbar_clear_list ();
295 main_window_reflect_prefs_all_real(TRUE);
298 static void prefs_toolbar_ok(void)
300 prefs_toolbar_save();
301 prefs_toolbar_close();
304 static void prefs_toolbar_cancel(void)
306 prefs_toolbar_close();
309 static void get_action_name(gchar *entry, gchar **menu)
313 if (prefs_common.actions_list != NULL) {
315 act = g_strdup (entry);
316 act_p = strstr(act, ": ");
319 /* freed by calling func */
324 static gint prefs_toolbar_register(void)
326 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
327 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
328 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
335 if (clist_icons->rows == 0) return -1;
337 if (clist_icons->selection)
338 if (clist_icons->selection->data)
339 row_icons = GPOINTER_TO_INT(clist_icons->selection->data);
341 gtk_clist_get_text (clist_icons, row_icons, 1, &item[1]);
342 item[3] = g_strdup (gtk_entry_get_text (GTK_ENTRY (mtoolbar.combo_entry)));
344 /* SEPARATOR or other ? */
345 if (g_strcasecmp (item[1], SEPARATOR) == 0) {
346 item[0] = g_strdup (SEPARATOR_PIXMAP);
347 item[2] = g_strdup ("");
348 item[3] = g_strdup ("");
350 row_set = gtk_clist_append (GTK_CLIST (mtoolbar.clist_set), item);
355 if (is_duplicate (item[3])) {
356 alertpanel_error(ERROR_MSG);
361 stock_pixmap_gdk (mtoolbar.clist_set, stock_pixmap_get_icon (item[1]),
364 if (g_strcasecmp (item[3], syl_act) == 0) {
366 gchar *entry = gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_syl_entry));
367 get_action_name(entry, &item[2]);
370 item[2] = g_strdup (gtk_entry_get_text (GTK_ENTRY (mtoolbar.entry_icon_text)));
373 row_set = gtk_clist_append (GTK_CLIST (mtoolbar.clist_set), item);
374 gtk_clist_set_pixmap (clist_set, row_set, 0, xpm, xpmmask);
377 gtk_clist_moveto(clist_set, row_set, 0, row_set/clist_set->rows, 0);
378 gtk_clist_select_row (clist_set, row_set, 0);
386 static gint prefs_toolbar_substitute(void)
388 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
389 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
390 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
398 /* no rows or nothing selected */
399 if ((clist_set->rows == 0) || (clist_set->selection == 0)) return -1;
401 if (clist_icons->selection)
402 if (clist_icons->selection->data)
403 row_icons = GPOINTER_TO_INT(clist_icons->selection->data);
405 if (clist_set->selection)
406 if (clist_set->selection->data)
407 row_set = GPOINTER_TO_INT(clist_set->selection->data);
409 gtk_clist_get_text (clist_icons, row_icons, 1, &item[1]);
410 gtk_clist_get_text (clist_set, row_set, 3, &ac_set);
411 item[3] = g_strdup (gtk_entry_get_text (GTK_ENTRY (mtoolbar.combo_entry)));
413 if (g_strcasecmp (item[1], SEPARATOR) == 0) {
414 item[0] = g_strdup (SEPARATOR_PIXMAP);
415 item[2] = g_strdup ("");
416 item[3] = g_strdup ("");
418 gtk_clist_remove (clist_set, row_set);
419 row_set = gtk_clist_insert (clist_set, row_set, item);
424 if ((is_duplicate(item[3])) && (g_strcasecmp(item[3], ac_set) != 0)){
425 alertpanel_error(ERROR_MSG);
430 stock_pixmap_gdk (mtoolbar.clist_set, stock_pixmap_get_icon (item[1]),
433 if (g_strcasecmp (item[3], syl_act) == 0) {
435 gchar *entry = gtk_entry_get_text(GTK_ENTRY(mtoolbar.combo_syl_entry));
436 get_action_name(entry, &item[2]);
438 item[2] = g_strdup (gtk_entry_get_text (GTK_ENTRY (mtoolbar.entry_icon_text)));
441 gtk_clist_remove (clist_set, row_set);
442 row_set = gtk_clist_insert (clist_set, row_set, item);
443 gtk_clist_set_pixmap (clist_set, row_set, 0, xpm, xpmmask);
446 gtk_clist_moveto(clist_set, row_set, 0, row_set/clist_set->rows, 0);
447 gtk_clist_select_row (clist_set, row_set, 0);
455 static gint prefs_toolbar_delete(void)
457 GtkCList *clist_set = GTK_CLIST(mtoolbar.clist_set);
460 if (clist_set->rows == 0) return -1;
461 if (clist_set->selection)
462 if (clist_set->selection->data)
463 row_set = GPOINTER_TO_INT(clist_set->selection->data);
465 if (clist_set->row_list != NULL) {
467 row_set = GPOINTER_TO_INT(clist_set->selection->data);
468 gtk_clist_remove (clist_set, row_set);
469 gtk_clist_columns_autosize (clist_set);
471 if (clist_set->rows > 0)
472 gtk_clist_select_row (clist_set, (row_set == 0) ? 0:row_set - 1, 0);
478 static void prefs_toolbar_up(void)
480 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
483 if (!clist->selection) return;
484 if (clist->selection->data)
485 row = GPOINTER_TO_INT(clist->selection->data);
488 gtk_clist_row_move(clist, row, row - 1);
489 if(gtk_clist_row_is_visible(clist, row - 1) != GTK_VISIBILITY_FULL) {
490 gtk_clist_moveto(clist, row - 1, 0, 0, 0);
495 static void prefs_toolbar_down(void)
497 GtkCList *clist = GTK_CLIST(mtoolbar.clist_set);
500 if (!clist->selection) return;
501 if (clist->selection->data)
502 row = GPOINTER_TO_INT(clist->selection->data);
504 if (row >= 0 && row < clist->rows - 1) {
505 gtk_clist_row_move(clist, row, row + 1);
506 if(gtk_clist_row_is_visible(clist, row + 1) != GTK_VISIBILITY_FULL) {
507 gtk_clist_moveto(clist, row + 1, 0, 1, 0);
512 static void prefs_toolbar_select_row_set(GtkCList *clist, gint row, gint column,
513 GdkEvent *event, gpointer user_data)
515 GtkCList *clist_ico = GTK_CLIST (mtoolbar.clist_icons);
516 gchar *syl_act = toolbar_ret_descr_from_val(A_SYL_ACTIONS);
519 gchar *file, *icon_text, *descr, *entry;
521 if (clist->selection->data)
522 row_set = GPOINTER_TO_INT(clist->selection->data);
524 gtk_clist_get_text (clist, row_set, 1, &file);
525 gtk_clist_get_text (clist, row_set, 2, &icon_text);
526 gtk_clist_get_text (clist, row_set, 3, &descr);
528 if (g_strcasecmp (descr, syl_act) != 0)
529 gtk_entry_set_text (GTK_ENTRY (mtoolbar.entry_icon_text), icon_text);
531 gtk_list_select_item (GTK_LIST (mtoolbar.combo_list),
532 toolbar_ret_val_from_descr (descr));
534 gtk_clist_get_text (clist_ico, row_ico, 1, &entry);
536 } while (g_strcasecmp (entry, file) != 0);
538 gtk_clist_select_row (clist_ico, row_ico - 1, 0);
539 gtk_clist_moveto(clist_ico, row_ico - 1, 0, row_ico/clist_ico->rows, 0);
542 static void prefs_toolbar_select_row_icons(GtkCList *clist, gint row, gint column,
543 GdkEvent *event, gpointer user_data)
545 GtkCList *clist_icons = GTK_CLIST(mtoolbar.clist_icons);
548 gtk_clist_get_text (clist_icons, row, 1, &text);
553 if (g_strcasecmp (SEPARATOR, text) == 0) {
554 gtk_widget_set_sensitive (mtoolbar.combo_action, FALSE);
555 gtk_widget_set_sensitive (mtoolbar.entry_icon_text, FALSE);
556 gtk_widget_set_sensitive (mtoolbar.combo_syl_action, FALSE);
558 gtk_widget_set_sensitive (mtoolbar.combo_action, TRUE);
559 gtk_widget_set_sensitive (mtoolbar.entry_icon_text, TRUE);
560 gtk_widget_set_sensitive (mtoolbar.combo_syl_action, TRUE);
564 static void prefs_toolbar_selection_changed(GtkList *list,
568 gchar *cur_entry = g_strdup (gtk_entry_get_text (GTK_ENTRY (mtoolbar.combo_entry)));
569 gchar *actions_entry = toolbar_ret_descr_from_val (A_SYL_ACTIONS);
571 gtk_widget_set_sensitive (mtoolbar.combo_syl_action, TRUE);
573 if (g_strcasecmp (cur_entry, actions_entry) == 0) {
574 gtk_widget_hide (mtoolbar.entry_icon_text);
575 gtk_widget_show (mtoolbar.combo_syl_action);
576 gtk_label_set_text (GTK_LABEL(mtoolbar.label_icon_text), _("Sylpheed Action"));
578 if (prefs_common.actions_list == NULL) {
579 gtk_widget_set_sensitive (mtoolbar.combo_syl_action, FALSE);
583 gtk_widget_hide (mtoolbar.combo_syl_action);
584 gtk_widget_show (mtoolbar.entry_icon_text);
585 gtk_label_set_text (GTK_LABEL(mtoolbar.label_icon_text), _("Toolbar text (shown below Pixmap)"));
589 static gint prefs_toolbar_key_pressed(GtkWidget *widget,
593 if (event && event->keyval == GDK_Escape) {
594 prefs_toolbar_cancel();
600 static void prefs_toolbar_create(void)
603 GtkWidget *main_vbox;
605 GtkWidget *compose_frame;
610 GtkWidget *subst_btn;
612 GtkWidget *vbox_frame;
613 GtkWidget *scrolledwindow_clist_icon;
614 GtkWidget *clist_icons;
615 GtkWidget *hbox_icon_text;
616 GtkWidget *label_icon_text;
617 GtkWidget *entry_icon_text;
618 GtkWidget *hbox_action;
619 GtkWidget *label_action_sel;
620 GtkWidget *combo_action;
621 GtkWidget *combo_entry;
622 GtkWidget *combo_list;
623 GtkWidget *combo_syl_action;
624 GtkWidget *combo_syl_entry;
625 GtkWidget *combo_syl_list;
626 GtkWidget *frame_toolbar_items;
627 GtkWidget *hbox_bottom;
628 GtkWidget *scrolledwindow_clist_set;
629 GtkWidget *clist_set;
630 GtkWidget *label_icon;
631 GtkWidget *label_file;
632 GtkWidget *label_text;
633 GtkWidget *label_action;
639 GtkWidget *confirm_area;
641 GtkWidget *cancel_btn;
643 window = gtk_window_new (GTK_WINDOW_DIALOG);
644 gtk_window_set_title (GTK_WINDOW (window), _("Customize Toolbar"));
645 //gtk_widget_set_usize (window, 400, 500);
646 gtk_widget_realize (window);
648 main_vbox = gtk_vbox_new (FALSE, 0);
650 gtk_container_add (GTK_CONTAINER (window), main_vbox);
652 gtkut_button_set_create(&confirm_area, &ok_btn, _("OK"),
653 &cancel_btn, _("Cancel"), NULL, NULL);
654 gtk_box_pack_end (GTK_BOX(main_vbox), confirm_area, FALSE, FALSE, 0);
655 gtk_container_set_border_width (GTK_CONTAINER (confirm_area), 5);
656 gtk_widget_grab_default (ok_btn);
658 top_hbox = gtk_hbox_new (FALSE, 0);
659 gtk_box_pack_start (GTK_BOX (main_vbox), top_hbox, TRUE, TRUE, 0);
661 compose_frame = gtk_frame_new (_("Available toolbar items"));
662 gtk_box_pack_start (GTK_BOX (top_hbox), compose_frame, TRUE, TRUE, 0);
663 gtk_container_set_border_width (GTK_CONTAINER (compose_frame), 5);
665 vbox_frame = gtk_vbox_new (FALSE, 0);
666 gtk_container_add (GTK_CONTAINER (compose_frame), vbox_frame);
668 /* available icons */
669 scrolledwindow_clist_icon = gtk_scrolled_window_new (NULL, NULL);
670 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow_clist_icon), 5);
671 gtk_container_add (GTK_CONTAINER (vbox_frame), scrolledwindow_clist_icon);
672 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_clist_icon),
673 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
675 clist_icons = gtk_clist_new (2);
676 gtk_container_add (GTK_CONTAINER (scrolledwindow_clist_icon), clist_icons);
677 gtk_container_set_border_width (GTK_CONTAINER (clist_icons), 1);
678 gtk_clist_set_column_width (GTK_CLIST (clist_icons), 0, 35);
679 gtk_clist_set_column_width (GTK_CLIST (clist_icons), 1, 200);
680 gtk_clist_column_titles_hide (GTK_CLIST (clist_icons));
681 gtk_widget_set_usize (clist_icons, 300, 150);
683 /* icon description */
684 hbox_icon_text = gtk_hbox_new (TRUE, 5);
685 gtk_container_add (GTK_CONTAINER (vbox_frame), hbox_icon_text);
686 gtk_container_set_border_width (GTK_CONTAINER (hbox_icon_text), 5);
688 label_icon_text = gtk_label_new ("");
689 gtk_box_pack_start (GTK_BOX (hbox_icon_text), label_icon_text, FALSE, FALSE, 5);
691 entry_icon_text = gtk_entry_new ();
692 gtk_box_pack_start (GTK_BOX (hbox_icon_text), entry_icon_text, FALSE, FALSE, 0);
694 /* Sylpheed Action Combo Box */
695 combo_syl_action = gtk_combo_new ();
696 gtk_box_pack_start (GTK_BOX (hbox_icon_text), combo_syl_action, TRUE, TRUE, 0);
698 combo_syl_list = GTK_COMBO (combo_syl_action)->list;
699 combo_syl_entry = GTK_COMBO (combo_syl_action)->entry;
700 gtk_entry_set_editable (GTK_ENTRY (combo_syl_entry), FALSE);
702 /* available actions */
703 hbox_action = gtk_hbox_new (TRUE, 5);
704 gtk_container_add (GTK_CONTAINER (vbox_frame), hbox_action);
705 gtk_container_set_border_width (GTK_CONTAINER (hbox_action), 5);
707 label_action_sel = gtk_label_new (_("Event executed on click"));
708 gtk_box_pack_start (GTK_BOX (hbox_action), label_action_sel, FALSE, FALSE, 0);
709 gtk_label_set_justify (GTK_LABEL (label_action_sel), GTK_JUSTIFY_RIGHT);
711 combo_action = gtk_combo_new ();
712 gtk_box_pack_start (GTK_BOX (hbox_action), combo_action, TRUE, TRUE, 0);
714 combo_list = GTK_COMBO (combo_action)->list;
715 combo_entry = GTK_COMBO (combo_action)->entry;
716 gtk_entry_set_editable (GTK_ENTRY (combo_entry), FALSE);
718 /* register / substitute / delete */
719 reg_hbox = gtk_hbox_new (FALSE, 4);
720 gtk_box_pack_start (GTK_BOX (main_vbox), reg_hbox, FALSE, FALSE, 0);
721 gtk_container_set_border_width (GTK_CONTAINER (reg_hbox), 10);
723 arrow = gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_OUT);
724 gtk_box_pack_start (GTK_BOX (reg_hbox), arrow, FALSE, FALSE, 0);
725 gtk_widget_set_usize (arrow, -1, 16);
727 btn_hbox = gtk_hbox_new (TRUE, 4);
728 gtk_box_pack_start (GTK_BOX (reg_hbox), btn_hbox, FALSE, FALSE, 0);
730 reg_btn = gtk_button_new_with_label (_("Register"));
731 gtk_box_pack_start (GTK_BOX (btn_hbox), reg_btn, FALSE, TRUE, 0);
732 gtk_signal_connect (GTK_OBJECT (reg_btn), "clicked",
733 GTK_SIGNAL_FUNC (prefs_toolbar_register),
736 subst_btn = gtk_button_new_with_label (_(" Substitute "));
737 gtk_box_pack_start (GTK_BOX (btn_hbox), subst_btn, FALSE, TRUE, 0);
738 gtk_signal_connect (GTK_OBJECT (subst_btn), "clicked",
739 GTK_SIGNAL_FUNC (prefs_toolbar_substitute),
742 del_btn = gtk_button_new_with_label (_("Delete"));
743 gtk_box_pack_start (GTK_BOX (btn_hbox), del_btn, FALSE, TRUE, 0);
744 gtk_signal_connect (GTK_OBJECT (del_btn), "clicked",
745 GTK_SIGNAL_FUNC (prefs_toolbar_delete),
748 /* currently active toolbar items */
749 frame_toolbar_items = gtk_frame_new (_("Displayed toolbar items"));
750 gtk_box_pack_start (GTK_BOX (main_vbox), frame_toolbar_items, TRUE, TRUE, 0);
751 gtk_container_set_border_width (GTK_CONTAINER (frame_toolbar_items), 5);
753 hbox_bottom = gtk_hbox_new (FALSE, 0);
754 gtk_container_add (GTK_CONTAINER (frame_toolbar_items), hbox_bottom);
756 scrolledwindow_clist_set = gtk_scrolled_window_new (NULL, NULL);
757 gtk_box_pack_start (GTK_BOX (hbox_bottom), scrolledwindow_clist_set, TRUE, TRUE, 0);
758 gtk_container_set_border_width (GTK_CONTAINER (scrolledwindow_clist_set), 5);
759 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolledwindow_clist_icon),
760 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
762 clist_set = gtk_clist_new (4);
763 gtk_container_add (GTK_CONTAINER (scrolledwindow_clist_set), clist_set);
764 gtk_clist_set_column_width (GTK_CLIST (clist_set), 0, 80);
765 gtk_clist_set_column_width (GTK_CLIST (clist_set), 1, 80);
766 gtk_clist_set_column_width (GTK_CLIST (clist_set), 2, 80);
767 gtk_clist_set_column_width (GTK_CLIST (clist_set), 3, 80);
768 gtk_clist_column_titles_show (GTK_CLIST (clist_set));
769 gtk_widget_set_usize (clist_set, 300, 200);
771 label_icon = gtk_label_new (_("Pixmap"));
772 gtk_clist_set_column_widget (GTK_CLIST (clist_set), 0, label_icon);
774 label_file = gtk_label_new (_("File name"));
775 gtk_clist_set_column_widget (GTK_CLIST (clist_set), 1, label_file);
777 label_text = gtk_label_new (_("Pixmap text"));
778 gtk_clist_set_column_widget (GTK_CLIST (clist_set), 2, label_text);
780 label_action = gtk_label_new (_("Mapped event"));
781 gtk_clist_set_column_widget (GTK_CLIST (clist_set), 3, label_action);
783 toolbar = gtk_toolbar_new (GTK_ORIENTATION_VERTICAL, GTK_TOOLBAR_BOTH);
784 gtk_box_pack_start (GTK_BOX (hbox_bottom), toolbar, FALSE, FALSE, 0);
785 gtk_container_set_border_width (GTK_CONTAINER (toolbar), 5);
787 icon_wid = stock_pixmap_widget(hbox_bottom, STOCK_PIXMAP_UP_ARROW);
788 up_btn = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar),
789 GTK_TOOLBAR_CHILD_BUTTON,
793 icon_wid, NULL, NULL);
795 icon_wid = stock_pixmap_widget(hbox_bottom, STOCK_PIXMAP_DOWN_ARROW);
796 down_btn = gtk_toolbar_append_element (GTK_TOOLBAR (toolbar),
797 GTK_TOOLBAR_CHILD_BUTTON,
801 icon_wid, NULL, NULL);
803 gtk_signal_connect(GTK_OBJECT (window), "delete_event",
804 GTK_SIGNAL_FUNC (prefs_toolbar_cancel),
806 gtk_signal_connect(GTK_OBJECT(window), "key_press_event",
807 GTK_SIGNAL_FUNC(prefs_toolbar_key_pressed),
809 MANAGE_WINDOW_SIGNALS_CONNECT(window);
811 gtk_signal_connect(GTK_OBJECT(ok_btn), "clicked",
812 GTK_SIGNAL_FUNC(prefs_toolbar_ok),
814 gtk_signal_connect(GTK_OBJECT(cancel_btn), "clicked",
815 GTK_SIGNAL_FUNC(prefs_toolbar_cancel),
817 gtk_signal_connect(GTK_OBJECT (clist_set), "select_row",
818 GTK_SIGNAL_FUNC (prefs_toolbar_select_row_set),
820 gtk_signal_connect(GTK_OBJECT (clist_icons), "select_row",
821 GTK_SIGNAL_FUNC (prefs_toolbar_select_row_icons),
823 gtk_signal_connect(GTK_OBJECT (down_btn), "clicked",
824 GTK_SIGNAL_FUNC (prefs_toolbar_down),
826 gtk_signal_connect(GTK_OBJECT (up_btn), "clicked",
827 GTK_SIGNAL_FUNC (prefs_toolbar_up),
829 gtk_signal_connect(GTK_OBJECT(combo_list), "selection-changed",
830 GTK_SIGNAL_FUNC(prefs_toolbar_selection_changed),
833 mtoolbar.window = window;
834 mtoolbar.clist_icons = clist_icons;
835 mtoolbar.clist_set = clist_set;
836 mtoolbar.combo_action = combo_action;
837 mtoolbar.combo_entry = combo_entry;
838 mtoolbar.combo_list = combo_list;
839 mtoolbar.entry_icon_text = entry_icon_text;
840 mtoolbar.combo_syl_action = combo_syl_action;
841 mtoolbar.combo_syl_list = combo_syl_list;
842 mtoolbar.combo_syl_entry = combo_syl_entry;
844 mtoolbar.label_icon_text = label_icon_text;
846 gtk_widget_show_all (window);