[totem] Port publish plugin to libpeas



commit 854c51a5190d94357b5a25b90cc0607f31cc6906
Author: Philip Withnall <philip tecnocode co uk>
Date:   Sun Jul 11 00:22:46 2010 +0100

    Port publish plugin to libpeas

 configure.in                          |    2 +-
 src/plugins/publish/Makefile.am       |   12 +-
 src/plugins/publish/publish-plugin.ui |  171 +++++++++++---------------------
 src/plugins/publish/totem-publish.c   |   64 +++++-------
 4 files changed, 92 insertions(+), 157 deletions(-)
---
diff --git a/configure.in b/configure.in
index 4929479..c2d774a 100644
--- a/configure.in
+++ b/configure.in
@@ -471,7 +471,7 @@ for plugin in ${used_plugins}; do
 		;;
 		publish)
 			# FIXME
-			PKG_CHECK_MODULES(LIBEPC, libepc-ui-1.0 >= 0.3.0, [HAVE_LIBEPC=no], [HAVE_LIBEPC=no])
+			PKG_CHECK_MODULES(LIBEPC, libepc-ui-1.0 >= 0.3.0, [HAVE_LIBEPC=yes], [HAVE_LIBEPC=no])
 			if test "${HAVE_LIBEPC}" != "yes" ; then
 				plugin_error_or_ignore "you need the easy-publish-and-consume library installed for the publish plugin"
 				add_plugin="0"
diff --git a/src/plugins/publish/Makefile.am b/src/plugins/publish/Makefile.am
index 6e3bf2d..5044aed 100644
--- a/src/plugins/publish/Makefile.am
+++ b/src/plugins/publish/Makefile.am
@@ -3,15 +3,15 @@ modules_flags = -export_dynamic -avoid-version -module
 plugindir = $(PLUGINDIR)/publish
 plugin_LTLIBRARIES = libpublish.la
 
+uidir = $(PLUGINDIR)/publish
+ui_DATA = publish-plugin.ui
+
 plugin_in_files = publish.totem-plugin.in
 
 %.totem-plugin: %.totem-plugin.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:.totem-plugin.in=.totem-plugin)
 
-uidir = $(PLUGINDIR)/publish
-ui_DATA = publish-plugin.ui
-
 common_defines = \
 	-D_REENTRANT					\
 	-DDBUS_API_SUBJECT_TO_CHANGE			\
@@ -31,14 +31,14 @@ libpublish_la_CPPFLAGS = $(common_defines)
 
 libpublish_la_CFLAGS = \
 	$(DEPENDENCY_CFLAGS)	\
+	$(PEAS_CFLAGS)		\
+	$(LIBEPC_CFLAGS)	\
 	$(WARN_CFLAGS)		\
 	$(DBUS_CFLAGS)		\
-	$(LIBEPC_CFLAGS)	\
 	$(AM_CFLAGS)		\
 	-I$(top_srcdir)/	\
-	-I$(top_srcdir)/lib	\
 	-I$(top_srcdir)/src	\
-	-I$(top_srcdir)/src/backend \
+	-I$(top_srcdir)/src/backend	\
 	-I$(top_srcdir)/src/plugins
 
 EXTRA_DIST = $(plugin_in_files) $(ui_DATA)
diff --git a/src/plugins/publish/publish-plugin.ui b/src/plugins/publish/publish-plugin.ui
index 70ec0cf..111fb0a 100644
--- a/src/plugins/publish/publish-plugin.ui
+++ b/src/plugins/publish/publish-plugin.ui
@@ -1,124 +1,72 @@
 <?xml version="1.0"?>
 <!--Generated with glade3 3.4.0 on Sat Nov 24 11:44:42 2007 -->
 <interface>
-  <object class="GtkDialog" id="publish-settings-dialog">
+  <object class="GtkVBox" id="publish-settings-vbox">
+    <property name="visible">True</property>
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-    <property name="border_width">5</property>
-    <property name="modal">True</property>
-    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
-    <property name="destroy_with_parent">True</property>
-    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
-    <property name="skip_taskbar_hint">True</property>
-    <property name="skip_pager_hint">True</property>
-    <property name="has_separator">False</property>
-    <signal handler="totem_publish_plugin_dialog_response_cb" name="response"/>
-    <child internal-child="vbox">
-      <object class="GtkVBox" id="dialog-vbox1">
+    <property name="border_width">6</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkLabel" id="service-name-label">
         <property name="visible">True</property>
         <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-        <property name="spacing">2</property>
