[gnome-panel] don't use GtkPlug/GtkSocket for in process applets
- From: Alberts Muktupāvels <muktupavels src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-panel] don't use GtkPlug/GtkSocket for in process applets
- Date: Thu, 6 Nov 2014 22:02:18 +0000 (UTC)
commit df4ec78272624660e1e01b7382dac3e1f83cfc4a
Author: Alberts Muktupāvels <alberts muktupavels gmail com>
Date: Thu Nov 6 22:37:00 2014 +0200
don't use GtkPlug/GtkSocket for in process applets
1. This will allow panel to exit/stop without crashing when using
in process applets. It was crashing because of following assert:
g_assert (widget->priv->verifying_invariants_count > 0);
2. In process applet will not have extra background. Transparency
should now work as expected. This is still problem with out of
process applets.
.../panel-applet-container.c | 39 ++++++++++++++++----
libpanel-applet/panel-applet.c | 31 +++++++++++++---
2 files changed, 57 insertions(+), 13 deletions(-)
---
diff --git a/gnome-panel/libpanel-applet-private/panel-applet-container.c
b/gnome-panel/libpanel-applet-private/panel-applet-container.c
index 595bad0..8abca4f 100644
--- a/gnome-panel/libpanel-applet-private/panel-applet-container.c
+++ b/gnome-panel/libpanel-applet-private/panel-applet-container.c
@@ -20,6 +20,7 @@
#include <string.h>
#include <gtk/gtkx.h>
+#include <panel-applets-manager.h>
#include "panel-applet-container.h"
#include "panel-marshal.h"
@@ -29,6 +30,7 @@ struct _PanelAppletContainerPrivate {
guint name_watcher_id;
gchar *bus_name;
+ gchar *iid;
gboolean out_of_process;
guint32 xid;
guint32 uid;
@@ -84,19 +86,32 @@ panel_applet_container_init (PanelAppletContainer *container)
{
container->priv = PANEL_APPLET_CONTAINER_GET_PRIVATE (container);
- container->priv->socket = gtk_socket_new ();
- g_signal_connect_swapped (container->priv->socket, "plug-removed",
- G_CALLBACK (panel_applet_container_plug_removed),
- container);
-
container->priv->pending_ops = g_hash_table_new_full (g_direct_hash,
g_direct_equal,
NULL,
(GDestroyNotify) g_object_unref);
+}
- gtk_container_add (GTK_CONTAINER (container),
- container->priv->socket);
- gtk_widget_show (container->priv->socket);
+static void
+panel_applet_container_setup (PanelAppletContainer *container)
+{
+ if (container->priv->out_of_process) {
+ container->priv->socket = gtk_socket_new ();
+
+ g_signal_connect_swapped (container->priv->socket,
+ "plug-removed",
+ G_CALLBACK (panel_applet_container_plug_removed),
+ container);
+
+ gtk_container_add (GTK_CONTAINER (container), container->priv->socket);
+ gtk_widget_show (container->priv->socket);
+ } else {
+ GtkWidget *applet;
+
+ applet = panel_applets_manager_get_applet_widget (container->priv->iid, container->priv->uid);
+
+ gtk_container_add (GTK_CONTAINER (container), applet);
+ }
}
static void
@@ -134,6 +149,11 @@ panel_applet_container_dispose (GObject *object)
container->priv->bus_name = NULL;
}
+ if (container->priv->iid) {
+ g_free (container->priv->iid);
+ container->priv->iid = NULL;
+ }
+
if (container->priv->name_watcher_id > 0) {
g_bus_unwatch_name (container->priv->name_watcher_id);
container->priv->name_watcher_id = 0;
@@ -339,6 +359,8 @@ on_proxy_appeared (GObject *source_object,
g_simple_async_result_complete (result);
g_object_unref (result);
+ panel_applet_container_setup (container);
+
if (container->priv->xid > 0) {
gtk_socket_add_id (GTK_SOCKET (container->priv->socket),
container->priv->xid);
@@ -486,6 +508,7 @@ panel_applet_container_get_applet (PanelAppletContainer *container,
bus_name = g_strdup_printf (PANEL_APPLET_BUS_NAME, factory_id);
+ container->priv->iid = g_strdup (iid);
container->priv->name_watcher_id =
g_bus_watch_name (G_BUS_TYPE_SESSION,
bus_name,
diff --git a/libpanel-applet/panel-applet.c b/libpanel-applet/panel-applet.c
index e4e6282..c6d2f4e 100644
--- a/libpanel-applet/panel-applet.c
+++ b/libpanel-applet/panel-applet.c
@@ -1033,13 +1033,19 @@ panel_applet_can_focus (GtkWidget *widget)
/* Taken from libbonoboui/bonobo/bonobo-plug.c */
static gboolean
-panel_applet_button_event (GtkWidget *widget,
- GdkEventButton *event)
+panel_applet_button_event (PanelApplet *applet,
+ GdkEventButton *event)
{
+ GtkWidget *widget;
GdkWindow *window;
GdkWindow *socket_window;
XEvent xevent;
+ if (!applet->priv->out_of_process)
+ return FALSE;
+
+ widget = applet->priv->plug;
+
if (!gtk_widget_is_toplevel (widget))
return FALSE;
@@ -1112,7 +1118,7 @@ panel_applet_button_press (GtkWidget *widget,
return TRUE;
}
- return panel_applet_button_event (applet->priv->plug, event);
+ return panel_applet_button_event (applet, event);
}
static gboolean
@@ -1121,7 +1127,7 @@ panel_applet_button_release (GtkWidget *widget,
{
PanelApplet *applet = PANEL_APPLET (widget);
- return panel_applet_button_event (applet->priv->plug, event);
+ return panel_applet_button_event (applet, event);
}
static gboolean
@@ -1847,6 +1853,9 @@ panel_applet_constructor (GType type,
construct_properties);
applet = PANEL_APPLET (object);
+ if (!applet->priv->out_of_process)
+ return object;
+
applet->priv->plug = gtk_plug_new (0);
g_signal_connect_swapped (G_OBJECT (applet->priv->plug), "embedded",
@@ -2447,6 +2456,9 @@ guint32
panel_applet_get_xid (PanelApplet *applet,
GdkScreen *screen)
{
+ if (applet->priv->out_of_process == FALSE)
+ return 0;
+
gtk_window_set_screen (GTK_WINDOW (applet->priv->plug), screen);
gtk_widget_show (applet->priv->plug);
@@ -2463,5 +2475,14 @@ G_MODULE_EXPORT GtkWidget *
panel_applet_get_applet_widget (const gchar *factory_id,
guint uid)
{
- return panel_applet_factory_get_applet_widget (factory_id, uid);
+ GtkWidget *widget;
+
+ widget = panel_applet_factory_get_applet_widget (factory_id, uid);
+ if (!widget) {
+ return NULL;
+ }
+
+ panel_applet_setup (PANEL_APPLET (widget));
+
+ return widget;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]