[gedit-plugins] Port showtabbar plugin to gsettings.
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] Port showtabbar plugin to gsettings.
- Date: Sat, 22 May 2010 23:43:30 +0000 (UTC)
commit b4035b06c1f2f093b8e29a9b757b437b8d047b8a
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Sun May 23 01:38:45 2010 +0200
Port showtabbar plugin to gsettings.
configure.ac | 1 +
plugins/showtabbar/Makefile.am | 27 ++----
plugins/showtabbar/gedit-show-tabbar-plugin.c | 103 ++++++++------------
plugins/showtabbar/gedit-show-tabbar-plugin.h | 3 +
.../showtabbar/gedit-show-tabbar-plugin.schemas.in | 15 ---
.../org.gnome.gedit.showtabbar.gschema.xml.in.in | 9 ++
6 files changed, 63 insertions(+), 95 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index dddfb1f..27d4c93 100644
--- a/configure.ac
+++ b/configure.ac
@@ -463,6 +463,7 @@ plugins/sessionsaver/Makefile
plugins/sessionsaver/sessionsaver.gedit-plugin.desktop.in
plugins/showtabbar/Makefile
plugins/showtabbar/showtabbar.gedit-plugin.desktop.in
+plugins/showtabbar/org.gnome.gedit.showtabbar.gschema.xml.in
plugins/smartspaces/Makefile
plugins/smartspaces/smartspaces.gedit-plugin.desktop.in
plugins/terminal/Makefile
diff --git a/plugins/showtabbar/Makefile.am b/plugins/showtabbar/Makefile.am
index 45e9f84..19aac57 100644
--- a/plugins/showtabbar/Makefile.am
+++ b/plugins/showtabbar/Makefile.am
@@ -24,25 +24,14 @@ plugin_in_files = showtabbar.gedit-plugin.desktop.in
plugin_DATA = $(plugin_in_files:.gedit-plugin.desktop.in=.gedit-plugin)
-# GConf Schemas
-
-schemasdir = $(GCONF_SCHEMA_FILE_DIR)
-schemas_in_files = gedit-show-tabbar-plugin.schemas.in
-schemas_DATA = $(schemas_in_files:.schemas.in=.schemas)
- INTLTOOL_SCHEMAS_RULE@
-
-if GCONF_SCHEMAS_INSTALL
-install-data-local:
- if test -z "$(DESTDIR)" ; then \
- for p in $(schemas_DATA) ; do \
- GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $$p ; \
- done \
- fi
-else
-install-data-local:
-endif
-
-EXTRA_DIST = $(plugin_in_files) $(schemas_in_files)
+# GSettings Schemas
+
+gsettings_SCHEMAS = org.gnome.gedit.showtabbar.gschema.xml
+
+ INTLTOOL_XML_NOMERGE_RULE@
+ GSETTINGS_RULES@
+
+EXTRA_DIST = $(plugin_in_files) $(gsettings_SCHEMAS)
CLEANFILES = $(plugin_DATA) $(schemas_DATA)
DISTCLEANFILES = $(plugin_DATA) $(schemas_DATA)
diff --git a/plugins/showtabbar/gedit-show-tabbar-plugin.c b/plugins/showtabbar/gedit-show-tabbar-plugin.c
index 3b4d42c..b0e5d69 100644
--- a/plugins/showtabbar/gedit-show-tabbar-plugin.c
+++ b/plugins/showtabbar/gedit-show-tabbar-plugin.c
@@ -28,22 +28,28 @@
#include <glib/gi18n-lib.h>
#include <gedit/gedit-debug.h>
-#include <gconf/gconf-client.h>
-#define WINDOW_DATA_KEY "GeditShowTabbarWindowData"
-#define MENU_PATH "/MenuBar/ViewMenu"
-#define GCONF_BASE_KEY "/apps/gedit-2/plugins/showtabbar"
+#define WINDOW_DATA_KEY "GeditShowTabbarWindowData"
+#define MENU_PATH "/MenuBar/ViewMenu"
+#define GSETTINGS_BASE_KEY "org.gnome.gedit.plugins.showtabbar"
+#define GSETTINGS_KEY_TABBAR "tabbar-visible"
#define GEDIT_SHOW_TABBAR_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GEDIT_TYPE_SHOW_TABBAR_PLUGIN, GeditShowTabbarPluginPrivate))
GEDIT_PLUGIN_REGISTER_TYPE (GeditShowTabbarPlugin, gedit_show_tabbar_plugin)
+struct _GeditShowTabbarPluginPrivate
+{
+ GSettings *settings;
+};
+
typedef struct
{
- GtkActionGroup *action_group;
- guint ui_id;
- gulong signal_handler_id;
+ GeditShowTabbarPlugin *plugin;
+ GtkActionGroup *action_group;
+ guint ui_id;
+ gulong signal_handler_id;
} WindowData;
static void
@@ -51,61 +57,27 @@ gedit_show_tabbar_plugin_init (GeditShowTabbarPlugin *plugin)
{
gedit_debug_message (DEBUG_PLUGINS,
"GeditShowTabbarPlugin initializing");
-}
-static void
-gedit_show_tabbar_plugin_finalize (GObject *object)
-{
- gedit_debug_message (DEBUG_PLUGINS,
- "GeditShowTabbarPlugin finalizing");
+ plugin->priv = GEDIT_SHOW_TABBAR_PLUGIN_GET_PRIVATE (plugin);
- G_OBJECT_CLASS (gedit_show_tabbar_plugin_parent_class)->finalize (object);
+ plugin->priv->settings = g_settings_new (GSETTINGS_BASE_KEY);
}
-static gboolean
-gconf_load_tabbar_visible (void)
+static void
+gedit_show_tabbar_plugin_dispose (GObject *object)
{
- GConfClient *client;
- GConfValue *value;
-
- client = gconf_client_get_default ();
-
- value = gconf_client_get (client,
- GCONF_BASE_KEY "/tabbar_visible",
- NULL);
-
- g_object_unref (client);
-
- if (value != NULL)
- {
- gboolean visible;
+ GeditShowTabbarPlugin *plugin = GEDIT_SHOW_TABBAR_PLUGIN (object);
- visible = (value->type == GCONF_VALUE_BOOL)
- ? gconf_value_get_bool (value)
- : TRUE;
- gconf_value_free (value);
+ gedit_debug_message (DEBUG_PLUGINS,
+ "GeditShowTabbarPlugin disposing");
- return visible;
- }
- else
+ if (plugin->priv->settings != NULL)
{
- return TRUE; /* default value */
+ g_object_unref (plugin->priv->settings);
+ plugin->priv->settings = NULL;
}
-}
-
-static void
-gconf_store_tabbar_visible (gboolean visible)
-{
- GConfClient *client;
- client = gconf_client_get_default ();
-
- gconf_client_set_bool (client,
- GCONF_BASE_KEY "/tabbar_visible",
- visible,
- NULL);
-
- g_object_unref (client);
+ G_OBJECT_CLASS (gedit_show_tabbar_plugin_parent_class)->dispose (object);
}
static GtkNotebook *
@@ -138,8 +110,9 @@ get_notebook (GeditWindow *window)
static void
on_notebook_show_tabs_changed (GtkNotebook *notebook,
GParamSpec *pspec,
- GtkToggleAction *action)
+ WindowData *data)
{
+ GtkAction *action;
gboolean visible;
#if 0
@@ -151,14 +124,18 @@ on_notebook_show_tabs_changed (GtkNotebook *notebook,
gtk_toggle_action_set_active (action, visible);
#endif
- visible = gtk_toggle_action_get_active (action);
+ action = gtk_action_group_get_action (data->action_group,
+ "ShowTabbar");
+ visible = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
/* this is intendend to avoid the GeditNotebook to show the tabs again
(it does so everytime a new tab is added) */
if (visible != gtk_notebook_get_show_tabs (notebook))
gtk_notebook_set_show_tabs (notebook, visible);
- gconf_store_tabbar_visible (visible);
+ g_settings_set_boolean (data->plugin->priv->settings,
+ GSETTINGS_KEY_TABBAR,
+ visible);
}
static void
@@ -175,7 +152,7 @@ free_window_data (WindowData *data)
g_return_if_fail (data != NULL);
g_object_unref (data->action_group);
- g_free (data);
+ g_slice_free (WindowData, data);
}
static void
@@ -190,14 +167,16 @@ impl_activate (GeditPlugin *plugin,
gedit_debug (DEBUG_PLUGINS);
- visible = gconf_load_tabbar_visible ();
+ data = g_slice_new (WindowData);
+ data->plugin = GEDIT_SHOW_TABBAR_PLUGIN (plugin);
+
+ visible = g_settings_get_boolean (data->plugin->priv->settings,
+ GSETTINGS_KEY_TABBAR);
notebook = get_notebook (window);
gtk_notebook_set_show_tabs (notebook, visible);
- data = g_new (WindowData, 1);
-
manager = gedit_window_get_ui_manager (window);
data->action_group = gtk_action_group_new ("GeditHideTabbarPluginActions");
@@ -234,7 +213,7 @@ impl_activate (GeditPlugin *plugin,
g_signal_connect (notebook,
"notify::show-tabs",
G_CALLBACK (on_notebook_show_tabs_changed),
- action);
+ data);
g_object_set_data_full (G_OBJECT (window),
WINDOW_DATA_KEY,
@@ -272,7 +251,9 @@ gedit_show_tabbar_plugin_class_init (GeditShowTabbarPluginClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GeditPluginClass *plugin_class = GEDIT_PLUGIN_CLASS (klass);
- object_class->finalize = gedit_show_tabbar_plugin_finalize;
+ g_type_class_add_private (object_class, sizeof (GeditShowTabbarPluginPrivate));
+
+ object_class->dispose = gedit_show_tabbar_plugin_dispose;
plugin_class->activate = impl_activate;
plugin_class->deactivate = impl_deactivate;
diff --git a/plugins/showtabbar/gedit-show-tabbar-plugin.h b/plugins/showtabbar/gedit-show-tabbar-plugin.h
index f24a067..2646c64 100644
--- a/plugins/showtabbar/gedit-show-tabbar-plugin.h
+++ b/plugins/showtabbar/gedit-show-tabbar-plugin.h
@@ -50,6 +50,9 @@ typedef struct _GeditShowTabbarPlugin GeditShowTabbarPlugin;
struct _GeditShowTabbarPlugin
{
GeditPlugin parent_instance;
+
+ /* private */
+ GeditShowTabbarPluginPrivate *priv;
};
/*
diff --git a/plugins/showtabbar/org.gnome.gedit.showtabbar.gschema.xml.in.in b/plugins/showtabbar/org.gnome.gedit.showtabbar.gschema.xml.in.in
new file mode 100644
index 0000000..5c3737d
--- /dev/null
+++ b/plugins/showtabbar/org.gnome.gedit.showtabbar.gschema.xml.in.in
@@ -0,0 +1,9 @@
+<schemalist>
+ <schema gettext-domain="@GETTEXT_PACKAGE@" id="org.gnome.gedit.plugins.showtabbar" path="/apps/gedit/plugins/showtabbar/">
+ <key name="tabbar-visible" type="b">
+ <default>true</default>
+ <_summary>Tabbar is Visible</_summary>
+ <_description>Whether the tabbar should be visible in editing windows.</_description>
+ </key>
+ </schema>
+</schemalist>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]