Browse Source

Cleanup. Unify PanelItem and MenuItem to avoid code duplication. Small bug fixes.

(Old svn revision: 3516)
tags/xfce4-panel-4.10.0
Jasper Huijsmans 19 years ago
parent
commit
6e6bd0dc13
17 changed files with 553 additions and 823 deletions
  1. +8
    -5
      README
  2. +6
    -6
      TODO
  3. +0
    -151
      panel/callbacks.c
  4. +0
    -27
      panel/callbacks.h
  5. +1
    -2
      panel/global.h
  6. +299
    -80
      panel/item.c
  7. +38
    -14
      panel/item.h
  8. +175
    -265
      panel/item_dialog.c
  9. +1
    -1
      panel/item_dialog.h
  10. +20
    -242
      panel/popup.c
  11. +4
    -29
      panel/popup.h
  12. BIN
      po/de.gmo
  13. BIN
      po/es.gmo
  14. BIN
      po/fi.gmo
  15. BIN
      po/fr.gmo
  16. BIN
      po/nl.gmo
  17. +1
    -1
      settings/xfce_settings.h

+ 8
- 5
README View File

@@ -3,10 +3,10 @@ README for xfce version 4.x

WHAT IS IT ?
------------
'xfce' is the panel of the XFce Desktop Environment. It is modeled after the
CDE panel and, of course, previous versions of xfce.
This version is based on GTK2 and should have all the advantages that come with
this new and improved toolkit (see http://www.gtk.org).
'xfce4-panel' is the panel of the XFce Desktop Environment. It is modeled
after the CDE panel and, of course, previous versions of xfce.
This version is based on GTK2 and should have all the advantages that come
with this new and improved toolkit (see http://www.gtk.org).

WHAT'S NEW ?
------------
@@ -18,7 +18,10 @@ manager hints as defined on http://www.freedesktop.org. This means that you
will need a compliant window manager for xfce to function properly (preferably
xfwm4 ;-).

The panel can now hold normal buttons and dynamic modules.
Highlights from the new panel include:
o vertical and horizontal mode
o icon themes
o dynamic modules as well as traditional luancher buttons

INFO FOR DEVELOPERS
===================


+ 6
- 6
TODO View File

@@ -7,21 +7,21 @@ Major features for 4.0
* write API docs for plugin writers
* write user docs
* provide good default configuration
* new dialog for panel controls (treeview with dialog area)
adding/removing controls from here.

Nice to have for 4.0
--------------------
* more themes: Night, KDE, Next, WindowsXP, BeOS, ...
(not too many released with xfce4; < 10)
* volume control plugin
* new dialog for panel controls (treeview with dialog area)
adding/removing controls from here.

Other feature ideas
------------------------------------
* optional pager instead of desktop buttons
* swallow apps
* hide popup buttons
* volume control plugin
* notification area plugin (as used by GNOME and KDE).
This would be really cool!
* dockapps support
* swallow apps
* hide popup buttons



+ 0
- 151
panel/callbacks.c View File

@@ -246,155 +246,4 @@ gboolean popup_key_pressed(GtkWidget * window, GdkEventKey * ev,
return FALSE;
}

/* Panel item callbacks
* --------------------
*/
void
panel_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, PanelItem * pi)
{
GList *fnames, *fnp;
guint count;
char *execute;

fnames = gnome_uri_list_extract_filenames((char *)data->data);
count = g_list_length(fnames);

if(count > 0)
{
execute = (char *)g_new0(char, MAXSTRLEN);

strcpy(execute, pi->command);

for(fnp = fnames; fnp; fnp = fnp->next, count--)
{
strcat(execute, " \'");
strncat(execute, (char *)(fnp->data), MAXSTRLEN - strlen(execute));
strcat(execute, "\' ");
}

exec_cmd(execute, pi->in_terminal);
g_free(execute);

hide_current_popup_menu();
}
gnome_uri_list_free_strings(fnames);
gtk_drag_finish(context, (count > 0), (context->action == GDK_ACTION_MOVE),
time);
}

void panel_item_click_cb(GtkButton * b, PanelItem * pi)
{
hide_current_popup_menu();
exec_cmd(pi->command, pi->in_terminal);
}

/* Menu item callbacks
* -------------------
*/
void
addtomenu_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, PanelPopup * pp)
{
GList *fnames, *fnp;
guint count;

fnames = gnome_uri_list_extract_filenames((char *)data->data);
count = g_list_length(fnames);

if(count > 0)
{
for(fnp = fnames; fnp; fnp = fnp->next, count--)
{
char *cmd;
MenuItem *mi = menu_item_new(pp);

if(!(cmd = g_find_program_in_path((char *)fnp->data)))
continue;

mi->command = cmd;

mi->caption = g_path_get_basename(cmd);
mi->caption[0] = g_ascii_toupper(mi->caption[0]);

create_menu_item(mi);
panel_popup_add_item(pp, mi);

if (!pp->detached)
{
xfce_togglebutton_toggled(XFCE_TOGGLEBUTTON(pp->button));
xfce_togglebutton_toggled(XFCE_TOGGLEBUTTON(pp->button));
}
}
}

gnome_uri_list_free_strings(fnames);
gtk_drag_finish(context, (count > 0), (context->action == GDK_ACTION_MOVE),
time);
}

void addtomenu_item_click_cb(GtkButton * b, PanelPopup * pp)
{
add_menu_item_dialog(pp);
}

gboolean menu_item_press(GtkButton * b, GdkEventButton * ev, MenuItem * mi)
{
if(disable_user_config)
return FALSE;

if(ev->button == 3 ||
(ev->button == 1 && (ev->state & GDK_SHIFT_MASK)))
{
edit_menu_item_dialog(mi);

return TRUE;
}
else
{
return FALSE;
}
}

void
menu_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, MenuItem * mi)
{
GList *fnames, *fnp;
guint count;
char *execute;

fnames = gnome_uri_list_extract_filenames((char *)data->data);
count = g_list_length(fnames);

if(count > 0)
{
execute = (char *)g_new0(char, MAXSTRLEN);

strcpy(execute, mi->command);

for(fnp = fnames; fnp; fnp = fnp->next, count--)
{
strcat(execute, " \'");
strncat(execute, (char *)(fnp->data), MAXSTRLEN - strlen(execute));
strcat(execute, "\' ");
}

exec_cmd(execute, mi->in_terminal);
g_free(execute);

hide_current_popup_menu();
}
gnome_uri_list_free_strings(fnames);
gtk_drag_finish(context, (count > 0), (context->action == GDK_ACTION_MOVE),
time);
}

void menu_item_click_cb(GtkButton * b, MenuItem * mi)
{
hide_current_popup_menu();
exec_cmd(mi->command, mi->in_terminal);
}

+ 0
- 27
panel/callbacks.h View File

@@ -22,14 +22,9 @@

