Browse Source

Further cleanup: only create popup widgets when actually used. Start xfcalendar from the clock or send it a client message if already running

(Old svn revision: 3918)
upstream/xfce4-panel-4.10.1
Jasper Huijsmans 20 years ago
parent
commit
c0d2e0cd8a
  1. 12
      AUTHORS
  2. 15
      panel/controls.c
  3. 4
      panel/controls.h
  4. 42
      panel/controls_dialog.c
  5. 166
      panel/groups.c
  6. 6
      panel/groups.h
  7. 4
      panel/icons.c
  8. 44
      panel/item.c
  9. 365
      panel/item_dialog.c
  10. 16
      panel/item_dialog.h
  11. 44
      panel/main.c
  12. 240
      panel/panel.c
  13. 5
      panel/panel.h
  14. 62
      panel/popup.c
  15. 60
      panel/xfce_support.c
  16. 77
      plugins/clock/clock.c
  17. BIN
      po/ca.gmo
  18. 241
      po/ca.po
  19. BIN
      po/cs.gmo
  20. 237
      po/cs.po
  21. BIN
      po/de.gmo
  22. 237
      po/de.po
  23. BIN
      po/es.gmo
  24. 241
      po/es.po
  25. BIN
      po/es_MX.gmo
  26. 241
      po/es_MX.po
  27. BIN
      po/fi.gmo
  28. 241
      po/fi.po
  29. BIN
      po/fr.gmo
  30. 241
      po/fr.po
  31. BIN
      po/hi.gmo
  32. 241
      po/hi.po
  33. BIN
      po/hu.gmo
  34. 237
      po/hu.po
  35. BIN
      po/it.gmo
  36. 237
      po/it.po
  37. BIN
      po/ja.gmo
  38. 241
      po/ja.po
  39. BIN
      po/ko.gmo
  40. 317
      po/ko.po
  41. BIN
      po/lt.gmo
  42. 237
      po/lt.po
  43. BIN
      po/ms.gmo
  44. 237
      po/ms.po
  45. BIN
      po/nl.gmo
  46. 247
      po/nl.po
  47. BIN
      po/pl.gmo
  48. 241
      po/pl.po
  49. BIN
      po/pt_PT.gmo
  50. 237
      po/pt_PT.po
  51. BIN
      po/ru.gmo
  52. 237
      po/ru.po
  53. BIN
      po/sv.gmo
  54. 228
      po/sv.po
  55. BIN
      po/ta.gmo
  56. 253
      po/ta.po
  57. BIN
      po/tr.gmo
  58. 237
      po/tr.po
  59. BIN
      po/vi.gmo
  60. 241
      po/vi.po
  61. 174
      po/xfce4-panel.pot
  62. BIN
      po/zh_CN.gmo
  63. 239
      po/zh_CN.po
  64. BIN
      po/zh_TW.gmo
  65. 237
      po/zh_TW.po

12
AUTHORS

@ -1,11 +1,13 @@
Olivier Fourdan <fourdan@xfce.org>
Jasper Huijsmans <huysmans@users.sourceforge.net>
Olivier Fourdan <fourdan@xfce.org>
Edscott Wilson Garcia <edscott@imp.mx>
Biju Chacko <botsie@myrealbox.com>
Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
Bernhard Walle <Bernhard.Walle@gmx.de>
Eduard Rocatello <master@spine-group.org>
Erik Touve <etouve@earthlink.net>
Jens Luedicke <jens@irs-net.com>
Martin Loschwitz <madkiss@users.sourceforge.net>
Xavier Maillard <zedek@fxgsproject.org>
Michael Mosier <michael@spyonit.com>
Erik Touve <etouve@earthlink.net>
Benedikt Meurer <benedikt.meurer@unix-ag.uni-siegen.de>
Bernhard Walle <Bernhard.Walle@gmx.de>
Oliver M. Bolzer <oliver@fakeroot.net>
Xavier Maillard <zedek@fxgsproject.org>

15
panel/controls.c

@ -268,7 +268,7 @@ remove_control (void)
pp = groups_get_popup (popup_control->index);
if (!(popup_control->with_popup) || pp->items == NULL ||
if (!(popup_control->with_popup) || !pp || pp->items == NULL ||
confirm (_("Removing an item will also remove its popup menu.\n\n"
"Do you want to remove the item?"),
GTK_STOCK_REMOVE, NULL))
@ -362,6 +362,7 @@ get_controls_menu_entries (GtkItemFactoryEntry ** entries, const char *base)
li; li = li->next, entry++, i++)
{
ControlClass *cc = li->data;
entry->path = g_strconcat (base, "/", cc->caption, NULL);
entry->callback = add_control;
entry->callback_action = i;
@ -496,7 +497,7 @@ control_new (int index)
Control *control = g_new0 (Control, 1);
control->index = index;
control->with_popup = TRUE;
control->with_popup = FALSE;
control->base = gtk_event_box_new ();
gtk_widget_show (control->base);
@ -600,12 +601,12 @@ control_set_from_xml (Control * control, xmlNodePtr node)
create_control (control, id, filename);
g_free (filename);
/* hide popup? also check if added to the panel */
if (control->with_popup && control->base->parent)
groups_show_popup (control->index, TRUE);
/* allow the control to read its configuration */
control_read_config (control, node);
/* hide popup? also check if added to the panel */
if (!control->with_popup && control->base->parent)
groups_show_popup (control->index, FALSE);
}
void
@ -630,7 +631,7 @@ control_write_xml (Control * control, xmlNodePtr parent)
/* options dialog */
void
control_create_options (Control * control, GtkContainer * container,
GtkWidget * done)
GtkWidget * done)
{
ControlClass *cc = control->cclass;

4
panel/controls.h

@ -47,7 +47,7 @@ struct _ControlClass
GCallback callback, gpointer data);
void (*create_options) (Control * control, GtkContainer * container,
GtkWidget * done);
GtkWidget * done);
/* global preferences */
void (*set_orientation) (Control * control, int orientation);
@ -95,7 +95,7 @@ void control_unpack (Control * control);
void control_attach_callbacks (Control * control);
void control_create_options (Control * control, GtkContainer * container,
GtkWidget * done);
GtkWidget * done);
/* global settings */
void control_set_settings (Control * control);

