From 95a600525148564d98a0c26f1c7fe9d8b6ecc7a5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Wed, 9 Aug 2006 01:26:19 +0000 Subject: Configurable toolbars (icons, text or both) git-archimport-id: mdk@sv.gnu.org/mdk--devel--1--patch-36 --- mixgtk/mixgtk.glade | 132 +++++++++++++++++++++++++++++++++++++++---------- mixgtk/mixgtk_config.c | 26 +++++++--- mixgtk/mixgtk_config.h | 7 +++ mixgtk/mixgtk_wm.c | 49 +++++++++++++++++- 4 files changed, 180 insertions(+), 34 deletions(-) diff --git a/mixgtk/mixgtk.glade b/mixgtk/mixgtk.glade index 1de46eb..434d171 100644 --- a/mixgtk/mixgtk.glade +++ b/mixgtk/mixgtk.glade @@ -53,7 +53,7 @@ - + True gtk-open 1 @@ -76,7 +76,7 @@ - + True gtk-justify-fill 1 @@ -99,7 +99,7 @@ - + True gtk-execute 1 @@ -128,7 +128,7 @@ - + True gtk-quit 1 @@ -164,7 +164,7 @@ - + True gtk-go-forward 1 @@ -187,7 +187,7 @@ - + True gtk-goto-last 1 @@ -210,7 +210,7 @@ - + True gtk-clear 1 @@ -233,7 +233,7 @@ - + True gtk-index 1 @@ -260,22 +260,102 @@ - + True _Toolbars True - False + + + + True + gtk-preferences + 1 + 0.5 + 0.5 + 0 + 0 + + + + + + + + + True + _Show Toolbars + True + False + + + + + + True + _Style + True + + + + + + + True + Show only icons in toolbar buttons + _Icons + True + True + + + + + + True + Show only labels in toolbar buttons + _Labels + True + False + tb_style_icons + + + + + + True + Show both icons and labels in toolbar buttons + _Both + True + False + tb_style_icons + + + + + + True + _Sideways + True + False + tb_style_icons + + + + + + + + - + True _Detached windows True - + True gtk-dnd-multiple 1 @@ -287,7 +367,7 @@ - + @@ -340,7 +420,7 @@ True - + True gtk-select-font 1 @@ -437,7 +517,7 @@ - + True gtk-zoom-100 1 @@ -458,7 +538,7 @@ - + True gtk-home 1 @@ -479,7 +559,7 @@ - + True gtk-preferences 1 @@ -507,7 +587,7 @@ - + True gtk-save 1 @@ -552,7 +632,7 @@ - + True gtk-help 1 @@ -819,7 +899,7 @@ True Attach all windows - + Attach True gtk-dnd True @@ -2134,7 +2214,7 @@ disk7 GTK_POS_TOP - + 2 True True @@ -2263,7 +2343,7 @@ disk7 True Attach window - + Attach True gtk-dnd True @@ -2351,7 +2431,7 @@ disk7 GTK_POS_TOP - + 2 True True @@ -2444,7 +2524,7 @@ disk7 True Attach window - + Attach True gtk-dnd True @@ -2661,7 +2741,7 @@ disk7 GTK_POS_TOP - + True True GTK_ORIENTATION_HORIZONTAL @@ -2704,7 +2784,7 @@ disk7 True Attach window - + Attach True gtk-dnd True diff --git a/mixgtk/mixgtk_config.c b/mixgtk/mixgtk_config.c index 519e3cb..81cebac 100644 --- a/mixgtk/mixgtk_config.c +++ b/mixgtk/mixgtk_config.c @@ -30,9 +30,10 @@ #include "mixgtk_config.h" static const gchar *MIXGTK_CONFIG_FILE_ = "gmixvm.config"; -static const gchar *SHOW_TB_KEY = "Toolbars"; -static const gchar *TB_YES = "Yes"; -static const gchar *TB_NO = "No"; +static const gchar *SHOW_TB_KEY_ = "Toolbars"; +static const gchar *TB_YES_ = "Yes"; +static const gchar *TB_NO_ = "No"; +static const gchar *TB_STYLE_KEY_ = "ToolbarStyle"; static mix_config_t *config_ = NULL; @@ -47,6 +48,7 @@ mixgtk_config_load (void) config_ = mix_config_new (cdir, MIXGTK_CONFIG_FILE_); g_free (cdir); } + return (config_ != NULL); } @@ -70,6 +72,18 @@ mixgtk_config_set_autosave (gboolean autosave) mix_config_set_autosave (config_, autosave); } +guint +mixgtk_config_tb_style (void) +{ + return (guint)mix_config_get_integer (config_, TB_STYLE_KEY_); +} + +void +mixgtk_config_set_tb_style (guint style) +{ + mix_config_update_integer (config_, TB_STYLE_KEY_, (gint)style); +} + /* update config item */ void mixgtk_config_update (const gchar *key, const gchar *value) @@ -100,12 +114,12 @@ mixgtk_config_save (void) gboolean mixgtk_config_show_toolbars (void) { - const gchar *show = mixgtk_config_get (SHOW_TB_KEY); - return (!show || !strcmp (show, TB_YES)); + const gchar *show = mixgtk_config_get (SHOW_TB_KEY_); + return (!show || !strcmp (show, TB_YES_)); } void mixgtk_config_set_show_toolbars (gboolean show) { - mixgtk_config_update (SHOW_TB_KEY, show? TB_YES : TB_NO); + mixgtk_config_update (SHOW_TB_KEY_, show? TB_YES_ : TB_NO_); } diff --git a/mixgtk/mixgtk_config.h b/mixgtk/mixgtk_config.h index 971c862..9f464c4 100644 --- a/mixgtk/mixgtk_config.h +++ b/mixgtk/mixgtk_config.h @@ -41,6 +41,13 @@ mixgtk_config_is_autosave (void); extern void mixgtk_config_set_autosave (gboolean autosave); +/* toolbar style */ +extern guint +mixgtk_config_tb_style (void); + +extern void +mixgtk_config_set_tb_style (guint style); + /* update config item */ extern void mixgtk_config_update (const gchar *key, const gchar *value); diff --git a/mixgtk/mixgtk_wm.c b/mixgtk/mixgtk_wm.c index 6bf691e..c4f2ef6 100644 --- a/mixgtk/mixgtk_wm.c +++ b/mixgtk/mixgtk_wm.c @@ -81,6 +81,7 @@ static void mixal_detach_ (void); static void dev_attach_ (void); static void dev_detach_ (void); static void update_attach_buttons_ (void); +static void on_tb_style_ (GtkMenuItem *w, gpointer style); static void on_nb_switch_ (GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data); @@ -223,7 +224,6 @@ on_widget_attach (GtkWidget *ign, gpointer id) mixgtk_wm_attach_window (GPOINTER_TO_INT (id)); } - /* about box */ void on_about_activate (GtkWidget *w, gpointer data) @@ -438,6 +438,10 @@ init_dev_ (void) static void init_tb_ (void) { + gchar *names[4]; + gint k; + gint tb_style = mixgtk_config_tb_style (); + tb_menu_ = GTK_CHECK_MENU_ITEM (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, TB_MENU_NAME_)); @@ -456,6 +460,47 @@ init_tb_ (void) g_assert (attach_button_); g_assert (detach_button_); + + names[GTK_TOOLBAR_ICONS] = "tb_style_icons"; + names[GTK_TOOLBAR_TEXT] = "tb_style_labels"; + names[GTK_TOOLBAR_BOTH] = "tb_style_both"; + names[GTK_TOOLBAR_BOTH_HORIZ] = "tb_style_bothh"; + + for (k = 0; k < 4; ++k) + { + GtkWidget *item = + mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, names[k]); + g_signal_connect (G_OBJECT (item), + "activate", + G_CALLBACK (on_tb_style_), GUINT_TO_POINTER (k)); + if (k == tb_style) + { + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item), TRUE); + } + } +} + +static void +on_tb_style_ (GtkMenuItem *w, gpointer style) +{ + static const gchar *TB_NAME = "main_toolbar"; + static const gchar *TB_DNAME = "dlg_toolbar"; + + guint ui_style = GPOINTER_TO_UINT (style); + gint k; + + GtkToolbar *tb = GTK_TOOLBAR + (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, TB_NAME)); + gtk_toolbar_set_style (tb, ui_style); + + for (k = 0; k < INF_NO_; ++k) + { + GtkToolbar *tb = GTK_TOOLBAR + (mixgtk_widget_factory_get_child_by_name (infos_[k].dialog, TB_DNAME)); + gtk_toolbar_set_style (tb, ui_style); + } + + mixgtk_config_set_tb_style (ui_style); } static void @@ -463,7 +508,7 @@ show_toolbars_ (gboolean show) { static const gchar *HANDLE_NAME = "tb_handle"; - int k; + gint k; GtkWidget *handle = mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, HANDLE_NAME); -- cgit v1.2.3