[gedit-plugins] drawspaces: split app activatable into its own file
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit-plugins] drawspaces: split app activatable into its own file
- Date: Mon, 31 Mar 2014 17:06:07 +0000 (UTC)
commit 3c760068879d79e16a0b9bb05a0638e5fc3f9c21
Author: Ignacio Casal Quinteiro <icq gnome org>
Date: Mon Mar 31 14:48:02 2014 +0200
drawspaces: split app activatable into its own file
plugins/drawspaces/Makefile.am | 2 +
.../drawspaces/gedit-drawspaces-app-activatable.c | 170 ++++++++++++++++++++
.../drawspaces/gedit-drawspaces-app-activatable.h | 56 +++++++
plugins/drawspaces/gedit-drawspaces-plugin.c | 59 +-------
4 files changed, 230 insertions(+), 57 deletions(-)
---
diff --git a/plugins/drawspaces/Makefile.am b/plugins/drawspaces/Makefile.am
index f1ccee7..b0292e6 100644
--- a/plugins/drawspaces/Makefile.am
+++ b/plugins/drawspaces/Makefile.am
@@ -31,6 +31,8 @@ BUILT_SOURCES += \
plugins_drawspaces_libdrawspaces_la_SOURCES = \
plugins/drawspaces/gedit-drawspaces-plugin.h \
plugins/drawspaces/gedit-drawspaces-plugin.c \
+ plugins/drawspaces/gedit-drawspaces-app-activatable.h \
+ plugins/drawspaces/gedit-drawspaces-app-activatable.c \
$(BUILT_SOURCES)
plugin_in_files += plugins/drawspaces/drawspaces.plugin.desktop.in
diff --git a/plugins/drawspaces/gedit-drawspaces-app-activatable.c
b/plugins/drawspaces/gedit-drawspaces-app-activatable.c
new file mode 100644
index 0000000..b462c1f
--- /dev/null
+++ b/plugins/drawspaces/gedit-drawspaces-app-activatable.c
@@ -0,0 +1,170 @@
+/*
+ * Copyright (C) 2008-2014 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gedit-drawspaces-app-activatable.h"
+
+#include <gedit/gedit-app.h>
+#include <gedit/gedit-app-activatable.h>
+#include <gedit/gedit-debug.h>
+#include <libpeas/peas-object-module.h>
+#include <gio/gio.h>
+#include <glib/gi18n-lib.h>
+
+struct _GeditDrawspacesAppActivatablePrivate
+{
+ GeditApp *app;
+ GeditMenuExtension *menu_ext;
+};
+
+enum
+{
+ PROP_0,
+ PROP_APP
+};
+
+static void gedit_app_activatable_iface_init (GeditAppActivatableInterface *iface);
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditDrawspacesAppActivatable,
+ gedit_drawspaces_app_activatable,
+ G_TYPE_OBJECT,
+ 0,
+ G_ADD_PRIVATE_DYNAMIC (GeditDrawspacesAppActivatable)
+ G_IMPLEMENT_INTERFACE_DYNAMIC (GEDIT_TYPE_APP_ACTIVATABLE,
+ gedit_app_activatable_iface_init))
+
+static void
+gedit_drawspaces_app_activatable_dispose (GObject *object)
+{
+ GeditDrawspacesAppActivatable *activatable = GEDIT_DRAWSPACES_APP_ACTIVATABLE (object);
+ GeditDrawspacesAppActivatablePrivate *priv = gedit_drawspaces_app_activatable_get_instance_private
(activatable);
+
+ g_clear_object (&priv->app);
+
+ G_OBJECT_CLASS (gedit_drawspaces_app_activatable_parent_class)->dispose (object);
+}
+
+static void
+gedit_drawspaces_app_activatable_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ GeditDrawspacesAppActivatable *activatable = GEDIT_DRAWSPACES_APP_ACTIVATABLE (object);
+ GeditDrawspacesAppActivatablePrivate *priv = gedit_drawspaces_app_activatable_get_instance_private
(activatable);
+
+ switch (prop_id)
+ {
+ case PROP_APP:
+ priv->app = GEDIT_APP (g_value_dup_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_drawspaces_app_activatable_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ GeditDrawspacesAppActivatable *activatable = GEDIT_DRAWSPACES_APP_ACTIVATABLE (object);
+ GeditDrawspacesAppActivatablePrivate *priv = gedit_drawspaces_app_activatable_get_instance_private
(activatable);
+
+ switch (prop_id)
+ {
+ case PROP_APP:
+ g_value_set_object (value, priv->app);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+static void
+gedit_drawspaces_app_activatable_class_init (GeditDrawspacesAppActivatableClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+ object_class->dispose = gedit_drawspaces_app_activatable_dispose;
+ object_class->set_property = gedit_drawspaces_app_activatable_set_property;
+ object_class->get_property = gedit_drawspaces_app_activatable_get_property;
+
+ g_object_class_override_property (object_class, PROP_APP, "app");
+}
+
+static void
+gedit_drawspaces_app_activatable_class_finalize (GeditDrawspacesAppActivatableClass *klass)
+{
+}
+
+static void
+gedit_drawspaces_app_activatable_init (GeditDrawspacesAppActivatable *self)
+{
+}
+
+static void
+gedit_drawspaces_app_activatable_activate (GeditAppActivatable *activatable)
+{
+ GeditDrawspacesAppActivatable *app_activatable = GEDIT_DRAWSPACES_APP_ACTIVATABLE (activatable);
+ GeditDrawspacesAppActivatablePrivate *priv = gedit_drawspaces_app_activatable_get_instance_private
(app_activatable);
+ GMenuItem *item;
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ priv->menu_ext = gedit_app_activatable_extend_menu (activatable, "view-section-2");
+ item = g_menu_item_new (_("Show _White Space"), "win.show-white-space");
+ gedit_menu_extension_append_menu_item (priv->menu_ext, item);
+ g_object_unref (item);
+}
+
+static void
+gedit_drawspaces_app_activatable_deactivate (GeditAppActivatable *activatable)
+{
+ GeditDrawspacesAppActivatable *app_activatable = GEDIT_DRAWSPACES_APP_ACTIVATABLE (activatable);
+ GeditDrawspacesAppActivatablePrivate *priv = gedit_drawspaces_app_activatable_get_instance_private
(app_activatable);
+
+ gedit_debug (DEBUG_PLUGINS);
+
+ g_clear_object (&priv->menu_ext);
+}
+
+static void
+gedit_app_activatable_iface_init (GeditAppActivatableInterface *iface)
+{
+ iface->activate = gedit_drawspaces_app_activatable_activate;
+ iface->deactivate = gedit_drawspaces_app_activatable_deactivate;
+}
+
+void
+gedit_drawspaces_app_activatable_register (GTypeModule *module)
+{
+ gedit_drawspaces_app_activatable_register_type (module);
+
+ peas_object_module_register_extension_type (PEAS_OBJECT_MODULE (module),
+ GEDIT_TYPE_APP_ACTIVATABLE,
+ GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE);
+}
+
+/* ex:set ts=8 noet: */
diff --git a/plugins/drawspaces/gedit-drawspaces-app-activatable.h
b/plugins/drawspaces/gedit-drawspaces-app-activatable.h
new file mode 100644
index 0000000..435686e
--- /dev/null
+++ b/plugins/drawspaces/gedit-drawspaces-app-activatable.h
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2008-2014 Ignacio Casal Quinteiro <icq gnome org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __GEDIT_DRAWSPACES_APP_ACTIVATABLE_H__
+#define __GEDIT_DRAWSPACES_APP_ACTIVATABLE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE (gedit_drawspaces_app_activatable_get_type ())
+#define GEDIT_DRAWSPACES_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE, GeditDrawspacesAppActivatable))
+#define GEDIT_DRAWSPACES_APP_ACTIVATABLE_CONST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE, GeditDrawspacesAppActivatable const))
+#define GEDIT_DRAWSPACES_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE, GeditDrawspacesAppActivatableClass))
+#define GEDIT_IS_DRAWSPACES_APP_ACTIVATABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE))
+#define GEDIT_IS_DRAWSPACES_APP_ACTIVATABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE))
+#define GEDIT_DRAWSPACES_APP_ACTIVATABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),
GEDIT_TYPE_DRAWSPACES_APP_ACTIVATABLE, GeditDrawspacesAppActivatableClass))
+
+typedef struct _GeditDrawspacesAppActivatable GeditDrawspacesAppActivatable;
+typedef struct _GeditDrawspacesAppActivatableClass GeditDrawspacesAppActivatableClass;
+typedef struct _GeditDrawspacesAppActivatablePrivate GeditDrawspacesAppActivatablePrivate;
+
+struct _GeditDrawspacesAppActivatable
+{
+ GObject parent;
+
+ GeditDrawspacesAppActivatablePrivate *priv;
+};
+
+struct _GeditDrawspacesAppActivatableClass
+{
+ GObjectClass parent_class;
+};
+
+GType gedit_drawspaces_app_activatable_get_type (void) G_GNUC_CONST;
+
+void gedit_drawspaces_app_activatable_register (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __GEDIT_DRAWSPACES_APP_ACTIVATABLE_H__ */
diff --git a/plugins/drawspaces/gedit-drawspaces-plugin.c b/plugins/drawspaces/gedit-drawspaces-plugin.c
index 266ba66..0c23d4b 100644
--- a/plugins/drawspaces/gedit-drawspaces-plugin.c
+++ b/plugins/drawspaces/gedit-drawspaces-plugin.c
@@ -21,13 +21,12 @@
#endif
#include "gedit-drawspaces-plugin.h"
+#include "gedit-drawspaces-app-activatable.h"
#include <glib/gi18n-lib.h>
#include <gedit/gedit-debug.h>
#include <gedit/gedit-view.h>
#include <gedit/gedit-tab.h>
-#include <gedit/gedit-app.h>
-#include <gedit/gedit-app-activatable.h>
#include <gedit/gedit-window.h>
#include <gedit/gedit-window-activatable.h>
#include <gedit/gedit-utils.h>
@@ -44,7 +43,6 @@
GEDIT_TYPE_DRAWSPACES_PLUGIN, \
GeditDrawspacesPluginPrivate))
-static void gedit_app_activatable_iface_init (GeditAppActivatableInterface *iface);
static void gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface);
static void peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface);
@@ -52,8 +50,6 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditDrawspacesPlugin,
gedit_drawspaces_plugin,
PEAS_TYPE_EXTENSION_BASE,
0,
- G_IMPLEMENT_INTERFACE_DYNAMIC (GEDIT_TYPE_APP_ACTIVATABLE,
- gedit_app_activatable_iface_init)
G_IMPLEMENT_INTERFACE_DYNAMIC (GEDIT_TYPE_WINDOW_ACTIVATABLE,
gedit_window_activatable_iface_init)
G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_GTK_TYPE_CONFIGURABLE,
@@ -61,9 +57,6 @@ G_DEFINE_DYNAMIC_TYPE_EXTENDED (GeditDrawspacesPlugin,
struct _GeditDrawspacesPluginPrivate
{
- GeditApp *app;
- GeditMenuExtension *menu_ext;
-
GSettings *settings;
GeditWindow *window;
GtkSourceDrawSpacesFlags flags;
@@ -152,8 +145,6 @@ gedit_drawspaces_plugin_dispose (GObject *object)
gedit_debug_message (DEBUG_PLUGINS, "GeditDrawspacesPlugin disposing");
- g_clear_object (&plugin->priv->app);
- g_clear_object (&plugin->priv->menu_ext);
g_clear_object (&priv->settings);
g_clear_object (&priv->window);
@@ -170,9 +161,6 @@ gedit_drawspaces_plugin_set_property (GObject *object,
switch (prop_id)
{
- case PROP_APP:
- plugin->priv->app = GEDIT_APP (g_value_dup_object (value));
- break;
case PROP_WINDOW:
plugin->priv->window = GEDIT_WINDOW (g_value_dup_object (value));
break;
@@ -192,9 +180,6 @@ gedit_drawspaces_plugin_get_property (GObject *object,
switch (prop_id)
{
- case PROP_APP:
- g_value_set_object (value, plugin->priv->app);
- break;
case PROP_WINDOW:
g_value_set_object (value, plugin->priv->window);
break;
@@ -251,36 +236,6 @@ get_config_options (GeditDrawspacesPlugin *plugin)
}
static void
-gedit_drawspaces_plugin_app_activate (GeditAppActivatable *activatable)
-{
- GeditDrawspacesPluginPrivate *priv;
- GMenuItem *item;
- GAction *action;
-
- gedit_debug (DEBUG_PLUGINS);
-
- priv = GEDIT_DRAWSPACES_PLUGIN (activatable)->priv;
-
- priv->menu_ext = gedit_app_activatable_extend_menu (activatable, "view-section-2");
- item = g_menu_item_new (_("Show _White Space"), "win.show-white-space");
- gedit_menu_extension_append_menu_item (priv->menu_ext, item);
- g_object_unref (item);
-}
-
-static void
-gedit_drawspaces_plugin_app_deactivate (GeditAppActivatable *activatable)
-{
- GeditDrawspacesPluginPrivate *priv;
- GtkUIManager *manager;
-
- gedit_debug (DEBUG_PLUGINS);
-
- priv = GEDIT_DRAWSPACES_PLUGIN (activatable)->priv;
-
- g_clear_object (&priv->menu_ext);
-}
-
-static void
gedit_drawspaces_plugin_window_activate (GeditWindowActivatable *activatable)
{
GeditDrawspacesPluginPrivate *priv;
@@ -502,7 +457,6 @@ gedit_drawspaces_plugin_class_init (GeditDrawspacesPluginClass *klass)
object_class->set_property = gedit_drawspaces_plugin_set_property;
object_class->get_property = gedit_drawspaces_plugin_get_property;
- g_object_class_override_property (object_class, PROP_APP, "app");
g_object_class_override_property (object_class, PROP_WINDOW, "window");
g_type_class_add_private (object_class, sizeof (GeditDrawspacesPluginPrivate));
@@ -520,13 +474,6 @@ peas_gtk_configurable_iface_init (PeasGtkConfigurableInterface *iface)
}
static void
-gedit_app_activatable_iface_init (GeditAppActivatableInterface *iface)
-{
- iface->activate = gedit_drawspaces_plugin_app_activate;
- iface->deactivate = gedit_drawspaces_plugin_app_deactivate;
-}
-
-static void
gedit_window_activatable_iface_init (GeditWindowActivatableInterface *iface)
{
iface->activate = gedit_drawspaces_plugin_window_activate;
@@ -537,11 +484,9 @@ G_MODULE_EXPORT void
peas_register_types (PeasObjectModule *module)
{
gedit_drawspaces_plugin_register_type (G_TYPE_MODULE (module));
+ gedit_drawspaces_app_activatable_register (G_TYPE_MODULE (module));
peas_object_module_register_extension_type (module,
- GEDIT_TYPE_APP_ACTIVATABLE,
- GEDIT_TYPE_DRAWSPACES_PLUGIN);
- peas_object_module_register_extension_type (module,
GEDIT_TYPE_WINDOW_ACTIVATABLE,
GEDIT_TYPE_DRAWSPACES_PLUGIN);
peas_object_module_register_extension_type (module,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]