42
panel/controls_dialog.c

@ -40,8 +40,8 @@
#include "popup.h"
#include "settings.h"
static GtkWidget *controlsdialog = NULL; /* keep track of it for
signal handling */
static GtkWidget *controlsdialog = NULL; /* keep track of it for
signal handling */
static GSList *control_list = NULL; /* list of available controls */
@ -116,7 +116,7 @@ clear_control_list (void)
control_list = NULL;
}
#if 0 /* NEVER USED */
#if 0 /* NEVER USED */
/* Type options menu
* -----------------
*/
@ -148,7 +148,7 @@ type_option_changed (GtkOptionMenu * om)
}
#endif
#if 0 /* NEVER USED */
#if 0 /* NEVER USED */
static GtkWidget *
create_type_option_menu (void)
{
@ -246,18 +246,20 @@ controls_dialog (Control * control)
/* Keep track of the panel container */
container = control->base->parent;
controlsdialog = dlg = gtk_dialog_new();
controlsdialog = dlg = gtk_dialog_new ();
dlg_ptr = &controlsdialog;
g_object_add_weak_pointer(G_OBJECT(dlg), (gpointer*)dlg_ptr);
gtk_window_set_title(GTK_WINDOW(dlg), _("Change item"));
g_object_add_weak_pointer (G_OBJECT (dlg), (gpointer *) dlg_ptr);
gtk_window_set_title (GTK_WINDOW (dlg), _("Change item"));
button = gtk_button_new_from_stock (GTK_STOCK_REMOVE);
gtk_widget_show (button);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg), button, RESPONSE_REMOVE);
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_button_box_set_child_secondary(GTK_BUTTON_BOX (GTK_DIALOG(dlg)->action_area), button, TRUE);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX
(GTK_DIALOG (dlg)->action_area),
button, TRUE);
done = button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
gtk_widget_show (button);
@ -268,7 +270,7 @@ controls_dialog (Control * control)
gtk_button_box_set_layout (GTK_BUTTON_BOX (GTK_DIALOG(dlg)->action_area),
GTK_BUTTONBOX_END);
*/
main_vbox = GTK_DIALOG (dlg)->vbox;
vbox = gtk_vbox_new (FALSE, 7);
@ -292,7 +294,7 @@ controls_dialog (Control * control)
if (settings.num_groups > 1)
{
pos_spin = gtk_spin_button_new_with_range (1, settings.num_groups, 1);
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin),
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin),
backup_index + 1);
g_signal_connect (pos_spin, "value-changed", G_CALLBACK (pos_changed),
@ -301,10 +303,11 @@ controls_dialog (Control * control)
else
{
char postext[2];
sprintf(postext, "%d", 1);
pos_spin = gtk_label_new(postext);
sprintf (postext, "%d", 1);
pos_spin = gtk_label_new (postext);
}
gtk_widget_show (pos_spin);
gtk_box_pack_start (GTK_BOX (hbox), pos_spin, FALSE, FALSE, 0);
@ -326,7 +329,7 @@ controls_dialog (Control * control)
gtk_widget_grab_default (done);
gtk_widget_grab_focus (done);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
response = gtk_dialog_run (GTK_DIALOG (dlg));
if (response == RESPONSE_REMOVE)
@ -337,7 +340,7 @@ controls_dialog (Control * control)
popup = groups_get_popup (control->index);
if (!(control->with_popup) || popup->items == NULL ||
if (!(control->with_popup) || !popup || popup->items == NULL ||
confirm (_
("Removing an item will also remove its popup menu.\n\n"
"Do you want to remove the item?"),
@ -346,7 +349,7 @@ controls_dialog (Control * control)
break;
}
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
gtk_widget_show (dlg);
}
else
@ -368,9 +371,8 @@ controls_dialog (Control * control)
}
void
destroy_controls_dialog(void)
destroy_controls_dialog (void)
{
if (controlsdialog)
gtk_dialog_response(GTK_DIALOG(controlsdialog), GTK_RESPONSE_OK);
gtk_dialog_response (GTK_DIALOG (controlsdialog), GTK_RESPONSE_OK);
}

166
panel/groups.c

@ -39,8 +39,7 @@
#include "popup.h"
static GSList *group_list = NULL;
static GSList *removed_list = NULL;
static GtkArrowType popup_arrow_type = GTK_ARROW_UP;
static GtkBox *groupbox;
/* Panel group
@ -66,7 +65,7 @@ panel_group_arrange (PanelGroup * pg)
if (pg->box)
{
if (pg->popup)
if (pg->popup && pg->popup->button->parent)
panel_popup_unpack (pg->popup);
if (pg->control)
control_unpack (pg->control);
@ -170,9 +169,7 @@ groups_cleanup (void)
control_class_list_cleanup ();
g_slist_free (group_list);
g_slist_free (removed_list);
group_list = NULL;
removed_list = NULL;
}
void
@ -193,7 +190,7 @@ old_groups_set_from_xml (int side, xmlNodePtr node)
if (node)
node = node->children;
for (i = last_group; /*i < settings.num_groups ||*/ li || node; i++)
for (i = last_group; /*i < settings.num_groups || */ li || node; i++)
{
gboolean control_created = FALSE;
@ -211,7 +208,6 @@ old_groups_set_from_xml (int side, xmlNodePtr node)
group_list = g_slist_append (group_list, group);
group->popup = create_panel_popup ();
group->control = control_new (i);
panel_group_arrange (group);
@ -253,69 +249,47 @@ groups_set_from_xml (xmlNodePtr node)
{
xmlNodePtr child;
int i;
GSList *li;
PanelGroup *group;
li = group_list;
/* children are "Group" nodes */
if (node)
node = node->children;
DBG("expected number of panel items: %d", settings.num_groups);
for (i = 0; /* i < settings.num_groups || */ li || node; i++)
for (i = 0; node; i++, node = node->next)
{
gboolean control_created = FALSE;
if (li)
{
group = li->data;
}
else
{
group = create_panel_group (i);
panel_group_pack (group, groupbox);
group_list = g_slist_append (group_list, group);
group->popup = create_panel_popup ();
group = create_panel_group (i);
panel_group_pack (group, groupbox);
group_list = g_slist_append (group_list, group);
group->control = control_new (i);
group->control = control_new (i);
panel_group_arrange (group);
}
panel_group_arrange (group);
if (node)
for (child = node->children; child; child = child->next)
{
for (child = node->children; child; child = child->next)
/* create popup items and panel control */
if (xmlStrEqual (child->name, (const xmlChar *) "Popup"))
{
/* create popup items and panel control */
if (xmlStrEqual (child->name, (const xmlChar *) "Popup"))
{
panel_popup_set_from_xml (group->popup, child);
}
else if (xmlStrEqual
(child->name, (const xmlChar *) "Control"))
{
control_set_from_xml (group->control, child);
control_created = TRUE;
}
group->popup = create_panel_popup ();
panel_group_arrange (group);
gtk_widget_hide (group->popup->button);
panel_popup_set_from_xml (group->popup, child);
}
else if (xmlStrEqual
(child->name, (const xmlChar *) "Control"))
{
control_set_from_xml (group->control, child);
control_created = TRUE;
}
}
if (!control_created)
control_set_from_xml (group->control, NULL);
if (node)
node = node->next;
if (li)
li = li->next;
}
settings.num_groups = g_slist_length (group_list);
DBG("actual number of panel items: %d", settings.num_groups);
}
void
@ -333,7 +307,9 @@ groups_write_xml (xmlNodePtr root)
child = xmlNewTextChild (node, NULL, "Group", NULL);
panel_popup_write_xml (group->popup, child);
if (group->control->with_popup && group->popup)
panel_popup_write_xml (group->popup, child);
control_write_xml (group->control, child);
}
}
@ -488,10 +464,19 @@ groups_show_popup (int index, gboolean show)
li = g_slist_nth (group_list, index);
group = li->data;
if (show)
gtk_widget_show (group->popup->button);
else
gtk_widget_hide (group->popup->button);
if (show && group->control->with_popup && !group->popup)
{
group->popup = create_panel_popup ();
panel_group_arrange (group);
}
if (group->popup)
{
if (show)
gtk_widget_show (group->popup->button);
else
gtk_widget_hide (group->popup->button);
}
}
/* settings */
@ -568,12 +553,14 @@ groups_set_theme (const char *theme)
}
}
void
void
groups_set_arrow_direction (GtkArrowType type)
{
GSList *li;
PanelGroup *group;
popup_arrow_type = type;
for (li = group_list; li; li = li->next)
{
group = li->data;
@ -582,6 +569,12 @@ groups_set_arrow_direction (GtkArrowType type)
}
}
GtkArrowType
groups_get_arrow_direction (void)
{
return popup_arrow_type;
}
void
groups_add_control (int id, const char *filename, int index)
{
@ -597,8 +590,6 @@ groups_add_control (int id, const char *filename, int index)
panel_group_pack (group, groupbox);
group_list = g_slist_append (group_list, group);
group->popup = create_panel_popup ();
group->control = control_new (index);
create_control (group->control, id, filename);
@ -608,68 +599,11 @@ groups_add_control (int id, const char *filename, int index)
groups_move (len, index);
if (!group->control->with_popup)
{
group->popup = create_panel_popup ();
groups_show_popup (index, FALSE);
}
settings.num_groups++;
}
void
groups_set_num_groups (int n)
{
int i, len;
GSList *li;
PanelGroup *group = NULL;
len = g_slist_length (group_list);
/* nothing to do */
if (n == len)
return;
/* add group(s) */
if (n > len)
{
for (i = len; i < n; i++)
{
if (removed_list)
{
group = removed_list->data;
removed_list =
g_slist_delete_link (removed_list, removed_list);
panel_group_pack (group, groupbox);
group_list = g_slist_append (group_list, group);
panel_group_arrange (group);
settings.num_groups++;
}
else
{
groups_add_control (ICON, NULL, i);
}
gtk_widget_show (group->base);
}
return;
}
/* removing group(s) */
li = g_slist_nth (group_list, n);
for (i = n; i < len; i++)
{
GSList *li2;
group = li->data;
panel_group_unpack (group);
/* this sets the list to the next group */
li2 = li;
li = li->next;
group_list = g_slist_remove_link (group_list, li2);
removed_list = g_slist_prepend (removed_list, group);
settings.num_groups--;
}
}