#include "global.h"

/* global */
void iconify_cb(void);
void close_cb(void);

/* side panel */
gboolean panel_control_press_cb(GtkWidget * b, GdkEventButton * ev,
Control * control);

void toggle_popup(GtkWidget * button, PanelPopup * pp);

void tearoff_popup(GtkWidget * button, PanelPopup * pp);
@@ -39,26 +34,4 @@ gboolean delete_popup(GtkWidget * window, GdkEvent * ev, PanelPopup * pp);
gboolean popup_key_pressed(GtkWidget * window, GdkEventKey * ev,
PanelPopup * pp);

/* panel items */
void panel_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, PanelItem * pi);

void panel_item_click_cb(GtkButton * b, PanelItem * pi);

/* menu items */
void addtomenu_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, PanelPopup * pp);

void addtomenu_item_click_cb(GtkButton * b, PanelPopup * pp);

gboolean menu_item_press(GtkButton * b, GdkEventButton * ev, MenuItem * mi);

void menu_item_drop_cb(GtkWidget * widget, GdkDragContext * context,
gint x, gint y, GtkSelectionData * data,
guint info, guint time, MenuItem * mi);

void menu_item_click_cb(GtkButton * b, MenuItem * mi);

#endif /* __XFCE_CALLBACKS_H__ */

+ 1
- 2
panel/global.h View File

@@ -91,8 +91,7 @@ enum
typedef struct _ControlClass ControlClass;
typedef struct _Control Control;
typedef struct _PanelPopup PanelPopup;
typedef struct _PanelItem PanelItem;
typedef struct _MenuItem MenuItem;
typedef struct _Item Item;

/* global settings */
typedef struct _Settings Settings;


+ 299
- 80
panel/item.c View File

@@ -1,4 +1,4 @@
/* item.c
/* xfce4
*
* Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net)
*
@@ -20,94 +20,154 @@
#include <config.h>
#include <my_gettext.h>

#include <libxfcegui4/xfce_iconbutton.h>
#include <libxfcegui4/xfce_togglebutton.h>
#include <libxfcegui4/xfce_menubutton.h>

#include "xfce.h"
#include "item.h"
#include "item_dialog.h"
#include "popup.h"
#include "callbacks.h"
#include "item_dialog.h"
#include "settings.h"

/* (re)apply the settings to the icon button
/* Common item callbacks
* ---------------------
*/
void panel_item_apply_config(PanelItem * pi)
static void item_drop_cb(GtkWidget * widget, GdkDragContext * context, gint x, gint y,
GtkSelectionData * data, guint info, guint time,
Item * item)
{
GdkPixbuf *tmp;
GList *fnames, *fnp;
guint count;
char *execute;

if(pi->icon_id == EXTERN_ICON)
tmp = get_pixbuf_from_file(pi->icon_path);
else
tmp = get_pixbuf_by_id(pi->icon_id);
fnames = gnome_uri_list_extract_filenames((char *)data->data);
count = g_list_length(fnames);

if(count > 0)
{
execute = g_new0(char, MAXSTRLEN);

strcpy(execute, item->command);

for(fnp = fnames; fnp; fnp = fnp->next, count--)
{
strcat(execute, " \'");
strncat(execute, (char *)(fnp->data), MAXSTRLEN - strlen(execute));
strcat(execute, "\' ");
}

xfce_iconbutton_set_pixbuf(XFCE_ICONBUTTON(pi->button), tmp);
g_object_unref(tmp);
exec_cmd(execute, item->in_terminal);
g_free(execute);

if(pi->tooltip)
add_tooltip(pi->button, pi->tooltip);
hide_current_popup_menu();
}
gnome_uri_list_free_strings(fnames);
gtk_drag_finish(context, (count > 0), (context->action == GDK_ACTION_MOVE),
time);
}

/* global settings
*/
static void panel_item_set_theme(Control * control, const char *theme)
static void item_click_cb(GtkButton * b, Item * item)
{
PanelItem *pi = (PanelItem *) control->data;
panel_item_apply_config(pi);
hide_current_popup_menu();
exec_cmd(item->command, item->in_terminal);
}

/* creation
/* Menu item callbacks
* -------------------
*/
static PanelItem *panel_item_new(void)
static void addtomenu_item_drop_cb(GtkWidget * widget,
GdkDragContext * context,
gint x, gint y,
GtkSelectionData * data,
guint info, guint time,
PanelPopup * pp)
{
PanelItem *pi = g_new(PanelItem, 1);
GList *fnames, *fnp;
guint count;

pi->command = NULL;
pi->in_terminal = FALSE;
pi->tooltip = NULL;
fnames = gnome_uri_list_extract_filenames((char *)data->data);
count = g_list_length(fnames);

pi->icon_id = UNKNOWN_ICON;
pi->icon_path = NULL;
if(count > 0)
{
for(fnp = fnames; fnp; fnp = fnp->next, count--)
{
Item *mi;

pi->button = xfce_iconbutton_new();
gtk_widget_show(pi->button);
gtk_button_set_relief(GTK_BUTTON(pi->button), GTK_RELIEF_NONE);
mi = menu_item_new(pp);

add_tooltip(pi->button, _("Click mouse button 3 to change item"));
mi->command = g_strdup((char *)fnp->data);

g_signal_connect(pi->button, "clicked", G_CALLBACK(panel_item_click_cb), pi);
mi->caption = g_path_get_basename(mi->command);
mi->caption[0] = g_ascii_toupper(mi->caption[0]);

dnd_set_drag_dest(pi->button);
g_signal_connect(pi->button, "drag-data-received", G_CALLBACK(panel_item_drop_cb),
pi);
create_menu_item(mi);
panel_popup_add_item(pp, mi);

panel_item_apply_config(pi);
if (!pp->detached)
{
xfce_togglebutton_toggled(XFCE_TOGGLEBUTTON(pp->button));
xfce_togglebutton_toggled(XFCE_TOGGLEBUTTON(pp->button));
}
}
}

return pi;
gnome_uri_list_free_strings(fnames);
gtk_drag_finish(context, (count > 0), (context->action == GDK_ACTION_MOVE),
time);
}

static void panel_item_read_config(Control * control, xmlNodePtr node)
static void addtomenu_item_click_cb(GtkButton * b, PanelPopup * pp)
{
PanelItem *pi = (PanelItem *) control->data;
xmlNodePtr child;
xmlChar *value;
add_menu_item_dialog(pp);
}

static gboolean menu_item_press(GtkButton * b, GdkEventButton * ev, Item * mi)
{
if(disable_user_config)
return FALSE;

if(!node)
if(ev->button == 3 ||
(ev->button == 1 && (ev->state & GDK_SHIFT_MASK)))
{
panel_item_apply_config(pi);
return;
edit_menu_item_dialog(mi);

return TRUE;
}
else
{
return FALSE;
}
}

