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)
tags/xfce4-panel-4.10.0
Jasper Huijsmans 18 years ago
parent
commit
c0d2e0cd8a
65 changed files with 3503 additions and 3656 deletions
  1. +7
    -5
      AUTHORS
  2. +8
    -7
      panel/controls.c
  3. +2
    -2
      panel/controls.h
  4. +22
    -20
      panel/controls_dialog.c
  5. +50
    -116
      panel/groups.c
  6. +2
    -4
      panel/groups.h
  7. +2
    -2
      panel/icons.c
  8. +22
    -22
      panel/item.c
  9. +188
    -177
      panel/item_dialog.c
  10. +3
    -13
      panel/item_dialog.h
  11. +23
    -21
      panel/main.c
  12. +109
    -131
      panel/panel.c
  13. +1
    -4
      panel/panel.h
  14. +49
    -13
      panel/popup.c
  15. +30
    -30
      panel/xfce_support.c
  16. +75
    -2
      plugins/clock/clock.c
  17. BIN
      po/ca.gmo
  18. +118
    -123
      po/ca.po
  19. BIN
      po/cs.gmo
  20. +117
    -120
      po/cs.po
  21. BIN
      po/de.gmo
  22. +117
    -120
      po/de.po
  23. BIN
      po/es.gmo
  24. +118
    -123
      po/es.po
  25. BIN
      po/es_MX.gmo
  26. +118
    -123
      po/es_MX.po
  27. BIN
      po/fi.gmo
  28. +118
    -123
      po/fi.po
  29. BIN
      po/fr.gmo
  30. +118
    -123
      po/fr.po
  31. BIN
      po/hi.gmo
  32. +118
    -123
      po/hi.po
  33. BIN
      po/hu.gmo
  34. +117
    -120
      po/hu.po
  35. BIN
      po/it.gmo
  36. +117
    -120
      po/it.po
  37. BIN
      po/ja.gmo
  38. +118
    -123
      po/ja.po
  39. BIN
      po/ko.gmo
  40. +152
    -165
      po/ko.po
  41. BIN
      po/lt.gmo
  42. +117
    -120
      po/lt.po
  43. BIN
      po/ms.gmo
  44. +117
    -120
      po/ms.po
  45. BIN
      po/nl.gmo
  46. +121
    -126
      po/nl.po
  47. BIN
      po/pl.gmo
  48. +118
    -123
      po/pl.po
  49. BIN
      po/pt_PT.gmo
  50. +117
    -120
      po/pt_PT.po
  51. BIN
      po/ru.gmo
  52. +117
    -120
      po/ru.po
  53. BIN
      po/sv.gmo
  54. +106
    -122
      po/sv.po
  55. BIN
      po/ta.gmo
  56. +124
    -129
      po/ta.po
  57. BIN
      po/tr.gmo
  58. +117
    -120
      po/tr.po
  59. BIN
      po/vi.gmo
  60. +119
    -122
      po/vi.po
  61. +57
    -117
      po/xfce4-panel.pot
  62. BIN
      po/zh_CN.gmo
  63. +117
    -122
      po/zh_CN.po
  64. BIN
      po/zh_TW.gmo
  65. +117
    -120
      po/zh_TW.po

+ 7
- 5
AUTHORS View File

@@ -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>

+ 8
- 7
panel/controls.c View File

@@ -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;



+ 2
- 2
panel/controls.h View File

@@ -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);


+ 22
- 20
panel/controls_dialog.c View File

@@ -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);
}


+ 50
- 116
panel/groups.c View File

@@ -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--;
}
}

+ 2
- 4
panel/groups.h View File

@@ -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__ */

+ 2
- 2
panel/icons.c View File

@@ -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


+ 22
- 22
panel/item.c View File

@@ -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;


+ 188
- 177
panel/item_dialog.c View File

@@ -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);
}
@@ -951,7 +961,7 @@ panel_item_create_options (Control * control, GtkContainer * container,
/* Menu item dialogs
* -----------------
*/
GtkWidget *
static GtkWidget *
create_menu_item_dialog (Item * mi)
{
GtkWidget *dlg;
@@ -961,28 +971,30 @@ create_menu_item_dialog (Item * mi)
GtkWidget *sep;

/* create dialog */
dlg = gtk_dialog_new();
gtk_window_set_title(GTK_WINDOW(dlg), _("Change menu item"));
dlg = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dlg), _("Change menu item"));

