aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2001-07-01 14:14:59 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2001-07-01 14:14:59 +0800
commit3950295c0f8adbf2003eb84322fa6e7c8ba6af47 (patch)
treef5095d400302809537b08cfe658ce5bf44511195
parentd1706596df85327b41dd4b4fe39dd88f4a954dae (diff)
downloadgsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar.gz
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar.bz2
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar.lz
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar.xz
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.tar.zst
gsoc2013-evolution-3950295c0f8adbf2003eb84322fa6e7c8ba6af47.zip
Implemented a "Rename Shortcut" command.
svn path=/trunk/; revision=10651
-rw-r--r--shell/ChangeLog11
-rw-r--r--shell/e-shortcuts-view.c44
-rw-r--r--shell/e-shortcuts.c64
3 files changed, 88 insertions, 31 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 69f46445e1..bf1fa018c3 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,16 @@
2001-07-01 Ettore Perazzoli <ettore@ximian.com>
+ * e-shortcuts-view.c: Added a "Rename" right-click command.
+ (rename_shortcut_cb): New function, implementation for the "Rename
+ command".
+ (rename_shortcut_dialog_cb): Callback for the gnome_request_dialog
+ function to ask the new name.
+
+ * e-shortcuts.c (e_shortcuts_update_shortcut): Call `make_dirty()'
+ so we get saved too.
+
+2001-07-01 Ettore Perazzoli <ettore@ximian.com>
+
* e-shell-view.c (activate_shortcut_cb): Receive an @in_new_window
arg as well.
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
index 76939f1941..4009e7e5a8 100644
--- a/shell/e-shortcuts-view.c
+++ b/shell/e-shortcuts-view.c
@@ -40,6 +40,8 @@
#include <libgnomeui/gnome-uidefs.h>
#include <gal/util/e-util.h>
+#include "e-util/e-request.h"
+
#include "e-shortcuts-view-model.h"
#include "e-shortcuts-view.h"
@@ -336,7 +338,7 @@ pop_up_right_click_menu_for_group (EShortcutsView *shortcuts_view,
}
-/* Shortcut right-click menu. */
+/* Data to be passed around for the shortcut right-click menu items. */
struct _ShortcutRightClickMenuData {
EShortcutsView *shortcuts_view;
@@ -345,6 +347,9 @@ struct _ShortcutRightClickMenuData {
};
typedef struct _ShortcutRightClickMenuData ShortcutRightClickMenuData;
+
+/* "Open Shortcut" and "Open Shortcut in New Window" commands. */
+
static void
open_shortcut_helper (ShortcutRightClickMenuData *menu_data,
gboolean in_new_window)
@@ -375,9 +380,10 @@ static void
open_shortcut_in_new_window_cb (GtkWidget *widget,
void *data)
{
- open_shortcut_helper ((ShortcutRightClickMenuData *) data, TRUE);
+
}
+
static void
remove_shortcut_cb (GtkWidget *widget,
void *data)
@@ -393,12 +399,46 @@ remove_shortcut_cb (GtkWidget *widget,
e_shortcuts_remove_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
}
+
+/* "Rename Shortcut" command. */
+
+static void
+rename_shortcut_cb (GtkWidget *widget,
+ void *data)
+{
+ ShortcutRightClickMenuData *menu_data;
+ EShortcutsView *shortcuts_view;
+ EShortcuts *shortcuts;
+ const EShortcutItem *shortcut_item;
+ char *new_name;
+
+ menu_data = (ShortcutRightClickMenuData *) data;
+ shortcuts_view = menu_data->shortcuts_view;
+ shortcuts = shortcuts_view->priv->shortcuts;
+
+ shortcut_item = e_shortcuts_get_shortcut (shortcuts, menu_data->group_num, menu_data->item_num);
+
+ new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+ _("Rename shortcut"),
+ _("Rename selected shortcut to:"),
+ shortcut_item->name);
+
+ if (new_name == NULL)
+ return;
+
+ e_shortcuts_update_shortcut (shortcuts, menu_data->group_num, menu_data->item_num,
+ shortcut_item->uri, new_name, shortcut_item->type);
+ g_free (new_name);
+}
+
static GnomeUIInfo shortcut_right_click_menu_uiinfo[] = {
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_("Rename"), N_("Rename this shortcut"),
+ rename_shortcut_cb, NULL),
GNOMEUIINFO_ITEM_STOCK (N_("Remove"), N_("Remove this shortcut from the shortcut bar"),
remove_shortcut_cb, GNOME_STOCK_MENU_CLOSE),
GNOMEUIINFO_END
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 60453eae4b..1dff42e6f7 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -119,6 +119,9 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+static void make_dirty (EShortcuts *shortcuts);
+
+
static EShortcutItem *
shortcut_item_new (const char *uri,
const char *name,
@@ -360,6 +363,7 @@ load_shortcuts (EShortcuts *shortcuts,
/* 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. */
+ /* FIXME: Obviously, this sucks. */
make_dirty (shortcuts);
return TRUE;
@@ -412,35 +416,6 @@ save_shortcuts (EShortcuts *shortcuts,
return TRUE;
}
-
-static EShortcutItem *
-get_item (EShortcuts *shortcuts,
- int group_num,
- int num)
-{
- EShortcutsPrivate *priv;
- ShortcutGroup *group;
- GSList *group_element;
- GSList *shortcut_element;
-
- g_return_val_if_fail (shortcuts != NULL, NULL);
- g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
-
- priv = shortcuts->priv;
-
- group_element = g_slist_nth (priv->groups, group_num);
- if (group_element == NULL)
- return NULL;
-
- group = (ShortcutGroup *) group_element->data;
-
- shortcut_element = g_slist_nth (group->shortcuts, num);
- if (shortcut_element == NULL)
- return NULL;
-
- return (EShortcutItem *) shortcut_element->data;
-}
-
/* Idle function to update the file on disk. */
@@ -533,6 +508,35 @@ update_shortcuts_by_path (EShortcuts *shortcuts,
}
+static EShortcutItem *
+get_item (EShortcuts *shortcuts,
+ int group_num,
+ int num)
+{
+ EShortcutsPrivate *priv;
+ ShortcutGroup *group;
+ GSList *group_element;
+ GSList *shortcut_element;
+
+ g_return_val_if_fail (shortcuts != NULL, NULL);
+ g_return_val_if_fail (E_IS_SHORTCUTS (shortcuts), NULL);
+
+ priv = shortcuts->priv;
+
+ group_element = g_slist_nth (priv->groups, group_num);
+ if (group_element == NULL)
+ return NULL;
+
+ group = (ShortcutGroup *) group_element->data;
+
+ shortcut_element = g_slist_nth (group->shortcuts, num);
+ if (shortcut_element == NULL)
+ return NULL;
+
+ return (EShortcutItem *) shortcut_element->data;
+}
+
+
/* Signal handlers for the views. */
static void
@@ -973,6 +977,8 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts,
shortcut_item = get_item (shortcuts, group_num, num);
update_shortcut_and_emit_signal (shortcuts, shortcut_item, group_num, num, uri, name, type);
+
+ make_dirty (shortcuts);
}