/* Common item interface
* ---------------------
*/
void item_read_config(Item * item, xmlNodePtr node)
{
xmlNodePtr child;
xmlChar *value;

for(child = node->children; child; child = child->next)
{
if(xmlStrEqual(child->name, (const xmlChar *)"Command"))
if(xmlStrEqual(child->name, (const xmlChar *)"Caption"))
{
value = DATA(child);

if(value)
item->caption = (char *)value;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Command"))
{
int n = -1;

value = DATA(child);

if(value)
pi->command = (char *)value;
item->command = (char *)value;

value = xmlGetProp(child, "term");

@@ -115,90 +175,249 @@ static void panel_item_read_config(Control * control, xmlNodePtr node)
n = atoi(value);

if(n == 1)
pi->in_terminal = TRUE;
item->in_terminal = TRUE;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Tooltip"))
{
value = DATA(child);

if(value)
pi->tooltip = (char *)value;
item->tooltip = (char *)value;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Icon"))
{
value = xmlGetProp(child, (const xmlChar *)"id");

if(value)
pi->icon_id = atoi(value);
item->icon_id = atoi(value);

if(!value || pi->icon_id < EXTERN_ICON || pi->icon_id >= NUM_ICONS)
pi->icon_id = UNKNOWN_ICON;
if(!value || item->icon_id < EXTERN_ICON || item->icon_id >= NUM_ICONS)
item->icon_id = UNKNOWN_ICON;

g_free(value);

if(pi->icon_id == EXTERN_ICON)
if(item->icon_id == EXTERN_ICON)
{
value = DATA(child);

if(value)
pi->icon_path = (char *)value;
item->icon_path = (char *)value;
else
pi->icon_id = UNKNOWN_ICON;
item->icon_id = UNKNOWN_ICON;
}
}
}
}

void item_write_config(Item * item, xmlNodePtr node)
{
xmlNodePtr child;
char value[3];

if (item->type == MENUITEM)
xmlNewTextChild(node, NULL, "Caption", item->caption);

panel_item_apply_config(pi);
child = xmlNewChild(node, NULL, "Command", item->command);

snprintf(value, 2, "%d", item->in_terminal);
xmlSetProp(child, "term", value);

if(item->tooltip)
xmlNewTextChild(node, NULL, "Tooltip", item->tooltip);

child = xmlNewTextChild(node, NULL, "Icon", item->icon_path);

snprintf(value, 3, "%d", item->icon_id);
xmlSetProp(child, "id", value);
}

void item_free(Item * item)
{
g_free(item->command);
g_free(item->caption);
g_free(item->tooltip);
g_free(item->icon_path);

g_free(item);
}

/* destruction
void item_set_theme(Item * item, const char *theme)
{
GdkPixbuf *pb;
if(item->icon_id <= EXTERN_ICON)
return;

pb = get_pixbuf_by_id(item->icon_id);

if (item->type == MENUITEM)
xfce_menubutton_set_pixbuf(XFCE_MENUBUTTON(item->button), pb);
else
xfce_iconbutton_set_pixbuf(XFCE_ICONBUTTON(item->button), pb);
g_object_unref(pb);
}

void item_apply_config(Item * item)
{
GdkPixbuf *pb = NULL;

if(item->icon_id == EXTERN_ICON && item->icon_path)
pb = get_pixbuf_from_file(item->icon_path);
else if (item->icon_id != STOCK_ICON)
pb = get_pixbuf_by_id(item->icon_id);

if (pb)
{
if (item->type == MENUITEM)
xfce_menubutton_set_pixbuf(XFCE_MENUBUTTON(item->button), pb);
else
xfce_iconbutton_set_pixbuf(XFCE_ICONBUTTON(item->button), pb);
g_object_unref(pb);
}
if (item->type == MENUITEM)
{
xfce_menubutton_set_text(XFCE_MENUBUTTON(item->button), item->caption);
menu_item_set_popup_size(item, settings.size);
}

if(item->tooltip && strlen(item->tooltip))
add_tooltip(item->button, item->tooltip);
else if(item->command && strlen(item->command))
add_tooltip(item->button, item->command);
else
add_tooltip(item->button, _("Click mouse button 3 to change item"));
}

/* Menu items
* ----------
*/
static void panel_item_free(Control * control)
Item *menu_item_new(PanelPopup * pp)
{
PanelItem *pi = (PanelItem *) control->data;
Item *mi = g_new0(Item, 1);

mi->type = MENUITEM;

mi->parent = pp;

return mi;
}

void create_addtomenu_item(Item * mi)
{
mi->button = xfce_menubutton_new_with_stock_icon(_("Add launcher"), GTK_STOCK_ADD);
gtk_widget_show(mi->button);
gtk_button_set_relief(GTK_BUTTON(mi->button), GTK_RELIEF_NONE);

add_tooltip(mi->button, _("Add new item"));

/* signals */
dnd_set_drag_dest(mi->button);

g_signal_connect(mi->button, "drag_data_received",
G_CALLBACK(addtomenu_item_drop_cb), mi->parent);

g_signal_connect(mi->button, "clicked", G_CALLBACK(addtomenu_item_click_cb),
mi->parent);

menu_item_set_popup_size(mi, settings.size);
}

void create_menu_item(Item * mi)
{
mi->button = xfce_menubutton_new(NULL);
gtk_widget_show(mi->button);
gtk_button_set_relief(GTK_BUTTON(mi->button), GTK_RELIEF_NONE);

item_apply_config(mi);
/* signals */
g_signal_connect(mi->button, "button-press-event",
G_CALLBACK(menu_item_press), mi);

g_signal_connect(mi->button, "clicked", G_CALLBACK(item_click_cb), mi);

dnd_set_drag_dest(mi->button);

g_signal_connect(mi->button, "drag_data_received",
G_CALLBACK(item_drop_cb), mi);

menu_item_set_popup_size(mi, settings.size);
}

g_free(pi->command);
g_free(pi->icon_path);
g_free(pi->tooltip);
void menu_item_set_popup_size(Item * mi, int size)
{
int s = popup_icon_size[size];

g_free(pi);
gtk_widget_set_size_request(mi->button, -1, s + border_width);
}

/* exit
/* Panel item
* ----------
*/
static void panel_item_write_config(Control * control, xmlNodePtr root)
static Item *panel_item_new(void)
{
PanelItem *pi = (PanelItem *) control->data;
xmlNodePtr child;
char value[3];
Item *pi = g_new0(Item, 1);

child = xmlNewChild(root, NULL, "Command", pi->command);
pi->type = PANELITEM;
pi->button = xfce_iconbutton_new();
gtk_widget_show(pi->button);
gtk_button_set_relief(GTK_BUTTON(pi->button), GTK_RELIEF_NONE);

snprintf(value, 2, "%d", pi->in_terminal);
xmlSetProp(child, "term", value);
item_apply_config(pi);

if(pi->tooltip)
xmlNewTextChild(root, NULL, "Tooltip", pi->tooltip);
g_signal_connect(pi->button, "clicked", G_CALLBACK(item_click_cb), pi);

child = xmlNewTextChild(root, NULL, "Icon", pi->icon_path);
dnd_set_drag_dest(pi->button);
g_signal_connect(pi->button, "drag-data-received", G_CALLBACK(item_drop_cb),
pi);

snprintf(value, 3, "%d", pi->icon_id);
xmlSetProp(child, "id", value);
return pi;
}

static void panel_item_free(Control * control)
{
Item *pi = control->data;

item_free(pi);
}

static void panel_item_set_theme(Control * control, const char *theme)
{
Item *pi = control->data;

item_apply_config(pi);
}

static void panel_item_read_config(Control * control, xmlNodePtr node)
{
Item *pi = control->data;

item_read_config(pi, node);
item_apply_config(pi);
}

static void panel_item_write_config(Control * control, xmlNodePtr root)
{
Item *pi = control->data;

item_write_config(pi, root);
}

static void panel_item_attach_callback(Control *control, const char *signal,
GCallback callback, gpointer data)
{
PanelItem *pi = control->data;
Item *pi = control->data;

g_signal_connect(pi->button, signal, callback,data);
}

/* create a default panel item
*/
void create_panel_item(Control * control)
{
PanelItem *pi = panel_item_new();
Item *pi = panel_item_new();

gtk_container_add(GTK_CONTAINER(control->base), pi->button);



+ 38
- 14
panel/item.h View File

@@ -1,4 +1,4 @@
/* item.h
/* xfce4
*
* Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net)
*
@@ -17,33 +17,57 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#ifndef __XFCE_ITEM_H__
#define __XFCE_ITEM_H__
#ifndef __XFCE_ITEMS_H
#define __XFCE_ITEMS_H

#include "global.h"

/* The panel item stuff is only public for use in item_dialog.c, so that
* the dialog can provide immediate apply and revert functionality.
*
* The dialog is in a separate file because it is shared with menu items.
*/
struct _PanelItem
enum
{ PANELITEM, MENUITEM };

struct _Item
{
char *command;
gboolean in_terminal;
char *caption;
char *tooltip;

int icon_id;
char *icon_path; /* if id==EXTERN_ICON */
char *icon_path;

int type;
GtkWidget *button;

/* for menu items */
PanelPopup *parent;
int pos;
};

void panel_item_apply_config(PanelItem * pi);
/* special menu item */
void create_addtomenu_item(Item * mi);
/* menu items */
Item *menu_item_new(PanelPopup * pp);

/* panel control interface
*/
void create_menu_item(Item * mi);

void menu_item_set_popup_size(Item *item, int size);

/* panel control interface for panel items */
void create_panel_item(Control * control);

void panel_item_class_init(ControlClass *cc);

#endif /* __XFCE_ITEM_H__ */
/* common functions */
void item_free(Item * item);

void item_set_theme(Item *item, const char *theme);

void item_apply_config(Item *item);

void item_read_config(Item *item, xmlNodePtr node);

void item_write_config(Item *item, xmlNodePtr node);

#endif /* __XFCE_ITEMS_H */


+ 175
- 265
panel/item_dialog.c View File

@@ -41,16 +41,18 @@
* options for caption and position in menu.
*/

static void menu_item_apply_options(void);
static void panel_item_apply_options(void);
static void item_apply_options(void);

enum
{ RESPONSE_REVERT, RESPONSE_DONE, RESPONSE_REMOVE };

/* the item is a menu item or a panel control */
MenuItem *mitem = NULL;
Item *config_item = NULL;
int num_items = 0;
PanelItem *pitem;

static GtkWidget *dialog;

static int id_callback;

/* important widgets */
static GtkWidget *command_entry;
@@ -63,16 +65,12 @@ static GtkWidget *tip_entry;
static GtkWidget *preview_image;

/* for menu items */
GtkWidget *caption_entry;
GtkWidget *pos_spin;
static GtkWidget *caption_entry;
static GtkWidget *pos_spin;

/* controls on the parent dialog */
GtkWidget *revert_button;
GtkWidget *done_button;

static GtkWidget *dialog;

static int id_callback;
static GtkWidget *revert_button;
static GtkWidget *done_button;

/* usefull for (instant) apply */
int icon_id;
@@ -82,7 +80,7 @@ int pos;
/* reindex menuitems */
static void reindex_items(GList *items)
{
MenuItem *item;
Item *item;
GList *li;
int i;

@@ -155,10 +153,7 @@ void make_sensitive(GtkWidget * widget)
gboolean entry_lost_focus(GtkEntry * entry, GdkEventFocus * event,
gpointer data)
{
if(mitem)
menu_item_apply_options();
else
panel_item_apply_options();
item_apply_options();

/* needed to prevent GTK+ crash :( */
return FALSE;
@@ -184,8 +179,8 @@ static void change_icon(int id, const char *path)

if(!pb || !GDK_IS_PIXBUF(pb))
{
g_printerr("xfce4: %s (line %d): couldn't create pixbuf\n",
__FILE__, __LINE__);
g_warning("%s: couldn't create pixbuf: id=%d, path=%s\n", PACKAGE,
id, path ? path : "");
return;
}

@@ -215,7 +210,7 @@ static void change_icon(int id, const char *path)
gtk_entry_set_text(GTK_ENTRY(icon_entry), "");

gtk_widget_set_sensitive(icon_entry, FALSE);
gtk_widget_set_sensitive(icon_browse_button, FALSE);
/* gtk_widget_set_sensitive(icon_browse_button, FALSE);*/
}

g_signal_handler_block(icon_id_menu, id_callback);
@@ -223,10 +218,7 @@ static void change_icon(int id, const char *path)
(id == EXTERN_ICON) ? 0 : id);
g_signal_handler_unblock(icon_id_menu, id_callback);

if(mitem)
menu_item_apply_options();
else
panel_item_apply_options();
item_apply_options();

make_sensitive(revert_button);
}
@@ -485,17 +477,17 @@ static GtkWidget *create_tooltip_option(GtkSizeGroup * sg)
static void pos_changed(GtkSpinButton * spin, gpointer data)
{
int n = gtk_spin_button_get_value_as_int(spin);
PanelPopup *pp = mitem->parent;
PanelPopup *pp = config_item->parent;

if (n == mitem->pos)
if (n -1 == config_item->pos)
return;
pp->items = g_list_remove(pp->items, mitem);
mitem->pos = n - 1;
pp->items = g_list_insert(pp->items, mitem, mitem->pos);
reindex_items(mitem->parent->items);
pp->items = g_list_remove(pp->items, config_item);
config_item->pos = n - 1;
pp->items = g_list_insert(pp->items, config_item, config_item->pos);
reindex_items(pp->items);
menu_item_apply_options();
item_apply_options();
gtk_widget_set_sensitive(revert_button, TRUE);
}

@@ -548,7 +540,7 @@ static GtkWidget *create_item_options_box(void)
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, TRUE, 0);

/* caption (menu item) */
if(mitem)
if(config_item->type == MENUITEM)
{
box = create_caption_option(sg);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, TRUE, 0);
@@ -559,7 +551,7 @@ static GtkWidget *create_item_options_box(void)
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, TRUE, 0);

/* position (menu item) */
if(mitem && num_items > 1)
if(config_item->type == MENUITEM && num_items > 1)
{
box = create_position_option(sg);
gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, TRUE, 0);
@@ -622,265 +614,166 @@ static GtkWidget *create_icon_preview_frame()
return frame;
}

