From 8fc1cb82feb23034360af987834f6bce8aebe0f3 Mon Sep 17 00:00:00 2001 From: Ettore Perazzoli Date: Sun, 1 Jul 2001 07:12:56 +0000 Subject: Implemented a "Rename Group" command. Unfortunately, it doesn't work very well due to EShortcutBar breakage. But we'll fix that later. svn path=/trunk/; revision=10653 --- shell/ChangeLog | 6 ++++++ shell/e-shortcuts-view-model.c | 18 ++++++++++++++++++ shell/e-shortcuts-view.c | 28 ++++++++++++++++++++++++++++ shell/e-shortcuts.c | 39 +++++++++++++++++++++++++++++++++++++++ shell/e-shortcuts.h | 7 ++++++- 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/shell/ChangeLog b/shell/ChangeLog index 6cdc375c4a..bd19e4b9ae 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,9 @@ +2001-07-01 Ettore Perazzoli + + * e-shortcuts.c (class_init): Install signal "rename_group". + + * e-shortcuts.h: New signal "rename_group". + 2001-07-01 Ettore Perazzoli * e-shortcuts.c: Removed `title_to_group' hash from diff --git a/shell/e-shortcuts-view-model.c b/shell/e-shortcuts-view-model.c index 15e1d3cec1..57d2762fb9 100644 --- a/shell/e-shortcuts-view-model.c +++ b/shell/e-shortcuts-view-model.c @@ -125,6 +125,21 @@ shortcuts_remove_group_cb (EShortcuts *shortcuts, e_shortcut_model_remove_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num); } +static void +shortcuts_rename_group_cb (EShortcuts *shortcuts, + int group_num, + const char *new_title, + void *data) +{ + EShortcutsViewModel *shortcuts_view_model; + + shortcuts_view_model = E_SHORTCUTS_VIEW_MODEL (data); + + e_shortcut_model_remove_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num); + e_shortcut_model_add_group (E_SHORTCUT_MODEL (shortcuts_view_model), group_num, new_title); + load_group_into_model (shortcuts_view_model, group_num); +} + static void shortcuts_new_shortcut_cb (EShortcuts *shortcuts, int group_num, @@ -244,6 +259,9 @@ e_shortcuts_view_model_construct (EShortcutsViewModel *model, gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "remove_group", GTK_SIGNAL_FUNC (shortcuts_remove_group_cb), model, GTK_OBJECT (model)); + gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), + "rename_group", GTK_SIGNAL_FUNC (shortcuts_rename_group_cb), model, + GTK_OBJECT (model)); gtk_signal_connect_while_alive (GTK_OBJECT (priv->shortcuts), "new_shortcut", GTK_SIGNAL_FUNC (shortcuts_new_shortcut_cb), model, GTK_OBJECT (model)); diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c index 4009e7e5a8..de30fdba1c 100644 --- a/shell/e-shortcuts-view.c +++ b/shell/e-shortcuts-view.c @@ -274,6 +274,31 @@ destroy_group_cb (GtkWidget *widget, e_shortcuts_remove_group (shortcuts, menu_data->group_num); } +static void +rename_group_cb (GtkWidget *widget, + void *data) +{ + RightClickMenuData *menu_data; + EShortcuts *shortcuts; + const char *old_name; + const char *new_name; + + menu_data = (RightClickMenuData *) data; + shortcuts = menu_data->shortcuts_view->priv->shortcuts; + + old_name = e_shortcuts_get_group_title (shortcuts, menu_data->group_num); + + new_name = e_request_string (GTK_WINDOW (gtk_widget_get_toplevel (widget)), + _("Rename Shortcut Group"), + _("Rename selected shortcut group to:"), + old_name); + + if (new_name == NULL) + return; + + e_shortcuts_rename_group (shortcuts, menu_data->group_num, new_name); +} + static GnomeUIInfo icon_size_radio_group_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Small Icons"), N_("Show the shortcuts as small icons"), toggle_small_icons_cb, NULL, @@ -296,6 +321,9 @@ static GnomeUIInfo right_click_menu_uiinfo[] = { { GNOME_APP_UI_ITEM, N_("_Remove This Group..."), N_("Remove this shortcut group"), destroy_group_cb, NULL, NULL, 0, 0, 0, 0 }, + { GNOME_APP_UI_ITEM, N_("Re_name This Group..."), + N_("Rename this shortcut group"), rename_group_cb, NULL, + NULL, 0, 0, 0, 0 }, GNOMEUIINFO_SEPARATOR, diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c index 20d12cce2d..5f1614a964 100644 --- a/shell/e-shortcuts.c +++ b/shell/e-shortcuts.c @@ -107,6 +107,7 @@ struct _EShortcutsPrivate { enum { NEW_GROUP, REMOVE_GROUP, + RENAME_GROUP, NEW_SHORTCUT, REMOVE_SHORTCUT, UPDATE_SHORTCUT, @@ -627,6 +628,16 @@ class_init (EShortcutsClass *klass) GTK_TYPE_NONE, 1, GTK_TYPE_INT); + signals[RENAME_GROUP] + = gtk_signal_new ("rename_group", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (EShortcutsClass, rename_group), + gtk_marshal_NONE__INT_POINTER, + GTK_TYPE_NONE, 2, + GTK_TYPE_INT, + GTK_TYPE_STRING); + signals[NEW_SHORTCUT] = gtk_signal_new ("new_shortcut", GTK_RUN_FIRST, @@ -989,6 +1000,34 @@ e_shortcuts_remove_group (EShortcuts *shortcuts, make_dirty (shortcuts); } +void +e_shortcuts_rename_group (EShortcuts *shortcuts, + int group_num, + const char *new_title) +{ + EShortcutsPrivate *priv; + GSList *p; + ShortcutGroup *group; + + g_return_if_fail (shortcuts != NULL); + g_return_if_fail (E_IS_SHORTCUTS (shortcuts)); + + priv = shortcuts->priv; + + p = g_slist_nth (priv->groups, group_num); + g_return_if_fail (p != NULL); + + group = (ShortcutGroup *) p->data; + if (group->title != new_title) { + g_free (group->title); + group->title = g_strdup (new_title); + } + + gtk_signal_emit (GTK_OBJECT (shortcuts), signals[RENAME_GROUP], group_num, new_title); + + make_dirty (shortcuts); +} + void e_shortcuts_add_group (EShortcuts *shortcuts, int group_num, diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h index 8d08586c47..2a9836e2a0 100644 --- a/shell/e-shortcuts.h +++ b/shell/e-shortcuts.h @@ -65,6 +65,8 @@ struct _EShortcutsClass { 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); @@ -118,7 +120,10 @@ void e_shortcuts_remove_group (EShortcuts *shortcuts, int group_num); void e_shortcuts_add_group (EShortcuts *shortcuts, int group_num, - const char *group_name); + const char *group_title); +void e_shortcuts_rename_group (EShortcuts *shortcuts, + int group_name, + const char *new_title); #ifdef __cplusplus } -- cgit