aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shortcuts-view.c
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-09-26 03:11:15 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-09-26 03:11:15 +0800
commita75e971a552b0e4138ce901fd33d50d45319c919 (patch)
tree85d6d9350bc2eb1d1495343051b463f93290020b /shell/e-shortcuts-view.c
parent72fff3213ae1221b3c13841cb43df39f963efb1f (diff)
downloadgsoc2013-evolution-a75e971a552b0e4138ce901fd33d50d45319c919.tar.gz
gsoc2013-evolution-a75e971a552b0e4138ce901fd33d50d45319c919.tar.zst
gsoc2013-evolution-a75e971a552b0e4138ce901fd33d50d45319c919.zip
Update the shortcut bar in the shell view to match the changes in the
way drag and drop is handled. Separate the handling for the view into a separate object. This should make the shortcut bar work again, but it's untested. svn path=/trunk/; revision=5575
Diffstat (limited to 'shell/e-shortcuts-view.c')
-rw-r--r--shell/e-shortcuts-view.c184
1 files changed, 26 insertions, 158 deletions
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
index 7a9b75a86a..014be21beb 100644
--- a/shell/e-shortcuts-view.c
+++ b/shell/e-shortcuts-view.c
@@ -29,6 +29,8 @@
#include <gal/util/e-util.h>
+#include "e-shortcuts-view-model.h"
+
#include "e-shortcuts-view.h"
@@ -47,7 +49,7 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
-/* View initialization. */
+/* FIXME this should all be in the model. */
static const char *
get_storage_set_path_from_uri (const char *uri)
@@ -70,80 +72,6 @@ get_storage_set_path_from_uri (const char *uri)
return colon + 1;
}
-static void
-load_group (EShortcutsView *shortcuts_view,
- EShortcuts *shortcuts,
- const char *group_title,
- int group_num)
-{
- EShortcutsViewPrivate *priv;
- EStorageSet *storage_set;
- GList *shortcut_list;
- GList *p;
-
- priv = shortcuts_view->priv;
-
- storage_set = e_shortcuts_get_storage_set (shortcuts);
- g_assert (storage_set != NULL);
-
- shortcut_list = e_shortcuts_get_shortcuts_in_group (shortcuts, group_title);
- if (shortcut_list == NULL)
- return;
-
- for (p = shortcut_list; p != NULL; p = p->next) {
- EFolder *folder;
- const char *path;
- const char *uri;
- const char *name;
-
- uri = (const char *) p->data;
- path = get_storage_set_path_from_uri (uri);
- if (path != NULL)
- folder = e_storage_set_get_folder (storage_set, path);
-
- if (path == NULL || folder == NULL) {
- /* FIXME */
- g_warning ("Invalid link while loading shortcut bar view -- %s\n",
- uri);
- continue;
- }
-
- name = e_folder_get_name (folder);
- e_shortcut_model_add_item (E_SHORTCUT_BAR (shortcuts_view)->model, group_num, -1, uri, name);
- }
-
- e_free_string_list (shortcut_list);
-}
-
-static void
-load_all_shortcuts (EShortcutsView *shortcuts_view,
- EShortcuts *shortcuts)
-{
- EShortcutsViewPrivate *priv;
- GList *group_titles;
- GList *p;
- int group_num;
-
- priv = shortcuts_view->priv;
-
- group_titles = e_shortcuts_get_group_titles (shortcuts);
-
- for (p = group_titles; p != NULL; p = p->next) {
- const char *group_title;
-
- group_title = (const char *) p->data;
- group_num = e_shortcut_model_add_group (E_SHORTCUT_BAR (shortcuts_view)->model,
- -1, group_title);
-
- load_group (shortcuts_view, shortcuts, group_title, group_num);
- }
-
- e_free_string_list (group_titles);
-
- gtk_object_ref (GTK_OBJECT (shortcuts));
- priv->shortcuts = shortcuts;
-}
-
/* Icon callback for the shortcut bar. */
static GdkPixbuf *
icon_callback (EShortcutBar *shortcut_bar,
@@ -381,7 +309,7 @@ destroy (GtkObject *object)
/* EShortcutBar methods. */
static void
-selected_item (EShortcutBar *shortcut_bar,
+item_selected (EShortcutBar *shortcut_bar,
GdkEvent *event,
int group_num,
int item_num)
@@ -416,90 +344,35 @@ selected_item (EShortcutBar *shortcut_bar,
shortcuts, uri);
}
-#if 0
-static void
-added_item (EShortcutBar *shortcut_bar,
- int group_num,
- int item_num)
-{
- EShortcutsViewPrivate *priv;
- EShortcutBarGroup *group;
- EShortcuts *shortcuts;
- const char *url;
-
- priv = E_SHORTCUTS_VIEW (shortcut_bar)->priv;
- shortcuts = priv->shortcuts;
-
- if (shortcuts == NULL)
- return;
-
- /* FIXME ** NASTY ** */
-
- group = &g_array_index (shortcut_bar->groups, EShortcutBarGroup, group_num);
- url = e_icon_bar_get_item_data (E_ICON_BAR (group->icon_bar), item_num);
-
- if (url == NULL) {
- g_warning ("NULL URL being added to the shortcut bar!?");
- return;
- }
-
- e_shortcuts_add_shortcut (shortcuts, group_num, item_num, url);
-}
-
static void
-removed_item (EShortcutBar *shortcut_bar,
- int group_num,
- int item_num)
-{
- EShortcutsViewPrivate *priv;
- EShortcuts *shortcuts;
-
- priv = E_SHORTCUTS_VIEW (shortcut_bar)->priv;
- shortcuts = priv->shortcuts;
-
- e_shortcuts_remove_shortcut (shortcuts, group_num, item_num);
-}
-
-static void
-added_group (EShortcutBar *shortcut_bar,
- int group_num)
+impl_shortcut_dropped (EShortcutBar *shortcut_bar,
+ int group_num,
+ int position,
+ const char *item_url,
+ const char *item_name)
{
+ EShortcutsView *shortcuts_view;
EShortcutsViewPrivate *priv;
- EShortcuts *shortcuts;
- EShortcutBarGroup *group;
- const char *group_name;
- priv = E_SHORTCUTS_VIEW (shortcut_bar)->priv;
- shortcuts = priv->shortcuts;
-
- if (shortcuts == NULL)
- return;
-
- group = &g_array_index (shortcut_bar->groups, EShortcutBarGroup, group_num);
-
- /* FIXME Losing EShortcutBar does not give me a method to retrieve the
- group name. */
- group_name = "Foo";
+ shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
+ priv = shortcuts_view->priv;
- e_shortcuts_add_group (shortcuts, group_num, group_name);
+ e_shortcuts_add_shortcut (priv->shortcuts, group_num, position, item_url);
}
static void
-removed_group (EShortcutBar *shortcut_bar,
- int group_num)
+impl_shortcut_dragged (EShortcutBar *shortcut_bar,
+ gint group_num,
+ gint item_num)
{
+ EShortcutsView *shortcuts_view;
EShortcutsViewPrivate *priv;
- EShortcuts *shortcuts;
-
- priv = E_SHORTCUTS_VIEW (shortcut_bar)->priv;
- shortcuts = priv->shortcuts;
- if (shortcuts == NULL)
- return;
+ shortcuts_view = E_SHORTCUTS_VIEW (shortcut_bar);
+ priv = shortcuts_view->priv;
- e_shortcuts_remove_group (shortcuts, group_num);
+ e_shortcuts_remove_shortcut (priv->shortcuts, group_num, item_num);
}
-#endif
static void
@@ -512,13 +385,10 @@ class_init (EShortcutsViewClass *klass)
object_class->destroy = destroy;
shortcut_bar_class = E_SHORTCUT_BAR_CLASS (klass);
- shortcut_bar_class->selected_item = selected_item;
-#if 0
- shortcut_bar_class->added_item = added_item;
- shortcut_bar_class->removed_item = removed_item;
- shortcut_bar_class->added_group = added_group;
- shortcut_bar_class->removed_group = removed_group;
-#endif
+ shortcut_bar_class->item_selected = item_selected;
+ shortcut_bar_class->shortcut_dropped = impl_shortcut_dropped;
+ shortcut_bar_class->shortcut_dragged = impl_shortcut_dragged;
+
parent_class = gtk_type_class (e_shortcut_bar_get_type ());
signals[ACTIVATE_SHORTCUT] =
@@ -557,13 +427,11 @@ e_shortcuts_view_construct (EShortcutsView *shortcuts_view,
priv = shortcuts_view->priv;
- e_shortcut_bar_set_model (E_SHORTCUT_BAR (shortcuts_view),
- e_shortcut_model_new ());
-
e_shortcut_bar_set_icon_callback (E_SHORTCUT_BAR (shortcuts_view), icon_callback,
shortcuts);
- load_all_shortcuts (shortcuts_view, shortcuts);
+ e_shortcut_bar_set_model (E_SHORTCUT_BAR (shortcuts_view),
+ E_SHORTCUT_MODEL (e_shortcuts_view_model_new (shortcuts)));
}
GtkWidget *