summaryrefslogtreecommitdiffhomepage
path: root/mixgtk/mixgtk_wm.c
diff options
context:
space:
mode:
Diffstat (limited to 'mixgtk/mixgtk_wm.c')
-rw-r--r--mixgtk/mixgtk_wm.c85
1 files changed, 65 insertions, 20 deletions
diff --git a/mixgtk/mixgtk_wm.c b/mixgtk/mixgtk_wm.c
index 7e28baf..9f227c5 100644
--- a/mixgtk/mixgtk_wm.c
+++ b/mixgtk/mixgtk_wm.c
@@ -33,19 +33,22 @@ typedef struct window_info_t_
const gchar *menu_name;
const gchar *config_key;
gboolean visible;
+ const gchar *toolbar_name;
} window_info_t_;
static window_info_t_ infos_[] = {
- {MIXGTK_MIXVM_DIALOG, NULL, NULL, "mix_view", "MIX.view"},
- {MIXGTK_MIXAL_DIALOG, NULL, NULL, "mixal_view", "MIXAL.view"},
- {MIXGTK_DEVICES_DIALOG, NULL, NULL, "devices_view", "Devices.view"}
+ {MIXGTK_MIXVM_DIALOG, NULL, NULL, "mix_view", "MIX.view", FALSE, NULL},
+ {MIXGTK_MIXAL_DIALOG, NULL, NULL, "mixal_view", "MIXAL.view", FALSE,
+ "mixal_toolbar"},
+ {MIXGTK_DEVICES_DIALOG, NULL, NULL, "devices_view", "Devices.view",
+ FALSE, "devices_toolbar"}
};
static size_t INF_NO_ = sizeof (infos_) / sizeof (infos_[0]);
static gboolean split_ = FALSE;
-static const gchar *SPLIT_MENU_NAME_ = "split_windows";
-static GtkCheckMenuItem *split_menu_ = NULL;
+static const gchar *TB_MENU_NAME_ = "show_toolbars";
+static GtkCheckMenuItem *tb_menu_ = NULL;
static const gchar *VIEW_YES_ = "Yes";
static const gchar *VIEW_NO_ = "No";
@@ -56,18 +59,15 @@ static gboolean restart_ = FALSE;
gboolean
mixgtk_wm_init (void)
{
- static gboolean restart = FALSE;
split_ = mixgtk_config_is_split ();
if (split_)
{
gint i;
- split_menu_ = GTK_CHECK_MENU_ITEM
- (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN,
- SPLIT_MENU_NAME_));
- g_return_val_if_fail (split_menu_, FALSE);
- gtk_check_menu_item_set_active (split_menu_, TRUE);
for (i = 0; i < INF_NO_; ++i)
{
+ const gchar *view = mixgtk_config_get (infos_[i].config_key);
+ infos_[i].visible = !view || !strcmp (VIEW_YES_, view);
+ if (!view) mixgtk_config_update (infos_[i].config_key, VIEW_YES_);
infos_[i].widget =
mixgtk_widget_factory_get_dialog (infos_[i].dialog);
g_return_val_if_fail (infos_[i].widget, FALSE);
@@ -75,11 +75,6 @@ mixgtk_wm_init (void)
(mixgtk_widget_factory_get_child_by_name
(MIXGTK_MAIN, infos_[i].menu_name));
g_return_val_if_fail (infos_[i].menu, FALSE);
- if (!restart)
- {
- const gchar *view = mixgtk_config_get (infos_[i].config_key);
- infos_[i].visible = !view || !strcmp (VIEW_YES_, view);
- }
if (infos_[i].visible) gtk_widget_show (infos_[i].widget);
gtk_check_menu_item_set_active (infos_[i].menu, infos_[i].visible);
}
@@ -90,8 +85,14 @@ mixgtk_wm_init (void)
for (k = 0; k < INF_NO_; ++k)
if (infos_[k].widget) gtk_widget_destroy (infos_[k].widget);
}
-
- restart = TRUE;
+
+ tb_menu_ = GTK_CHECK_MENU_ITEM
+ (mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN,
+ TB_MENU_NAME_));
+ g_return_val_if_fail (tb_menu_, FALSE);
+ gtk_check_menu_item_set_active (tb_menu_, mixgtk_config_show_toolbars ());
+ mixgtk_wm_show_toolbars (mixgtk_config_show_toolbars ());
+
return TRUE;
}
@@ -121,6 +122,36 @@ mixgtk_wm_hide_window (mixgtk_window_id_t w)
}
}
+void
+mixgtk_wm_show_toolbars (gboolean show)
+{
+ static const gchar *MAIN_TB_NAME = "main_toolbar";
+ GtkWidget *toolbar =
+ mixgtk_widget_factory_get_child_by_name (MIXGTK_MAIN, MAIN_TB_NAME);
+ if (toolbar != NULL)
+ {
+ if (show) gtk_widget_show (toolbar);
+ else gtk_widget_hide (toolbar);
+ }
+
+ if (split_)
+ {
+ int k;
+ for (k = 0; k < INF_NO_; ++k)
+ {
+ if (infos_[k].toolbar_name != NULL)
+ {
+ GtkWidget *tb = mixgtk_widget_factory_get_child_by_name
+ (infos_[k].dialog, infos_[k].toolbar_name);
+ if (show && tb) gtk_widget_show (tb);
+ else if (tb) gtk_widget_hide (tb);
+ }
+ }
+ }
+
+ mixgtk_config_set_show_toolbars (show);
+}
+
/* callbacks */
void
on_view_toggled (GtkCheckMenuItem *item)
@@ -142,9 +173,17 @@ on_view_toggled (GtkCheckMenuItem *item)
}
void
-on_split_windows_toggled (GtkCheckMenuItem *item)
+on_one_window_activate ()
{
- mixgtk_config_set_split (item->active);
+ mixgtk_config_set_split (FALSE);
+ restart_ = TRUE;
+ gtk_widget_destroy (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN));
+}
+
+void
+on_split_windows_activate ()
+{
+ mixgtk_config_set_split (TRUE);
restart_ = TRUE;
gtk_widget_destroy (mixgtk_widget_factory_get_dialog (MIXGTK_MAIN));
}
@@ -170,3 +209,9 @@ on_main_window_destroy (GtkWidget *w, gpointer data)
else gtk_main_quit ();
}
+void
+on_show_toolbars_toggled (GtkCheckMenuItem *item)
+{
+ if (!restart_ && item->active != mixgtk_config_show_toolbars ())
+ mixgtk_wm_show_toolbars (item->active);
+}