From 536dd16de6917c4d70311d275188b79f61403f18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Sat, 12 Dec 2009 12:11:19 +0100 Subject: [PeasDemo] Add a configuration dialog to the C sample plugin. --- .../helloworld/peasdemo-hello-world-plugin.c | 57 +++++++++++++++++++++- .../helloworld/peasdemo-hello-world-plugin.h | 12 ++--- 2 files changed, 62 insertions(+), 7 deletions(-) (limited to 'peas-demo') diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c index 44ee0b3..38d1385 100644 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c +++ b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c @@ -1,11 +1,21 @@ #include +#include #include +#include + #include "peasdemo-hello-world-plugin.h" #define WINDOW_DATA_KEY "PeasDemoHelloWorldPluginWindowData" -PEAS_REGISTER_TYPE(PEAS_TYPE_PLUGIN, PeasDemoHelloWorldPlugin, peasdemo_hello_world_plugin) +static void peas_ui_configurable_iface_init (PeasUIConfigurableIface *iface); + +G_DEFINE_DYNAMIC_TYPE_EXTENDED (PeasDemoHelloWorldPlugin, + peasdemo_hello_world_plugin, + PEAS_TYPE_PLUGIN, + 0, + G_IMPLEMENT_INTERFACE (PEAS_UI_TYPE_CONFIGURABLE, + peas_ui_configurable_iface_init)) typedef struct { GtkWidget *label; @@ -90,6 +100,32 @@ peasdemo_hello_world_plugin_deactivate (PeasPlugin *plugin, g_object_set_data (G_OBJECT (window), WINDOW_DATA_KEY, NULL); } +static void +on_configure_dialog_response (GtkDialog *dialog, + gint response_id, + gpointer user_data) +{ + gtk_widget_destroy (GTK_WIDGET (dialog)); +} + +static GtkWidget * +peasdemo_hello_world_plugin_create_configure_dialog (PeasUIConfigurable *configurable) +{ + GtkWidget *dialog; + + g_debug (G_STRFUNC); + + dialog = gtk_message_dialog_new (NULL, + 0, + GTK_MESSAGE_INFO, + GTK_BUTTONS_OK, + "This is a configuration dialog for the HelloWorld plugin."); + g_signal_connect (dialog, "response", + G_CALLBACK (on_configure_dialog_response), NULL); + + return dialog; +} + static void peasdemo_hello_world_plugin_class_init (PeasDemoHelloWorldPluginClass *klass) { @@ -101,3 +137,22 @@ peasdemo_hello_world_plugin_class_init (PeasDemoHelloWorldPluginClass *klass) plugin_class->activate = peasdemo_hello_world_plugin_activate; plugin_class->deactivate = peasdemo_hello_world_plugin_deactivate; } + +static void +peas_ui_configurable_iface_init (PeasUIConfigurableIface *iface) +{ + iface->create_configure_dialog = peasdemo_hello_world_plugin_create_configure_dialog; +} + +static void +peasdemo_hello_world_plugin_class_finalize (PeasDemoHelloWorldPluginClass *klass) +{ +} + +G_MODULE_EXPORT GType +register_peas_plugin (GTypeModule *type_module) +{ + peasdemo_hello_world_plugin_register_type (type_module); + + return PEASDEMO_TYPE_HELLO_WORLD_PLUGIN; +} diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h index f8ca9e6..89b8b3b 100644 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h +++ b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.h @@ -7,12 +7,12 @@ G_BEGIN_DECLS -#define PeasDEMO_TYPE_HELLO_WORLD_PLUGIN (peasdemo_hello_world_plugin_get_type ()) -#define PeasDEMO_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) -#define PeasDEMO_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) -#define PeasDEMO_IS_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN)) -#define PeasDEMO_IS_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN)) -#define PeasDEMO_HELLO_WORLD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPluginClass)) +#define PEASDEMO_TYPE_HELLO_WORLD_PLUGIN (peasdemo_hello_world_plugin_get_type ()) +#define PEASDEMO_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) +#define PEASDEMO_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPlugin)) +#define PEASDEMO_IS_HELLO_WORLD_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN)) +#define PEASDEMO_IS_HELLO_WORLD_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN)) +#define PEASDEMO_HELLO_WORLD_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), PeasDEMO_TYPE_HELLO_WORLD_PLUGIN, PeasDemoHelloWorldPluginClass)) typedef struct _PeasDemoHelloWorldPlugin PeasDemoHelloWorldPlugin; typedef struct _PeasDemoHelloWorldPluginClass PeasDemoHelloWorldPluginClass; -- cgit v1.2.1 From b80b935502fb0ad2731a4565efacd2b446cd1386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Steve=20Fr=C3=A9cinaux?= Date: Fri, 11 Dec 2009 23:51:14 +0100 Subject: Remove GTK+ dependendency for libpeas. Everything linked to Gtk+ has been moved from libpeas to libpeasui, hence we will not link libpeas against Gtk+ anymore... --- peas-demo/Makefile.am | 4 +++- peas-demo/plugins/helloworld/Makefile.am | 5 +++-- peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) (limited to 'peas-demo') diff --git a/peas-demo/Makefile.am b/peas-demo/Makefile.am index c53a0d6..abf4d28 100644 --- a/peas-demo/Makefile.am +++ b/peas-demo/Makefile.am @@ -6,6 +6,7 @@ INCLUDES = \ -I$(top_srcdir) \ -I$(srcdir) \ $(PEAS_CFLAGS) \ + $(PEASUI_CFLAGS) \ $(WARN_CFLAGS) \ $(DISABLE_DEPRECATED_CFLAGS) @@ -14,7 +15,8 @@ peas_demo_SOURCES = \ peas_demo_LDADD = \ $(PEAS_LIBS) \ - ../libpeas/libpeas-2.0.la \ + $(PEASUI_LIBS) \ + ../libpeas/libpeas-2.0.la \ ../libpeasui/libpeasui-2.0.la peas_demo_CFLAGS = \ diff --git a/peas-demo/plugins/helloworld/Makefile.am b/peas-demo/plugins/helloworld/Makefile.am index 604d633..7f44913 100644 --- a/peas-demo/plugins/helloworld/Makefile.am +++ b/peas-demo/plugins/helloworld/Makefile.am @@ -2,7 +2,8 @@ plugindir = $(prefix)/lib/peas-demo/plugins/helloworld INCLUDES = \ -I$(top_srcdir) \ - $(PEAS_CFLAGS) + $(PEAS_CFLAGS) \ + $(PEASUI_CFLAGS) plugin_LTLIBRARIES = libhelloworld.la @@ -11,7 +12,7 @@ libhelloworld_la_SOURCES = \ peasdemo-hello-world-plugin.c libhelloworld_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS) -libhelloworld_la_LIBADD = $(PEAS_LIBS) +libhelloworld_la_LIBADD = $(PEAS_LIBS) $(PEASUI_LIBS) plugin_DATA = helloworld.peasdemo-plugin diff --git a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c index 38d1385..aacddb3 100644 --- a/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c +++ b/peas-demo/plugins/helloworld/peasdemo-hello-world-plugin.c @@ -1,6 +1,7 @@ #include #include #include +#include #include -- cgit v1.2.1