Ignore unknown actions in toolbar; handle toolbar-visible, actions and prefs properly
parent
29d463d52c
commit
c49ec72594
|
@ -2124,7 +2124,7 @@ fill_toolbar (MooUIXML *xml,
|
||||||
switch (node->type)
|
switch (node->type)
|
||||||
{
|
{
|
||||||
case MOO_UI_NODE_ITEM:
|
case MOO_UI_NODE_ITEM:
|
||||||
result = create_tool_item (xml, toplevel, toolbar, node, -1);
|
create_tool_item (xml, toplevel, toolbar, node, -1);
|
||||||
break;
|
break;
|
||||||
case MOO_UI_NODE_SEPARATOR:
|
case MOO_UI_NODE_SEPARATOR:
|
||||||
create_tool_separator (xml, toplevel, toolbar, node, -1);
|
create_tool_separator (xml, toplevel, toolbar, node, -1);
|
||||||
|
|
|
@ -39,10 +39,14 @@ static GSList *window_instances = NULL;
|
||||||
|
|
||||||
struct _MooWindowPrivate {
|
struct _MooWindowPrivate {
|
||||||
guint save_size_id;
|
guint save_size_id;
|
||||||
|
|
||||||
char *toolbar_ui_name;
|
char *toolbar_ui_name;
|
||||||
|
GtkWidget *toolbar_holder;
|
||||||
|
gboolean toolbar_visible;
|
||||||
|
|
||||||
char *menubar_ui_name;
|
char *menubar_ui_name;
|
||||||
GtkWidget *menubar_holder;
|
GtkWidget *menubar_holder;
|
||||||
GtkWidget *toolbar_holder;
|
gboolean menubar_visible;
|
||||||
|
|
||||||
MooUIXML *ui_xml;
|
MooUIXML *ui_xml;
|
||||||
MooActionGroup *actions;
|
MooActionGroup *actions;
|
||||||
|
@ -166,7 +170,6 @@ static void moo_window_class_init (MooWindowClass *klass)
|
||||||
"name", "Show Toolbar",
|
"name", "Show Toolbar",
|
||||||
"label", "Show Toolbar",
|
"label", "Show Toolbar",
|
||||||
"tooltip", "Show Toolbar",
|
"tooltip", "Show Toolbar",
|
||||||
"toggled-callback", moo_window_set_toolbar_visible,
|
|
||||||
"condition::active", "toolbar-visible",
|
"condition::active", "toolbar-visible",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -175,7 +178,6 @@ static void moo_window_class_init (MooWindowClass *klass)
|
||||||
"name", "Show Menubar",
|
"name", "Show Menubar",
|
||||||
"label", "Show Menubar",
|
"label", "Show Menubar",
|
||||||
"tooltip", "Show Menubar",
|
"tooltip", "Show Menubar",
|
||||||
"toggled-callback", moo_window_set_menubar_visible,
|
|
||||||
"condition::active", "menubar-visible",
|
"condition::active", "menubar-visible",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
@ -266,13 +268,15 @@ static void moo_window_class_init (MooWindowClass *klass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GObject *moo_window_constructor (GType type,
|
GObject *
|
||||||
guint n_props,
|
moo_window_constructor (GType type,
|
||||||
GObjectConstructParam *props)
|
guint n_props,
|
||||||
|
GObjectConstructParam *props)
|
||||||
{
|
{
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
MooWindow *window;
|
MooWindow *window;
|
||||||
MooWindowClass *klass;
|
MooWindowClass *klass;
|
||||||
|
MooAction *action;
|
||||||
|
|
||||||
GObject *object =
|
GObject *object =
|
||||||
G_OBJECT_CLASS(moo_window_parent_class)->constructor (type, n_props, props);
|
G_OBJECT_CLASS(moo_window_parent_class)->constructor (type, n_props, props);
|
||||||
|
@ -335,6 +339,16 @@ GObject *moo_window_constructor (GType type,
|
||||||
g_signal_connect (window, "configure-event",
|
g_signal_connect (window, "configure-event",
|
||||||
G_CALLBACK (moo_window_save_size), NULL);
|
G_CALLBACK (moo_window_save_size), NULL);
|
||||||
|
|
||||||
|
moo_window_set_toolbar_visible (window,
|
||||||
|
moo_prefs_get_bool (setting (window, PREFS_SHOW_TOOLBAR)));
|
||||||
|
action = moo_window_get_action_by_id (window, "ShowToolbar");
|
||||||
|
moo_sync_bool_property (action, "active", window, "toolbar-visible", FALSE);
|
||||||
|
|
||||||
|
moo_window_set_menubar_visible (window,
|
||||||
|
moo_prefs_get_bool (setting (window, PREFS_SHOW_MENUBAR)));
|
||||||
|
action = moo_window_get_action_by_id (window, "ShowMenubar");
|
||||||
|
moo_sync_bool_property (action, "active", window, "menubar-visible", FALSE);
|
||||||
|
|
||||||
g_type_class_unref (klass);
|
g_type_class_unref (klass);
|
||||||
return object;
|
return object;
|
||||||
}
|
}
|
||||||
|
@ -344,6 +358,8 @@ static void moo_window_init (MooWindow *window)
|
||||||
{
|
{
|
||||||
window->priv = g_new0 (MooWindowPrivate, 1);
|
window->priv = g_new0 (MooWindowPrivate, 1);
|
||||||
window->vbox = gtk_vbox_new (FALSE, 0);
|
window->vbox = gtk_vbox_new (FALSE, 0);
|
||||||
|
window->priv->toolbar_visible = TRUE;
|
||||||
|
window->priv->menubar_visible = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -384,7 +400,8 @@ moo_window_delete_event (GtkWidget *widget,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean save_size (MooWindow *window)
|
static gboolean
|
||||||
|
save_size (MooWindow *window)
|
||||||
{
|
{
|
||||||
window->priv->save_size_id = 0;
|
window->priv->save_size_id = 0;
|
||||||
|
|
||||||
|
@ -408,7 +425,8 @@ static gboolean save_size (MooWindow *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static gboolean moo_window_save_size (MooWindow *window)
|
static gboolean
|
||||||
|
moo_window_save_size (MooWindow *window)
|
||||||
{
|
{
|
||||||
if (!window->priv->save_size_id)
|
if (!window->priv->save_size_id)
|
||||||
window->priv->save_size_id =
|
window->priv->save_size_id =
|
||||||
|
@ -417,7 +435,8 @@ static gboolean moo_window_save_size (MooWindow *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
gboolean moo_window_close (MooWindow *window)
|
gboolean
|
||||||
|
moo_window_close (MooWindow *window)
|
||||||
{
|
{
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
g_signal_emit_by_name (window, "close", &result);
|
g_signal_emit_by_name (window, "close", &result);
|
||||||
|
@ -433,10 +452,11 @@ gboolean moo_window_close (MooWindow *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void moo_window_set_property (GObject *object,
|
static void
|
||||||
guint prop_id,
|
moo_window_set_property (GObject *object,
|
||||||
const GValue *value,
|
guint prop_id,
|
||||||
GParamSpec *pspec)
|
const GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
MooWindow *window = MOO_WINDOW (object);
|
MooWindow *window = MOO_WINDOW (object);
|
||||||
|
@ -479,10 +499,12 @@ static void moo_window_set_property (GObject *object,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void moo_window_get_property (GObject *object,
|
|
||||||
guint prop_id,
|
static void
|
||||||
GValue *value,
|
moo_window_get_property (GObject *object,
|
||||||
GParamSpec *pspec)
|
guint prop_id,
|
||||||
|
GValue *value,
|
||||||
|
GParamSpec *pspec)
|
||||||
{
|
{
|
||||||
MooWindow *window = MOO_WINDOW (object);
|
MooWindow *window = MOO_WINDOW (object);
|
||||||
|
|
||||||
|
@ -520,11 +542,11 @@ static void moo_window_get_property (GObject *object,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_TOOLBAR_VISIBLE:
|
case PROP_TOOLBAR_VISIBLE:
|
||||||
g_value_set_boolean (value, window->toolbar && GTK_WIDGET_VISIBLE (window->toolbar));
|
g_value_set_boolean (value, window->priv->toolbar_visible);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_MENUBAR_VISIBLE:
|
case PROP_MENUBAR_VISIBLE:
|
||||||
g_value_set_boolean (value, window->menubar && GTK_WIDGET_VISIBLE (window->menubar));
|
g_value_set_boolean (value, window->priv->menubar_visible);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -538,7 +560,6 @@ static gboolean
|
||||||
moo_window_create_ui (MooWindow *window)
|
moo_window_create_ui (MooWindow *window)
|
||||||
{
|
{
|
||||||
MooUIXML *xml;
|
MooUIXML *xml;
|
||||||
MooAction *show_toolbar, *show_menubar;
|
|
||||||
GtkToolbarStyle style;
|
GtkToolbarStyle style;
|
||||||
|
|
||||||
g_return_val_if_fail (MOO_IS_WINDOW (window), FALSE);
|
g_return_val_if_fail (MOO_IS_WINDOW (window), FALSE);
|
||||||
|
@ -571,11 +592,9 @@ moo_window_create_ui (MooWindow *window)
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (window->priv->menubar_holder),
|
gtk_box_pack_start (GTK_BOX (window->priv->menubar_holder),
|
||||||
window->menubar, FALSE, FALSE, 0);
|
window->menubar, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (window->menubar);
|
|
||||||
|
|
||||||
show_menubar = moo_action_group_get_action (actions, "ShowMenubar");
|
if (window->priv->menubar_visible)
|
||||||
moo_toggle_action_set_active (MOO_TOGGLE_ACTION (show_menubar),
|
gtk_widget_show (window->menubar);
|
||||||
moo_prefs_get_bool (setting (window, PREFS_SHOW_MENUBAR)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window->priv->toolbar_ui_name && window->priv->toolbar_ui_name[0])
|
if (window->priv->toolbar_ui_name && window->priv->toolbar_ui_name[0])
|
||||||
|
@ -592,11 +611,9 @@ moo_window_create_ui (MooWindow *window)
|
||||||
|
|
||||||
gtk_box_pack_start (GTK_BOX (window->priv->toolbar_holder),
|
gtk_box_pack_start (GTK_BOX (window->priv->toolbar_holder),
|
||||||
window->toolbar, FALSE, FALSE, 0);
|
window->toolbar, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (window->toolbar);
|
|
||||||
|
|
||||||
show_toolbar = moo_action_group_get_action (actions, "ShowToolbar");
|
if (window->priv->toolbar_visible)
|
||||||
moo_toggle_action_set_active (MOO_TOGGLE_ACTION (show_toolbar),
|
gtk_widget_show (window->toolbar);
|
||||||
moo_prefs_get_bool (setting (window, PREFS_SHOW_TOOLBAR)));
|
|
||||||
|
|
||||||
style = get_toolbar_style (window);
|
style = get_toolbar_style (window);
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (MOO_WINDOW(window)->toolbar), style);
|
gtk_toolbar_set_style (GTK_TOOLBAR (MOO_WINDOW(window)->toolbar), style);
|
||||||
|
@ -606,7 +623,8 @@ moo_window_create_ui (MooWindow *window)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void moo_window_shortcuts_prefs_dialog (MooWindow *window)
|
static void
|
||||||
|
moo_window_shortcuts_prefs_dialog (MooWindow *window)
|
||||||
{
|
{
|
||||||
moo_accel_prefs_dialog_run (moo_window_get_actions (window),
|
moo_accel_prefs_dialog_run (moo_window_get_actions (window),
|
||||||
GTK_WIDGET (window));
|
GTK_WIDGET (window));
|
||||||
|
@ -617,12 +635,12 @@ static void
|
||||||
moo_window_set_toolbar_visible (MooWindow *window,
|
moo_window_set_toolbar_visible (MooWindow *window,
|
||||||
gboolean visible)
|
gboolean visible)
|
||||||
{
|
{
|
||||||
if (window->toolbar && visible != GTK_WIDGET_VISIBLE (window->toolbar))
|
if (!visible != !window->priv->toolbar_visible)
|
||||||
{
|
{
|
||||||
if (visible)
|
window->priv->toolbar_visible = visible != 0;
|
||||||
gtk_widget_show (window->toolbar);
|
|
||||||
else
|
if (window->toolbar)
|
||||||
gtk_widget_hide (window->toolbar);
|
g_object_set (window->toolbar, "visible", visible, NULL);
|
||||||
|
|
||||||
moo_prefs_set_bool (setting (window, PREFS_SHOW_TOOLBAR), visible);
|
moo_prefs_set_bool (setting (window, PREFS_SHOW_TOOLBAR), visible);
|
||||||
g_object_notify (G_OBJECT (window), "toolbar-visible");
|
g_object_notify (G_OBJECT (window), "toolbar-visible");
|
||||||
|
@ -634,12 +652,12 @@ static void
|
||||||
moo_window_set_menubar_visible (MooWindow *window,
|
moo_window_set_menubar_visible (MooWindow *window,
|
||||||
gboolean visible)
|
gboolean visible)
|
||||||
{
|
{
|
||||||
if (window->menubar && visible != GTK_WIDGET_VISIBLE (window->menubar))
|
if (!visible != !window->priv->menubar_visible)
|
||||||
{
|
{
|
||||||
if (visible)
|
window->priv->menubar_visible = visible != 0;
|
||||||
gtk_widget_show (window->menubar);
|
|
||||||
else
|
if (window->menubar)
|
||||||
gtk_widget_hide (window->menubar);
|
g_object_set (window->menubar, "visible", visible, NULL);
|
||||||
|
|
||||||
moo_prefs_set_bool (setting (window, PREFS_SHOW_MENUBAR), visible);
|
moo_prefs_set_bool (setting (window, PREFS_SHOW_MENUBAR), visible);
|
||||||
g_object_notify (G_OBJECT (window), "menubar-visible");
|
g_object_notify (G_OBJECT (window), "menubar-visible");
|
||||||
|
|
Loading…
Reference in New Issue