-        <child>
-          <object class="GtkVBox" id="publish-settings-vbox">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="border_width">6</property>
-            <property name="spacing">6</property>
-            <child>
-              <object class="GtkLabel" id="service-name-label">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">Service _Name:</property>
-                <property name="use_underline">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkEntry" id="service-name-entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="max_length">64</property>
-                <signal handler="totem_publish_plugin_service_name_entry_changed_cb" name="changed"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="service-name-description">
-                <property name="visible">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="xalign">0</property>
-                <property name="yalign">0</property>
-                <property name="xpad">12</property>
-                <property name="label" translatable="yes">The name used for announcing the playlist service on the network.
+        <property name="xalign">0</property>
+        <property name="label" translatable="yes">Service _Name:</property>
+        <property name="use_underline">True</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkEntry" id="service-name-entry">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="max_length">64</property>
+        <signal handler="totem_publish_plugin_service_name_entry_changed_cb" name="changed"/>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="service-name-description">
+        <property name="visible">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="xalign">0</property>
+        <property name="yalign">0</property>
+        <property name="xpad">12</property>
+        <property name="label" translatable="yes">The name used for announcing the playlist service on the network.
 All occurrences of the string &lt;b&gt;%u&lt;/b&gt; will be replaced by your name,
 and &lt;b&gt;%h&lt;/b&gt; will be replaced by your computer's host name.</property>
-                <property name="use_markup">True</property>
-                <property name="wrap">True</property>
-                <attributes>
-                  <attribute name="scale" value="0.833333333"/><!-- PANGO_SCALE_SMALL -->
-                </attributes>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkCheckButton" id="encryption-button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label" translatable="yes">Use _encrypted transport protocol (HTTPS)</property>
-                <property name="use_underline">True</property>
-                <property name="draw_indicator">True</property>
-                <signal handler="totem_publish_plugin_encryption_button_toggled_cb" name="toggled"/>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="position">3</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">1</property>
-          </packing>
-        </child>
-        <child internal-child="action_area">
-          <object class="GtkHButtonBox" id="dialog-action_area1">
-            <property name="visible">True</property>
-            <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="layout_style">GTK_BUTTONBOX_END</property>
-            <!--Placeholder-->
-            <child>
-              <object class="GtkButton" id="close-button">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">True</property>
-                <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-                <property name="label">gtk-close</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="pack_type">GTK_PACK_END</property>
-          </packing>
-        </child>
+        <property name="use_markup">True</property>
+        <property name="wrap">True</property>
+        <attributes>
+          <attribute name="scale" value="0.833333333"/><!-- PANGO_SCALE_SMALL -->
+        </attributes>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">2</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkCheckButton" id="encryption-button">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+        <property name="label" translatable="yes">Use _encrypted transport protocol (HTTPS)</property>
+        <property name="use_underline">True</property>
+        <property name="draw_indicator">True</property>
+        <signal handler="totem_publish_plugin_encryption_button_toggled_cb" name="toggled"/>
       </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="position">3</property>
+      </packing>
     </child>
-    <action-widgets>
-      <action-widget response="-1">close-button</action-widget>
-    </action-widgets>
   </object>
   <object class="GtkWindow" id="neighbours-window">
     <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -151,7 +99,6 @@ and &lt;b&gt;%h&lt;/b&gt; will be replaced by your computer's host name.</proper
           <object class="GtkProgressBar" id="neighbours-scanning">
             <property name="visible">True</property>
             <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
-            <property name="activity_mode">True</property>
           </object>
           <packing>
             <property name="expand">False</property>
diff --git a/src/plugins/publish/totem-publish.c b/src/plugins/publish/totem-publish.c
index 20ac7f5..6cba26d 100644
--- a/src/plugins/publish/totem-publish.c
+++ b/src/plugins/publish/totem-publish.c
@@ -33,19 +33,23 @@
 #include <glib-object.h>
 #include <glib/gi18n-lib.h>
 #include <gconf/gconf-client.h>
+#include <gio/gio.h>
 
 #include <libepc/consumer.h>
 #include <libepc/enums.h>
 #include <libepc/publisher.h>
 #include <libepc/service-monitor.h>
-
 #include <libepc-ui/progress-window.h>
-#include <gio/gio.h>
+
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
+#include <libpeas/peas-activatable.h>
+#include <libpeasui/peas-ui-configurable.h>
 
 #include "ev-sidebar.h"
 #include "totem-plugin.h"
-#include "totem-interface.h"
 #include "totem-private.h"
+#include "totem-dirs.h"
 #include "totem.h"
 
 #define TOTEM_TYPE_PUBLISH_PLUGIN		(totem_publish_plugin_get_type ())