/* add buttons */
remove_button = mixed_button_new (GTK_STOCK_REMOVE, _("Remove"));
GTK_WIDGET_SET_FLAGS (remove_button, GTK_CAN_DEFAULT);
gtk_widget_show (remove_button);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg), remove_button,
RESPONSE_REMOVE);
RESPONSE_REMOVE);

done_button = gtk_button_new_from_stock (GTK_STOCK_CLOSE);
GTK_WIDGET_SET_FLAGS (done_button, GTK_CAN_DEFAULT);
gtk_widget_show (done_button);
gtk_dialog_add_action_widget (GTK_DIALOG (dlg), done_button,
RESPONSE_DONE);
RESPONSE_DONE);

/* gtk_widget_show(GTK_DIALOG(dlg)->action_area);
gtk_button_box_set_layout (GTK_BUTTON_BOX (GTK_DIALOG(dlg)->action_area),
GTK_BUTTONBOX_END);
*/
gtk_button_box_set_child_secondary(GTK_BUTTON_BOX (GTK_DIALOG(dlg)->action_area), remove_button, TRUE);
gtk_button_box_set_child_secondary (GTK_BUTTON_BOX
(GTK_DIALOG (dlg)->action_area),
remove_button, TRUE);

/* the options */
main_vbox = GTK_DIALOG (dlg)->vbox;

@@ -998,7 +1010,7 @@ create_menu_item_dialog (Item * mi)
gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, TRUE, 0);

gtk_container_add (GTK_CONTAINER (frame), create_position_option ());
sep = gtk_hseparator_new ();
gtk_widget_show (sep);
gtk_box_pack_start (GTK_BOX (main_vbox), sep, FALSE, TRUE, 0);
@@ -1015,11 +1027,11 @@ create_menu_item_dialog (Item * mi)

/* signals */
g_signal_connect (done_button, "clicked",
G_CALLBACK (item_apply_options), NULL);
G_CALLBACK (item_apply_options), NULL);

gtk_widget_grab_default (done_button);
gtk_widget_grab_focus (done_button);
return dlg;
}

@@ -1039,8 +1051,8 @@ edit_menu_item_dialog (Item * mi)
dialog = dlg;

dlg_ptr = &menudialog;
g_object_add_weak_pointer(G_OBJECT(dlg), (gpointer*)dlg_ptr);
g_object_add_weak_pointer (G_OBJECT (dlg), (gpointer *) dlg_ptr);
gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER);
response = gtk_dialog_run (GTK_DIALOG (dlg));

@@ -1051,7 +1063,7 @@ edit_menu_item_dialog (Item * mi)
gtk_container_remove (GTK_CONTAINER (pp->item_vbox), mi->button);
pp->items = g_list_remove (pp->items, mi);
item_free (mi);
reindex_items(pp->items);
reindex_items (pp->items);
}

gtk_widget_destroy (dlg);
@@ -1076,9 +1088,8 @@ add_menu_item_dialog (PanelPopup * pp)
}

void
destroy_menu_dialog(void)
destroy_menu_dialog (void)
{
if (menudialog)
gtk_dialog_response(GTK_DIALOG(menudialog), GTK_RESPONSE_OK);
gtk_dialog_response (GTK_DIALOG (menudialog), GTK_RESPONSE_OK);
}


+ 3
- 13
panel/item_dialog.h View File

@@ -26,20 +26,10 @@ void edit_menu_item_dialog (Item * mi);

void add_menu_item_dialog (PanelPopup * pp);

void destroy_menu_dialog(void);
void destroy_menu_dialog (void);
/* options box for panel control dialog */
void panel_item_create_options (Control * control, GtkContainer * container,
GtkWidget * done);

extern GtkWidget *create_icon_option_menu (void);
extern GtkWidget *create_icon_option (GtkSizeGroup *);
extern GtkWidget *create_command_option (GtkSizeGroup *);
extern GtkWidget *create_caption_option (GtkSizeGroup *);
extern GtkWidget *create_tooltip_option (GtkSizeGroup *);
extern GtkWidget *create_position_option (void);
extern GtkWidget *create_item_options_box (void);
extern GtkWidget *create_icon_preview_frame (void);
extern GtkWidget *create_menu_item_dialog (Item *);
GtkWidget * done);

