[Xfce4-commits] r24241 - in xfce4-panel/branches/4_5_nick: libxfce4panel panel
Nick Schermer
nick at xfce.org
Tue Jan 2 18:06:13 CET 2007
Author: nick
Date: 2007-01-02 17:06:12 +0000 (Tue, 02 Jan 2007)
New Revision: 24241
Modified:
xfce4-panel/branches/4_5_nick/libxfce4panel/xfce-panel-external-item.c
xfce4-panel/branches/4_5_nick/panel/panel-properties.c
Log:
Plugin restart code from trunk.
Extra debug message when struts are finished.
Modified: xfce4-panel/branches/4_5_nick/libxfce4panel/xfce-panel-external-item.c
===================================================================
--- xfce4-panel/branches/4_5_nick/libxfce4panel/xfce-panel-external-item.c 2007-01-02 16:01:26 UTC (rev 24240)
+++ xfce4-panel/branches/4_5_nick/libxfce4panel/xfce-panel-external-item.c 2007-01-02 17:06:12 UTC (rev 24241)
@@ -37,9 +37,9 @@
#define XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), XFCE_TYPE_EXTERNAL_PANEL_ITEM, \
XfceExternalPanelItemPrivate))
-
+
typedef struct _XfceExternalPanelItemPrivate XfceExternalPanelItemPrivate;
struct _XfceExternalPanelItemPrivate
@@ -50,14 +50,17 @@
gint size;
XfceScreenPosition screen_position;
- guint expand : 1;
+ guint expand : 1;
/* detect problems */
guint to_be_removed : 1;
+ guint restart : 1;
+
+ gchar *file;
};
-
-
+
+
static void xfce_external_panel_item_interface_init (gpointer g_iface,
gpointer data);
static const gchar *xfce_external_panel_item_get_name (XfcePanelItem *item);
@@ -82,17 +85,19 @@
static void _item_construct (XfceExternalPanelItem *item);
static void _item_setup (XfceExternalPanelItem *item,
const gchar *file);
-
-
+static void _item_screen_changed (XfceExternalPanelItem *item,
+ GdkScreen *screen);
+
+
/* type definition and initialization */
G_DEFINE_TYPE_EXTENDED (XfceExternalPanelItem, xfce_external_panel_item,
GTK_TYPE_SOCKET, 0,
G_IMPLEMENT_INTERFACE (XFCE_TYPE_PANEL_ITEM,
xfce_external_panel_item_interface_init))
-
-
+
+
static void
xfce_external_panel_item_interface_init (gpointer g_iface,
gpointer data)
@@ -111,9 +116,9 @@
iface->remove = xfce_external_panel_item_remove;
iface->configure = xfce_external_panel_item_configure;
}
-
-
+
+
static void
xfce_external_panel_item_class_init (XfceExternalPanelItemClass *klass)
{
@@ -130,9 +135,9 @@
widget_class->button_press_event =
xfce_external_panel_item_button_press_event;
}
-
-
+
+
static void
xfce_external_panel_item_init (XfceExternalPanelItem *item)
{
@@ -147,10 +152,12 @@
priv->screen_position = XFCE_SCREEN_POSITION_NONE;
priv->expand = FALSE;
priv->to_be_removed = FALSE;
+ priv->restart = FALSE;
+ priv->file = NULL;
}
-
+
static void
xfce_external_panel_item_finalize (GObject *object)
{
@@ -168,12 +175,13 @@
g_free (priv->name);
g_free (priv->id);
g_free (priv->display_name);
+ g_free (priv->file);
G_OBJECT_CLASS (xfce_external_panel_item_parent_class)->finalize (object);
}
-
+
static gboolean
xfce_external_panel_item_button_press_event (GtkWidget *widget,
GdkEventButton *ev)
@@ -199,8 +207,8 @@
return FALSE;
}
-
+
static const gchar *
xfce_external_panel_item_get_name (XfcePanelItem *item)
{
@@ -213,9 +221,9 @@
return priv->name;
}
-
-
+
+
static const gchar *
xfce_external_panel_item_get_id (XfcePanelItem *item)
{
@@ -228,9 +236,9 @@
return priv->id;
}
-
-
+
+
static const gchar *
xfce_external_panel_item_get_display_name (XfcePanelItem *item)
{
@@ -243,9 +251,9 @@
return priv->display_name;
}
-
-
+
+
gboolean
xfce_external_panel_item_get_expand (XfcePanelItem *item)
{
@@ -258,9 +266,9 @@
return priv->expand;
}
-
-
+
+
static void
xfce_external_panel_item_free_data (XfcePanelItem *item)
{
@@ -278,9 +286,9 @@
plug_window),
XFCE_PANEL_PLUGIN_FREE_DATA, 0);
}
-
-
+
+
static void
xfce_external_panel_item_save (XfcePanelItem *item)
{
@@ -294,9 +302,9 @@
plug_window),
XFCE_PANEL_PLUGIN_SAVE, 0);
}
-
-
+
+
static void
xfce_external_panel_item_set_size (XfcePanelItem *item,
gint size)
@@ -318,9 +326,9 @@
XFCE_PANEL_PLUGIN_SIZE, size);
}
}
-
-
+
+
static void
xfce_external_panel_item_set_screen_position (XfcePanelItem *item,
XfceScreenPosition position)
@@ -340,9 +348,9 @@
XFCE_PANEL_PLUGIN_SCREEN_POSITION,
position);
}
-
-
+
+
static void
delayed_set_sensitive (XfcePanelItem *item,
gpointer sensitive)
@@ -353,9 +361,9 @@
G_CALLBACK(delayed_set_sensitive),
sensitive);
}
-
-
+
+
static void
xfce_external_panel_item_set_sensitive (XfcePanelItem *item,
gboolean sensitive)
@@ -383,8 +391,8 @@
}
}
-
+
static void
xfce_external_panel_item_remove (XfcePanelItem *item)
{
@@ -400,9 +408,9 @@
plug_window),
XFCE_PANEL_PLUGIN_REMOVE, 0);
}
-
-
+
+
static void
delayed_configure(XfcePanelItem *item)
{
@@ -411,9 +419,9 @@
g_signal_handlers_disconnect_by_func (G_OBJECT (item),
G_CALLBACK (delayed_configure), NULL);
}
-
-
+
+
static void
xfce_external_panel_item_configure (XfcePanelItem * item)
{
@@ -437,9 +445,9 @@
G_CALLBACK(delayed_configure), NULL);
}
}
-
+
static gboolean
_item_event_received (XfceExternalPanelItem *item,
GdkEventClient *ev)
@@ -495,9 +503,9 @@
return FALSE;
}
-
-
+
+
static void
_item_construct (XfceExternalPanelItem *item)
{
@@ -507,10 +515,39 @@
GDK_WINDOW_XID (socket->plug_window),
XFCE_PANEL_PLUGIN_CONSTRUCT, 0);
}
-
-
+
+
static void
+_item_screen_changed (XfceExternalPanelItem *item,
+ GdkScreen *screen)
+{
+ XfceExternalPanelItemPrivate *priv;
+
+ priv = XFCE_EXTERNAL_PANEL_ITEM_GET_PRIVATE (XFCE_EXTERNAL_PANEL_ITEM (item));
+
+ screen = gtk_widget_get_screen (GTK_WIDGET (item));
+ g_message ("%s: screen changed: %d\n",
+ xfce_external_panel_item_get_display_name (XFCE_PANEL_ITEM (item)),
+ gdk_screen_get_number (screen));
+
+ if (GTK_SOCKET(item)->plug_window)
+ {
+ xfce_panel_plugin_message_send (GTK_WIDGET (item)->window,
+ GDK_WINDOW_XID (GTK_SOCKET (item)->plug_window),
+ XFCE_PANEL_PLUGIN_SIZE, priv->size);
+ }
+ else
+ {
+ g_message ("No valid plug window.");
+ priv->restart = TRUE;
+ _item_setup (item, priv->file);
+ }
+}
+
+
+
+static void
_item_setup (XfceExternalPanelItem *item,
const gchar *file)
{
@@ -539,11 +576,14 @@
argv[6] = g_strdup_printf ("screen_position=%d", priv->screen_position);
argv[7] = NULL;
- g_signal_connect (G_OBJECT (item), "plug-added",
- G_CALLBACK (_item_construct), NULL);
+ if (G_LIKELY (priv->restart == FALSE))
+ {
+ g_signal_connect (G_OBJECT (item), "plug-added",
+ G_CALLBACK (_item_construct), NULL);
- g_signal_connect (G_OBJECT (item), "client-event",
- G_CALLBACK (_item_event_received), NULL);
+ g_signal_connect (G_OBJECT (item), "client-event",
+ G_CALLBACK (_item_event_received), NULL);
+ }
gscreen = gtk_widget_get_screen (GTK_WIDGET (item));
gdkdisplay_name = gdk_screen_make_display_name (gscreen);
@@ -564,14 +604,19 @@
_exit (1);
default:
/* parent: do nothing */;
+ if (G_LIKELY (priv->restart == FALSE))
+ {
+ g_signal_connect (G_OBJECT (item), "screen-changed",
+ G_CALLBACK (_item_screen_changed), NULL);
+ }
}
g_free (gdkdisplay_name);
g_strfreev (argv);
}
-
+
/**
* xfce_external_panel_item_new
* @name : plugin name
@@ -606,6 +651,7 @@
priv->display_name = g_strdup (display_name);
priv->size = size;
priv->screen_position = position;
+ priv->file = g_strdup (file);
g_signal_connect_after (G_OBJECT (item), "realize", G_CALLBACK (_item_setup),
(gpointer) file);
Modified: xfce4-panel/branches/4_5_nick/panel/panel-properties.c
===================================================================
--- xfce4-panel/branches/4_5_nick/panel/panel-properties.c 2007-01-02 16:01:26 UTC (rev 24240)
+++ xfce4-panel/branches/4_5_nick/panel/panel-properties.c 2007-01-02 17:06:12 UTC (rev 24241)
@@ -375,6 +375,8 @@
gdk_error_trap_pop ();
}
+
+ DBG ("all struts are checked and updated");
}
static gboolean
More information about the Xfce4-commits
mailing list