@@ -68,7 +72,7 @@ enum
 
 typedef struct
 {
-	TotemPlugin parent;
+	PeasExtensionBase parent;
 
 	TotemObject       *totem;
 	GConfClient       *client;
@@ -92,11 +96,10 @@ typedef struct
 
 typedef struct
 {
-	TotemPluginClass parent_class;
+	PeasExtensionBaseClass parent_class;
 } TotemPublishPluginClass;
 
-G_MODULE_EXPORT GType register_totem_plugin		   (GTypeModule     *module);
-static GType totem_publish_plugin_get_type		   (void);
+GType totem_publish_plugin_get_type (void) G_GNUC_CONST;
 
 void totem_publish_plugin_service_name_entry_changed_cb	   (GtkEntry        *entry,
 							    gpointer         data);
@@ -111,7 +114,7 @@ void totem_publish_plugin_neighbours_list_row_activated_cb (GtkTreeView       *v
 							    gpointer           data);
 
 G_LOCK_DEFINE_STATIC(totem_publish_plugin_lock);
-TOTEM_PLUGIN_REGISTER(TotemPublishPlugin, totem_publish_plugin);
+TOTEM_PLUGIN_REGISTER_CONFIGURABLE (TOTEM_TYPE_PUBLISH_PLUGIN, TotemPublishPlugin, totem_publish_plugin);
 
 static void
 totem_publish_plugin_name_changed_cb (GConfClient *client,
@@ -515,12 +518,11 @@ totem_publish_plugin_create_neigbours_page (TotemPublishPlugin *self)
 	return page;
 }
 
-static gboolean
-totem_publish_plugin_activate (TotemPlugin  *plugin,
-			       TotemObject  *totem,
-			       GError      **error)
+static void
+impl_activate (PeasActivatable *plugin, GObject *object)
 {
 	TotemPublishPlugin *self = TOTEM_PUBLISH_PLUGIN (plugin);
+	TotemObject *totem = TOTEM_OBJECT (object);
 	EpcProtocol protocol = EPC_PROTOCOL_HTTPS;
 	GtkWindow *window;
 	GError *internal_error = NULL;
@@ -530,15 +532,15 @@ totem_publish_plugin_activate (TotemPlugin  *plugin,
 	gchar *service_pattern;
 	gchar *service_name;
 
-	g_return_val_if_fail (NULL == self->publisher, FALSE);
-	g_return_val_if_fail (NULL == self->totem, FALSE);
+	g_return_if_fail (NULL == self->publisher);
+	g_return_if_fail (NULL == self->totem);
 
 	G_LOCK (totem_publish_plugin_lock);
 
 	self->totem = g_object_ref (totem);
-	self->ui = totem_plugin_load_interface (plugin, "publish-plugin.ui", TRUE, NULL, self);
 
 	window = totem_get_main_window (self->totem);
+	self->ui = totem_plugin_load_interface ("publish", "publish-plugin.ui", TRUE, window, self);
 	epc_progress_window_install (window);
 	g_object_unref (window);
 
@@ -613,12 +615,13 @@ totem_publish_plugin_activate (TotemPlugin  *plugin,
 
 	totem_publish_plugin_playlist_changed_cb (self->totem->playlist, self);
 
-	return epc_publisher_run_async (self->publisher, error);
+	epc_publisher_run_async (self->publisher, NULL);
+
+	return;
 }
 
 static void
-totem_publish_plugin_deactivate (TotemPlugin *plugin,
-				 TotemObject *totem)
+impl_deactivate (PeasActivatable *plugin, GObject *totem)
 {
 	TotemPublishPlugin *self = TOTEM_PUBLISH_PLUGIN (plugin);
 	TotemPlaylist *playlist = NULL;
@@ -686,26 +689,17 @@ totem_publish_plugin_deactivate (TotemPlugin *plugin,
 	self->scanning = NULL;
 }
 
-void
-totem_publish_plugin_dialog_response_cb (GtkDialog *dialog,
-					 gint       response,
-					 gpointer   data G_GNUC_UNUSED)
-{
-	if (response)
-		gtk_widget_hide (GTK_WIDGET (dialog));
-}
-
-static GtkWidget*
-totem_publish_plugin_create_configure_dialog (TotemPlugin *plugin)
+static GtkWidget *
+impl_create_configure_widget (PeasUIConfigurable *configurable)
 {
-	TotemPublishPlugin *self = TOTEM_PUBLISH_PLUGIN (plugin);
+	TotemPublishPlugin *self = TOTEM_PUBLISH_PLUGIN (configurable);
 
 	if (NULL == self->settings && GTK_IS_BUILDER (self->ui)) {
 		gchar *service_name = gconf_client_get_string (self->client, TOTEM_PUBLISH_CONFIG_NAME, NULL);
 		EpcProtocol protocol = epc_publisher_get_protocol (self->publisher);
 		GtkWidget *widget;
 
-		self->settings = g_object_ref (gtk_builder_get_object (self->ui, "publish-settings-dialog"));
+		self->settings = g_object_ref (gtk_builder_get_object (self->ui, "publish-settings-vbox"));
 
 		widget = GTK_WIDGET (gtk_builder_get_object (self->ui, "service-name-entry"));
 		gtk_entry_set_text (GTK_ENTRY (widget), service_name);
@@ -735,7 +729,7 @@ totem_publish_plugin_dispose (GObject *object)
 		g_object_unref (self->client);
 		self->client = NULL;
 	}
-	totem_publish_plugin_deactivate (TOTEM_PLUGIN (object), NULL);
+
 	G_OBJECT_CLASS (totem_publish_plugin_parent_class)->dispose (object);
 }
 
@@ -743,12 +737,6 @@ static void
 totem_publish_plugin_class_init (TotemPublishPluginClass *klass)
 {
 	GObjectClass *object_class = G_OBJECT_CLASS (klass);
-	TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
-
 	object_class->dispose = totem_publish_plugin_dispose;
-
-	plugin_class->activate = totem_publish_plugin_activate;
-	plugin_class->deactivate = totem_publish_plugin_deactivate;
-	plugin_class->create_configure_dialog = totem_publish_plugin_create_configure_dialog;
 }
 



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