diff options
author | Jasper Huijsmans <jbhuijsmans@home.nl> | 2004-08-30 12:55:43 +0000 |
---|---|---|
committer | Jasper Huijsmans <jbhuijsmans@home.nl> | 2004-08-30 12:55:43 +0000 |
commit | 61be86b17dce8dba673c18d4da3e2c745cd74004 (patch) | |
tree | e0e249fca6c8fc101525e004dc239a322c25296c | |
parent | 7446e148d8e7aacf6a22899516b19c0a6b4d29a9 (diff) |
* Use XfceIconTheme (warning: still crashes)
* Add $ and clean up copyright statements
* Reindent using only spaces (more like Olivier's style)
(Old svn revision: 4117)
45 files changed, 1259 insertions, 1214 deletions
diff --git a/.indent.pro b/.indent.pro index 41ac50c3..e125466d 100644 --- a/.indent.pro +++ b/.indent.pro @@ -4,3 +4,4 @@ -cli4 -hnl -bad +-nut diff --git a/panel/add-control-dialog.c b/panel/add-control-dialog.c index 7bd27af0..83c02aaa 100644 --- a/panel/add-control-dialog.c +++ b/panel/add-control-dialog.c @@ -30,16 +30,18 @@ #include "add-control-dialog.h" /* Make sure translations are taken from the panel and not from some plugin */ +#ifdef ENABLE_NLS #undef _ #define _(s) dgettext (PACKAGE, s) +#endif typedef struct { Panel *panel; int position; - + GtkWidget *add_button; - + GSList *infolist; ControlInfo *current; } @@ -49,10 +51,11 @@ ControlList; static GtkWidget *the_dialog = NULL; /* prototypes */ -static void dialog_response (GtkWidget *dlg, int response, ControlList *list); +static void dialog_response (GtkWidget * dlg, int response, + ControlList * list); -static gboolean treeview_dblclick (GtkWidget *tv, GdkEventButton *evt, - ControlList *list); +static gboolean treeview_dblclick (GtkWidget * tv, GdkEventButton * evt, + ControlList * list); static void dialog_destroyed (ControlList * list); @@ -81,7 +84,7 @@ add_control_dialog (Panel * panel, int position) } panel_block_autohide (panel); - + dlg = gtk_dialog_new_with_buttons (_("Add new item"), GTK_WINDOW (panel->toplevel), GTK_DIALOG_DESTROY_WITH_PARENT | @@ -89,8 +92,8 @@ add_control_dialog (Panel * panel, int position) cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL); gtk_widget_show (cancel); - gtk_dialog_add_action_widget (GTK_DIALOG (dlg), cancel, - GTK_RESPONSE_CANCEL); + gtk_dialog_add_action_widget (GTK_DIALOG (dlg), cancel, + GTK_RESPONSE_CANCEL); add = gtk_button_new_from_stock (GTK_STOCK_ADD); GTK_WIDGET_SET_FLAGS (add, GTK_CAN_DEFAULT); @@ -125,12 +128,12 @@ add_control_dialog (Panel * panel, int position) gtk_widget_show (dlg); } -static void -dialog_response (GtkWidget *dlg, int response, ControlList *list) +static void +dialog_response (GtkWidget * dlg, int response, ControlList * list) { gtk_widget_hide (dlg); - + if (response == GTK_RESPONSE_OK) { insert_control (list->panel, list->current->name, list->position); @@ -185,7 +188,7 @@ dialog_destroyed (ControlList * list) } static void -add_spacer (GtkBox *box, int size) +add_spacer (GtkBox * box, int size) { GtkWidget *align; @@ -193,7 +196,7 @@ add_spacer (GtkBox *box, int size) gtk_widget_show (align); gtk_widget_set_size_request (align, size, size); gtk_box_pack_start (box, align, FALSE, FALSE, 0); -} +} static void add_header (GtkBox * box) @@ -229,7 +232,7 @@ cursor_changed (GtkTreeView * tv, ControlList * list) gtk_tree_selection_get_selected (sel, &model, &iter); gtk_tree_model_get (model, &iter, 0, &info, -1); - + list->current = info; if (info->can_be_added) @@ -260,8 +263,8 @@ render_text (GtkTreeViewColumn * col, GtkCellRenderer * cell, insensitive = !(info->can_be_added); - g_object_set (cell, "text", info->caption, "foreground-set", insensitive, - NULL); + g_object_set (cell, "text", info->caption, "foreground-set", insensitive, + NULL); } static ControlList * @@ -306,19 +309,19 @@ add_control_list (GtkBox * box) cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_cell_data_func (col, cell, - (GtkTreeCellDataFunc) render_icon, - NULL, NULL); + gtk_tree_view_column_set_cell_data_func (col, cell, + (GtkTreeCellDataFunc) + render_icon, NULL, NULL); cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, cell, TRUE); - gtk_tree_view_column_set_cell_data_func (col, cell, - (GtkTreeCellDataFunc) render_text, - tv, NULL); + gtk_tree_view_column_set_cell_data_func (col, cell, + (GtkTreeCellDataFunc) + render_text, tv, NULL); color = tv->style->fg[GTK_STATE_INSENSITIVE]; g_object_set (cell, "foreground-gdk", &color, NULL); - + /* fill model */ list = g_new0 (ControlList, 1); @@ -339,10 +342,11 @@ add_control_list (GtkBox * box) gtk_tree_view_set_cursor (GTK_TREE_VIEW (tv), path, NULL, FALSE); gtk_tree_path_free (path); - g_signal_connect (tv, "cursor_changed", G_CALLBACK (cursor_changed), list); - - g_signal_connect (tv, "button-press-event", - G_CALLBACK (treeview_dblclick), list); + g_signal_connect (tv, "cursor_changed", G_CALLBACK (cursor_changed), + list); + + g_signal_connect (tv, "button-press-event", + G_CALLBACK (treeview_dblclick), list); gtk_widget_set_size_request (tv, 300, 300); diff --git a/panel/add-control-dialog.h b/panel/add-control-dialog.h index ef9da0a8..4d03a978 100644 --- a/panel/add-control-dialog.h +++ b/panel/add-control-dialog.h @@ -22,9 +22,9 @@ #include <panel/global.h> -G_BEGIN_DECLS +G_BEGIN_DECLS -void add_control_dialog (Panel *panel, int position); +void add_control_dialog (Panel * panel, int position); G_END_DECLS diff --git a/panel/controls.c b/panel/controls.c index daeaad25..872e3fd8 100644 --- a/panel/controls.c +++ b/panel/controls.c @@ -1,4 +1,4 @@ -/* controls.c +/* $Id$ * * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * @@ -60,7 +60,7 @@ #define API_VERSION 5 -#define UNLOAD_TIMEOUT 30000 /* 30 secs */ +#define UNLOAD_TIMEOUT 30000 /* 30 secs */ /* Make sure translations are taken from the panel and not from some plugin */ #ifdef ENABLE_NLS @@ -78,10 +78,10 @@ struct _ControlClassInfo * these values when the module is unloaded */ char *name; char *caption; - + /* private info */ char *path; - int refcount; + int refcount; gboolean unique; GdkPixbuf *icon; gboolean unloadable; @@ -104,9 +104,9 @@ wait_for_unloading (void) while (unloading) { DBG ("unloading in progress"); - g_usleep (200*1000); + g_usleep (200 * 1000); } - + } /* ControlClass and ControlClassInfo @@ -119,8 +119,8 @@ compare_class_info_by_name (gconstpointer info, gconstpointer name) g_assert (info != NULL); g_assert (name != NULL); - return g_ascii_strcasecmp (((ControlClassInfo *)info)->name, - (char *)name); + return g_ascii_strcasecmp (((ControlClassInfo *) info)->name, + (char *) name); } static gint @@ -132,10 +132,11 @@ lookup_info_by_filename (gconstpointer info, gconstpointer filename) g_assert (info != NULL); g_assert (filename != NULL); - if (((ControlClassInfo *)info)->class->gmodule) + if (((ControlClassInfo *) info)->class->gmodule) { - fn = g_path_get_basename ( - g_module_name(((ControlClassInfo *)info)->class->gmodule)); + fn = g_path_get_basename (g_module_name + (((ControlClassInfo *) info)->class-> + gmodule)); result = g_ascii_strcasecmp (fn, filename); g_free (fn); @@ -150,8 +151,10 @@ control_class_info_free (ControlClassInfo * cci) g_free (cci->path); g_free (cci->name); g_free (cci->caption); + if (cci->icon) g_object_unref (cci->icon); + g_free (cci); } @@ -170,31 +173,31 @@ control_class_free (ControlClass * cc) } static ControlClassInfo * -get_control_class_info (ControlClass *cc) +get_control_class_info (ControlClass * cc) { ControlClassInfo *info; - + g_return_val_if_fail (cc->name != NULL, NULL); - - if (info_to_add && + + if (info_to_add && g_ascii_strcasecmp (info_to_add->class->name, cc->name) == 0) { info = info_to_add; } else { - GSList *li = - g_slist_find_custom (control_class_info_list, - cc->name, compare_class_info_by_name); + GSList *li = g_slist_find_custom (control_class_info_list, + cc->name, + compare_class_info_by_name); - info = li->data; + info = li->data; } - + return info; } static gboolean -control_class_info_create_control (ControlClassInfo *info, Control *control) +control_class_info_create_control (ControlClassInfo * info, Control * control) { g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (control != NULL, FALSE); @@ -204,10 +207,10 @@ control_class_info_create_control (ControlClassInfo *info, Control *control) info->class->create_control (control); return TRUE; } - - wait_for_unloading(); - if (info->class->id == PLUGIN && info->refcount == 0 && + wait_for_unloading (); + + if (info->class->id == PLUGIN && info->refcount == 0 && info->class->gmodule == NULL) { GModule *gm; @@ -215,7 +218,7 @@ control_class_info_create_control (ControlClassInfo *info, Control *control) void (*init) (ControlClass * cc); gm = info->class->gmodule = g_module_open (info->path, 0); - + if (!g_module_symbol (gm, "xfce_control_class_init", &symbol)) goto failed; @@ -225,12 +228,12 @@ control_class_info_create_control (ControlClassInfo *info, Control *control) if (info->unique && info->refcount > 0) goto failed; - + info->refcount++; return info->class->create_control (control); -failed: + failed: return FALSE; } @@ -252,7 +255,7 @@ load_plugin (gchar * path) gpointer symbol; DBG ("Load module: %s", path); - + gm = g_module_open (path, 0); if (gm && g_module_symbol (gm, "xfce_control_class_init", &symbol)) @@ -260,35 +263,35 @@ load_plugin (gchar * path) ControlClassInfo *info; ControlClass *cc; void (*init) (ControlClass * cc); - + info = g_new0 (ControlClassInfo, 1); cc = info->class = g_new0 (ControlClass, 1); - + info->unloadable = TRUE; cc->id = PLUGIN; cc->gmodule = gm; - + /* keep track of info structure we are about to add */ info_to_add = info; - + /* fill in the class structure */ init = symbol; init (cc); info_to_add = NULL; - if (g_slist_find_custom (control_class_info_list, - cc->name, compare_class_info_by_name)) + if (g_slist_find_custom (control_class_info_list, + cc->name, compare_class_info_by_name)) { control_class_free (cc); control_class_info_free (info); } else { - control_class_info_list = + control_class_info_list = g_slist_append (control_class_info_list, info); - + cc->filename = g_path_get_basename (path); info->path = g_strdup (path); info->name = g_strdup (cc->name); @@ -298,7 +301,7 @@ load_plugin (gchar * path) else if (gm) { g_warning ("%s: incompatible module %s", PACKAGE, path); - + g_module_close (gm); } else @@ -342,7 +345,7 @@ add_plugin_classes (void) wait_for_unloading (); unloading++; - + dirs = get_plugin_dirs (); for (d = dirs; *d; d++) @@ -352,29 +355,30 @@ add_plugin_classes (void) g_strfreev (dirs); } -static void +static void clean_plugin_classes (void) { GSList *li, *prev; prev = control_class_info_list; - + for (li = control_class_info_list->next; li; li = li->next) { ControlClassInfo *info = li->data; - + if (g_file_test (info->path, G_FILE_TEST_EXISTS) || info->refcount > 0) { - DBG ("plugin %s exists, %d in use", info->caption, info->refcount); + DBG ("plugin %s exists, %d in use", info->caption, + info->refcount); prev = li; } else { GSList *tmp; - + DBG ("plugin %s (%s) was removed", info->name, info->path); - + tmp = li; li = prev; li->next = tmp->next; @@ -393,8 +397,8 @@ add_launcher_class (void) { ControlClassInfo *info; ControlClass *cc; - - info = g_new0(ControlClassInfo, 1); + + info = g_new0 (ControlClassInfo, 1); cc = info->class = g_new0 (ControlClass, 1); panel_item_class_init (cc); @@ -416,16 +420,15 @@ unload_modules (void) return TRUE; unloading++; - + /* first item is launcher */ for (li = control_class_info_list->next; li != NULL; li = li->next) { ControlClassInfo *info = li->data; - if (info->unloadable && - info->class->id == PLUGIN && - info->refcount == 0 && - info->class->gmodule != NULL) + if (info->unloadable && + info->class->id == PLUGIN && + info->refcount == 0 && info->class->gmodule != NULL) { DBG ("unload %s", info->caption); @@ -433,9 +436,9 @@ unload_modules (void) info->class->gmodule = NULL; } } - + unloading--; - + return TRUE; } @@ -448,7 +451,7 @@ control_class_list_init (void) add_launcher_class (); add_plugin_classes (); - unload_id = + unload_id = g_timeout_add (UNLOAD_TIMEOUT, (GSourceFunc) unload_modules, NULL); } @@ -458,13 +461,13 @@ control_class_list_cleanup (void) GSList *li; unloading++; - + if (unload_id) { g_source_remove (unload_id); unload_id = 0; } - + for (li = control_class_info_list; li; li = li->next) { ControlClassInfo *info = li->data; @@ -478,8 +481,8 @@ control_class_list_cleanup (void) unloading--; } -void -control_class_set_unique (ControlClass *cclass, gboolean unique) +void +control_class_set_unique (ControlClass * cclass, gboolean unique) { ControlClassInfo *info; @@ -489,8 +492,8 @@ control_class_set_unique (ControlClass *cclass, gboolean unique) info->unique = unique; } -void -control_class_set_icon (ControlClass *cclass, GdkPixbuf *icon) +void +control_class_set_icon (ControlClass * cclass, GdkPixbuf * icon) { ControlClassInfo *info; @@ -508,8 +511,8 @@ control_class_set_icon (ControlClass *cclass, GdkPixbuf *icon) } } -void -control_class_set_unloadable (ControlClass *cclass, gboolean unloadable) +void +control_class_set_unloadable (ControlClass * cclass, gboolean unloadable) { ControlClassInfo *info; @@ -519,11 +522,11 @@ control_class_set_unloadable (ControlClass *cclass, gboolean unloadable) info->unloadable = unloadable; } - + /* not in header, but exported for groups.c */ -void -control_class_unref (ControlClass *cclass) +void +control_class_unref (ControlClass * cclass) { ControlClassInfo *info; @@ -540,19 +543,19 @@ sort_control_func (gpointer a, gpointer b) ControlInfo *cb = (ControlInfo *) b; if ((!ca) || (!ca->caption)) - return -1; - + return -1; + if ((!cb) || (!cb->caption)) - return 1; - + return 1; + return g_utf8_collate (ca->caption, cb->caption); } static ControlInfo * -create_control_info (ControlClassInfo *info) +create_control_info (ControlClassInfo * info) { ControlInfo *ci; - + ci = g_new0 (ControlInfo, 1); ci->name = g_strdup (info->name); @@ -560,7 +563,7 @@ create_control_info (ControlClassInfo *info) ci->icon = info->icon != NULL ? g_object_ref (info->icon) : NULL; ci->can_be_added = !(info->unique && info->refcount > 0); - + return ci; } @@ -574,17 +577,18 @@ get_control_info_list (void) /* good place to remove plugins that are not in use and were * uninstalled after the panel was started */ clean_plugin_classes (); - + /* update module list */ add_plugin_classes (); - - launcherinfo = - create_control_info ((ControlClassInfo*)control_class_info_list->data); - + + launcherinfo = + create_control_info ((ControlClassInfo *) control_class_info_list-> + data); + for (li = control_class_info_list->next; li; li = li->next) { ControlClassInfo *info = li->data; - + infolist = g_slist_prepend (infolist, create_control_info (info)); } @@ -596,14 +600,14 @@ get_control_info_list (void) return infolist; } -void -insert_control (Panel *panel, const char *name, int position) +void +insert_control (Panel * panel, const char *name, int position) { gboolean hidden = settings.autohide; Control *control; ControlClassInfo *info; GSList *list; - + if (hidden) { DBG ("unhide before adding new item"); @@ -613,8 +617,8 @@ insert_control (Panel *panel, const char *name, int position) gtk_main_iteration (); } - list = g_slist_find_custom (control_class_info_list, name, - compare_class_info_by_name); + list = g_slist_find_custom (control_class_info_list, name, + compare_class_info_by_name); if (G_UNLIKELY (list == NULL)) { @@ -623,11 +627,11 @@ insert_control (Panel *panel, const char *name, int position) goto out; } - info = list->data; + info = list->data; control = control_new (position); control->cclass = info->class; - + if (control_class_info_create_control (info, control)) { hide_current_popup_menu (); @@ -646,7 +650,7 @@ insert_control (Panel *panel, const char *name, int position) xfce_err (_("Could not create panel item \"%s\"."), info->caption); } -out: + out: popup_control = NULL; if (hidden) @@ -657,7 +661,7 @@ static void run_add_control_dialog (void) { int position; - + position = popup_control ? popup_control->index : -1; add_control_dialog (&panel, position); @@ -689,8 +693,7 @@ remove_control (void) if (!(popup_control->with_popup) || !pp || pp->items == NULL || xfce_confirm (_("Removing the item will also remove " - "its popup menu."), - GTK_STOCK_REMOVE, NULL)) + "its popup menu."), GTK_STOCK_REMOVE, NULL)) { groups_remove (popup_control->index); } @@ -700,7 +703,7 @@ remove_control (void) } static void -add_control (GtkWidget * w, ControlClassInfo *info) +add_control (GtkWidget * w, ControlClassInfo * info) { gboolean hidden = settings.autohide; Control *control; @@ -719,7 +722,7 @@ add_control (GtkWidget * w, ControlClassInfo *info) control = control_new (index); control->cclass = info->class; - + if (control_class_info_create_control (info, control)) { groups_add_control (control, index); @@ -748,19 +751,19 @@ get_controls_submenu (void) { static GtkWidget *menu = NULL; GSList *li; - + if (menu) gtk_widget_destroy (menu); menu = gtk_menu_new (); - + for (li = control_class_info_list; li != NULL; li = li->next) { ControlClassInfo *info = li->data; GtkWidget *item; DBG ("info: %s (%s)", info->caption, info->name); - + item = gtk_menu_item_new_with_label (info->caption); gtk_widget_show (item); gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); @@ -785,16 +788,16 @@ get_control_menu (void) menu = gtk_menu_new (); /* replaced with actual name */ - mi = gtk_menu_item_new_with_label("Item"); + mi = gtk_menu_item_new_with_label ("Item"); gtk_widget_show (mi); gtk_widget_set_sensitive (mi, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - + + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("_Properties...")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (edit_control), NULL); @@ -804,20 +807,20 @@ get_control_menu (void) gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (remove_control), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - mi = gtk_menu_item_new_with_mnemonic(_("Add _new item")); + + mi = gtk_menu_item_new_with_mnemonic (_("Add _new item")); gtk_widget_show (mi); - g_signal_connect (mi, "activate", G_CALLBACK (run_add_control_dialog), + g_signal_connect (mi, "activate", G_CALLBACK (run_add_control_dialog), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); } g_assert (menu != NULL); - + return menu; } @@ -840,9 +843,9 @@ control_press_cb (GtkWidget * b, GdkEventButton * ev, Control * control) menu = get_control_menu (); /* update first item */ - item = GTK_MENU_SHELL(menu)->children->data; + item = GTK_MENU_SHELL (menu)->children->data; label = gtk_bin_get_child (GTK_BIN (item)); - gtk_label_set_text (GTK_LABEL (label), + gtk_label_set_text (GTK_LABEL (label), popup_control->cclass->caption); panel_register_open_menu (menu); @@ -914,8 +917,8 @@ create_control (Control * control, int id, const char *filename) control_set_settings (control); return TRUE; - -failed: + + failed: return FALSE; } diff --git a/panel/controls.h b/panel/controls.h index 43898e40..4a574c0d 100644 --- a/panel/controls.h +++ b/panel/controls.h @@ -1,6 +1,6 @@ -/* controls.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,13 +78,13 @@ typedef struct char *name; char *caption; GdkPixbuf *icon; - gboolean can_be_added; /* not unique or not already added */ + gboolean can_be_added; /* not unique or not already added */ } ControlInfo; GSList *get_control_info_list (void); -void insert_control (Panel *panel, const char *name, int position); +void insert_control (Panel * panel, const char *name, int position); /* control classes */ void control_class_list_init (void); @@ -94,11 +94,12 @@ void control_class_list_cleanup (void); /* NOTE: * Use next functions only on classes that have at least * their name field initialized */ -void control_class_set_icon (ControlClass *cclass, GdkPixbuf *icon); +void control_class_set_icon (ControlClass * cclass, GdkPixbuf * icon); -void control_class_set_unique (ControlClass *cclass, gboolean unique); +void control_class_set_unique (ControlClass * cclass, gboolean unique); -void control_class_set_unloadable (ControlClass *cclass, gboolean unloadable); +void control_class_set_unloadable (ControlClass * cclass, + gboolean unloadable); /* add controls menu */ GtkWidget *get_controls_submenu (void); diff --git a/panel/controls_dialog.c b/panel/controls_dialog.c index 9d98d346..abdf4b75 100644 --- a/panel/controls_dialog.c +++ b/panel/controls_dialog.c @@ -1,6 +1,6 @@ -/* controls_dialog.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,11 +52,11 @@ static GtkWidget *cdialog = NULL; /* container for control options */ static void -add_container (GtkBox * box, GtkWidget *close, Control *control) +add_container (GtkBox * box, GtkWidget * close, Control * control) { GtkWidget *align; - align = gtk_alignment_new (0,0,1,1); + align = gtk_alignment_new (0, 0, 1, 1); gtk_widget_show (align); gtk_container_set_border_width (GTK_CONTAINER (align), BORDER); gtk_box_pack_start (box, align, TRUE, TRUE, 0); @@ -67,7 +67,7 @@ add_container (GtkBox * box, GtkWidget *close, Control *control) /* position */ static void -pos_changed (GtkSpinButton * spin, Control *control) +pos_changed (GtkSpinButton * spin, Control * control) { int n; @@ -81,11 +81,11 @@ pos_changed (GtkSpinButton * spin, Control *control) } static void -add_position_option (GtkBox *box, Control *control) +add_position_option (GtkBox * box, Control * control) { GtkWidget *pos_spin, *hbox, *label; int n; - + hbox = gtk_hbox_new (FALSE, BORDER); gtk_container_set_border_width (GTK_CONTAINER (hbox), BORDER); gtk_widget_show (hbox); @@ -97,15 +97,15 @@ add_position_option (GtkBox *box, Control *control) gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); n = groups_get_n_controls (); - + if (n > 1) { pos_spin = gtk_spin_button_new_with_range (1, n, 1); - - gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin), + + gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin), control->index + 1); - g_signal_connect (pos_spin, "value-changed", + g_signal_connect (pos_spin, "value-changed", G_CALLBACK (pos_changed), control); } else @@ -119,11 +119,12 @@ add_position_option (GtkBox *box, Control *control) /* main dialog */ -static void add_spacer (GtkBox *box, int size) +static void +add_spacer (GtkBox * box, int size) { GtkWidget *align; - align = gtk_alignment_new (0,0,0,0); + align = gtk_alignment_new (0, 0, 0, 0); gtk_widget_set_size_request (align, size, size); gtk_widget_show (align); gtk_box_pack_start (box, align, FALSE, FALSE, 0); @@ -147,7 +148,7 @@ controls_dialog (Control * control) /* keep gcc3 happy -- warns about this: (gpointer *)&cdialog; */ ptr = &cdialog; - g_object_add_weak_pointer (G_OBJECT (cdialog), (gpointer *)ptr); + g_object_add_weak_pointer (G_OBJECT (cdialog), (gpointer *) ptr); gtk_dialog_set_has_separator (dlg, FALSE); @@ -166,14 +167,14 @@ controls_dialog (Control * control) GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); header = xfce_create_header (NULL, control->cclass->caption); - gtk_container_set_border_width (GTK_CONTAINER (GTK_BIN (header)->child), - BORDER); + gtk_container_set_border_width (GTK_CONTAINER (GTK_BIN (header)->child), + BORDER); gtk_widget_set_size_request (header, -1, 32); gtk_widget_show (header); gtk_box_pack_start (GTK_BOX (dlg->vbox), header, FALSE, TRUE, 0); add_spacer (GTK_BOX (dlg->vbox), BORDER); - + /* position */ add_position_option (GTK_BOX (dlg->vbox), control); @@ -204,8 +205,7 @@ retry: if (!(control->with_popup) || !pp || pp->items == NULL || xfce_confirm (_("Removing the item will also remove " - "its popup menu."), - GTK_STOCK_REMOVE, NULL)) + "its popup menu."), GTK_STOCK_REMOVE, NULL)) { groups_remove (control->index); } diff --git a/panel/controls_dialog.h b/panel/controls_dialog.h index 274fece2..8c2bca22 100644 --- a/panel/controls_dialog.h +++ b/panel/controls_dialog.h @@ -1,6 +1,6 @@ -/* controls_dialog.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright (C) 2002,2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/global.h b/panel/global.h index 23736793..b80b23ed 100644 --- a/panel/global.h +++ b/panel/global.h @@ -1,6 +1,6 @@ -/* global.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,9 +83,9 @@ extern int popup_icon_size[PANEL_SIZES]; /* types for panel controls */ enum { - ICON = -2, /* special case: the traditional laucher item */ - PLUGIN = -1, /* external plugin */ - NUM_BUILTINS /* no more builtins! yay! */ + ICON = -2, /* special case: the traditional laucher item */ + PLUGIN = -1, /* external plugin */ + NUM_BUILTINS /* no more builtins! yay! */ }; /* global settings */ diff --git a/panel/groups.c b/panel/groups.c index f34fce3f..0d35538d 100644 --- a/panel/groups.c +++ b/panel/groups.c @@ -42,7 +42,7 @@ #include "popup.h" /* defined in controls.c */ -extern void control_class_unref (ControlClass *cclass); +extern void control_class_unref (ControlClass * cclass); static GSList *group_list = NULL; static GtkArrowType popup_arrow_type = GTK_ARROW_UP; @@ -57,7 +57,7 @@ struct _PanelGroup { int index; - GtkWidget *base; /* container to pack into panel */ + GtkWidget *base; /* container to pack into panel */ GtkWidget *box; PanelPopup *popup; @@ -311,8 +311,7 @@ groups_set_from_xml (xmlNodePtr node) { popup_node = child; } - else if (xmlStrEqual - (child->name, (const xmlChar *) "Control")) + else if (xmlStrEqual (child->name, (const xmlChar *) "Control")) { /* TODO: make this part of control creation */ if (popup_node) @@ -322,8 +321,8 @@ groups_set_from_xml (xmlNodePtr node) gtk_widget_hide (group->popup->button); panel_popup_set_from_xml (group->popup, popup_node); } - - control_created = + + control_created = control_set_from_xml (group->control, child); break; @@ -538,16 +537,16 @@ groups_remove (int index) li = g_slist_nth (group_list, index); /* Paranoid, should not happen here */ - if (!li) - return; - + if (!li) + return; + group = li->data; DBG ("unref class %s", group->control->cclass->caption); control_class_unref (group->control->cclass); - + panel_group_unpack (group); - + group_list = g_slist_delete_link (group_list, li); panel_group_free (group); @@ -569,8 +568,8 @@ groups_show_popup (int index, gboolean show) PanelGroup *group; li = g_slist_nth (group_list, index); - if (!li) - return; + if (!li) + return; group = li->data; @@ -579,7 +578,7 @@ groups_show_popup (int index, gboolean show) group->popup = create_panel_popup (); panel_group_arrange (group); } - + if (group->popup) { if (show) @@ -590,7 +589,7 @@ groups_show_popup (int index, gboolean show) } void -groups_add_control (Control *control, int index) +groups_add_control (Control * control, int index) { int len; PanelGroup *group = NULL; diff --git a/panel/groups.h b/panel/groups.h index 492e240e..1c276624 100644 --- a/panel/groups.h +++ b/panel/groups.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ PanelPopup *groups_get_popup (int index); void groups_move (int from, int to); void groups_remove (int index); void groups_show_popup (int index, gboolean show); -void groups_add_control (Control *control, int index); +void groups_add_control (Control * control, int index); int groups_get_n_controls (void); diff --git a/panel/icons.c b/panel/icons.c index 6aba3169..75ae111a 100644 --- a/panel/icons.c +++ b/panel/icons.c @@ -22,6 +22,7 @@ #endif #include <libxfce4util/libxfce4util.h> +#include <libxfcegui4/xfce-icontheme.h> #include "xfce.h" @@ -29,12 +30,13 @@ #define gdk_pixbuf_new_from_inline gdk_pixbuf_new_from_stream #endif +static XfceIconTheme *global_icon_theme = NULL; + const char *icon_names[NUM_ICONS]; /* icon themes */ /* TODO: Someone please get me a list of names that give a fully themed panel * for all major icon themes. - */ static char *xfce_icon_names[][4] = { {"xfce-unknown", "gnome-fs-executable", "exec", NULL}, {"xfce-edit", "gedit-icon", "edit", NULL}, @@ -50,15 +52,21 @@ static char *xfce_icon_names[][4] = { {"xfce-sound", "gnome-audio", "sound", NULL}, {"xfce-terminal", "gnome-terminal", "terminal", NULL}, }; + */ -/* icons for the panel */ -/* TODO: add kde names */ -static char *minibutton_names[][3] = { - {"xfce-system-lock", "gnome-lockscreen", NULL}, - {"xfce-system-info", "gnome-info", NULL}, - {"xfce-system-settings", "gnome-settings", NULL}, - {"xfce-system-exit", "gnome-logout", NULL}, -}; +static void +icon_theme_changed (XfceIconTheme * icontheme) +{ + char *theme; + + g_object_get (gtk_settings_get_default (), "gtk-icon-theme-name", + &theme, NULL); + + DBG ("Theme: %s\n", theme); + panel_set_theme (theme); + + g_free (theme); +} void icons_init (void) @@ -78,88 +86,157 @@ icons_init (void) icon_names[++i] = _("Productivity"); icon_names[++i] = _("Sound"); icon_names[++i] = _("Terminal"); + + global_icon_theme = xfce_icon_theme_get_for_screen (NULL); +} + +void +icon_theme_init (void) +{ + g_signal_connect (global_icon_theme, "changed", + G_CALLBACK (icon_theme_changed), NULL); } GdkPixbuf * themed_pixbuf_from_name_list (char **namelist, int size) { - GdkPixbuf *pb = NULL, *fallback = NULL; - + GdkPixbuf *pb; + char *icon = NULL, *fallback = NULL; + for (; namelist[0] != NULL; ++namelist) { - char *iconname = xfce_themed_icon_lookup (namelist[0], size); + icon = xfce_icon_theme_lookup (global_icon_theme, namelist[0], size); - if (iconname) + if (icon && (strstr (icon, "hicolor") || strstr (icon, "pixmaps"))) { - gboolean is_fallback = FALSE; - - is_fallback = strstr (iconname, "/hicolor/") != NULL - || strstr (iconname, "/pixmaps/") != NULL; - - DBG ("Icon: %s %s\n", iconname, is_fallback ? "(fallback)" : ""); - - if (is_fallback) - { - if (!fallback) - { - fallback = - xfce_pixbuf_new_from_file_at_size (iconname, - size, size, NULL); - } - } + if (!fallback) + fallback = icon; else - { - pb = xfce_pixbuf_new_from_file_at_size (iconname, - size, size, NULL); - - if (pb) - break; - } - - g_free (iconname); + g_free (icon); + + icon = NULL; } + + if (icon) + break; } - if (pb) + if (icon) { - if (fallback) - g_object_unref (fallback); - - return pb; + pb = gdk_pixbuf_new_from_file (icon, NULL); } + else if (fallback) + { + pb = gdk_pixbuf_new_from_file (fallback, NULL); + } + else + { + pb = xfce_icon_theme_load_category (global_icon_theme, + XFCE_ICON_CATEGORY_UNKNOWN, size); + } + + g_free (icon); + g_free (fallback); - return fallback; + return pb; } GdkPixbuf * get_pixbuf_by_id (int id) { - GdkPixbuf *pb; - - if (id < UNKNOWN_ICON || id >= NUM_ICONS) - id = UNKNOWN_ICON; - - pb = themed_pixbuf_from_name_list (xfce_icon_names [id], - icon_size[settings.size]); - - if (!pb && id != UNKNOWN_ICON) - return get_pixbuf_by_id (UNKNOWN_ICON); + char *icon = NULL; + GdkPixbuf *pb = NULL; - return pb; -} + switch (id) + { + case EDIT_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_EDITOR, + icon_size[settings.size]); + break; + case FILE1_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_FILEMAN, + icon_size[settings.size]); + break; + case FILE2_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_UTILITY, + icon_size[settings.size]); + break; + case GAMES_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_GAME, + icon_size[settings.size]); + break; + case MAN_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_HELP, + icon_size[settings.size]); + break; + case MULTIMEDIA_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_MULTIMEDIA, + icon_size[settings.size]); + break; + case NETWORK_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_NETWORK, + icon_size[settings.size]); + break; + case PAINT_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_GRAPHICS, + icon_size[settings.size]); + break; + case PRINT_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_PRINTER, + icon_size[settings.size]); + break; + case SCHEDULE_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_PRODUCTIVITY, + icon_size[settings.size]); + break; + case SOUND_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_SOUND, + icon_size[settings.size]); + break; + case TERMINAL_ICON: + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_TERMINAL, + icon_size[settings.size]); + break; + } -GdkPixbuf * -get_minibutton_pixbuf (int id) -{ - GdkPixbuf *pb; + if (!icon) + { + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_UNKNOWN, + icon_size[settings.size]); + } - if (id < 0 || id >= MINIBUTTONS) - return get_pixbuf_by_id (UNKNOWN_ICON); + if (icon) + { + pb = gdk_pixbuf_new_from_file (icon, NULL); - pb = themed_pixbuf_from_name_list (minibutton_names [id], 16); - - if (!pb) - return get_pixbuf_by_id (UNKNOWN_ICON); + g_free (icon); + } return pb; } @@ -167,15 +244,29 @@ get_minibutton_pixbuf (int id) GdkPixbuf * get_pixbuf_from_file (const char *path) { - GdkPixbuf *pb; + char *icon = NULL; + GdkPixbuf *pb = NULL; if (!g_file_test (path, G_FILE_TEST_EXISTS)) - return get_pixbuf_by_id (UNKNOWN_ICON); + { + icon = xfce_icon_theme_lookup (global_icon_theme, path, + icon_size[settings.size]); + } + + if (!icon) + { + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_UNKNOWN, + icon_size[settings.size]); + } - pb = xfce_themed_icon_load (path, icon_size[settings.size]); + if (icon) + { + pb = gdk_pixbuf_new_from_file (icon, NULL); - if (!pb) - return get_pixbuf_by_id (UNKNOWN_ICON); + g_free (icon); + } return pb; } @@ -183,7 +274,19 @@ get_pixbuf_from_file (const char *path) GdkPixbuf * get_panel_pixbuf (void) { - return xfce_themed_icon_load ("xfce4-panel", 48); + char *icon = NULL; + GdkPixbuf *pb = NULL; + + icon = xfce_icon_theme_lookup (global_icon_theme, "xfce4-panel", 48); + + if (icon) + { + pb = gdk_pixbuf_new_from_file (icon, NULL); + + g_free (icon); + } + + return pb; } GdkPixbuf * @@ -228,29 +331,23 @@ get_scaled_pixbuf (GdkPixbuf * pb, int size) GdkPixbuf * get_themed_pixbuf (const char *name) { + char *icon = NULL; GdkPixbuf *pb = NULL; - gchar *p, *rootname = g_strdup(name); - if ((p=g_strrstr(rootname, "."))) + icon = xfce_icon_theme_lookup (global_icon_theme, name, 48); + + if (!icon) { - if (strlen(rootname) - (p-rootname) <= 5) - *p = 0; + icon = + xfce_icon_theme_lookup_category (global_icon_theme, + XFCE_ICON_CATEGORY_UNKNOWN, 48); } - pb = xfce_themed_icon_load (rootname, 48); - g_free(rootname); - - if (!pb) + if (icon) { - int size = settings.size; - - /* usually the pixbuf will be scaled afterwards, so we want to get a - * decent size, even for a 'missing' icon ;-) */ - settings.size = LARGE; - pb = get_pixbuf_by_id (UNKNOWN_ICON); - settings.size = size; - - g_warning ("Couldn't find icon: %s\n", name); + pb = gdk_pixbuf_new_from_file (icon, NULL); + + g_free (icon); } return pb; diff --git a/panel/icons.h b/panel/icons.h index 923b47e7..7dfb9403 100644 --- a/panel/icons.h +++ b/panel/icons.h @@ -1,6 +1,6 @@ -/* icons.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,22 +46,13 @@ enum extern const char *icon_names[NUM_ICONS]; -/* system icons */ -enum -{ - MINILOCK_ICON, - MINIINFO_ICON, - MINIPALET_ICON, - MINIPOWER_ICON, - MINIBUTTONS -}; - #define UNKNOWN_ICON DEFAULT_ICON void icons_init (void); +void icon_theme_init (void); + GdkPixbuf *get_pixbuf_by_id (int id); -GdkPixbuf *get_minibutton_pixbuf (int id); GdkPixbuf *get_panel_pixbuf (void); diff --git a/panel/item.c b/panel/item.c index 783f8182..88af0595 100644 --- a/panel/item.c +++ b/panel/item.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002-2003 Jasper Huijsmans (jasper@xfce.org) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,7 +75,7 @@ item_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x, if (item->in_terminal) g_string_append_c (execute, '"'); - + g_string_append (execute, item->command); for (fnp = fnames; fnp; fnp = fnp->next, count--) @@ -118,7 +118,7 @@ item_click_cb (GtkButton * b, Item * item) } static gboolean -item_middle_click (GtkWidget *w, GdkEventButton *ev, Item *item) +item_middle_click (GtkWidget * w, GdkEventButton * ev, Item * item) { if (ev->button == 2) { @@ -540,7 +540,8 @@ create_menu_item (Item * mi) void menu_item_set_popup_size (Item * mi, int size) { - gtk_widget_set_size_request (mi->button, -1, popup_icon_size[size] + border_width); + gtk_widget_set_size_request (mi->button, -1, + popup_icon_size[size] + border_width); } /* Panel item @@ -560,10 +561,10 @@ 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 (item_middle_click), pi); diff --git a/panel/item.h b/panel/item.h index 98962391..e09daaea 100644 --- a/panel/item.h +++ b/panel/item.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/item_dialog.c b/panel/item_dialog.c index 4b2b604d..35c0cb57 100644 --- a/panel/item_dialog.c +++ b/panel/item_dialog.c @@ -1,4 +1,4 @@ -/* xfce4 +/* $Id$ * * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * @@ -66,13 +66,13 @@ struct _ItemDialog GtkContainer *container; GtkWidget *close; - + /* command */ CommandOptions *cmd_opts; /* icon */ IconOptions *icon_opts; - + /* Name and Tooltip */ GtkWidget *caption_entry; GtkWidget *tip_entry; @@ -103,12 +103,12 @@ static const char *keys[] = { /* useful widgets */ -static void -add_spacer (GtkBox *box, int size) +static void +add_spacer (GtkBox * box, int size) { GtkWidget *align; - align = gtk_alignment_new (0,0,0,0); + align = gtk_alignment_new (0, 0, 0, 0); gtk_widget_set_size_request (align, size, size); gtk_widget_show (align); gtk_box_pack_start (box, align, FALSE, FALSE, 0); @@ -120,18 +120,18 @@ add_spacer (GtkBox *box, int size) */ static void -combo_completion_cb (xfc_combo_info_t *info, CommandOptions *opts) +combo_completion_cb (xfc_combo_info_t * info, CommandOptions * opts) { const char *cmd; GtkToggleButton *tb; gboolean in_term; - cmd = gtk_entry_get_text (GTK_ENTRY(opts->command_entry)); + cmd = gtk_entry_get_text (GTK_ENTRY (opts->command_entry)); tb = GTK_TOGGLE_BUTTON (opts->term_checkbutton); in_term = history_check_in_terminal (cmd); gtk_toggle_button_set_active (tb, in_term); - + if (opts->on_change) { gboolean use_sn = FALSE; @@ -141,21 +141,21 @@ combo_completion_cb (xfc_combo_info_t *info, CommandOptions *opts) tb = GTK_TOGGLE_BUTTON (opts->sn_checkbutton); use_sn = gtk_toggle_button_get_active (tb); } - + opts->on_change (cmd, in_term, use_sn, opts->data); } } -static void -command_browse_cb (GtkWidget *w, CommandOptions *opts) +static void +command_browse_cb (GtkWidget * w, CommandOptions * opts) { char *file; const char *text; - + text = gtk_entry_get_text (GTK_ENTRY (opts->command_entry)); - file = select_file_name (_("Select command"), text, - gtk_widget_get_toplevel (opts->base)); + file = select_file_name (_("Select command"), text, + gtk_widget_get_toplevel (opts->base)); if (file) { @@ -163,54 +163,54 @@ command_browse_cb (GtkWidget *w, CommandOptions *opts) completion_combo_set_text (opts->info, file); else gtk_entry_set_text (GTK_ENTRY (opts->command_entry), file); - + gtk_editable_set_position (GTK_EDITABLE (opts->command_entry), -1); - + if (opts->on_change) { GtkToggleButton *tb; gboolean in_term, use_sn = FALSE; - + tb = GTK_TOGGLE_BUTTON (opts->term_checkbutton); in_term = gtk_toggle_button_get_active (tb); - + if (opts->sn_checkbutton) { tb = GTK_TOGGLE_BUTTON (opts->sn_checkbutton); use_sn = gtk_toggle_button_get_active (tb); } - - + + opts->on_change (file, in_term, use_sn, opts->data); } - + g_free (file); } } static void -command_toggle_cb (GtkWidget *w, CommandOptions *opts) +command_toggle_cb (GtkWidget * w, CommandOptions * opts) { if (opts->on_change) { GtkToggleButton *tb; gboolean in_term, use_sn = FALSE; const char *cmd; - + cmd = gtk_entry_get_text (GTK_ENTRY (opts->command_entry)); - if (!cmd || !strlen(cmd)) + if (!cmd || !strlen (cmd)) cmd = NULL; - + tb = GTK_TOGGLE_BUTTON (opts->term_checkbutton); in_term = gtk_toggle_button_get_active (tb); - + if (opts->sn_checkbutton) { tb = GTK_TOGGLE_BUTTON (opts->sn_checkbutton); use_sn = gtk_toggle_button_get_active (tb); } - + opts->on_change (cmd, in_term, use_sn, opts->data); } } @@ -279,19 +279,19 @@ drag_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x, } CommandOptions * -create_command_options (GtkSizeGroup *sg) +create_command_options (GtkSizeGroup * sg) { GtkWidget *w, *vbox, *hbox, *image; CommandOptions *opts; if (!sg) sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - + opts = g_new0 (CommandOptions, 1); - + opts->base = vbox = gtk_vbox_new (FALSE, 0); gtk_widget_show (vbox); - + /* entry */ hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); @@ -303,12 +303,12 @@ create_command_options (GtkSizeGroup *sg) gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); gtk_size_group_add_widget (sg, w); - + /* only available when compiled with libdbh support and * libxfce4_combo module is installed * Disabled, doesn't work properly */ - opts->info = - create_completion_combo ((ComboCallback)combo_completion_cb, opts); + opts->info = + create_completion_combo ((ComboCallback) combo_completion_cb, opts); if (opts->info) { @@ -332,18 +332,17 @@ create_command_options (GtkSizeGroup *sg) gtk_widget_show (image); gtk_container_add (GTK_CONTAINER (w), image); - g_signal_connect (w, "clicked", G_CALLBACK (command_browse_cb), - opts); + g_signal_connect (w, "clicked", G_CALLBACK (command_browse_cb), opts); /* xfce4-appfinder support (desktop files / menu spec) */ - gtk_drag_dest_set (opts->base, GTK_DEST_DEFAULT_ALL, entry, 2, - GDK_ACTION_COPY); - g_signal_connect (opts->base, "drag-data-received", - G_CALLBACK (drag_drop_cb), opts); - - g_signal_connect (opts->command_entry, "drag-data-received", - G_CALLBACK (drag_drop_cb), opts); - + gtk_drag_dest_set (opts->base, GTK_DEST_DEFAULT_ALL, entry, 2, + GDK_ACTION_COPY); + g_signal_connect (opts->base, "drag-data-received", + G_CALLBACK (drag_drop_cb), opts); + + g_signal_connect (opts->command_entry, "drag-data-received", + G_CALLBACK (drag_drop_cb), opts); + hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 0); @@ -353,16 +352,15 @@ create_command_options (GtkSizeGroup *sg) gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); gtk_size_group_add_widget (sg, w); - + /* terminal */ - opts->term_checkbutton = w = + opts->term_checkbutton = w = gtk_check_button_new_with_mnemonic (_("Run in _terminal")); gtk_widget_show (w); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - g_signal_connect (w, "toggled", G_CALLBACK (command_toggle_cb), - opts); - + g_signal_connect (w, "toggled", G_CALLBACK (command_toggle_cb), opts); + #ifdef HAVE_LIBSTARTUP_NOTIFICATION hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); @@ -373,36 +371,35 @@ create_command_options (GtkSizeGroup *sg) gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); gtk_size_group_add_widget (sg, w); - - opts->sn_checkbutton = w = + + opts->sn_checkbutton = w = gtk_check_button_new_with_mnemonic (_("Use startup _notification")); gtk_widget_show (w); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, FALSE, 0); - g_signal_connect (w, "toggled", G_CALLBACK (command_toggle_cb), - opts); + g_signal_connect (w, "toggled", G_CALLBACK (command_toggle_cb), opts); #endif - g_signal_connect_swapped (opts->base, "destroy", - G_CALLBACK (destroy_command_options), opts); - + g_signal_connect_swapped (opts->base, "destroy", + G_CALLBACK (destroy_command_options), opts); + return opts; } -void -destroy_command_options (CommandOptions *opts) +void +destroy_command_options (CommandOptions * opts) { if (opts->on_change) { GtkToggleButton *tb; gboolean in_term, use_sn = FALSE; const char *cmd; - + cmd = gtk_entry_get_text (GTK_ENTRY (opts->command_entry)); - if (!cmd || !strlen(cmd)) + if (!cmd || !strlen (cmd)) cmd = NULL; - + tb = GTK_TOGGLE_BUTTON (opts->term_checkbutton); in_term = gtk_toggle_button_get_active (tb); @@ -411,7 +408,7 @@ destroy_command_options (CommandOptions *opts) tb = GTK_TOGGLE_BUTTON (opts->sn_checkbutton); use_sn = gtk_toggle_button_get_active (tb); } - + opts->on_change (cmd, in_term, use_sn, opts->data); } @@ -421,12 +418,12 @@ destroy_command_options (CommandOptions *opts) g_free (opts); } -void -command_options_set_command (CommandOptions *opts, const char *command, +void +command_options_set_command (CommandOptions * opts, const char *command, gboolean in_term, gboolean use_sn) { const char *cmd = (command != NULL) ? command : ""; - + if (opts->info) { completion_combo_set_text (opts->info, cmd); @@ -435,42 +432,42 @@ command_options_set_command (CommandOptions *opts, const char *command, { gtk_entry_set_text (GTK_ENTRY (opts->command_entry), cmd); } - + gtk_editable_set_position (GTK_EDITABLE (opts->command_entry), -1); - + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (opts->term_checkbutton), - in_term); + in_term); if (opts->sn_checkbutton) { - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (opts->sn_checkbutton), - use_sn); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON + (opts->sn_checkbutton), use_sn); } - + if (opts->on_change) opts->on_change (command, in_term, use_sn, opts->data); } -void -command_options_set_callback (CommandOptions *opts, - void (*callback)(const char *, gboolean, - gboolean, gpointer), +void +command_options_set_callback (CommandOptions * opts, + void (*callback) (const char *, gboolean, + gboolean, gpointer), gpointer data) { opts->on_change = callback; opts->data = data; } -void -command_options_get_command (CommandOptions *opts, char **command, - gboolean *in_term, gboolean *use_sn) +void +command_options_get_command (CommandOptions * opts, char **command, + gboolean * in_term, gboolean * use_sn) { const char *tmp; GtkToggleButton *tb; tmp = gtk_entry_get_text (GTK_ENTRY (opts->command_entry)); - if (tmp && strlen(tmp)) + if (tmp && strlen (tmp)) *command = g_strdup (tmp); else *command = NULL; @@ -495,13 +492,13 @@ command_options_get_command (CommandOptions *opts, char **command, */ static void -update_icon_preview (int id, const char *path, IconOptions *opts) +update_icon_preview (int id, const char *path, IconOptions * opts) { int w, h; GdkPixbuf *pb = NULL; - if (id == EXTERN_ICON && path && - g_file_test (path, G_FILE_TEST_EXISTS) && + if (id == EXTERN_ICON && path && + g_file_test (path, G_FILE_TEST_EXISTS) && !g_file_test (path, G_FILE_TEST_IS_DIR)) { pb = gdk_pixbuf_new_from_file (path, NULL); @@ -520,7 +517,7 @@ update_icon_preview (int id, const char *path, IconOptions *opts) if (w > PREVIEW_SIZE || h > PREVIEW_SIZE) { GdkPixbuf *newpb; - + if (w > h) { h = (int) (((double) PREVIEW_SIZE / (double) w) * (double) h); @@ -536,25 +533,25 @@ update_icon_preview (int id, const char *path, IconOptions *opts) g_object_unref (pb); pb = newpb; } - + gtk_image_set_from_pixbuf (GTK_IMAGE (opts->image), pb); g_object_unref (pb); } static void -icon_id_changed (GtkOptionMenu *om, IconOptions *opts) +icon_id_changed (GtkOptionMenu * om, IconOptions * opts) { int id; char *path = NULL; id = gtk_option_menu_get_history (om); - + if (id == 0) id = EXTERN_ICON; - + if (id == opts->icon_id) return; - + if (id == EXTERN_ICON && opts->saved_path) path = opts->saved_path; @@ -568,7 +565,7 @@ create_icon_option_menu (void) int i; menu = gtk_menu_new (); - + mi = gtk_menu_item_new_with_label (_("Other Icon")); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); @@ -587,8 +584,8 @@ create_icon_option_menu (void) } gboolean -icon_entry_lost_focus (GtkEntry * entry, GdkEventFocus * event, - IconOptions *opts) +icon_entry_lost_focus (GtkEntry * entry, GdkEventFocus * event, + IconOptions * opts) { const char *temp = gtk_entry_get_text (entry); @@ -599,19 +596,19 @@ icon_entry_lost_focus (GtkEntry * entry, GdkEventFocus * event, return FALSE; } -static void -icon_browse_cb (GtkWidget *w, IconOptions *opts) +static void +icon_browse_cb (GtkWidget * w, IconOptions * opts) { char *file; const char *text; GdkPixbuf *test = NULL; - + text = gtk_entry_get_text (GTK_ENTRY (opts->icon_entry)); - file = select_file_with_preview (_("Select command"), text, - gtk_widget_get_toplevel (opts->base)); + file = select_file_with_preview (_("Select command"), text, + gtk_widget_get_toplevel (opts->base)); - if (file && g_file_test (file, G_FILE_TEST_EXISTS) && + if (file && g_file_test (file, G_FILE_TEST_EXISTS) && !g_file_test (file, G_FILE_TEST_IS_DIR)) { test = gdk_pixbuf_new_from_file (file, NULL); @@ -619,11 +616,11 @@ icon_browse_cb (GtkWidget *w, IconOptions *opts) if (test) { g_object_unref (test); - + icon_options_set_icon (opts, EXTERN_ICON, file); } } - + g_free (file); } @@ -631,15 +628,15 @@ static void xtm_cb (GtkWidget * b, GtkEntry * entry) { gchar *argv[2] = { "xfmime-edit", NULL }; - - g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, - NULL, NULL, NULL, NULL); + + g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, + NULL, NULL, NULL, NULL); } static void icon_drop_cb (GtkWidget * widget, GdkDragContext * context, gint x, gint y, GtkSelectionData * data, - guint info, guint time, IconOptions *opts) + guint info, guint time, IconOptions * opts) { GList *fnames; guint count; @@ -669,7 +666,7 @@ icon_drop_cb (GtkWidget * widget, GdkDragContext * context, } static GtkWidget * -create_icon_preview_frame (IconOptions *opts) +create_icon_preview_frame (IconOptions * opts) { GtkWidget *frame; GtkWidget *eventbox; @@ -697,13 +694,13 @@ create_icon_preview_frame (IconOptions *opts) } IconOptions * -create_icon_options (GtkSizeGroup *sg, gboolean use_builtins) +create_icon_options (GtkSizeGroup * sg, gboolean use_builtins) { GtkWidget *w, *vbox, *hbox, *image; IconOptions *opts; opts = g_new0 (IconOptions, 1); - + opts->base = hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); @@ -711,10 +708,10 @@ create_icon_options (GtkSizeGroup *sg, gboolean use_builtins) w = create_icon_preview_frame (opts); gtk_widget_show (w); gtk_box_pack_start (GTK_BOX (hbox), w, FALSE, TRUE, 0); - + if (sg) gtk_size_group_add_widget (sg, w); - + vbox = gtk_vbox_new (FALSE, BORDER); gtk_widget_show (vbox); gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0); @@ -726,10 +723,10 @@ create_icon_options (GtkSizeGroup *sg, gboolean use_builtins) gtk_widget_show (w); gtk_box_pack_start (GTK_BOX (vbox), w, TRUE, TRUE, 0); - opts->id_sig = g_signal_connect (w, "changed", + opts->id_sig = g_signal_connect (w, "changed", G_CALLBACK (icon_id_changed), opts); } - + /* icon entry */ opts->icon_entry = w = gtk_entry_new (); gtk_widget_show (w); @@ -750,7 +747,7 @@ create_icon_options (GtkSizeGroup *sg, gboolean use_builtins) gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0); } - + g_signal_connect (w, "focus-out-event", G_CALLBACK (icon_entry_lost_focus), opts); @@ -787,14 +784,14 @@ create_icon_options (GtkSizeGroup *sg, gboolean use_builtins) } } - g_signal_connect_swapped (opts->base, "destroy", - G_CALLBACK (destroy_icon_options), opts); - + g_signal_connect_swapped (opts->base, "destroy", + G_CALLBACK (destroy_icon_options), opts); + return opts; } -void -destroy_icon_options (IconOptions *opts) +void +destroy_icon_options (IconOptions * opts) { if (opts->on_change) { @@ -806,9 +803,9 @@ destroy_icon_options (IconOptions *opts) if (id == 0) { id = EXTERN_ICON; - + icon_path = gtk_entry_get_text (GTK_ENTRY (opts->icon_entry)); - + if (!icon_path || !strlen (icon_path)) icon_path = NULL; } @@ -821,25 +818,25 @@ destroy_icon_options (IconOptions *opts) g_free (opts); } -void -icon_options_set_icon (IconOptions *opts, int id, const char *path) +void +icon_options_set_icon (IconOptions * opts, int id, const char *path) { g_signal_handler_block (opts->icon_menu, opts->id_sig); - gtk_option_menu_set_history (GTK_OPTION_MENU (opts->icon_menu), - (id == EXTERN_ICON) ? 0 : id); + gtk_option_menu_set_history (GTK_OPTION_MENU (opts->icon_menu), + (id == EXTERN_ICON) ? 0 : id); g_signal_handler_unblock (opts->icon_menu, opts->id_sig); if (id == EXTERN_ICON) { gtk_entry_set_text (GTK_ENTRY (opts->icon_entry), path); gtk_editable_set_position (GTK_EDITABLE (opts->icon_entry), -1); - + gtk_widget_set_sensitive (opts->icon_entry, TRUE); } - else + else { const char *icon_path = NULL; - + if (opts->icon_id == EXTERN_ICON) icon_path = gtk_entry_get_text (GTK_ENTRY (opts->icon_entry)); @@ -854,24 +851,24 @@ icon_options_set_icon (IconOptions *opts, int id, const char *path) } opts->icon_id = id; - + update_icon_preview (id, path, opts); if (opts->on_change) opts->on_change (id, path, opts->data); } -void -icon_options_set_callback (IconOptions *opts, - void (*callback)(int, const char *, gpointer), +void +icon_options_set_callback (IconOptions * opts, + void (*callback) (int, const char *, gpointer), gpointer data) { opts->on_change = callback; opts->data = data; } -void -icon_options_get_icon (IconOptions *opts, int *id, char **path) +void +icon_options_get_icon (IconOptions * opts, int *id, char **path) { *id = gtk_option_menu_get_history (GTK_OPTION_MENU (opts->icon_menu)); @@ -882,9 +879,9 @@ icon_options_get_icon (IconOptions *opts, int *id, char **path) const char *icon_path; *id = EXTERN_ICON; - + icon_path = gtk_entry_get_text (GTK_ENTRY (opts->icon_entry)); - + if (icon_path && strlen (icon_path)) *path = g_strdup (icon_path); } @@ -908,28 +905,28 @@ icon_options_changed (int id, const char *path, gpointer data) item->icon_path = g_strdup (path); else item->icon_path = NULL; - + item_apply_config (item); } static inline void -add_command_options (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) +add_command_options (GtkBox * box, ItemDialog * idlg, GtkSizeGroup * sg) { idlg->cmd_opts = create_command_options (sg); - - command_options_set_command (idlg->cmd_opts, idlg->item->command, - idlg->item->in_terminal, idlg->item->use_sn); + + command_options_set_command (idlg->cmd_opts, idlg->item->command, + idlg->item->in_terminal, idlg->item->use_sn); gtk_box_pack_start (box, idlg->cmd_opts->base, FALSE, TRUE, 0); } static inline void -add_icon_options (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) +add_icon_options (GtkBox * box, ItemDialog * idlg, GtkSizeGroup * sg) { idlg->icon_opts = create_icon_options (sg, TRUE); - icon_options_set_icon (idlg->icon_opts, idlg->item->icon_id, - idlg->item->icon_path); + icon_options_set_icon (idlg->icon_opts, idlg->item->icon_id, + idlg->item->icon_path); icon_options_set_callback (idlg->icon_opts, icon_options_changed, idlg); @@ -937,11 +934,12 @@ add_icon_options (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) } static gboolean -caption_entry_lost_focus (GtkWidget *entry, GdkEventFocus *event, Item *item) +caption_entry_lost_focus (GtkWidget * entry, GdkEventFocus * event, + Item * item) { const char *tmp; - tmp = gtk_entry_get_text (GTK_ENTRY(entry)); + tmp = gtk_entry_get_text (GTK_ENTRY (entry)); if (tmp && strlen (tmp)) { @@ -956,7 +954,7 @@ caption_entry_lost_focus (GtkWidget *entry, GdkEventFocus *event, Item *item) } static inline void -add_caption_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) +add_caption_option (GtkBox * box, ItemDialog * idlg, GtkSizeGroup * sg) { GtkWidget *hbox; GtkWidget *label; @@ -976,7 +974,7 @@ add_caption_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) gtk_box_pack_start (GTK_BOX (hbox), idlg->caption_entry, TRUE, TRUE, 0); if (idlg->item->caption) - gtk_entry_set_text (GTK_ENTRY (idlg->caption_entry), + gtk_entry_set_text (GTK_ENTRY (idlg->caption_entry), idlg->item->caption); /* only set label on focus out */ @@ -985,7 +983,7 @@ add_caption_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) } static inline void -add_tooltip_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) +add_tooltip_option (GtkBox * box, ItemDialog * idlg, GtkSizeGroup * sg) { GtkWidget *hbox; GtkWidget *label; @@ -1009,17 +1007,17 @@ add_tooltip_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) } static void -popup_menu_changed (GtkToggleButton * tb, Control *control) +popup_menu_changed (GtkToggleButton * tb, Control * control) { Item *item = control->data; - + item->with_popup = gtk_toggle_button_get_active (tb); groups_show_popup (control->index, item->with_popup); } static inline void -add_menu_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) +add_menu_option (GtkBox * box, ItemDialog * idlg, GtkSizeGroup * sg) { idlg->menu_checkbutton = gtk_check_button_new_with_label (_("Attach menu to launcher")); @@ -1033,31 +1031,31 @@ add_menu_option (GtkBox *box, ItemDialog *idlg, GtkSizeGroup *sg) } static void -item_dialog_closed (GtkWidget *w, ItemDialog *idlg) +item_dialog_closed (GtkWidget * w, ItemDialog * idlg) { Item *item; const char *temp; item = idlg->item; - + /* command */ g_free (item->command); item->command = NULL; command_options_get_command (idlg->cmd_opts, &(item->command), - &(item->in_terminal), &(item->use_sn)); + &(item->in_terminal), &(item->use_sn)); /* icon */ g_free (item->icon_path); item->icon_path = NULL; - icon_options_get_icon (idlg->icon_opts, &(item->icon_id), - &(item->icon_path)); - + icon_options_get_icon (idlg->icon_opts, &(item->icon_id), + &(item->icon_path)); + /* tooltip */ g_free (item->tooltip); item->tooltip = NULL; - + temp = gtk_entry_get_text (GTK_ENTRY (idlg->tip_entry)); if (temp && *temp) @@ -1070,7 +1068,7 @@ item_dialog_closed (GtkWidget *w, ItemDialog *idlg) item->caption = NULL; temp = gtk_entry_get_text (GTK_ENTRY (idlg->caption_entry)); - + if (temp && *temp) item->caption = g_strdup (temp); } @@ -1079,7 +1077,7 @@ item_dialog_closed (GtkWidget *w, ItemDialog *idlg) } static void -destroy_item_dialog (ItemDialog *idlg) +destroy_item_dialog (ItemDialog * idlg) { /* TODO: check if these are still here */ command_options_set_callback (idlg->cmd_opts, NULL, NULL); @@ -1089,8 +1087,8 @@ destroy_item_dialog (ItemDialog *idlg) } static void -create_item_dialog (Control *control, Item *item, - GtkContainer *container, GtkWidget *close) +create_item_dialog (Control * control, Item * item, + GtkContainer * container, GtkWidget * close) { ItemDialog *idlg; GtkWidget *vbox; @@ -1101,25 +1099,25 @@ create_item_dialog (Control *control, Item *item, if (control) { idlg->control = control; - idlg->item = (Item *)control->data; + idlg->item = (Item *) control->data; } else { idlg->item = item; } - + vbox = gtk_vbox_new (FALSE, BORDER); gtk_widget_show (vbox); gtk_container_add (container, vbox); sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); - + add_icon_options (GTK_BOX (vbox), idlg, sg); add_spacer (GTK_BOX (vbox), BORDER); add_command_options (GTK_BOX (vbox), idlg, sg); add_spacer (GTK_BOX (vbox), BORDER); - + if (!control) { add_caption_option (GTK_BOX (vbox), idlg, sg); @@ -1134,12 +1132,12 @@ create_item_dialog (Control *control, Item *item, } add_spacer (GTK_BOX (vbox), BORDER); - - g_signal_connect (close, "clicked", - G_CALLBACK (item_dialog_closed), idlg); - g_signal_connect_swapped (container, "destroy", - G_CALLBACK (destroy_item_dialog), idlg); + g_signal_connect (close, "clicked", + G_CALLBACK (item_dialog_closed), idlg); + + g_signal_connect_swapped (container, "destroy", + G_CALLBACK (destroy_item_dialog), idlg); } /* panel and menu item API @@ -1148,7 +1146,7 @@ create_item_dialog (Control *control, Item *item, /* panel control */ -void +void panel_item_create_options (Control * control, GtkContainer * container, GtkWidget * done) { @@ -1173,7 +1171,7 @@ reindex_items (GList * items) } static void -pos_changed (GtkSpinButton * spin, Item *item) +pos_changed (GtkSpinButton * spin, Item * item) { int n = gtk_spin_button_get_value_as_int (spin) - 1; PanelPopup *pp = item->parent; @@ -1185,19 +1183,18 @@ pos_changed (GtkSpinButton * spin, Item *item) pp->items = g_list_insert (pp->items, item, n); reindex_items (pp->items); - gtk_box_reorder_child (GTK_BOX (pp->item_vbox), item->button, - item->pos); + gtk_box_reorder_child (GTK_BOX (pp->item_vbox), item->button, item->pos); } static void -add_position_option (GtkBox *box, Item *item, int num_items) +add_position_option (GtkBox * box, Item * item, int num_items) { GtkWidget *hbox; GtkWidget *label; GtkWidget *pos_spin; g_return_if_fail (num_items > 1); - + hbox = gtk_hbox_new (FALSE, BORDER); gtk_container_set_border_width (GTK_CONTAINER (hbox), BORDER); gtk_widget_show (hbox); @@ -1212,22 +1209,22 @@ add_position_option (GtkBox *box, Item *item, int num_items) gtk_widget_show (pos_spin); gtk_box_pack_start (GTK_BOX (hbox), pos_spin, FALSE, FALSE, 0); - gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin), - (gfloat) item->pos + 1); - + gtk_spin_button_set_value (GTK_SPIN_BUTTON (pos_spin), + (gfloat) item->pos + 1); + g_signal_connect (pos_spin, "value-changed", G_CALLBACK (pos_changed), item); } static gboolean -menu_dialog_delete (GtkWidget *dlg) +menu_dialog_delete (GtkWidget * dlg) { gtk_dialog_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK); return TRUE; } -void +void edit_menu_item_dialog (Item * mi) { GtkWidget *remove, *close, *header; @@ -1236,12 +1233,12 @@ edit_menu_item_dialog (Item * mi) menudialog = gtk_dialog_new (); dlg = GTK_DIALOG (menudialog); - + gtk_window_set_title (GTK_WINDOW (dlg), _("Change menu item")); gtk_window_set_position (GTK_WINDOW (dlg), GTK_WIN_POS_CENTER); gtk_dialog_set_has_separator (dlg, FALSE); - + /* add buttons */ remove = xfce_create_mixed_button (GTK_STOCK_REMOVE, _("_Remove")); gtk_widget_show (remove); @@ -1252,18 +1249,18 @@ edit_menu_item_dialog (Item * mi) gtk_widget_show (close); gtk_dialog_add_action_widget (dlg, close, GTK_RESPONSE_OK); - gtk_button_box_set_child_secondary (GTK_BUTTON_BOX(dlg->action_area), + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (dlg->action_area), remove, TRUE); header = xfce_create_header (NULL, _("Launcher")); - gtk_container_set_border_width (GTK_CONTAINER (GTK_BIN (header)->child), - BORDER); + gtk_container_set_border_width (GTK_CONTAINER (GTK_BIN (header)->child), + BORDER); gtk_widget_set_size_request (header, -1, 32); gtk_widget_show (header); gtk_box_pack_start (GTK_BOX (dlg->vbox), header, FALSE, TRUE, 0); add_spacer (GTK_BOX (dlg->vbox), BORDER); - + /* position */ num_items = g_list_length (mi->parent->items); @@ -1279,9 +1276,9 @@ edit_menu_item_dialog (Item * mi) add_spacer (GTK_BOX (dlg->vbox), BORDER); - g_signal_connect (dlg, "delete-event", G_CALLBACK (menu_dialog_delete), - NULL); - + g_signal_connect (dlg, "delete-event", G_CALLBACK (menu_dialog_delete), + NULL); + gtk_widget_grab_focus (close); gtk_widget_grab_default (close); @@ -1291,19 +1288,19 @@ edit_menu_item_dialog (Item * mi) if (response == GTK_RESPONSE_CANCEL) { PanelPopup *pp = mi->parent; - + 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); } - + gtk_widget_destroy (menudialog); write_panel_config (); } -void +void add_menu_item_dialog (PanelPopup * pp) { Item *mi = menu_item_new (pp); @@ -1322,4 +1319,3 @@ destroy_menu_dialog (void) if (menudialog) gtk_dialog_response (GTK_DIALOG (menudialog), GTK_RESPONSE_OK); } - diff --git a/panel/item_dialog.h b/panel/item_dialog.h index fb60752d..b1c4ec3e 100644 --- a/panel/item_dialog.h +++ b/panel/item_dialog.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2003 Jasper Huijsmans (jasper@xfce.org) + * Copyright 2003-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -39,35 +39,35 @@ struct _CommandOptions { /* add this to your dialog */ GtkWidget *base; - + /* use the functions declared below to change the contents of * the members of this struct */ - + xfc_combo_info_t *info; GtkWidget *command_entry; GtkWidget *term_checkbutton; GtkWidget *sn_checkbutton; - - void (*on_change) (const char *command, gboolean in_term, gboolean use_sn, - gpointer data); + + void (*on_change) (const char *command, gboolean in_term, gboolean use_sn, + gpointer data); gpointer data; }; -CommandOptions * create_command_options (GtkSizeGroup *sg); +CommandOptions *create_command_options (GtkSizeGroup * sg); -void destroy_command_options (CommandOptions *opts); +void destroy_command_options (CommandOptions * opts); -void command_options_set_command (CommandOptions *opts, const char *command, - gboolean in_term, gboolean use_sn); +void command_options_set_command (CommandOptions * opts, const char *command, + gboolean in_term, gboolean use_sn); -void command_options_set_callback (CommandOptions *opts, - void (*callback)(const char *, gboolean, - gboolean, gpointer), +void command_options_set_callback (CommandOptions * opts, + void (*callback) (const char *, gboolean, + gboolean, gpointer), gpointer data); -void command_options_get_command (CommandOptions *opts, char **command, - gboolean *in_term, gboolean *use_sn); +void command_options_get_command (CommandOptions * opts, char **command, + gboolean * in_term, gboolean * use_sn); /* IconOptions @@ -89,7 +89,7 @@ struct _IconOptions /* use the functions declared below to change the contents of * the members of this struct */ - + GtkWidget *icon_menu; GtkWidget *icon_entry; GtkWidget *image; @@ -98,23 +98,23 @@ struct _IconOptions int id_sig; int icon_id; char *saved_path; - + /* callback */ void (*on_change) (int icon_id, const char *icon_path, gpointer data); gpointer data; }; -IconOptions * create_icon_options (GtkSizeGroup *sg, gboolean use_builtins); +IconOptions *create_icon_options (GtkSizeGroup * sg, gboolean use_builtins); -void destroy_icon_options (IconOptions *opts); +void destroy_icon_options (IconOptions * opts); -void icon_options_set_icon (IconOptions *opts, int id, const char *path); +void icon_options_set_icon (IconOptions * opts, int id, const char *path); -void icon_options_set_callback (IconOptions *opts, - void (*callback)(int, const char *, gpointer), - gpointer data); +void icon_options_set_callback (IconOptions * opts, + void (*callback) (int, const char *, + gpointer), gpointer data); -void icon_options_get_icon (IconOptions *opts, int *id, char **path); +void icon_options_get_icon (IconOptions * opts, int *id, char **path); /* PanelItem and MenuItem dialogs diff --git a/panel/main.c b/panel/main.c index 0224ce52..b592f7ce 100644 --- a/panel/main.c +++ b/panel/main.c @@ -1,4 +1,4 @@ -/* xfce4 +/* $Id$ * * Copyright (c) 2002-2004 Jasper Huijsmans <jasper@xfce.org> * Copyright (c) 2003 Benedikt Meurer <benedikt.meurer@xfce.org> @@ -122,8 +122,8 @@ quit (gboolean force) logout_session (client_session); return; } - else if (!xfce_confirm (_("Are you sure you want to exit?"), - GTK_STOCK_QUIT, NULL)) + else if (!xfce_confirm (_("Are you sure you want to exit?"), + GTK_STOCK_QUIT, NULL)) { return; } @@ -334,9 +334,8 @@ main (int argc, char **argv) " Version %s\n\n" " Part of the Xfce Desktop Environment\n" " http://www.xfce.org\n\n" - " Licensed under the GNU GPL.\n\n"), - VERSION); - + " Licensed under the GNU GPL.\n\n"), VERSION); + return 0; } @@ -355,8 +354,8 @@ main (int argc, char **argv) } /* so clients are started on the correct screen */ - xfce_setenv ("DISPLAY", gdk_display_get_name (gdk_display_get_default()), - TRUE); + xfce_setenv ("DISPLAY", gdk_display_get_name (gdk_display_get_default ()), + TRUE); #ifdef HAVE_SIGACTION act.sa_handler = sighandler; sigemptyset (&act.sa_mask); @@ -380,7 +379,7 @@ main (int argc, char **argv) /* hack to prevent arrow buttons from being cropped */ gtk_rc_parse_string (RC_STRING); - + /* icon framework: names and id's */ icons_init (); @@ -394,20 +393,20 @@ main (int argc, char **argv) client_session->die = die; session_managed = session_init (client_session); - + #if DEBUG if (!session_managed) { - g_message (_("%s: Successfully started without session management"), + g_message (_("%s: Successfully started without session management"), PACKAGE); } else { - g_message (_("%s: Successfully started with session management"), + g_message (_("%s: Successfully started with session management"), PACKAGE); } #endif - + /* signal state */ g_timeout_add (500, (GSourceFunc) check_signal_state, NULL); diff --git a/panel/main.h b/panel/main.h index 6c899212..02ca5a10 100644 --- a/panel/main.h +++ b/panel/main.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002-2004 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/mcs_client.c b/panel/mcs_client.c index 0a0d8bdb..72f0815e 100644 --- a/panel/mcs_client.c +++ b/panel/mcs_client.c @@ -46,8 +46,6 @@ static McsClient *client = NULL; -static int settings_cb_id = 0; - /* settings hash table */ static GHashTable *settings_hash = NULL; @@ -87,7 +85,7 @@ update_setting (const char *name, McsSetting * setting) set_int = g_hash_table_lookup (settings_hash, name); DBG ("Set %s : %d", name, setting->data.v_int); - + if (set_int) set_int (setting->data.v_int); } @@ -96,7 +94,7 @@ update_setting (const char *name, McsSetting * setting) set_string = g_hash_table_lookup (settings_hash, name); DBG ("Set %s : %s", name, setting->data.v_string); - + if (set_string) set_string (setting->data.v_string); } @@ -145,47 +143,12 @@ watch_cb (Window window, Bool is_start, long mask, void *cb_data) gdk_window_remove_filter (gdkwin, client_event_filter, NULL); } -/* icon theme */ -#if GTK_CHECK_VERSION (2,4,0) -static void -icontheme_cb (GtkIconTheme *icontheme) -{ - char *theme; - - g_object_get (gtk_settings_get_default(), "gtk-icon-theme-name", - &theme, NULL); - - DBG ("Theme: %s\n", theme); - panel_set_theme (theme); - - g_free (theme); -} -#else /* gtk < 2.4 */ -static void -settings_notify_cb (GtkSettings *gsettings, GParamSpec *pspec) -{ - if (strequal (pspec->name, "gtk-icon-theme-name")) - { - char *theme; - - g_object_get (G_OBJECT (gsettings), "gtk-icon-theme-name", - &theme, NULL); - - panel_set_theme (theme); - - g_free (theme); - } -} -#endif - /* connecting and disconnecting */ void mcs_watch_xfce_channel (void) { Display *dpy = GDK_DISPLAY (); int screen = DefaultScreen (dpy); - GtkSettings *gsettings = gtk_settings_get_default (); - char *theme; if (!settings_hash) init_settings_hash (); @@ -207,25 +170,6 @@ mcs_watch_xfce_channel (void) } mcs_client_add_channel (client, CHANNEL); - - theme = NULL; - g_object_get (G_OBJECT (gsettings), "gtk-icon-theme-name", &theme, NULL); - - if (theme) - { - xfce_set_icon_theme (theme); - panel_set_theme (theme); - g_free (theme); - } - -#if GTK_CHECK_VERSION (2,4,0) - settings_cb_id = - g_signal_connect (gtk_icon_theme_get_default (), "changed", - G_CALLBACK (icontheme_cb), NULL); -#else - settings_cb_id = g_signal_connect (gsettings, "notify", - G_CALLBACK (settings_notify_cb), NULL); -#endif } void @@ -234,20 +178,8 @@ mcs_stop_watch (void) if (client) { mcs_client_destroy (client); - - client = NULL; - } - if (settings_cb_id) - { -#if GTK_CHECK_VERSION (2,4,0) - g_signal_handler_disconnect (gtk_icon_theme_get_default (), - settings_cb_id); -#else - g_signal_handler_disconnect (gtk_settings_get_default (), - settings_cb_id); -#endif - settings_cb_id = 0; + client = NULL; } } diff --git a/panel/mcs_client.h b/panel/mcs_client.h index e9fdde51..075ebf35 100644 --- a/panel/mcs_client.h +++ b/panel/mcs_client.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002-2004 Jasper Huijsmans <jasper@xfce.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/panel.c b/panel/panel.c index 3754ce00..fd745112 100644 --- a/panel/panel.c +++ b/panel/panel.c @@ -1,6 +1,6 @@ /* $Id$ * - * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,7 +27,6 @@ #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/libnetk.h> -#include <libxfcegui4/icons.h> #include "xfce.h" #include "groups.h" @@ -37,6 +36,7 @@ #include "popup.h" #include "settings.h" #include "mcs_client.h" +#include "icons.h" #define HIDE_TIMEOUT 500 #define UNHIDE_TIMEOUT 100 @@ -67,7 +67,7 @@ struct _PanelPrivate int offset; GtkRequisition req; - + gboolean is_created; int block_autohide; }; @@ -96,9 +96,9 @@ int popup_icon_size[] = { 22, 26, 26, 32 }; /* static prototypes * * ----------------- */ -static void update_partial_struts (Panel *p); +static void update_partial_struts (Panel * p); -static void update_arrow_direction (Panel *p); +static void update_arrow_direction (Panel * p); static void update_xinerama_coordinates (Panel * p, int x, int y); @@ -108,16 +108,16 @@ static void panel_set_position (Panel * p); static void panel_set_hidden (Panel * p, gboolean hide); -static void init_settings (Panel *p); +static void init_settings (Panel * p); /* positioning and position related functions * * ------------------------------------------ */ -static void -update_partial_struts (Panel *p) +static void +update_partial_struts (Panel * p) { - gulong data [12] = { 0, }; + gulong data[12] = { 0, }; if (!p->priv->settings.autohide && p->priv->settings.layer == 0) { @@ -131,28 +131,28 @@ update_partial_struts (Panel *p) switch (p->priv->side) { case LEFT: - data[0] = w; /* left */ - - data[4] = y; /* left_start_y */ - data[5] = y + h; /* left_end_y */ + data[0] = w; /* left */ + + data[4] = y; /* left_start_y */ + data[5] = y + h; /* left_end_y */ break; case RIGHT: - data[1] = w; /* right */ - - data[6] = y; /* right_start_y */ - data[7] = y + h; /* right_end_y */ + data[1] = w; /* right */ + + data[6] = y; /* right_start_y */ + data[7] = y + h; /* right_end_y */ break; case TOP: - data[2] = h; /* top */ - - data[8] = x; /* top_start_x */ - data[9] = x + w; /* top_end_x */ + data[2] = h; /* top */ + + data[8] = x; /* top_start_x */ + data[9] = x + w; /* top_end_x */ break; default: - data[3] = h; /* bottom */ - - data[10] = x; /* bottom_start_x */ - data[11] = x + w; /* bottom_end_x */ + data[3] = h; /* bottom */ + + data[10] = x; /* bottom_start_x */ + data[11] = x + w; /* bottom_end_x */ } } @@ -166,13 +166,13 @@ update_partial_struts (Panel *p) gdk_property_change (p->toplevel->window, gdk_atom_intern ("_NET_WM_STRUT_PARTIAL", FALSE), gdk_atom_intern ("CARDINAL", FALSE), 32, - GDK_PROP_MODE_REPLACE, (guchar *) &data, 12); + GDK_PROP_MODE_REPLACE, (guchar *) & data, 12); gdk_error_trap_pop (); } static void -update_arrow_direction (Panel *p) +update_arrow_direction (Panel * p) { GtkArrowType type; @@ -198,21 +198,21 @@ static void update_xinerama_coordinates (Panel * p, int x, int y) { int monitor; - + monitor = gdk_screen_get_monitor_at_point (p->priv->screen, x, y); if (monitor != p->priv->monitor) { p->priv->monitor = monitor; - gdk_screen_get_monitor_geometry (p->priv->screen, p->priv->monitor, + gdk_screen_get_monitor_geometry (p->priv->screen, p->priv->monitor, &(p->priv->monitor_geometry)); - DBG ("\n monitor: %d\n geometry: %d,%d %dx%d", + DBG ("\n monitor: %d\n geometry: %d,%d %dx%d", p->priv->monitor, - p->priv->monitor_geometry.x, + p->priv->monitor_geometry.x, p->priv->monitor_geometry.y, - p->priv->monitor_geometry.width, + p->priv->monitor_geometry.width, p->priv->monitor_geometry.height); } } @@ -221,38 +221,35 @@ static void restrict_position (Panel * p, int *x, int *y) { int xcenter, ycenter; - + if (!p || !p->toplevel) return; DBG ("\n desired position: %d,%d\n size: %d x %d", *x, *y, p->priv->req.width, p->priv->req.height); - xcenter = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width / 2 - - p->priv->req.width / 2; + xcenter = p->priv->monitor_geometry.x + + p->priv->monitor_geometry.width / 2 - p->priv->req.width / 2; - ycenter = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height / 2 - - p->priv->req.height / 2; + ycenter = p->priv->monitor_geometry.y + + p->priv->monitor_geometry.height / 2 - p->priv->req.height / 2; p->priv->pos_state = XFCE_POS_STATE_NONE; p->priv->offset = 0; - + if (p->priv->settings.orientation == HORIZONTAL) { if (*y < ycenter) { *y = p->priv->monitor_geometry.y; - + p->priv->side = TOP; } else { *y = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height - - p->priv->req.height; - + + p->priv->monitor_geometry.height - p->priv->req.height; + p->priv->side = BOTTOM; } @@ -260,20 +257,19 @@ restrict_position (Panel * p, int *x, int *y) if (*x > xcenter - SNAP_WIDTH && *x < xcenter + SNAP_WIDTH) { *x = xcenter; - + p->priv->pos_state = XFCE_POS_STATE_CENTER; } /* right edge */ else if (*x + p->priv->req.width > p->priv->monitor_geometry.x + p->priv->monitor_geometry.width - SNAP_WIDTH) { - *x = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width - - p->priv->req.width; - + *x = p->priv->monitor_geometry.x + + p->priv->monitor_geometry.width - p->priv->req.width; + p->priv->pos_state = XFCE_POS_STATE_END; } - + /* left edge */ if (*x < p->priv->monitor_geometry.x + SNAP_WIDTH) { @@ -295,8 +291,7 @@ restrict_position (Panel * p, int *x, int *y) else { *x = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width - - p->priv->req.width; + + p->priv->monitor_geometry.width - p->priv->req.width; p->priv->side = RIGHT; } @@ -313,12 +308,11 @@ restrict_position (Panel * p, int *x, int *y) + p->priv->monitor_geometry.height - SNAP_WIDTH) { *y = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height - - p->priv->req.height; + + p->priv->monitor_geometry.height - p->priv->req.height; p->priv->pos_state = XFCE_POS_STATE_END; } - + /* top edge */ if (*y < p->priv->monitor_geometry.y + SNAP_WIDTH) { @@ -330,47 +324,43 @@ restrict_position (Panel * p, int *x, int *y) p->priv->offset = *y - p->priv->monitor_geometry.y; } - DBG ("++ position: %d, %d\n", - p->position.x, p->position.y); - DBG (" monitor: %d\n", - p->priv->monitor); - DBG (" side: %s\n", - p->priv->side==LEFT ? "left" : - p->priv->side==RIGHT ? "right" : - p->priv->side==TOP ? "top" : - "bottom"); - DBG (" state: %s\n", - p->priv->pos_state==XFCE_POS_STATE_CENTER ? "center" : - p->priv->pos_state==XFCE_POS_STATE_START ? "start" : - p->priv->pos_state==XFCE_POS_STATE_END ? "end" : - "none"); + DBG ("++ position: %d, %d\n", p->position.x, p->position.y); + DBG (" monitor: %d\n", p->priv->monitor); + DBG (" side: %s\n", + p->priv->side == LEFT ? "left" : + p->priv->side == RIGHT ? "right" : + p->priv->side == TOP ? "top" : "bottom"); + DBG (" state: %s\n", + p->priv->pos_state == XFCE_POS_STATE_CENTER ? "center" : + p->priv->pos_state == XFCE_POS_STATE_START ? "start" : + p->priv->pos_state == XFCE_POS_STATE_END ? "end" : "none"); } static void -panel_move_func (GtkWidget *win, int *x, int *y, Panel *panel) +panel_move_func (GtkWidget * win, int *x, int *y, Panel * panel) { static int num_screens = 0; int side; - if (G_UNLIKELY(num_screens == 0)) + if (G_UNLIKELY (num_screens == 0)) { - num_screens = gdk_screen_get_n_monitors (panel->priv->screen); + num_screens = gdk_screen_get_n_monitors (panel->priv->screen); } - - if (G_UNLIKELY(num_screens > 1)) + + if (G_UNLIKELY (num_screens > 1)) { int xcenter, ycenter; - + xcenter = *x + panel->priv->req.width / 2; ycenter = *y + panel->priv->req.height / 2; update_xinerama_coordinates (panel, xcenter, ycenter); } - + side = panel->priv->side; - + restrict_position (panel, x, y); - + if (side != panel->priv->side) update_arrow_direction (panel); } @@ -382,7 +372,7 @@ panel_set_position (Panel * p) return; gtk_widget_size_request (p->toplevel, &(p->priv->req)); - + if (p->priv->settings.orientation == VERTICAL) { if (p->priv->side == LEFT) @@ -392,15 +382,14 @@ panel_set_position (Panel * p) else { p->position.x = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width - - p->priv->req.width; + + p->priv->monitor_geometry.width - p->priv->req.width; } - + switch (p->priv->pos_state) { case XFCE_POS_STATE_CENTER: p->position.y = p->priv->monitor_geometry.y - + (p->priv->monitor_geometry.height + + (p->priv->monitor_geometry.height - p->priv->req.height) / 2; break; case XFCE_POS_STATE_START: @@ -408,12 +397,10 @@ panel_set_position (Panel * p) break; case XFCE_POS_STATE_END: p->position.y = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height - - p->priv->req.height; + + p->priv->monitor_geometry.height - p->priv->req.height; break; default: - p->position.y = p->priv->monitor_geometry.y - + p->priv->offset; + p->position.y = p->priv->monitor_geometry.y + p->priv->offset; } } else @@ -425,10 +412,9 @@ panel_set_position (Panel * p) else { p->position.y = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height - - p->priv->req.height; + + p->priv->monitor_geometry.height - p->priv->req.height; } - + switch (p->priv->pos_state) { case XFCE_POS_STATE_CENTER: @@ -441,30 +427,24 @@ panel_set_position (Panel * p) break; case XFCE_POS_STATE_END: p->position.x = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width - - p->priv->req.width; + + p->priv->monitor_geometry.width - p->priv->req.width; break; default: - p->position.x = p->priv->monitor_geometry.x - + p->priv->offset; + p->position.x = p->priv->monitor_geometry.x + p->priv->offset; } } - DBG (" ++ position: %d, %d\n", - p->position.x, p->position.y); - DBG (" monitor: %d\n", - p->priv->monitor); - DBG (" side: %s\n", - p->priv->side==LEFT ? "left" : - p->priv->side==RIGHT ? "right" : - p->priv->side==TOP ? "top" : - "bottom"); - DBG (" state: %s\n", - p->priv->pos_state==XFCE_POS_STATE_CENTER ? "center" : - p->priv->pos_state==XFCE_POS_STATE_START ? "start" : - p->priv->pos_state==XFCE_POS_STATE_END ? "end" : - "none"); - + DBG (" ++ position: %d, %d\n", p->position.x, p->position.y); + DBG (" monitor: %d\n", p->priv->monitor); + DBG (" side: %s\n", + p->priv->side == LEFT ? "left" : + p->priv->side == RIGHT ? "right" : + p->priv->side == TOP ? "top" : "bottom"); + DBG (" state: %s\n", + p->priv->pos_state == XFCE_POS_STATE_CENTER ? "center" : + p->priv->pos_state == XFCE_POS_STATE_START ? "start" : + p->priv->pos_state == XFCE_POS_STATE_END ? "end" : "none"); + gtk_window_move (GTK_WINDOW (p->toplevel), p->position.x, p->position.y); update_arrow_direction (p); @@ -481,20 +461,20 @@ screen_size_changed (GdkScreen * screen, Panel * p) double scale; r = p->priv->monitor_geometry; - + gdk_screen_get_monitor_geometry (screen, p->priv->monitor, - &(p->priv->monitor_geometry)); - + &(p->priv->monitor_geometry)); + if (p->priv->settings.orientation == VERTICAL) { scale = (double) (p->position.y - r.y) / (double) r.height; - + p->priv->offset = rint (scale * p->priv->monitor_geometry.height); } else { scale = (double) (p->position.x - r.x) / (double) r.width; - + p->priv->offset = rint (scale * p->priv->monitor_geometry.width); } @@ -554,28 +534,28 @@ get_handle_menu (void) if (!menu) { GtkWidget *mi; - + menu = gtk_menu_new (); - mi = gtk_menu_item_new_with_label(_("Xfce Panel")); + mi = gtk_menu_item_new_with_label (_("Xfce Panel")); gtk_widget_show (mi); gtk_widget_set_sensitive (mi, FALSE); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - - mi = gtk_menu_item_new_with_mnemonic(_("Add _new item")); + + mi = gtk_menu_item_new_with_mnemonic (_("Add _new item")); gtk_widget_show (mi); - g_signal_connect (mi, "activate", G_CALLBACK (run_add_control_dialog), + g_signal_connect (mi, "activate", G_CALLBACK (run_add_control_dialog), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("_Properties...")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (edit_prefs), NULL); @@ -585,30 +565,30 @@ get_handle_menu (void) gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (do_info), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("_Help")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (do_help), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("_Lock screen")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (lock_screen), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("_Restart")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (restart_panel), NULL); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_separator_menu_item_new (); gtk_widget_show (mi); gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi); - + mi = gtk_menu_item_new_with_mnemonic (_("E_xit")); gtk_widget_show (mi); g_signal_connect (mi, "activate", G_CALLBACK (exit_panel), NULL); @@ -616,27 +596,27 @@ get_handle_menu (void) } g_assert (menu != NULL); - + /* when XFCE_DISABLE_USER_CONFIG is set, hide 3rd, 4th and 5th item; * keep in sync with factory. */ if (G_UNLIKELY (disable_user_config)) { GList *l; GtkWidget *item; - + l = g_list_nth (GTK_MENU_SHELL (menu)->children, 2); item = l->data; gtk_widget_hide (item); - + l = l->next; item = l->data; gtk_widget_hide (item); - + l = l->next; item = l->data; gtk_widget_hide (item); } - + return GTK_MENU (menu); } @@ -670,7 +650,7 @@ handler_pressed_cb (GtkWidget * h, GdkEventButton * event) menu = get_handle_menu (); panel_register_open_menu (GTK_WIDGET (menu)); - + gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, event->time); @@ -692,7 +672,7 @@ handler_move_end_cb (GtkWidget * h, Panel * p) DBG ("move end: %d,%d", p->position.x, p->position.y); update_xinerama_coordinates (p, p->position.x + p->priv->req.width / 2, - p->position.y + p->priv->req.height / 2); + p->position.y + p->priv->req.height / 2); x = p->position.x; y = p->position.y; @@ -714,10 +694,10 @@ handler_move_end_cb (GtkWidget * h, Panel * p) } static void -handler_move_start (Panel *p) +handler_move_start (Panel * p) { update_xinerama_coordinates (p, p->position.x + p->priv->req.width / 2, - p->position.y + p->priv->req.height / 2); + p->position.y + p->priv->req.height / 2); } GtkWidget * @@ -727,7 +707,7 @@ handle_new (Panel * p) mh = xfce_movehandler_new (panel.toplevel); xfce_movehandler_set_move_func (XFCE_MOVEHANDLER (mh), - (XfceMoveFunc) panel_move_func, p); + (XfceMoveFunc) panel_move_func, p); gtk_widget_show (mh); gtk_widget_set_name (mh, "xfce_panel"); @@ -735,8 +715,8 @@ handle_new (Panel * p) g_signal_connect (mh, "button-press-event", G_CALLBACK (handler_pressed_cb), p); - g_signal_connect_swapped (mh, "move-start", - G_CALLBACK (handler_move_start), p); + g_signal_connect_swapped (mh, "move-start", + G_CALLBACK (handler_move_start), p); g_signal_connect (mh, "move-end", G_CALLBACK (handler_move_end_cb), p); @@ -778,8 +758,7 @@ panel_set_hidden (Panel * p, gboolean hide) break; case RIGHT: x = p->priv->monitor_geometry.x - + p->priv->monitor_geometry.width - - HIDDEN_SIZE; + + p->priv->monitor_geometry.width - HIDDEN_SIZE; w = HIDDEN_SIZE; break; case TOP: @@ -788,8 +767,7 @@ panel_set_hidden (Panel * p, gboolean hide) break; default: y = p->priv->monitor_geometry.y - + p->priv->monitor_geometry.height - - HIDDEN_SIZE; + + p->priv->monitor_geometry.height - HIDDEN_SIZE; h = HIDDEN_SIZE; } } @@ -804,13 +782,13 @@ panel_set_hidden (Panel * p, gboolean hide) gtk_widget_set_size_request (p->toplevel, -1, -1); gtk_widget_show (p->main_frame); } - + DBG ("%s: (%d,%d) %dx%d", hide ? "hide" : "unhide", x, y, w, h); /* this seems to be necessary to be able to move the window ... */ while (gtk_events_pending ()) gtk_main_iteration_do (FALSE); - + gdk_window_move_resize (p->toplevel->window, x, y, w, h); /* set flag after moving when unhiding */ @@ -968,7 +946,7 @@ create_panel_window (Panel * p) gtk_window_set_skip_pager_hint (window, TRUE); gtk_window_set_gravity (window, GDK_GRAVITY_STATIC); - + pb = get_panel_pixbuf (); gtk_window_set_icon (window, pb); g_object_unref (pb); @@ -976,7 +954,7 @@ create_panel_window (Panel * p) g_signal_connect (w, "delete-event", G_CALLBACK (panel_delete_cb), p); g_object_set_data (G_OBJECT (w), "panel", p); - + return w; } @@ -1034,7 +1012,7 @@ create_panel (void) /* FIXME: get rid of global panel variable */ p = &panel; - + p->toplevel = NULL; p->position.x = -1; @@ -1048,7 +1026,7 @@ create_panel (void) /* toplevel window */ p->toplevel = create_panel_window (p); - + g_object_add_weak_pointer (G_OBJECT (p->toplevel), (gpointer *) & (p->toplevel)); @@ -1075,6 +1053,8 @@ create_panel (void) /* If there is a settings manager it takes precedence */ mcs_watch_xfce_channel (); + icon_theme_init (); + /* backwards compat */ p->priv->settings = settings; @@ -1095,10 +1075,10 @@ create_panel (void) panel_set_position (p); DBG (" ++ position: %d, %d\n", panel.position.x, panel.position.y); - + update_xinerama_coordinates (p, p->position.x + p->priv->req.width / 2, - p->position.y + p->priv->req.height / 2); - + p->position.y + p->priv->req.height / 2); + gtk_widget_show (p->toplevel); /* set layer on visible window */ @@ -1120,9 +1100,9 @@ create_panel (void) update_arrow_direction (p); /* auto resize functions */ - g_signal_connect (p->toplevel, "size-allocate", - G_CALLBACK (panel_allocate_cb), p); - + g_signal_connect (p->toplevel, "size-allocate", + G_CALLBACK (panel_allocate_cb), p); + g_signal_connect (p->priv->screen, "size-changed", G_CALLBACK (screen_size_changed), p); } @@ -1140,7 +1120,7 @@ panel_set_orientation (int orientation) /* backwards compat */ settings = panel.priv->settings; - + if (!panel.priv->is_created) return; @@ -1194,7 +1174,7 @@ panel_set_orientation (int orientation) panel_set_size (settings.size); gtk_widget_size_request (panel.toplevel, &panel.priv->req); - + /* calls panel_set_position () */ if (orientation == HORIZONTAL) panel_center (BOTTOM); @@ -1212,7 +1192,7 @@ panel_set_orientation (int orientation) if (hidden) panel_set_autohide (TRUE); - + update_partial_struts (&panel); } @@ -1223,40 +1203,40 @@ panel_set_layer (int layer) /* backwards compat */ settings = panel.priv->settings; - + if (panel.priv->is_created) { set_window_layer (panel.toplevel, layer); if (layer == ABOVE) gtk_window_present (GTK_WINDOW (panel.toplevel)); - + update_partial_struts (&panel); - + #if 0 /* dock type hint */ gboolean autohide = panel.priv->settings.autohide; if (autohide) panel_set_autohide (FALSE); - + gtk_widget_hide (panel.toplevel); gtk_widget_unrealize (panel.toplevel); - - gtk_window_set_type_hint (GTK_WINDOW (panel.toplevel), - layer == 0 ? GDK_WINDOW_TYPE_HINT_DOCK - : GDK_WINDOW_TYPE_HINT_NORMAL); + + gtk_window_set_type_hint (GTK_WINDOW (panel.toplevel), + layer == 0 ? GDK_WINDOW_TYPE_HINT_DOCK + : GDK_WINDOW_TYPE_HINT_NORMAL); /* position and properties are lost by unrealizing */ - gtk_window_move (GTK_WINDOW (panel.toplevel), + gtk_window_move (GTK_WINDOW (panel.toplevel), panel.position.x, panel.position.y); gtk_window_set_skip_taskbar_hint (GTK_WINDOW (panel.toplevel), TRUE); gtk_window_set_skip_pager_hint (GTK_WINDOW (panel.toplevel), TRUE); gtk_window_stick (GTK_WINDOW (panel.toplevel)); - + /* make sure it is really shown before setting struts */ gtk_widget_show_now (panel.toplevel); - + if (autohide) panel_set_autohide (TRUE); @@ -1271,7 +1251,7 @@ panel_set_size (int size) /* backwards compat */ settings = panel.priv->settings; - + if (!panel.priv->is_created) return; @@ -1292,7 +1272,7 @@ panel_set_popup_position (int position) /* backwards compat */ settings = panel.priv->settings; - + if (!panel.priv->is_created) return; @@ -1309,13 +1289,15 @@ void panel_set_theme (const char *theme) { g_free (panel.priv->settings.theme); - panel.priv->settings.theme = g_strdup (theme); - xfce_set_icon_theme (theme); + if (theme) + panel.priv->settings.theme = g_strdup (theme); + else + panel.priv->settings.theme = NULL; /* backwards compat */ settings = panel.priv->settings; - + if (panel.priv->is_created) { groups_set_theme (theme); @@ -1337,7 +1319,7 @@ panel_center (int side) panel.priv->side = side; panel.priv->pos_state = XFCE_POS_STATE_CENTER; panel.priv->offset = 0; - + panel_set_position (&panel); } @@ -1348,7 +1330,7 @@ panel_set_autohide (gboolean hide) /* backwards compat */ settings = panel.priv->settings; - + if (!panel.priv->is_created) return; @@ -1364,7 +1346,7 @@ panel_set_autohide (gboolean hide) { panel_set_hidden (&panel, hide); } - + update_partial_struts (&panel); } @@ -1372,7 +1354,7 @@ panel_set_autohide (gboolean hide) * ------------------ */ static void -init_settings (Panel *p) +init_settings (Panel * p) { p->priv->settings.orientation = HORIZONTAL; p->priv->settings.layer = ABOVE; @@ -1383,7 +1365,7 @@ init_settings (Panel *p) p->priv->settings.autohide = FALSE; p->priv->settings.theme = NULL; - + /* backwards compat */ settings = p->priv->settings; } @@ -1401,7 +1383,7 @@ panel_parse_xml (xmlNodePtr node) if (value) { n = (int) strtol (value, NULL, 0); - + settings.orientation = (n == VERTICAL) ? VERTICAL : HORIZONTAL; g_free (value); } @@ -1425,7 +1407,7 @@ panel_parse_xml (xmlNodePtr node) if (n >= TINY && n <= LARGE) settings.size = n; - + g_free (value); } @@ -1434,10 +1416,10 @@ panel_parse_xml (xmlNodePtr node) if (value) { n = (int) strtol (value, NULL, 0); - + if (n >= LEFT && n <= BOTTOM) settings.popup_position = n; - + g_free (value); } @@ -1460,7 +1442,7 @@ panel_parse_xml (xmlNodePtr node) if (value) { - int num_screens = + int num_screens = gdk_screen_get_n_monitors (panel.priv->screen); n = (int) strtol (value, NULL, 0); @@ -1478,10 +1460,10 @@ panel_parse_xml (xmlNodePtr node) if (n >= LEFT && n <= BOTTOM) panel.priv->side = n; - + g_free (value); } - + value = xmlGetProp (child, (const xmlChar *) "posstate"); if (value) @@ -1490,10 +1472,10 @@ panel_parse_xml (xmlNodePtr node) if (n > XFCE_POS_STATE_NONE && n <= XFCE_POS_STATE_END) panel.priv->pos_state = n; - + g_free (value); } - + if (panel.priv->pos_state != XFCE_POS_STATE_CENTER) { value = xmlGetProp (child, (const xmlChar *) "offset"); @@ -1507,7 +1489,9 @@ panel_parse_xml (xmlNodePtr node) } gdk_screen_get_monitor_geometry (panel.priv->screen, - panel.priv->monitor, &(panel.priv->monitor_geometry)); + panel.priv->monitor, + &(panel.priv-> + monitor_geometry)); } else { @@ -1532,21 +1516,22 @@ panel_parse_xml (xmlNodePtr node) if (panel.position.x != -1 && panel.position.y != -1) { - panel.priv->monitor = - gdk_screen_get_monitor_at_point (panel.priv->screen, - panel.position.x, - panel.position.y); + panel.priv->monitor = + gdk_screen_get_monitor_at_point (panel.priv->screen, + panel.position.x, + panel.position.y); gdk_screen_get_monitor_geometry (panel.priv->screen, - panel.priv->monitor, - &(panel.priv->monitor_geometry)); + panel.priv->monitor, + &(panel.priv-> + monitor_geometry)); panel.priv->pos_state = XFCE_POS_STATE_NONE; - + if (panel.priv->settings.orientation == HORIZONTAL) { if (panel.position.y < panel.priv->monitor_geometry.y - + panel.priv->monitor_geometry.height / 2) + + panel.priv->monitor_geometry.height / 2) { panel.priv->side = TOP; } @@ -1555,13 +1540,13 @@ panel_parse_xml (xmlNodePtr node) panel.priv->side = BOTTOM; } - panel.priv->offset = panel.position.x - + panel.priv->offset = panel.position.x - panel.priv->monitor_geometry.x; } else { if (panel.position.y < panel.priv->monitor_geometry.x - + panel.priv->monitor_geometry.width / 2) + + panel.priv->monitor_geometry.width / 2) { panel.priv->side = LEFT; } @@ -1570,25 +1555,25 @@ panel_parse_xml (xmlNodePtr node) panel.priv->side = RIGHT; } - panel.priv->offset = panel.position.y - + panel.priv->offset = panel.position.y - panel.priv->monitor_geometry.y; } } } } } - + if (panel.position.x == -1 || panel.position.y == -1) { DBG (" ++ Center panel on 1st monitor\n"); - + panel.priv->monitor = 0; panel.priv->side = BOTTOM; panel.priv->pos_state = XFCE_POS_STATE_CENTER; gdk_screen_get_monitor_geometry (panel.priv->screen, - panel.priv->monitor, - &(panel.priv->monitor_geometry)); + panel.priv->monitor, + &(panel.priv->monitor_geometry)); } } @@ -1643,15 +1628,15 @@ panel_write_xml (xmlNodePtr root) /* for menus, to prevent problems with autohide */ static void -menu_destroyed (GtkWidget *menu, Panel *p) +menu_destroyed (GtkWidget * menu, Panel * p) { - if (p->priv->settings.autohide + if (p->priv->settings.autohide && gdk_window_at_pointer (NULL, NULL) != p->toplevel->window) { GdkEvent *ev = gdk_event_new (GDK_LEAVE_NOTIFY); - ((GdkEventCrossing *)ev)->time = GDK_CURRENT_TIME; - ((GdkEventCrossing *)ev)->detail = GDK_NOTIFY_NONLINEAR; + ((GdkEventCrossing *) ev)->time = GDK_CURRENT_TIME; + ((GdkEventCrossing *) ev)->detail = GDK_NOTIFY_NONLINEAR; gtk_widget_event (p->toplevel, ev); @@ -1659,28 +1644,29 @@ menu_destroyed (GtkWidget *menu, Panel *p) } } -void -panel_register_open_menu (GtkWidget *menu) +void +panel_register_open_menu (GtkWidget * menu) { g_return_if_fail (GTK_IS_WIDGET (menu)); - g_signal_connect (menu, "deactivate", G_CALLBACK (menu_destroyed), &panel); + g_signal_connect (menu, "deactivate", G_CALLBACK (menu_destroyed), + &panel); } -void -panel_block_autohide (Panel *p) +void +panel_block_autohide (Panel * p) { p->priv->block_autohide++; } -void -panel_unblock_autohide (Panel *p) +void +panel_unblock_autohide (Panel * p) { if (p->priv->block_autohide > 0) p->priv->block_autohide--; } -int +int panel_get_side (void) { return panel.priv->side; diff --git a/panel/panel.h b/panel/panel.h index 147467c4..1f9df2c1 100644 --- a/panel/panel.h +++ b/panel/panel.h @@ -1,6 +1,6 @@ /* $Id$ * - * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -46,7 +46,7 @@ struct _Panel int unhide_timeout; Position position; - + GtkWidget *toplevel; GtkWidget *main_frame; @@ -80,11 +80,11 @@ void panel_parse_xml (xmlNodePtr node); void panel_write_xml (xmlNodePtr root); /* for menus, to prevent problems with autohide */ -void panel_register_open_menu (GtkWidget *menu); +void panel_register_open_menu (GtkWidget * menu); -void panel_block_autohide (Panel *panel); +void panel_block_autohide (Panel * panel); -void panel_unblock_autohide (Panel *panel); +void panel_unblock_autohide (Panel * panel); int panel_get_side (void); diff --git a/panel/plugins.h b/panel/plugins.h index 334491d9..304f9b1d 100644 --- a/panel/plugins.h +++ b/panel/plugins.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,17 +27,14 @@ #define XFCE_PLUGIN_API_VERSION 5 -#ifdef __cplusplus -extern "C" -{ -#endif /* __cplusplus */ +G_BEGIN_DECLS /* prototype for plugin init function * (must be implemented by plugin) */ - G_MODULE_EXPORT void xfce_control_class_init (ControlClass * control); +G_MODULE_EXPORT void xfce_control_class_init (ControlClass * control); /* plugin version check function (implemented by xfce4 in controls.c) */ - gchar *xfce_plugin_check_version (gint version); +gchar *xfce_plugin_check_version (gint version); /* nifty idea, I think from dia: * every module just has to include this header and put @@ -46,15 +43,13 @@ extern "C" * be checked on opening the GModule. */ #define XFCE_PLUGIN_CHECK_INIT \ -G_MODULE_EXPORT const gchar *g_module_check_init(GModule *gmodule); \ -const gchar * \ -g_module_check_init(GModule *gmodule) \ -{ \ - return xfce_plugin_check_version(XFCE_PLUGIN_API_VERSION); \ -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ + G_MODULE_EXPORT const gchar *g_module_check_init(GModule *gmodule); \ + const gchar * \ + g_module_check_init(GModule *gmodule) \ + { \ + return xfce_plugin_check_version(XFCE_PLUGIN_API_VERSION); \ + } + +G_END_DECLS #endif /* _XFCE_PLUGIN_H */ diff --git a/panel/popup.c b/panel/popup.c index 4cb2338b..2a4abf35 100644 --- a/panel/popup.c +++ b/panel/popup.c @@ -1,6 +1,6 @@ -/* popup.c +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -72,12 +72,14 @@ position_popup (PanelPopup * pp) int xbutton, ybutton, xparent, yparent, x, y; int w, h; gboolean vertical = settings.orientation == VERTICAL; - GtkAllocation alloc1 = {0}, alloc2 = {0}; + GtkAllocation alloc1 = { 0 }, alloc2 = + { + 0}; GtkArrowType at; if (!pp) return; - + if (pp->detached) return; @@ -123,8 +125,10 @@ position_popup (PanelPopup * pp) if (vertical) { - /* left if buttons left or if menu doesn't fit right, but does fit left */ - if ((at == GTK_ARROW_LEFT || x + req.width + alloc1.width > w) && x - req.width >= 0) + /* left if buttons left or if menu doesn't fit right, + * but does fit left */ + if ((at == GTK_ARROW_LEFT || x + req.width + alloc1.width > w) + && x - req.width >= 0) { x = x - req.width; } @@ -140,8 +144,9 @@ position_popup (PanelPopup * pp) } else { - /* down if buttons on bottom or up doesn't fit and down doe */ - if ((at == GTK_ARROW_DOWN || y - req.height < 0) && y + alloc1.height + req.height <= h) + /* down if buttons on bottom or up doesn't fit and down does */ + if ((at == GTK_ARROW_DOWN || y - req.height < 0) + && y + alloc1.height + req.height <= h) { y = y + alloc1.height; } @@ -168,7 +173,7 @@ show_popup (PanelPopup * pp) { if (!pp) return; - + if (open_popup) hide_popup (open_popup); @@ -387,7 +392,7 @@ panel_popup_pack (PanelPopup * pp, GtkBox * box) { if (!pp) return; - + gtk_box_pack_start (box, pp->button, FALSE, FALSE, 0); } @@ -398,7 +403,7 @@ panel_popup_unpack (PanelPopup * pp) if (!pp) return; - + container = pp->button->parent; gtk_container_remove (GTK_CONTAINER (container), pp->button); @@ -451,7 +456,7 @@ panel_popup_set_from_xml (PanelPopup * pp, xmlNodePtr node) if (!pp) return; - + for (i = 0, child = node->children; child; i++, child = child->next) { Item *mi; @@ -477,7 +482,7 @@ panel_popup_write_xml (PanelPopup * pp, xmlNodePtr root) if (!pp || !pp->items) return; - + node = xmlNewTextChild (root, NULL, "Popup", NULL); for (li = pp->items; li; li = li->next) @@ -500,7 +505,7 @@ panel_popup_free (PanelPopup * pp) return; gtk_widget_destroy (pp->window); - + for (li = pp->items; li && li->data; li = li->next) { Item *mi = li->data; @@ -520,7 +525,7 @@ panel_popup_set_size (PanelPopup * pp, int size) if (!pp) return; - + w = icon_size[size] + border_width; h = top_height[size]; @@ -547,7 +552,7 @@ panel_popup_set_popup_position (PanelPopup * pp, int position) if (!pp) return; - + panel_popup_set_size (pp, settings.size); } @@ -556,7 +561,7 @@ panel_popup_set_layer (PanelPopup * pp, int layer) { if (!pp) return; - + set_window_layer (pp->window, layer); } @@ -567,7 +572,7 @@ panel_popup_set_theme (PanelPopup * pp, const char *theme) if (!pp) return; - + for (li = pp->items; li && li->data; li = li->next) { Item *mi = li->data; diff --git a/panel/popup.h b/panel/popup.h index 92717ecb..ddabcb87 100644 --- a/panel/popup.h +++ b/panel/popup.h @@ -1,6 +1,6 @@ -/* popup.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/settings.c b/panel/settings.c index 28e39628..df429f92 100644 --- a/panel/settings.c +++ b/panel/settings.c @@ -1,6 +1,6 @@ -/* settings.c +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -63,13 +63,13 @@ check_disable_user_config (void) xfce_kiosk_free (kiosk); if (var != NULL) - { - g_warning ("Deprecated XFCE_DISABLE_USER_CONFIG environment variable " - "found. Please use the new KIOSK mode instead."); - } + { + g_warning ("Deprecated XFCE_DISABLE_USER_CONFIG environment variable " + "found. Please use the new KIOSK mode instead."); + } if (!result) - return TRUE; + return TRUE; return (var && !strequal (var, "0")); } @@ -243,24 +243,24 @@ write_panel_config (void) goto out; } - if (g_file_test (xfcerc, G_FILE_TEST_EXISTS) && unlink(xfcerc)) + if (g_file_test (xfcerc, G_FILE_TEST_EXISTS) && unlink (xfcerc)) { g_critical ("Could not remove old xfce4rc"); goto out; } - if(link(tmprc, xfcerc)) + if (link (tmprc, xfcerc)) { g_critical ("Could not link new xfce4rc"); goto out; } - if (unlink(tmprc)) + if (unlink (tmprc)) { g_warning ("Could not remove temporary file xfce4rc.tmp"); } - -out: + + out: g_free (tmprc); g_free (xfcerc); xmlFreeDoc (xmlconfig); diff --git a/panel/settings.h b/panel/settings.h index 968eab01..03bee4f4 100644 --- a/panel/settings.h +++ b/panel/settings.h @@ -1,6 +1,6 @@ -/* settings.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/xfce.h b/panel/xfce.h index f8241e71..b5226614 100644 --- a/panel/xfce.h +++ b/panel/xfce.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans(huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/panel/xfce_support.c b/panel/xfce_support.c index 20d45cd2..2aa33664 100644 --- a/panel/xfce_support.c +++ b/panel/xfce_support.c @@ -1,8 +1,9 @@ -/* xfce_support.c +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) - * startup notification added by Olivier fourdan based on gnome-desktop - * developed by Elliot Lee <sopwith@redhat.com> and Sid Vicious + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) + * + * Startup notification added by Olivier fourdan based on gnome-desktop + * developed by Elliot Lee <sopwith@redhat.com> and Sid Vicious. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -82,9 +83,9 @@ get_save_file (const gchar * name) fmt = g_strconcat (name, ".%u", NULL); realname = g_strdup_printf (fmt, scr); - + file = xfce_get_userfile (realname, NULL); - + g_free (fmt); g_free (realname); } @@ -120,14 +121,14 @@ static gchar * get_localized_system_rcfile (const gchar * name) { char *sysrcfile, *result; - char buffer [PATH_MAX]; + char buffer[PATH_MAX]; - snprintf(buffer, PATH_MAX, "%s.%%l", name); + snprintf (buffer, PATH_MAX, "%s.%%l", name); sysrcfile = g_build_filename (SYSCONFDIR, SYSRCDIR, buffer, NULL); - result = xfce_get_path_localized (buffer, PATH_MAX, sysrcfile, NULL, - G_FILE_TEST_EXISTS); + result = xfce_get_path_localized (buffer, PATH_MAX, sysrcfile, NULL, + G_FILE_TEST_EXISTS); g_free (sysrcfile); @@ -314,8 +315,8 @@ void set_window_skip (GtkWidget * win) { #if GTK_CHECK_VERSION(2, 2, 0) - g_object_set (G_OBJECT(win), "skip_taskbar_hint", TRUE, NULL); - g_object_set (G_OBJECT(win), "skip_pager_hint", TRUE, NULL); + g_object_set (G_OBJECT (win), "skip_taskbar_hint", TRUE, NULL); + g_object_set (G_OBJECT (win), "skip_pager_hint", TRUE, NULL); #else Screen *xscreen; Window xid; @@ -662,13 +663,13 @@ real_exec_cmd (const char *cmd, gboolean in_terminal, gboolean use_sn, gboolean silent) { GError *error = NULL; - + if (!xfce_exec (cmd, in_terminal, use_sn, &error)) { if (error) { char *msg = g_strcompress (error->message); - + if (silent) { g_warning ("%s", msg); diff --git a/panel/xfce_support.h b/panel/xfce_support.h index d37f6ee2..e48b9fb8 100644 --- a/panel/xfce_support.h +++ b/panel/xfce_support.h @@ -1,7 +1,8 @@ -/* xfce_support.h +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) - * startup notification added by Olivier Fourdan based on gnome-desktop + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) + * + * Startup notification added by Olivier Fourdan based on gnome-desktop * developed by Elliot Lee <sopwith@redhat.com> and Sid Vicious * * This program is free software; you can redistribute it and/or modify diff --git a/panel/xfcombo.c b/panel/xfcombo.c index 4604d4be..479f929a 100644 --- a/panel/xfcombo.c +++ b/panel/xfcombo.c @@ -1,4 +1,4 @@ -/* xfce4 +/* $Id$ * * Copyright (C) 2004 Edscott Wilson Garcia <edscott@users.sourceforge.net> * Copyright (C) 2004 Jasper Huijsmans (jasper@xfce.org) @@ -57,35 +57,35 @@ struct _CompletionCombo xfc_combo_functions_t *fun; xfc_combo_info_t *info; - + gboolean widget_destroyed; - + /* callbacks */ - void (*cancel)(CompletionCombo *combo, gpointer data); + void (*cancel) (CompletionCombo * combo, gpointer data); gpointer cancel_data; - void (*activate)(CompletionCombo *combo, gpointer data); + void (*activate) (CompletionCombo * combo, gpointer data); gpointer activate_data; - void (*complete)(CompletionCombo *combo, gpointer data); + void (*complete) (CompletionCombo * combo, gpointer data); gpointer complete_data; }; -CompletionCombo *completion_combo_new (GtkCombo *combo); +CompletionCombo *completion_combo_new (GtkCombo * combo); -void completion_combo_destroy (CompletionCombo *combo); +void completion_combo_destroy (CompletionCombo * combo); -void completion_combo_set_cancel_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_cancel_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); -void completion_combo_set_activate_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_activate_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); -void completion_combo_set_complete_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_complete_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); #define CC_SET_COMBO(combo,token) \ @@ -127,12 +127,12 @@ completion_combo_new (void) CompletionCombo *cc; gpointer symbol; - cc = g_new0 (CompletionCombo,1); + cc = g_new0 (CompletionCombo, 1); - cc->combo = gtk_combo_new(); + cc->combo = gtk_combo_new (); cc->entry = GTK_COMBO (cc->combo)->entry; - cc->gmodule = get_combo_module(); + cc->gmodule = get_combo_module (); if (!g_module_find_symbol (cc->gmodule, "module_init", &symbol)) { @@ -149,39 +149,39 @@ completion_combo_new (void) } cc->info = cc->fun->xfc_init_combo (GTK_COMBO (cc->combo)); - + /* set all user data to the CompletionCombo */ cc->info->cancel_user_data = cc->info->activate_user_data = cc->fun->extra_key_data = cc; - + cc->info->cancel_func = completion_combo_cancel; cc->info->activate_function = completion_combo_activate; cc->fun->extra_key_completion = completion_combo_complete; - + return cc; -failed: + failed: gtk_widget_destroy (cc->combo); g_free (cc); return NULL; } -void completion_combo_destroy (CompletionCombo *combo); +void completion_combo_destroy (CompletionCombo * combo); -void completion_combo_set_cancel_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_cancel_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); -void completion_combo_set_activate_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_activate_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); -void completion_combo_set_complete_callback (CompletionCombo *combo, - void (*callback)(CompletionCombo*, - gpointer), +void completion_combo_set_complete_callback (CompletionCombo * combo, + void (*callback) (CompletionCombo + *, gpointer), gpointer data); #endif static int refcount = 0; @@ -195,7 +195,7 @@ unload_xfc (void) xfc_fun = NULL; DBG ("unloading module \"libxfce4_combo\""); - + if (!g_module_close (xfc_cm)) { g_warning ("Failed to unload module \"libxfce4_combo\""); @@ -234,18 +234,18 @@ load_xfc (void) module_init = symbol; xfc_fun = module_init (); - + DBG ("module %s successfully loaded", library); - + g_free (library); g_free (module); - + return xfc_fun; - -failed: + + failed: g_free (library); g_free (module); - + return NULL; } @@ -261,7 +261,7 @@ save_flags (gchar * in_cmd, gboolean interm, gboolean hold) int *flags; GString *gs; gchar *file; - + file = xfce_get_userfile ("xffm", RUN_FLAG_FILE, NULL); if ((runflags = DBH_open (file)) == NULL) @@ -273,17 +273,17 @@ save_flags (gchar * in_cmd, gboolean interm, gboolean hold) return; } } - + g_free (file); - + gs = g_string_new (in_cmd); sprintf ((char *) DBH_KEY (runflags), "%10u", g_string_hash (gs)); g_string_free (gs, TRUE); - + flags = (int *) runflags->data; flags[0] = interm; flags[1] = hold; - + DBH_set_recordsize (runflags, 2 * sizeof (int)); DBH_update (runflags); DBH_close (runflags); @@ -299,7 +299,7 @@ recover_flags (gchar * in_cmd, gboolean * interm, gboolean * hold) int *flags; GString *gs; char *file; - + file = xfce_get_userfile ("xffm", RUN_FLAG_FILE, NULL); if ((runflags = DBH_open (file)) == NULL) @@ -308,13 +308,13 @@ recover_flags (gchar * in_cmd, gboolean * interm, gboolean * hold) *interm = *hold = FALSE; return; } - + g_free (file); - + gs = g_string_new (in_cmd); sprintf ((char *) DBH_KEY (runflags), "%10u", g_string_hash (gs)); g_string_free (gs, TRUE); - + flags = (int *) runflags->data; DBH_load (runflags); *interm = (flags[0] != 0); @@ -336,7 +336,7 @@ extra_key_completion (gpointer data) if (callback) { gpointer data; - + data = g_object_get_data (G_OBJECT (info->combo), "data"); callback (info, data); @@ -358,47 +358,46 @@ create_completion_combo (ComboCallback completion_cb, gpointer data) xfc_fun = load_xfc (); refcount = 0; } - + if (xfc_fun != NULL) { GtkWidget *command_combo; char *f; refcount++; - + DBG ("refcount: %d", refcount); command_combo = gtk_combo_new (); if (completion_cb) { - g_object_set_data (G_OBJECT (command_combo), "callback", - completion_cb); + g_object_set_data (G_OBJECT (command_combo), "callback", + completion_cb); if (data) { - g_object_set_data (G_OBJECT (command_combo), "data", - data); + g_object_set_data (G_OBJECT (command_combo), "data", data); } } combo_info = xfc_fun->xfc_init_combo ((GtkCombo *) command_combo); combo_info->activate_func = NULL; - + f = xfce_get_userfile ("xffm", RUN_DBH_FILE, NULL); - + xfc_fun->extra_key_completion = NULL; xfc_fun->extra_key_data = NULL; - + if (access (f, F_OK) == 0) { xfc_fun->xfc_read_history (combo_info, f); xfc_fun->xfc_set_combo (combo_info, NULL); } - + g_free (f); - + xfc_fun->extra_key_completion = extra_key_completion; xfc_fun->extra_key_data = combo_info; } @@ -406,8 +405,8 @@ create_completion_combo (ComboCallback completion_cb, gpointer data) return combo_info; } -void -destroy_completion_combo (xfc_combo_info_t *info) +void +destroy_completion_combo (xfc_combo_info_t * info) { if (xfc_fun) { @@ -423,23 +422,23 @@ destroy_completion_combo (xfc_combo_info_t *info) } } -void -completion_combo_set_text (xfc_combo_info_t *info, const char *text) +void +completion_combo_set_text (xfc_combo_info_t * info, const char *text) { if (xfc_fun) - xfc_fun->xfc_set_entry (info, (char *)text); + xfc_fun->xfc_set_entry (info, (char *) text); } -gboolean +gboolean history_check_in_terminal (const char *command) { gboolean interm, hold; - recover_flags ((char *)command, &interm, &hold); - + recover_flags ((char *) command, &interm, &hold); + return interm; } -#else +#else /* ! HAVE_LIBDBH * * These are just stubs to keep the compiler happy ;-) @@ -451,22 +450,22 @@ create_completion_combo (ComboCallback completion_cb, gpointer cb) return NULL; } -void -destroy_completion_combo (xfc_combo_info_t *info) +void +destroy_completion_combo (xfc_combo_info_t * info) { /* */ } -void -completion_combo_set_text (xfc_combo_info_t *info, const char *text) +void +completion_combo_set_text (xfc_combo_info_t * info, const char *text) { /* */ } -gboolean history_check_in_terminal (const char *command) +gboolean +history_check_in_terminal (const char *command) { return FALSE; } #endif /* HAVE_LIBDBH */ - diff --git a/panel/xfcombo.h b/panel/xfcombo.h index 13c7a7aa..1e75f723 100644 --- a/panel/xfcombo.h +++ b/panel/xfcombo.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2004 Jasper Huijsmans (jasper@xfce.org) + * Copyright 2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -73,16 +73,15 @@ struct _xfc_combo_info_t #endif /* HAVE_LIBDBH */ -typedef void (*ComboCallback) (xfc_combo_info_t *info, gpointer data); +typedef void (*ComboCallback) (xfc_combo_info_t * info, gpointer data); -xfc_combo_info_t *create_completion_combo (ComboCallback completion_cb, - gpointer data); +xfc_combo_info_t *create_completion_combo (ComboCallback completion_cb, + gpointer data); -void destroy_completion_combo (xfc_combo_info_t *info); +void destroy_completion_combo (xfc_combo_info_t * info); -void completion_combo_set_text (xfc_combo_info_t *info, const char *text); +void completion_combo_set_text (xfc_combo_info_t * info, const char *text); gboolean history_check_in_terminal (const char *command); #endif /* _XFCOMBO_H */ - diff --git a/plugins/clock/clock.c b/plugins/clock/clock.c index c124ea7e..e2fb10ff 100644 --- a/plugins/clock/clock.c +++ b/plugins/clock/clock.c @@ -1,8 +1,8 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans(huysmans@users.sourceforge.net) - * Xavier Maillard (zedek@fxgsproject.org) - * Olivier Fourdan (fourdan@xfce.org) + * Copyright 2002,2004 Jasper Huijsmans(jasper@xfce.org) + * Olivier Fourdan (fourdan@xfce.org) + * Xavier Maillard (zedek@fxgsproject.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -147,7 +147,7 @@ popup_xfcalendar (GtkWidget * widget, guint32 time) { start_time = time; exec_cmd_silent ("xfcalendar", FALSE, FALSE); - g_timeout_add (1000, (GSourceFunc)retry_popup_xfcalendar, widget); + g_timeout_add (1000, (GSourceFunc) retry_popup_xfcalendar, widget); } return FALSE; diff --git a/plugins/mailcheck/mailcheck.c b/plugins/mailcheck/mailcheck.c index 5102e8cb..6fd2ef5a 100644 --- a/plugins/mailcheck/mailcheck.c +++ b/plugins/mailcheck/mailcheck.c @@ -1,6 +1,6 @@ -/* mailcheck.c +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans (huysmans@users.sourceforge.net) + * Copyright (C) 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * - 2004 Add Maildir support Julien NOEL (dev@no-l.org) * @@ -104,8 +104,8 @@ get_mail_pixbuf (void) { GdkPixbuf *pb; - pb = themed_pixbuf_from_name_list (mailcheck_icon_names, - icon_size [settings.size]); + pb = themed_pixbuf_from_name_list (mailcheck_icon_names, + icon_size[settings.size]); if (G_UNLIKELY (!pb)) { @@ -117,7 +117,7 @@ get_mail_pixbuf (void) } static void -reset_mailcheck_icons (t_mailcheck *mc) +reset_mailcheck_icons (t_mailcheck * mc) { if (mc->newmail_pb) g_object_unref (mc->newmail_pb); @@ -133,9 +133,7 @@ reset_mailcheck_icons (t_mailcheck *mc) g_return_if_fail (mc->newmail_pb != NULL); mc->nomail_pb = gdk_pixbuf_copy (mc->newmail_pb); - gdk_pixbuf_saturate_and_pixelate (mc->nomail_pb, - mc->nomail_pb, - 0, TRUE); + gdk_pixbuf_saturate_and_pixelate (mc->nomail_pb, mc->nomail_pb, 0, TRUE); mc->oldmail_pb = mc->nomail_pb; g_object_ref (mc->oldmail_pb); @@ -336,57 +334,58 @@ check_mail (t_mailcheck * mailcheck) } else { - if (stat (mailcheck->mbox, &s) < 0) + if (stat (mailcheck->mbox, &s) < 0) { mail = NO_MAIL; } - else if (S_ISREG(s.st_mode)) + else if (S_ISREG (s.st_mode)) { - DBG("mbox format"); + DBG ("mbox format"); if (!s.st_size) mail = NO_MAIL; - else if (s.st_mtime <= s.st_atime) + else if (s.st_mtime <= s.st_atime) mail = OLD_MAIL; - else + else mail = NEW_MAIL; - } - else if (S_ISDIR (s.st_mode)) + } + else if (S_ISDIR (s.st_mode)) { DIR *dr; struct dirent *de; - char *c_list[] = {"tmp","cur","new"}; + char *c_list[] = { "tmp", "cur", "new" }; char *c_tmp; - int i_tmp; - + int i_tmp; + /* mailbox is a maildir */ - DBG("maildir format"); + DBG ("maildir format"); mail = NO_MAIL; /* Verify the Maildir integrity */ - for (i_tmp = 0; i_tmp < 3; i_tmp++) + for (i_tmp = 0; i_tmp < 3; i_tmp++) { - c_tmp = g_build_filename(mailcheck->mbox, c_list[i_tmp], NULL); + c_tmp = + g_build_filename (mailcheck->mbox, c_list[i_tmp], NULL); - if (stat (c_tmp, &s) >= 0 && S_ISDIR(s.st_mode)) + if (stat (c_tmp, &s) >= 0 && S_ISDIR (s.st_mode)) { - dr = opendir(c_tmp); - - if (dr != NULL) + dr = opendir (c_tmp); + + if (dr != NULL) { - while ((de = readdir(dr))) + while ((de = readdir (dr))) { - if (strlen(de->d_name) >= 1 && - de->d_name[0] != '.') + if (strlen (de->d_name) >= 1 && + de->d_name[0] != '.') { if (i_tmp < 2) { mail = OLD_MAIL; break; } - else + else { mail = NEW_MAIL; break; @@ -394,15 +393,15 @@ check_mail (t_mailcheck * mailcheck) } } - closedir(dr); + closedir (dr); } } } } } - DBG("Done"); - + DBG ("Done"); + if (mail != mailcheck->status) { if (mail == NEW_MAIL && mailcheck->status != NEW_MAIL && @@ -518,7 +517,7 @@ mailcheck_read_config (Control * control, xmlNodePtr node) g_free (value); } - + value = xmlGetProp (node, "sn"); if (value) @@ -594,7 +593,7 @@ mailcheck_new (void) mailcheck->timeout_id = 0; reset_mailcheck_icons (mailcheck); - + mailcheck->newmail_command = g_strdup (""); mail = g_getenv ("MAIL"); @@ -649,7 +648,7 @@ mailcheck_set_theme (Control * control, const char *theme) t_mailcheck *mailcheck = (t_mailcheck *) control->data; reset_mailcheck_icons (mailcheck); - + if (mailcheck->status == NO_MAIL) { xfce_iconbutton_set_pixbuf (XFCE_ICONBUTTON (mailcheck->button), @@ -698,10 +697,10 @@ mailcheck_apply_options (MailDialog * md) const char *tmp; t_mailcheck *mc = md->mc; - g_free (mc->command); + g_free (mc->command); command_options_get_command (md->cmd_opts, &(mc->command), &(mc->term), - &(mc->use_sn)); + &(mc->use_sn)); tmp = gtk_entry_get_text (GTK_ENTRY (md->mbox_entry)); @@ -725,7 +724,7 @@ mailcheck_apply_options (MailDialog * md) mailcheck_set_tip (mc); - run_mailcheck (mc); + run_mailcheck (mc); } /* mbox */ @@ -859,16 +858,15 @@ static void add_command_box (GtkWidget * vbox, GtkSizeGroup * sg, MailDialog * md) { md->cmd_opts = create_command_options (sg); - - command_options_set_command (md->cmd_opts, md->mc->command, - md->mc->term, md->mc->use_sn); + + command_options_set_command (md->cmd_opts, md->mc->command, + md->mc->term, md->mc->use_sn); gtk_box_pack_start (GTK_BOX (vbox), md->cmd_opts->base, FALSE, TRUE, 0); gtk_tooltips_set_tip (tooltips, md->cmd_opts->command_entry, _("Command to run when the button " - "on the panel is clicked"), - NULL); + "on the panel is clicked"), NULL); } /* interval */ diff --git a/plugins/pager/pager.c b/plugins/pager/pager.c index f327348f..f6dc23f5 100644 --- a/plugins/pager/pager.c +++ b/plugins/pager/pager.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans(huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -164,8 +164,8 @@ arrange_pager (t_pager * pager) GList *li; if (pager->netk_pager) - gtk_widget_destroy(pager->netk_pager); - + gtk_widget_destroy (pager->netk_pager); + pager->netk_pager = create_netk_pager (pager->screen); netk_pager_set_n_rows (NETK_PAGER (pager->netk_pager), pager->rows); @@ -204,8 +204,8 @@ pager_new (NetkScreen * screen) pager->screen = screen; - pager->base = gtk_alignment_new (0.5, 0.5, 0, 0); - gtk_widget_show (pager->base); + pager->base = gtk_alignment_new (0.5, 0.5, 0, 0); + gtk_widget_show (pager->base); pager->rows = 1; @@ -245,7 +245,7 @@ pager_free (Control * control) /* configuration */ static void -pager_read_config (Control *control, xmlNodePtr node) +pager_read_config (Control * control, xmlNodePtr node) { xmlChar *value; int n, max; @@ -254,7 +254,7 @@ pager_read_config (Control *control, xmlNodePtr node) value = xmlGetProp (node, (const xmlChar *) "rows"); max = netk_screen_get_workspace_count (pager->screen); - + if (value) { n = strtol (value, NULL, 0); @@ -269,7 +269,7 @@ pager_read_config (Control *control, xmlNodePtr node) } static void -pager_write_config (Control *control, xmlNodePtr node) +pager_write_config (Control * control, xmlNodePtr node) { char prop[3]; t_pager *pager = control->data; @@ -281,7 +281,7 @@ pager_write_config (Control *control, xmlNodePtr node) /* property dialog */ static void -rows_changed (GtkSpinButton *spin, t_pager *pager) +rows_changed (GtkSpinButton * spin, t_pager * pager) { int rows = gtk_spin_button_get_value_as_int (spin); @@ -294,8 +294,8 @@ rows_changed (GtkSpinButton *spin, t_pager *pager) } static void -pager_create_options (Control *control, GtkContainer *container, - GtkWidget *close) +pager_create_options (Control * control, GtkContainer * container, + GtkWidget * close) { GtkWidget *hbox, *label, *spin; int max; @@ -313,14 +313,15 @@ pager_create_options (Control *control, GtkContainer *container, gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); max = netk_screen_get_workspace_count (pager->screen); - + spin = gtk_spin_button_new_with_range (1, max, 1); gtk_widget_show (spin); gtk_box_pack_start (GTK_BOX (hbox), spin, FALSE, FALSE, 0); gtk_spin_button_set_value (GTK_SPIN_BUTTON (spin), pager->rows); - - g_signal_connect (spin, "value-changed", G_CALLBACK (rows_changed), pager); + + g_signal_connect (spin, "value-changed", G_CALLBACK (rows_changed), + pager); } /* Switcher panel control diff --git a/plugins/sample-plugin/sample.c b/plugins/sample-plugin/sample.c index a9565938..7ac78bb1 100644 --- a/plugins/sample-plugin/sample.c +++ b/plugins/sample-plugin/sample.c @@ -75,14 +75,14 @@ sample_read_config (Control * control, xmlNodePtr node) xmlChar *value; int n; t_sample *sample; - + if (!node || !node->children) return; sample = (t_sample *) control->data; /* xml properties ... */ - + value = xmlGetProp (node, (const xmlChar *) "sampleint"); if (value) @@ -100,18 +100,18 @@ sample_read_config (Control * control, xmlNodePtr node) if (value) { g_free (sample->stringval); - sample->stringval = (char *)value; + sample->stringval = (char *) value; } /* xml elements (child nodes) */ - + for (node = node->children; node; node = node->next) { if (xmlStrEqual (node->name, (const xmlChar *) "samplenode1")) { /* this macro is defined in <xfce4/settings.h> */ value = DATA (node); - + if (value) { g_free (sample->elementval1); @@ -146,7 +146,7 @@ sample_write_config (Control * control, xmlNodePtr parent) { char value[5]; t_sample *sample; - + sample = (t_sample *) control->data; g_snprintf (value, 4, "%d", sample->intval); @@ -172,9 +172,9 @@ sample_write_config (Control * control, xmlNodePtr parent) * receive events, at least one. This is used, for example to connect the * right-click menu. **/ -static void +static void sample_attach_callback (Control * control, const char *signal, - GCallback callback, gpointer data) + GCallback callback, gpointer data) { t_sample *sample = control->data; @@ -246,7 +246,7 @@ static void sample_set_theme (Control * control, const char *theme) { t_sample *sample; - + sample = (t_sample *) control->data; /* update the icons */ @@ -318,7 +318,7 @@ sample_apply_options (SampleDialog * sd) } tmp = gtk_entry_get_text (GTK_ENTRY (sd->ev1_entry)); - + if (tmp && *tmp) { g_free (sample->elementval1); @@ -326,7 +326,7 @@ sample_apply_options (SampleDialog * sd) } tmp = gtk_entry_get_text (GTK_ENTRY (sd->ev2_entry)); - + if (tmp && *tmp) { g_free (sample->elementval2); @@ -379,7 +379,7 @@ int_changed (GtkSpinButton * spin, SampleDialog * sd) **/ static void sample_create_options (Control * control, GtkContainer * container, - GtkWidget * done) + GtkWidget * done) { GtkWidget *vbox, *hbox, *label; GtkSizeGroup *sg = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); @@ -393,12 +393,12 @@ sample_create_options (Control * control, GtkContainer * container, sd->dialog = gtk_widget_get_toplevel (done); /* don't set a border width, the dialog will take care of that */ - + vbox = gtk_vbox_new (FALSE, BORDER); gtk_widget_show (vbox); /* spin button */ - + hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -417,7 +417,7 @@ sample_create_options (Control * control, GtkContainer * container, g_signal_connect (sd->int_spin, "value-changed", G_CALLBACK (int_changed), sd); - + /* entries */ hbox = gtk_hbox_new (FALSE, BORDER); @@ -435,10 +435,10 @@ sample_create_options (Control * control, GtkContainer * container, gtk_widget_show (sd->string_entry); gtk_box_pack_start (GTK_BOX (hbox), sd->string_entry, TRUE, TRUE, 0); - g_signal_connect (sd->string_entry, "focus-out", - G_CALLBACK (entry_lost_focus), sd); - - + g_signal_connect (sd->string_entry, "focus-out", + G_CALLBACK (entry_lost_focus), sd); + + hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -454,10 +454,10 @@ sample_create_options (Control * control, GtkContainer * container, gtk_widget_show (sd->ev1_entry); gtk_box_pack_start (GTK_BOX (hbox), sd->ev1_entry, TRUE, TRUE, 0); - g_signal_connect (sd->ev1_entry, "focus-out", - G_CALLBACK (entry_lost_focus), sd); - - + g_signal_connect (sd->ev1_entry, "focus-out", + G_CALLBACK (entry_lost_focus), sd); + + hbox = gtk_hbox_new (FALSE, BORDER); gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0); @@ -473,10 +473,10 @@ sample_create_options (Control * control, GtkContainer * container, gtk_widget_show (sd->ev2_entry); gtk_box_pack_start (GTK_BOX (hbox), sd->ev2_entry, TRUE, TRUE, 0); - g_signal_connect (sd->ev2_entry, "focus-out", - G_CALLBACK (entry_lost_focus), sd); - - + g_signal_connect (sd->ev2_entry, "focus-out", + G_CALLBACK (entry_lost_focus), sd); + + /* update settings when dialog is closed */ g_signal_connect_swapped (done, "clicked", @@ -534,7 +534,7 @@ xfce_control_class_init (ControlClass * cc) */ cc->name = "sample"; cc->caption = "Sample"; - + cc->create_control = (CreateControlFunc) create_sample_control; cc->attach_callback = sample_attach_callback; diff --git a/plugins/separator/separator.c b/plugins/separator/separator.c index 6de60e6b..6205a3a3 100644 --- a/plugins/separator/separator.c +++ b/plugins/separator/separator.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2003 Jasper Huijsmans(huysmans@users.sourceforge.net) + * Copyright 2003 Jasper Huijsmans (jasper) * * Adapted from initial implementation by Ejvend Nielsen, copyright 2003 * licensed under GNU GPL. @@ -46,18 +46,18 @@ separator_free (Control * control) { t_separator *sep = control->data; - g_object_unref(sep->hsep); - g_object_unref(sep->vsep); + g_object_unref (sep->hsep); + g_object_unref (sep->vsep); g_free (sep); } static void separator_attach_callback (Control * control, const char *signal, - GCallback callback, gpointer data) + GCallback callback, gpointer data) { t_separator *sep = (t_separator *) control->data; - + g_signal_connect (sep->box, signal, callback, data); g_signal_connect (sep->hsep, signal, callback, data); g_signal_connect (sep->vsep, signal, callback, data); @@ -67,17 +67,17 @@ static void separator_set_size (Control * control, int size) { /* define explicitly to do nothing */ - + #if 0 int s; t_separator *sep = control->data; s = icon_size[size] + border_width; - + if (settings.orientation == HORIZONTAL) - gtk_widget_set_size_request(control->base, -1, s); + gtk_widget_set_size_request (control->base, -1, s); else - gtk_widget_set_size_request(control->base, s, -1); + gtk_widget_set_size_request (control->base, s, -1); #endif } @@ -87,20 +87,20 @@ separator_set_orientation (Control * control, int orientation) t_separator *sep = control->data; GtkWidget *child; - child = gtk_bin_get_child(GTK_BIN(sep->align)); + child = gtk_bin_get_child (GTK_BIN (sep->align)); if (child) - gtk_container_remove(GTK_CONTAINER(sep->align), child); + gtk_container_remove (GTK_CONTAINER (sep->align), child); if (orientation == HORIZONTAL) { - gtk_container_add(GTK_CONTAINER(sep->align), sep->vsep); - gtk_widget_show(sep->vsep); + gtk_container_add (GTK_CONTAINER (sep->align), sep->vsep); + gtk_widget_show (sep->vsep); } else { - gtk_container_add(GTK_CONTAINER(sep->align), sep->hsep); - gtk_widget_show(sep->hsep); + gtk_container_add (GTK_CONTAINER (sep->align), sep->hsep); + gtk_widget_show (sep->hsep); } } @@ -109,22 +109,22 @@ separator_new (void) { t_separator *sep = g_new0 (t_separator, 1); - sep->box = gtk_event_box_new(); - gtk_widget_show(sep->box); - gtk_container_set_border_width(GTK_CONTAINER(sep->box), 3); - - sep->align = gtk_alignment_new(0.5, 0.5, 0.75, 0.75); - gtk_widget_show(sep->align); - gtk_container_add(GTK_CONTAINER(sep->box), sep->align); - - sep->hsep = gtk_hseparator_new(); - g_object_ref(sep->hsep); - gtk_object_sink(GTK_OBJECT(sep->hsep)); - - sep->vsep = gtk_vseparator_new(); - g_object_ref(sep->vsep); - gtk_object_sink(GTK_OBJECT(sep->vsep)); - + sep->box = gtk_event_box_new (); + gtk_widget_show (sep->box); + gtk_container_set_border_width (GTK_CONTAINER (sep->box), 3); + + sep->align = gtk_alignment_new (0.5, 0.5, 0.75, 0.75); + gtk_widget_show (sep->align); + gtk_container_add (GTK_CONTAINER (sep->box), sep->align); + + sep->hsep = gtk_hseparator_new (); + g_object_ref (sep->hsep); + gtk_object_sink (GTK_OBJECT (sep->hsep)); + + sep->vsep = gtk_vseparator_new (); + g_object_ref (sep->vsep); + gtk_object_sink (GTK_OBJECT (sep->vsep)); + return sep; } @@ -133,16 +133,16 @@ gboolean create_separator_control (Control * control) { t_separator *sep; - + sep = separator_new (); gtk_container_add (GTK_CONTAINER (control->base), sep->box); - gtk_widget_set_size_request(control->base, -1, -1); + gtk_widget_set_size_request (control->base, -1, -1); control->data = (gpointer) sep; control->with_popup = FALSE; - separator_set_orientation(control, settings.orientation); - + separator_set_orientation (control, settings.orientation); + return TRUE; } @@ -157,7 +157,7 @@ xfce_control_class_init (ControlClass * cc) cc->free = separator_free; cc->attach_callback = separator_attach_callback; - cc->set_size = separator_set_size; + cc->set_size = separator_set_size; cc->set_orientation = separator_set_orientation; } diff --git a/plugins/switcher/switcher.c b/plugins/switcher/switcher.c index 23565018..ba0f3a15 100644 --- a/plugins/switcher/switcher.c +++ b/plugins/switcher/switcher.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans(huysmans@users.sourceforge.net) + * Copyright 2002 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/plugins/systembuttons/systembuttons.c b/plugins/systembuttons/systembuttons.c index 94185690..a3f7319b 100644 --- a/plugins/systembuttons/systembuttons.c +++ b/plugins/systembuttons/systembuttons.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans(huysmans@users.sourceforge.net) + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -17,23 +17,53 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -/* systembuttons.c : xfce4 panel plugin that shows one or two - * 'system buttons'. These are the same buttons also present on - * both sides of the switcher plugin: - * lock, exit, setup and info. - */ - #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <libxfce4util/libxfce4util.h> #include <libxfcegui4/xfce_iconbutton.h> +#include <libxfcegui4/xfce-icontheme.h> #include <panel/mcs_client.h> #include <panel/plugins.h> #include <panel/xfce.h> + +/* icons * + * ----- */ + +enum +{ + MINILOCK_ICON, + MINIINFO_ICON, + MINIPALET_ICON, + MINIPOWER_ICON, + MINIBUTTONS +}; + +/* TODO: add kde names */ +static char *minibutton_names[][3] = { + {"xfce-system-lock", "gnome-lockscreen", NULL}, + {"xfce-system-info", "gnome-info", NULL}, + {"xfce-system-settings", "gnome-settings", NULL}, + {"xfce-system-exit", "gnome-logout", NULL}, +}; + +static GdkPixbuf * +get_minibutton_pixbuf (int id) +{ + GdkPixbuf *pb; + + pb = themed_pixbuf_from_name_list (minibutton_names[id], 16); + + if (!pb) + return get_pixbuf_by_id (UNKNOWN_ICON); + + return pb; +} + + /* callbacks */ static void mini_lock_cb (void) @@ -82,11 +112,11 @@ enum typedef struct { gboolean show_two; - int button_types[2]; /* 0, 1, 2 or 3 for lock, exit, setup and info */ + int button_types[2]; /* 0, 1, 2 or 3 for lock, exit, setup and info */ GtkWidget *box; GtkWidget *buttons[2]; - GList *callbacks; /* save callbacks for when we change buttons */ + GList *callbacks; /* save callbacks for when we change buttons */ int cb_ids[2]; } t_systembuttons; @@ -148,10 +178,10 @@ button_set_tip (GtkWidget * button, int type) /* creation and destruction */ static int -connect_callback(GtkWidget *button, int type) +connect_callback (GtkWidget * button, int type) { GCallback callback = NULL; - + switch (type) { case LOCK: @@ -167,12 +197,12 @@ connect_callback(GtkWidget *button, int type) callback = G_CALLBACK (mini_info_cb); break; } - + return g_signal_connect (button, "clicked", callback, NULL); } static void -create_systembutton (t_systembuttons *sb, int n, int type) +create_systembutton (t_systembuttons * sb, int n, int type) { GtkWidget *button; @@ -183,10 +213,10 @@ create_systembutton (t_systembuttons *sb, int n, int type) button_set_tip (button, type); button_update_image (button, type); - sb->cb_ids[n] = connect_callback(button, type); + sb->cb_ids[n] = connect_callback (button, type); sb->buttons[n] = button; - if (G_UNLIKELY (type == SETUP && disable_user_config)) + if (G_UNLIKELY (disable_user_config && type == SETUP)) gtk_widget_set_sensitive (button, FALSE); } @@ -199,11 +229,16 @@ systembuttons_change_type (t_systembuttons * sb, int n, int type) button = sb->buttons[n]; - g_signal_handler_disconnect(sb->buttons[n], sb->cb_ids[n]); + g_signal_handler_disconnect (sb->buttons[n], sb->cb_ids[n]); + + sb->cb_ids[n] = connect_callback (button, type); + button_set_tip (button, type); + button_update_image (button, type); - sb->cb_ids[n] = connect_callback(button, type); - button_set_tip(button, type); - button_update_image(button, type); + if (G_UNLIKELY (disable_user_config && type == SETUP)) + gtk_widget_set_sensitive (button, FALSE); + else + gtk_widget_set_sensitive (button, TRUE); } static void @@ -230,15 +265,15 @@ arrange_systembuttons (t_systembuttons * sb, int orientation) gtk_widget_show (sb->box); - gtk_widget_show(sb->buttons[0]); + gtk_widget_show (sb->buttons[0]); if (sb->show_two) - gtk_widget_show(sb->buttons[1]); + gtk_widget_show (sb->buttons[1]); else - gtk_widget_hide(sb->buttons[1]); - - gtk_box_pack_start(GTK_BOX(sb->box), sb->buttons[0], TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(sb->box), sb->buttons[1], TRUE, TRUE, 0); + gtk_widget_hide (sb->buttons[1]); + + gtk_box_pack_start (GTK_BOX (sb->box), sb->buttons[0], TRUE, TRUE, 0); + gtk_box_pack_start (GTK_BOX (sb->box), sb->buttons[1], TRUE, TRUE, 0); } static t_systembuttons * @@ -304,7 +339,7 @@ systembuttons_set_size (Control * control, int size) s = w = h = icon_size[size] + border_width; n = sb->show_two ? 2 : 1; - + if (settings.orientation == HORIZONTAL) { if (settings.size > SMALL) @@ -391,9 +426,9 @@ systembuttons_read_config (Control * control, xmlNodePtr node) gtk_widget_show (sb->buttons[1]); } } - + /* Try to resize the systembuttons to fit the user settings */ - systembuttons_set_size (control, settings.size); + systembuttons_set_size (control, settings.size); } static void @@ -458,7 +493,7 @@ buttons_changed (GtkOptionMenu * om, t_systembuttons_dialog * sbd) void systembuttons_create_options (Control * control, GtkContainer * container, - GtkWidget * done) + GtkWidget * done) { GtkWidget *vbox, *hbox, *label, *om = NULL; const char *names[4]; Binary files differdiff --git a/settings/xfce_settings.h b/settings/xfce_settings.h index c7cbd02c..9e412c8d 100644 --- a/settings/xfce_settings.h +++ b/settings/xfce_settings.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/settings/xfce_settings_dialog.c b/settings/xfce_settings_dialog.c index ebadb673..5ab32294 100644 --- a/settings/xfce_settings_dialog.c +++ b/settings/xfce_settings_dialog.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -44,9 +44,11 @@ #define BORDER 5 -enum { LEFT, RIGHT, TOP, BOTTOM }; +enum +{ LEFT, RIGHT, TOP, BOTTOM }; -enum { HORIZONTAL, VERTICAL }; +enum +{ HORIZONTAL, VERTICAL }; static McsManager *mcs_manager; @@ -81,9 +83,9 @@ static void size_menu_changed (GtkOptionMenu * menu) { int n = gtk_option_menu_get_history (menu); - + mcs_manager_set_int (mcs_manager, xfce_settings_names[XFCE_SIZE], - CHANNEL, n); + CHANNEL, n); mcs_manager_notify (mcs_manager, CHANNEL); } @@ -113,9 +115,9 @@ add_size_menu (GtkWidget * option_menu) gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); setting = mcs_manager_setting_lookup (mcs_manager, - xfce_settings_names[XFCE_SIZE], + xfce_settings_names[XFCE_SIZE], CHANNEL); - + if (setting) { gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), @@ -133,15 +135,15 @@ orientation_changed (GtkOptionMenu * menu) int n = gtk_option_menu_get_history (menu); int pos; McsSetting *setting; - - setting = + + setting = mcs_manager_setting_lookup (mcs_manager, "orientation", CHANNEL); - + if (!setting || n == setting->data.v_int) return; mcs_manager_set_int (mcs_manager, xfce_settings_names[XFCE_ORIENTATION], - CHANNEL, n); + CHANNEL, n); /* TODO: find out why this crashed the panel * the error is in libxfce4mcs * @@ -151,9 +153,9 @@ orientation_changed (GtkOptionMenu * menu) * g_usleep(10); */ - setting = + setting = mcs_manager_setting_lookup (mcs_manager, "popupposition", CHANNEL); - + if (!setting) return; @@ -195,15 +197,15 @@ add_orientation_menu (GtkWidget * option_menu) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - - setting = + + setting = mcs_manager_setting_lookup (mcs_manager, xfce_settings_names[XFCE_ORIENTATION], CHANNEL); - + if (setting) { - gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), + gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), setting->data.v_int); } @@ -216,9 +218,9 @@ static void popup_position_changed (GtkOptionMenu * menu) { int n = gtk_option_menu_get_history (menu); - + mcs_manager_set_int (mcs_manager, xfce_settings_names[XFCE_POPUPPOSITION], - CHANNEL, n); + CHANNEL, n); mcs_manager_notify (mcs_manager, CHANNEL); } @@ -246,15 +248,15 @@ add_popup_position_menu (GtkWidget * option_menu) gtk_menu_shell_append (GTK_MENU_SHELL (menu), item); gtk_option_menu_set_menu (GTK_OPTION_MENU (option_menu), menu); - - setting = + + setting = mcs_manager_setting_lookup (mcs_manager, xfce_settings_names[XFCE_POPUPPOSITION], CHANNEL); - + if (setting) { - gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), + gtk_option_menu_set_history (GTK_OPTION_MENU (option_menu), setting->data.v_int); } @@ -331,7 +333,7 @@ layer_changed (GtkToggleButton * tb) int layer = gtk_toggle_button_get_active (tb) ? 0 : 1; mcs_manager_set_int (mcs_manager, xfce_settings_names[XFCE_LAYER], - CHANNEL, layer); + CHANNEL, layer); mcs_manager_notify (mcs_manager, CHANNEL); } @@ -356,10 +358,10 @@ add_layer_box (GtkBox * box, GtkSizeGroup * sg) gtk_widget_show (cb); gtk_box_pack_start (GTK_BOX (hbox), cb, FALSE, FALSE, 0); - setting = mcs_manager_setting_lookup (mcs_manager, - xfce_settings_names[XFCE_LAYER], + setting = mcs_manager_setting_lookup (mcs_manager, + xfce_settings_names[XFCE_LAYER], CHANNEL); - + if (setting) { /* We no longer use layers, but make the panel a docktype window @@ -371,7 +373,7 @@ add_layer_box (GtkBox * box, GtkSizeGroup * sg) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cb), setting->data.v_int == 0); } - + g_signal_connect (cb, "toggled", G_CALLBACK (layer_changed), NULL); } @@ -384,12 +386,12 @@ autohide_changed (GtkToggleButton * tb) hide = gtk_toggle_button_get_active (tb) ? 1 : 0; mcs_manager_set_int (mcs_manager, xfce_settings_names[XFCE_AUTOHIDE], - CHANNEL, hide); + CHANNEL, hide); mcs_manager_notify (mcs_manager, CHANNEL); } static void -add_autohide_box (GtkBox *box, GtkSizeGroup *sg) +add_autohide_box (GtkBox * box, GtkSizeGroup * sg) { GtkWidget *hbox, *label, *check; McsSetting *setting; @@ -408,9 +410,9 @@ add_autohide_box (GtkBox *box, GtkSizeGroup *sg) gtk_box_pack_start (GTK_BOX (hbox), check, FALSE, FALSE, 0); setting = mcs_manager_setting_lookup (mcs_manager, - xfce_settings_names[XFCE_AUTOHIDE], + xfce_settings_names[XFCE_AUTOHIDE], CHANNEL); - + if (setting) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check), @@ -446,7 +448,7 @@ run_xfce_settings_dialog (McsPlugin * mp) is_running = TRUE; - xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); + xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); mcs_manager = mp->manager; diff --git a/settings/xfce_settings_dialog.h b/settings/xfce_settings_dialog.h index 299c4cee..f24f8a0d 100644 --- a/settings/xfce_settings_dialog.h +++ b/settings/xfce_settings_dialog.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by diff --git a/settings/xfce_settings_plugin.c b/settings/xfce_settings_plugin.c index 2f9bdc5f..fcfa54cb 100644 --- a/settings/xfce_settings_plugin.c +++ b/settings/xfce_settings_plugin.c @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002-2004 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,7 +57,7 @@ static void xfce_set_options (McsManager * sm); McsPluginInitResult mcs_plugin_init (McsPlugin * mp) { - xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); + xfce_textdomain (GETTEXT_PACKAGE, LOCALEDIR, "UTF-8"); mcs_manager = mp->manager; @@ -73,19 +73,18 @@ mcs_plugin_init (McsPlugin * mp) /* GMarkup parser for old style config file */ static void -old_xml_start_element (GMarkupParseContext *context, - const gchar *element_name, - const gchar **attribute_names, - const gchar **attribute_values, - gpointer user_data, - GError **error) +old_xml_start_element (GMarkupParseContext * context, + const gchar * element_name, + const gchar ** attribute_names, + const gchar ** attribute_values, + gpointer user_data, GError ** error) { int i, j; McsSetting opt; - + if (!STREQUAL (element_name, "Settings")) return; - + opt.channel_name = CHANNEL; opt.last_change_serial = 0; @@ -104,7 +103,7 @@ old_xml_start_element (GMarkupParseContext *context, if (!opt.name) continue; - + switch (i) { case XFCE_ORIENTATION: @@ -126,14 +125,14 @@ old_xml_start_element (GMarkupParseContext *context, opt.type = MCS_TYPE_INT; break; } - + if (opt.type == MCS_TYPE_INT) { opt.data.v_int = (int) strtol (attribute_values[j], NULL, 0); } else { - opt.data.v_string = (char*)attribute_values[j]; + opt.data.v_string = (char *) attribute_values[j]; } mcs_manager_set_setting (mcs_manager, &opt, CHANNEL); @@ -155,10 +154,10 @@ old_xml_read_options (const char *path) g_error_free (error); return; } - + parser = g_new0 (GMarkupParser, 1); parser->start_element = old_xml_start_element; - + context = g_markup_parse_context_new (parser, 0, NULL, NULL); if (!g_markup_parse_context_parse (context, contents, len, &error)) @@ -166,7 +165,7 @@ old_xml_read_options (const char *path) g_warning ("%s", error->message); g_error_free (error); } - + g_markup_parse_context_free (context); g_free (parser); } @@ -175,12 +174,12 @@ void xfce_write_options (McsManager * sm) { char *file, *dir; - + /* this initializes base directory, but not settings dir */ dir = xfce_get_userfile ("settings", NULL); file = g_build_filename (dir, "panel.xml", NULL); - - if (!g_file_test (dir, G_FILE_TEST_IS_DIR) + + if (!g_file_test (dir, G_FILE_TEST_IS_DIR) && mkdir (dir, S_IRUSR | S_IWUSR | S_IXUSR) < 0) { g_critical ("Couldn't create directory %s", dir); @@ -202,7 +201,7 @@ xfce_init_options (void) int i; McsSetting opt; McsSetting *setting; - + opt.channel_name = CHANNEL; opt.last_change_serial = 0; @@ -211,10 +210,10 @@ xfce_init_options (void) opt.name = xfce_settings_names[i]; setting = mcs_manager_setting_lookup (mcs_manager, opt.name, CHANNEL); - + if (setting) continue; - + switch (i) { case XFCE_ORIENTATION: @@ -242,7 +241,7 @@ xfce_init_options (void) opt.data.v_int = 0; break; } - + mcs_manager_set_setting (mcs_manager, &opt, CHANNEL); } } @@ -254,11 +253,11 @@ xfce_set_options (McsManager * sm) gboolean found = FALSE; file = xfce_get_userfile ("settings", "panel.xml", NULL); - + if (g_file_test (file, G_FILE_TEST_EXISTS)) { - mcs_manager_add_channel_from_file(sm, CHANNEL, file); - + mcs_manager_add_channel_from_file (sm, CHANNEL, file); + found = TRUE; } else @@ -273,7 +272,7 @@ xfce_set_options (McsManager * sm) mcs_manager_add_channel (sm, CHANNEL); DBG ("reading old style options"); - + old_xml_read_options (file); found = TRUE; @@ -287,16 +286,16 @@ xfce_set_options (McsManager * sm) if (!found && g_file_test (file, G_FILE_TEST_EXISTS)) { - mcs_manager_add_channel_from_file(sm, CHANNEL, file); - + mcs_manager_add_channel_from_file (sm, CHANNEL, file); + found = TRUE; } - + g_free (file); /* set values if not already set */ xfce_init_options (); - + mcs_manager_notify (sm, CHANNEL); xfce_write_options (sm); } diff --git a/settings/xfce_settings_plugin.h b/settings/xfce_settings_plugin.h index f5d3a5bd..1eb965c6 100644 --- a/settings/xfce_settings_plugin.h +++ b/settings/xfce_settings_plugin.h @@ -1,6 +1,6 @@ -/* xfce4 +/* $Id$ * - * Copyright (C) 2002 Jasper Huijsmans <huysmans@users.sourceforge.net> + * Copyright 2002 Jasper Huijsmans (jasper@xfce.org) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by |