From 6d778b9fa21e33d502a6b6c98639cb19dd8becfb Mon Sep 17 00:00:00 2001
From: Ettore Perazzoli <ettore@src.gnome.org>
Date: Wed, 31 Jul 2002 22:10:37 +0000
Subject: New, implement a right-click -> "Add Default Shortcuts" menu item.

* e-shortcuts-view.c (create_default_shortcuts_cb): New, implement
a right-click -> "Add Default Shortcuts" menu item.
(rename_group_cb): Remove double casts.  *lol*

* e-shortcuts.c (e_shortcuts_add_default_shortcuts): New.
(e_shortcuts_add_default_group): Use
e_shortcuts_add_default_shortcuts().

svn path=/trunk/; revision=17663
---
 shell/ChangeLog          | 10 ++++++++++
 shell/e-shortcuts-view.c | 23 +++++++++++++++++++++--
 shell/e-shortcuts.c      | 33 +++++++++++++++++++++------------
 shell/e-shortcuts.h      |  4 +++-
 4 files changed, 55 insertions(+), 15 deletions(-)

diff --git a/shell/ChangeLog b/shell/ChangeLog
index fa1a36bfcb..69ad01cb91 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,3 +1,13 @@
+2002-07-31  Ettore Perazzoli  <ettore@ximian.com>
+
+	* e-shortcuts-view.c (create_default_shortcuts_cb): New, implement
+	a right-click -> "Add Default Shortcuts" menu item.
+	(rename_group_cb): Remove double casts.  *lol*
+
+	* e-shortcuts.c (e_shortcuts_add_default_shortcuts): New.
+	(e_shortcuts_add_default_group): Use
+	e_shortcuts_add_default_shortcuts().
+
 2002-07-31  Ettore Perazzoli  <ettore@ximian.com>
 
 	* e-shell-user-creatable-items-handler.c (ensure_menu_items):
diff --git a/shell/e-shortcuts-view.c b/shell/e-shortcuts-view.c
index ab3841b3aa..50641c2f2f 100644
--- a/shell/e-shortcuts-view.c
+++ b/shell/e-shortcuts-view.c
@@ -215,15 +215,28 @@ rename_group_cb (GtkWidget *widget,
 	/* Remember the group and flip back to it.  FIXME: This is a workaround
 	   to an actual ShortcutBar bug.  */
 
-	group = e_group_bar_get_current_group_num (E_GROUP_BAR (E_SHORTCUT_BAR (shortcuts_view)));
+	group = e_group_bar_get_current_group_num (E_GROUP_BAR (shortcuts_view));
 	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_group_bar_set_current_group_num (E_GROUP_BAR (shortcuts_view), group, FALSE);
 	e_shortcut_bar_set_view_type (E_SHORTCUT_BAR (menu_data->shortcuts_view), group, original_view_type);
 }
 
+static void
+create_default_shortcuts_cb (GtkWidget *widget,
+			     void *data)
+{
+	RightClickMenuData *menu_data;
+	EShortcutsView *shortcuts_view;
+
+	menu_data = (RightClickMenuData *) data;
+	shortcuts_view = menu_data->shortcuts_view;
+	e_shortcuts_add_default_shortcuts (shortcuts_view->priv->shortcuts,
+					   e_group_bar_get_current_group_num (E_GROUP_BAR (shortcuts_view)));
+}
+
 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,
@@ -256,6 +269,12 @@ static GnomeUIInfo right_click_menu_uiinfo[] = {
 	  N_("Hide the shortcut bar"), hide_shortcut_bar_cb, NULL,
 	  NULL, 0, 0, 0, 0 },
 
+	GNOMEUIINFO_SEPARATOR,
+
+	{ GNOME_APP_UI_ITEM, N_("Create _Default Shortcuts"), 
+	  N_("Create Default Shortcuts"), create_default_shortcuts_cb, NULL,
+	  NULL, 0, 0, 0, 0 },
+
 	GNOMEUIINFO_END
 };
 
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 9b1a26cb79..8ad70eba0f 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -1043,36 +1043,45 @@ e_shortcuts_update_shortcut (EShortcuts *shortcuts,
 
 
 void
-e_shortcuts_add_default_group (EShortcuts *shortcuts)
+e_shortcuts_add_default_shortcuts (EShortcuts *shortcuts,
+				   int group_num)
 {
 	char *utf;
 
-	g_return_if_fail (shortcuts != NULL);
-	g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
-
-	utf = e_utf8_from_locale_string (_("Shortcuts"));
-	e_shortcuts_add_group (shortcuts, -1, utf);
-	g_free (utf);
-
 	utf = e_utf8_from_locale_string (_("Summary"));
 	e_shortcuts_add_shortcut (shortcuts, 0, -1, E_SUMMARY_URI, utf, 0, "summary", NULL);
 	g_free (utf);
 
 	utf = e_utf8_from_locale_string (_("Inbox"));
-	e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_INBOX_URI, utf, 0, "mail", "inbox");
+	e_shortcuts_add_shortcut (shortcuts, 0, -1, "default:mail", utf, 0, "mail", "inbox");
 	g_free (utf);
 
 	utf = e_utf8_from_locale_string (_("Calendar"));
-	e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CALENDAR_URI, utf, 0, "calendar", NULL);
+	e_shortcuts_add_shortcut (shortcuts, 0, -1, "default:calendar", utf, 0, "calendar", NULL);
 	g_free (utf);
 
 	utf = e_utf8_from_locale_string (_("Tasks"));
-	e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_TASKS_URI, utf, 0, "tasks", NULL);
+	e_shortcuts_add_shortcut (shortcuts, 0, -1, "default:tasks", utf, 0, "tasks", NULL);
 	g_free (utf);
 
 	utf = e_utf8_from_locale_string (_("Contacts"));
-	e_shortcuts_add_shortcut (shortcuts, 0, -1, E_LOCAL_CONTACTS_URI, utf, 0, "contacts", NULL);
+	e_shortcuts_add_shortcut (shortcuts, 0, -1, "default:contacts", utf, 0, "contacts", NULL);
+	g_free (utf);
+}
+
+void
+e_shortcuts_add_default_group (EShortcuts *shortcuts)
+{
+	char *utf;
+
+	g_return_if_fail (shortcuts != NULL);
+	g_return_if_fail (E_IS_SHORTCUTS (shortcuts));
+
+	utf = e_utf8_from_locale_string (_("Shortcuts"));
+	e_shortcuts_add_group (shortcuts, -1, utf);
 	g_free (utf);
+
+	e_shortcuts_add_default_shortcuts (shortcuts, -1);
 }
 
 void
diff --git a/shell/e-shortcuts.h b/shell/e-shortcuts.h
index bbc438c606..1fb4bb8209 100644
--- a/shell/e-shortcuts.h
+++ b/shell/e-shortcuts.h
@@ -117,7 +117,9 @@ gboolean     e_shortcuts_load                    (EShortcuts          *shortcuts
 gboolean     e_shortcuts_save                    (EShortcuts          *shortcuts,
 						  const char          *path);
 
-void  e_shortcuts_add_default_group  (EShortcuts *shortcuts);
+void  e_shortcuts_add_default_shortcuts  (EShortcuts *shortcuts,
+					  int         group_num);
+void  e_shortcuts_add_default_group      (EShortcuts *shortcuts);
 
 void  e_shortcuts_remove_shortcut    (EShortcuts *shortcuts,
 				      int         group_num,
-- 
cgit