Browse Source

Launcher:

* Finish arrow position code (Bug #1046 and Bug #2985).
* Code cleanups and fixes.

Libxfce4panel:
* Force plugins to use the panel size.

Po:
* Merge strings


(Old svn revision: 26065)
upstream/xfce4-panel-4.10.1
Nick Schermer 15 years ago
parent
commit
d3ff8144bc
  1. 22
      libxfce4panel/xfce-panel-plugin-iface.c
  2. 334
      plugins/launcher/launcher-dialog.c
  3. 2
      plugins/launcher/launcher-dialog.h
  4. 48
      plugins/launcher/launcher-exec.c
  5. 10
      plugins/launcher/launcher-exec.h
  6. 1704
      plugins/launcher/launcher.c
  7. 94
      plugins/launcher/launcher.h
  8. 222
      plugins/systray/xfce-tray-widget.c
  9. 801
      po/am.po
  10. 98
      po/ar.po
  11. 97
      po/az.po
  12. 99
      po/be.po
  13. 98
      po/bg.po
  14. 98
      po/bn_IN.po
  15. 96
      po/ca.po
  16. 218
      po/cs.po
  17. 99
      po/de.po
  18. 99
      po/dz.po
  19. 99
      po/el.po
  20. 99
      po/en_GB.po
  21. 99
      po/eo.po
  22. 99
      po/es.po
  23. 98
      po/es_MX.po
  24. 98
      po/et.po
  25. 96
      po/eu.po
  26. 97
      po/fa.po
  27. 99
      po/fi.po
  28. 99
      po/fr.po
  29. 99
      po/gl.po
  30. 98
      po/gu.po
  31. 99
      po/he.po
  32. 99
      po/hi.po
  33. 99
      po/hu.po
  34. 97
      po/hy.po
  35. 97
      po/it.po
  36. 96
      po/ja.po
  37. 94
      po/ka.po
  38. 99
      po/ko.po
  39. 98
      po/lt.po
  40. 99
      po/mk.po
  41. 98
      po/mr.po
  42. 98
      po/ms.po
  43. 97
      po/nb_NO.po
  44. 99
      po/nl.po
  45. 96
      po/pa.po
  46. 99
      po/pl.po
  47. 99
      po/pt_BR.po
  48. 96
      po/pt_PT.po
  49. 99
      po/ro.po
  50. 99
      po/ru.po
  51. 98
      po/sk.po
  52. 99
      po/sq.po
  53. 99
      po/sv.po
  54. 98
      po/ta.po
  55. 99
      po/tr.po
  56. 96
      po/uk.po
  57. 99
      po/vi.po
  58. 94
      po/xfce4-panel.pot
  59. 99
      po/zh_CN.po
  60. 99
      po/zh_TW.po

22
libxfce4panel/xfce-panel-plugin-iface.c

@ -343,15 +343,35 @@ void
_xfce_panel_plugin_signal_size (XfcePanelPlugin *plugin,
gint size)
{
gboolean handled = FALSE;
gboolean handled = FALSE;
GtkOrientation orientation;
gint width, height;
_panel_return_if_fail (XFCE_IS_PANEL_PLUGIN (plugin));
/* emit signal */
g_signal_emit (G_OBJECT (plugin), xfce_panel_plugin_signals[SIZE_CHANGED], 0,
size, &handled);
if (!handled)
{
/* size was not handled by the plugin, so we set it */
gtk_widget_set_size_request (GTK_WIDGET (plugin), size, size);
}
else
{
/* get the orientation of the panel */
orientation = xfce_panel_plugin_get_orientation (plugin);
/* get the requested plugin size */
gtk_widget_get_size_request (GTK_WIDGET (plugin), &width, &height);
/* force the plugin size */
if (orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_widget_set_size_request (GTK_WIDGET (plugin), width, size);
else
gtk_widget_set_size_request (GTK_WIDGET (plugin), size, height);
}
}

334
plugins/launcher/launcher-dialog.c

@ -35,10 +35,11 @@
#include "launcher.h"
#include "launcher-dialog.h"
enum
{
COL_ICON = 0,
COL_TEXT
COLUMN_ICON = 0,
COLUMN_NAME
};
typedef struct _LauncherDialog LauncherDialog;
@ -47,6 +48,12 @@ struct _LauncherDialog
{
LauncherPlugin *launcher;
/* stored setting */
guint stored_move_first : 1;
/* arrow position */
GtkWidget *arrow_position;
/* entries list */
GtkWidget *treeview;
GtkListStore *store;
@ -80,7 +87,8 @@ struct _LauncherDialog
/**
* Prototypes
**/
static gchar *launcher_dialog_parse_exec (const gchar *exec) G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
static void launcher_dialog_g_list_swap (GList *li_a,
GList *li_b);
static gboolean launcher_dialog_read_desktop_file (const gchar *file,
LauncherEntry *entry);
static void launcher_dialog_tree_drag_data_received (GtkWidget *widget,
@ -99,7 +107,6 @@ static void launcher_dialog_frame_drag_data_received (GtkWidget
guint info,
guint time,
LauncherDialog *ld);
static void launcher_dialog_update_panel (LauncherDialog *ld);
static void launcher_dialog_save_entry (GtkWidget *entry,
LauncherDialog *ld);
static void launcher_dialog_save_button (GtkWidget *button,
@ -109,7 +116,6 @@ static void launcher_dialog_update_icon (LauncherDialog
static void launcher_dialog_folder_chooser (LauncherDialog *ld);
static void launcher_dialog_command_chooser (LauncherDialog *ld);
static void launcher_dialog_icon_chooser (LauncherDialog *ld);
static void launcher_dialog_tree_free_store (LauncherDialog *ld);
static void launcher_dialog_tree_update_row (LauncherDialog *ld,
gint column);
static void launcher_dialog_tree_selection_changed (LauncherDialog *ld,
@ -128,23 +134,19 @@ static void launcher_dialog_response (GtkWidget
/**
* .Desktop entry
**/
static gchar *
launcher_dialog_parse_exec (const gchar *exec)
static void
launcher_dialog_g_list_swap (GList *li_a,
GList *li_b)
{
gchar *command;
/* quit if nothing is set */
if (exec == NULL)
return NULL;
gpointer data;
/* expand enviorement variables like ~/ and ~user/ */
command = xfce_expand_variables (exec, NULL);
return command;
/* swap the data pointers */
data = li_a->data;
li_a->data = li_b->data;
li_b->data = data;
}
static gboolean
launcher_dialog_read_desktop_file (const gchar *path,
LauncherEntry *entry)
@ -203,7 +205,7 @@ launcher_dialog_read_desktop_file (const gchar *path,
g_free (entry->exec);
/* expand variables and store */
entry->exec = launcher_dialog_parse_exec (value);
entry->exec = value ? xfce_expand_variables (value, NULL) : NULL;
}
/* working directory */
@ -247,13 +249,14 @@ launcher_dialog_tree_drag_data_received (GtkWidget *widget,
GtkTreeModel *model;
GtkTreeIter iter_a;
GtkTreeIter iter_b;
GSList *file_list = NULL;
GSList *filenames = NULL;
GSList *li;
gchar *file;
const gchar *file;
gboolean insert_before = FALSE;
gboolean update_icon = FALSE;
gint i = 0;
LauncherEntry *entry;
GdkPixbuf *icon = NULL;
GdkPixbuf *pixbuf;
/* get drop position in the tree */
if (gtk_tree_view_get_dest_row_at_pos (GTK_TREE_VIEW (ld->treeview),
@ -289,48 +292,47 @@ launcher_dialog_tree_drag_data_received (GtkWidget *widget,
break;
}
/* we need to update the button icon if something was dropped on the first position */
/* we need to update the button icon afterwards */
if (i == 0)
ld->launcher->icon_update_required = TRUE;
update_icon = TRUE;
/* create list from selection data */
file_list = launcher_file_list_from_selection (selection_data);
filenames = launcher_utility_filenames_from_selection_data (selection_data);
}
if (G_LIKELY (file_list != NULL))
if (G_LIKELY (filenames != NULL))
{
for (li = file_list; li != NULL; li = li->next)
for (li = filenames; li != NULL; li = li->next)
{
file = (gchar *) li->data;
file = li->data;
/* create new entry */
entry = launcher_new_entry ();
entry = launcher_entry_new ();
/* try to parse desktop file */
if (G_LIKELY (launcher_dialog_read_desktop_file (file, entry) == TRUE))
{
/* try to load the pixbuf */
icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE);
/* insert new row in store */
if (insert_before)
gtk_list_store_insert_before (ld->store, &iter_b, &iter_a);
else
gtk_list_store_insert_after (ld->store, &iter_b, &iter_a);
/* try to load the pixbuf */
pixbuf = launcher_utility_load_pixbuf (gtk_widget_get_screen (ld->treeview), entry->icon, LAUNCHER_TREE_ICON_SIZE);
/* set tree data */
gtk_list_store_set (ld->store, &iter_b,
COL_ICON, icon,
COL_TEXT, entry->name,
COLUMN_ICON, pixbuf,
COLUMN_NAME, entry->name,
-1);
/* release pixbuf */
if (G_LIKELY (icon != NULL))
g_object_unref (G_OBJECT (icon));
if (G_LIKELY (pixbuf != NULL))
g_object_unref (G_OBJECT (pixbuf));
/* insert in list */
ld->launcher->entries = g_list_insert (ld->launcher->entries,
entry, i);
ld->launcher->entries = g_list_insert (ld->launcher->entries, entry, i);
/* copy iter, so we add after last item */
iter_a = iter_b;
@ -345,7 +347,7 @@ launcher_dialog_tree_drag_data_received (GtkWidget *widget,
else
{
/* desktop file pasring failed, free new entry */
launcher_free_entry (entry, NULL);
launcher_entry_free (entry, NULL);
}
}
@ -353,10 +355,10 @@ launcher_dialog_tree_drag_data_received (GtkWidget *widget,
gtk_tree_view_set_cursor (GTK_TREE_VIEW (ld->treeview), path, NULL, FALSE);
/* update the panel */
launcher_dialog_update_panel (ld);
launcher_plugin_rebuild (ld->launcher, update_icon);
/* cleanup */
g_slist_free_all (file_list);
launcher_free_filenames (filenames);
}
/* free path */
@ -379,16 +381,16 @@ launcher_dialog_frame_drag_data_received (GtkWidget *widget,
guint time,
LauncherDialog *ld)
{
GSList *file_list = NULL;
GSList *li;
gchar *file;
GSList *filenames, *li;
gchar *file;
gboolean update_icon = FALSE;
/* create list from all the uri list */
file_list = launcher_file_list_from_selection (selection_data);
filenames = launcher_utility_filenames_from_selection_data (selection_data);
if (G_LIKELY (file_list != NULL))
if (G_LIKELY (filenames != NULL))
{
for (li = file_list; li != NULL; li = li->next)
for (li = filenames; li != NULL; li = li->next)
{
file = (gchar *) li->data;
@ -399,14 +401,15 @@ launcher_dialog_frame_drag_data_received (GtkWidget *widget,
launcher_dialog_update_entries (ld);
/* update the tree */
launcher_dialog_tree_update_row (ld, COL_TEXT);
launcher_dialog_tree_update_row (ld, COL_ICON);
launcher_dialog_tree_update_row (ld, COLUMN_NAME);
launcher_dialog_tree_update_row (ld, COLUMN_ICON);
/* also update the panel button icon */
ld->launcher->icon_update_required = TRUE;
if (g_list_index (ld->launcher->entries, ld->entry) == 0)
update_icon = TRUE;
/* update the panel */
launcher_dialog_update_panel (ld);
launcher_plugin_rebuild (ld->launcher, update_icon);
/* stop trying */
break;
@ -414,7 +417,7 @@ launcher_dialog_frame_drag_data_received (GtkWidget *widget,
}
/* cleanup */
g_slist_free_all (file_list);
launcher_free_filenames (filenames);
}
/* finish drag */
@ -426,15 +429,6 @@ launcher_dialog_frame_drag_data_received (GtkWidget *widget,
/**
* Properties update and save functions
**/
static void
launcher_dialog_update_panel (LauncherDialog *ld)
{
g_idle_add ((GSourceFunc) launcher_button_update, ld->launcher);
g_idle_add ((GSourceFunc) launcher_menu_prepare, ld->launcher);
}
static void
launcher_dialog_save_entry (GtkWidget *entry,
LauncherDialog *ld)
@ -459,7 +453,7 @@ launcher_dialog_save_entry (GtkWidget *entry,
ld->entry->name = g_strdup (text);
/* update tree, when triggered by widget */
launcher_dialog_tree_update_row (ld, COL_TEXT);
launcher_dialog_tree_update_row (ld, COLUMN_NAME);
}
else if (entry == ld->entry_comment)
{
@ -469,7 +463,7 @@ launcher_dialog_save_entry (GtkWidget *entry,
else if (entry == ld->entry_exec)
{
g_free (ld->entry->exec);
ld->entry->exec = launcher_dialog_parse_exec (text);
ld->entry->exec = text ? xfce_expand_variables (text, NULL) : NULL;
}
else if (entry == ld->entry_path)
{
@ -478,7 +472,7 @@ launcher_dialog_save_entry (GtkWidget *entry,
}
/* update panel */
launcher_dialog_update_panel (ld);
launcher_plugin_rebuild (ld->launcher, FALSE);
}
@ -565,21 +559,24 @@ launcher_dialog_update_icon (LauncherDialog *ld)
gtk_widget_destroy (GTK_BIN (ld->entry_icon)->child);
if (G_LIKELY (ld->entry->icon))
icon = launcher_load_pixbuf (ld->entry_icon, ld->entry->icon, CHOOSER_ICON_SIZE, FALSE);
icon = launcher_utility_load_pixbuf (gtk_widget_get_screen (ld->entry_icon), ld->entry->icon, LAUNCHER_CHOOSER_ICON_SIZE);
/* create icon button */
if (G_LIKELY (icon != NULL))
{
/* create image from pixbuf */
child = gtk_image_new_from_pixbuf (icon);
/* release icon */
g_object_unref (G_OBJECT (icon));
gtk_widget_set_size_request (child, LAUNCHER_CHOOSER_ICON_SIZE, LAUNCHER_CHOOSER_ICON_SIZE);
}
else
{
child = gtk_label_new (_("No icon"));
gtk_widget_set_size_request (child, -1, CHOOSER_ICON_SIZE);
gtk_widget_set_size_request (child, -1, LAUNCHER_CHOOSER_ICON_SIZE);
}
gtk_container_add (GTK_CONTAINER (ld->entry_icon), child);
@ -756,6 +753,7 @@ launcher_dialog_icon_chooser (LauncherDialog *ld)
const gchar *name;
GtkWidget *chooser;
gchar *title;
gboolean update_icon = FALSE;
/* determine the name of the entry being edited */
name = gtk_entry_get_text (GTK_ENTRY (ld->entry_name));
@ -790,14 +788,14 @@ launcher_dialog_icon_chooser (LauncherDialog *ld)
launcher_dialog_update_icon (ld);
/* update the icon column in the tree */
launcher_dialog_tree_update_row (ld, COL_ICON);
launcher_dialog_tree_update_row (ld, COLUMN_ICON);
/* check if we need to update the icon button image */
if (g_list_index (ld->launcher->entries, ld->entry) == 0)
ld->launcher->icon_update_required = TRUE;
update_icon = TRUE;
/* update the panel widgets */
launcher_dialog_update_panel (ld);
launcher_plugin_rebuild (ld->launcher, update_icon);
}
/* destroy the chooser */
@ -809,18 +807,6 @@ launcher_dialog_icon_chooser (LauncherDialog *ld)
/**
* Tree functions
**/
static void
launcher_dialog_tree_free_store (LauncherDialog *ld)
{
/* clear the store */
gtk_list_store_clear (ld->store);
/* release the store */
g_object_unref (G_OBJECT (ld->store));
}
static void
launcher_dialog_tree_update_row (LauncherDialog *ld,
gint column)
@ -835,13 +821,13 @@ launcher_dialog_tree_update_row (LauncherDialog *ld,
{
switch (column)
{
case COL_ICON:
case COLUMN_ICON:
/* load entry icon */
icon = launcher_load_pixbuf (ld->treeview, ld->entry->icon, TREE_ICON_SIZE, TRUE);
icon = launcher_utility_load_pixbuf (gtk_widget_get_screen (ld->treeview), ld->entry->icon, LAUNCHER_TREE_ICON_SIZE);
/* set new icon */
gtk_list_store_set (ld->store, &iter,
COL_ICON, icon,
COLUMN_ICON, icon,
-1);
/* release icon */
@ -850,10 +836,10 @@ launcher_dialog_tree_update_row (LauncherDialog *ld,
break;
case COL_TEXT:
case COLUMN_NAME:
/* set new name */
gtk_list_store_set (ld->store, &iter,
COL_TEXT, ld->entry->name,
COLUMN_NAME, ld->entry->name,
-1);
break;
@ -925,9 +911,11 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
GtkTreeIter iter_a;
GtkTreeIter iter_b;
guint position;
gint list_length;
GList *li;
GdkPixbuf *icon = NULL;
LauncherEntry *entry;
gboolean update_icon = FALSE;
/* get the selected items in the treeview */
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (ld->treeview));
@ -945,9 +933,9 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* position of the item in the list */
position = gtk_tree_path_get_indices (path)[0];
/* check if we need to update the icon button image*/
/* check if we need to update the icon button image */
if (position == 1)
ld->launcher->icon_update_required = TRUE;
update_icon = TRUE;
/* get previous path */
if (G_LIKELY (gtk_tree_path_prev (path)))
@ -960,7 +948,7 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* swap items in the list */
li = g_list_nth (ld->launcher->entries, position);
launcher_g_list_swap (li, li->prev);
launcher_dialog_g_list_swap (li, li->prev);
}
/* release the path */
@ -979,7 +967,7 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* check if we need to update the icon button image*/
if (position == 0)
ld->launcher->icon_update_required = TRUE;
update_icon = TRUE;
/* get next item in the list */
gtk_tree_path_next (path);
@ -992,7 +980,7 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* swap items in the list */
li = g_list_nth (ld->launcher->entries, position);
launcher_g_list_swap (li, li->next);
launcher_dialog_g_list_swap (li, li->next);
}
/* release the path */
@ -1004,16 +992,16 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
else if (button == ld->add)
{
/* create new entry */
entry = launcher_new_entry ();
entry = launcher_entry_new ();
/* load new launcher icon */
icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE);
icon = launcher_utility_load_pixbuf (gtk_widget_get_screen (ld->treeview), entry->icon, LAUNCHER_TREE_ICON_SIZE);
/* append new entry */
gtk_list_store_insert_after (ld->store, &iter_b, &iter_a);
gtk_list_store_set (ld->store, &iter_b,
COL_ICON, icon,
COL_TEXT, entry->name,
COLUMN_ICON, icon,
COLUMN_NAME, entry->name,
-1);
/* release the pixbuf */
@ -1036,6 +1024,9 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* cleanup */
gtk_tree_path_free (path);
/* allow to set the arrow position */
gtk_widget_set_sensitive (ld->arrow_position, TRUE);
}
else if (button == ld->remove)
{
@ -1047,13 +1038,13 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* check if we need to update the icon button image*/
if (position == 0)
ld->launcher->icon_update_required = TRUE;
update_icon = TRUE;
/* lock */
ld->updating = TRUE;
/* remove active entry */
launcher_free_entry (ld->entry, ld->launcher);
launcher_entry_free (ld->entry, ld->launcher);
ld->entry = NULL;
/* remove row from store */
@ -1062,8 +1053,11 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* unlock */
ld->updating = FALSE;
/* list length */
list_length = g_list_length (ld->launcher->entries);
/* select previous item, if last item was removed */
if (position >= g_list_length (ld->launcher->entries))
if (position >= list_length)
gtk_tree_path_prev (path);
/* select the new item (also updates treeview buttons) */
@ -1071,10 +1065,28 @@ launcher_dialog_tree_button_clicked (GtkWidget *button,
/* cleanup */
gtk_tree_path_free (path);
/* allow to set the arrow position */
gtk_widget_set_sensitive (ld->arrow_position, list_length > 1);
/* don't allow menu arrows */
if (list_length == 1 && ld->launcher->arrow_position == LAUNCHER_ARROW_INSIDE_BUTTON)
gtk_combo_box_set_active (GTK_COMBO_BOX (ld->arrow_position), LAUNCHER_ARROW_DEFAULT);
}
/* update panel */
launcher_dialog_update_panel (ld);
launcher_plugin_rebuild (ld->launcher, update_icon);
}
static void
launcher_dialog_arrow_position_changed (GtkComboBox *combo,
LauncherDialog *ld)
{
ld->launcher->arrow_position = gtk_combo_box_get_active (combo);
launcher_plugin_rebuild (ld->launcher, TRUE);
}
@ -1281,25 +1293,27 @@ launcher_dialog_add_tree (LauncherDialog *ld)
/* create tree view */
ld->treeview = gtk_tree_view_new_with_model (GTK_TREE_MODEL (ld->store));
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (ld->treeview), FALSE);
gtk_tree_view_set_search_column (GTK_TREE_VIEW (ld->treeview), COLUMN_NAME);
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (ld->treeview), TRUE);
gtk_tree_view_set_fixed_height_mode (GTK_TREE_VIEW (ld->treeview), TRUE);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (ld->treeview), TRUE);
gtk_container_add (GTK_CONTAINER (scroll), ld->treeview);
g_signal_connect_swapped (G_OBJECT (ld->treeview), "destroy",
G_CALLBACK (launcher_dialog_tree_free_store), ld);
/* create columns and cell renders */
column = gtk_tree_view_column_new ();
gtk_tree_view_column_set_expand (column, TRUE);
gtk_tree_view_column_set_resizable (column, FALSE);
gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED);
gtk_tree_view_append_column (GTK_TREE_VIEW (ld->treeview), column);
renderer = gtk_cell_renderer_pixbuf_new();
gtk_cell_renderer_set_fixed_size (renderer, LAUNCHER_TREE_ICON_SIZE, LAUNCHER_TREE_ICON_SIZE);
gtk_tree_view_column_pack_start (column, renderer, FALSE);
gtk_tree_view_column_set_attributes (column, renderer, "pixbuf", COL_ICON, NULL);
gtk_tree_view_column_set_attributes (column, renderer, "pixbuf", COLUMN_ICON, NULL);
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_column_pack_start (column, renderer, TRUE);
gtk_tree_view_column_set_attributes (column, renderer, "text", COL_TEXT, NULL);
gtk_tree_view_column_set_attributes (column, renderer, "text", COLUMN_NAME, NULL);
g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
/* set selection change signal */
@ -1316,14 +1330,13 @@ launcher_dialog_add_tree (LauncherDialog *ld)
if (G_LIKELY (entry && entry->name))
{
/* load icon */
icon = launcher_load_pixbuf (ld->treeview, entry->icon, TREE_ICON_SIZE, TRUE);
icon = launcher_utility_load_pixbuf (gtk_widget_get_screen (ld->treeview), entry->icon, LAUNCHER_TREE_ICON_SIZE);
/* create new row and add the data */
gtk_list_store_append (ld->store, &iter);
gtk_list_store_set (ld->store, &iter,
COL_ICON, icon,
COL_TEXT, entry->name,
-1);
COLUMN_ICON, icon,
COLUMN_NAME, entry->name, -1);
/* release the pixbuf */
if (G_LIKELY (icon))
@ -1416,9 +1429,11 @@ launcher_dialog_add_tree_buttons (LauncherDialog *ld)
**/
static void
launcher_dialog_response (GtkWidget *dialog,
gint response,
LauncherDialog *ld)
gint response,
LauncherDialog *ld)
{
LauncherPlugin *launcher = ld->launcher;
/* hide the dialog */
gtk_widget_hide (dialog);
@ -1426,43 +1441,42 @@ launcher_dialog_response (GtkWidget *dialog,
ld->updating = TRUE;
ld->entry = NULL;
/* remove link */
g_object_set_data (G_OBJECT (ld->launcher->plugin), "dialog", NULL);
/* cleanup the store */
gtk_list_store_clear (ld->store);
g_object_unref (G_OBJECT (ld->store));
/* the launcher dialog dataS */
g_object_set_data (G_OBJECT (launcher->panel_plugin), I_("launcher-dialog"), NULL);
/* destroy the dialog */
gtk_widget_destroy (dialog);
/* unlock plugin menu (do this before writing -> see hack in write function) */
xfce_panel_plugin_unblock_menu (ld->launcher->plugin);
/* revert settings made */
if (response == GTK_RESPONSE_CANCEL)
{
/* remove all entries from the list */
g_list_foreach (ld->launcher->entries,
(GFunc) launcher_free_entry, ld->launcher);
/* unlock plugin menu */
xfce_panel_plugin_unblock_menu (launcher->panel_plugin);
/* read last saved settings */
launcher_read (ld->launcher);
/* restore move first */
launcher->move_first = ld->stored_move_first;
/* if this is a newly created item, there is no saved data yet */
if (G_UNLIKELY (g_list_length (ld->launcher->entries) == 0))
{
ld->launcher->entries = g_list_append (ld->launcher->entries,
launcher_new_entry ());
}
/* allow saving again */
launcher->plugin_can_save = TRUE;
/* update the panel again */
launcher_dialog_update_panel (ld);
}
else /* save changes */
if (response == GTK_RESPONSE_OK)
{
/* write new settings */
launcher_write (ld->launcher);
launcher_plugin_save (launcher);
}
else /* revert changes */
{
/* remove all the entries */
g_list_foreach (launcher->entries, (GFunc) launcher_entry_free, launcher);
/* enable/disable auto sort again */
launcher_set_move_first (ld->launcher->move_first);
/* read the last saved settings */
launcher_plugin_read (launcher);
/* add new item if there are no entries yet */
if (G_UNLIKELY (g_list_length (launcher->entries) == 0))
launcher->entries = g_list_append (launcher->entries, launcher_entry_new ());
}
/* free the panel structure */
panel_slice_free (LauncherDialog, ld);
@ -1476,28 +1490,26 @@ launcher_dialog_show (LauncherPlugin *launcher)
LauncherDialog *ld;
GtkWidget *dialog;
GtkWidget *dialog_vbox;
GtkWidget *paned, *vbox;
GtkWidget *widget;
GtkWidget *paned, *vbox, *hbox;
GtkWidget *widget, *label, *combo;
GtkTreePath *path;
/* create new structure */
ld = panel_slice_new0 (LauncherDialog);
/* init */
ld->launcher = launcher;
ld->entry = g_list_first (launcher->entries)->data;
/* get first entry */
if (G_UNLIKELY (g_list_length (launcher->entries) == 0))
{
launcher->entries = g_list_append (launcher->entries,
launcher_new_entry ());
}
ld->entry = launcher->entries->data;
/* prevent saving to be able to use the cancel button */
launcher->plugin_can_save = FALSE;
/* lock right-click plugin menu */
xfce_panel_plugin_block_menu (launcher->plugin);
xfce_panel_plugin_block_menu (launcher->panel_plugin);
/* disable the auto sort of the list, while working in properties */
launcher_set_move_first (FALSE);
ld->stored_move_first = launcher->move_first;
launcher->move_first = FALSE;
/* create new dialog */
dialog = xfce_titled_dialog_new_with_buttons (_("Program Launcher"),
@ -1506,16 +1518,13 @@ launcher_dialog_show (LauncherPlugin *launcher)
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_OK,
NULL);
gtk_window_set_screen (GTK_WINDOW (dialog),
gtk_widget_get_screen (GTK_WIDGET (launcher->plugin)));
gtk_window_set_screen (GTK_WINDOW (dialog), gtk_widget_get_screen (GTK_WIDGET (launcher->panel_plugin)));
gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
gtk_window_set_icon_name (GTK_WINDOW (dialog), "xfce4-settings");
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
/* connect dialog to plugin, so we can destroy it when plugin is closed */
g_object_set_data (G_OBJECT (ld->launcher->plugin), "dialog", dialog);
g_object_set_data (G_OBJECT (ld->launcher->panel_plugin), "dialog", dialog);
dialog_vbox = GTK_DIALOG (dialog)->vbox;
@ -1527,6 +1536,27 @@ launcher_dialog_show (LauncherPlugin *launcher)
vbox = gtk_vbox_new (FALSE, BORDER);
gtk_paned_pack1 (GTK_PANED (paned), vbox, FALSE, FALSE);
/* arrow button position */
hbox = gtk_hbox_new (FALSE, BORDER);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
label = gtk_label_new_with_mnemonic (_("A_rrow:"));
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
ld->arrow_position = combo = gtk_combo_box_new_text ();
gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Default"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Left"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Right"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Top"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Bottom"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Inside Button"));
gtk_widget_set_sensitive (combo, g_list_length (launcher->entries) > 1);
gtk_combo_box_set_active (GTK_COMBO_BOX (combo), launcher->arrow_position);
g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (launcher_dialog_arrow_position_changed), ld);
gtk_widget_show (combo);
/* add the entries list */
widget = launcher_dialog_add_tree (ld);
gtk_box_pack_start (GTK_BOX (vbox), widget, TRUE, TRUE, 0);

2
plugins/launcher/launcher-dialog.h

@ -21,6 +21,6 @@
#ifndef __XFCE_PANEL_LAUNCHER_DIALOG_H__
#define __XFCE_PANEL_LAUNCHER_DIALOG_H__
void launcher_dialog_show (LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_dialog_show (LauncherPlugin *launcher) G_GNUC_INTERNAL;
#endif /* !__XFCE_PANEL_LAUNCHER_DIALOG_H__ */

48
plugins/launcher/launcher-exec.c

@ -20,20 +20,22 @@
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#ifdef HAVE_MEMORY_H
#include <memory.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#ifdef HAVE_MEMORY_H
#include <memory.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifndef WAIT_ANY
@ -154,7 +156,7 @@ launcher_exec_startup_timeout (gpointer data)
elapsed = (((gdouble) now.tv_sec - tv_sec) * G_USEC_PER_SEC + (now.tv_usec - tv_usec)) / 1000.0;
/* check if the timeout was reached */
if (elapsed >= STARTUP_TIMEOUT)
if (elapsed >= LAUNCHER_STARTUP_TIMEOUT)
{
/* abort the startup notification */
sn_launcher_context_complete (startup_data->sn_launcher);
@ -163,7 +165,7 @@ launcher_exec_startup_timeout (gpointer data)
}
/* keep the startup timeout if not elapsed */
return (elapsed < STARTUP_TIMEOUT);
return (elapsed < LAUNCHER_STARTUP_TIMEOUT);
}
@ -211,7 +213,7 @@ launcher_exec_startup_watch (GPid pid,
{
/* get the child process state without hanging */
ret = waitpid (WAIT_ANY, NULL, WNOHANG);
/* exit if there is nothing to wait for */
if (ret == 0 || ret < 0)
break;
@ -487,7 +489,7 @@ launcher_exec_on_screen (GdkScreen *screen,
/* schedule a startup notification timeout */
startup_data = panel_slice_new (LauncherStartupData);
startup_data->sn_launcher = sn_launcher;
startup_data->timeout_id = g_timeout_add_full (G_PRIORITY_LOW, STARTUP_TIMEOUT,
startup_data->timeout_id = g_timeout_add_full (G_PRIORITY_LOW, LAUNCHER_STARTUP_TIMEOUT,
launcher_exec_startup_timeout,
startup_data, launcher_exec_startup_timeout_destroy);
startup_data->watch_id = g_child_watch_add_full (G_PRIORITY_LOW, pid, launcher_exec_startup_watch,
@ -547,7 +549,7 @@ launcher_execute (GdkScreen *screen,
screen = gdk_screen_get_default ();
/* maybe no command have been filed yet */
if (G_UNLIKELY (entry->exec == NULL))
if (G_UNLIKELY (entry->exec == NULL || *entry->exec == '\0'))
return;
/* check if the launcher supports (and needs) multiple instances */
@ -583,13 +585,9 @@ launcher_execute_from_clipboard (GdkScreen *screen,
{
GtkClipboard *clipboard;
gchar *text = NULL;
GSList *file_list = NULL;
GSList *filenames;
GtkSelectionData selection_data;
/* maybe no command have been filed yet */
if (G_UNLIKELY (entry->exec == NULL))
return;
/* get the clipboard */
clipboard = gtk_clipboard_get (GDK_SELECTION_PRIMARY);
@ -605,26 +603,26 @@ launcher_execute_from_clipboard (GdkScreen *screen,
/* get clipboard text */
if (G_LIKELY (clipboard))
text = gtk_clipboard_wait_for_text (clipboard);
text = gtk_clipboard_wait_for_text (clipboard);
}
if (G_LIKELY (text != NULL))
if (G_LIKELY (text))
{
/* create some fake selection data */
selection_data.data = (guchar *) text;
selection_data.length = strlen (text);
/* parse the filelist, this way we can handle 'copied' file from thunar */
file_list = launcher_file_list_from_selection (&selection_data);
filenames = launcher_utility_filenames_from_selection_data (&selection_data);
if (G_LIKELY (file_list != NULL))
if (G_LIKELY (filenames))
{
/* run the command with argument from clipboard */
launcher_exec_on_screen (screen, entry, file_list);
launcher_execute (screen, entry, filenames);
/* cleanup */
g_slist_free_all (file_list);
}
launcher_free_filenames (filenames);
}
/* cleanup */
g_free (text);

10
plugins/launcher/launcher-exec.h

@ -20,10 +20,10 @@
#ifndef __XFCE_PANEL_EXEC_H__
#define __XFCE_PANEL_EXEC_H__
void launcher_execute (GdkScreen *screen,
LauncherEntry *entry,
GSList *file_list) G_GNUC_INTERNAL;
void launcher_execute_from_clipboard (GdkScreen *screen,
LauncherEntry *entry) G_GNUC_INTERNAL;
void launcher_execute (GdkScreen *screen,
LauncherEntry *entry,
GSList *file_list) G_GNUC_INTERNAL;
void launcher_execute_from_clipboard (GdkScreen *screen,
LauncherEntry *entry) G_GNUC_INTERNAL;
#endif /* !__XFCE_PANEL_EXEC_H__ */

1704
plugins/launcher/launcher.c

File diff suppressed because it is too large

94
plugins/launcher/launcher.h

@ -25,16 +25,23 @@
#include <exo/exo.h>
#include <libxfce4panel/xfce-panel-plugin.h>
#define STARTUP_TIMEOUT (30 * 1000)
#define ARROW_WIDTH 16
#define MENU_ICON_SIZE 24
#define MENU_POPUP_DELAY 225
#define BORDER 8
#define TREE_ICON_SIZE 24
#define CHOOSER_ICON_SIZE 48
#define BORDER (8)
#define LAUNCHER_NEW_TOOLTIP_API (GTK_CHECK_VERSION (2,11,6))
#define LAUNCHER_ARROW_SIZE (16)
#define LAUNCHER_POPUP_DELAY (225)
#define LAUNCHER_TOOLTIP_SIZE (32)
#define LAUNCHER_MENU_SIZE (24)
#define LAUNCHER_STARTUP_TIMEOUT (30 * 1000)
#define LAUNCHER_TREE_ICON_SIZE (24)
#define LAUNCHER_CHOOSER_ICON_SIZE (48)
/* frequently used code */
#define launcher_free_filenames(list) G_STMT_START{ \
g_slist_foreach (list, (GFunc) g_free, NULL); \
g_slist_free (list); \
}G_STMT_END
#define g_free_null(mem) g_free (mem); mem = NULL
#define g_slist_free_all(list) g_slist_foreach (list, (GFunc) g_free, NULL); g_slist_free (list)
typedef struct _LauncherEntry LauncherEntry;
typedef struct _LauncherPlugin LauncherPlugin;
@ -55,26 +62,43 @@ struct _LauncherEntry
struct _LauncherPlugin
{
/* globals */
XfcePanelPlugin *plugin;
GtkTooltips *tips;
GList *entries;
/* panel plugin */
XfcePanelPlugin *panel_plugin;
/* cpu saver */
guint icon_update_required : 1;
/* whether saving is allowed */
guint plugin_can_save : 1;
gint image_size;
/* list of launcher entries */
GList *entries;
/* panel widgets */
GtkWidget *arrowbutton;
GtkWidget *iconbutton;
GtkWidget *box;
GtkWidget *icon_button;
GtkWidget *arrow_button;
GtkWidget *image;
GtkWidget *menu;
#if !LAUNCHER_NEW_TOOLTIP_API
GtkTooltips *tips;
#endif
/* global settings */
guint move_first : 1;
/* timeouts */
/* event source ids */
guint popup_timeout_id;
guint theme_timeout_id;
/* settings */
guint move_first : 1;
guint arrow_position;
};
enum
{
LAUNCHER_ARROW_DEFAULT = 0,
LAUNCHER_ARROW_LEFT,
LAUNCHER_ARROW_RIGHT,
LAUNCHER_ARROW_TOP,
LAUNCHER_ARROW_BOTTOM,
LAUNCHER_ARROW_INSIDE_BUTTON
};
/* target types for dropping in the launcher plugin */
@ -83,20 +107,18 @@ static const GtkTargetEntry drop_targets[] =
{ "text/uri-list", 0, 0, },
};
void launcher_g_list_swap (GList *li_a,
GList *li_b) G_GNUC_INTERNAL;
GdkPixbuf *launcher_load_pixbuf (GtkWidget *widget,
const gchar *icon_name,
guint size,
gboolean fallback) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
void launcher_set_move_first (gboolean activate) G_GNUC_INTERNAL;
GSList *launcher_file_list_from_selection (GtkSelectionData *selection_data) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
gboolean launcher_button_update (LauncherPlugin *launcher) G_GNUC_INTERNAL;
gboolean launcher_menu_prepare (LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_read (LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_write (LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_free_entry (LauncherEntry *entry,
LauncherPlugin *launcher) G_GNUC_INTERNAL;
LauncherEntry *launcher_new_entry (void) G_GNUC_INTERNAL G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT;
GSList *launcher_utility_filenames_from_selection_data (GtkSelectionData *selection_data) G_GNUC_MALLOC G_GNUC_INTERNAL;
GdkPixbuf *launcher_utility_load_pixbuf (GdkScreen *screen,
const gchar *name,
guint size) G_GNUC_MALLOC G_GNUC_INTERNAL;
LauncherEntry *launcher_entry_new (void) G_GNUC_MALLOC G_GNUC_INTERNAL;
void launcher_entry_free (LauncherEntry *entry,
LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_plugin_rebuild (LauncherPlugin *launcher,
gboolean update_icon) G_GNUC_INTERNAL;
void launcher_plugin_read (LauncherPlugin *launcher) G_GNUC_INTERNAL;
void launcher_plugin_save (LauncherPlugin *launcher) G_GNUC_INTERNAL;
#endif /* !__XFCE_PANEL_LAUNCHER_H__ */

222
plugins/systray/xfce-tray-widget.c

@ -51,21 +51,21 @@ static void xfce_tray_widget_finalize (GObject *object
static void xfce_tray_widget_style_set (GtkWidget *widget,
GtkStyle *previous_style);
static void xfce_tray_widget_map (GtkWidget *widget);
static gint xfce_tray_widget_expose_event (GtkWidget *widget,
static gint xfce_tray_widget_expose_event (GtkWidget *widget,
GdkEventExpose *event);
static void xfce_tray_widget_button_set_arrow (XfceTrayWidget *tray);
static void xfce_tray_widget_button_clicked (GtkToggleButton *button,
static void xfce_tray_widget_button_clicked (GtkToggleButton *button,
XfceTrayWidget *tray);
static gboolean xfce_tray_widget_button_press_event (GtkWidget *widget,
GdkEventButton *event,
GtkWidget *tray);
static gint xfce_tray_widget_compare_function (gconstpointer a,
static gint xfce_tray_widget_compare_function (gconstpointer a,
gconstpointer b);
static void xfce_tray_widget_icon_added (XfceTrayManager *manager,
static void xfce_tray_widget_icon_added (XfceTrayManager *manager,
GtkWidget *icon,
XfceTrayWidget *tray);
static void xfce_tray_widget_icon_removed (XfceTrayManager *manager,
GtkWidget *icon,
static void xfce_tray_widget_icon_removed (XfceTrayManager *manager,
GtkWidget *icon,
XfceTrayWidget *tray);
static gint xfce_tray_widget_size_request (XfceTrayWidget *tray,
gint size);
@ -83,25 +83,25 @@ struct _XfceTrayWidgetClass
struct _XfceTrayWidget
{
GtkContainer __parent__;
/* tray manager of this tray */
XfceTrayManager *manager;
/* arrow toggle button */
GtkWidget *button;
/* all the icons packed in this box */
GSList *childeren;
/* counters for the icons in the list */
guint n_childeren;
guint n_hidden_childeren;
/* whether hidden icons are visible */
guint all_visible : 1;
guint idle_redraw_id;
/* properties */
gint size;
GtkArrowType arrow_position;
@ -110,7 +110,7 @@ struct _XfceTrayWidget
enum
{
TRAY_SIZE_CHANGED,
LAST_SIGNAL
LAST_SIGNAL
};
@ -153,16 +153,16 @@ xfce_tray_widget_class_init (XfceTrayWidgetClass *klass)
gobject_class = G_OBJECT_CLASS (klass);
gobject_class->finalize = xfce_tray_widget_finalize;
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->style_set = xfce_tray_widget_style_set;
gtkwidget_class->expose_event = xfce_tray_widget_expose_event;
gtkwidget_class->map = xfce_tray_widget_map;
gtkcontainer_class = GTK_CONTAINER_CLASS (klass);
gtkcontainer_class->add = NULL;
gtkcontainer_class->remove = NULL;
xfce_tray_widget_signals[TRAY_SIZE_CHANGED] =
g_signal_new (I_("tray-size-changed"),
G_OBJECT_CLASS_TYPE (klass),
@ -180,7 +180,7 @@ xfce_tray_widget_init (XfceTrayWidget *tray)
{
/* for realize */
GTK_WIDGET_SET_FLAGS (tray, GTK_NO_WINDOW);
/* initialize */
tray->childeren = NULL;
tray->button = NULL;
@ -199,17 +199,17 @@ static void
xfce_tray_widget_finalize (GObject *object)
{
XfceTrayWidget *tray = XFCE_TRAY_WIDGET (object);
/* stop idle timeout */
if (tray->idle_redraw_id != 0)
g_source_remove (tray->idle_redraw_id);
/* free the child list */
g_slist_free (tray->childeren);
/* release the manager */
g_object_unref (G_OBJECT (tray->manager));
G_OBJECT_CLASS (xfce_tray_widget_parent_class)->finalize (object);
}
@ -220,10 +220,10 @@ xfce_tray_widget_expose_event (GtkWidget *widget,
GdkEventExpose *event)
{
XfceTrayWidget *tray = XFCE_TRAY_WIDGET (widget);
/* expose the button, because it doesn't have its own window */
gtk_container_propagate_expose (GTK_CONTAINER (widget), tray->button, event);
return FALSE;
}
@ -235,15 +235,15 @@ xfce_tray_widget_style_set (GtkWidget *widget,
{
XfceTrayWidget *tray = XFCE_TRAY_WIDGET (widget);
GSList *li;
/* set the button style */
if (tray->button)
gtk_widget_set_style (tray->button, widget->style);
/* send the style to all the childeren */
for (li = tray->childeren; li != NULL; li = li->next)
gtk_widget_set_style (GTK_WIDGET (li->data), widget->style);
/* invoke the parent */
GTK_WIDGET_CLASS (xfce_tray_widget_parent_class)->style_set (widget, previous_style);
}
@ -254,10 +254,10 @@ static void
xfce_tray_widget_map (GtkWidget *widget)
{
XfceTrayWidget *tray = XFCE_TRAY_WIDGET (widget);
/* we've been mapped */
GTK_WIDGET_SET_FLAGS (widget, GTK_MAPPED);
/* create the arrow button (needs a mapped tray before the parent is set) */
tray->button = xfce_arrow_button_new (tray->arrow_position);
GTK_WIDGET_UNSET_FLAGS (tray->button, GTK_CAN_DEFAULT | GTK_CAN_FOCUS);
@ -274,10 +274,10 @@ static void
xfce_tray_widget_button_set_arrow (XfceTrayWidget *tray)
{
GtkArrowType arrow_type;
/* get the origional arrow type */
arrow_type = tray->arrow_position;
/* invert the arrow direction when the button is toggled */
if (tray->all_visible)
{
@ -286,23 +286,23 @@ xfce_tray_widget_button_set_arrow (XfceTrayWidget *tray)
else
arrow_type = (arrow_type == GTK_ARROW_UP ? GTK_ARROW_DOWN : GTK_ARROW_UP);
}
/* set the arrow type */
xfce_arrow_button_set_arrow_type (XFCE_ARROW_BUTTON (tray->button), arrow_type);
}
static void
xfce_tray_widget_button_clicked (GtkToggleButton *button,
static void
xfce_tray_widget_button_clicked (GtkToggleButton *button,
XfceTrayWidget *tray)
{
/* set the new visible state */
tray->all_visible = gtk_toggle_button_get_active (button);
/* set the button arrow */
xfce_tray_widget_button_set_arrow (tray);
/* update the tray */
xfce_tray_widget_redraw (tray);
}
@ -316,7 +316,7 @@ xfce_tray_widget_button_press_event (GtkWidget *widget,
{
/* send the event to the tray for the panel menu */
gtk_widget_event (tray, (GdkEvent *)event);
return FALSE;
}
@ -328,23 +328,23 @@ xfce_tray_widget_compare_function (gconstpointer a,
{
gboolean a_hidden, b_hidden;
const gchar *a_wmname, *b_wmname;
/* get hidden state */
a_hidden = xfce_tray_manager_application_get_hidden (GTK_WIDGET (a));
b_hidden = xfce_tray_manager_application_get_hidden (GTK_WIDGET (b));
/* sort hidden icons before visible ones */
if (a_hidden != b_hidden)
return (a_hidden ? -1 : 1);
/* get the window names */
a_wmname = xfce_tray_manager_application_get_name (GTK_WIDGET (a));
b_wmname = xfce_tray_manager_application_get_name (GTK_WIDGET (b));
/* return when one of them has no name */
if (G_UNLIKELY (!a_wmname || !b_wmname))
return (a_wmname == b_wmname ? 0 : (!a_wmname ? -1 : 1));
return strcmp (a_wmname, b_wmname);
}
@ -356,30 +356,30 @@ xfce_tray_widget_icon_added (XfceTrayManager *manager,
XfceTrayWidget *tray)
{
gboolean hidden;
g_return_if_fail (XFCE_IS_TRAY_MANAGER (manager));
g_return_if_fail (XFCE_IS_TRAY_WIDGET (tray));
g_return_if_fail (GTK_IS_WIDGET (icon));
/* add the icon to the list */
tray->childeren = g_slist_insert_sorted (tray->childeren, icon, xfce_tray_widget_compare_function);
/* increase counter */
tray->n_childeren++;
/* whether this icon could be hidden */
hidden = xfce_tray_manager_application_get_hidden (icon);
/* increase hidden counter */
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);
}
@ -394,24 +394,24 @@ xfce_tray_widget_icon_removed (XfceTrayManager *manager,
g_return_if_fail (XFCE_IS_TRAY_MANAGER (manager));
g_return_if_fail (XFCE_IS_TRAY_WIDGET (tray));
g_return_if_fail (GTK_IS_WIDGET (icon));
/* decrease counter */
tray->n_childeren--;
/* remove the child from the list */
tray->childeren = g_slist_remove (tray->childeren, icon);
/* handle hidden icons */
if (xfce_tray_manager_application_get_hidden (icon))
{
/* decrease hidden counter */
tray->n_hidden_childeren--;
/* collapse the hidden button */
if (tray->n_hidden_childeren == 0)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tray->button), FALSE);
}
/* update the tray */
xfce_tray_widget_redraw (tray);
}
@ -425,26 +425,26 @@ xfce_tray_widget_new_for_screen (GdkScreen *screen,
{
XfceTrayWidget *tray = NULL;
XfceTrayManager *manager;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
/* new tray manager */
manager = xfce_tray_manager_new ();