/* Panel item options box
* ----------------------
/* Apply and revert
* ----------------
*/
void panel_item_revert_options(Control * control)
{
g_free(pitem->command);
pitem->command = g_strdup(backup.command);

pitem->in_terminal = backup.in_terminal;

g_free(pitem->tooltip);
pitem->tooltip = g_strdup(backup.tooltip);

pitem->icon_id = backup.icon_id;

g_free(pitem->icon_path);
pitem->icon_path = g_strdup(backup.icon_path);

panel_item_apply_config(pitem);

/* revert the widgets */
if(pitem->command)
gtk_entry_set_text(GTK_ENTRY(command_entry), pitem->command);
else
gtk_entry_set_text(GTK_ENTRY(command_entry), "");

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(term_checkbutton),
pitem->in_terminal);

change_icon(pitem->icon_id, pitem->icon_path);

if(pitem->tooltip)
gtk_entry_set_text(GTK_ENTRY(tip_entry), pitem->tooltip);
else
gtk_entry_set_text(GTK_ENTRY(tip_entry), "");
}

void panel_item_apply_options(void)
static void item_apply_options(void)
{
const char *temp;

g_free(pitem->command);
PanelPopup *pp = NULL;
/* command */
g_free(config_item->command);
config_item->command = NULL;
temp = gtk_entry_get_text(GTK_ENTRY(command_entry));

if(temp && *temp)
pitem->command = g_strdup(temp);
else
pitem->command = NULL;
config_item->command = g_strdup(temp);

pitem->in_terminal =
config_item->in_terminal =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(term_checkbutton));

