nautilus r14245 - in branches/multiview: . src
- From: jaredm svn gnome org
- To: svn-commits-list gnome org
- Subject: nautilus r14245 - in branches/multiview: . src
- Date: Sun, 8 Jun 2008 13:36:18 +0000 (UTC)
Author: jaredm
Date: Sun Jun 8 13:36:18 2008
New Revision: 14245
URL: http://svn.gnome.org/viewvc/nautilus?rev=14245&view=rev
Log:
2008-06-08 Jared Moore <jaredm svn gnome org>
* src/nautilus-navigation-window-menus.c
(update_tab_action_sensitivity), (tab_menu_action_activate_callback),
(reload_tab_menu), (nautilus_navigation_window_sync_tab_menu_title):
* src/nautilus-navigation-window.c (real_sync_title):
* src/nautilus-window-private.h:
Add tab list to Tabs menu. Use <Alt>(Num) keyboard accelerators to
access first 10 tabs. Update tab list labels when slot title changes.
Set labels in tab list to the title of the corresponding slot. Update
the label when the slot title changes.
Modified:
branches/multiview/ChangeLog
branches/multiview/src/nautilus-navigation-window-menus.c
branches/multiview/src/nautilus-navigation-window.c
branches/multiview/src/nautilus-window-private.h
Modified: branches/multiview/src/nautilus-navigation-window-menus.c
==============================================================================
--- branches/multiview/src/nautilus-navigation-window-menus.c (original)
+++ branches/multiview/src/nautilus-navigation-window-menus.c Sun Jun 8 13:36:18 2008
@@ -60,6 +60,7 @@
#include <libnautilus-private/nautilus-signaller.h>
#define MENU_PATH_HISTORY_PLACEHOLDER "/MenuBar/Other Menus/Go/History Placeholder"
+#define MENU_PATH_TABS_PLACEHOLDER "/MenuBar/Other Menus/Tabs/TabsOpen"
#define RESPONSE_FORGET 1000
#define MENU_ITEM_MAX_WIDTH_CHARS 32
@@ -437,6 +438,7 @@
GtkAction *action;
NautilusNotebook *notebook;
gboolean sensitive;
+ int tab_num;
g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
@@ -458,14 +460,117 @@
action = gtk_action_group_get_action (action_group, "TabsMoveRight");
sensitive = nautilus_notebook_can_reorder_current_child_relative (notebook, 1);
g_object_set (action, "sensitive", sensitive, NULL);
+
+ action_group = window->details->tabs_menu_action_group;
+ tab_num = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+ action = gtk_action_group_get_action (action_group, "Tab0");
+ if (tab_num >= 0 && action != NULL) {
+ gtk_radio_action_set_current_value (GTK_RADIO_ACTION (action), tab_num);
+ }
+}
+
+static void
+tab_menu_action_activate_callback (GtkAction *action,
+ gpointer user_data)
+{
+ int num;
+ GtkWidget *notebook;
+ NautilusNavigationWindow *window;
+
+ window = NAUTILUS_NAVIGATION_WINDOW (user_data);
+ notebook = window->notebook;
+
+ num = gtk_radio_action_get_current_value (GTK_RADIO_ACTION (action));
+
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), num);
}
static void
reload_tab_menu (NautilusNavigationWindow *window)
{
+ GtkRadioAction *action;
+ GtkUIManager *ui_manager;
+ int i;
+ gchar action_name[80];
+ gchar *action_label;
+ gchar accelerator[80];
+ GSList *radio_group;
+ NautilusWindowSlot *slot;
+ GtkNotebook *notebook;
+
g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window));
- /* multiview-TODO rebuild (not yet existing) tab list */
+ /* Remove old tab menu items */
+ ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window));
+ if (window->details->tabs_menu_merge_id != 0) {
+ gtk_ui_manager_remove_ui (ui_manager,
+ window->details->tabs_menu_merge_id);
+ window->details->tabs_menu_merge_id = 0;
+ }
+ if (window->details->tabs_menu_action_group != NULL) {
+ gtk_ui_manager_remove_action_group (ui_manager,
+ window->details->tabs_menu_action_group);
+ window->details->tabs_menu_action_group = NULL;
+ }
+
+ /* Add new tab menu items */
+ window->details->tabs_menu_merge_id = gtk_ui_manager_new_merge_id (ui_manager);
+ window->details->tabs_menu_action_group = gtk_action_group_new ("TabsMenuGroup");
+
+ gtk_ui_manager_insert_action_group (ui_manager,
+ window->details->tabs_menu_action_group,
+ -1);
+ g_object_unref (window->details->tabs_menu_action_group);
+
+ notebook = GTK_NOTEBOOK (window->notebook);
+ radio_group = NULL;
+ for (i = 0; i < gtk_notebook_get_n_pages (notebook); i++) {
+
+ snprintf(action_name, sizeof (action_name), "Tab%d", i);
+
+ slot = nautilus_window_get_slot_for_content_box (NAUTILUS_WINDOW (window),
+ gtk_notebook_get_nth_page (notebook, i));
+ if (slot) {
+ action_label = g_strdup (slot->title);
+ } else {
+ /* Give the action a generic label. This should only happen when the tab is created
+ * and the slot has not yet be created, so if all goes to plan then the action label
+ * will be updated when the slot is created. */
+ action_label = g_strdup_printf ("Tab %d", i);
+ }
+
+ action = gtk_radio_action_new (action_name, action_label, NULL, NULL, i);
+
+ g_free (action_label);
+ action_label = NULL;
+
+ gtk_radio_action_set_group (action, radio_group);
+ radio_group = gtk_radio_action_get_group (action);
+
+ g_signal_connect (action, "activate",
+ G_CALLBACK (tab_menu_action_activate_callback),
+ window);
+
+ /* Use Alt+(Number) keyboard accelerators for first 10 tabs */
+ if (i < 10) {
+ snprintf(accelerator, sizeof (accelerator), "<Alt>%d", (i+1)%10);
+ } else {
+ accelerator[0] = '\0';
+ }
+ gtk_action_group_add_action_with_accel (window->details->tabs_menu_action_group,
+ GTK_ACTION (action),
+ accelerator);
+
+ g_object_unref (action);
+
+ gtk_ui_manager_add_ui (ui_manager,
+ window->details->tabs_menu_merge_id,
+ MENU_PATH_TABS_PLACEHOLDER,
+ action_name,
+ action_name,
+ GTK_UI_MANAGER_MENUITEM,
+ FALSE);
+ }
update_tab_action_sensitivity (window);
}
@@ -486,6 +591,40 @@
reload_tab_menu (window);
}
+/* Update the label displayed in the "Tabs" menu. This is called when the title of
+ * a slot changes. */
+void
+nautilus_navigation_window_sync_tab_menu_title (NautilusNavigationWindow *window,
+ NautilusWindowSlot *slot)
+{
+ int tab_num;
+ GtkNotebook *notebook;
+ GtkAction *action;
+ GtkActionGroup *action_group;
+ char action_name[80];
+
+ notebook = GTK_NOTEBOOK (window->notebook);
+
+ /* Find the tab number for that slot. It should (almost?) always be the current
+ * tab, so check that first in order to avoid searching through the entire tab
+ * list. */
+ tab_num = gtk_notebook_get_current_page (notebook);
+ if (slot->content_box != gtk_notebook_get_nth_page (notebook, tab_num)) {
+ tab_num = gtk_notebook_page_num (notebook, slot->content_box);
+ }
+
+ g_return_if_fail (tab_num >= 0);
+
+ /* Find the action associated with that tab */
+ action_group = window->details->tabs_menu_action_group;
+ snprintf (action_name, sizeof (action_name), "Tab%d", tab_num);
+ action = gtk_action_group_get_action (action_group, action_name);
+
+ /* Update the label */
+ g_return_if_fail (action);
+ g_object_set (action, "label", slot->title, NULL);
+}
+
static void
action_new_window_callback (GtkAction *action,
gpointer user_data)
Modified: branches/multiview/src/nautilus-navigation-window.c
==============================================================================
--- branches/multiview/src/nautilus-navigation-window.c (original)
+++ branches/multiview/src/nautilus-navigation-window.c Sun Jun 8 13:36:18 2008
@@ -1126,6 +1126,8 @@
notebook = NAUTILUS_NOTEBOOK (navigation_window->notebook);
nautilus_notebook_sync_tab_label (notebook, slot);
+
+ nautilus_navigation_window_sync_tab_menu_title (navigation_window, slot);
}
static NautilusIconInfo *
Modified: branches/multiview/src/nautilus-window-private.h
==============================================================================
--- branches/multiview/src/nautilus-window-private.h (original)
+++ branches/multiview/src/nautilus-window-private.h Sun Jun 8 13:36:18 2008
@@ -99,6 +99,9 @@
guint refresh_go_menu_idle_id;
guint go_menu_merge_id;
+ GtkActionGroup *tabs_menu_action_group;
+ guint tabs_menu_merge_id;
+
/* Toolbar */
GtkWidget *toolbar;
GtkWidget *location_bar;
@@ -221,6 +224,8 @@
void nautilus_navigation_window_update_show_hide_menu_items (NautilusNavigationWindow *window);
void nautilus_navigation_window_update_spatial_menu_item (NautilusNavigationWindow *window);
void nautilus_navigation_window_update_tab_menu_item_visibility (NautilusNavigationWindow *window);
+void nautilus_navigation_window_sync_tab_menu_title (NautilusNavigationWindow *window,
+ NautilusWindowSlot *slot);
void nautilus_navigation_window_remove_go_menu_callback (NautilusNavigationWindow *window);
void nautilus_navigation_window_remove_go_menu_items (NautilusNavigationWindow *window);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]