#endif /* __XFCE_ITEM_DIALOG_H__ */

+ 23
- 21
panel/main.c View File

@@ -57,7 +57,7 @@
#include "item_dialog.h"
#include "popup.h"

#define XFCE_PANEL_SELECTION_FMT "XFCE_PANEL_SELECTION_%d"
/*#define XFCE_PANEL_SELECTION_FMT "XFCE_PANEL_SELECTION_%d"*/

/* signal handling */
typedef enum
@@ -133,10 +133,10 @@ quit (gboolean force)
if (gtk_main_level ())
gtk_main_quit ();

DBG("sigstate: %d", sigstate);
DBG ("sigstate: %d", sigstate);
if (sigstate != RESTART)
{
g_message("%s: Exit", PACKAGE);
g_message ("%s: Exit", PACKAGE);
exit (0);
}
}
@@ -146,14 +146,14 @@ restart (void)
{
/* don't really quit */
sigstate = RESTART;
/* calls gtk_main_quit() */
quit(TRUE);
quit (TRUE);

/* progname is saved on startup
* TODO: do we need to pass on arguments? */
g_message("%s: restarting %s ...", PACKAGE, progname);
execlp(progname,progname,NULL);
g_message ("%s: restarting %s ...", PACKAGE, progname);
execlp (progname, progname, NULL);
}