g_free(pitem->tooltip);
/* tooltip */
g_free(config_item->tooltip);
config_item->tooltip = NULL;
temp = gtk_entry_get_text(GTK_ENTRY(tip_entry));

if(temp && *temp)
pitem->tooltip = g_strdup(temp);
else
pitem->tooltip = NULL;

pitem->icon_id = icon_id;

g_free(pitem->icon_path);

if(icon_path && pitem->icon_id == EXTERN_ICON)
pitem->icon_path = g_strdup(icon_path);
else
pitem->icon_path = NULL;
config_item->tooltip = g_strdup(temp);

panel_item_apply_config(pitem);
}

void panel_item_add_options(Control * control, GtkContainer * container,
GtkWidget * revert, GtkWidget * done)
{
GtkWidget *main_hbox;
GtkWidget *options_box;
GtkWidget *preview_frame;

pitem = (PanelItem *) control->data;
mitem = NULL;

dialog = gtk_widget_get_toplevel(done);

revert_button = revert;

g_signal_connect_swapped(revert, "clicked",
G_CALLBACK(panel_item_revert_options), pitem);

g_signal_connect_swapped(done, "clicked",
G_CALLBACK(panel_item_apply_options), pitem);

/* create backup for revert */
init_backup();

if(pitem->command)
backup.command = g_strdup(pitem->command);

backup.in_terminal = pitem->in_terminal;

if(pitem->tooltip)
backup.tooltip = g_strdup(pitem->tooltip);

backup.icon_id = pitem->icon_id;

if(pitem->icon_path)
backup.icon_path = g_strdup(pitem->icon_path);
/* icon */
config_item->icon_id = icon_id;

main_hbox = gtk_hbox_new(FALSE, 8);
gtk_widget_show(main_hbox);
gtk_container_add(container, main_hbox);
g_free(config_item->icon_path);
config_item->icon_path = NULL;

/* clean backup when dialog is destroyed */
g_signal_connect(main_hbox, "destroy-event",
G_CALLBACK(clear_backup), NULL);
if(icon_path && config_item->icon_id == EXTERN_ICON)
config_item->icon_path = g_strdup(icon_path);

options_box = create_item_options_box();
gtk_box_pack_start(GTK_BOX(main_hbox), options_box, TRUE, TRUE, 0);
if (config_item->type == MENUITEM)
{
pp = config_item->parent;

preview_frame = create_icon_preview_frame();
gtk_box_pack_start(GTK_BOX(main_hbox), preview_frame, TRUE, FALSE, 0);
/* caption */
g_free(config_item->caption);
temp = gtk_entry_get_text(GTK_ENTRY(caption_entry));
config_item->caption = NULL;

/* fill in the structures
* use the backup values because the item may have changed
* after connecting callbacks */
if(backup.command)
gtk_entry_set_text(GTK_ENTRY(command_entry), backup.command);
if(temp && *temp)
config_item->caption = g_strdup(temp);

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(term_checkbutton),
backup.in_terminal);
change_icon(backup.icon_id, backup.icon_path);
/* position */
gtk_box_reorder_child(GTK_BOX(pp->item_vbox), config_item->button,
config_item->pos);
}

if(backup.tooltip)
gtk_entry_set_text(GTK_ENTRY(tip_entry), backup.tooltip);
item_apply_config(config_item);
}

/* Menu item options box
* ---------------------
* Much of the code is shared with the panel item option box
*/
static void menu_item_apply_options(void)
void item_revert_options(void)
{
const char *temp;
PanelPopup *pp = mitem->parent;

g_free(mitem->command);
temp = gtk_entry_get_text(GTK_ENTRY(command_entry));

if(temp && *temp)
mitem->command = g_strdup(temp);
else
mitem->command = NULL;

mitem->in_terminal =
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(term_checkbutton));

g_free(mitem->tooltip);
temp = gtk_entry_get_text(GTK_ENTRY(tip_entry));

if(temp && *temp)
mitem->tooltip = g_strdup(temp);
else
mitem->tooltip = NULL;

mitem->icon_id = icon_id;

g_free(mitem->icon_path);

if(icon_path && mitem->icon_id == EXTERN_ICON)
mitem->icon_path = g_strdup(icon_path);
else
mitem->icon_path = NULL;

g_free(mitem->caption);
temp = gtk_entry_get_text(GTK_ENTRY(caption_entry));

if(temp && *temp)
mitem->caption = g_strdup(temp);
else
mitem->caption = NULL;
PanelPopup *pp = NULL;

