[Xfce4-commits] <xfce4-panel:devel> Make icon hiding work again with GtkBuilder and Xfconf.
Nick Schermer
noreply at xfce.org
Thu Jan 28 14:56:01 CET 2010
Updating branch refs/heads/devel
to fa2481116f11d003f9b1f47ec05f499a19d055a5 (commit)
from a4c620e80c6ab063fa32f8e353898d3965bea653 (commit)
commit fa2481116f11d003f9b1f47ec05f499a19d055a5
Author: Nick Schermer <nick at xfce.org>
Date: Wed Jan 20 21:04:58 2010 +0100
Make icon hiding work again with GtkBuilder and Xfconf.
plugins/systray/systray-box.c | 342 +++++++++++++++++++++++++---------
plugins/systray/systray-dialog.glade | 10 +-
plugins/systray/systray-manager.c | 28 +--
plugins/systray/systray.c | 337 ++++++++++++++++++++-------------
4 files changed, 473 insertions(+), 244 deletions(-)
diff --git a/plugins/systray/systray-box.c b/plugins/systray/systray-box.c
index 5807df0..51c0177 100644
--- a/plugins/systray/systray-box.c
+++ b/plugins/systray/systray-box.c
@@ -28,6 +28,7 @@
#include <gtk/gtk.h>
#include <libxfce4panel/libxfce4panel.h>
#include <common/panel-private.h>
+#include <common/panel-xfconf.h>
#include "systray-box.h"
#include "systray-socket.h"
@@ -40,28 +41,46 @@
-static void systray_box_finalize (GObject *object);
-static void systray_box_size_request (GtkWidget *widget,
- GtkRequisition *requisition);
-static void systray_box_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation);
-static gboolean systray_box_expose_event (GtkWidget *widget,
- GdkEventExpose *event);
-static void systray_box_add (GtkContainer *container,
- GtkWidget *child);
-static void systray_box_remove (GtkContainer *container,
- GtkWidget *child);
-static void systray_box_forall (GtkContainer *container,
- gboolean include_internals,
- GtkCallback callback,
- gpointer callback_data);
-static GType systray_box_child_type (GtkContainer *container);
-static void systray_box_button_set_arrow (SystrayBox *box);
-static gboolean systray_box_button_press_event (GtkWidget *widget,
- GdkEventButton *event,
- GtkWidget *box);
-static void systray_box_button_clicked (GtkToggleButton *button,
- SystrayBox *box);
+static void systray_box_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void systray_box_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void systray_box_finalize (GObject *object);
+static void systray_box_size_request (GtkWidget *widget,
+ GtkRequisition *requisition);
+static void systray_box_size_allocate (GtkWidget *widget,
+ GtkAllocation *allocation);
+static gboolean systray_box_expose_event (GtkWidget *widget,
+ GdkEventExpose *event);
+static void systray_box_add (GtkContainer *container,
+ GtkWidget *child);
+static void systray_box_remove (GtkContainer *container,
+ GtkWidget *child);
+static void systray_box_forall (GtkContainer *container,
+ gboolean include_internals,
+ GtkCallback callback,
+ gpointer callback_data);
+static GType systray_box_child_type (GtkContainer *container);
+static void systray_box_names_collect_visible (gpointer key,
+ gpointer value,
+ gpointer user_data);
+static void systray_box_names_collect_hidden (gpointer key,
+ gpointer value,
+ gpointer user_data);
+static gboolean systray_box_names_remove (gpointer key,
+ gpointer value,
+ gpointer user_data);
+static void systray_box_button_set_arrow (SystrayBox *box);
+static gboolean systray_box_button_press_event (GtkWidget *widget,
+ GdkEventButton *event,
+ GtkWidget *box);
+static void systray_box_button_clicked (GtkToggleButton *button,
+ SystrayBox *box);
+static void systray_box_update_hidden (SystrayBox *box);
@@ -116,6 +135,13 @@ typedef struct
}
SystrayBoxChild;
+enum
+{
+ PROP_0,
+ PROP_NAMES_HIDDEN,
+ PROP_NAMES_VISIBLE
+};
+
XFCE_PANEL_DEFINE_TYPE (SystrayBox, systray_box, GTK_TYPE_CONTAINER)
@@ -130,6 +156,8 @@ systray_box_class_init (SystrayBoxClass *klass)
GtkContainerClass *gtkcontainer_class;
gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->get_property = systray_box_get_property;
+ gobject_class->set_property = systray_box_set_property;
gobject_class->finalize = systray_box_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
@@ -142,6 +170,20 @@ systray_box_class_init (SystrayBoxClass *klass)
gtkcontainer_class->remove = systray_box_remove;
gtkcontainer_class->forall = systray_box_forall;
gtkcontainer_class->child_type = systray_box_child_type;
+
+ g_object_class_install_property (gobject_class,
+ PROP_NAMES_HIDDEN,
+ g_param_spec_boxed ("names-hidden",
+ NULL, NULL,
+ PANEL_PROPERTIES_TYPE_VALUE_ARRAY,
+ EXO_PARAM_READWRITE));
+
+ g_object_class_install_property (gobject_class,
+ PROP_NAMES_VISIBLE,
+ g_param_spec_boxed ("names-visible",
+ NULL, NULL,
+ PANEL_PROPERTIES_TYPE_VALUE_ARRAY,
+ EXO_PARAM_READWRITE));
}
@@ -149,10 +191,8 @@ systray_box_class_init (SystrayBoxClass *klass)
static void
systray_box_init (SystrayBox *box)
{
- /* initialize the widget */
GTK_WIDGET_SET_FLAGS (box, GTK_NO_WINDOW);
- /* initialize */
box->childeren = NULL;
box->button = NULL;
box->rows = 1;
@@ -160,8 +200,6 @@ systray_box_init (SystrayBox *box)
box->arrow_type = GTK_ARROW_LEFT;
box->show_hidden = FALSE;
box->guess_size = 128;
-
- /* create hash table */
box->names = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
/* create arrow button */
@@ -178,6 +216,89 @@ systray_box_init (SystrayBox *box)
static void
+systray_box_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ SystrayBox *box = XFCE_SYSTRAY_BOX (object);
+ GPtrArray *array;
+
+ switch (prop_id)
+ {
+ case PROP_NAMES_VISIBLE:
+ array = g_ptr_array_new ();
+ g_hash_table_foreach (box->names, systray_box_names_collect_visible, array);
+ g_value_set_boxed (value, array);
+ xfconf_array_free (array);
+ break;
+
+ case PROP_NAMES_HIDDEN:
+ array = g_ptr_array_new ();
+ g_hash_table_foreach (box->names, systray_box_names_collect_hidden, array);
+ g_value_set_boxed (value, array);
+ xfconf_array_free (array);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
+systray_box_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ SystrayBox *box = XFCE_SYSTRAY_BOX (object);
+ GPtrArray *array;
+ guint i;
+ const GValue *tmp;
+ gchar *name;
+ gboolean hidden = TRUE;
+
+ switch (prop_id)
+ {
+ case PROP_NAMES_VISIBLE:
+ hidden = FALSE;
+ /* fall-though */
+
+ case PROP_NAMES_HIDDEN:
+ /* remove old names with this state */
+ g_hash_table_foreach_remove (box->names,
+ systray_box_names_remove,
+ GUINT_TO_POINTER (hidden));
+
+ /* add new values */
+ array = g_value_get_boxed (value);
+ if (G_LIKELY (array != NULL))
+ {
+ for (i = 0; i < array->len; i++)
+ {
+ tmp = g_ptr_array_index (array, i);
+ panel_assert (G_VALUE_HOLDS_STRING (tmp));
+ name = g_value_dup_string (tmp);
+ g_hash_table_replace (box->names, name, GUINT_TO_POINTER (hidden));
+ }
+ }
+
+ /* update icons in the box */
+ systray_box_update_hidden (box);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
+ }
+}
+
+
+
+static void
systray_box_finalize (GObject *object)
{
SystrayBox *box = XFCE_SYSTRAY_BOX (object);
@@ -230,7 +351,7 @@ systray_box_size_request (GtkWidget *widget,
if (G_UNLIKELY (child_req.width == 1 || child_req.height == 1))
{
/* icons that return a 1 by 1 requisition supposed to be hidden */
- if (child_info->invalid == FALSE)
+ if (!child_info->invalid)
{
/* this icon should not be visible */
child_info->invalid = TRUE;
@@ -254,7 +375,7 @@ systray_box_size_request (GtkWidget *widget,
}
/* count the number of visible childeren */
- if (child_info->auto_hide == FALSE || box->show_hidden == TRUE)
+ if (!child_info->auto_hide || box->show_hidden)
{
/* get the icon size */
icon_size = MIN (guess_size, MAX (child_req.width, child_req.height));
@@ -577,6 +698,54 @@ systray_box_child_type (GtkContainer *container)
+static inline void
+systray_box_names_collect (GPtrArray *array,
+ const gchar *name)
+{
+ GValue *tmp;
+
+ tmp = g_new0 (GValue, 1);
+ g_value_init (tmp, G_TYPE_STRING);
+ g_value_set_string (tmp, name);
+ g_ptr_array_add (array, tmp);
+}
+
+
+
+static void
+systray_box_names_collect_visible (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ /* add all the visible names */
+ if (!GPOINTER_TO_UINT (value))
+ systray_box_names_collect (user_data, key);
+}
+
+
+
+static void
+systray_box_names_collect_hidden (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ /* add all the hidden names */
+ if (GPOINTER_TO_UINT (value))
+ systray_box_names_collect (user_data, key);
+}
+
+
+
+static gboolean
+systray_box_names_remove (gpointer key,
+ gpointer value,
+ gpointer user_data)
+{
+ return GPOINTER_TO_UINT (value) == GPOINTER_TO_UINT (user_data);
+}
+
+
+
static void
systray_box_button_set_arrow (SystrayBox *box)
{
@@ -631,7 +800,7 @@ systray_box_button_clicked (GtkToggleButton *button,
static gint
systray_box_compare_function (gconstpointer a,
- gconstpointer b)
+ gconstpointer b)
{
const SystrayBoxChild *child_a = a;
const SystrayBoxChild *child_b = b;
@@ -655,6 +824,47 @@ systray_box_compare_function (gconstpointer a,
+static void
+systray_box_update_hidden (SystrayBox *box)
+{
+ SystrayBoxChild *child_info;
+ GSList *li;
+ gint n_hidden_childeren;
+
+ panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
+
+ /* reset counter */
+ n_hidden_childeren = 0;
+
+ /* update the icons */
+ for (li = box->childeren; li != NULL; li = li->next)
+ {
+ child_info = li->data;
+
+ /* update the hidden state */
+ child_info->auto_hide = systray_box_name_get_hidden (box, child_info->name);
+
+ /* increase counter if needed */
+ if (child_info->auto_hide && !child_info->invalid)
+ n_hidden_childeren++;
+ }
+
+ if (box->n_hidden_childeren != n_hidden_childeren)
+ {
+ /* set value */
+ box->n_hidden_childeren = n_hidden_childeren;
+
+ /* sort the list again */
+ box->childeren = g_slist_sort (box->childeren,
+ systray_box_compare_function);
+
+ /* update the box */
+ gtk_widget_queue_resize (GTK_WIDGET (box));
+ }
+}
+
+
+
GtkWidget *
systray_box_new (void)
{
@@ -770,6 +980,9 @@ systray_box_name_add (SystrayBox *box,
/* insert the application */
g_hash_table_insert (box->names, g_strdup (name),
GUINT_TO_POINTER (hidden ? 1 : 0));
+
+ g_object_notify (G_OBJECT (box), hidden ? "names-hidden"
+ : "names-visible");
}
@@ -779,10 +992,6 @@ systray_box_name_set_hidden (SystrayBox *box,
const gchar *name,
gboolean hidden)
{
- SystrayBoxChild *child_info;
- GSList *li;
- gint n_hidden_childeren;
-
panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (box));
panel_return_if_fail (!exo_str_is_empty (name));
@@ -790,34 +999,12 @@ systray_box_name_set_hidden (SystrayBox *box,
g_hash_table_replace (box->names, g_strdup (name),
GUINT_TO_POINTER (hidden ? 1 : 0));
- /* reset counter */
- n_hidden_childeren = 0;
+ /* save new values */
+ g_object_notify (G_OBJECT (box), "names-hidden");
+ g_object_notify (G_OBJECT (box), "names-visible");
- /* update the icons */
- for (li = box->childeren; li != NULL; li = li->next)
- {
- child_info = li->data;
-
- /* update the hidden state */
- child_info->auto_hide = systray_box_name_get_hidden (box, child_info->name);
-
- /* increase counter if needed */
- if (child_info->auto_hide && !child_info->invalid)
- n_hidden_childeren++;
- }
-
- if (box->n_hidden_childeren != n_hidden_childeren)
- {
- /* set value */
- box->n_hidden_childeren = n_hidden_childeren;
-
- /* sort the list again */
- box->childeren = g_slist_sort (box->childeren,
- systray_box_compare_function);
-
- /* update the box */
- gtk_widget_queue_resize (GTK_WIDGET (box));
- }
+ /* update the box */
+ systray_box_update_hidden (box);
}
@@ -834,8 +1021,6 @@ systray_box_name_get_hidden (SystrayBox *box,
/* lookup the name in the table */
p = g_hash_table_lookup (box->names, name);
-
- /* check the pointer */
if (G_UNLIKELY (p == NULL))
{
/* add the name */
@@ -871,39 +1056,12 @@ systray_box_name_list (SystrayBox *box)
void
systray_box_name_clear (SystrayBox *box)
{
- SystrayBoxChild *child_info;
- GSList *li;
- gint n_hidden_childeren = 0;
-
/* remove all the entries from the list */
g_hash_table_remove_all (box->names);
- /* remove hidden flags from all childeren */
- for (li = box->childeren; li != NULL; li = li->next)
- {
- child_info = li->data;
-
- /* update the hidden state */
- if (child_info->auto_hide)
- {
- n_hidden_childeren++;
-
- child_info->auto_hide = FALSE;
- }
- }
-
- /* reset */
- box->n_hidden_childeren = 0;
+ g_object_notify (G_OBJECT (box), "names-hidden");
+ g_object_notify (G_OBJECT (box), "names-visible");
- /* update box if needed */
- if (n_hidden_childeren > 0)
- {
- /* sort the list again */
- box->childeren = g_slist_sort (box->childeren,
- systray_box_compare_function);
-
- /* update the box */
- gtk_widget_queue_resize (GTK_WIDGET (box));
- }
+ systray_box_update_hidden (box);
}
diff --git a/plugins/systray/systray-dialog.glade b/plugins/systray/systray-dialog.glade
index 44a703c..b41a25a 100644
--- a/plugins/systray/systray-dialog.glade
+++ b/plugins/systray/systray-dialog.glade
@@ -11,10 +11,14 @@
<column type="gchararray"/>
<!-- column-name hidden -->
<column type="gboolean"/>
+ <!-- column-name internal-name -->
+ <column type="gchararray"/>
</columns>
</object>
<object class="XfceTitledDialog" id="dialog">
<property name="title" translatable="yes">Notification Area</property>
+ <property name="default_width">325</property>
+ <property name="default_height">425</property>
<property name="icon_name">gtk-properties</property>
<property name="type_hint">normal</property>
<property name="has_separator">False</property>
@@ -167,11 +171,11 @@
</child>
<child>
<object class="GtkTreeViewColumn" id="treeviewcolumn3">
- <property name="title">Visible</property>
+ <property name="title">Hidden</property>
<child>
- <object class="GtkCellRendererToggle" id="cellrenderertoggle1"/>
+ <object class="GtkCellRendererToggle" id="hidden-toggle"/>
<attributes>
- <attribute name="activatable">2</attribute>
+ <attribute name="active">2</attribute>
</attributes>
</child>
</object>
diff --git a/plugins/systray/systray-manager.c b/plugins/systray/systray-manager.c
index b4e40ec..8581970 100644
--- a/plugins/systray/systray-manager.c
+++ b/plugins/systray/systray-manager.c
@@ -210,7 +210,6 @@ systray_manager_class_init (SystrayManagerClass *klass)
static void
systray_manager_init (SystrayManager *manager)
{
- /* initialize */
manager->invisible = NULL;
manager->orientation = GTK_ORIENTATION_HORIZONTAL;
manager->messages = NULL;
@@ -287,7 +286,6 @@ systray_manager_check_running (GdkScreen *screen)
selection_atom = gdk_x11_get_xatom_by_name_for_display (display,
selection_name);
- /* cleanup */
g_free (selection_name);
/* return result */
@@ -331,7 +329,6 @@ systray_manager_register (SystrayManager *manager,
/* get the selection atom */
manager->selection_atom = gdk_atom_intern (selection_name, FALSE);
- /* cleanup */
g_free (selection_name);
/* get the display */
@@ -523,20 +520,20 @@ systray_manager_handle_client_message_opcode (GdkXEvent *xevent,
switch (xev->data.l[1])
{
- case XFCE_SYSTRAY_MANAGER_REQUEST_DOCK:
- /* handled in systray_manager_window_filter () */
- break;
+ case XFCE_SYSTRAY_MANAGER_REQUEST_DOCK:
+ /* handled in systray_manager_window_filter () */
+ break;
- case XFCE_SYSTRAY_MANAGER_BEGIN_MESSAGE:
- systray_manager_handle_begin_message (manager, xev);
- return GDK_FILTER_REMOVE;
+ case XFCE_SYSTRAY_MANAGER_BEGIN_MESSAGE:
+ systray_manager_handle_begin_message (manager, xev);
+ return GDK_FILTER_REMOVE;
- case XFCE_SYSTRAY_MANAGER_CANCEL_MESSAGE:
- systray_manager_handle_cancel_message (manager, xev);
- return GDK_FILTER_REMOVE;
+ case XFCE_SYSTRAY_MANAGER_CANCEL_MESSAGE:
+ systray_manager_handle_cancel_message (manager, xev);
+ return GDK_FILTER_REMOVE;
- default:
- break;
+ default:
+ break;
}
return GDK_FILTER_CONTINUE;
@@ -840,10 +837,7 @@ systray_manager_set_orientation (SystrayManager *manager,
static void
systray_manager_message_free (SystrayMessage *message)
{
- /* cleanup */
g_free (message->string);
-
- /* remove slice */
g_slice_free (SystrayMessage, message);
}
diff --git a/plugins/systray/systray.c b/plugins/systray/systray.c
index f06a96e..87f7a9d 100644
--- a/plugins/systray/systray.c
+++ b/plugins/systray/systray.c
@@ -38,33 +38,38 @@
-static void systray_plugin_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-static void systray_plugin_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void systray_plugin_construct (XfcePanelPlugin *panel_plugin);
-static void systray_plugin_free_data (XfcePanelPlugin *panel_plugin);
-static void systray_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
- XfceScreenPosition screen_position);
-static void systray_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
- GtkOrientation orientation);
-static gboolean systray_plugin_size_changed (XfcePanelPlugin *panel_plugin,
- gint size);
-static void systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
-static void systray_plugin_icon_added (SystrayManager *manager,
- GtkWidget *icon,
- SystrayPlugin *plugin);
-static void systray_plugin_icon_removed (SystrayManager *manager,
- GtkWidget *icon,
- SystrayPlugin *plugin);
-static void systray_plugin_lost_selection (SystrayManager *manager,
- SystrayPlugin *plugin);
-static void systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
- GtkListStore *store);
+static void systray_plugin_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec);
+static void systray_plugin_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec);
+static void systray_plugin_construct (XfcePanelPlugin *panel_plugin);
+static void systray_plugin_free_data (XfcePanelPlugin *panel_plugin);
+static void systray_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
+ XfceScreenPosition screen_position);
+static void systray_plugin_orientation_changed (XfcePanelPlugin *panel_plugin,
+ GtkOrientation orientation);
+static gboolean systray_plugin_size_changed (XfcePanelPlugin *panel_plugin,
+ gint size);
+static void systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin);
+static void systray_plugin_icon_added (SystrayManager *manager,
+ GtkWidget *icon,
+ SystrayPlugin *plugin);
+static void systray_plugin_icon_removed (SystrayManager *manager,
+ GtkWidget *icon,
+ SystrayPlugin *plugin);
+static void systray_plugin_lost_selection (SystrayManager *manager,
+ SystrayPlugin *plugin);
+static void systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
+ GtkListStore *store);
+static void systray_plugin_dialog_hidden_toggled (GtkCellRendererToggle *renderer,
+ const gchar *path_string,
+ SystrayPlugin *plugin);
+static void systray_plugin_dialog_clear_clicked (GtkWidget *button,
+ SystrayPlugin *plugin);
@@ -95,6 +100,14 @@ enum
PROP_SHOW_FRAME
};
+enum
+{
+ COLUMN_PIXBUF,
+ COLUMN_TITLE,
+ COLUMN_HIDDEN,
+ COLUMN_INTERNAL_NAME
+};
+
/* define the plugin */
@@ -108,8 +121,9 @@ XFCE_PANEL_DEFINE_PLUGIN (SystrayPlugin, systray_plugin,
/* known applications to improve the icon and name */
static const gchar *known_applications[][3] =
{
- /* application name, icon-name, translated name */
- { "networkmanager applet", "network-workgroup", N_("Network Manager Applet") },
+ /* application name, icon-name, understandable name */
+ { "networkmanager applet", "network-workgroup", "Network Manager Applet" },
+ { "thunar", "Thunar", "Thunar Progress Dialog" },
};
@@ -155,7 +169,6 @@ systray_plugin_init (SystrayPlugin *plugin)
plugin->manager = NULL;
plugin->show_frame = TRUE;
- /* plugin widgets */
plugin->frame = gtk_frame_new (NULL);
gtk_container_add (GTK_CONTAINER (plugin), plugin->frame);
gtk_frame_set_shadow_type (GTK_FRAME (plugin->frame), GTK_SHADOW_ETCHED_IN);
@@ -180,18 +193,18 @@ systray_plugin_get_property (GObject *object,
switch (prop_id)
{
- case PROP_ROWS:
- rows = systray_box_get_rows (XFCE_SYSTRAY_BOX (plugin->box));
- g_value_set_uint (value, rows);
- break;
-
- case PROP_SHOW_FRAME:
- g_value_set_boolean (value, plugin->show_frame);
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_ROWS:
+ rows = systray_box_get_rows (XFCE_SYSTRAY_BOX (plugin->box));
+ g_value_set_uint (value, rows);
+ break;
+
+ case PROP_SHOW_FRAME:
+ g_value_set_boolean (value, plugin->show_frame);
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -208,24 +221,24 @@ systray_plugin_set_property (GObject *object,
switch (prop_id)
{
- case PROP_ROWS:
- systray_box_set_rows (XFCE_SYSTRAY_BOX (plugin->box),
- g_value_get_uint (value));
- break;
-
- case PROP_SHOW_FRAME:
- show_frame = g_value_get_boolean (value);
- if (plugin->show_frame != show_frame)
- {
- plugin->show_frame = show_frame;
- gtk_frame_set_shadow_type (GTK_FRAME (plugin->frame),
- show_frame ? GTK_SHADOW_ETCHED_IN : GTK_SHADOW_NONE);
- }
- break;
-
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
+ case PROP_ROWS:
+ systray_box_set_rows (XFCE_SYSTRAY_BOX (plugin->box),
+ g_value_get_uint (value));
+ break;
+
+ case PROP_SHOW_FRAME:
+ show_frame = g_value_get_boolean (value);
+ if (plugin->show_frame != show_frame)
+ {
+ plugin->show_frame = show_frame;
+ gtk_frame_set_shadow_type (GTK_FRAME (plugin->frame),
+ show_frame ? GTK_SHADOW_ETCHED_IN : GTK_SHADOW_NONE);
+ }
+ break;
+
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ break;
}
}
@@ -247,11 +260,9 @@ systray_plugin_screen_changed (GtkWidget *widget,
plugin->manager = NULL;
}
- /* get the new screen */
- screen = gtk_widget_get_screen (widget);
-
/* check if not another systray is running on this screen */
- if (G_LIKELY (systray_manager_check_running (screen) == FALSE))
+ screen = gtk_widget_get_screen (widget);
+ if (G_LIKELY (!systray_manager_check_running (screen)))
{
/* create a new manager and register this screen */
plugin->manager = systray_manager_new ();
@@ -285,6 +296,7 @@ systray_plugin_screen_changed (GtkWidget *widget,
}
+#define LAUNCHER_TYPE_PTR_ARRAY (dbus_g_type_get_collection("GPtrArray", G_TYPE_VALUE))
static void
systray_plugin_construct (XfcePanelPlugin *panel_plugin)
@@ -296,20 +308,26 @@ systray_plugin_construct (XfcePanelPlugin *panel_plugin)
{ "show-frame", G_TYPE_BOOLEAN },
{ NULL }
};
+ const PanelProperty box_properties[] =
+ {
+ { "names-visible", PANEL_PROPERTIES_TYPE_VALUE_ARRAY },
+ { "names-hidden", PANEL_PROPERTIES_TYPE_VALUE_ARRAY },
+ { NULL }
+ };
- /* show configure */
xfce_panel_plugin_menu_show_configure (XFCE_PANEL_PLUGIN (plugin));
/* bind all properties */
panel_properties_bind (NULL, G_OBJECT (plugin),
xfce_panel_plugin_get_property_base (panel_plugin),
properties, FALSE);
+ panel_properties_bind (NULL, G_OBJECT (plugin->box),
+ xfce_panel_plugin_get_property_base (panel_plugin),
+ box_properties, FALSE);
/* monitor screen changes */
g_signal_connect (G_OBJECT (plugin), "screen-changed",
G_CALLBACK (systray_plugin_screen_changed), NULL);
-
- /* initialize the screen */
systray_plugin_screen_changed (GTK_WIDGET (plugin), NULL);
}
@@ -324,7 +342,6 @@ systray_plugin_free_data (XfcePanelPlugin *panel_plugin)
g_signal_handlers_disconnect_by_func (G_OBJECT (plugin),
systray_plugin_screen_changed, NULL);
- /* release the manager */
if (G_LIKELY (plugin->manager != NULL))
{
systray_manager_unregister (plugin->manager);
@@ -349,48 +366,48 @@ systray_plugin_screen_position_changed (XfcePanelPlugin *panel_plugin,
/* get the button position */
switch (screen_position)
{
- /* horizontal west */
- case XFCE_SCREEN_POSITION_NW_H:
- case XFCE_SCREEN_POSITION_SW_H:
- arrow_type = GTK_ARROW_RIGHT;
- break;
-
- /* horizontal east */
- case XFCE_SCREEN_POSITION_N:
- case XFCE_SCREEN_POSITION_NE_H:
- case XFCE_SCREEN_POSITION_S:
- case XFCE_SCREEN_POSITION_SE_H:
- arrow_type = GTK_ARROW_LEFT;
- break;
-
- /* vertical north */
- case XFCE_SCREEN_POSITION_NW_V:
- case XFCE_SCREEN_POSITION_NE_V:
- arrow_type = GTK_ARROW_DOWN;
- break;
-
- /* vertical south */
- case XFCE_SCREEN_POSITION_W:
- case XFCE_SCREEN_POSITION_SW_V:
- case XFCE_SCREEN_POSITION_E:
- case XFCE_SCREEN_POSITION_SE_V:
- arrow_type = GTK_ARROW_UP;
- break;
-
- /* floating */
- default:
- /* get the screen information */
- screen = gtk_widget_get_screen (GTK_WIDGET (panel_plugin));
- 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 (screen_position == XFCE_SCREEN_POSITION_FLOATING_H)
- arrow_type = ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
- else
- arrow_type = ((y < (geom.y + geom.height / 2)) ? GTK_ARROW_DOWN : GTK_ARROW_UP);
- break;
+ /* horizontal west */
+ case XFCE_SCREEN_POSITION_NW_H:
+ case XFCE_SCREEN_POSITION_SW_H:
+ arrow_type = GTK_ARROW_RIGHT;
+ break;
+
+ /* horizontal east */
+ case XFCE_SCREEN_POSITION_N:
+ case XFCE_SCREEN_POSITION_NE_H:
+ case XFCE_SCREEN_POSITION_S:
+ case XFCE_SCREEN_POSITION_SE_H:
+ arrow_type = GTK_ARROW_LEFT;
+ break;
+
+ /* vertical north */
+ case XFCE_SCREEN_POSITION_NW_V:
+ case XFCE_SCREEN_POSITION_NE_V:
+ arrow_type = GTK_ARROW_DOWN;
+ break;
+
+ /* vertical south */
+ case XFCE_SCREEN_POSITION_W:
+ case XFCE_SCREEN_POSITION_SW_V:
+ case XFCE_SCREEN_POSITION_E:
+ case XFCE_SCREEN_POSITION_SE_V:
+ arrow_type = GTK_ARROW_UP;
+ break;
+
+ /* floating */
+ default:
+ /* get the screen information */
+ screen = gtk_widget_get_screen (GTK_WIDGET (panel_plugin));
+ 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 (screen_position == XFCE_SCREEN_POSITION_FLOATING_H)
+ arrow_type = ((x < (geom.x + geom.width / 2)) ? GTK_ARROW_RIGHT : GTK_ARROW_LEFT);
+ else
+ arrow_type = ((y < (geom.y + geom.height / 2)) ? GTK_ARROW_DOWN : GTK_ARROW_UP);
+ break;
}
/* set the arrow type of the tray widget */
@@ -444,7 +461,7 @@ systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
{
SystrayPlugin *plugin = XFCE_SYSTRAY_PLUGIN (panel_plugin);
GtkBuilder *builder;
- GObject *dialog, *object;
+ GObject *dialog, *object, *store;
/* setup the dialog */
PANEL_BUILDER_LINK_4UI
@@ -463,9 +480,20 @@ systray_plugin_configure_plugin (XfcePanelPlugin *panel_plugin)
exo_mutual_binding_new (G_OBJECT (plugin), "show-frame",
G_OBJECT (object), "active");
- object = gtk_builder_get_object (builder, "applications-store");
- panel_return_if_fail (GTK_IS_LIST_STORE (object));
- systray_plugin_dialog_add_application_names (plugin, GTK_LIST_STORE (object));
+ store = gtk_builder_get_object (builder, "applications-store");
+ panel_return_if_fail (GTK_IS_LIST_STORE (store));
+ systray_plugin_dialog_add_application_names (plugin, GTK_LIST_STORE (store));
+ g_object_set_data (G_OBJECT (plugin), "applications-store", store);
+
+ object = gtk_builder_get_object (builder, "hidden-toggle");
+ panel_return_if_fail (GTK_IS_CELL_RENDERER_TOGGLE (object));
+ g_signal_connect (G_OBJECT (object), "toggled",
+ G_CALLBACK (systray_plugin_dialog_hidden_toggled), plugin);
+
+ object = gtk_builder_get_object (builder, "applications-clear");
+ panel_return_if_fail (GTK_IS_BUTTON (object));
+ g_signal_connect (G_OBJECT (object), "clicked",
+ G_CALLBACK (systray_plugin_dialog_clear_clicked), plugin);
gtk_widget_show (GTK_WIDGET (dialog));
}
@@ -484,16 +512,10 @@ systray_plugin_icon_added (SystrayManager *manager,
panel_return_if_fail (plugin->manager == manager);
panel_return_if_fail (GTK_IS_WIDGET (icon));
- /* get the application name */
name = systray_socket_get_title (XFCE_SYSTRAY_SOCKET (icon));
-
- /* add the icon to the widget */
systray_box_add_with_name (XFCE_SYSTRAY_BOX (plugin->box), icon, name);
-
- /* cleanup */
g_free (name);
- /* show icon */
gtk_widget_show (icon);
}
@@ -533,6 +555,7 @@ systray_plugin_lost_selection (SystrayManager *manager,
}
+
static gchar *
systray_plugin_dialog_camel_case (const gchar *text)
{
@@ -594,13 +617,8 @@ systray_plugin_dialog_icon (GtkIconTheme *icon_theme,
p = g_utf8_strchr (icon_name, -1, ' ');
if (p != NULL)
{
- /* get the string before the first occurrence */
first_occ = g_strndup (icon_name, p - icon_name);
-
- /* try to load the icon from the theme */
icon = gtk_icon_theme_load_icon (icon_theme, first_occ, ICON_SIZE, 0, NULL);
-
- /* cleanup */
g_free (first_occ);
}
@@ -627,7 +645,6 @@ systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (plugin->box));
panel_return_if_fail (GTK_IS_LIST_STORE (store));
- /* get the icon theme */
icon_theme = gtk_icon_theme_get_default ();
/* get the know application names and insert them in the store */
@@ -640,18 +657,16 @@ systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
if (exo_str_is_empty (name))
continue;
- /* init */
title = NULL;
icon_name = name;
camelcase = NULL;
hidden = systray_box_name_get_hidden (XFCE_SYSTRAY_BOX (plugin->box), name);
- /* lookup the application in the store */
+ /* check if we have a better name for the application */
for (i = 0; i < G_N_ELEMENTS (known_applications); i++)
{
if (strcmp (name, known_applications[i][0]) == 0)
{
- /* get the info from the array */
icon_name = known_applications[i][1];
title = _(known_applications[i][2]);
break;
@@ -670,14 +685,72 @@ systray_plugin_dialog_add_application_names (SystrayPlugin *plugin,
/* insert in the store */
gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter, 0, icon, 1, title, 2, hidden, -1);
+ gtk_list_store_set (store, &iter,
+ COLUMN_PIXBUF, icon,
+ COLUMN_TITLE, title,
+ COLUMN_HIDDEN, hidden,
+ COLUMN_INTERNAL_NAME, name,
+ -1);
- /* cleanup */
g_free (camelcase);
if (icon != NULL)
g_object_unref (G_OBJECT (icon));
}
- /* cleanup */
g_list_free (names);
}
+
+
+
+static void
+systray_plugin_dialog_hidden_toggled (GtkCellRendererToggle *renderer,
+ const gchar *path_string,
+ SystrayPlugin *plugin)
+{
+ GtkTreeIter iter;
+ gboolean hidden;
+ GtkTreeModel *model;
+ gchar *name;
+
+ panel_return_if_fail (XFCE_IS_SYSTRAY_PLUGIN (plugin));
+ panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (plugin->box));
+
+ model = g_object_get_data (G_OBJECT (plugin), "applications-store");
+ panel_return_if_fail (GTK_IS_LIST_STORE (model));
+ if (gtk_tree_model_get_iter_from_string (model, &iter, path_string))
+ {
+ gtk_tree_model_get (model, &iter,
+ COLUMN_HIDDEN, &hidden,
+ COLUMN_INTERNAL_NAME, &name, -1);
+
+ /* update box and store with new state */
+ systray_box_name_set_hidden (XFCE_SYSTRAY_BOX (plugin->box), name, !hidden);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter, 2, !hidden, -1);
+
+ g_free (name);
+ }
+}
+
+
+
+static void
+systray_plugin_dialog_clear_clicked (GtkWidget *button,
+ SystrayPlugin *plugin)
+{
+ GtkListStore *store;
+
+ panel_return_if_fail (XFCE_IS_SYSTRAY_PLUGIN (plugin));
+ panel_return_if_fail (XFCE_IS_SYSTRAY_BOX (plugin->box));
+
+ if (xfce_dialog_confirm (GTK_WINDOW (gtk_widget_get_toplevel (button)),
+ GTK_STOCK_CLEAR, NULL, NULL,
+ _("Are you sure you want to clear the list of "
+ "known applications?")))
+ {
+ store = g_object_get_data (G_OBJECT (plugin), "applications-store");
+ panel_return_if_fail (GTK_IS_LIST_STORE (store));
+ gtk_list_store_clear (store);
+
+ systray_box_name_clear (XFCE_SYSTRAY_BOX (plugin->box));
+ }
+}
More information about the Xfce4-commits
mailing list