6
panel/groups.h

@ -35,6 +35,7 @@ void groups_register_control (Control * control);
Control *groups_get_control (int index);
PanelPopup *groups_get_popup (int index);
void groups_add_control (int id, const char *filename, int index);
void groups_move (int from, int to);
void groups_remove (int index);
void groups_show_popup (int index, gboolean show);
@ -48,9 +49,6 @@ void groups_set_popup_position (int position);
void groups_set_theme (const char *theme);
void groups_set_arrow_direction (GtkArrowType type);
/* add/remove */
void groups_set_num_groups (int n);
void groups_add_control (int id, const char *filename, int index);
GtkArrowType groups_get_arrow_direction (void);
#endif /* __XFCE_GROUPS_H__ */

4
panel/icons.c

@ -34,8 +34,8 @@ const char *icon_names[NUM_ICONS];
/* icon themes */
static char *icon_suffix[] = {
"svg", /* librsvg provides a gdk_pixbuf loader for svg files */
"svg.gz", /* librsvg provides a gdk_pixbuf loader for svg files */
"svg", /* librsvg provides a gdk_pixbuf loader for svg files */
"svg.gz", /* librsvg provides a gdk_pixbuf loader for svg files */
"png",
"xpm",
NULL

44
panel/item.c

@ -83,10 +83,10 @@ item_click_cb (GtkButton * b, Item * item)
{
if (item->type == PANELITEM && popup_from_timeout)
return;
if (popup_timeout_id > 0)
{
g_source_remove(popup_timeout_id);
g_source_remove (popup_timeout_id);
popup_timeout_id = 0;
}
@ -166,17 +166,17 @@ menu_item_press (GtkButton * b, GdkEventButton * ev, Item * mi)
/* Panel item callbacks
* --------------------
*/
*/
static gboolean
popup_menu_timeout(Item * item)
popup_menu_timeout (Item * item)
{
GtkWidget *box;
GList *li;
popup_timeout_id = 0;
/* FIXME: items should know about their parent */
/* Explanantion of code below:
*
* For a panel item with menu we have a GtkBox containing a control
@ -190,25 +190,25 @@ popup_menu_timeout(Item * item)
* toggle button.
*
* There, that's it.
*/
box=item->button->parent->parent;
*/
box = item->button->parent->parent;
for (li = GTK_BOX(box)->children; li; li = li->next)
for (li = GTK_BOX (box)->children; li; li = li->next)
{
GtkWidget *w = ((GtkBoxChild*)li->data)->widget;
if (!GTK_IS_WIDGET(w))
GtkWidget *w = ((GtkBoxChild *) li->data)->widget;
if (!GTK_IS_WIDGET (w))
continue;
if (w != item->button->parent)
{
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)))
if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w)))
{
popup_from_timeout = TRUE;
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w), TRUE);
}
break;
}
}
@ -218,7 +218,7 @@ popup_menu_timeout(Item * item)
static gboolean
panel_item_press (GtkButton * b, GdkEventButton * ev, Item * item)
{
{
popup_from_timeout = FALSE;
if (!item->with_popup)
@ -226,8 +226,8 @@ panel_item_press (GtkButton * b, GdkEventButton * ev, Item * item)
if (ev->button == 1 && !(ev->state & GDK_SHIFT_MASK))
{
popup_timeout_id = g_timeout_add(400, (GSourceFunc)popup_menu_timeout,
item);
popup_timeout_id =
g_timeout_add (400, (GSourceFunc) popup_menu_timeout, item);
}
return FALSE;
@ -528,8 +528,8 @@ panel_item_new (void)
item_apply_config (pi);
g_signal_connect (pi->button, "clicked", G_CALLBACK (item_click_cb), pi);
g_signal_connect (pi->button, "button-press-event",
G_CALLBACK (panel_item_press), pi);
g_signal_connect (pi->button, "button-press-event",
G_CALLBACK (panel_item_press), pi);
dnd_set_drag_dest (pi->button);
g_signal_connect (pi->button, "drag-data-received",
@ -562,7 +562,6 @@ panel_item_read_config (Control * control, xmlNodePtr node)
item_read_config (pi, node);
item_apply_config (pi);
control->with_popup = pi->with_popup;
groups_show_popup (control->index, pi->with_popup);
}
@ -588,6 +587,7 @@ create_panel_item (Control * control)
{
Item *pi = panel_item_new ();
control->with_popup = TRUE;
gtk_container_add (GTK_CONTAINER (control->base), pi->button);
control->data = (gpointer) pi;

365
panel/item_dialog.c

@ -47,6 +47,16 @@
*/
static void item_apply_options (void);
static GtkWidget *create_icon_option_menu (void);
static GtkWidget *create_icon_option (GtkSizeGroup *);
static GtkWidget *create_command_option (GtkSizeGroup *);
static GtkWidget *create_caption_option (GtkSizeGroup *);
static GtkWidget *create_tooltip_option (GtkSizeGroup *);
static GtkWidget *create_position_option (void);
static GtkWidget *create_item_options_box (void);
static GtkWidget *create_icon_preview_frame (void);
static GtkWidget *create_menu_item_dialog (Item *);
enum
{ RESPONSE_DONE, RESPONSE_REMOVE };
@ -56,8 +66,8 @@ Control *config_control = NULL;
Item *config_item = NULL;
int num_items = 0;
static GtkWidget *menudialog = NULL; /* keep track of this for signal
handling */
static GtkWidget *menudialog = NULL; /* keep track of this for signal
handling */
static GtkWidget *dialog;
@ -99,9 +109,9 @@ reindex_items (GList * items)
for (i = 0, li = items; li; i++, li = li->next)
{
item = li->data;
item = li->data;
item->pos = i;
item->pos = i;
}
}
@ -191,35 +201,35 @@ entry_lost_focus (GtkEntry * entry, GdkEventFocus * event, gpointer data)
#define PREVIEW_SIZE 48
static GdkPixbuf *
scale_image(GdkPixbuf *pb)
scale_image (GdkPixbuf * pb)
{
int w, h;
GdkPixbuf *newpb;
g_return_val_if_fail(pb != NULL, NULL);
w = gdk_pixbuf_get_width(pb);
h = gdk_pixbuf_get_height(pb);
g_return_val_if_fail (pb != NULL, NULL);
w = gdk_pixbuf_get_width (pb);
h = gdk_pixbuf_get_height (pb);
if (w > PREVIEW_SIZE || h > PREVIEW_SIZE)
{
if (w > h)
{
h = (int) (((double)PREVIEW_SIZE/(double)w)*(double)h);
h = (int) (((double) PREVIEW_SIZE / (double) w) * (double) h);
w = PREVIEW_SIZE;
}
else
{
w = (int) (((double)PREVIEW_SIZE/(double)h)*(double)w);
w = (int) (((double) PREVIEW_SIZE / (double) h) * (double) w);
h = PREVIEW_SIZE;
}
newpb = gdk_pixbuf_scale_simple(pb, w, h, GDK_INTERP_BILINEAR);
newpb = gdk_pixbuf_scale_simple (pb, w, h, GDK_INTERP_BILINEAR);
}
else
{
newpb = pb;
g_object_ref(newpb);
g_object_ref (newpb);
}
return newpb;
@ -232,32 +242,32 @@ change_icon (int id, const char *path)
if (id == EXTERN_ICON && path)
{
if (g_file_test (path, G_FILE_TEST_IS_DIR) ||
!g_file_test (path, G_FILE_TEST_EXISTS))
{
pb = get_pixbuf_by_id (UNKNOWN_ICON);
}
else
{
pb = gdk_pixbuf_new_from_file (path, NULL);
}
if (g_file_test (path, G_FILE_TEST_IS_DIR) ||
!g_file_test (path, G_FILE_TEST_EXISTS))
{
pb = get_pixbuf_by_id (UNKNOWN_ICON);
}
else
{
pb = gdk_pixbuf_new_from_file (path, NULL);
}
}
else
{
pb = get_pixbuf_by_id (id);
pb = get_pixbuf_by_id (id);
}
if (!pb || !GDK_IS_PIXBUF (pb))
{
g_warning ("%s: couldn't create pixbuf: id=%d, path=%s\n", PACKAGE,
id, path ? path : "");
return;
g_warning ("%s: couldn't create pixbuf: id=%d, path=%s\n", PACKAGE,
id, path ? path : "");
return;
}
tmp = pb;
pb = scale_image(tmp);
g_object_unref(tmp);
pb = scale_image (tmp);
g_object_unref (tmp);
gtk_image_set_from_pixbuf (GTK_IMAGE (preview_image), pb);
g_object_unref (pb);
@ -265,31 +275,31 @@ change_icon (int id, const char *path)
if (id == EXTERN_ICON || id == UNKNOWN_ICON)
{
if (path)
{
if (!icon_path || !strequal (path, icon_path))
{
g_free (icon_path);
icon_path = g_strdup (path);
}
gtk_entry_set_text (GTK_ENTRY (icon_entry), path);
}
gtk_widget_set_sensitive (icon_entry, TRUE);
gtk_widget_set_sensitive (icon_browse_button, TRUE);
if (path)
{
if (!icon_path || !strequal (path, icon_path))
{
g_free (icon_path);
icon_path = g_strdup (path);
}
gtk_entry_set_text (GTK_ENTRY (icon_entry), path);
}
gtk_widget_set_sensitive (icon_entry, TRUE);
gtk_widget_set_sensitive (icon_browse_button, TRUE);
}
else
{
gtk_entry_set_text (GTK_ENTRY (icon_entry), "");
gtk_entry_set_text (GTK_ENTRY (icon_entry), "");
gtk_widget_set_sensitive (icon_entry, FALSE);
gtk_widget_set_sensitive (icon_entry, FALSE);
/* gtk_widget_set_sensitive(icon_browse_button, FALSE);*/
}
g_signal_handler_block (icon_id_menu, id_callback);
gtk_option_menu_set_history (GTK_OPTION_MENU (icon_id_menu),
(id == EXTERN_ICON) ? 0 : id);
(id == EXTERN_ICON) ? 0 : id);
g_signal_handler_unblock (icon_id_menu, id_callback);
item_apply_options ();
@ -302,15 +312,15 @@ icon_id_changed (void)
if (new_id == 0)
{
change_icon (EXTERN_ICON, icon_path);
change_icon (EXTERN_ICON, icon_path);
}
else
{
change_icon (new_id, NULL);
change_icon (new_id, NULL);
}
}
GtkWidget *
static GtkWidget *
create_icon_option_menu (void)
{
GtkWidget *om;
@ -324,17 +334,17 @@ create_icon_option_menu (void)
for (i = 1; i < NUM_ICONS; i++)
{
mi = gtk_menu_item_new_with_label (icon_names[i]);
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
mi = gtk_menu_item_new_with_label (icon_names[i]);
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
}
om = gtk_option_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (om), menu);
id_callback =
g_signal_connect_swapped (om, "changed", G_CALLBACK (icon_id_changed),
NULL);
g_signal_connect_swapped (om, "changed", G_CALLBACK (icon_id_changed),
NULL);
return om;
}
@ -342,15 +352,14 @@ create_icon_option_menu (void)
static void
icon_browse_cb (GtkWidget * b, GtkEntry * entry)
{
char *file =
select_file_with_preview (_("Select icon"),
gtk_entry_get_text (entry),
dialog);
char *file = select_file_with_preview (_("Select icon"),
gtk_entry_get_text (entry),
dialog);
if (file)
{
change_icon (EXTERN_ICON, file);
g_free (file);
change_icon (EXTERN_ICON, file);
g_free (file);
}
}
@ -359,9 +368,11 @@ static void
xtm_cb (GtkWidget * b, GtkEntry * entry)
{
GError *error = NULL;
gchar *argv[2]={"xffm_theme_maker",NULL};
g_spawn_async (NULL,argv,NULL,G_SPAWN_SEARCH_PATH,NULL,NULL,NULL,&error);
if (error) g_error_free(error);
gchar *argv[2] = { "xffm_theme_maker", NULL };
g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL,
&error);
if (error)
g_error_free (error);
}
#endif
@ -371,13 +382,13 @@ icon_entry_lost_focus (GtkEntry * entry, GdkEventFocus * event, gpointer data)
const char *temp = gtk_entry_get_text (entry);
if (temp)
change_icon (EXTERN_ICON, temp);
change_icon (EXTERN_ICON, temp);
/* we must return FALSE or gtk will crash :-( */
return FALSE;
}
GtkWidget *
static GtkWidget *
create_icon_option (GtkSizeGroup * sg)
{
GtkWidget *vbox;
@ -418,41 +429,45 @@ create_icon_option (GtkSizeGroup * sg)
gtk_box_pack_start (GTK_BOX (hbox), icon_entry, TRUE, TRUE, 0);
g_signal_connect (icon_entry, "focus-out-event",
G_CALLBACK (icon_entry_lost_focus), NULL);
G_CALLBACK (icon_entry_lost_focus), NULL);
icon_browse_button = gtk_button_new();
icon_browse_button = gtk_button_new ();
gtk_widget_show (icon_browse_button);
gtk_box_pack_start (GTK_BOX (hbox), icon_browse_button, FALSE, FALSE, 0);
image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_widget_show(image);
gtk_container_add(GTK_CONTAINER(icon_browse_button), image);
image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (icon_browse_button), image);
g_signal_connect (icon_browse_button, "clicked",
G_CALLBACK (icon_browse_cb), icon_entry);
G_CALLBACK (icon_browse_cb), icon_entry);
#ifdef USE_XFFM_THEME_MAKER
{
gchar *g=g_find_program_in_path("xffm_theme_maker");
if (g)
gchar *g = g_find_program_in_path ("xffm_theme_maker");
if (g)
{
GtkWidget *xtm_button = gtk_button_new();
gtk_box_pack_start (GTK_BOX (hbox), xtm_button, FALSE, FALSE, 0);
gtk_widget_show (xtm_button);
image = gtk_image_new_from_stock(GTK_STOCK_SELECT_COLOR, GTK_ICON_SIZE_BUTTON);
gtk_widget_show(image);
gtk_container_add(GTK_CONTAINER(xtm_button), image);
g_signal_connect (xtm_button, "clicked",
G_CALLBACK (xtm_cb), icon_entry);
g_free(g);
GtkWidget *xtm_button = gtk_button_new ();
gtk_box_pack_start (GTK_BOX (hbox), xtm_button, FALSE, FALSE, 0);
gtk_widget_show (xtm_button);
image =
gtk_image_new_from_stock (GTK_STOCK_SELECT_COLOR,
GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (xtm_button), image);
g_signal_connect (xtm_button, "clicked",
G_CALLBACK (xtm_cb), icon_entry);
g_free (g);
}
}
#endif
return vbox;
}
@ -464,17 +479,17 @@ static void
command_browse_cb (GtkWidget * b, GtkEntry * entry)
{
char *file =
select_file_name (_("Select command"), gtk_entry_get_text (entry),
dialog);
select_file_name (_("Select command"), gtk_entry_get_text (entry),
dialog);
if (file)
{
gtk_entry_set_text (entry, file);
g_free (file);
gtk_entry_set_text (entry, file);
g_free (file);
}
}
GtkWidget *
static GtkWidget *
create_command_option (GtkSizeGroup * sg)
{
GtkWidget *vbox;
@ -502,17 +517,17 @@ create_command_option (GtkSizeGroup * sg)
gtk_widget_show (command_entry);
gtk_box_pack_start (GTK_BOX (hbox), command_entry, TRUE, TRUE, 0);
command_browse_button = gtk_button_new();
command_browse_button = gtk_button_new ();
gtk_widget_show (command_browse_button);
gtk_box_pack_start (GTK_BOX (hbox), command_browse_button, FALSE, FALSE,
0);
0);
image = gtk_image_new_from_stock (GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_widget_show (image);
gtk_container_add (GTK_CONTAINER (command_browse_button), image);
image = gtk_image_new_from_stock(GTK_STOCK_OPEN, GTK_ICON_SIZE_BUTTON);
gtk_widget_show(image);
gtk_container_add(GTK_CONTAINER(command_browse_button), image);
g_signal_connect (command_browse_button, "clicked",
G_CALLBACK (command_browse_cb), command_entry);
G_CALLBACK (command_browse_cb), command_entry);
/* terminal */
hbox2 = gtk_hbox_new (FALSE, 4);
@ -529,12 +544,12 @@ create_command_option (GtkSizeGroup * sg)
gtk_box_pack_start (GTK_BOX (hbox2), vbox2, FALSE, TRUE, 0);
term_checkbutton =
gtk_check_button_new_with_mnemonic (_("Run in _terminal"));
gtk_check_button_new_with_mnemonic (_("Run in _terminal"));
gtk_widget_show (term_checkbutton);
gtk_box_pack_start (GTK_BOX (vbox2), term_checkbutton, FALSE, FALSE, 0);
sn_checkbutton =
gtk_check_button_new_with_mnemonic (_("Use startup _notification"));
gtk_check_button_new_with_mnemonic (_("Use startup _notification"));
gtk_widget_show (sn_checkbutton);
gtk_box_pack_start (GTK_BOX (vbox2), sn_checkbutton, FALSE, FALSE, 0);
#ifdef HAVE_LIBSTARTUP_NOTIFICATION
@ -547,7 +562,7 @@ create_command_option (GtkSizeGroup * sg)
/* Change caption
*/
GtkWidget *
static GtkWidget *
create_caption_option (GtkSizeGroup * sg)
{
GtkWidget *vbox;
@ -573,14 +588,14 @@ create_caption_option (GtkSizeGroup * sg)
/* only set label on focus out */
g_signal_connect (caption_entry, "focus-out-event",
G_CALLBACK (entry_lost_focus), NULL);
G_CALLBACK (entry_lost_focus), NULL);
return vbox;
}
/* Change tooltip
*/
GtkWidget *
static GtkWidget *
create_tooltip_option (GtkSizeGroup * sg)
{
GtkWidget *vbox;
@ -613,12 +628,7 @@ popup_changed (GtkToggleButton * tb, gpointer data)
{
config_item->with_popup = gtk_toggle_button_get_active (tb);
if (config_item->with_popup != config_control->with_popup)
{
config_control->with_popup = config_item->with_popup;
groups_show_popup (config_control->index, config_control->with_popup);
}
groups_show_popup (config_control->index, config_item->with_popup);
}
static GtkWidget *
@ -637,14 +647,14 @@ create_popup_option (GtkSizeGroup * sg)
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
popup_checkbutton =
gtk_check_button_new_with_label (_("Attach menu to launcher"));
gtk_check_button_new_with_label (_("Attach menu to launcher"));
gtk_widget_show (popup_checkbutton);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (popup_checkbutton),
config_item->with_popup);
config_item->with_popup);
gtk_box_pack_start (GTK_BOX (hbox), popup_checkbutton, FALSE, FALSE, 2);
g_signal_connect (popup_checkbutton, "toggled",
G_CALLBACK (popup_changed), NULL);
G_CALLBACK (popup_changed), NULL);
return hbox;
}
@ -659,7 +669,7 @@ pos_changed (GtkSpinButton * spin, gpointer data)
PanelPopup *pp = config_item->parent;
if (n - 1 == config_item->pos)
return;
return;
pp->items = g_list_remove (pp->items, config_item);
config_item->pos = n - 1;
@ -669,7 +679,7 @@ pos_changed (GtkSpinButton * spin, gpointer data)
item_apply_options ();
}
GtkWidget *
static GtkWidget *
create_position_option (void)
{
GtkWidget *hbox;
@ -683,13 +693,13 @@ create_position_option (void)
gtk_widget_show (label);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
pos_spin = gtk_spin_button_new_with_range
(1, (num_items > 0) ? num_items : 1, 1);
pos_spin = gtk_spin_button_new_with_range
(1, (num_items > 0) ? num_items : 1, 1);
gtk_widget_show (pos_spin);
gtk_box_pack_start (GTK_BOX (hbox), pos_spin, FALSE, FALSE, 0);
g_signal_connect (pos_spin, "value-changed", G_CALLBACK (pos_changed),
NULL);
NULL);
return hbox;
}
@ -697,7 +707,7 @@ create_position_option (void)
/* The main options box
* --------------------
*/
GtkWidget *
static GtkWidget *
create_item_options_box (void)
{
GtkWidget *vbox;
@ -718,8 +728,8 @@ create_item_options_box (void)
/* caption (menu item) */
if (config_item->type == MENUITEM)
{
box = create_caption_option (sg);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0);
box = create_caption_option (sg);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 0);
}
/* tooltip */
@ -729,8 +739,8 @@ create_item_options_box (void)
/* subpanel (panel item) */
if (config_item->type == PANELITEM)
{
box = create_popup_option (sg);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 4);
box = create_popup_option (sg);
gtk_box_pack_start (GTK_BOX (vbox), box, FALSE, TRUE, 4);
}
return vbox;
@ -741,8 +751,8 @@ create_item_options_box (void)
*/
static void
icon_drop_cb (GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, gpointer user_data)
gint x, gint y, GtkSelectionData * data,
guint info, guint time, gpointer user_data)
{
GList *fnames;
guint count;
@ -752,19 +762,19 @@ icon_drop_cb (GtkWidget * widget, GdkDragContext * context,
if (count > 0)
{
char *icon;
char *icon;
icon = (char *) fnames->data;
icon = (char *) fnames->data;
change_icon (EXTERN_ICON, icon);
change_icon (EXTERN_ICON, icon);
}
gnome_uri_list_free_strings (fnames);
gtk_drag_finish (context, (count > 0),
(context->action == GDK_ACTION_MOVE), time);
(context->action == GDK_ACTION_MOVE), time);
}
GtkWidget *
static GtkWidget *
create_icon_preview_frame ()
{
GtkWidget *frame;
@ -786,7 +796,7 @@ create_icon_preview_frame ()
dnd_set_drag_dest (eventbox);
g_signal_connect (eventbox, "drag_data_received",
G_CALLBACK (icon_drop_cb), NULL);
G_CALLBACK (icon_drop_cb), NULL);
return frame;
}
@ -807,13 +817,13 @@ item_apply_options (void)
temp = gtk_entry_get_text (GTK_ENTRY (command_entry));
if (temp && *temp)
config_item->command = g_strdup (temp);
config_item->command = g_strdup (temp);
config_item->in_terminal =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (term_checkbutton));
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (term_checkbutton));
config_item->use_sn =
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sn_checkbutton));
gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sn_checkbutton));
/* tooltip */
g_free (config_item->tooltip);
@ -821,7 +831,7 @@ item_apply_options (void)
temp = gtk_entry_get_text (GTK_ENTRY (tip_entry));
if (temp && *temp)
config_item->tooltip = g_strdup (temp);
config_item->tooltip = g_strdup (temp);
/* icon */
config_item->icon_id = icon_id;
@ -830,23 +840,23 @@ item_apply_options (void)
config_item->icon_path = NULL;
if (icon_path && config_item->icon_id == EXTERN_ICON)
config_item->icon_path = g_strdup (icon_path);
config_item->icon_path = g_strdup (icon_path);
if (config_item->type == MENUITEM)
{
pp = config_item->parent;
pp = config_item->parent;
/* caption */
g_free (config_item->caption);
temp = gtk_entry_get_text (GTK_ENTRY (caption_entry));
config_item->caption = NULL;
/* caption */
g_free (config_item->caption);
temp = gtk_entry_get_text (GTK_ENTRY (caption_entry));
config_item->caption = NULL;
if (temp && *temp)
config_item->caption = g_strdup (temp);
if (temp && *temp)
config_item->caption = g_strdup (temp);
/* position */
gtk_box_reorder_child (GTK_BOX (pp->item_vbox), config_item->button,
config_item->pos);
/* position */
gtk_box_reorder_child (GTK_BOX (pp->item_vbox), config_item->button,
config_item->pos);
}
item_apply_config (config_item);
@ -864,25 +874,25 @@ item_create_options (GtkContainer * container)
init_backup ();
if (config_item->command)
backup.command = g_strdup (config_item->command);
backup.command = g_strdup (config_item->command);
backup.in_terminal = config_item->in_terminal;
backup.use_sn = config_item->use_sn;
if (config_item->tooltip)
backup.tooltip = g_strdup (config_item->tooltip);
backup.tooltip = g_strdup (config_item->tooltip);
backup.icon_id = config_item->icon_id;
if (config_item->icon_path)
backup.icon_path = g_strdup (config_item->icon_path);
backup.icon_path = g_strdup (config_item->icon_path);
if (config_item->type == MENUITEM)
{
if (config_item->caption)
backup.caption = g_strdup (config_item->caption);
if (config_item->caption)
backup.caption = g_strdup (config_item->caption);
backup.pos = config_item->pos;
backup.pos = config_item->pos;
}
/* main vbox */
@ -904,27 +914,27 @@ item_create_options (GtkContainer * container)
/* fill in the structures use the backup values
* because the item values may have changed when connecting signals */
if (backup.command)
gtk_entry_set_text (GTK_ENTRY (command_entry), backup.command);
gtk_entry_set_text (GTK_ENTRY (command_entry), backup.command);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (term_checkbutton),
backup.in_terminal);
backup.in_terminal);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sn_checkbutton),
backup.use_sn);
backup.use_sn);
change_icon (backup.icon_id, backup.icon_path);
if (backup.tooltip)
gtk_entry_set_text (GTK_ENTRY (tip_entry), backup.tooltip);
gtk_entry_set_text (GTK_ENTRY (tip_entry), backup.tooltip);
if (config_item->type == MENUITEM)
{
if (backup.caption)
gtk_entry_set_text (GTK_ENTRY (caption_entry), backup.caption);
if (backup.caption)
gtk_entry_set_text (GTK_ENTRY (caption_entry), backup.caption);
if (num_items > 1)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin),
(gfloat) backup.pos + 1);
if (num_items > 1)
gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin),
(gfloat) backup.pos + 1);
}
item_apply_options ();
@ -935,7 +945,7 @@ item_create_options (GtkContainer * container)
*/
void
panel_item_create_options (Control * control, GtkContainer * container,
GtkWidget * done)
GtkWidget * done)
{
config_control = control;
config_item = control->data;
@ -943,7 +953,7 @@ panel_item_create_options (Control * control, GtkContainer * container,
dialog = gtk_widget_get_toplevel (done);
g_signal_connect_swapped (done, "clicked",
G_CALLBACK (item_apply_options), NULL);
G_CALLBACK (item_apply_options), NULL);
item_create_options (container);
}