[gedit/wip/configurable: 5/5] Add GeditConfigurable



commit 1c742abc7a86f86f12d0359590abaa84781f6050
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Sat Apr 27 12:26:23 2013 +0200

    Add GeditConfigurable

 gedit/Makefile.am          |    4 +-
 gedit/gedit-configurable.c |   98 ++++++++++++++++++++++++++++++++++++++++++++
 gedit/gedit-configurable.h |   65 +++++++++++++++++++++++++++++
 3 files changed, 166 insertions(+), 1 deletions(-)
---
diff --git a/gedit/Makefile.am b/gedit/Makefile.am
index 0b06442..6dd6636 100644
--- a/gedit/Makefile.am
+++ b/gedit/Makefile.am
@@ -130,6 +130,7 @@ INST_H_FILES =                              \
        gedit-app.h                     \
        gedit-app-activatable.h         \
        gedit-commands.h                \
+       gedit-configurable.h            \
        gedit-debug.h                   \
        gedit-document.h                \
        gedit-encodings.h               \
@@ -160,6 +161,7 @@ BUILT_SOURCES_PRIVATE = \
 
 libgedit_private_la_SOURCES =          \
        gedit-app-activatable.c         \
+       gedit-configurable.c            \
        gedit-view-activatable.c        \
        gedit-window-activatable.c      \
        gedit-resources.c
@@ -276,7 +278,7 @@ INTROSPECTION_SCANNER_ARGS = -I$(top_srcdir) --warn-all
 Gedit_3_0_gir_NAMESPACE = Gedit
 Gedit_3_0_gir_VERSION = 3.0
 Gedit_3_0_gir_PROGRAM = $(builddir)/gedit
-Gedit_3_0_gir_FILES = $(INST_H_FILES) $(libgedit_c_files) $(BUILT_SOURCES)
+Gedit_3_0_gir_FILES = $(INST_H_FILES) $(libgedit_private_la_SOURCES) $(libgedit_c_files) $(BUILT_SOURCES)
 Gedit_3_0_gir_INCLUDES = Gtk-3.0 GtkSource-3.0
 
 girdir = $(datadir)/gedit/gir-1.0
diff --git a/gedit/gedit-configurable.c b/gedit/gedit-configurable.c
new file mode 100644
index 0000000..2a0f00d
--- /dev/null
+++ b/gedit/gedit-configurable.c
@@ -0,0 +1,98 @@
+/*
+ * gedit-configurable.c
+ * This file is part of gedit
+ *
+ * Copyright (C) 2009 - 2010 Steve Frécinaux
+ * Copyright (C) 2013 - Ignacio Casal Quinteiro
+ *
+ * gedit 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 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "gedit-configurable.h"
+
+/**
+ * SECTION:gedit-configurable
+ * @short_description: Interface for providing a plugin configuration UI.
+ *
+ * The #GeditConfigurable interface will allow a plugin to provide a
+ * graphical interface for the user to configure the plugin through the
+ * gedit preferences dialog.
+ **/
+
+G_DEFINE_INTERFACE (GeditConfigurable, gedit_configurable, G_TYPE_OBJECT)
+
+static void
+gedit_configurable_default_init (GeditConfigurableInterface *iface)
+{
+}
+
+/**
+ * gedit_configurable_get_page_name:
+ * @configurable: A #GeditConfigurable.
+ *
+ * Returns: (transfer none):
+ */
+const gchar *
+gedit_configurable_get_page_name (GeditConfigurable *configurable)
+{
+       GeditConfigurableInterface *iface;
+
+       g_return_val_if_fail (GEDIT_IS_CONFIGURABLE (configurable), NULL);
+
+       iface = GEDIT_CONFIGURABLE_GET_IFACE (configurable);
+
+       if (G_LIKELY (iface->get_page_name != NULL))
+       {
+               return iface->get_page_name (configurable);
+       }
+
+       /* Default implementation */
+       return NULL;
+}
+
+/**
+ * gedit_configurable_create_configure_widget:
+ * @configurable: A #GeditConfigurable.
+ *
+ * Creates the configure widget for the plugin. The returned widget
+ * should allow configuring all the relevant aspects of the plugin, and should
+ * allow instant-apply, as promoted by the Gnome Human Interface Guidelines.
+ *
+ * The returned widget will be embedded into gedit's preferences dialog.
+ *
+ * This method should always return a valid #GtkWidget instance, never %NULL.
+ *
+ * Returns: (transfer full): A #GtkWidget used for configuration.
+ */
+GtkWidget *
+gedit_configurable_create_configure_widget (GeditConfigurable *configurable)
+{
+       GeditConfigurableInterface *iface;
+
+       g_return_val_if_fail (GEDIT_IS_CONFIGURABLE (configurable), NULL);
+
+       iface = GEDIT_CONFIGURABLE_GET_IFACE (configurable);
+
+       if (G_LIKELY (iface->create_configure_widget != NULL))
+       {
+               return iface->create_configure_widget (configurable);
+       }
+
+       /* Default implementation */
+       return NULL;
+}
diff --git a/gedit/gedit-configurable.h b/gedit/gedit-configurable.h
new file mode 100644
index 0000000..f93bd53
--- /dev/null
+++ b/gedit/gedit-configurable.h
@@ -0,0 +1,65 @@
+/*
+ * gedit-configurable.h
+ * This file is part of gedit
+ *
+ * Copyright (C) 2009 Steve Frécinaux
+ * Copyright (C) 2013 - Ignacio Casal Quinteiro
+ *
+ * gedit 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 of the License, or
+ * (at your option) any later version.
+ *
+ * gedit 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 gedit. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GEDIT_CONFIGURABLE_H__
+#define __GEDIT_CONFIGURABLE_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GEDIT_TYPE_CONFIGURABLE            (gedit_configurable_get_type ())
+#define GEDIT_CONFIGURABLE(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEDIT_TYPE_CONFIGURABLE, 
GeditConfigurable))
+#define GEDIT_CONFIGURABLE_IFACE(obj)      (G_TYPE_CHECK_CLASS_CAST ((obj), GEDIT_TYPE_CONFIGURABLE, 
GeditConfigurableInterface))
+#define GEDIT_IS_CONFIGURABLE(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEDIT_TYPE_CONFIGURABLE))
+#define GEDIT_CONFIGURABLE_GET_IFACE(obj)  (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEDIT_TYPE_CONFIGURABLE, 
GeditConfigurableInterface))
+
+/**
+ * GeditConfigurable:
+ *
+ * Interface for configurable plugins.
+ */
+typedef struct _GeditConfigurable           GeditConfigurable; /* dummy typedef */
+typedef struct _GeditConfigurableInterface  GeditConfigurableInterface;
+
+/**
+ * GeditConfigurableInterface:
+ * @g_iface: The parent interface.
+ * @create_configure_widget: Creates the configure widget for the plugin.
+ *
+ * Provides an interface for configurable plugins.
+ */
+struct _GeditConfigurableInterface
+{
+       GTypeInterface g_iface;
+
+       const gchar *(*get_page_name)            (GeditConfigurable  *configurable);
+       GtkWidget   *(*create_configure_widget)  (GeditConfigurable  *configurable);
+};
+
+GType       gedit_configurable_get_type                 (void)  G_GNUC_CONST;
+
+const gchar *gedit_configurable_get_page_name           (GeditConfigurable  *configurable);
+GtkWidget   *gedit_configurable_create_configure_widget (GeditConfigurable  *configurable);
+
+G_END_DECLS
+
+#endif /* __GEDIT_PLUGIN_MANAGER_H__  */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]