/* Signals
@@ -167,14 +167,14 @@ check_signal_state (void)
if (sigstate != NOSIGNAL)
{
/* close open dialogs */
destroy_controls_dialog();
destroy_menu_dialog();
destroy_controls_dialog ();
destroy_menu_dialog ();
if (sigstate == RESTART && !restarting)
{
restarting = TRUE;
restart();
restart ();
}
else if (sigstate == QUIT)
{
@@ -208,7 +208,7 @@ sighandler (int sig)
case SIGUSR2:
sigstate = QUIT_CONFIRM;
break;
case SIGINT:
/* hack: prevent the panel from saving config on ^C */
disable_user_config = TRUE;
@@ -238,7 +238,8 @@ xfce_panel_is_running (void)

if (!selection_atom)
{
selection_name = g_strdup_printf (XFCE_PANEL_SELECTION_FMT, scr);
/* selection_name = g_strdup_printf (XFCE_PANEL_SELECTION_FMT, scr);*/
selection_name = g_strdup ("XFCE_PANEL_SELECTION");
selection_atom = XInternAtom (gdk_display, selection_name, False);
g_free (selection_name);
}
@@ -259,7 +260,7 @@ xfce_panel_set_xselection (void)

display = GDK_DISPLAY ();
scr = DefaultScreen (display);
TRACE ("claiming xfdesktop manager selection for screen %d", scr);

invisible = gtk_invisible_new ();
@@ -267,7 +268,8 @@ xfce_panel_set_xselection (void)

if (!selection_atom)
{
selection_name = g_strdup_printf (XFCE_PANEL_SELECTION_FMT, scr);
/* selection_name = g_strdup_printf (XFCE_PANEL_SELECTION_FMT, scr);*/
selection_name = g_strdup ("XFCE_PANEL_SELECTION");
selection_atom = XInternAtom (display, selection_name, False);
g_free (selection_name);
}
@@ -298,7 +300,7 @@ xfce_panel_set_xselection (void)
xev.data.l[3] = 0; /* manager specific data */
xev.data.l[4] = 0; /* manager specific data */

XSendEvent (display, GDK_ROOT_WINDOW(), False,
XSendEvent (display, GDK_ROOT_WINDOW (), False,
StructureNotifyMask, (XEvent *) & xev);
}
else
@@ -320,7 +322,7 @@ main (int argc, char **argv)
gboolean net_wm_support;
int i;

xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");

if (argc == 2 &&
(strequal (argv[1], "-v") || strequal (argv[1], "--version") ||
@@ -335,8 +337,8 @@ main (int argc, char **argv)
gtk_init (&argc, &argv);

progname = argv[0];
if (xfce_panel_is_running())
if (xfce_panel_is_running ())
{
g_message ("%s is already running", PACKAGE);
return 0;
@@ -345,7 +347,7 @@ main (int argc, char **argv)
{
xfce_panel_set_xselection ();
}
net_wm_support = FALSE;

for (i = 0; i < 5; i++)


+ 109
- 131
panel/panel.c View File

@@ -93,7 +93,7 @@ struct XineramaScreen
int xmax, ymax;
};

struct XineramaScreen xinerama_scr = {0};
struct XineramaScreen xinerama_scr = { 0 };

typedef enum
{
@@ -101,19 +101,19 @@ typedef enum
EDGE,
CENTER,
CORNER
}
}
XfcePositionState;
static XfcePositionState pos_state = FLOATING;

static GtkRequisition panel_req = {0};
static GtkRequisition panel_req = { 0 };

/* prototypes */

static void update_arrow_direction (int x, int y);
static void update_xinerama_coordinates (Panel *p);
static void update_position (Panel *p, int *x, int *y);
static void panel_reallocate (Panel *p, GtkRequisition *previous);
static void update_xinerama_coordinates (Panel * p);
static void update_position (Panel * p, int *x, int *y);
static void panel_reallocate (Panel * p, GtkRequisition * previous);
static void panel_set_hidden (Panel * p, gboolean hide);
static void init_settings ();

@@ -129,12 +129,12 @@ update_arrow_direction (int x, int y)
{
int center;
GtkArrowType type;
if (settings.orientation == HORIZONTAL)
{
center = xinerama_scr.ymin +
(xinerama_scr.ymax - xinerama_scr.ymin) / 2 -
panel_req.height / 2;
center = xinerama_scr.ymin +
(xinerama_scr.ymax - xinerama_scr.ymin) / 2 -
panel_req.height / 2;

if (y > center)
type = GTK_ARROW_UP;
@@ -143,29 +143,28 @@ update_arrow_direction (int x, int y)
}
else
{
center = xinerama_scr.xmin +
(xinerama_scr.xmax - xinerama_scr.xmin) / 2 -
panel_req.width / 2;
center = xinerama_scr.xmin +
(xinerama_scr.xmax - xinerama_scr.xmin) / 2 - panel_req.width / 2;

if (x > center)
type = GTK_ARROW_LEFT;
else
type = GTK_ARROW_RIGHT;
}
groups_set_arrow_direction (type);
}

static void
update_xinerama_coordinates (Panel *p)
static void
update_xinerama_coordinates (Panel * p)
{
int x, y;
g_return_if_fail(dpy != NULL);

x = p->toplevel->allocation.x + p->toplevel->allocation.width / 2;
y = p->toplevel->allocation.y + p->toplevel->allocation.height / 2;
g_return_if_fail (dpy != NULL);

gtk_window_get_position (GTK_WINDOW (p->toplevel), &x, &y);
x += p->toplevel->allocation.width / 2;
y += p->toplevel->allocation.height / 2;

xinerama_scr.xmin = MyDisplayX (x, y);
xinerama_scr.xmax = MyDisplayMaxX (dpy, scr, x, y);
@@ -173,9 +172,9 @@ update_xinerama_coordinates (Panel *p)
xinerama_scr.ymax = MyDisplayMaxY (dpy, scr, x, y);

DBG ("screen: %d,%d+%dx%d",
xinerama_scr.xmin, xinerama_scr.ymin,
xinerama_scr.xmax - xinerama_scr.xmin,
xinerama_scr.ymax - xinerama_scr.ymin);
xinerama_scr.xmin, xinerama_scr.ymin,
xinerama_scr.xmax - xinerama_scr.xmin,
xinerama_scr.ymax - xinerama_scr.ymin);
}

/**
@@ -190,18 +189,18 @@ update_xinerama_coordinates (Panel *p)
* Assumes panel_req and xinerama_scr are up-to-date.
**/
static void
update_position (Panel *p, int *x, int *y)
update_position (Panel * p, int *x, int *y)
{
int xthick, ythick;

if (!p || !p->toplevel)
return;
xthick = p->toplevel->style->xthickness + FRAME_IPADDING;
ythick = p->toplevel->style->ythickness + FRAME_IPADDING;

pos_state = FLOATING;
DBG ("desired position: %d,%d", *x, *y);

/* use an 'error' margin of 2 */
@@ -212,7 +211,7 @@ update_position (Panel *p, int *x, int *y)
*y = xinerama_scr.ymax - panel_req.height + ythick;
pos_state = EDGE;
}
if (*y < xinerama_scr.ymin + 2)
{
*y = xinerama_scr.ymin - ythick;
@@ -226,19 +225,19 @@ update_position (Panel *p, int *x, int *y)
*x = xinerama_scr.xmax - panel_req.width + xthick;
pos_state = CORNER;
}
if (*x < xinerama_scr.xmin + 2)
{
*x = xinerama_scr.xmin - xthick;
pos_state = CORNER;
}
}
if (pos_state == EDGE)
{
int xcenter = xinerama_scr.xmin +
(xinerama_scr.xmax - xinerama_scr.xmin) / 2 -
panel_req.width / 2;
int xcenter = xinerama_scr.xmin +
(xinerama_scr.xmax - xinerama_scr.xmin) / 2 -
panel_req.width / 2;

if (xcenter > xinerama_scr.xmin - xthick &&
*x > xcenter - 2 && *x < xcenter + 2)
@@ -255,7 +254,7 @@ update_position (Panel *p, int *x, int *y)
*x = xinerama_scr.xmax - panel_req.width + xthick;
pos_state = EDGE;
}
if (*x < xinerama_scr.xmin + 2)
{
*x = xinerama_scr.xmin - xthick;
@@ -269,19 +268,19 @@ update_position (Panel *p, int *x, int *y)
*y = xinerama_scr.ymax - panel_req.height + ythick;
pos_state = CORNER;
}
if (*y < xinerama_scr.ymin + 2)
{
*y = xinerama_scr.ymin - ythick;
pos_state = CORNER;
}
}
if (pos_state == EDGE)
{
int ycenter = xinerama_scr.ymin +
(xinerama_scr.ymax - xinerama_scr.ymin) / 2 -
panel_req.height / 2;
int ycenter = xinerama_scr.ymin +
(xinerama_scr.ymax - xinerama_scr.ymin) / 2 -
panel_req.height / 2;

if (ycenter > xinerama_scr.ymin - ythick &&
*y > ycenter - 2 && *y < ycenter + 2)
@@ -295,14 +294,14 @@ update_position (Panel *p, int *x, int *y)
DBG ("new position: %d,%d", *x, *y);
}

