diff options
Diffstat (limited to 'shell')
-rw-r--r-- | shell/ChangeLog | 28 | ||||
-rw-r--r-- | shell/e-shell-view.c | 13 | ||||
-rw-r--r-- | shell/e-shortcuts-view.c | 49 | ||||
-rw-r--r-- | shell/e-shortcuts-view.h | 4 | ||||
-rw-r--r-- | shell/e-shortcuts.c | 81 | ||||
-rw-r--r-- | shell/e-shortcuts.h | 22 |
6 files changed, 164 insertions, 33 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 2a7e916a78..c6bd64ae58 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,5 +1,33 @@ 2002-07-08 Ettore Perazzoli <ettore@ximian.com> + * e-shortcuts-view.c (toggle_large_icons_cb): Change the group + icon size using e_shortcuts_set_group_uses_small_icons() instead + of changing it on the widget directly. + (toggle_small_icons_cb): Likewise. + (group_change_icon_size_callback): New, callback for the + "group_change_icon_size" signal on the EShortcuts object. + (e_shortcuts_view_construct): Connect. Also, initialize the icon + sizes in the icon bars from the EShortcuts object. + + * e-shell-view.c (e_shell_view_load_settings): Don't set the + shortcut group icon modes here anymore. + + * e-shortcuts.c: New member use_small_icons in struct + ShortcutGroup. + (shortcut_group_new): Init to FALSE. + (e_shortcuts_set_group_uses_small_icons): New. + (e_shortcuts_get_group_uses_small_icons): New. + (class_init): Install "group_change_icon_size" signal. + (save_shortcuts): Save the icon size per-group + here, i.e. <group title="foo" icon_size="small">. + (load_shortcuts): Set the icon size from the group's definition + here. + + * e-shortcuts.h: New signal "group_change_icon_size" in + EShortcutsClass. + +2002-07-08 Ettore Perazzoli <ettore@ximian.com> + * e-folder.c (safe_corba_string_dup): New helper function. (e_folder_to_corba): Use it here. diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 2b706028c1..3cd04a983e 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -2678,7 +2678,7 @@ e_shell_view_load_settings (EShellView *shell_view, Bonobo_ConfigDatabase db; EShellViewPrivate *priv; EShortcutBar *shortcut_bar; - int num_groups, group, val; + int num_groups, val; long width, height; char *stringval, *prefix, *filename, *key; CORBA_Environment ev; @@ -2754,17 +2754,6 @@ e_shell_view_load_settings (EShellView *shell_view, num_groups = e_shortcut_model_get_num_groups (shortcut_bar->model); - for (group = 0; group < num_groups; group++) { - int iconmode; - - key = g_strdup_printf ("%sShortcutBarGroup%dIconMode", prefix, - group); - iconmode = bonobo_config_get_long (db, key, NULL); - g_free (key); - - e_shortcut_bar_set_view_type (shortcut_bar, group, iconmode); - } - g_free (prefix); /* Load the expanded state for the ShellView's StorageSetView */ diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index fea3182dd9..670bae4468 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -65,6 +65,8 @@ enum { static guint signals[LAST_SIGNAL] = { 0 }; +/* Utility functions. */ + static void show_new_group_dialog (EShortcutsView *view) { @@ -106,9 +108,7 @@ toggle_large_icons_cb (GtkWidget *widget, if (! GTK_CHECK_MENU_ITEM (widget)->active) return; - e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), - menu_data->group_num, - E_ICON_BAR_LARGE_ICONS); + e_shortcuts_set_group_uses_small_icons (menu_data->shortcuts_view->priv->shortcuts, menu_data->group_num, FALSE); } static void @@ -124,9 +124,7 @@ toggle_small_icons_cb (GtkWidget *widget, if (! GTK_CHECK_MENU_ITEM (widget)->active) return; - e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), - menu_data->group_num, - E_ICON_BAR_SMALL_ICONS); + e_shortcuts_set_group_uses_small_icons (menu_data->shortcuts_view->priv->shortcuts, menu_data->group_num, TRUE); } static void @@ -218,14 +216,12 @@ rename_group_cb (GtkWidget *widget, to an actual ShortcutBar bug. */ group = e_group_bar_get_current_group_num (E_GROUP_BAR (E_SHORTCUT_BAR (shortcuts_view))); - original_view_type = e_shortcut_bar_get_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), - group); + original_view_type = e_shortcut_bar_get_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), group); e_shortcuts_rename_group (shortcuts, menu_data->group_num, new_name); g_free (new_name); e_group_bar_set_current_group_num (E_GROUP_BAR (E_SHORTCUT_BAR (shortcuts_view)), group, FALSE); - e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), - group, original_view_type); + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), group, original_view_type); } static GnomeUIInfo icon_size_radio_group_uiinfo[] = { @@ -424,6 +420,26 @@ pop_up_right_click_menu_for_shortcut (EShortcutsView *shortcuts_view, } +/* View callbacks. This part exists mostly because of breakage in the + EShortcutBar design. */ + +static void +group_change_icon_size_callback (EShortcuts *shortucts, + int group_num, + gboolean use_small_icons, + void *data) +{ + EShortcutsView *view; + + view = E_SHORTCUTS_VIEW (data); + + if (use_small_icons) + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (view), group_num, E_ICON_BAR_SMALL_ICONS); + else + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (view), group_num, E_ICON_BAR_LARGE_ICONS); +} + + /* GtkObject methods. */ static void @@ -685,6 +701,7 @@ e_shortcuts_view_construct (EShortcutsView *shortcuts_view, EShortcuts *shortcuts) { EShortcutsViewPrivate *priv; + int i, num_groups; g_return_if_fail (shortcuts != NULL); g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); @@ -696,6 +713,18 @@ e_shortcuts_view_construct (EShortcutsView *shortcuts_view, e_shortcut_bar_set_model (E_SHORTCUT_BAR (shortcuts_view), E_SHORTCUT_MODEL (e_shortcuts_view_model_new (shortcuts))); + + gtk_signal_connect_while_alive (GTK_OBJECT (shortcuts), "group_change_icon_size", + GTK_SIGNAL_FUNC (group_change_icon_size_callback), + shortcuts_view, GTK_OBJECT (shortcuts_view)); + + num_groups = e_shortcuts_get_num_groups (shortcuts); + for (i = 0; i < num_groups; i ++) { + if (e_shortcuts_get_group_uses_small_icons (shortcuts, i)) + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (shortcuts_view), i, E_ICON_BAR_SMALL_ICONS); + else + e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (shortcuts_view), i, E_ICON_BAR_LARGE_ICONS); + } } GtkWidget * diff --git a/shell/e-shortcuts-view.h b/shell/e-shortcuts-view.h index 531718283a..e905fabdc8 100644 --- a/shell/e-shortcuts-view.h +++ b/shell/e-shortcuts-view.h @@ -36,8 +36,8 @@ extern "C" { #define E_TYPE_SHORTCUTS_VIEW (e_shortcuts_view_get_type ()) #define E_SHORTCUTS_VIEW(obj) (GTK_CHECK_CAST ((obj), E_TYPE_SHORTCUTS_VIEW, EShortcutsView)) #define E_SHORTCUTS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_TYPE_SHORTCUTS_VIEW, EShortcutsViewClass)) -#define E_IS_SHORTCUTS_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW)) -#define E_IS_SHORTCUTS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW)) +#define E_IS_SHORTCUTS_VIEW(obj) (GTK_CHECK_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW)) +#define E_IS_SHORTCUTS_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_TYPE_SHORTCUTS_VIEW)) typedef struct _EShortcutsView EShortcutsView; diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index fffedfbaf3..e253764571 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -76,6 +76,9 @@ struct _ShortcutGroup { /* A list of shortcuts. */ GSList *shortcuts; + + /* Whether to use small icons for this group. */ + unsigned int use_small_icons : 1; }; typedef struct _ShortcutGroup ShortcutGroup; @@ -111,6 +114,7 @@ enum { NEW_GROUP, REMOVE_GROUP, RENAME_GROUP, + GROUP_CHANGE_ICON_SIZE, NEW_SHORTCUT, REMOVE_SHORTCUT, UPDATE_SHORTCUT, @@ -200,8 +204,9 @@ shortcut_group_new (const char *title) ShortcutGroup *new; new = g_new (ShortcutGroup, 1); - new->title = g_strdup (title); - new->shortcuts = NULL; + new->title = g_strdup (title); + new->shortcuts = NULL; + new->use_small_icons = FALSE; return new; } @@ -307,6 +312,7 @@ load_shortcuts (EShortcuts *shortcuts, for (p = root->childs; p != NULL; p = p->next) { ShortcutGroup *shortcut_group; xmlChar *shortcut_group_title; + xmlChar *icon_size; if (strcmp ((char *) p->name, "group") != 0) continue; @@ -318,6 +324,13 @@ load_shortcuts (EShortcuts *shortcuts, shortcut_group = shortcut_group_new (shortcut_group_title); xmlFree (shortcut_group_title); + icon_size = xmlGetProp (p, "icon_size"); + if (icon_size != NULL && strcmp (icon_size, "small") == 0) + shortcut_group->use_small_icons = TRUE; + else + shortcut_group->use_small_icons = FALSE; + xmlFree (icon_size); + for (q = p->childs; q != NULL; q = q->next) { EShortcutItem *shortcut_item; xmlChar *uri; @@ -399,6 +412,11 @@ save_shortcuts (EShortcuts *shortcuts, xmlSetProp (group_node, (xmlChar *) "title", group->title); + if (group->use_small_icons) + xmlSetProp (group_node, (xmlChar *) "icon_size", "small"); + else + xmlSetProp (group_node, (xmlChar *) "icon_size", "large"); + for (q = group->shortcuts; q != NULL; q = q->next) { EShortcutItem *shortcut; xmlNode *shortcut_node; @@ -663,6 +681,16 @@ class_init (EShortcutsClass *klass) GTK_TYPE_INT, GTK_TYPE_STRING); + signals[GROUP_CHANGE_ICON_SIZE] + = gtk_signal_new ("group_change_icon_size", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutsClass, group_change_icon_size), + gtk_marshal_NONE__INT_INT, + GTK_TYPE_NONE, 2, + GTK_TYPE_INT, + GTK_TYPE_INT); + signals[NEW_SHORTCUT] = gtk_signal_new ("new_shortcut", GTK_RUN_FIRST, @@ -1147,5 +1175,54 @@ e_shortcuts_get_group_title (EShortcuts *shortcuts, return group->title; } +void +e_shortcuts_set_group_uses_small_icons (EShortcuts *shortcuts, + int group_num, + gboolean use_small_icons) +{ + EShortcutsPrivate *priv; + ShortcutGroup *group; + GSList *group_element; + + g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); + + priv = shortcuts->priv; + + group_element = g_slist_nth (priv->groups, group_num); + if (group_element == NULL) + return; + + group = (ShortcutGroup *) group_element->data; + + use_small_icons = !! use_small_icons; + if (group->use_small_icons != use_small_icons) { + group->use_small_icons = use_small_icons; + gtk_signal_emit (GTK_OBJECT (shortcuts), signals[GROUP_CHANGE_ICON_SIZE], + group_num, use_small_icons); + + make_dirty (shortcuts); + } +} + +gboolean +e_shortcuts_get_group_uses_small_icons (EShortcuts *shortcuts, + int group_num) +{ + EShortcutsPrivate *priv; + ShortcutGroup *group; + GSList *group_element; + + g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), FALSE); + + priv = shortcuts->priv; + + group_element = g_slist_nth (priv->groups, group_num); + if (group_element == NULL) + return FALSE; + + group = (ShortcutGroup *) group_element->data; + return group->use_small_icons; +} + E_MAKE_TYPE (e_shortcuts, "EShortcuts", EShortcuts, class_init, init, PARENT_TYPE) diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h index 3b93d5c032..a50e726a4a 100644 --- a/shell/e-shortcuts.h +++ b/shell/e-shortcuts.h @@ -71,13 +71,15 @@ struct _EShortcutsClass { /* Signals. */ - void (* new_group) (EShortcuts *shortcuts, int group_num); - void (* remove_group) (EShortcuts *shortcuts, int group_num); - void (* rename_group) (EShortcuts *shortcuts, int group_num, const char *new_title); + void (* new_group) (EShortcuts *shortcuts, int group_num); + void (* remove_group) (EShortcuts *shortcuts, int group_num); + void (* rename_group) (EShortcuts *shortcuts, int group_num, const char *new_title); - void (* new_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); - void (* remove_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); - void (* update_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); + void (* group_change_icon_size) (EShortcuts *shortcuts, int group_num, gboolean use_small_icons); + + void (* new_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); + void (* remove_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); + void (* update_shortcut) (EShortcuts *shortcuts, int group_num, int item_num); }; @@ -136,9 +138,15 @@ void e_shortcuts_add_group (EShortcuts *shortcuts, int group_num, const char *group_title); void e_shortcuts_rename_group (EShortcuts *shortcuts, - int group_name, + int group_num, const char *new_title); +void e_shortcuts_set_group_uses_small_icons (EShortcuts *shortcuts, + int group_num, + gboolean use_small_icons); +gboolean e_shortcuts_get_group_uses_small_icons (EShortcuts *shortcuts, + int group_num); + #ifdef __cplusplus } #endif /* __cplusplus */ |