gtk_box_reorder_child(GTK_BOX(pp->item_vbox), mitem->button, mitem->pos);

menu_item_apply_config(mitem);
}

void menu_item_revert_options(void)
{
PanelPopup *pp = mitem->parent;
/* command */
g_free(config_item->command);
config_item->command = g_strdup(backup.command);

g_free(mitem->command);
mitem->command = g_strdup(backup.command);
config_item->in_terminal = backup.in_terminal;

mitem->in_terminal = backup.in_terminal;
/* tooltip */
g_free(config_item->tooltip);
config_item->tooltip = g_strdup(backup.tooltip);

g_free(mitem->tooltip);
mitem->tooltip = g_strdup(backup.tooltip);
/* icon */
config_item->icon_id = backup.icon_id;

g_free(mitem->caption);
mitem->caption = g_strdup(backup.caption);
g_free(config_item->icon_path);
config_item->icon_path = g_strdup(backup.icon_path);

mitem->icon_id = backup.icon_id;
if (config_item->type == MENUITEM)
{
pp = config_item->parent;

g_free(mitem->icon_path);
mitem->icon_path = g_strdup(backup.icon_path);
/* caption */
g_free(config_item->caption);
config_item->caption = g_strdup(backup.caption);

pp->items = g_list_remove(pp->items, mitem);
mitem->pos = backup.pos;
pp->items = g_list_insert(pp->items, mitem, mitem->pos);
reindex_items(mitem->parent->items);
/* position */
pp->items = g_list_remove(pp->items, config_item);
config_item->pos = backup.pos;
pp->items = g_list_insert(pp->items, config_item, config_item->pos);
reindex_items(config_item->parent->items);

gtk_box_reorder_child(GTK_BOX(mitem->parent->item_vbox), mitem->button,
mitem->pos);
gtk_box_reorder_child(GTK_BOX(config_item->parent->item_vbox),
config_item->button, config_item->pos);
}

menu_item_apply_config(mitem);
item_apply_config(config_item);

/* revert the widgets */
if(mitem->command)
gtk_entry_set_text(GTK_ENTRY(command_entry), mitem->command);
if(config_item->command)
gtk_entry_set_text(GTK_ENTRY(command_entry), config_item->command);
else
gtk_entry_set_text(GTK_ENTRY(command_entry), "");

gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(term_checkbutton),
mitem->in_terminal);

if(mitem->tooltip)
gtk_entry_set_text(GTK_ENTRY(tip_entry), mitem->tooltip);
config_item->in_terminal);

if(mitem->caption)
gtk_entry_set_text(GTK_ENTRY(caption_entry), mitem->caption);
if(config_item->tooltip)
gtk_entry_set_text(GTK_ENTRY(tip_entry), config_item->tooltip);
else
gtk_entry_set_text(GTK_ENTRY(tip_entry), "");

if(num_items > 1)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pos_spin),
(gfloat) mitem->pos + 1);
if(config_item->type == MENUITEM)
{
if (config_item->caption)
gtk_entry_set_text(GTK_ENTRY(caption_entry), config_item->caption);
else
gtk_entry_set_text(GTK_ENTRY(caption_entry), "");

if(num_items > 1)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pos_spin),
(gfloat) config_item->pos + 1);
}

change_icon(mitem->icon_id, mitem->icon_path);
change_icon(config_item->icon_id, config_item->icon_path);

gtk_widget_set_sensitive(revert_button, FALSE);
}

void menu_item_add_options(MenuItem * item, GtkContainer * container)
static void item_add_options(GtkContainer *container)
{
GtkWidget *main_hbox;
GtkWidget *options_box;
GtkWidget *preview_frame;

pitem = NULL;
mitem = item;

/* backup */
init_backup();

backup.command = g_strdup(mitem->command);
backup.in_terminal = mitem->in_terminal;
backup.tooltip = g_strdup(mitem->tooltip);
backup.caption = g_strdup(mitem->caption);
backup.icon_id = mitem->icon_id;
backup.icon_path = g_strdup(mitem->icon_path);
backup.pos = mitem->pos;
if (config_item->command)
backup.command = g_strdup(config_item->command);
backup.in_terminal = config_item->in_terminal;
if (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);
if (config_item->type == MENUITEM)
{
if (config_item->caption)
backup.caption = g_strdup(config_item->caption);
backup.pos = config_item->pos;
}

main_hbox = gtk_hbox_new(FALSE, 8);
/* options box */
main_hbox = gtk_hbox_new(FALSE, 6);
gtk_widget_show(main_hbox);
gtk_container_add(container, main_hbox);

@@ -903,21 +796,44 @@ void menu_item_add_options(MenuItem * item, GtkContainer * container)
if(backup.tooltip)
gtk_entry_set_text(GTK_ENTRY(tip_entry), backup.tooltip);

if(backup.caption)
gtk_entry_set_text(GTK_ENTRY(caption_entry), backup.caption);
if (config_item->type == MENUITEM)
{
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);
}

item_apply_options();
}

/* Panel item dialog
* -----------------
*/
void panel_item_add_options(Control * control, GtkContainer * container,
GtkWidget * revert, GtkWidget * done)
{
config_item = control->data;

dialog = gtk_widget_get_toplevel(done);

revert_button = revert;

if(num_items > 1)
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pos_spin),
(gfloat) backup.pos + 1);
g_signal_connect_swapped(revert, "clicked",
G_CALLBACK(item_revert_options), NULL);

menu_item_apply_options();
g_signal_connect_swapped(done, "clicked",
G_CALLBACK(item_apply_options), NULL);

item_add_options(container);
}

/* Menu item dialogs
* -----------------
* Edit or add menu items
*/
GtkWidget *create_menu_item_dialog(MenuItem * mi)
GtkWidget *create_menu_item_dialog(Item * mi)
{
char *title;
GtkWidget *dlg;
@@ -953,18 +869,19 @@ GtkWidget *create_menu_item_dialog(MenuItem * mi)

frame = gtk_frame_new(NULL);
gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_NONE);
gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
gtk_container_set_border_width(GTK_CONTAINER(frame), 6);
gtk_widget_show(frame);
gtk_box_pack_start(GTK_BOX(main_vbox), frame, TRUE, TRUE, 0);

menu_item_add_options(mi, GTK_CONTAINER(frame));
config_item = mi;
item_add_options(GTK_CONTAINER(frame));

/* signals */
g_signal_connect(revert_button, "clicked",
G_CALLBACK(menu_item_revert_options), NULL);
G_CALLBACK(item_revert_options), NULL);

g_signal_connect(done_button, "clicked",
G_CALLBACK(menu_item_apply_options), NULL);
G_CALLBACK(item_apply_options), NULL);