static void
panel_reallocate (Panel *p, GtkRequisition *previous)
static void
panel_reallocate (Panel * p, GtkRequisition * previous)
{
GtkRequisition new;
int xold, yold, xnew, ynew, xcenter, ycenter;

gtk_widget_size_request(p->toplevel, &new);
gtk_widget_size_request (p->toplevel, &new);
xold = xnew = p->position.x;
yold = ynew = p->position.y;

@@ -318,10 +317,10 @@ panel_reallocate (Panel *p, GtkRequisition *previous)
}
else
{
ynew = ycenter - new.height / 2;
ynew = ycenter - new.height / 2;
}
}
/* only right and bottom edge/corner can change */
/* use an 'error' margin of 2 */
if (pos_state == EDGE || pos_state == CORNER)
@@ -338,16 +337,16 @@ panel_reallocate (Panel *p, GtkRequisition *previous)
}

panel_req = new;
update_position (p, &xnew, &ynew);
DBG("reallocate: %d,%d+%dx%d -> %d,%d+%dx%d",
xold, yold, previous->width, previous->height,
xnew, ynew, new.width, new.height);
DBG ("reallocate: %d,%d+%dx%d -> %d,%d+%dx%d",
xold, yold, previous->width, previous->height,
xnew, ynew, new.width, new.height);

if (xnew != xold || ynew != yold)
{
gtk_window_move (GTK_WINDOW(p->toplevel), xnew, ynew);
gtk_window_move (GTK_WINDOW (p->toplevel), xnew, ynew);

p->position.x = xnew;
p->position.y = ynew;
@@ -506,28 +505,28 @@ handler_pressed_cb (GtkWidget * h, GdkEventButton * event)
}

static void
handler_move_end_cb (GtkWidget * h, Panel *p)
handler_move_end_cb (GtkWidget * h, Panel * p)
{
int x, y;
gtk_window_get_position (GTK_WINDOW (panel.toplevel),
&p->position.x, &p->position.y);

DBG ("move end: %d,%d", p->position.x, p->position.y);

update_xinerama_coordinates(p);
update_xinerama_coordinates (p);

x = panel.position.x;
y = panel.position.y;<