diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2001-07-01 13:11:43 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2001-07-01 13:11:43 +0800 |
commit | d801d2df671bea7e08711f0027fbf8f3dc873b01 (patch) | |
tree | 01fbaeffccb8f6167971b7cd90f5688254de21f8 | |
parent | a0afdf4f53224a55425a8826c0563faa510fa6c5 (diff) | |
download | gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar.gz gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar.bz2 gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar.lz gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar.xz gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.tar.zst gsoc2013-evolution-d801d2df671bea7e08711f0027fbf8f3dc873b01.zip |
Change the internal structure for shortucts, so that it contains a
type and a name too. The name will allow renaming shortcuts (thus
decoupling the name of the folder the shortcuts points to from the
name of the shortcut); the type member is used to cache the type of
the folder we point to so that we can still display the right icon
even if the folder is currently not in the storage (e.g. this happens
for IMAP folders when you haven't opened the corresponding IMAP node
yet).
I don't like the way this is designed at all (mainly, the
responsibility for saving the values should be moved elsewhere), but
I'll fix it later.
Also, I added an "Open in New Window" right-click menu item for
shortcuts.
svn path=/trunk/; revision=10649
-rw-r--r-- | shell/ChangeLog | 42 | ||||
-rw-r--r-- | shell/e-shell-view.c | 6 | ||||
-rw-r--r-- | shell/e-shortcuts-view.c | 37 | ||||
-rw-r--r-- | shell/e-shortcuts-view.h | 3 | ||||
-rw-r--r-- | shell/e-shortcuts.c | 190 |
5 files changed, 242 insertions, 36 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog index 803c0c7d39..69f46445e1 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,10 +1,28 @@ -2001-06-30 Federico Mena Quintero <federico@ximian.com> - - * e-storage-set-view.c (popup_folder_menu): Pass the event time to - gtk_menu_popup() so that we can release the button and have the - menu stay up. - -2001-06-29 Ettore Perazzoli <ettore@ximian.com> +2001-07-01 Ettore Perazzoli <ettore@ximian.com> + + * e-shell-view.c (activate_shortcut_cb): Receive an @in_new_window + arg as well. + + * e-shortcuts-view.c: Added a new "Open in New Window" right-click + menu item. Renamed "Activate" to "Open". + (class_init): Update the installation of the "activate_shortcut" + signal for the additional @in_new_window_arg. + (open_shortcut_helper): New helper function. + (open_shortcut_cb): Renamed from `open_shortcut_cb'. Changed to + use `open_shortcut_helper' + (open_shortcut_in_new_window_cb): New. + (item_selected): Pass %FALSE as the @in_new_window arg for + "activate_shortcut". + + * e-shortcuts.c (save_shortcuts): Set the "name" and "type" + properties for the <item> nodes too. + (load_shortcuts): Change `shortcut_group_title' to be an `xmlChar + (shortcut_set): New helper function. + (shortcut_update): New helper function. + (update_shortcut_and_emit_signal): New helper function. + (e_shortcuts_update_shortcut): Use it. + +2001-07-01 Ettore Perazzoli <ettore@ximian.com> This is a first shoot at making shortcuts renameable [#3719]; unfinished. Also, it causes the shortcut bar to stop displaying @@ -64,6 +82,12 @@ * e-shortcuts.h: New typedef EShortcutItem. +2001-06-30 Federico Mena Quintero <federico@ximian.com> + + * e-storage-set-view.c (popup_folder_menu): Pass the event time to + gtk_menu_popup() so that we can release the button and have the + menu stay up. + 2001-06-29 Christopher James Lahey <clahey@ximian.com> * e-shortcuts-view-model.c (load_all_shortcuts_into_model): @@ -106,8 +130,8 @@ different incarnations involving updates to an shortcut bar having shortcuts to non-existent folders. Also, this fixes #1643, shortcuts not visible until you enable an IMAP account, and #2436, - i.e. misbehavior of shortcut groups when IMAP or invalid shortcuts - are involved.] + misbehavior of shortcut groups when IMAP or invalid shortcuts are + involved.] * e-shortcuts-view-model.c (load_group_into_model): Add the shortcuts that point to folders that don't exist yet, too. diff --git a/shell/e-shell-view.c b/shell/e-shell-view.c index 2c3a493c7f..f7d40e5330 100644 --- a/shell/e-shell-view.c +++ b/shell/e-shell-view.c @@ -494,13 +494,17 @@ static void activate_shortcut_cb (EShortcutsView *shortcut_view, EShortcuts *shortcuts, const char *uri, + gboolean in_new_window, void *data) { EShellView *shell_view; shell_view = E_SHELL_VIEW (data); - e_shell_view_display_uri (shell_view, uri); + if (in_new_window) + e_shell_create_view (e_shell_view_get_shell (shell_view), uri); + else + e_shell_view_display_uri (shell_view, uri); } /* Callback when user chooses "Hide shortcut bar" via a right click */ diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index bfde8d02c4..76939f1941 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -346,15 +346,13 @@ struct _ShortcutRightClickMenuData { typedef struct _ShortcutRightClickMenuData ShortcutRightClickMenuData; static void -activate_shortcut_cb (GtkWidget *widget, - void *data) +open_shortcut_helper (ShortcutRightClickMenuData *menu_data, + gboolean in_new_window) { - ShortcutRightClickMenuData *menu_data; EShortcutsView *shortcuts_view; EShortcuts *shortcuts; const EShortcutItem *shortcut_item; - menu_data = (ShortcutRightClickMenuData *) data; shortcuts_view = menu_data->shortcuts_view; shortcuts = shortcuts_view->priv->shortcuts; @@ -363,7 +361,21 @@ activate_shortcut_cb (GtkWidget *widget, return; gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT], - shortcuts, shortcut_item->uri); + shortcuts, shortcut_item->uri, in_new_window); +} + +static void +open_shortcut_cb (GtkWidget *widget, + void *data) +{ + open_shortcut_helper ((ShortcutRightClickMenuData *) data, FALSE); +} + +static void +open_shortcut_in_new_window_cb (GtkWidget *widget, + void *data) +{ + open_shortcut_helper ((ShortcutRightClickMenuData *) data, TRUE); } static void @@ -382,8 +394,10 @@ remove_shortcut_cb (GtkWidget *widget, } static GnomeUIInfo shortcut_right_click_menu_uiinfo[] = { - GNOMEUIINFO_ITEM (N_("Activate"), N_("Activate this shortcut"), - activate_shortcut_cb, NULL), + GNOMEUIINFO_ITEM (N_("Open"), N_("Open the folder linked to this shortcut"), + open_shortcut_cb, NULL), + GNOMEUIINFO_ITEM (N_("Open in New Window"), N_("Open the folder linked to this shortcut in a new window"), + open_shortcut_in_new_window_cb, NULL), GNOMEUIINFO_SEPARATOR, GNOMEUIINFO_ITEM_STOCK (N_("Remove"), N_("Remove this shortcut from the shortcut bar"), remove_shortcut_cb, GNOME_STOCK_MENU_CLOSE), @@ -468,7 +482,7 @@ item_selected (EShortcutBar *shortcut_bar, return; gtk_signal_emit (GTK_OBJECT (shortcuts_view), signals[ACTIVATE_SHORTCUT], - shortcuts, shortcut_item->uri); + shortcuts, shortcut_item->uri, FALSE); } static void @@ -523,10 +537,11 @@ class_init (EShortcutsViewClass *klass) GTK_RUN_LAST | GTK_RUN_ACTION, object_class->type, GTK_SIGNAL_OFFSET (EShortcutsViewClass, activate_shortcut), - gtk_marshal_NONE__POINTER_POINTER, - GTK_TYPE_NONE, 2, + e_marshal_NONE__POINTER_POINTER_INT, + GTK_TYPE_NONE, 3, GTK_TYPE_POINTER, - GTK_TYPE_STRING); + GTK_TYPE_STRING, + GTK_TYPE_BOOL); signals[HIDE_REQUESTED] = gtk_signal_new ("hide_requested", diff --git a/shell/e-shortcuts-view.h b/shell/e-shortcuts-view.h index 26de749fb9..d98f0e68f6 100644 --- a/shell/e-shortcuts-view.h +++ b/shell/e-shortcuts-view.h @@ -56,7 +56,8 @@ struct _EShortcutsViewClass { void (* activate_shortcut) (EShortcutsView *view, EShortcuts *shortcuts, - const char *uri); + const char *uri, + gboolean in_new_window); void (* hide_requested) (EShortcutsView *view); }; diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 18d79b330f..60453eae4b 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -138,6 +138,31 @@ shortcut_item_new (const char *uri, } static void +shortcut_item_update (EShortcutItem *shortcut_item, + const char *uri, + const char *name, + const char *type) +{ + if (name == NULL) + name = g_basename (uri); + + if (shortcut_item->uri != uri) { + g_free (shortcut_item->uri); + shortcut_item->uri = g_strdup (uri); + } + + if (shortcut_item->name != name) { + g_free (shortcut_item->name); + shortcut_item->name = g_strdup (name); + } + + if (shortcut_item->type != type) { + g_free (shortcut_item->type); + shortcut_item->type = g_strdup (type); + } +} + +static void shortcut_item_free (EShortcutItem *shortcut_item) { g_free (shortcut_item->uri); @@ -177,6 +202,43 @@ shortcut_group_free (ShortcutGroup *group) /* Utility functions. */ static void +update_shortcut_and_emit_signal (EShortcuts *shortcuts, + EShortcutItem *shortcut_item, + int group_num, + int num, + const char *uri, + const char *name, + const char *type) +{ + shortcut_item_update (shortcut_item, uri, name, type); + gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num); +} + +static void +override_shortcut_name_and_type_from_storage_set (EShortcuts *shortcuts, + EShortcutItem *shortcut_item) +{ + EShortcutsPrivate *priv; + EFolder *folder; + + priv = shortcuts->priv; + + /* If it is not an evolution: link, there is not much we can do. */ + if (strncmp (shortcut_item->uri, E_SHELL_URI_PREFIX, E_SHELL_URI_PREFIX_LEN) != 0) + return; + + folder = e_storage_set_get_folder (priv->storage_set, + shortcut_item->uri + E_SHELL_URI_PREFIX_LEN); + if (folder == NULL) + return; + + shortcut_item_update (shortcut_item, + shortcut_item->uri, + NULL, + e_folder_get_type_string (folder)); +} + +static void unload_shortcuts (EShortcuts *shortcuts) { EShortcutsPrivate *priv; @@ -235,12 +297,12 @@ load_shortcuts (EShortcuts *shortcuts, for (p = root->childs; p != NULL; p = p->next) { ShortcutGroup *shortcut_group; - char *shortcut_group_title; + xmlChar *shortcut_group_title; if (strcmp ((char *) p->name, "group") != 0) continue; - shortcut_group_title = (char *) xmlGetProp (p, "title"); + shortcut_group_title = xmlGetProp (p, "title"); if (shortcut_group_title == NULL) continue; @@ -256,15 +318,34 @@ load_shortcuts (EShortcuts *shortcuts, xmlFree (shortcut_group_title); for (q = p->childs; q != NULL; q = q->next) { + EShortcutItem *shortcut_item; xmlChar *uri; + xmlChar *name; + xmlChar *type; if (strcmp ((char *) q->name, "item") != 0) continue; - uri = xmlNodeListGetString (doc, q->childs, 1); + uri = xmlNodeListGetString (doc, q->childs, 1); + name = xmlGetProp (q, "name"); + type = xmlGetProp (q, "type"); + + shortcut_item = shortcut_item_new (uri, name, type); + + /* The name and type are the ones we saved from the + last session. If the folder is in the storage, we + have to get the type and name from this storage. */ + override_shortcut_name_and_type_from_storage_set (shortcuts, shortcut_item); + shortcut_group->shortcuts = g_slist_prepend (shortcut_group->shortcuts, - shortcut_item_new (uri, NULL, NULL)); - xmlFree (uri); + shortcut_item); + + if (uri != NULL) + xmlFree (uri); + if (name != NULL) + xmlFree (name); + if (type != NULL) + xmlFree (type); } shortcut_group->shortcuts = g_slist_reverse (shortcut_group->shortcuts); @@ -276,6 +357,11 @@ load_shortcuts (EShortcuts *shortcuts, xmlFreeDoc (doc); + /* After loading, we always have to re-save ourselves as we have merged + the information we have with the information we got from the + StorageSet. */ + make_dirty (shortcuts); + return TRUE; } @@ -305,9 +391,15 @@ save_shortcuts (EShortcuts *shortcuts, for (q = group->shortcuts; q != NULL; q = q->next) { EShortcutItem *shortcut; + xmlNode *shortcut_node; shortcut = (EShortcutItem *) q->data; - xmlNewChild (group_node, NULL, (xmlChar *) "item", (xmlChar *) shortcut->uri); + shortcut_node = xmlNewChild (group_node, NULL, (xmlChar *) "item", (xmlChar *) shortcut->uri); + + if (shortcut->name != NULL) + xmlSetProp (shortcut_node, (xmlChar *) "name", shortcut->name); + if (shortcut->type != NULL) + xmlSetProp (shortcut_node, (xmlChar *) "type", shortcut->type); } } @@ -384,7 +476,7 @@ schedule_idle (EShortcuts *shortcuts) if (priv->save_idle_id != 0) return; - gtk_idle_add (idle_cb, shortcuts); + priv->save_idle_id = gtk_idle_add (idle_cb, shortcuts); } static void @@ -398,6 +490,48 @@ make_dirty (EShortcuts *shortcuts) schedule_idle (shortcuts); } +static void +update_shortcuts_by_path (EShortcuts *shortcuts, + const char *path) +{ + EShortcutsPrivate *priv; + EFolder *folder; + const GSList *p, *q; + char *evolution_uri; + int group_num, num; + + priv = shortcuts->priv; + folder = e_storage_set_get_folder (priv->storage_set, path); + + evolution_uri = g_strconcat (E_SHELL_URI_PREFIX, path, NULL); + + group_num = 0; + for (p = priv->groups; p != NULL; p = p->next, group_num++) { + ShortcutGroup *group; + + group = (ShortcutGroup *) p->data; + num = 0; + for (q = group->shortcuts; q != NULL; q = q->next, num++) { + EShortcutItem *shortcut_item; + + shortcut_item = (EShortcutItem *) q->data; + + if (strcmp (shortcut_item->uri, evolution_uri) == 0) + update_shortcut_and_emit_signal (shortcuts, + shortcut_item, + group_num, + num, + evolution_uri, + NULL, + e_folder_get_type_string (folder)); + } + } + + g_free (evolution_uri); + + make_dirty (shortcuts); +} + /* Signal handlers for the views. */ @@ -415,6 +549,35 @@ view_destroyed_cb (GtkObject *object, } +/* Signal handlers for the EStorageSet. */ + +static void +storage_set_new_folder_callback (EStorageSet *storage_set, + const char *path, + void *data) +{ + EShortcuts *shortcuts; + + shortcuts = E_SHORTCUTS (data); + + update_shortcuts_by_path (shortcuts, path); + make_dirty (shortcuts); +} + +static void +storage_set_updated_folder_callback (EStorageSet *storage_set, + const char *path, + void *data) +{ + EShortcuts *shortcuts; + + shortcuts = E_SHORTCUTS (data); + + update_shortcuts_by_path (shortcuts, path); + make_dirty (shortcuts); +} + + /* GtkObject methods. */ static void @@ -547,10 +710,14 @@ e_shortcuts_construct (EShortcuts *shortcuts, priv = shortcuts->priv; - /* FIXME: Get rid of the storage set, we dont' need it here. */ gtk_object_ref (GTK_OBJECT (storage_set)); priv->storage_set = storage_set; + gtk_signal_connect (GTK_OBJECT (storage_set), "new_folder", + GTK_SIGNAL_FUNC (storage_set_new_folder_callback), shortcuts); + gtk_signal_connect (GTK_OBJECT (storage_set), "updated_folder", + GTK_SIGNAL_FUNC (storage_set_updated_folder_callback), shortcuts); + gtk_object_ref (GTK_OBJECT (folder_type_registry)); priv->folder_type_registry = folder_type_registry; } @@ -804,13 +971,8 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts, g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); shortcut_item = get_item (shortcuts, group_num, num); - g_free (shortcut_item->uri); - shortcut_item->uri = g_strdup (uri); - shortcut_item->name = g_strdup (name); - shortcut_item->type = g_strdup (type); - - gtk_signal_emit (GTK_OBJECT (shortcuts), signals[UPDATE_SHORTCUT], group_num, num); + update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, uri, name, type); } |