[vinagre/plugin] more work on plugin stuff
- From: Jonh Wendell <jwendell src gnome org>
- To: svn-commits-list gnome org
- Subject: [vinagre/plugin] more work on plugin stuff
- Date: Wed, 8 Jul 2009 03:37:15 +0000 (UTC)
commit c7aa00845109fef000f67112aa3c0258d9beb91c
Author: Jonh Wendell <jwendell gnome org>
Date: Wed Jul 8 04:29:49 2009 +0100
more work on plugin stuff
configure.ac | 4 +-
data/Makefile.am | 3 +-
data/{vinagre.schemas.in => vinagre.schemas.in.in} | 14 +
plugins/Makefile.am | 4 +-
plugins/vnc/Makefile.am | 35 ++
plugins/vnc/vinagre-vnc-plugin.c | 85 ++++
plugins/vnc/vinagre-vnc-plugin.h | 74 +++
plugins/vnc/vnc.vinagre-plugin.desktop.in | 10 +
vinagre/vinagre-plugin-info-priv.h | 50 +-
vinagre/vinagre-plugin-info.c | 474 ++++++++++----------
vinagre/vinagre-plugin-info.h | 11 +-
vinagre/vinagre-plugin-prefs.c | 474 --------------------
vinagre/vinagre-plugin-prefs.h | 59 ---
vinagre/vinagre-plugin.h | 1 +
vinagre/vinagre-plugins-engine.c | 149 ++++---
vinagre/vinagre-prefs.c | 43 ++-
16 files changed, 627 insertions(+), 863 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 9fe349a..f726690 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,7 @@ AC_SUBST(REBUILD)
#*******************************************************************************
#
dnl active plugins for vinagre.schemas
-ACTIVE_PLUGINS="dummy"
+ACTIVE_PLUGINS="vnc"
AC_SUBST(ACTIVE_PLUGINS)
VINAGRE_IMPLIB="-lvinagre-${VINAGRE_API_VERSION}"
@@ -158,6 +158,7 @@ data/Makefile
data/vinagre.desktop.in
data/vinagre-file.desktop.in
data/vinagre.pc
+data/vinagre.schemas.in
data/icons/Makefile
data/pixmaps/Makefile
help/Makefile
@@ -166,6 +167,7 @@ plugin-loaders/Makefile
plugin-loaders/c/Makefile
plugins/Makefile
plugins/dummy/Makefile
+plugins/vnc/Makefile
vinagre/Makefile
vinagre/view/Makefile
])
diff --git a/data/Makefile.am b/data/Makefile.am
index 619f997..fca6183 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -53,7 +53,8 @@ EXTRA_DIST = \
$(desktop_in_files) \
$(MIMEFILES) \
$(schemas_in_files) \
- vinagre.pc.in
+ vinagre.pc.in \
+ vinagre.schemas.in.in
if TELEPATHY
diff --git a/data/vinagre.schemas.in b/data/vinagre.schemas.in.in
similarity index 86%
rename from data/vinagre.schemas.in
rename to data/vinagre.schemas.in.in
index 7916265..bab0eac 100644
--- a/data/vinagre.schemas.in
+++ b/data/vinagre.schemas.in.in
@@ -98,5 +98,19 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/vinagre/plugins/active-plugins</key>
+ <applyto>/apps/vinagre/plugins/active-plugins</applyto>
+ <owner>vinagre</owner>
+ <type>list</type>
+ <list_type>string</list_type>
+ <default>[ ACTIVE_PLUGINS@]</default>
+ <locale name="C">
+ <short>Active plugins</short>
+ <long>List of active plugins. It contains the "Location" of the active plugins. See the .vinagre-plugin file for obtaining
+ the "Location" of a given plugin.</long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index ac7866e..fd4b06a 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -1,7 +1,7 @@
DIST_SUBDIRS = \
- dummy
+ dummy vnc
SUBDIRS = \
- dummy
+ dummy vnc
-include $(top_srcdir)/git.mk
diff --git a/plugins/vnc/Makefile.am b/plugins/vnc/Makefile.am
new file mode 100644
index 0000000..9f4206b
--- /dev/null
+++ b/plugins/vnc/Makefile.am
@@ -0,0 +1,35 @@
+# vnc plugin
+plugindir = $(VINAGRE_PLUGINS_LIBS_DIR)
+
+INCLUDES = \
+ -I$(top_srcdir) \
+ $(VINAGRE_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(DISABLE_DEPRECATED_CFLAGS)
+
+plugin_LTLIBRARIES = libvnc.la
+
+libvnc_la_SOURCES = \
+ vinagre-vnc-plugin.h \
+ vinagre-vnc-plugin.c
+
+libvnc_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
+libvnc_la_LIBADD = $(VINAGRE_LIBS)
+
+#uidir = $(VINAGRE_PLUGINS_DATA_DIR)/vnc
+#ui_DATA = vnc.ui
+
+plugin_in_files = vnc.vinagre-plugin.desktop.in
+
+vnc.vinagre-plugin: vnc.vinagre-plugin.desktop.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+plugin_DATA = $(plugin_in_files:.vinagre-plugin.desktop.in=.vinagre-plugin)
+
+#EXTRA_DIST = $(ui_DATA) $(plugin_in_files)
+EXTRA_DIST = $(plugin_in_files)
+
+CLEANFILES = $(plugin_DATA)
+DISTCLEANFILES = $(plugin_DATA)
+
+
+-include $(top_srcdir)/git.mk
diff --git a/plugins/vnc/vinagre-vnc-plugin.c b/plugins/vnc/vinagre-vnc-plugin.c
new file mode 100644
index 0000000..910e5f4
--- /dev/null
+++ b/plugins/vnc/vinagre-vnc-plugin.c
@@ -0,0 +1,85 @@
+/*
+ * vinagre-vnc-plugin.c
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2009 Jonh Wendell <wendell bani com br>
+ *
+ * vinagre-vnc-plugin.c 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.
+ *
+ * vinagre-vnc-plugin.c 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "vinagre-vnc-plugin.h"
+
+#include <string.h>
+#include <glib/gi18n-lib.h>
+#include <gmodule.h>
+
+#include <vinagre/vinagre-debug.h>
+#include <vinagre/vinagre-utils.h>
+
+#define VINAGRE_SORT_PLUGIN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), VINAGRE_TYPE_SORT_PLUGIN, VinagreVncPluginPrivate))
+
+VINAGRE_PLUGIN_REGISTER_TYPE(VinagreVncPlugin, vinagre_vnc_plugin)
+
+static void
+impl_activate (VinagrePlugin *plugin,
+ VinagreWindow *window)
+{
+ vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Activate");
+}
+
+static void
+impl_deactivate (VinagrePlugin *plugin,
+ VinagreWindow *window)
+{
+ vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Deactivate");
+}
+
+static void
+impl_update_ui (VinagrePlugin *plugin,
+ VinagreWindow *window)
+{
+ vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin Update UI");
+}
+
+static void
+vinagre_vnc_plugin_init (VinagreVncPlugin *plugin)
+{
+ vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin initializing");
+}
+
+static void
+vinagre_vnc_plugin_finalize (GObject *object)
+{
+ vinagre_debug_message (DEBUG_PLUGINS, "VinagreVncPlugin finalizing");
+
+ G_OBJECT_CLASS (vinagre_vnc_plugin_parent_class)->finalize (object);
+}
+
+static void
+vinagre_vnc_plugin_class_init (VinagreVncPluginClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ VinagrePluginClass *plugin_class = VINAGRE_PLUGIN_CLASS (klass);
+
+ object_class->finalize = vinagre_vnc_plugin_finalize;
+
+ plugin_class->activate = impl_activate;
+ plugin_class->deactivate = impl_deactivate;
+ plugin_class->update_ui = impl_update_ui;
+}
+/* vim: set ts=8: */
diff --git a/plugins/vnc/vinagre-vnc-plugin.h b/plugins/vnc/vinagre-vnc-plugin.h
new file mode 100644
index 0000000..7235884
--- /dev/null
+++ b/plugins/vnc/vinagre-vnc-plugin.h
@@ -0,0 +1,74 @@
+/*
+ * vinagre-vnc-plugin.h
+ * This file is part of vinagre
+ *
+ * Copyright (C) 2009 Jorge Pereira <jorge jorgepereira com br>
+ *
+ * vinagre-vnc-plugin.h 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.
+ *
+ * vinagre-vnc-plugin.h 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __VINAGRE_VNC_PLUGIN_H__
+#define __VINAGRE_VNC_PLUGIN_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <vinagre/vinagre-plugin.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define VINAGRE_TYPE_SORT_PLUGIN (vinagre_vnc_plugin_get_type ())
+#define VINAGRE_SORT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), VINAGRE_TYPE_SORT_PLUGIN, VinagreVncPlugin))
+#define VINAGRE_SORT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), VINAGRE_TYPE_SORT_PLUGIN, VinagreVncPluginClass))
+#define VINAGRE_IS_SORT_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), VINAGRE_TYPE_SORT_PLUGIN))
+#define VINAGRE_IS_SORT_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VINAGRE_TYPE_SORT_PLUGIN))
+#define VINAGRE_SORT_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VINAGRE_TYPE_SORT_PLUGIN, VinagreVncPluginClass))
+
+/* Private structure type */
+typedef struct _VinagreVncPluginPrivate VinagreVncPluginPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _VinagreVncPlugin VinagreVncPlugin;
+
+struct _VinagreVncPlugin
+{
+ VinagrePlugin parent_instance;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _VinagreVncPluginClass VinagreVncPluginClass;
+
+struct _VinagreVncPluginClass
+{
+ VinagrePluginClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType vinagre_vnc_plugin_get_type (void) G_GNUC_CONST;
+
+/* All the plugins must implement this function */
+G_MODULE_EXPORT GType register_vinagre_plugin (GTypeModule *module);
+
+G_END_DECLS
+
+#endif /* __VINAGRE_VNC_PLUGIN_H__ */
+/* vim: set ts=8: */
diff --git a/plugins/vnc/vnc.vinagre-plugin.desktop.in b/plugins/vnc/vnc.vinagre-plugin.desktop.in
new file mode 100644
index 0000000..a1bed4e
--- /dev/null
+++ b/plugins/vnc/vnc.vinagre-plugin.desktop.in
@@ -0,0 +1,10 @@
+[Vinagre Plugin]
+Module=vnc
+IAge=1
+_Name=Vnc
+_Description=Vnc support
+Authors=Jonh Wendell
+Copyright=Copyright © 2009 Jonh Wendell
+Website=http://www.bani.com.br
+Version=1.0
+Engine=1
diff --git a/vinagre/vinagre-plugin-info-priv.h b/vinagre/vinagre-plugin-info-priv.h
index b3ed18e..5acc583 100644
--- a/vinagre/vinagre-plugin-info-priv.h
+++ b/vinagre/vinagre-plugin-info-priv.h
@@ -26,33 +26,33 @@
struct _VinagrePluginInfo
{
- gint refcount;
-
- VinagrePlugin *plugin;
- gchar *file;
-
- gchar *module_name;
- gchar *loader;
- gchar **dependencies;
-
- gchar *name;
- gchar *desc;
- gchar *icon_name;
- gchar **authors;
- gchar *copyright;
- gchar *website;
- gchar *version;
-
- /* A plugin is unavailable if it is not possible to activate it
- due to an error loading the plugin module (e.g. for Python plugins
- when the interpreter has not been correctly initializated) */
- gint available : 1;
+ gint refcount;
+
+ VinagrePlugin *plugin;
+ gchar *file;
+
+ gchar *module_name;
+ gchar *loader;
+ gchar **dependencies;
+
+ gchar *name;
+ gchar *desc;
+ gchar *icon_name;
+ gchar **authors;
+ gchar *copyright;
+ gchar *website;
+ gchar *version;
+
+ /* A plugin is unavailable if it is not possible to activate it
+ due to an error loading the plugin module (e.g. for Python plugins
+ when the interpreter has not been correctly initializated) */
+ gint available : 1;
+ gint engine : 1;
};
-VinagrePluginInfo *_vinagre_plugin_info_new (const gchar *file);
-void _vinagre_plugin_info_ref (VinagrePluginInfo *info);
+VinagrePluginInfo *_vinagre_plugin_info_new (const gchar *file);
+void _vinagre_plugin_info_ref (VinagrePluginInfo *info);
void _vinagre_plugin_info_unref (VinagrePluginInfo *info);
-
#endif /* __VINAGRE_PLUGIN_INFO_PRIV_H__ */
-
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-plugin-info.c b/vinagre/vinagre-plugin-info.c
index 0c4a3bf..2aa8f68 100644
--- a/vinagre/vinagre-plugin-info.c
+++ b/vinagre/vinagre-plugin-info.c
@@ -34,42 +34,41 @@
void
_vinagre_plugin_info_ref (VinagrePluginInfo *info)
{
- g_atomic_int_inc (&info->refcount);
+ g_atomic_int_inc (&info->refcount);
}
static VinagrePluginInfo *
vinagre_plugin_info_copy (VinagrePluginInfo *info)
{
- _vinagre_plugin_info_ref (info);
- return info;
+ _vinagre_plugin_info_ref (info);
+ return info;
}
void
_vinagre_plugin_info_unref (VinagrePluginInfo *info)
{
- if (!g_atomic_int_dec_and_test (&info->refcount))
- return;
-
- if (info->plugin != NULL)
- {
- vinagre_debug_message (DEBUG_PLUGINS, "Unref plugin %s", info->name);
-
- g_object_unref (info->plugin);
- }
-
- g_free (info->file);
- g_free (info->module_name);
- g_strfreev (info->dependencies);
- g_free (info->name);
- g_free (info->desc);
- g_free (info->icon_name);
- g_free (info->website);
- g_free (info->copyright);
- g_free (info->loader);
- g_free (info->version);
- g_strfreev (info->authors);
-
- g_free (info);
+ if (!g_atomic_int_dec_and_test (&info->refcount))
+ return;
+
+ if (info->plugin != NULL)
+ {
+ vinagre_debug_message (DEBUG_PLUGINS, "Unref plugin %s", info->name);
+ g_object_unref (info->plugin);
+ }
+
+ g_free (info->file);
+ g_free (info->module_name);
+ g_strfreev (info->dependencies);
+ g_free (info->name);
+ g_free (info->desc);
+ g_free (info->icon_name);
+ g_free (info->website);
+ g_free (info->copyright);
+ g_free (info->loader);
+ g_free (info->version);
+ g_strfreev (info->authors);
+
+ g_free (info);
}
/**
@@ -83,15 +82,14 @@ _vinagre_plugin_info_unref (VinagrePluginInfo *info)
GType
vinagre_plugin_info_get_type (void)
{
- static GType the_type = 0;
+ static GType the_type = 0;
- if (G_UNLIKELY (!the_type))
- the_type = g_boxed_type_register_static (
- "VinagrePluginInfo",
- (GBoxedCopyFunc) vinagre_plugin_info_copy,
- (GBoxedFreeFunc) _vinagre_plugin_info_unref);
+ if (G_UNLIKELY (!the_type))
+ the_type = g_boxed_type_register_static ("VinagrePluginInfo",
+ (GBoxedCopyFunc) vinagre_plugin_info_copy,
+ (GBoxedFreeFunc) _vinagre_plugin_info_unref);
- return the_type;
+ return the_type;
}
/**
@@ -105,279 +103,293 @@ vinagre_plugin_info_get_type (void)
VinagrePluginInfo *
_vinagre_plugin_info_new (const gchar *file)
{
- VinagrePluginInfo *info;
- GKeyFile *plugin_file = NULL;
- gchar *str;
-
- g_return_val_if_fail (file != NULL, NULL);
-
- vinagre_debug_message (DEBUG_PLUGINS, "Loading plugin: %s", file);
-
- info = g_new0 (VinagrePluginInfo, 1);
- info->refcount = 1;
- info->file = g_strdup (file);
-
- plugin_file = g_key_file_new ();
- if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL))
- {
- g_warning ("Bad plugin file: %s", file);
- goto error;
- }
-
- if (!g_key_file_has_key (plugin_file,
- "Vinagre Plugin",
- "IAge",
- NULL))
- {
- vinagre_debug_message (DEBUG_PLUGINS,
- "IAge key does not exist in file: %s", file);
- goto error;
- }
+ VinagrePluginInfo *info;
+ GKeyFile *plugin_file = NULL;
+ gchar *str;
+
+ g_return_val_if_fail (file != NULL, NULL);
+
+ vinagre_debug_message (DEBUG_PLUGINS, "Loading plugin: %s", file);
+
+ info = g_new0 (VinagrePluginInfo, 1);
+ info->refcount = 1;
+ info->file = g_strdup (file);
+
+ plugin_file = g_key_file_new ();
+ if (!g_key_file_load_from_file (plugin_file, file, G_KEY_FILE_NONE, NULL))
+ {
+ g_warning ("Bad plugin file: %s", file);
+ goto error;
+ }
+
+ if (!g_key_file_has_key (plugin_file,
+ "Vinagre Plugin",
+ "IAge",
+ NULL))
+ {
+ vinagre_debug_message (DEBUG_PLUGINS,
+ "IAge key does not exist in file: %s", file);
+ goto error;
+ }
- /* Check IAge=2 */
- if (g_key_file_get_integer (plugin_file,
- "Vinagre Plugin",
- "IAge",
- NULL) != 2)
- {
- vinagre_debug_message (DEBUG_PLUGINS,
- "Wrong IAge in file: %s", file);
- goto error;
- }
+ /* Check IAge=1 */
+ if (g_key_file_get_integer (plugin_file,
+ "Vinagre Plugin",
+ "IAge",
+ NULL) != 1)
+ {
+ vinagre_debug_message (DEBUG_PLUGINS,
+ "Wrong IAge in file: %s", file);
+ goto error;
+ }
- /* Get module name */
- str = g_key_file_get_string (plugin_file,
- "Vinagre Plugin",
- "Module",
- NULL);
-
- if ((str != NULL) && (*str != '\0'))
- {
- info->module_name = str;
- }
- else
- {
- g_warning ("Could not find 'Module' in %s", file);
- goto error;
- }
-
- /* Get the dependency list */
- info->dependencies = g_key_file_get_string_list (plugin_file,
- "Vinagre Plugin",
- "Depends",
- NULL,
- NULL);
- if (info->dependencies == NULL)
- {
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Depends' in %s", file);
- info->dependencies = g_new0 (gchar *, 1);
- }
-
- /* Get the loader for this plugin */
- str = g_key_file_get_string (plugin_file,
- "Vinagre Plugin",
- "Loader",
- NULL);
-
- if ((str != NULL) && (*str != '\0'))
- {
- info->loader = str;
- }
- else
- {
- /* default to the C loader */
- info->loader = g_strdup("c");
- }
-
- /* Get Name */
- str = g_key_file_get_locale_string (plugin_file,
- "Vinagre Plugin",
- "Name",
- NULL, NULL);
- if (str)
- info->name = str;
- else
- {
- g_warning ("Could not find 'Name' in %s", file);
- goto error;
- }
-
- /* Get Description */
- str = g_key_file_get_locale_string (plugin_file,
- "Vinagre Plugin",
- "Description",
- NULL, NULL);
- if (str)
- info->desc = str;
- else
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Description' in %s", file);
-
- /* Get Icon */
- str = g_key_file_get_locale_string (plugin_file,
- "Vinagre Plugin",
- "Icon",
- NULL, NULL);
- if (str)
- info->icon_name = str;
- else
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Icon' in %s, using 'vinagre-plugin'", file);
-
-
- /* Get Authors */
- info->authors = g_key_file_get_string_list (plugin_file,
- "Vinagre Plugin",
- "Authors",
+ /* Get module name */
+ str = g_key_file_get_string (plugin_file,
+ "Vinagre Plugin",
+ "Module",
+ NULL);
+
+ if ((str != NULL) && (*str != '\0'))
+ info->module_name = str;
+ else
+ {
+ g_warning ("Could not find 'Module' in %s", file);
+ goto error;
+ }
+
+ /* Get the dependency list */
+ info->dependencies = g_key_file_get_string_list (plugin_file,
+ "Vinagre Plugin",
+ "Depends",
NULL,
NULL);
- if (info->authors == NULL)
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Authors' in %s", file);
-
-
- /* Get Copyright */
- str = g_key_file_get_string (plugin_file,
- "Vinagre Plugin",
- "Copyright",
- NULL);
- if (str)
- info->copyright = str;
- else
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Copyright' in %s", file);
-
- /* Get Website */
- str = g_key_file_get_string (plugin_file,
- "Vinagre Plugin",
- "Website",
- NULL);
- if (str)
- info->website = str;
- else
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Website' in %s", file);
+ if (info->dependencies == NULL)
+ {
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Depends' in %s", file);
+ info->dependencies = g_new0 (gchar *, 1);
+ }
+
+ /* Get the loader for this plugin */
+ str = g_key_file_get_string (plugin_file,
+ "Vinagre Plugin",
+ "Loader",
+ NULL);
+ if ((str != NULL) && (*str != '\0'))
+ info->loader = str;
+ else
+ /* default to the C loader */
+ info->loader = g_strdup("c");
+
+ /* Get Name */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Vinagre Plugin",
+ "Name",
+ NULL,
+ NULL);
+ if (str)
+ info->name = str;
+ else
+ {
+ g_warning ("Could not find 'Name' in %s", file);
+ goto error;
+ }
+
+ /* Get Description */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Vinagre Plugin",
+ "Description",
+ NULL,
+ NULL);
+ if (str)
+ info->desc = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Description' in %s", file);
+
+ /* Get Icon */
+ str = g_key_file_get_locale_string (plugin_file,
+ "Vinagre Plugin",
+ "Icon",
+ NULL,
+ NULL);
+ if (str)
+ info->icon_name = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Icon' in %s, using 'vinagre-plugin'", file);
- /* Get Version */
- str = g_key_file_get_string (plugin_file,
- "Vinagre Plugin",
- "Version",
- NULL);
- if (str)
- info->version = str;
- else
- vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Version' in %s", file);
+ /* Get Authors */
+ info->authors = g_key_file_get_string_list (plugin_file,
+ "Vinagre Plugin",
+ "Authors",
+ NULL,
+ NULL);
+ if (info->authors == NULL)
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Authors' in %s", file);
+
+ /* Get Copyright */
+ str = g_key_file_get_string (plugin_file,
+ "Vinagre Plugin",
+ "Copyright",
+ NULL);
+ if (str)
+ info->copyright = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Copyright' in %s", file);
+
+ /* Get Website */
+ str = g_key_file_get_string (plugin_file,
+ "Vinagre Plugin",
+ "Website",
+ NULL);
+ if (str)
+ info->website = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Website' in %s", file);
- g_key_file_free (plugin_file);
+ /* Get Version */
+ str = g_key_file_get_string (plugin_file,
+ "Vinagre Plugin",
+ "Version",
+ NULL);
+ if (str)
+ info->version = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Version' in %s", file);
+
+ /* Check if is engine or normal plugin */
+ info->engine = g_key_file_get_boolean (plugin_file,
+ "Vinagre Plugin",
+ "Engine",
+ NULL);
+ if (str)
+ info->version = str;
+ else
+ vinagre_debug_message (DEBUG_PLUGINS, "Could not find 'Version' in %s", file);
- /* If we know nothing about the availability of the plugin,
- set it as available */
- info->available = TRUE;
+ g_key_file_free (plugin_file);
- return info;
+ /* If we know nothing about the availability of the plugin,
+ set it as available */
+ info->available = TRUE;
+
+ return info;
error:
- g_free (info->file);
- g_free (info->module_name);
- g_free (info->name);
- g_free (info->loader);
- g_free (info);
- g_key_file_free (plugin_file);
-
- return NULL;
+ g_free (info->file);
+ g_free (info->module_name);
+ g_free (info->name);
+ g_free (info->loader);
+ g_free (info);
+ g_key_file_free (plugin_file);
+
+ return NULL;
}
gboolean
vinagre_plugin_info_is_active (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- return info->available && info->plugin != NULL;
+ return info->available && info->plugin != NULL;
}
gboolean
vinagre_plugin_info_is_available (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- return info->available != FALSE;
+ return info->available != FALSE;
}
gboolean
vinagre_plugin_info_is_configurable (VinagrePluginInfo *info)
{
- vinagre_debug_message (DEBUG_PLUGINS, "Is '%s' configurable?", info->name);
+ vinagre_debug_message (DEBUG_PLUGINS, "Is '%s' configurable?", info->name);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (info->plugin == NULL || !info->available)
- return FALSE;
+ if (info->plugin == NULL || !info->available)
+ return FALSE;
- return vinagre_plugin_is_configurable (info->plugin);
+ return vinagre_plugin_is_configurable (info->plugin);
}
const gchar *
vinagre_plugin_info_get_module_name (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->module_name;
+ return info->module_name;
}
const gchar *
vinagre_plugin_info_get_name (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->name;
+ return info->name;
}
const gchar *
vinagre_plugin_info_get_description (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->desc;
+ return info->desc;
}
const gchar *
vinagre_plugin_info_get_icon_name (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
-
- /* use the vinagre-plugin icon as a default if the plugin does not
- have its own */
- if (info->icon_name != NULL &&
- gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
- info->icon_name))
- return info->icon_name;
- else
- return "vinagre-plugin";
+ g_return_val_if_fail (info != NULL, NULL);
+
+ /* use the vinagre-plugin icon as a default if the plugin does not
+ have its own */
+ if (info->icon_name != NULL &&
+ gtk_icon_theme_has_icon (gtk_icon_theme_get_default (),
+ info->icon_name))
+ return info->icon_name;
+ else
+ return "vinagre-plugin";
}
const gchar **
vinagre_plugin_info_get_authors (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, (const gchar **)NULL);
+ g_return_val_if_fail (info != NULL, (const gchar **)NULL);
- return (const gchar **) info->authors;
+ return (const gchar **) info->authors;
}
const gchar *
vinagre_plugin_info_get_website (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->website;
+ return info->website;
}
const gchar *
vinagre_plugin_info_get_copyright (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
- return info->copyright;
+ return info->copyright;
}
const gchar *
vinagre_plugin_info_get_version (VinagrePluginInfo *info)
{
- g_return_val_if_fail (info != NULL, NULL);
+ g_return_val_if_fail (info != NULL, NULL);
+
+ return info->version;
+}
+
+gboolean
+vinagre_plugin_info_is_engine (VinagrePluginInfo *info)
+{
+ g_return_val_if_fail (info != NULL, FALSE);
- return info->version;
+ return info->engine;
}
+
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-plugin-info.h b/vinagre/vinagre-plugin-info.h
index 43f8c27..ad2443a 100644
--- a/vinagre/vinagre-plugin-info.h
+++ b/vinagre/vinagre-plugin-info.h
@@ -33,7 +33,7 @@ typedef struct _VinagrePluginInfo VinagrePluginInfo;
GType vinagre_plugin_info_get_type (void) G_GNUC_CONST;
gboolean vinagre_plugin_info_is_active (VinagrePluginInfo *info);
-gboolean vinagre_plugin_info_is_available (VinagrePluginInfo *info);
+gboolean vinagre_plugin_info_is_available (VinagrePluginInfo *info);
gboolean vinagre_plugin_info_is_configurable (VinagrePluginInfo *info);
const gchar *vinagre_plugin_info_get_module_name (VinagrePluginInfo *info);
@@ -41,12 +41,13 @@ const gchar *vinagre_plugin_info_get_module_name (VinagrePluginInfo *info);
const gchar *vinagre_plugin_info_get_name (VinagrePluginInfo *info);
const gchar *vinagre_plugin_info_get_description (VinagrePluginInfo *info);
const gchar *vinagre_plugin_info_get_icon_name (VinagrePluginInfo *info);
-const gchar **vinagre_plugin_info_get_authors (VinagrePluginInfo *info);
-const gchar *vinagre_plugin_info_get_website (VinagrePluginInfo *info);
+const gchar **vinagre_plugin_info_get_authors (VinagrePluginInfo *info);
+const gchar *vinagre_plugin_info_get_website (VinagrePluginInfo *info);
const gchar *vinagre_plugin_info_get_copyright (VinagrePluginInfo *info);
-const gchar *vinagre_plugin_info_get_version (VinagrePluginInfo *info);
+const gchar *vinagre_plugin_info_get_version (VinagrePluginInfo *info);
+gboolean vinagre_plugin_info_is_engine (VinagrePluginInfo *info);
G_END_DECLS
#endif /* __VINAGRE_PLUGIN_INFO_H__ */
-
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-plugin.h b/vinagre/vinagre-plugin.h
index 5a1cdf8..96a658e 100644
--- a/vinagre/vinagre-plugin.h
+++ b/vinagre/vinagre-plugin.h
@@ -228,3 +228,4 @@ object_name##_register_type (GTypeModule *type_module) \
G_END_DECLS
#endif /* __VINAGRE_PLUGIN_H__ */
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-plugins-engine.c b/vinagre/vinagre-plugins-engine.c
index 82f1960..ec282a9 100644
--- a/vinagre/vinagre-plugins-engine.c
+++ b/vinagre/vinagre-plugins-engine.c
@@ -30,7 +30,7 @@
#include "vinagre-plugin.h"
#include "vinagre-debug.h"
#include "vinagre-app.h"
-//#include "vinagre-prefs-manager.h"
+#include "vinagre-prefs.h"
#include "vinagre-plugin-loader.h"
#include "vinagre-object-module.h"
#include "vinagre-dirs.h"
@@ -78,10 +78,10 @@ typedef gboolean (*LoadDirCallback)(VinagrePluginsEngine *engine, const gchar *f
static gboolean
load_dir_real (VinagrePluginsEngine *engine,
- const gchar *dir,
- const gchar *suffix,
- LoadDirCallback callback,
- gpointer userdata)
+ const gchar *dir,
+ const gchar *suffix,
+ LoadDirCallback callback,
+ gpointer userdata)
{
GError *error = NULL;
GDir *d;
@@ -257,6 +257,21 @@ add_loader (VinagrePluginsEngine *engine,
}
static void
+activate_engine_plugins (VinagrePluginsEngine *engine)
+{
+ GList *item;
+
+ vinagre_debug_message (DEBUG_PLUGINS, "Activating engine plugins");
+ for (item = engine->priv->plugin_list; item; item = item->next)
+ {
+ VinagrePluginInfo *info = VINAGRE_PLUGIN_INFO (item->data);
+
+ if (vinagre_plugin_info_is_engine (info))
+ vinagre_plugins_engine_activate_plugin (engine, info);
+ }
+}
+
+static void
vinagre_plugins_engine_init (VinagrePluginsEngine *engine)
{
vinagre_debug (DEBUG_PLUGINS);
@@ -282,6 +297,8 @@ vinagre_plugins_engine_init (VinagrePluginsEngine *engine)
equal_lowercase,
(GDestroyNotify)g_free,
(GDestroyNotify)loader_destroy);
+
+ activate_engine_plugins (engine);
}
static void
@@ -507,7 +524,7 @@ compare_plugin_info_and_name (VinagrePluginInfo *info,
VinagrePluginInfo *
vinagre_plugins_engine_get_plugin_info (VinagrePluginsEngine *engine,
- const gchar *name)
+ const gchar *name)
{
GList *l = g_list_find_custom (engine->priv->plugin_list,
name,
@@ -519,23 +536,23 @@ vinagre_plugins_engine_get_plugin_info (VinagrePluginsEngine *engine,
static void
save_active_plugin_list (VinagrePluginsEngine *engine)
{
- GSList *active_plugins = NULL;
- GList *l;
+ GSList *active_plugins = NULL;
+ GList *l;
- for (l = engine->priv->plugin_list; l != NULL; l = l->next)
- {
- VinagrePluginInfo *info = (VinagrePluginInfo *) l->data;
+ for (l = engine->priv->plugin_list; l != NULL; l = l->next)
+ {
+ VinagrePluginInfo *info = (VinagrePluginInfo *) l->data;
- if (vinagre_plugin_info_is_active (info))
- {
- active_plugins = g_slist_prepend (active_plugins,
- (gpointer)vinagre_plugin_info_get_module_name (info));
- }
- }
+ if (vinagre_plugin_info_is_active (info))
+ active_plugins = g_slist_prepend (active_plugins,
+ (gpointer)vinagre_plugin_info_get_module_name (info));
+ }
-// AQUI: vinagre_prefs_manager_set_active_plugins (active_plugins);
+ g_object_set (vinagre_prefs_get_default (),
+ "active-plugins", active_plugins,
+ NULL);
- g_slist_free (active_plugins);
+ g_slist_free (active_plugins);
}
static gboolean
@@ -579,77 +596,79 @@ load_plugin (VinagrePluginsEngine *engine,
static void
vinagre_plugins_engine_activate_plugin_real (VinagrePluginsEngine *engine,
- VinagrePluginInfo *info)
+ VinagrePluginInfo *info)
{
- if (!load_plugin (engine, info))
- return;
+ const GList *wins;
+
+ if (!load_plugin (engine, info))
+ return;
- /* activate plugin for all windows */
- const GList *wins = vinagre_app_get_windows (vinagre_app_get_default ());
- for (; wins != NULL; wins = wins->next)
- vinagre_plugin_activate (info->plugin, VINAGRE_WINDOW (wins->data));
+ /* activate plugin for all windows */
+ wins = vinagre_app_get_windows (vinagre_app_get_default ());
+ for (; wins != NULL; wins = wins->next)
+ vinagre_plugin_activate (info->plugin, VINAGRE_WINDOW (wins->data));
}
gboolean
vinagre_plugins_engine_activate_plugin (VinagrePluginsEngine *engine,
- VinagrePluginInfo *info)
+ VinagrePluginInfo *info)
{
- vinagre_debug (DEBUG_PLUGINS);
+ vinagre_debug (DEBUG_PLUGINS);
- g_return_val_if_fail (info != NULL, FALSE);
+ g_return_val_if_fail (info != NULL, FALSE);
- if (!vinagre_plugin_info_is_available (info))
- return FALSE;
+ if (!vinagre_plugin_info_is_available (info))
+ return FALSE;
- if (vinagre_plugin_info_is_active (info))
- return TRUE;
+ if (vinagre_plugin_info_is_active (info))
+ return TRUE;
- g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
+ g_signal_emit (engine, signals[ACTIVATE_PLUGIN], 0, info);
- if (vinagre_plugin_info_is_active (info))
- save_active_plugin_list (engine);
+ if (vinagre_plugin_info_is_active (info))
+ save_active_plugin_list (engine);
- return vinagre_plugin_info_is_active (info);
+ return vinagre_plugin_info_is_active (info);
}
static void
call_plugin_deactivate (VinagrePlugin *plugin,
- VinagreWindow *window)
+ VinagreWindow *window)
{
- vinagre_plugin_deactivate (plugin, window);
+ vinagre_plugin_deactivate (plugin, window);
- /* ensure update of ui manager, because we suspect it does something
- with expected static strings in the type module (when unloaded the
- strings don't exist anymore, and ui manager updates in an idle
- func) */
- gtk_ui_manager_ensure_update (vinagre_window_get_ui_manager (window));
+ /* ensure update of ui manager, because we suspect it does something
+ with expected static strings in the type module (when unloaded the
+ strings don't exist anymore, and ui manager updates in an idle
+ func) */
+ gtk_ui_manager_ensure_update (vinagre_window_get_ui_manager (window));
}
static void
vinagre_plugins_engine_deactivate_plugin_real (VinagrePluginsEngine *engine,
- VinagrePluginInfo *info)
+ VinagrePluginInfo *info)
{
- const GList *wins;
- VinagrePluginLoader *loader;
+ const GList *wins;
+ VinagrePluginLoader *loader;
- if (!vinagre_plugin_info_is_active (info) ||
- !vinagre_plugin_info_is_available (info))
- return;
+ if (!vinagre_plugin_info_is_active (info) ||
+ !vinagre_plugin_info_is_available (info))
+ return;
- wins = vinagre_app_get_windows (vinagre_app_get_default ());
- for (; wins != NULL; wins = wins->next)
- call_plugin_deactivate (info->plugin, VINAGRE_WINDOW (wins->data));
+ wins = vinagre_app_get_windows (vinagre_app_get_default ());
+ for (; wins != NULL; wins = wins->next)
+ call_plugin_deactivate (info->plugin, VINAGRE_WINDOW (wins->data));
- /* first unref the plugin (the loader still has one) */
- g_object_unref (info->plugin);
+ /* first unref the plugin (the loader still has one) */
+ g_object_unref (info->plugin);
- /* find the loader and tell it to gc and unload the plugin */
- loader = get_plugin_loader (engine, info);
+ /* find the loader and tell it to gc and unload the plugin */
+ loader = get_plugin_loader (engine, info);
- vinagre_plugin_loader_garbage_collect (loader);
- vinagre_plugin_loader_unload (loader, info);
+ vinagre_plugin_loader_garbage_collect (loader);
+ vinagre_plugin_loader_unload (loader, info);
- info->plugin = NULL;
+ info->plugin = NULL;
}
gboolean
@@ -685,7 +704,9 @@ vinagre_plugins_engine_activate_plugins (VinagrePluginsEngine *engine,
/* the first time, we get the 'active' plugins from gconf */
if (engine->priv->activate_from_prefs)
{
- //AQUI: active_plugins = vinagre_prefs_manager_get_active_plugins ();
+ g_object_get (vinagre_prefs_get_default (),
+ "active-plugins", &active_plugins,
+ NULL);
}
for (pl = engine->priv->plugin_list; pl; pl = pl->next)
@@ -811,7 +832,9 @@ vinagre_plugins_engine_active_plugins_changed (VinagrePluginsEngine *engine)
vinagre_debug (DEBUG_PLUGINS);
-//AQUI active_plugins = vinagre_prefs_manager_get_active_plugins ();
+ g_object_get (vinagre_prefs_get_default (),
+ "active-plugins", &active_plugins,
+ NULL);
for (pl = engine->priv->plugin_list; pl; pl = pl->next)
{
@@ -841,4 +864,4 @@ vinagre_plugins_engine_rescan_plugins (VinagrePluginsEngine *engine)
load_all_plugins (engine);
}
-
+/* vim: set ts=8: */
diff --git a/vinagre/vinagre-prefs.c b/vinagre/vinagre-prefs.c
index a5263b2..4b74539 100644
--- a/vinagre/vinagre-prefs.c
+++ b/vinagre/vinagre-prefs.c
@@ -2,7 +2,7 @@
* vinagre-prefs.c
* This file is part of vinagre
*
- * Copyright (C) Jonh Wendell 2008 <wendell bani com br>
+ * Copyright (C) Jonh Wendell 2008,2009 <wendell bani com br>
*
* vinagre-prefs.c is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -38,6 +38,9 @@
#define VM_WINDOW_HEIGHT VINAGRE_BASE_KEY "/window_height"
#define VM_SIDE_PANEL_SIZE VINAGRE_BASE_KEY "/side_panel_size"
+#define VINAGRE_PLUGINS_DIR VINAGRE_BASE_KEY "/plugins"
+#define VM_ACTIVE_PLUGINS VINAGRE_PLUGINS_DIR "/active-plugins"
+
struct _VinagrePrefsPrivate
{
GConfClient *gconf_client;
@@ -57,7 +60,8 @@ enum
PROP_WINDOW_HEIGHT,
PROP_SIDE_PANEL_SIZE,
PROP_SHOW_ACCELS,
- PROP_HISTORY_SIZE
+ PROP_HISTORY_SIZE,
+ PROP_ACTIVE_PLUGINS
};
G_DEFINE_TYPE (VinagrePrefs, vinagre_prefs, G_TYPE_OBJECT);
@@ -123,6 +127,15 @@ vinagre_prefs_get_int (VinagrePrefs *prefs, const gchar* key, gint def)
return def;
}
+static GSList *
+vinagre_prefs_get_list (VinagrePrefs *prefs, const gchar* key)
+{
+ return gconf_client_get_list (prefs->priv->gconf_client,
+ key,
+ GCONF_VALUE_STRING,
+ NULL);
+}
+
static void
vinagre_prefs_set_bool (VinagrePrefs *prefs, const gchar* key, gboolean value)
{
@@ -142,6 +155,19 @@ vinagre_prefs_set_int (VinagrePrefs *prefs, const gchar* key, gint value)
}
static void
+vinagre_prefs_set_list (VinagrePrefs *prefs, const gchar* key, GSList *list)
+{
+ g_return_if_fail (gconf_client_key_is_writable (
+ prefs->priv->gconf_client, key, NULL));
+
+ gconf_client_set_list (prefs->priv->gconf_client,
+ key,
+ GCONF_VALUE_STRING,
+ list,
+ NULL);
+}
+
+static void
vinagre_prefs_always_show_tabs_notify (GConfClient *client,
guint cnx_id,
GConfEntry *entry,
@@ -224,6 +250,9 @@ vinagre_prefs_set_property (GObject *object, guint prop_id, const GValue *value,
case PROP_HISTORY_SIZE:
vinagre_prefs_set_int (prefs, VM_HISTORY_SIZE, g_value_get_int (value));
break;
+ case PROP_ACTIVE_PLUGINS:
+ vinagre_prefs_set_list (prefs, VM_ACTIVE_PLUGINS, g_value_get_pointer (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -270,6 +299,9 @@ vinagre_prefs_get_property (GObject *object, guint prop_id, GValue *value, GPara
case PROP_HISTORY_SIZE:
g_value_set_int (value, vinagre_prefs_get_int (prefs, VM_HISTORY_SIZE, 15));
break;
+ case PROP_ACTIVE_PLUGINS:
+ g_value_set_pointer (value, vinagre_prefs_get_list (prefs, VM_ACTIVE_PLUGINS));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -384,6 +416,13 @@ vinagre_prefs_class_init (VinagrePrefsClass *klass)
0, G_MAXINT, 15,
G_PARAM_READWRITE));
+ g_object_class_install_property (object_class,
+ PROP_ACTIVE_PLUGINS,
+ g_param_spec_pointer ("active-plugins",
+ "Active plugins",
+ "The list of active plugins",
+ G_PARAM_READWRITE));
+
}
/* Preferences dialog */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]