return dlg;
}
@@ -978,15 +895,14 @@ static void reposition_popup(PanelPopup * pp)
gtk_button_clicked(GTK_BUTTON(pp->button));
}

void edit_menu_item_dialog(MenuItem * mi)
void edit_menu_item_dialog(Item * mi)
{
GtkWidget *dlg;
PanelPopup *pp = mi->parent;

mitem = mi;
pitem = NULL;
config_item = mi;

num_items = g_list_length(mi->parent->items);
num_items = g_list_length(pp->items);

dlg = create_menu_item_dialog(mi);

@@ -1010,7 +926,7 @@ void edit_menu_item_dialog(MenuItem * mi)
{
gtk_container_remove(GTK_CONTAINER(pp->item_vbox), mi->button);
pp->items = g_list_remove(pp->items, mi);
menu_item_free(mi);
item_free(mi);

reposition_popup(pp);
}
@@ -1023,25 +939,19 @@ void edit_menu_item_dialog(MenuItem * mi)

clear_backup();

if(icon_path)
{
g_free(icon_path);
icon_path = NULL;
}

write_panel_config();
}

void add_menu_item_dialog(PanelPopup * pp)
{
MenuItem *mi = menu_item_new(pp);
Item *mi = menu_item_new(pp);

create_menu_item(mi);
mi->pos = 0;

panel_popup_add_item(pp, mi);

reposition_popup(pp);

edit_menu_item_dialog(mi);
}


+ 1
- 1
panel/item_dialog.h View File

@@ -22,7 +22,7 @@

#include "global.h"

void edit_menu_item_dialog(MenuItem * mi);
void edit_menu_item_dialog(Item * mi);

void add_menu_item_dialog(PanelPopup * pp);



+ 20
- 242
panel/popup.c View File

@@ -25,232 +25,10 @@

#include "xfce.h"
#include "popup.h"
#include "item.h"
#include "callbacks.h"
#include "settings.h"

/* Menu items
* ----------
*/
MenuItem *menu_item_new(PanelPopup * pp)
{
MenuItem *mi = g_new(MenuItem, 1);

mi->parent = pp;
mi->pos = 0;

mi->command = NULL;
mi->in_terminal = FALSE;
mi->caption = NULL;
mi->tooltip = NULL;

mi->icon_id = UNKNOWN_ICON;
mi->icon_path = NULL;

mi->button = NULL;

return mi;
}

