Author: nick
Date: 2007-09-10 16:01:26 +0000 (Mon, 10 Sep 2007)
New Revision: 26067
Modified:
xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.c
xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.h
xfce4-panel/trunk/plugins/systray/xfce-tray-manager.c
xfce4-panel/trunk/plugins/systray/xfce-tray-manager.h
xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.c
xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.h
xfce4-panel/trunk/plugins/systray/xfce-tray-widget.c
xfce4-panel/trunk/plugins/systray/xfce-tray-widget.h
Log:
* Slightly delay adding icons to the tray (250ms). This
should fix the invisible icons problem. I've no idea
why this happens, because everything is visible, mapped
and realized, but since it happens about 50% of the time,
it looks like some sort of race condition (bug appeard after
improving the tray redraw code).
* Cleanup trailing spaces.
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.c
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.c 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.c 2007-09-10
16:01:26 UTC (rev 26067)
@@ -14,7 +14,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -52,7 +52,7 @@
/* prototypes */
static gchar *xfce_tray_dialogs_camel_case (const gchar
*text);
-static GdkPixbuf *xfce_tray_dialogs_icon (GtkIconTheme
*icon_theme,
+static GdkPixbuf *xfce_tray_dialogs_icon (GtkIconTheme
*icon_theme,
const gchar
*name);
static void xfce_tray_dialogs_show_frame_toggled (GtkToggleButton
*button,
XfceTrayPlugin
*plugin);
@@ -60,8 +60,8 @@
gchar
*path,
GtkWidget
*treeview);
static void xfce_tray_dialogs_free_store (GtkListStore
*store);
-static void xfce_tray_dialogs_configure_response (GtkWidget
*dialog,
- gint
response,
+static void xfce_tray_dialogs_configure_response (GtkWidget
*dialog,
+ gint
response,
XfceTrayPlugin
*plugin);
@@ -112,60 +112,60 @@
GdkPixbuf *icon;
guint i;
gchar *first_occ;
- const gchar *p, *fallback[][2] =
+ const gchar *p, *fallback[][2] =
{
{ "xfce-mcs-manager", "input-mouse" },
{ "bluetooth-applet", "stock_bluetooth" }
};
-
+
/* return null on no name */
if (G_UNLIKELY (name == NULL))
return NULL;
-
+
/* try to load the icon from the theme */
icon = gtk_icon_theme_load_icon (icon_theme, name,
XFCE_TRAY_DIALOG_ICON_SIZE, 0, NULL);
if (G_LIKELY (icon))
return icon;
-
+
/* try the first part when the name contains a space */
p = g_utf8_strchr (name, -1, ' ');
if (p)
{
/* get the string before the first occurrence */
first_occ = g_strndup (name, p - name);
-
+
/* try to load the icon from the theme */
icon = gtk_icon_theme_load_icon (icon_theme, first_occ,
XFCE_TRAY_DIALOG_ICON_SIZE, 0, NULL);
-
+
/* cleanup */
g_free (first_occ);
-
+
if (icon)
return icon;
}
-
+
/* find and return a fall-back icon */
for (i = 0; i < G_N_ELEMENTS (fallback); i++)
if (strcmp (name, fallback[i][0]) == 0)
return gtk_icon_theme_load_icon (icon_theme, fallback[i][1],
XFCE_TRAY_DIALOG_ICON_SIZE, 0, NULL);
-
+
return NULL;
}
-static void
+static void
xfce_tray_dialogs_show_frame_toggled (GtkToggleButton *button,
XfceTrayPlugin *plugin)
{
gboolean active;
-
+
/* get state */
active = gtk_toggle_button_get_active (button);
-
+
/* set frame shadow */
gtk_frame_set_shadow_type (GTK_FRAME (plugin->frame), active ?
GTK_SHADOW_IN : GTK_SHADOW_NONE);
-
+
/* save */
plugin->show_frame = active;
}
@@ -181,27 +181,27 @@
GtkTreeIter iter;
XfceTrayApplication *application;
XfceTrayPlugin *plugin;
-
+
/* get the tree model */
model = gtk_tree_view_get_model (GTK_TREE_VIEW (treeview));
-
+
/* get the tree iter */
if (G_LIKELY (gtk_tree_model_get_iter_from_string (model, &iter, path)))
{
/* get the application data */
gtk_tree_model_get (model, &iter, APPLICATION_DATA, &application, -1);
-
+
/* get tray plugin */
plugin = g_object_get_data (G_OBJECT (treeview),
I_("xfce-tray-plugin"));
-
+
if (G_LIKELY (application && plugin))
{
/* update the manager */
xfce_tray_manager_application_update (plugin->manager,
application->name, !application->hidden);
-
+
/* sort and update the tray widget */
xfce_tray_widget_sort (XFCE_TRAY_WIDGET (plugin->tray));
-
+
/* set the new list value */
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
APPLICATION_HIDDEN, application->hidden, -1);
}
@@ -215,7 +215,7 @@
{
/* clear store */
gtk_list_store_clear (store);
-
+
/* release the store */
g_object_unref (G_OBJECT (store));
}
@@ -223,20 +223,20 @@
static void
-xfce_tray_dialogs_configure_response (GtkWidget *dialog,
- gint response,
+xfce_tray_dialogs_configure_response (GtkWidget *dialog,
+ gint response,
XfceTrayPlugin *plugin)
{
/* destroy dialog */
gtk_widget_destroy (dialog);
-
+
/* unblock plugin menu */
xfce_panel_plugin_unblock_menu (plugin->panel_plugin);
}
-void
+void
xfce_tray_dialogs_configure (XfceTrayPlugin *plugin)
{
GtkWidget *dialog, *dialog_vbox;
@@ -251,10 +251,10 @@
gchar *name;
GtkIconTheme *icon_theme;
GdkPixbuf *pixbuf;
-
+
/* lock plugin menu */
xfce_panel_plugin_block_menu (plugin->panel_plugin);
-
+
/* create dialog */
dialog = xfce_titled_dialog_new_with_buttons (_("System Tray"),
NULL,
@@ -267,38 +267,38 @@
gtk_window_set_default_size (GTK_WINDOW (dialog), 280, 350);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK
(xfce_tray_dialogs_configure_response), plugin);
-
+
dialog_vbox = GTK_DIALOG (dialog)->vbox;
-
+
/* appearance */
frame = xfce_create_framebox (_("Appearance"), &bin);
gtk_box_pack_start (GTK_BOX (dialog_vbox), frame, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
gtk_widget_show (frame);
-
+
/* show frame */
button = gtk_check_button_new_with_mnemonic (_("Show _frame"));
gtk_container_add (GTK_CONTAINER (bin), button);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
plugin->show_frame);
g_signal_connect (button, "toggled", G_CALLBACK
(xfce_tray_dialogs_show_frame_toggled), plugin);
gtk_widget_show (button);
-
+
/* applications */
frame = xfce_create_framebox (_("Hidden Applications"), &bin);
gtk_box_pack_start (GTK_BOX (dialog_vbox), frame, TRUE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (frame), 4);
gtk_widget_show (frame);
-
+
/* scrolled window */
scroll = gtk_scrolled_window_new (NULL, NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll),
GTK_SHADOW_IN);
gtk_container_add (GTK_CONTAINER (bin), scroll);
gtk_widget_show (scroll);
-
+
/* create list store */
store = gtk_list_store_new (N_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING,
G_TYPE_BOOLEAN, G_TYPE_POINTER);
-
+
/* create treeview */
treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (store));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (treeview), FALSE);
@@ -309,10 +309,10 @@
g_signal_connect_swapped (G_OBJECT (treeview), "destroy", G_CALLBACK
(xfce_tray_dialogs_free_store), store);
gtk_container_add (GTK_CONTAINER (scroll), treeview);
gtk_widget_show (treeview);
-
+
/* connect the plugin to the treeview */
g_object_set_data (G_OBJECT (treeview), I_("xfce-tray-plugin"), plugin);
-
+
/* create column */
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_spacing (column, 2);
@@ -326,59 +326,59 @@
gtk_cell_renderer_set_fixed_size (renderer, XFCE_TRAY_DIALOG_ICON_SIZE,
XFCE_TRAY_DIALOG_ICON_SIZE);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer, "pixbuf",
APPLICATION_ICON, NULL);
-
+
/* renderer for the name */
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_attributes (column, renderer, "text",
APPLICATION_NAME, NULL);
g_object_set (G_OBJECT (renderer), "ellipsize", PANGO_ELLIPSIZE_END, NULL);
-
+
/* renderer for the toggle button */
renderer = gtk_cell_renderer_toggle_new ();
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer, "active",
APPLICATION_HIDDEN, NULL);
g_signal_connect (G_OBJECT (renderer), "toggled",
G_CALLBACK(xfce_tray_dialogs_treeview_toggled), treeview);
-
+
/* get the icon theme */
if (G_LIKELY (gtk_widget_has_screen (dialog)))
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen
(dialog));
else
icon_theme = gtk_icon_theme_get_default ();
-
+
/* get the sorted list of applications */
applications = xfce_tray_manager_application_list (plugin->manager, TRUE);
-
+
/* add all the application to the list */
for (li = applications; li != NULL; li = li->next)
{
application = li->data;
-
+
/* create a camel case name of the application */
name = xfce_tray_dialogs_camel_case (application->name);
-
+
/* append the application */
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
APPLICATION_NAME, name,
APPLICATION_HIDDEN, application->hidden,
APPLICATION_DATA, application, -1);
-
+
/* cleanup */
g_free (name);
-
+
/* get the application icon */
pixbuf = xfce_tray_dialogs_icon (icon_theme, application->name);
-
+
if (pixbuf)
{
/* set the icon */
gtk_list_store_set (store, &iter, APPLICATION_ICON, pixbuf, -1);
-
+
/* release */
g_object_unref (G_OBJECT (pixbuf));
}
}
-
+
/* show the dialog */
gtk_widget_show (dialog);
}
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.h
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.h 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-dialogs.h 2007-09-10
16:01:26 UTC (rev 26067)
@@ -14,7 +14,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
#ifndef __XFCE_TRAY_DIALOGS_H__
#define __XFCE_TRAY_DIALOGS_H__
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-manager.c
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-manager.c 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-manager.c 2007-09-10
16:01:26 UTC (rev 26067)
@@ -124,7 +124,7 @@
/* _net_system_tray_s%d atom */
GdkAtom selection_atom;
-
+
/* list of known and hidden applications */
GSList *applications;
};
@@ -255,12 +255,12 @@
xfce_tray_manager_error_quark (void)
{
static GQuark q = 0;
-
+
if (q == 0)
{
q = g_quark_from_static_string ("xfce-tray-manager-error-quark");
}
-
+
return q;
}
@@ -276,7 +276,7 @@
/* destroy the hash table */
g_hash_table_destroy (manager->sockets);
-
+
if (manager->messages)
{
/* cleanup all pending messages */
@@ -290,7 +290,7 @@
{
/* free all items */
g_slist_foreach (manager->applications, (GFunc)
xfce_tray_manager_application_free, NULL);
-
+
/* free the list */
g_slist_free (manager->applications);
}
@@ -358,7 +358,7 @@
/* let the invisible window monitor property and configuration changes */
gtk_widget_add_events (invisible, GDK_PROPERTY_CHANGE_MASK |
GDK_STRUCTURE_MASK);
-
+
/* get the screen number */
screen_number = gdk_screen_get_number (screen);
@@ -425,7 +425,7 @@
{
/* desktroy the invisible window */
gtk_widget_destroy (invisible);
-
+
/* set an error */
g_set_error (error, XFCE_TRAY_MANAGER_ERROR,
XFCE_TRAY_MANAGER_ERROR_SELECTION_FAILED,
_("Failed to acquire manager selection for screen %d"),
screen_number);
@@ -482,7 +482,7 @@
{
XEvent *xevent = (XEvent *)xev;
XfceTrayManager *manager = XFCE_TRAY_MANAGER (user_data);
-
+
if (xevent->type == ClientMessage)
{
if (xevent->xclient.message_type == manager->opcode_atom
@@ -702,8 +702,8 @@
/* emit signal */
g_signal_emit (manager, xfce_tray_manager_signals[TRAY_ICON_ADDED], 0,
socket);
- /* check if the widget has been attached. if it has not been attached,
- * there's no need to add the socket to the hash table. */
+ /* check if the widget has been attached. if the widget has no
+ toplevel window, we cannot set the socket id. */
if (G_LIKELY (GTK_IS_WINDOW (gtk_widget_get_toplevel (socket))))
{
/* signal to monitor if the client is removed from the socket */
@@ -714,6 +714,9 @@
/* add the socket to the list of known sockets */
g_hash_table_insert (manager->sockets, GUINT_TO_POINTER (*xwindow),
socket);
+
+ /* show the socket */
+ gtk_widget_show (socket);
}
else
{
@@ -735,7 +738,7 @@
/* emit signal that the socket will be removed */
g_signal_emit (manager, xfce_tray_manager_signals[TRAY_ICON_REMOVED], 0,
socket);
-
+
/* get the xwindow */
xwindow = g_object_get_data (G_OBJECT (socket),
I_("xfce-tray-manager-xwindow"));
@@ -809,20 +812,20 @@
gboolean hidden)
{
XfceTrayApplication *application;
-
+
g_return_val_if_fail (XFCE_IS_TRAY_MANAGER (manager), NULL);
g_return_val_if_fail (name, NULL);
-
+
/* create structure */
application = panel_slice_new0 (XfceTrayApplication);
-
+
/* set values */
application->name = g_strdup (name);
application->hidden = hidden;
-
+
/* add to the list */
manager->applications = g_slist_prepend (manager->applications,
application);
-
+
/* return the pointer */
return application;
}
@@ -836,21 +839,21 @@
{
GSList *li;
XfceTrayApplication *application;
-
+
g_return_if_fail (XFCE_IS_TRAY_MANAGER (manager));
g_return_if_fail (name);
-
+
/* walk through the known window names */
for (li = manager->applications; li != NULL; li = li->next)
{
application = li->data;
-
+
/* check if the names match */
if (strcmp (application->name, name) == 0)
{
/* set the new hidden state */
application->hidden = hidden;
-
+
/* stop searching */
break;
}
@@ -865,11 +868,11 @@
{
XfceTrayApplication *app_a = (XfceTrayApplication *)a;
XfceTrayApplication *app_b = (XfceTrayApplication *)b;
-
+
/* sort order when one of the names is null */
if (G_UNLIKELY (app_a->name == NULL || app_b->name == NULL))
return (app_a->name == app_b->name ? 0 : (app_a->name == NULL ? -1 :
1));
-
+
return strcmp (app_a->name, app_b->name);
}
@@ -880,7 +883,7 @@
gboolean sorted)
{
g_return_val_if_fail (XFCE_IS_TRAY_MANAGER (manager), NULL);
-
+
/* sort the list if requested */
if (sorted)
manager->applications = g_slist_sort (manager->applications,
xfce_tray_manager_application_list_compare);
@@ -896,7 +899,7 @@
{
/* free name */
g_free (application->name);
-
+
/* free structure */
panel_slice_free (XfceTrayApplication, application);
}
@@ -909,19 +912,19 @@
{
GSList *li;
XfceTrayApplication *application;
-
+
g_return_val_if_fail (name, NULL);
-
+
/* walk through the known window names */
for (li = manager->applications; li != NULL; li = li->next)
{
application = li->data;
-
+
/* find a matching name and return the pointer */
if (strcmp (application->name, name) == 0)
return application;
}
-
+
/* no match was found, add the application and return the pointer */
return xfce_tray_manager_application_add (manager, name, FALSE);
}
@@ -962,10 +965,10 @@
/* find or create a structure */
application = xfce_tray_manager_application_find (manager,
name);
-
+
/* cleanup */
g_free (name);
-
+
/* set the object data */
g_object_set_data (G_OBJECT (socket),
I_("xfce-tray-manager-application"), application);
}
@@ -982,10 +985,10 @@
xfce_tray_manager_application_get_name (GtkWidget *socket)
{
XfceTrayApplication *application;
-
+
/* get the application data */
application = g_object_get_data (G_OBJECT (socket),
I_("xfce-tray-manager-application"));
-
+
return (application ? application->name : NULL);
}
@@ -995,10 +998,10 @@
xfce_tray_manager_application_get_hidden (GtkWidget *socket)
{
XfceTrayApplication *application;
-
+
/* get the application data */
application = g_object_get_data (G_OBJECT (socket),
I_("xfce-tray-manager-application"));
-
+
return (application ? application->hidden : FALSE);
}
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-manager.h
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-manager.h 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-manager.h 2007-09-10
16:01:26 UTC (rev 26067)
@@ -33,9 +33,9 @@
{
/* the name of the applications */
gchar *name;
-
+
/* whether it should be hidden */
- guint hidden : 1;
+ guint hidden : 1;
};
enum
@@ -62,26 +62,26 @@
gboolean xfce_tray_manager_register (XfceTrayManager
*manager,
GdkScreen
*screen,
GError
**error) G_GNUC_INTERNAL;
-
+
GtkOrientation xfce_tray_manager_get_orientation (XfceTrayManager
*manager) G_GNUC_INTERNAL;
void xfce_tray_manager_set_orientation (XfceTrayManager
*manager,
GtkOrientation
orientation) G_GNUC_INTERNAL;
-
+
XfceTrayApplication *xfce_tray_manager_application_add (XfceTrayManager
*manager,
const gchar
*name,
gboolean
hidden) G_GNUC_INTERNAL;
-
+
void xfce_tray_manager_application_update (XfceTrayManager
*manager,
const gchar
*name,
gboolean
hidden) G_GNUC_INTERNAL;
-
+
GSList *xfce_tray_manager_application_list (XfceTrayManager
*manager,
gboolean
sorted) G_GNUC_MALLOC G_GNUC_INTERNAL;
-
+
const gchar *xfce_tray_manager_application_get_name (GtkWidget
*socket) G_GNUC_INTERNAL;
gboolean xfce_tray_manager_application_get_hidden (GtkWidget
*socket) G_GNUC_INTERNAL;
-
+
#endif /* !__XFCE_TRAY_MANAGER_H__ */
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.c
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.c 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.c 2007-09-10
16:01:26 UTC (rev 26067)
@@ -16,7 +16,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -42,9 +42,9 @@
static gboolean xfce_tray_plugin_check (GdkScreen
*screen);
static GtkArrowType xfce_tray_plugin_button_position
(XfcePanelPlugin *panel_plugin);
static XfceTrayPlugin *xfce_tray_plugin_new
(XfcePanelPlugin *panel_plugin);
-static void xfce_tray_plugin_screen_position_changed
(XfceTrayPlugin *plugin,
+static void xfce_tray_plugin_screen_position_changed
(XfceTrayPlugin *plugin,
XfceScreenPosition position);
-static void xfce_tray_plugin_orientation_changed
(XfceTrayPlugin *plugin,
+static void xfce_tray_plugin_orientation_changed
(XfceTrayPlugin *plugin,
GtkOrientation orientation);
static void xfce_tray_plugin_tray_size_changed
(XfceTrayPlugin *plugin,
gint
size);
@@ -68,16 +68,16 @@
const gchar *message)
{
GtkWidget *dialog;
-
+
/* create a dialog */
dialog = gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, type,
GTK_BUTTONS_CLOSE, _("System Tray"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
"%s.", message);
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_window_set_screen (GTK_WINDOW (dialog), screen);
-
+
/* run the dialog */
gtk_dialog_run (GTK_DIALOG (dialog));
-
+
/* destroy */
gtk_widget_destroy (dialog);
}
@@ -88,16 +88,16 @@
xfce_tray_plugin_check (GdkScreen *screen)
{
gboolean running;
-
-
+
+
/* check if there is already a tray running */
running = xfce_tray_manager_check_running (screen);
-
+
/* message */
if (running)
- xfce_tray_plugin_message (GTK_MESSAGE_INFO, screen,
+ xfce_tray_plugin_message (GTK_MESSAGE_INFO, screen,
_("There is already a system tray running on
this screen"));
-
+
return (!running);
}
@@ -110,12 +110,12 @@
GdkScreen *screen;
GdkRectangle geom;
gint mon, x, y;
-
+
g_return_val_if_fail (GTK_WIDGET_REALIZED (panel_plugin), GTK_ARROW_LEFT);
-
+
/* get the plugin position */
position = xfce_panel_plugin_get_screen_position (panel_plugin);
-
+
/* get the button position */
switch (position)
{
@@ -123,26 +123,26 @@
case XFCE_SCREEN_POSITION_NW_H:
case XFCE_SCREEN_POSITION_SW_H:
return GTK_ARROW_RIGHT;
-
+
/* horizontal east */
case XFCE_SCREEN_POSITION_N:
case XFCE_SCREEN_POSITION_NE_H:
case XFCE_SCREEN_POSITION_S:
case XFCE_SCREEN_POSITION_SE_H:
return GTK_ARROW_LEFT;
-
+
/* vertical north */
case XFCE_SCREEN_POSITION_NW_V:
case XFCE_SCREEN_POSITION_NE_V:
return GTK_ARROW_DOWN;
-
+
/* vertical south */
case XFCE_SCREEN_POSITION_W:
case XFCE_SCREEN_POSITION_SW_V:
case XFCE_SCREEN_POSITION_E:
case XFCE_SCREEN_POSITION_SE_V:
return GTK_ARROW_UP;
-
+
/* floating */
default:
/* get the screen information */
@@ -150,7 +150,7 @@
mon = gdk_screen_get_monitor_at_window (screen, GTK_WIDGET
(panel_plugin)->window);
gdk_screen_get_monitor_geometry (screen, mon, &geom);
gdk_window_get_root_origin (GTK_WIDGET (panel_plugin)->window, &x,
&y);
-
+
/* get the position based on the screen position */
if (position == XFCE_SCREEN_POSITION_FLOATING_H)
return ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT :
GTK_ARROW_LEFT);
@@ -168,42 +168,42 @@
GError *error = NULL;
GtkArrowType position;
GdkScreen *screen;
-
+
/* create structure */
plugin = panel_slice_new0 (XfceTrayPlugin);
-
+
/* set some data */
plugin->panel_plugin = panel_plugin;
plugin->manager = NULL;
plugin->show_frame = TRUE;
-
+
/* get the button position */
- position = xfce_tray_plugin_button_position (panel_plugin);
-
+ position = xfce_tray_plugin_button_position (panel_plugin);
+
/* get the screen of the plugin */
screen = gtk_widget_get_screen (GTK_WIDGET (panel_plugin));
-
+
/* try to create the tray */
plugin->tray = xfce_tray_widget_new_for_screen (screen, position, &error);
-
+
if (G_LIKELY (plugin->tray))
{
/* get the manager */
plugin->manager = xfce_tray_widget_get_manager (XFCE_TRAY_WIDGET
(plugin->tray));
-
+
/* read the plugin settings */
xfce_tray_plugin_read (plugin);
-
+
/* create the frame */
plugin->frame = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (plugin->frame),
plugin->show_frame ? GTK_SHADOW_IN : GTK_SHADOW_NONE);
gtk_container_add (GTK_CONTAINER (panel_plugin), plugin->frame);
gtk_widget_show (plugin->frame);
-
+
/* add the tray */
gtk_container_add (GTK_CONTAINER (plugin->frame), plugin->tray);
gtk_widget_show (plugin->tray);
-
+
/* connect signal to handle the real plugin size */
g_signal_connect_swapped (G_OBJECT (plugin->tray), "tray-size-changed",
G_CALLBACK
(xfce_tray_plugin_tray_size_changed), plugin);
@@ -212,33 +212,33 @@
{
/* show the message */
xfce_tray_plugin_message (GTK_MESSAGE_ERROR, screen, error->message);
-
+
/* cleanup */
g_error_free (error);
}
-
+
return plugin;
}
-static void
-xfce_tray_plugin_screen_position_changed (XfceTrayPlugin *plugin,
+static void
+xfce_tray_plugin_screen_position_changed (XfceTrayPlugin *plugin,
XfceScreenPosition position)
{
GtkArrowType button_position;
-
+
/* get the new position */
button_position = xfce_tray_plugin_button_position (plugin->panel_plugin);
-
+
/* set the position */
xfce_tray_widget_set_arrow_position (XFCE_TRAY_WIDGET (plugin->tray),
button_position);
}
-static void
-xfce_tray_plugin_orientation_changed (XfceTrayPlugin *plugin,
+static void
+xfce_tray_plugin_orientation_changed (XfceTrayPlugin *plugin,
GtkOrientation orientation)
{
/* invoke the function above */
@@ -252,13 +252,13 @@
gint size)
{
gint panel_size;
-
+
/* get the panel size */
panel_size = xfce_panel_plugin_get_size (plugin->panel_plugin);
-
+
/* correct the requested plugin size */
size += panel_size > SMALL_PANEL_SIZE ? 6 : 4;
-
+
/* update the plugin size */
if (xfce_panel_plugin_get_orientation (plugin->panel_plugin) ==
GTK_ORIENTATION_HORIZONTAL)
gtk_widget_set_size_request (GTK_WIDGET (plugin->panel_plugin), size,
panel_size);
@@ -268,21 +268,21 @@
-static gboolean
+static gboolean
xfce_tray_plugin_size_changed (XfceTrayPlugin *plugin,
guint size)
{
gint border;
-
+
/* set the frame border size */
gtk_container_set_border_width (GTK_CONTAINER (plugin->frame), size >
SMALL_PANEL_SIZE ? 1 : 0);
-
+
/* get the border size */
border = size > SMALL_PANEL_SIZE ? 6 : 4;
-
+
/* set the new plugin size */
xfce_tray_widget_set_size_request (XFCE_TRAY_WIDGET (plugin->tray), size -
border);
-
+
/* we handled the size of the plugin */
return TRUE;
}
@@ -297,54 +297,54 @@
gboolean hidden;
XfceRc *rc;
guint i;
-
+
/* get rc file name */
file = xfce_panel_plugin_lookup_rc_file (plugin->panel_plugin);
-
+
if (G_LIKELY (file))
{
/* open the file, readonly */
rc = xfce_rc_simple_open (file, TRUE);
-
+
/* cleanup */
g_free (file);
-
+
if (G_LIKELY (rc))
{
/* save global plugin settings */
xfce_rc_set_group (rc, "Global");
-
+
/* frame setting */
plugin->show_frame = xfce_rc_read_bool_entry (rc, "ShowFrame",
TRUE);
-
+
if (G_LIKELY (plugin->manager))
{
/* list of known applications */
applications = xfce_rc_get_entries (rc, "Applications");
-
+
if (G_LIKELY (applications))
- {
+ {
/* set the group */
xfce_rc_set_group (rc, "Applications");
-
+
/* read their visibility */
for (i = 0; applications[i] != NULL; i++)
{
/* whether the application is hidden */
hidden = xfce_rc_read_bool_entry (rc, applications[i],
FALSE);
-
+
/* add the application name */
xfce_tray_manager_application_add (plugin->manager,
applications[i], hidden);
}
-
+
/* cleanup */
g_strfreev (applications);
}
}
-
+
/* close the rc file */
xfce_rc_close (rc);
- }
+ }
}
}
@@ -357,44 +357,44 @@
GSList *applications, *li;
XfceRc *rc;
XfceTrayApplication *application;
-
+
/* get rc file name, create it if needed */
file = xfce_panel_plugin_save_location (plugin->panel_plugin, TRUE);
-
+
if (G_LIKELY (file))
{
/* open the file, writable */
rc = xfce_rc_simple_open (file, FALSE);
-
+
/* cleanup */
g_free (file);
-
+
if (G_LIKELY (rc))
{
/* save global plugin settings */
xfce_rc_set_group (rc, "Global");
-
+
/* write setting */
xfce_rc_write_bool_entry (rc, "ShowFrame", plugin->show_frame);
-
+
if (G_LIKELY (plugin->manager))
{
/* save the list of known applications and their visibility */
xfce_rc_set_group (rc, "Applications");
-
+
/* get the list of known applications */
applications = xfce_tray_manager_application_list
(plugin->manager, FALSE);
-
+
/* save their state */
for (li = applications; li != NULL; li = li->next)
{
application = li->data;
-
+
if (G_LIKELY (application->name))
xfce_rc_write_bool_entry (rc, application->name,
application->hidden);
}
}
-
+
/* close the rc file */
xfce_rc_close (rc);
}
@@ -403,7 +403,7 @@
-static void
+static void
xfce_tray_plugin_free (XfceTrayPlugin *plugin)
{
/* free slice */
@@ -412,30 +412,30 @@
-static void
+static void
xfce_tray_plugin_construct (XfcePanelPlugin *panel_plugin)
{
XfceTrayPlugin *plugin;
-
+
/* create the tray panel plugin */
plugin = xfce_tray_plugin_new (panel_plugin);
-
+
/* set the action widgets and show configure */
xfce_panel_plugin_add_action_widget (panel_plugin, plugin->frame);
xfce_panel_plugin_add_action_widget (panel_plugin, plugin->tray);
xfce_panel_plugin_menu_show_configure (panel_plugin);
-
+
/* connect signals */
- g_signal_connect_swapped (G_OBJECT (panel_plugin),
"screen-position-changed",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin),
"screen-position-changed",
G_CALLBACK
(xfce_tray_plugin_screen_position_changed), plugin);
- g_signal_connect_swapped (G_OBJECT (panel_plugin), "orientation-changed",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin), "orientation-changed",
G_CALLBACK
(xfce_tray_plugin_orientation_changed), plugin);
- g_signal_connect_swapped (G_OBJECT (panel_plugin), "size-changed",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin), "size-changed",
G_CALLBACK (xfce_tray_plugin_size_changed),
plugin);
- g_signal_connect_swapped (G_OBJECT (panel_plugin), "save",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin), "save",
G_CALLBACK (xfce_tray_plugin_write), plugin);
- g_signal_connect_swapped (G_OBJECT (panel_plugin), "free-data",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin), "free-data",
G_CALLBACK (xfce_tray_plugin_free), plugin);
- g_signal_connect_swapped (G_OBJECT (panel_plugin), "configure-plugin",
+ g_signal_connect_swapped (G_OBJECT (panel_plugin), "configure-plugin",
G_CALLBACK (xfce_tray_dialogs_configure),
plugin);
}
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.h
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.h 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-plugin.h 2007-09-10
16:01:26 UTC (rev 26067)
@@ -16,7 +16,7 @@
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-
+
#ifndef __XFCE_TRAY_PLUGIN_H__
#define __XFCE_TRAY_PLUGIN_H__
@@ -26,14 +26,14 @@
{
/* panel plugin */
XfcePanelPlugin *panel_plugin;
-
+
/* tray manager */
XfceTrayManager *manager;
-
+
/* widgets */
GtkWidget *frame;
GtkWidget *tray;
-
+
/* properties */
guint show_frame : 1;
};
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-widget.c
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-widget.c 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-widget.c 2007-09-10
16:01:26 UTC (rev 26067)
@@ -33,6 +33,7 @@
#include "xfce-tray-widget.h"
#define XFCE_TRAY_WIDGET_BUTTON_SIZE (16)
+#define XFCE_TRAY_WIDGET_REDRAW_DELAY (250)
#define XFCE_TRAY_WIDGET_SPACING (1)
#define XFCE_TRAY_WIDGET_LINE_HEIGHT (24 + 2 *
XFCE_TRAY_WIDGET_SPACING)
#define XFCE_TRAY_WIDGET_OFFSCREEN (-9999)
@@ -71,7 +72,8 @@
gint
size);
static gboolean xfce_tray_widget_redraw_idle (gpointer
user_data);
static void xfce_tray_widget_redraw_destroyed (gpointer
user_data);
-static void xfce_tray_widget_redraw (XfceTrayWidget
*tray);
+static void xfce_tray_widget_redraw (XfceTrayWidget *tray,
+ gboolean
delayed);
@@ -304,7 +306,7 @@
xfce_tray_widget_button_set_arrow (tray);
/* update the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, FALSE);
}
@@ -374,14 +376,11 @@
if (hidden)
tray->n_hidden_childeren++;
- /* show the icon */
- gtk_widget_show (icon);
-
/* set the parent window */
gtk_widget_set_parent (icon, GTK_WIDGET (tray));
/* update the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, TRUE);
}
@@ -413,7 +412,7 @@
}
/* update the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, FALSE);
}
@@ -608,7 +607,7 @@
else if (tray->arrow_position == GTK_ARROW_DOWN)
child_allocation.y = height - child_allocation.y - child_size;
- /* add the tray coordinates */
+ /* add the tray coordinates and spacing */
child_allocation.x += x + XFCE_TRAY_WIDGET_SPACING;
child_allocation.y += y + XFCE_TRAY_WIDGET_SPACING;
}
@@ -636,15 +635,23 @@
static void
-xfce_tray_widget_redraw (XfceTrayWidget *tray)
+xfce_tray_widget_redraw (XfceTrayWidget *tray,
+ gboolean delayed)
{
+ g_return_if_fail (XFCE_IS_TRAY_WIDGET (tray));
+
/* ignore if there is already a redraw scheduled */
if (tray->idle_redraw_id != 0)
return;
- /* schedule a new idle redraw */
- tray->idle_redraw_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
xfce_tray_widget_redraw_idle,
- tray,
xfce_tray_widget_redraw_destroyed);
+ /* schedule an idle or delayed redraw */
+ if (delayed)
+ tray->idle_redraw_id = g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE,
XFCE_TRAY_WIDGET_REDRAW_DELAY,
+
xfce_tray_widget_redraw_idle, tray,
+
xfce_tray_widget_redraw_destroyed);
+ else
+ tray->idle_redraw_id = g_idle_add_full (G_PRIORITY_DEFAULT_IDLE,
xfce_tray_widget_redraw_idle,
+ tray,
xfce_tray_widget_redraw_destroyed);
}
@@ -681,7 +688,7 @@
tray->n_hidden_childeren = n_hidden_childeren;
/* update the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, FALSE);
}
}
@@ -715,7 +722,7 @@
xfce_tray_widget_button_set_arrow (tray);
/* update the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, FALSE);
}
}
@@ -733,6 +740,6 @@
tray->size = size;
/* redraw the tray */
- xfce_tray_widget_redraw (tray);
+ xfce_tray_widget_redraw (tray, FALSE);
}
}
Modified: xfce4-panel/trunk/plugins/systray/xfce-tray-widget.h
===================================================================
--- xfce4-panel/trunk/plugins/systray/xfce-tray-widget.h 2007-09-10
14:17:14 UTC (rev 26066)
+++ xfce4-panel/trunk/plugins/systray/xfce-tray-widget.h 2007-09-10
16:01:26 UTC (rev 26067)
@@ -32,15 +32,15 @@
GType xfce_tray_widget_get_type (void) G_GNUC_CONST
G_GNUC_INTERNAL;
-GtkWidget *xfce_tray_widget_new_for_screen (GdkScreen *screen,
+GtkWidget *xfce_tray_widget_new_for_screen (GdkScreen *screen,
GtkArrowType
arrow_position,
GError **error)
G_GNUC_MALLOC G_GNUC_INTERNAL;
-
+
void xfce_tray_widget_sort (XfceTrayWidget *tray)
G_GNUC_INTERNAL;
-
+
XfceTrayManager *xfce_tray_widget_get_manager (XfceTrayWidget *tray)
G_GNUC_INTERNAL;
-void xfce_tray_widget_set_arrow_position (XfceTrayWidget *tray,
+void xfce_tray_widget_set_arrow_position (XfceTrayWidget *tray,
GtkArrowType
arrow_position) G_GNUC_INTERNAL;
void xfce_tray_widget_set_size_request (XfceTrayWidget *tray,
_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits