[Xfce4-commits] <xfce4-panel:devel> Various fixes to make the verve and weather plugin work.
Nick Schermer
nick at xfce.org
Tue Aug 11 20:32:29 CEST 2009
Updating branch refs/heads/devel
to f13550e7427ac28eed2d3f34729737715b1bed52 (commit)
from a4b5b5d4b6c230b7b9c3e08711e63dd98644ffa7 (commit)
commit f13550e7427ac28eed2d3f34729737715b1bed52
Author: Nick Schermer <nick at xfce.org>
Date: Sun May 24 11:38:20 2009 +0200
Various fixes to make the verve and weather plugin work.
Implement xfce_panel_plugin_focus_widget().
Implement xfce_panel_plugin_block_autohide(). This is a replacement
for xfce_panel_plugin_set_panel_hidden() which describes the purpose
of the function better.
Re-add window autohide blocking.
Send the button press and release signals to the parent handler if
they exist in panel-window.
Some cleanups and temporarily disabled the XFCE_DISABLE_DEPRECATED
check in xfce-panel-macros.h so plugins can be compiled with
debugging.
libxfce4panel/xfce-panel-macros.h | 10 ++-
libxfce4panel/xfce-panel-plugin-provider.h | 3 +-
libxfce4panel/xfce-panel-plugin.c | 85 ++++++++++++++++++++++++----
libxfce4panel/xfce-panel-plugin.h | 6 ++
panel/panel-application.c | 12 ++++
panel/panel-window.c | 51 +++++++++++++----
6 files changed, 139 insertions(+), 28 deletions(-)
diff --git a/libxfce4panel/xfce-panel-macros.h b/libxfce4panel/xfce-panel-macros.h
index d5c23e4..84482c2 100644
--- a/libxfce4panel/xfce-panel-macros.h
+++ b/libxfce4panel/xfce-panel-macros.h
@@ -66,10 +66,14 @@ G_BEGIN_DECLS
#endif
/* make api compatible with 4.4 panel */
-#ifndef XFCE_DISABLE_DEPRECATED
+/* #ifndef XFCE_DISABLE_DEPRECATED */
/* panel plugin functio for the id, probably not used by anyone */
-#define xfce_panel_plugin_get_id(plugin) (g_strdup_printf ("%d", xfce_panel_plugin_get_unique_id (XFCE_PANEL_PLUGIN (plugin))))
+#define xfce_panel_plugin_get_id(plugin) (g_strdup_printf ("%d", \
+ xfce_panel_plugin_get_unique_id (XFCE_PANEL_PLUGIN (plugin))))
+
+#define xfce_panel_plugin_set_panel_hidden(plugin,hidden) \
+ xfce_panel_plugin_block_autohide (plugin, !hidden)
/* convenience functions (deprecated) */
#define xfce_create_panel_button xfce_panel_create_button
@@ -101,7 +105,7 @@ G_BEGIN_DECLS
#define _panel_return_if_fail(expr) panel_return_if_fail (expr)
#define _panel_return_val_if_fail(expr, val) panel_return_val_if_fail (expr, (val))
-#endif /* !XFCE_DISABLE_DEPRECATED */
+/* #endif *//* !XFCE_DISABLE_DEPRECATED */
G_END_DECLS
diff --git a/libxfce4panel/xfce-panel-plugin-provider.h b/libxfce4panel/xfce-panel-plugin-provider.h
index b497705..d75be30 100644
--- a/libxfce4panel/xfce-panel-plugin-provider.h
+++ b/libxfce4panel/xfce-panel-plugin-provider.h
@@ -85,7 +85,8 @@ enum _XfcePanelPluginProviderSignal
PROVIDER_SIGNAL_PANEL_RESTART,
PROVIDER_SIGNAL_PANEL_ABOUT,
PROVIDER_SIGNAL_SHOW_CONFIGURE,
- PROVIDER_SIGNAL_SHOW_ABOUT
+ PROVIDER_SIGNAL_SHOW_ABOUT,
+ PROVIDER_SIGNAL_FOCUS_PLUGIN
};
diff --git a/libxfce4panel/xfce-panel-plugin.c b/libxfce4panel/xfce-panel-plugin.c
index 30b9170..a19a1cd 100644
--- a/libxfce4panel/xfce-panel-plugin.c
+++ b/libxfce4panel/xfce-panel-plugin.c
@@ -111,7 +111,8 @@ typedef enum
PLUGIN_FLAG_DISPOSED = 1 << 0,
PLUGIN_FLAG_CONSTRUCTED = 1 << 1,
PLUGIN_FLAG_SHOW_CONFIGURE = 1 << 2,
- PLUGIN_FLAG_SHOW_ABOUT = 1 << 3
+ PLUGIN_FLAG_SHOW_ABOUT = 1 << 3,
+ PLUGIN_FLAG_BLOCK_AUTOHIDE = 1 << 4
}
PluginFlags;
@@ -136,10 +137,10 @@ struct _XfcePanelPluginPrivate
GtkMenu *menu;
/* menu block counter */
- guint menu_blocked;
+ gint menu_blocked;
- /* registered menu counter */
- guint registered_menus;
+ /* autohide block counter */
+ gint panel_lock;
};
@@ -457,7 +458,7 @@ xfce_panel_plugin_init (XfcePanelPlugin *plugin)
plugin->priv->screen_position = XFCE_SCREEN_POSITION_NONE;
plugin->priv->menu = NULL;
plugin->priv->menu_blocked = 0;
- plugin->priv->registered_menus = 0;
+ plugin->priv->panel_lock = 0;
plugin->priv->flags = 0;
/* hide the event box window to make the plugin transparent */
@@ -948,20 +949,20 @@ xfce_panel_plugin_unregister_menu (GtkMenu *menu,
XfcePanelPlugin *plugin)
{
panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
- panel_return_if_fail (plugin->priv->registered_menus > 0);
+ panel_return_if_fail (plugin->priv->panel_lock > 0);
panel_return_if_fail (GTK_IS_MENU (menu));
- if (G_LIKELY (plugin->priv->registered_menus > 0))
+ if (G_LIKELY (plugin->priv->panel_lock > 0))
{
/* disconnect this signal */
g_signal_handlers_disconnect_by_func (G_OBJECT (menu),
G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
/* decrease the counter */
- plugin->priv->registered_menus--;
+ plugin->priv->panel_lock--;
/* emit signal to unlock the panel */
- if (G_LIKELY (plugin->priv->registered_menus == 0))
+ if (plugin->priv->panel_lock == 0)
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_UNLOCK_PANEL);
}
@@ -1244,7 +1245,8 @@ xfce_panel_plugin_get_size (XfcePanelPlugin *plugin)
{
g_return_val_if_fail (XFCE_IS_PANEL_PLUGIN (plugin), -1);
- return plugin->priv->size;
+ /* always return a 'positive' size that makes sence */
+ return MAX (16, plugin->priv->size);
}
@@ -1504,13 +1506,13 @@ xfce_panel_plugin_register_menu (XfcePanelPlugin *plugin,
g_return_if_fail (GTK_IS_MENU (menu));
/* increase the counter */
- plugin->priv->registered_menus++;
+ plugin->priv->panel_lock++;
/* connect signal to menu to decrease counter */
g_signal_connect (G_OBJECT (menu), "deactivate", G_CALLBACK (xfce_panel_plugin_unregister_menu), plugin);
/* tell panel it needs to lock */
- if (G_LIKELY (plugin->priv->registered_menus == 1))
+ if (plugin->priv->panel_lock == 1)
xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
PROVIDER_SIGNAL_LOCK_PANEL);
}
@@ -1699,6 +1701,65 @@ xfce_panel_plugin_position_menu (GtkMenu *menu,
+PANEL_SYMBOL_EXPORT void
+xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin,
+ GtkWidget *widget)
+{
+ g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+ g_return_if_fail (GTK_IS_WIDGET (widget));
+
+ /* focus the panel window */
+ xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+ PROVIDER_SIGNAL_FOCUS_PLUGIN);
+
+ /* let the widget grab focus */
+ gtk_widget_grab_focus (widget);
+}
+
+
+
+PANEL_SYMBOL_EXPORT void
+xfce_panel_plugin_block_autohide (XfcePanelPlugin *plugin,
+ gboolean blocked)
+{
+ g_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
+
+ /* leave when requesting the same block state */
+ if (PANEL_HAS_FLAG (plugin->priv->flags, PLUGIN_FLAG_BLOCK_AUTOHIDE) == blocked)
+ return;
+
+ if (blocked)
+ {
+ /* increase the counter */
+ panel_return_if_fail (plugin->priv->panel_lock >= 0);
+ plugin->priv->panel_lock++;
+
+ /* remember this function blocked the panel */
+ PANEL_SET_FLAG (plugin->priv->flags, PLUGIN_FLAG_BLOCK_AUTOHIDE);
+
+ /* tell panel it needs to lock */
+ if (plugin->priv->panel_lock == 1)
+ xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+ PROVIDER_SIGNAL_LOCK_PANEL);
+ }
+ else
+ {
+ /* decrease the counter */
+ panel_return_if_fail (plugin->priv->panel_lock > 0);
+ plugin->priv->panel_lock--;
+
+ /* unset the flag */
+ PANEL_UNSET_FLAG (plugin->priv->flags, PLUGIN_FLAG_BLOCK_AUTOHIDE);
+
+ /* tell panel it needs to unlock */
+ if (plugin->priv->panel_lock == 0)
+ xfce_panel_plugin_provider_emit_signal (XFCE_PANEL_PLUGIN_PROVIDER (plugin),
+ PROVIDER_SIGNAL_UNLOCK_PANEL);
+ }
+}
+
+
+
/**
* xfce_panel_plugin_lookup_rc_file:
* @plugin : an #XfcePanelPlugin.
diff --git a/libxfce4panel/xfce-panel-plugin.h b/libxfce4panel/xfce-panel-plugin.h
index 2bb9bff..45a3871 100644
--- a/libxfce4panel/xfce-panel-plugin.h
+++ b/libxfce4panel/xfce-panel-plugin.h
@@ -145,6 +145,12 @@ void xfce_panel_plugin_position_menu (GtkMenu *m
gboolean *push_in,
gpointer panel_plugin);
+void xfce_panel_plugin_focus_widget (XfcePanelPlugin *plugin,
+ GtkWidget *widget);
+
+void xfce_panel_plugin_block_autohide (XfcePanelPlugin *plugin,
+ gboolean blocked);
+
gchar *xfce_panel_plugin_lookup_rc_file (XfcePanelPlugin *plugin) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
gchar *xfce_panel_plugin_save_location (XfcePanelPlugin *plugin,
diff --git a/panel/panel-application.c b/panel/panel-application.c
index 15f6260..edb3b95 100644
--- a/panel/panel-application.c
+++ b/panel/panel-application.c
@@ -441,6 +441,7 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
/* get the panel of the plugin */
window = PANEL_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (provider)));
+ panel_return_if_fail (PANEL_IS_WINDOW (window));
/* handle the signal emitted from the plugin provider */
switch (provider_signal)
@@ -510,7 +511,18 @@ panel_application_plugin_provider_signal (XfcePanelPluginProvider *provide
panel_dialogs_show_about ();
break;
+ case PROVIDER_SIGNAL_FOCUS_PLUGIN:
+ /* focus the panel window */
+ gtk_window_present_with_time (GTK_WINDOW (window), GDK_CURRENT_TIME);
+ break;
+
+ case PROVIDER_SIGNAL_SHOW_CONFIGURE:
+ case PROVIDER_SIGNAL_SHOW_ABOUT:
+ /* signals we can ignore, only for external plugins */
+ break;
+
default:
+ g_critical ("Received unknown provider signal %d", provider_signal);
break;
}
}
diff --git a/panel/panel-window.c b/panel/panel-window.c
index 09aaedf..f0840d6 100644
--- a/panel/panel-window.c
+++ b/panel/panel-window.c
@@ -139,7 +139,8 @@ enum _AutohideState
AUTOHIDE_POPDOWN, /* visible, but hide timeout is running */
AUTOHIDE_POPDOWN_SLOW, /* same as popdown, but timeout is 4x longer */
AUTOHIDE_HIDDEN, /* invisible */
- AUTOHIDE_POPUP /* invisible, but show timeout is running */
+ AUTOHIDE_POPUP, /* invisible, but show timeout is running */
+ AUTOHIDE_BLOCKED /* autohide is enabled, but blocked */
};
enum _SnapPosition
@@ -715,7 +716,8 @@ panel_window_leave_notify_event (GtkWidget *widget,
/* queue a new autohide time if needed */
if (event->detail != GDK_NOTIFY_INFERIOR
- && window->autohide_state != AUTOHIDE_DISABLED)
+ && window->autohide_state != AUTOHIDE_DISABLED
+ && window->autohide_state != AUTOHIDE_BLOCKED)
panel_window_autohide_queue (window, AUTOHIDE_POPDOWN);
return (*GTK_WIDGET_CLASS (panel_window_parent_class)->leave_notify_event) (widget, event);
@@ -797,7 +799,7 @@ panel_window_button_press_event (GtkWidget *widget,
/* leave if the event is not for this window */
if (event->window != widget->window)
- return FALSE;
+ goto end;
/* get the modifiers */
modifiers = event->state & gtk_accelerator_get_default_mod_mask ();
@@ -842,7 +844,11 @@ panel_window_button_press_event (GtkWidget *widget,
return TRUE;
}
- return FALSE;
+end:
+ if (GTK_WIDGET_CLASS (panel_window_parent_class)->button_release_event != NULL)
+ return (*GTK_WIDGET_CLASS (panel_window_parent_class)->button_release_event) (widget, event);
+ else
+ return FALSE;
}
@@ -867,7 +873,10 @@ panel_window_button_release_event (GtkWidget *widget,
return TRUE;
}
- return FALSE;
+ if (GTK_WIDGET_CLASS (panel_window_parent_class)->button_release_event != NULL)
+ return (*GTK_WIDGET_CLASS (panel_window_parent_class)->button_release_event) (widget, event);
+ else
+ return FALSE;
}
@@ -876,7 +885,6 @@ static void
panel_window_grab_notify (GtkWidget *widget,
gboolean was_grabbed)
{
-#if 0
PanelWindow *window = PANEL_WINDOW (widget);
/* avoid hiding the panel when the window is grabbed. this
@@ -886,7 +894,6 @@ panel_window_grab_notify (GtkWidget *widget,
panel_window_thaw_autohide (window);
else
panel_window_freeze_autohide (window);
-#endif
}
@@ -1629,6 +1636,7 @@ panel_window_autohide_timeout (gpointer user_data)
PanelWindow *window = PANEL_WINDOW (user_data);
panel_return_val_if_fail (window->autohide_state != AUTOHIDE_DISABLED, FALSE);
+ panel_return_val_if_fail (window->autohide_state != AUTOHIDE_BLOCKED, FALSE);
/* update the status */
if (window->autohide_state == AUTOHIDE_POPDOWN
@@ -1673,7 +1681,7 @@ panel_window_autohide_queue (PanelWindow *window,
|| window->snap_position != SNAP_POSITION_NONE)
panel_window_screen_layout_changed (window->screen, window);
- if (new_state == AUTOHIDE_DISABLED)
+ if (new_state == AUTOHIDE_DISABLED || new_state == AUTOHIDE_BLOCKED)
{
/* queue a resize to make sure the panel is visible */
gtk_widget_queue_resize (GTK_WIDGET (window));
@@ -1768,18 +1776,21 @@ panel_window_set_autohide (PanelWindow *window,
/* show the window */
window->autohide_window = popup;
gtk_widget_show (popup);
+
+ /* start autohide */
+ panel_window_autohide_queue (window,
+ window->autohide_block == 0 ? AUTOHIDE_POPDOWN_SLOW : AUTOHIDE_BLOCKED);
}
else if (window->autohide_window != NULL)
{
+ /* stop autohide */
+ panel_window_autohide_queue (window, AUTOHIDE_DISABLED);
+
/* destroy the autohide window */
panel_return_if_fail (GTK_IS_WINDOW (window->autohide_window));
gtk_widget_destroy (window->autohide_window);
window->autohide_window = NULL;
}
-
- /* start or stop autohiding */
- panel_window_autohide_queue (window,
- autohide ? AUTOHIDE_POPDOWN_SLOW : AUTOHIDE_DISABLED);
}
@@ -2038,6 +2049,14 @@ void
panel_window_freeze_autohide (PanelWindow *window)
{
panel_return_if_fail (PANEL_IS_WINDOW (window));
+ panel_return_if_fail (window->autohide_block >= 0);
+
+ /* increase autohide block counter */
+ window->autohide_block++;
+
+ if (window->autohide_block == 1
+ && window->autohide_state != AUTOHIDE_DISABLED)
+ panel_window_autohide_queue (window, AUTOHIDE_BLOCKED);
}
@@ -2046,4 +2065,12 @@ void
panel_window_thaw_autohide (PanelWindow *window)
{
panel_return_if_fail (PANEL_IS_WINDOW (window));
+ panel_return_if_fail (window->autohide_block > 0);
+
+ /* decrease autohide block counter */
+ window->autohide_block--;
+
+ if (window->autohide_block == 0
+ && window->autohide_state != AUTOHIDE_DISABLED)
+ panel_window_autohide_queue (window, AUTOHIDE_POPDOWN);
}
More information about the Xfce4-commits
mailing list