void menu_item_read_config(MenuItem * mi, xmlNodePtr node)
{
xmlNodePtr child;
xmlChar *value;

for(child = node->children; child; child = child->next)
{
if(xmlStrEqual(child->name, (const xmlChar *)"Caption"))
{
value = DATA(child);

if(value)
mi->caption = (char *)value;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Command"))
{
int n = -1;

value = DATA(child);

if(value)
mi->command = (char *)value;

value = xmlGetProp(child, "term");

if(value)
n = atoi(value);

if(n == 1)
mi->in_terminal = TRUE;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Tooltip"))
{
value = DATA(child);

if(value)
mi->tooltip = (char *)value;
}
else if(xmlStrEqual(child->name, (const xmlChar *)"Icon"))
{
value = xmlGetProp(child, (const xmlChar *)"id");

if(value)
mi->icon_id = atoi(value);

if(!value || mi->icon_id < EXTERN_ICON || mi->icon_id >= NUM_ICONS)
mi->icon_id = UNKNOWN_ICON;

g_free(value);

if(mi->icon_id == EXTERN_ICON)
{
value = DATA(child);

if(value)
mi->icon_path = (char *)value;
else
mi->icon_id = UNKNOWN_ICON;
}
}
}
}

void menu_item_write_xml(MenuItem * mi, xmlNodePtr root)
{
xmlNodePtr node;
xmlNodePtr child;
char value[3];

node = xmlNewTextChild(root, NULL, "Item", NULL);

xmlNewTextChild(node, NULL, "Caption", mi->caption);

child = xmlNewChild(node, NULL, "Command", mi->command);

snprintf(value, 2, "%d", mi->in_terminal);
xmlSetProp(child, "term", value);

if(mi->tooltip)
xmlNewTextChild(node, NULL, "Tooltip", mi->tooltip);

child = xmlNewTextChild(node, NULL, "Icon", mi->icon_path);

snprintf(value, 3, "%d", mi->icon_id);
xmlSetProp(child, "id", value);
}

void menu_item_free(MenuItem * mi)
{
g_free(mi->command);
g_free(mi->caption);
g_free(mi->tooltip);
g_free(mi->icon_path);

g_free(mi);
}

void menu_item_set_popup_size(MenuItem * mi, int size)
{
int s = popup_icon_size[size];

gtk_widget_set_size_request(mi->button, -1, s + border_width);
}

void menu_item_set_theme(MenuItem * mi, const char *theme)
{
GdkPixbuf *pb;
if(mi->icon_id <= EXTERN_ICON)
return;

pb = get_pixbuf_by_id(mi->icon_id);
xfce_menubutton_set_pixbuf(XFCE_MENUBUTTON(mi->button), pb);
g_object_unref(pb);
/* menu_item_set_popup_size(mi, settings.size);*/
}

void menu_item_apply_config(MenuItem * mi)
{
GdkPixbuf *pb = NULL;

xfce_menubutton_set_text(XFCE_MENUBUTTON(mi->button), mi->caption);
if(mi->icon_id == EXTERN_ICON)
pb = get_pixbuf_from_file(mi->icon_path);
else if (mi->icon_id != STOCK_ICON)
pb = get_pixbuf_by_id(mi->icon_id);

if (pb)
{
xfce_menubutton_set_pixbuf(XFCE_MENUBUTTON(mi->button), pb);
g_object_unref(pb);
}
menu_item_set_popup_size(mi, settings.size);

if(mi->tooltip)
add_tooltip(mi->button, mi->tooltip);
}

void create_addtomenu_item(MenuItem * mi)
{
mi->button = xfce_menubutton_new_with_stock_icon(_("Add launcher"), GTK_STOCK_ADD);
gtk_widget_show(mi->button);
gtk_button_set_relief(GTK_BUTTON(mi->button), GTK_RELIEF_NONE);

add_tooltip(mi->button, _("Add new item"));

/* signals */
dnd_set_drag_dest(mi->button);

g_signal_connect(mi->button, "drag_data_received",
G_CALLBACK(addtomenu_item_drop_cb), mi->parent);

g_signal_connect(mi->button, "clicked", G_CALLBACK(addtomenu_item_click_cb),
mi->parent);

menu_item_set_popup_size(mi, settings.size);
}

void create_menu_item(MenuItem * mi)
{
GdkPixbuf *pb = NULL;

mi->button = xfce_menubutton_new(mi->caption);
gtk_widget_show(mi->button);
gtk_button_set_relief(GTK_BUTTON(mi->button), GTK_RELIEF_NONE);

if(mi->icon_id == EXTERN_ICON && mi->icon_path)
pb = get_pixbuf_from_file(mi->icon_path);
else
pb = get_pixbuf_by_id(mi->icon_id);

if (pb)
{
xfce_menubutton_set_pixbuf(XFCE_MENUBUTTON(mi->button), pb);
g_object_unref(pb);
}

if(mi->tooltip && strlen(mi->tooltip))
add_tooltip(mi->button, mi->tooltip);
else if(mi->command && strlen(mi->command))
add_tooltip(mi->button, mi->command);
else
add_tooltip(mi->button, _("Click mouse button 3 to change item"));

/* signals */
g_signal_connect(mi->button, "button-press-event",
G_CALLBACK(menu_item_press), mi);

g_signal_connect(mi->button, "clicked", G_CALLBACK(menu_item_click_cb), mi);

dnd_set_drag_dest(mi->button);

g_signal_connect(mi->button, "drag_data_received",
G_CALLBACK(menu_item_drop_cb), mi);

menu_item_set_popup_size(mi, settings.size);
}

/* Popup menus
* -----------
*/
@@ -396,7 +174,7 @@ void panel_popup_unpack(PanelPopup * pp)
gtk_container_remove(GTK_CONTAINER(container), pp->button);
}

void panel_popup_add_item(PanelPopup * pp, MenuItem * mi)
void panel_popup_add_item(PanelPopup * pp, Item * mi)
{
GList *li;
int i;
@@ -408,13 +186,13 @@ void panel_popup_add_item(PanelPopup * pp, MenuItem * mi)

for(i = 0, li = pp->items; li && li->data; i++, li = li->next)
{
MenuItem *item = (MenuItem *) li->data;
Item *item = li->data;

item->pos = i;
}
}

void panel_popup_remove_item(PanelPopup * pp, MenuItem * mi)
void panel_popup_remove_item(PanelPopup * pp, Item * mi)
{
GList *li;
int i;
@@ -423,11 +201,11 @@ void panel_popup_remove_item(PanelPopup * pp, MenuItem * mi)

pp->items = g_list_remove(pp->items, mi);

menu_item_free(mi);
item_free(mi);

for(i = 0, li = pp->items; li && li->data; i++, li = li->next)
{
MenuItem *item = (MenuItem *) li->data;
Item *item = li->data;

item->pos = i;
}
@@ -436,39 +214,39 @@ void panel_popup_remove_item(PanelPopup * pp, MenuItem * mi)
void panel_popup_set_from_xml(PanelPopup * pp, xmlNodePtr node)
{
xmlNodePtr child;
int i = 0;
int i;

for(child = node->children; child; child = child->next)
for(i = 0, child = node->children; child; i++, child = child->next)
{
MenuItem *mi;
Item *mi;

if(!xmlStrEqual(child->name, (const xmlChar *)"Item"))
continue;

mi = menu_item_new(pp);
menu_item_read_config(mi, child);
item_read_config(mi, child);
create_menu_item(mi);

mi->pos = i;

panel_popup_add_item(pp, mi);

i++;
}
}

void panel_popup_write_xml(PanelPopup * pp, xmlNodePtr root)
{
xmlNodePtr node;
xmlNodePtr node, child;
GList *li;

node = xmlNewTextChild(root, NULL, "Popup", NULL);

for(li = pp->items; li; li = li->next)
{
MenuItem *mi = (MenuItem *) li->data;
Item *mi = li->data;

child = xmlNewTextChild(node, NULL, "Item", NULL);

menu_item_write_xml(mi, node);
item_write_config(mi, child);
}
}

@@ -478,8 +256,8 @@ void panel_popup_free(PanelPopup * pp)
GList *li;
for(li = pp->items; li && li->data; li = li->next)
{
MenuItem *mi = (MenuItem *) li->data;
menu_item_free(mi);
Item *mi = li->data;
item_free(mi);
}

g_free(pp);
@@ -504,7 +282,7 @@ void panel_popup_set_size(PanelPopup * pp, int size)
for(li = pp->items; li && li->data; li = li->next)
{
MenuItem *mi = (MenuItem *) li->data;
Item *mi = li->data;
menu_item_set_popup_size(mi, size);
}

@@ -547,8 +325,8 @@ void panel_popup_set_theme(PanelPopup * pp, const char *theme)

for(li = pp->items; li && li->data; li = li->next)
{
MenuItem *mi = (MenuItem *) li->data;
menu_item_set_theme(mi, theme);
Item *mi = li->data;
item_set_theme(mi, theme);
}
}


+ 4
- 29
panel/popup.h View File

@@ -37,28 +37,12 @@ struct _PanelPopup

GtkSizeGroup *hgroup;

MenuItem *addtomenu_item;
Item *addtomenu_item;
GtkWidget *separator;
GtkWidget *tearoff_button;

GtkWidget *item_vbox;
GList *items; /* type MenuItem */
};

struct _MenuItem
{
char *command;
gboolean in_terminal;
char *caption;
char *tooltip;

int icon_id;
char *icon_path;

PanelPopup *parent;
int pos;

GtkWidget *button;
GList *items; /* type Item */
};

/* Panel popups */
@@ -69,8 +53,8 @@ void panel_popup_free(PanelPopup * pp);
void panel_popup_pack(PanelPopup * pp, GtkBox * box);
void panel_popup_unpack(PanelPopup * pp);

void panel_popup_add_item(PanelPopup * pp, MenuItem * mi);
void panel_popup_remove_item(PanelPopup * pp, MenuItem * mi);
void panel_popup_add_item(PanelPopup * pp, Item * mi);
void panel_popup_remove_item(PanelPopup * pp, Item * mi);

void panel_popup_set_size(PanelPopup * pp, int size);
void panel_popup_set_popup_position(PanelPopup * pp, int position);
@@ -82,13 +66,4 @@ void hide_current_popup_menu(void);
void panel_popup_set_from_xml(PanelPopup * pp, xmlNodePtr node);
void panel_popup_write_xml(PanelPopup * pp, xmlNodePtr root);

/* Menu items */
MenuItem *menu_item_new(PanelPopup * pp);

void create_menu_item(MenuItem * mi);

void menu_item_free(MenuItem * mi);

void menu_item_apply_config(MenuItem * mi);

#endif /* __XFCE_POPUP_H__ */

BIN
po/de.gmo View File


BIN
po/es.gmo View File


BIN
po/fi.gmo View File


BIN
po/fr.gmo View File


BIN
po/nl.gmo View File


+ 1
- 1
settings/xfce_settings.h View File

@@ -20,7 +20,7 @@
#ifndef __XFCE_SETTINGS_H
#define __XFCE_SETTINGS_H

#define CHANNEL "xfce"
#define CHANNEL "XFCE"

/* IMPORTANT: keep this in sync with mcs_client.c */
enum {


Loading…
Cancel
Save