[vinagre] Begin porting applet to libpanelapplet-4.0 API
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vinagre] Begin porting applet to libpanelapplet-4.0 API
- Date: Sun, 13 Mar 2011 12:21:23 +0000 (UTC)
commit e6bc4948c1a6cb66ec7905f1a0abb09c6db55e89
Author: David King <amigadave amigadave com>
Date: Sat Mar 12 19:06:33 2011 +0100
Begin porting applet to libpanelapplet-4.0 API
Port the panel applet to the new D-Bus panel applet API. Add D-Bus
service file and panel-applet keyfile. Tidy build rules for the panel
applet to depend on the vinagre libtool convenience library. Change the
default configure arguments so that applet support is automagically
enabled by default.
The port is untested and incomplete, but builds successfully.
.gitignore | 4 +
Makefile.am | 99 +++++----------
configure.ac | 11 +-
data/GNOME_VinagreApplet.xml | 20 +---
data/org.gnome.panel.Vinagre.panel-applet.in.in | 16 +++
data/org.gnome.panel.applet.Vinagre.service.in | 3 +
po/POTFILES.in | 3 +-
po/POTFILES.skip | 2 +-
vinagre/GNOME_VinagreApplet.server.in.in | 38 ------
vinagre/vinagre-applet.c | 157 ++++++++++-------------
10 files changed, 134 insertions(+), 219 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index 5a0021e..460ec4f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -17,6 +17,9 @@ Makefile.in
/config.h.in
/config.status
/configure
+/data/org.gnome.panel.Vinagre.panel-applet
+/data/org.gnome.panel.Vinagre.panel-applet.in
+/data/org.gnome.panel.applet.Vinagre.service
/gnome-doc-utils.make
/help/*/*.mo
/help/*/vinagre.xml
@@ -76,6 +79,7 @@ Makefile.in
/po/stamp-it
/po/*.gmo
/stamp-h1
+/vinagre-applet
/vinagre/*.lo
/vinagre/*.o
/vinagre/.deps
diff --git a/Makefile.am b/Makefile.am
index c15a903..727de5e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
SUBDIRS = help po
-DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper --without-panelapplet
+DISTCHECK_CONFIGURE_FLAGS = --disable-scrollkeeper
AM_CPPFLAGS = \
-I$(top_builddir) \
@@ -120,77 +120,39 @@ libvinagre_la_LIBADD = $(VINAGRE_LIBS)
if VINAGRE_HAVE_PANELAPPLET
-# Bonobo .server
-serverdir = $(libdir)/bonobo/servers
-server_in_files = GNOME_VinagreApplet.server.in
-nodist_server_DATA = $(server_in_files:.server.in=.server)
+appletdir = $(LIBPANEL_APPLET_DIR)
+applet_in_file = data/org.gnome.panel.Vinagre.panel-applet.in
+nodist_applet_DATA = $(applet_in_file:.panel-applet.in=.panel-applet)
-$(server_in_files): $(server_in_files:.server.in=.server.in.in)
- $(AM_V_GEN)$(SED) -e "s|\ LIBEXECDIR\@|$(libexecdir)|" -e "s|\ PACKAGE_VERSION\@|$(PACKAGE_VERSION)|" $< > $@
+$(applet_in_file): $(applet_in_file).in Makefile
+ $(AM_V_GEN)$(SED) \
+ -e "s|\ LIBEXECDIR\@|$(libexecdir)|" \
+ -e "s|\ PACKAGE_VERSION\@|$(PACKAGE_VERSION)|" $< > $@
- INTLTOOL_SERVER_RULE@
+# TODO: Replace with INTLTOOL_PANEL_APPLET_RULE when it exists.
+$(nodist_applet_DATA): $(applet_in_file) $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po)
+ $(INTLTOOL_MERGE) $(top_srcdir)/po $< $@ -d -u -c $(top_builddir)/po/.intltool-merge-cache
+
+appletservicedir = $(datadir)/dbus-1/services
+appletservice_in_file = data/org.gnome.panel.applet.Vinagre.service.in
+nodist_appletservice_DATA = $(appletservice_in_file:.service.in=.service)
+
+$(nodist_appletservice_DATA): $(appletservice_in_file) Makefile
+ $(AM_V_GEN)$(SED) \
+ -e "s|\ LOCATION\@|$(libexecdir)/vinagre-applet|" $< > $@
# The applet binary
libexec_PROGRAMS = vinagre-applet
-vinagre_applet_CFLAGS = \
- $(PANELAPPLET_CFLAGS)
+vinagre_applet_CPPFLAGS = \
+ $(PANELAPPLET_CFLAGS) \
+ $(AM_CPPFLAGS)
vinagre_applet_SOURCES = \
- vinagre/vinagre-applet.c \
- vinagre/vinagre-bookmarks.h \
- vinagre/vinagre-bookmarks.c \
- vinagre/vinagre-bookmarks-ui.h \
- vinagre/vinagre-bookmarks-ui.c \
- vinagre/vinagre-connection.h \
- vinagre/vinagre-connection.c \
- vinagre/vinagre-utils.h \
- vinagre/vinagre-utils.c \
- vinagre/vinagre-bookmarks-entry.h \
- vinagre/vinagre-bookmarks-entry.c \
- vinagre/vinagre-bookmarks-tree.h \
- vinagre/vinagre-bookmarks-tree.c \
- vinagre/vinagre-bookmarks-migration.h \
- vinagre/vinagre-bookmarks-migration.c \
- vinagre/vinagre-plugin-dialog.h \
- vinagre/vinagre-plugin-dialog.c \
- vinagre/vinagre-debug.h \
- vinagre/vinagre-debug.c \
- vinagre/vinagre-window.h \
- vinagre/vinagre-window.c \
- vinagre/vinagre-commands.h \
- vinagre/vinagre-commands.c \
- vinagre/vinagre-notebook.h \
- vinagre/vinagre-notebook.c \
- vinagre/vinagre-tab.h \
- vinagre/vinagre-tab.c \
- vinagre/vinagre-prefs.h \
- vinagre/vinagre-prefs.c \
- vinagre/vinagre-dirs.h \
- vinagre/vinagre-dirs.c \
- vinagre/vinagre-fav.h \
- vinagre/vinagre-fav.c \
- vinagre/vinagre-connect.h \
- vinagre/vinagre-connect.c \
- vinagre/pty_open.h \
- vinagre/pty_open.c \
- vinagre/vinagre-ssh.h \
- vinagre/vinagre-ssh.c \
- vinagre/vinagre-cache-prefs.h \
- vinagre/vinagre-cache-prefs.c \
- vinagre/vinagre-protocol.h \
- vinagre/vinagre-protocol.c \
- vinagre/vinagre-plugins-engine.h \
- vinagre/vinagre-plugins-engine.c
-
-if VINAGRE_HAVE_AVAHI
-vinagre_applet_SOURCES += \
- vinagre/vinagre-mdns.h \
- vinagre/vinagre-mdns.c
-endif
+ vinagre/vinagre-applet.c
vinagre_applet_LDADD = \
- vinagre/view/libview.la \
+ libvinagre.la \
$(PANELAPPLET_LIBS) \
$(VINAGRE_LIBS)
@@ -486,12 +448,13 @@ dist_noinst_DATA = \
data/vinagre-mime.xml.in \
$(desktop_in_files) \
$(gsettings_in_file) \
+ $(applet_in_file) \
+ $(appletservice_in_file) \
$(service_in_file) \
intltool-extract.in \
intltool-merge.in \
intltool-update.in \
$(plugin_in_files) \
- vinagre/GNOME_VinagreApplet.server.in.in \
vinagre.doap
CLEANFILES += \
@@ -499,15 +462,15 @@ CLEANFILES += \
$(nodist_mime_DATA) \
$(gsettings_SCHEMAS) \
$(nodist_pkgconfig_DATA) \
- $(nodist_plugin_DATA) \
- data/org.freedesktop.Telepathy.Client.Vinagre.service
+ $(nodist_applet_DATA) \
+ $(nodist_appletservice_DATA) \
+ $(nodist_service_DATA) \
+ $(nodist_plugin_DATA)
DISTCLEANFILES = \
intltool-extract \
intltool-merge \
- intltool-update \
- $(server_in_files) \
- $(server_DATA)
+ intltool-update
MAINTAINERCLEANFILES = \
build-aux/compile \
diff --git a/configure.ac b/configure.ac
index 6eb2fff..1645bf1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,10 +173,8 @@ AM_CONDITIONAL([VINAGRE_HAVE_TELEPATHY_GLIB], [test "x$have_telepathy" = "xyes"]
PANELAPPLET_DEPS="libpanelapplet-4.0 >= 2.91.91"
AC_ARG_WITH([panelapplet],
- [AS_HELP_STRING([--with-panelapplet],
- [enable libpanelapplet support])],
- [],
- [with_panelapplet=no])
+ [AS_HELP_STRING([--without-panelapplet],
+ [ignore libpanelapplet support and disable it])])
AS_IF([test "x$with_panelapplet" != "xno"],
[PKG_CHECK_MODULES([PANELAPPLET],
@@ -186,7 +184,9 @@ AS_IF([test "x$with_panelapplet" != "xno"],
[have_panelapplet=no])
AS_IF([test "x$have_panelapplet" = "xyes"],
- [AC_MSG_WARN([Applet support is currently broken!])],
+ [AC_MSG_CHECKING([for panel applet path in pkg-config file])
+ AC_SUBST([LIBPANEL_APPLET_DIR], [`$PKG_CONFIG --variable=libpanel_applet_dir libpanelapplet-4.0`])
+ AC_MSG_RESULT([$LIBPANEL_APPLET_DIR])],
[PANELAPPLET_DEPS=""
AS_IF([test "x$with_panelapplet" = "xyes"],
[AC_MSG_ERROR([panelapplet support requested but not found])])])
@@ -261,6 +261,7 @@ GLIB_GSETTINGS
AC_CONFIG_FILES([
Makefile
+data/org.gnome.panel.Vinagre.panel-applet.in
data/vinagre.desktop.in
data/vinagre-file.desktop.in
data/vinagre-${VINAGRE_ABI_VERSION}.pc:data/vinagre.pc.in
diff --git a/data/GNOME_VinagreApplet.xml b/data/GNOME_VinagreApplet.xml
index f4df3c9..6ece58e 100644
--- a/data/GNOME_VinagreApplet.xml
+++ b/data/GNOME_VinagreApplet.xml
@@ -1,18 +1,2 @@
-<Root>
- <popups>
- <popup name="button3">
- <menuitem
- name="Help Item"
- verb="VinagreHelp"
- _label="_Help"
- pixtype="stock"
- pixname="gtk-help"/>
- <menuitem
- name="About Item"
- verb="VinagreAbout"
- _label="_About"
- pixtype="stock"
- pixname="gtk-about"/>
- </popup>
- </popups>
-</Root>
+<menuitem name="Help item" action="VinagreHelp"/>
+<menuitem name="About item" action="VinagreAbout"/>
diff --git a/data/org.gnome.panel.Vinagre.panel-applet.in.in b/data/org.gnome.panel.Vinagre.panel-applet.in.in
new file mode 100644
index 0000000..ba2ef8e
--- /dev/null
+++ b/data/org.gnome.panel.Vinagre.panel-applet.in.in
@@ -0,0 +1,16 @@
+[Applet Factory]
+Id=VinagreAppletFactory
+Location= LIBEXECDIR@
+_Name=Vinagre Applet Factory
+_Description=Vinagre Applet Factory
+
+[VinagreApplet]
+_Name=Remote Desktop Viewer
+_Description=A menu to quickly access remote machines
+Icon=vinagre
+BonoboId=OAFIID:GNOME_VinagreApplet
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=vinagre
+X-GNOME-Bugzilla-Component=applet
+X-GNOME-Bugzilla-Version= PACKAGE_VERSION@
+X-GNOME-Bugzilla-OtherBinaries=vinagre-applet
diff --git a/data/org.gnome.panel.applet.Vinagre.service.in b/data/org.gnome.panel.applet.Vinagre.service.in
new file mode 100644
index 0000000..3d4e3b2
--- /dev/null
+++ b/data/org.gnome.panel.applet.Vinagre.service.in
@@ -0,0 +1,3 @@
+[D-BUS Service]
+Name=org.gnome.panel.applet.Vinagre
+Exec= LOCATION@
diff --git a/po/POTFILES.in b/po/POTFILES.in
index ba5a2ab..c19e65b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -1,6 +1,6 @@
# List of source files containing translatable strings.
-data/GNOME_VinagreApplet.xml
+data/org.gnome.panel.Vinagre.panel-applet.in.in
data/org.gnome.Vinagre.gschema.xml.in
data/vinagre.desktop.in.in
data/vinagre-file.desktop.in.in
@@ -30,7 +30,6 @@ plugins/spice/vinagre-spice-tunnel.c
[type: gettext/glade]plugins/reverse-vnc/reverse-vnc.ui
plugins/im-status/im-status.plugin.desktop.in
plugins/im-status/im-status.js
-vinagre/GNOME_VinagreApplet.server.in.in
vinagre/vinagre-applet.c
vinagre/vinagre-bookmarks.c
vinagre/vinagre-bookmarks-migration.c
diff --git a/po/POTFILES.skip b/po/POTFILES.skip
index 8528c40..db575f6 100644
--- a/po/POTFILES.skip
+++ b/po/POTFILES.skip
@@ -1,7 +1,7 @@
+data/org.gnome.panel.Vinagre.panel-applet.in
data/vinagre.desktop.in
data/vinagre-file.desktop.in
data/vinagre-mime.xml.in
data/vinagre.schemas.in
plugins/dummy/dummy.vinagre-plugin.desktop.in
plugins/dummy/vinagre-dummy-plugin.c
-vinagre/GNOME_VinagreApplet.server.in
diff --git a/vinagre/vinagre-applet.c b/vinagre/vinagre-applet.c
index 296b4b7..6f7ec13 100644
--- a/vinagre/vinagre-applet.c
+++ b/vinagre/vinagre-applet.c
@@ -45,8 +45,8 @@
#define VINAGRE_IS_APPLET_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), VINAGRE_TYPE_APPLET))
#define VINAGRE_APPLET_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), VINAGRE_TYPE_APPLET, VinagreAppletClass))
-#define VINAGRE_APPLET_OAFID "OAFIID:GNOME_VinagreApplet"
-#define VINAGRE_APPLET_FACTORY_OAFID "OAFIID:GNOME_VinagreApplet_Factory"
+static const gchar VINAGRE_APPLET_FACTORY_ID[] = "VinagreAppletFactory";
+static const gchar VINAGRE_APPLET_ID[] = "VinagreApplet";
#define PANEL_APPLET_VERTICAL(p) (((p) == PANEL_APPLET_ORIENT_LEFT) || ((p) == PANEL_APPLET_ORIENT_RIGHT))
typedef struct{
@@ -138,9 +138,7 @@ vinagre_applet_check_size (VinagreApplet *applet)
static gboolean
vinagre_applet_draw_cb (VinagreApplet *applet)
{
- gint bg_type;
GdkColor color;
- GdkPixmap *background;
GdkWindow *window = gtk_widget_get_window (GTK_WIDGET (applet));
cairo_t *cr;
@@ -159,21 +157,7 @@ vinagre_applet_draw_cb (VinagreApplet *applet)
cr = gdk_cairo_create (window);
- /* draw pixmap background */
- bg_type = panel_applet_get_background (PANEL_APPLET (applet), &color, &background);
- if (bg_type == PANEL_PIXMAP_BACKGROUND)
- {
- /* fill with given background pixmap */
- gdk_cairo_set_source_pixmap (cr, background, 0, 0);
- cairo_paint (cr);
- }
-
- /* draw color background */
- if (bg_type == PANEL_COLOR_BACKGROUND)
- {
- gdk_cairo_set_source_color (cr, &color);
- cairo_fill (cr);
- }
+ panel_applet_set_background_widget(PANEL_APPLET(applet), GTK_WIDGET(applet));
gdk_cairo_set_source_pixbuf (cr, applet->icon, 0, 0);
cairo_paint (cr);
@@ -184,8 +168,8 @@ vinagre_applet_draw_cb (VinagreApplet *applet)
static void
vinagre_applet_change_background_cb (VinagreApplet *applet,
- PanelAppletBackgroundType arg1,
- GdkColor *arg2, GdkPixmap *arg3, gpointer data)
+ cairo_pattern_t *pattern,
+ gpointer user_data)
{
gtk_widget_queue_draw (GTK_WIDGET (applet));
}
@@ -217,7 +201,8 @@ menu_position (GtkMenu *menu,
GdkWindow *window = gtk_widget_get_window (applet);
gdk_window_get_origin (window, x, y);
- gdk_drawable_get_size (window, &applet_width, &applet_height);
+ applet_width = gdk_window_get_width(window);
+ applet_height = gdk_window_get_height(window);
gtk_widget_size_request (GTK_WIDGET (menu), &requisition);
switch (panel_applet_get_orient (PANEL_APPLET (applet)))
@@ -247,34 +232,32 @@ menu_position (GtkMenu *menu,
static void
open_connection_cb (GtkMenuItem *item,
- gpointer *user_data)
+ gpointer user_data)
{
- GError *err = NULL;
- gchar **argv;
- VinagreConnection *conn;
-
- conn = VINAGRE_CONNECTION (g_object_get_data (G_OBJECT (item), "conn"));
-
- argv = g_new0 (gchar *, 3);
- argv[0] = g_strdup ("vinagre");
- argv[1] = g_strdup (vinagre_connection_get_string_rep (conn, TRUE));
- argv[2] = NULL;
-
- if (!gdk_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (item)),
- NULL,
- argv,
- NULL,
- G_SPAWN_SEARCH_PATH,
- NULL,
- NULL,
- NULL,
- &err))
+ GAppInfo *info;
+ GdkAppLaunchContext *context;
+ GError *error = NULL;
+ VinagreConnection *conn;
+ gchar *commandline;
+ static const gchar application_name[] = PACKAGE_TARNAME;
+
+ conn = VINAGRE_CONNECTION (g_object_get_data (G_OBJECT (item), "conn"));
+
+ commandline = vinagre_connection_get_string_rep (conn, TRUE);
+
+ info = g_app_info_create_from_commandline(commandline, application_name,
+ G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION, &error);
+ context = gdk_display_get_app_launch_context(gdk_display_get_default());
+ g_app_info_launch(info, NULL, G_APP_LAUNCH_CONTEXT(context), &error);
+
+ if(error)
{
- vinagre_utils_show_error (_("Could not run vinagre:"), err->message, NULL);
- g_error_free (err);
+ vinagre_utils_show_error (_("Could not run vinagre:"), error->message,
+ NULL);
+ g_error_free(error);
}
-
- g_strfreev (argv);
+
+ g_free(commandline);
}
static void
@@ -287,7 +270,7 @@ fill_recursive_menu (GSList *entries, GtkWidget *menu)
{
VinagreBookmarksEntry *entry = VINAGRE_BOOKMARKS_ENTRY (l->data);
VinagreConnection *conn;
- VinagreProtocolExt *ext;
+ VinagreProtocol *ext;
switch (vinagre_bookmarks_entry_get_node (entry))
{
@@ -311,7 +294,7 @@ fill_recursive_menu (GSList *entries, GtkWidget *menu)
ext = vinagre_plugins_engine_get_plugin_by_protocol (vinagre_plugins_engine_get_default (),
vinagre_connection_get_protocol (conn));
- image = gtk_image_new_from_icon_name (vinagre_protocol_ext_get_icon_name (ext),
+ image = gtk_image_new_from_icon_name (vinagre_protocol_get_icon_name (ext),
GTK_ICON_SIZE_MENU);
item = gtk_image_menu_item_new_with_label (vinagre_connection_get_name (conn));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (item),
@@ -394,19 +377,17 @@ vinagre_applet_click_cb (GtkWidget *applet,
}
static void
-vinagre_applet_help_cb (BonoboUIComponent *ui_container,
- gpointer data,
- const gchar *cname)
+vinagre_applet_help_cb (GtkAction *action,
+ gpointer data)
{
- vinagre_utils_help_contents (NULL, NULL);
+ vinagre_utils_help_contents (NULL, NULL);
}
static void
-vinagre_applet_about_cb (BonoboUIComponent *ui_container,
- gpointer data,
- const gchar *cname)
+vinagre_applet_about_cb (GtkAction *action,
+ gpointer data)
{
- vinagre_utils_help_about (NULL);
+ vinagre_utils_help_about (NULL);
}
@@ -464,36 +445,38 @@ vinagre_applet_init (VinagreApplet *applet)
static gboolean
vinagre_applet_fill (PanelApplet *_applet,
- const gchar *iid,
- gpointer data)
+ const gchar *iid,
+ gpointer data)
{
- VinagreApplet *applet = VINAGRE_APPLET (_applet);
-
- static const BonoboUIVerb menu_verbs[] = {
- BONOBO_UI_VERB ("VinagreHelp", vinagre_applet_help_cb),
- BONOBO_UI_VERB ("VinagreAbout", vinagre_applet_about_cb),
- BONOBO_UI_VERB_END
- };
-
- if (strcmp (iid, VINAGRE_APPLET_OAFID) != 0)
- return FALSE;
-
- gtk_window_set_default_icon_name ("vinagre");
- g_set_application_name (_("Remote Desktop Viewer"));
-
- panel_applet_setup_menu_from_file (_applet,
- NULL,
- DATADIR "/vinagre/GNOME_VinagreApplet.xml",
- NULL, menu_verbs, applet);
- vinagre_applet_draw_cb (applet);
- return TRUE;
+ VinagreApplet *applet = VINAGRE_APPLET (_applet);
+ GtkActionGroup *action_group;
+ gchar *ui_path;
+
+ static const GtkActionEntry menu_actions[] = {
+ { "VinagreHelp", GTK_STOCK_HELP, N_("_Help"), NULL, NULL, G_CALLBACK(vinagre_applet_help_cb) },
+ { "VinagreAbout", GTK_STOCK_ABOUT, N_("_About"), NULL, NULL, G_CALLBACK(vinagre_applet_about_cb) }
+ };
+
+ if (g_strcmp0 (iid, VINAGRE_APPLET_ID) != 0)
+ return FALSE;
+
+ gtk_window_set_default_icon_name (PACKAGE_TARNAME);
+ g_set_application_name (_("Remote Desktop Viewer"));
+
+ action_group = gtk_action_group_new("Vinagre Applet Actions");
+ gtk_action_group_set_translation_domain(action_group, GETTEXT_PACKAGE);
+ gtk_action_group_add_actions(action_group, menu_actions,
+ G_N_ELEMENTS(menu_actions), applet);
+ ui_path = g_build_filename(VINAGRE_DATADIR, "VinagreApplet.xml", NULL);
+ panel_applet_setup_menu_from_file(_applet, ui_path, action_group);
+ g_free(ui_path);
+ g_object_unref(action_group);
+
+ vinagre_applet_draw_cb (applet);
+ return TRUE;
}
-PANEL_APPLET_BONOBO_FACTORY (VINAGRE_APPLET_FACTORY_OAFID,
- VINAGRE_TYPE_APPLET,
- "VinagreApplet",
- VERSION,
- vinagre_applet_fill,
- NULL);
-
-/* vim: set ts=8: */
+PANEL_APPLET_OUT_PROCESS_FACTORY (VINAGRE_APPLET_FACTORY_ID,
+ VINAGRE_TYPE_APPLET,
+ (PanelAppletFactoryCallback) vinagre_applet_fill,
+ NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]