diff options
author | Christian Persch <chpe@cvs.gnome.org> | 2005-02-10 05:08:03 +0800 |
---|---|---|
committer | Christian Persch <chpe@src.gnome.org> | 2005-02-10 05:08:03 +0800 |
commit | 712dc29890aa60293a880a7a1a9a8b03f0cf2e60 (patch) | |
tree | 23c6203659f652442a8b9c057a4c841862509b1d /src/ephy-toolbars-model.c | |
parent | f8ab0f22d40c474e5c9bd23cacc7fedeacade0fa (diff) | |
download | gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar.gz gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar.bz2 gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar.lz gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar.xz gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.tar.zst gsoc2013-epiphany-712dc29890aa60293a880a7a1a9a8b03f0cf2e60.zip |
Move style notifier to ephy-toolbars-model, and also apply the flags to
2005-02-09 Christian Persch <chpe@cvs.gnome.org>
* src/ephy-shell.c: (ephy_shell_finalize),
(ephy_shell_get_toolbars_model):
* src/ephy-toolbars-model.c: (update_flags),
(update_flags_and_save_changes), (get_toolbar_style),
(toolbar_style_notifier), (ephy_toolbars_model_init),
(ephy_toolbars_model_finalize):
Move style notifier to ephy-toolbars-model, and also apply
the flags to newly added toolbars.
Diffstat (limited to 'src/ephy-toolbars-model.c')
-rwxr-xr-x | src/ephy-toolbars-model.c | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c index 785974877..b36c0cc1b 100755 --- a/src/ephy-toolbars-model.c +++ b/src/ephy-toolbars-model.c @@ -23,6 +23,9 @@ #include "ephy-toolbars-model.h" #include "ephy-file-helpers.h" +#include "ephy-prefs.h" +#include "eel-gconf-extensions.h" +#include "eggtypebuiltins.h" #include "ephy-debug.h" #include <string.h> @@ -35,7 +38,9 @@ struct _EphyToolbarsModelPrivate { char *xml_file; + EggTbModelFlags style; guint timeout; + guint style_notifier_id; }; static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass); @@ -97,7 +102,7 @@ save_changes (EphyToolbarsModel *model) } static void -update_flags_and_save_changes (EphyToolbarsModel *model) +update_flags (EphyToolbarsModel *model) { EggToolbarsModel *eggmodel = EGG_TOOLBARS_MODEL (model); int i, n_toolbars; @@ -119,11 +124,17 @@ update_flags_and_save_changes (EphyToolbarsModel *model) g_return_if_fail (t_name != NULL); flags = egg_toolbars_model_get_flags (eggmodel, i); - flags &= ~EGG_TB_MODEL_NOT_REMOVABLE; + flags &= ~(EGG_TB_MODEL_NOT_REMOVABLE | EGG_TB_MODEL_STYLES_MASK); flags |= flag; + flags |= model->priv->style; egg_toolbars_model_set_flags (eggmodel, i, flags); } +} +static void +update_flags_and_save_changes (EphyToolbarsModel *model) +{ + update_flags (model); save_changes (model); } @@ -150,6 +161,43 @@ get_toolbar_pos (EggToolbarsModel *model, return -1; } +static EggTbModelFlags +get_toolbar_style (void) +{ + GFlagsClass *flags_class; + const GFlagsValue *value; + EggTbModelFlags flags = 0; + char *pref; + + pref = eel_gconf_get_string (CONF_INTERFACE_TOOLBAR_STYLE); + if (pref != NULL) + { + flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS); + value = g_flags_get_value_by_nick (flags_class, pref); + if (value != NULL) + { + flags = value->value; + } + g_type_class_unref (flags_class); + } + flags &= EGG_TB_MODEL_STYLES_MASK; + + g_free (pref); + + return flags; +} + +static void +toolbar_style_notifier (GConfClient *client, + guint cnxn_id, + GConfEntry *entry, + EphyToolbarsModel *model) +{ + model->priv->style = get_toolbar_style (); + + update_flags (model); +} + void ephy_toolbars_model_load (EphyToolbarsModel *model) { @@ -203,12 +251,19 @@ ephy_toolbars_model_load (EphyToolbarsModel *model) static void ephy_toolbars_model_init (EphyToolbarsModel *model) { - model->priv = EPHY_TOOLBARS_MODEL_GET_PRIVATE (model); + EphyToolbarsModelPrivate *priv; + + priv = model->priv = EPHY_TOOLBARS_MODEL_GET_PRIVATE (model); - model->priv->xml_file = g_build_filename (ephy_dot_dir (), - EPHY_TOOLBARS_XML_FILE, - NULL); + priv->xml_file = g_build_filename (ephy_dot_dir (), + EPHY_TOOLBARS_XML_FILE, + NULL); + priv->style = get_toolbar_style (); + priv->style_notifier_id = eel_gconf_notification_add + (CONF_INTERFACE_TOOLBAR_STYLE, + (GConfClientNotifyFunc) toolbar_style_notifier, model); + g_signal_connect_after (model, "item_added", G_CALLBACK (save_changes), NULL); g_signal_connect_after (model, "item_removed", @@ -233,14 +288,19 @@ static void ephy_toolbars_model_finalize (GObject *object) { EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (object); + EphyToolbarsModelPrivate *priv = model->priv; + + if (priv->style_notifier_id != 0) + { + eel_gconf_notification_remove (priv->style_notifier_id); + } - if (model->priv->timeout != 0) + if (priv->timeout != 0) { - g_source_remove (model->priv->timeout); - model->priv->timeout = 0; + g_source_remove (priv->timeout); } - g_free (model->priv->xml_file); + g_free (priv->xml_file); G_OBJECT_CLASS (parent_class)->finalize (object); } |