[totem] Port screenshot plugin to libpeas
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [totem] Port screenshot plugin to libpeas
- Date: Wed, 16 Jun 2010 17:27:40 +0000 (UTC)
commit 06f51a153420afa02b078e25cb9311a998007e8a
Author: Bastien Nocera <hadess hadess net>
Date: Tue Jun 15 17:14:55 2010 +0100
Port screenshot plugin to libpeas
https://bugzilla.gnome.org/show_bug.cgi?id=604830
src/plugins/screenshot/Makefile.am | 1 +
src/plugins/screenshot/totem-gallery.c | 5 +-
src/plugins/screenshot/totem-gallery.h | 4 +-
src/plugins/screenshot/totem-screenshot-plugin.c | 69 +++++++++++++++-------
src/plugins/screenshot/totem-screenshot-plugin.h | 9 ++-
src/plugins/screenshot/totem-screenshot.c | 5 +-
src/plugins/screenshot/totem-screenshot.h | 4 +-
7 files changed, 64 insertions(+), 33 deletions(-)
---
diff --git a/src/plugins/screenshot/Makefile.am b/src/plugins/screenshot/Makefile.am
index b2aaa60..c7d6277 100644
--- a/src/plugins/screenshot/Makefile.am
+++ b/src/plugins/screenshot/Makefile.am
@@ -41,6 +41,7 @@ libscreenshot_la_CPPFLAGS = \
libscreenshot_la_CFLAGS = \
$(DEPENDENCY_CFLAGS) \
+ $(PEAS_CFLAGS) \
$(WARN_CFLAGS) \
$(AM_CFLAGS) \
-I$(top_srcdir)/ \
diff --git a/src/plugins/screenshot/totem-gallery.c b/src/plugins/screenshot/totem-gallery.c
index a9aa0a6..c05b7c2 100644
--- a/src/plugins/screenshot/totem-gallery.c
+++ b/src/plugins/screenshot/totem-gallery.c
@@ -31,6 +31,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
+#include "totem-dirs.h"
#include "totem-gallery.h"
#include "totem-gallery-progress.h"
#include "totem-screenshot-plugin.h"
@@ -63,7 +64,7 @@ totem_gallery_init (TotemGallery *self)
}
TotemGallery *
-totem_gallery_new (Totem *totem, TotemPlugin *plugin)
+totem_gallery_new (Totem *totem, TotemScreenshotPlugin *plugin)
{
TotemGallery *gallery;
GtkWidget *container;
@@ -74,7 +75,7 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
/* Create the gallery and its interface */
gallery = g_object_new (TOTEM_TYPE_GALLERY, NULL);
- builder = totem_plugin_load_interface (plugin, "gallery.ui", TRUE, NULL, gallery);
+ builder = totem_plugin_load_interface ("screenshot", "gallery.ui", TRUE, NULL, gallery);
if (builder == NULL) {
g_object_unref (gallery);
return NULL;
diff --git a/src/plugins/screenshot/totem-gallery.h b/src/plugins/screenshot/totem-gallery.h
index 916bbb5..7ebcb71 100644
--- a/src/plugins/screenshot/totem-gallery.h
+++ b/src/plugins/screenshot/totem-gallery.h
@@ -32,7 +32,7 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include "totem-plugin.h"
+#include "totem-screenshot-plugin.h"
#include "totem.h"
G_BEGIN_DECLS
@@ -56,7 +56,7 @@ typedef struct {
} TotemGalleryClass;
GType totem_gallery_get_type (void);
-TotemGallery *totem_gallery_new (Totem *totem, TotemPlugin *plugin);
+TotemGallery *totem_gallery_new (Totem *totem, TotemScreenshotPlugin *plugin);
G_END_DECLS
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.c b/src/plugins/screenshot/totem-screenshot-plugin.c
index a48f67e..38fd4d7 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.c
+++ b/src/plugins/screenshot/totem-screenshot-plugin.c
@@ -31,6 +31,7 @@
#include <gmodule.h>
#include <string.h>
#include <gdk/gdkkeysyms.h>
+#include <libpeas/peas-activatable.h>
#include <gconf/gconf-client.h>
#ifdef HAVE_XFREE
@@ -58,26 +59,41 @@ struct TotemScreenshotPluginPrivate {
GtkActionGroup *action_group;
};
-static gboolean impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error);
-static void impl_deactivate (TotemPlugin *plugin, TotemObject *totem);
+static void peas_activatable_iface_init (PeasActivatableInterface *iface);
+static void impl_activate (PeasActivatable *plugin, GObject *totem);
+static void impl_deactivate (PeasActivatable *plugin, GObject *totem);
-TOTEM_PLUGIN_REGISTER (TotemScreenshotPlugin, totem_screenshot_plugin)
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (TotemScreenshotPlugin,
+ totem_screenshot_plugin,
+ PEAS_TYPE_EXTENSION_BASE,
+ 0,
+ G_IMPLEMENT_INTERFACE_DYNAMIC (PEAS_TYPE_ACTIVATABLE,
+ peas_activatable_iface_init))
static void
totem_screenshot_plugin_class_init (TotemScreenshotPluginClass *klass)
{
- TotemPluginClass *plugin_class = TOTEM_PLUGIN_CLASS (klass);
-
g_type_class_add_private (klass, sizeof (TotemScreenshotPluginPrivate));
+}
- plugin_class->activate = impl_activate;
- plugin_class->deactivate = impl_deactivate;
+static void
+peas_activatable_iface_init (PeasActivatableInterface *iface)
+{
+ iface->activate = impl_activate;
+ iface->deactivate = impl_deactivate;
}
static void
totem_screenshot_plugin_init (TotemScreenshotPlugin *plugin)
{
- plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin, TOTEM_TYPE_SCREENSHOT_PLUGIN, TotemScreenshotPluginPrivate);
+ plugin->priv = G_TYPE_INSTANCE_GET_PRIVATE (plugin,
+ TOTEM_TYPE_SCREENSHOT_PLUGIN,
+ TotemScreenshotPluginPrivate);
+}
+
+static void
+totem_screenshot_plugin_class_finalize (TotemScreenshotPluginClass *klass)
+{
}
static void
@@ -106,7 +122,7 @@ take_screenshot_action_cb (GtkAction *action, TotemScreenshotPlugin *self)
return;
}
- dialog = totem_screenshot_new (priv->totem, TOTEM_PLUGIN (self), pixbuf);
+ dialog = totem_screenshot_new (priv->totem, self, pixbuf);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
@@ -131,7 +147,7 @@ take_gallery_action_cb (GtkAction *action, TotemScreenshotPlugin *self)
if (bacon_video_widget_get_logo_mode (self->priv->bvw) != FALSE)
return;
- dialog = GTK_DIALOG (totem_gallery_new (totem, TOTEM_PLUGIN (self)));
+ dialog = GTK_DIALOG (totem_gallery_new (totem, self));
g_signal_connect (dialog, "response",
G_CALLBACK (take_gallery_response_cb), self);
@@ -196,8 +212,9 @@ disable_save_to_disk_changed_cb (GConfClient *client, guint connection_id, GConf
self->priv->save_to_disk = !gconf_client_get_bool (client, "/desktop/gnome/lockdown/disable_save_to_disk", NULL);
}
-static gboolean
-impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
+static void
+impl_activate (PeasActivatable *plugin,
+ GObject *totem)
{
GtkWindow *window;
GtkUIManager *manager;
@@ -209,8 +226,8 @@ impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
{ "take-gallery", NULL, N_("Create Screenshot _Gallery..."), NULL, N_("Create a gallery of screenshots"), G_CALLBACK (take_gallery_action_cb) }
};
- priv->totem = totem;
- priv->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (totem));
+ priv->totem = TOTEM_OBJECT (totem);
+ priv->bvw = BACON_VIDEO_WIDGET (totem_get_video_widget (priv->totem));
priv->got_metadata_signal = g_signal_connect (G_OBJECT (priv->bvw),
"got-metadata",
G_CALLBACK (got_metadata_cb),
@@ -221,7 +238,7 @@ impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
self);
/* Key press handler */
- window = totem_get_main_window (totem);
+ window = totem_get_main_window (priv->totem);
priv->key_press_event_signal = g_signal_connect (G_OBJECT (window),
"key-press-event",
G_CALLBACK (window_key_press_event_cb),
@@ -234,7 +251,7 @@ impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
gtk_action_group_add_actions (priv->action_group, menu_entries,
G_N_ELEMENTS (menu_entries), self);
- manager = totem_get_ui_manager (totem);
+ manager = totem_get_ui_manager (priv->totem);
gtk_ui_manager_insert_action_group (manager, priv->action_group, -1);
g_object_unref (priv->action_group);
@@ -260,12 +277,11 @@ impl_activate (TotemPlugin *plugin, TotemObject *totem, GError **error)
/* Update the menu entries' states */
update_state (self);
-
- return TRUE;
}
static void
-impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
+impl_deactivate (PeasActivatable *plugin,
+ GObject *totem)
{
TotemScreenshotPluginPrivate *priv = TOTEM_SCREENSHOT_PLUGIN (plugin)->priv;
GtkWindow *window;
@@ -276,7 +292,7 @@ impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
g_signal_handler_disconnect (G_OBJECT (priv->bvw), priv->got_metadata_signal);
g_signal_handler_disconnect (G_OBJECT (priv->bvw), priv->notify_logo_mode_signal);
- window = totem_get_main_window (totem);
+ window = totem_get_main_window (priv->totem);
g_signal_handler_disconnect (G_OBJECT (window), priv->key_press_event_signal);
g_object_unref (window);
@@ -286,7 +302,7 @@ impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
g_object_unref (client);
/* Remove the menu */
- manager = totem_get_ui_manager (totem);
+ manager = totem_get_ui_manager (priv->totem);
gtk_ui_manager_remove_ui (manager, priv->ui_merge_id);
gtk_ui_manager_remove_action_group (manager, priv->action_group);
@@ -372,3 +388,14 @@ totem_screenshot_plugin_update_file_chooser (const char *uri)
dir, NULL);
g_free (dir);
}
+
+G_MODULE_EXPORT void
+peas_register_types (PeasObjectModule *module)
+{
+ totem_screenshot_plugin_register_type (G_TYPE_MODULE (module));
+
+ peas_object_module_register_extension_type (module,
+ PEAS_TYPE_ACTIVATABLE,
+ TOTEM_TYPE_SCREENSHOT_PLUGIN);
+}
+
diff --git a/src/plugins/screenshot/totem-screenshot-plugin.h b/src/plugins/screenshot/totem-screenshot-plugin.h
index e3c2ce9..8d0d946 100644
--- a/src/plugins/screenshot/totem-screenshot-plugin.h
+++ b/src/plugins/screenshot/totem-screenshot-plugin.h
@@ -31,7 +31,8 @@
#include <glib.h>
#include "totem.h"
-#include "totem-plugin.h"
+#include <libpeas/peas-extension-base.h>
+#include <libpeas/peas-object-module.h>
G_BEGIN_DECLS
@@ -45,16 +46,16 @@ G_BEGIN_DECLS
typedef struct TotemScreenshotPluginPrivate TotemScreenshotPluginPrivate;
typedef struct {
- TotemPlugin parent;
+ PeasExtensionBase parent;
TotemScreenshotPluginPrivate *priv;
} TotemScreenshotPlugin;
typedef struct {
- TotemPluginClass parent_class;
+ PeasExtensionBaseClass parent_class;
} TotemScreenshotPluginClass;
GType totem_screenshot_plugin_get_type (void) G_GNUC_CONST;
-G_MODULE_EXPORT GType register_totem_plugin (GTypeModule *module);
+G_MODULE_EXPORT void peas_register_types (PeasObjectModule *module);
gchar *totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const char *movie_name) G_GNUC_WARN_UNUSED_RESULT;
void totem_screenshot_plugin_update_file_chooser (const char *filename);
diff --git a/src/plugins/screenshot/totem-screenshot.c b/src/plugins/screenshot/totem-screenshot.c
index d10e60d..4cdf0f2 100644
--- a/src/plugins/screenshot/totem-screenshot.c
+++ b/src/plugins/screenshot/totem-screenshot.c
@@ -35,6 +35,7 @@
#include <gtk/gtk.h>
#include <unistd.h>
+#include "totem-dirs.h"
#include "totem-interface.h"
#include "totem-screenshot-plugin.h"
#include "gnome-screenshot-widget.h"
@@ -145,7 +146,7 @@ totem_screenshot_init (TotemScreenshot *screenshot)
}
GtkWidget *
-totem_screenshot_new (Totem *totem, TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image)
+totem_screenshot_new (Totem *totem, TotemScreenshotPlugin *screenshot_plugin, GdkPixbuf *screen_image)
{
TotemScreenshot *screenshot;
GtkContainer *content_area;
@@ -159,7 +160,7 @@ totem_screenshot_new (Totem *totem, TotemPlugin *screenshot_plugin, GdkPixbuf *s
/* Translators: %s is the movie title and %d is an auto-incrementing number to make filename unique */
initial_uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot-%s-%d.png"), movie_title);
g_free (movie_title);
- interface_path = totem_plugin_find_file (screenshot_plugin, "gnome-screenshot.ui");
+ interface_path = totem_plugin_find_file ("screenshot", "gnome-screenshot.ui");
screenshot->priv->widget = GNOME_SCREENSHOT_WIDGET (gnome_screenshot_widget_new (interface_path, screen_image, initial_uri));
g_free (interface_path);
g_free (initial_uri);
diff --git a/src/plugins/screenshot/totem-screenshot.h b/src/plugins/screenshot/totem-screenshot.h
index 36cf383..651c95e 100644
--- a/src/plugins/screenshot/totem-screenshot.h
+++ b/src/plugins/screenshot/totem-screenshot.h
@@ -30,7 +30,7 @@
#define TOTEM_SCREENSHOT_H
#include <gtk/gtk.h>
-#include "totem-plugin.h"
+#include "totem-screenshot-plugin.h"
G_BEGIN_DECLS
@@ -54,7 +54,7 @@ struct TotemScreenshotClass {
};
GType totem_screenshot_get_type (void) G_GNUC_CONST;
-GtkWidget *totem_screenshot_new (Totem *totem, TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image) G_GNUC_WARN_UNUSED_RESULT;
+GtkWidget *totem_screenshot_new (Totem *totem, TotemScreenshotPlugin *screenshot_plugin, GdkPixbuf *screen_image) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]