void nautilus_navigation_window_initialize_actions (NautilusNavigationWindow *window) { GtkActionGroup *action_group; GtkUIManager *ui_manager; GtkAction *action; action_group = gtk_action_group_new ("NavigationActions"); gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); window->details->navigation_action_group = action_group; gtk_action_group_add_actions (action_group, navigation_entries, G_N_ELEMENTS (navigation_entries), window); gtk_action_group_add_toggle_actions (action_group, navigation_toggle_entries, G_N_ELEMENTS (navigation_toggle_entries), window); action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION, "name", "Back", "label", _("_Back"), "stock_id", GTK_STOCK_GO_BACK, "tooltip", _("Go to the previous visited location"), "arrow-tooltip", _("Back history"), "window", window, "direction", NAUTILUS_NAVIGATION_DIRECTION_BACK, "is_important", TRUE, NULL); g_signal_connect (action, "activate", G_CALLBACK (action_back_callback), window); gtk_action_group_add_action_with_accel (action_group, action, "<alt>Left"); g_object_unref (action); action = g_object_new (NAUTILUS_TYPE_NAVIGATION_ACTION, "name", "Forward", "label", _("_Forward"), "stock_id", GTK_STOCK_GO_FORWARD, "tooltip", _("Go to the next visited location"), "arrow-tooltip", _("Forward history"), "window", window, "direction", NAUTILUS_NAVIGATION_DIRECTION_FORWARD, "is_important", TRUE, NULL); g_signal_connect (action, "activate", G_CALLBACK (action_forward_callback), window); gtk_action_group_add_action_with_accel (action_group, action, "<alt>Right"); g_object_unref (action); action = gtk_action_group_get_action (action_group, NAUTILUS_ACTION_SEARCH); g_object_set (action, "short_label", _("_Search"), NULL); ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); gtk_ui_manager_insert_action_group (ui_manager, action_group, 0); g_object_unref (action_group); /* owned by ui_manager */ }
void nautilus_navigation_window_load_extension_toolbar_items (NautilusNavigationWindow *window) { GtkActionGroup *action_group; GtkAction *action; GtkUIManager *ui_manager; GList *items; GList *l; NautilusMenuItem *item; guint merge_id; ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); if (window->details->extensions_toolbar_merge_id != 0) { gtk_ui_manager_remove_ui (ui_manager, window->details->extensions_toolbar_merge_id); window->details->extensions_toolbar_merge_id = 0; } if (window->details->extensions_toolbar_action_group != NULL) { gtk_ui_manager_remove_action_group (ui_manager, window->details->extensions_toolbar_action_group); window->details->extensions_toolbar_action_group = NULL; } merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->extensions_toolbar_merge_id = merge_id; action_group = gtk_action_group_new ("ExtensionsToolbarGroup"); window->details->extensions_toolbar_action_group = action_group; gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE); gtk_ui_manager_insert_action_group (ui_manager, action_group, -1); g_object_unref (action_group); /* owned by ui manager */ items = get_extension_toolbar_items (window); for (l = items; l != NULL; l = l->next) { item = NAUTILUS_MENU_ITEM (l->data); action = nautilus_toolbar_action_from_menu_item (item); gtk_action_group_add_action (action_group, GTK_ACTION (action)); g_object_unref (action); gtk_ui_manager_add_ui (ui_manager, merge_id, TOOLBAR_PATH_EXTENSION_ACTIONS, gtk_action_get_name (action), gtk_action_get_name (action), GTK_UI_MANAGER_TOOLITEM, FALSE); g_object_unref (item); } g_list_free (items); }
static void update_bookmarks (NautilusWindow *window) { NautilusBookmarkList *bookmarks; NautilusBookmark *bookmark; guint bookmark_count; guint index; GtkUIManager *ui_manager; g_assert (NAUTILUS_IS_WINDOW (window)); g_assert (window->details->bookmarks_merge_id == 0); g_assert (window->details->bookmarks_action_group == NULL); if (window->details->bookmark_list == NULL) { window->details->bookmark_list = nautilus_bookmark_list_new (); } bookmarks = window->details->bookmark_list; ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); window->details->bookmarks_merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->bookmarks_action_group = gtk_action_group_new ("BookmarksGroup"); g_signal_connect (window->details->bookmarks_action_group, "connect-proxy", G_CALLBACK (connect_proxy_cb), NULL); gtk_ui_manager_insert_action_group (ui_manager, window->details->bookmarks_action_group, -1); g_object_unref (window->details->bookmarks_action_group); /* append new set of bookmarks */ bookmark_count = nautilus_bookmark_list_length (bookmarks); for (index = 0; index < bookmark_count; ++index) { bookmark = nautilus_bookmark_list_item_at (bookmarks, index); if (nautilus_bookmark_uri_known_not_to_exist (bookmark)) { continue; } nautilus_menus_append_bookmark_to_menu (NAUTILUS_WINDOW (window), bookmark, NAUTILUS_WINDOW_GET_CLASS (window)->bookmarks_placeholder, "dynamic", index, window->details->bookmarks_action_group, window->details->bookmarks_merge_id, G_CALLBACK (refresh_bookmarks_menu), show_bogus_bookmark_window); } }
/** * nautilus_window_initialize_menus * * Create and install the set of menus for this window. * @window: A recently-created NautilusWindow. */ void nautilus_navigation_window_initialize_menus (NautilusNavigationWindow *window) { GtkUIManager *ui_manager; const char *ui; ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); ui = nautilus_ui_string_get ("nautilus-navigation-window-ui.xml"); gtk_ui_manager_add_ui_from_string (ui_manager, ui, -1, NULL); nautilus_navigation_window_update_show_hide_menu_items (window); nautilus_navigation_window_update_spatial_menu_item (window); nautilus_navigation_window_initialize_go_menu (window); }
void nautilus_navigation_window_remove_go_menu_items (NautilusNavigationWindow *window) { GtkUIManager *ui_manager; ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); if (window->details->go_menu_merge_id != 0) { gtk_ui_manager_remove_ui (ui_manager, window->details->go_menu_merge_id); window->details->go_menu_merge_id = 0; } if (window->details->go_menu_action_group != NULL) { gtk_ui_manager_remove_action_group (ui_manager, window->details->go_menu_action_group); window->details->go_menu_action_group = NULL; } }
static void remove_bookmarks_menu_items (NautilusWindow *window) { GtkUIManager *ui_manager; ui_manager = nautilus_window_get_ui_manager (window); if (window->details->bookmarks_merge_id != 0) { gtk_ui_manager_remove_ui (ui_manager, window->details->bookmarks_merge_id); window->details->bookmarks_merge_id = 0; } if (window->details->bookmarks_action_group != NULL) { gtk_ui_manager_remove_action_group (ui_manager, window->details->bookmarks_action_group); window->details->bookmarks_action_group = NULL; } }
/** * refresh_go_menu: * * Refresh list of bookmarks at end of Go menu to match centralized history list. * @window: The NautilusWindow whose Go menu will be refreshed. **/ static void nautilus_window_initialize_go_menu (NautilusWindow *window) { GtkUIManager *ui_manager; GtkWidget *menuitem; int i; ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); for (i = 0; i < G_N_ELEMENTS (icon_entries); i++) { menuitem = gtk_ui_manager_get_widget ( ui_manager, icon_entries[i]); gtk_image_menu_item_set_always_show_image ( GTK_IMAGE_MENU_ITEM (menuitem), TRUE); } }
/** * refresh_go_menu: * * Refresh list of bookmarks at end of Go menu to match centralized history list. * @window: The NautilusWindow whose Go menu will be refreshed. **/ static void refresh_go_menu (NautilusNavigationWindow *window) { GtkUIManager *ui_manager; GList *node; int index; g_assert (NAUTILUS_IS_NAVIGATION_WINDOW (window)); /* Unregister any pending call to this function. */ nautilus_navigation_window_remove_go_menu_callback (window); /* Remove old set of history items. */ nautilus_navigation_window_remove_go_menu_items (window); ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); window->details->go_menu_merge_id = gtk_ui_manager_new_merge_id (ui_manager); window->details->go_menu_action_group = gtk_action_group_new ("GoMenuGroup"); g_signal_connect (window->details->go_menu_action_group, "connect-proxy", G_CALLBACK (connect_proxy_cb), NULL); gtk_ui_manager_insert_action_group (ui_manager, window->details->go_menu_action_group, -1); g_object_unref (window->details->go_menu_action_group); /* Add in a new set of history items. */ for (node = nautilus_get_history_list (), index = 0; node != NULL && index < 10; node = node->next, index++) { nautilus_menus_append_bookmark_to_menu (NAUTILUS_WINDOW (window), NAUTILUS_BOOKMARK (node->data), MENU_PATH_HISTORY_PLACEHOLDER, "history", index, window->details->go_menu_action_group, window->details->go_menu_merge_id, G_CALLBACK (schedule_refresh_go_menu), show_bogus_history_window); } }
static void nautilus_navigation_window_init (NautilusNavigationWindow *window) { GtkUIManager *ui_manager; GtkWidget *toolbar; NautilusWindow *win; NautilusNavigationWindowPane *pane; GtkWidget *hpaned; GtkWidget *vbox; win = NAUTILUS_WINDOW (window); window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, NAUTILUS_TYPE_NAVIGATION_WINDOW, NautilusNavigationWindowDetails); pane = nautilus_navigation_window_pane_new (win); win->details->panes = g_list_prepend (win->details->panes, pane); window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE); window->details->content_paned = nautilus_horizontal_splitter_new (); gtk_table_attach (GTK_TABLE (NAUTILUS_WINDOW (window)->details->table), window->details->content_paned, /* X direction */ /* Y direction */ 0, 1, 3, 4, GTK_EXPAND | GTK_FILL | GTK_SHRINK, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0); gtk_widget_show (window->details->content_paned); vbox = gtk_vbox_new (FALSE, 0); nautilus_horizontal_splitter_pack2 (NAUTILUS_HORIZONTAL_SPLITTER (window->details->content_paned), vbox); gtk_widget_show (vbox); hpaned = gtk_hpaned_new (); gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0); gtk_widget_show (hpaned); window->details->split_view_hpane = hpaned; gtk_box_pack_start (GTK_BOX (vbox), win->details->statusbar, FALSE, FALSE, 0); gtk_widget_show (win->details->statusbar); nautilus_navigation_window_pane_setup (pane); gtk_paned_pack1 (GTK_PANED(hpaned), pane->widget, TRUE, FALSE); gtk_widget_show (pane->widget); /* this has to be done after the location bar has been set up, * but before menu stuff is being called */ nautilus_window_set_active_pane (win, NAUTILUS_WINDOW_PANE (pane)); nautilus_navigation_window_initialize_actions (window); nautilus_navigation_window_initialize_menus (window); ui_manager = nautilus_window_get_ui_manager (NAUTILUS_WINDOW (window)); toolbar = gtk_ui_manager_get_widget (ui_manager, "/Toolbar"); window->details->toolbar = toolbar; gtk_table_attach (GTK_TABLE (NAUTILUS_WINDOW (window)->details->table), toolbar, /* X direction */ /* Y direction */ 0, 1, 1, 2, GTK_EXPAND | GTK_FILL | GTK_SHRINK, 0, 0, 0); gtk_widget_show (toolbar); nautilus_navigation_window_initialize_toolbars (window); /* Set initial sensitivity of some buttons & menu items * now that they're all created. */ nautilus_navigation_window_allow_back (window, FALSE); nautilus_navigation_window_allow_forward (window, FALSE); eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY, always_use_location_entry_changed, window, G_OBJECT (window)); eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER, always_use_browser_changed, window, G_OBJECT (window)); }
static void nautilus_toolbar_constructed (GObject *obj) { NautilusToolbar *self = NAUTILUS_TOOLBAR (obj); GtkWidget *toolbar; GtkWidget *button; GtkWidget *menu; GtkWidget *box; GtkWidget *separator; GtkUIManager *ui_manager; gboolean rtl; G_OBJECT_CLASS (nautilus_toolbar_parent_class)->constructed (obj); gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (self)), "header-bar"); self->priv->toolbar = toolbar = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); g_object_set (toolbar, "margin", 8, NULL); gtk_container_add (GTK_CONTAINER (self), toolbar); rtl = gtk_widget_get_default_direction () == GTK_TEXT_DIR_RTL; ui_manager = nautilus_window_get_ui_manager (self->priv->window); gtk_style_context_set_junction_sides (gtk_widget_get_style_context (GTK_WIDGET (self)), GTK_JUNCTION_BOTTOM); /* Back and Forward */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); /* Back */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_BACK, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-previous-rtl-symbolic" : "go-previous-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_BACK); gtk_container_add (GTK_CONTAINER (box), button); /* Forward */ button = toolbar_create_toolbutton (self, FALSE, FALSE, NAUTILUS_ACTION_FORWARD, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_action_set_icon_name (gtk_activatable_get_related_action (GTK_ACTIVATABLE (button)), rtl ? "go-next-rtl-symbolic" : "go-next-symbolic"); navigation_button_setup_menu (self, button, NAUTILUS_NAVIGATION_DIRECTION_FORWARD); gtk_container_add (GTK_CONTAINER (box), button); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_box_pack_start (GTK_BOX (toolbar), box, FALSE, FALSE, 0); if (rtl) { gtk_widget_set_margin_left (box, 12); } else { gtk_widget_set_margin_right (box, 12); } /* regular path bar */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); self->priv->path_bar = g_object_new (NAUTILUS_TYPE_PATH_BAR, NULL); gtk_box_pack_start (GTK_BOX (box), self->priv->path_bar, TRUE, TRUE, 0); /* entry-like location bar */ self->priv->location_entry = nautilus_location_entry_new (); gtk_box_pack_start (GTK_BOX (box), self->priv->location_entry, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (toolbar), box, TRUE, TRUE, 0); /* search */ button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_SEARCH, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 76); } else { gtk_widget_set_margin_left (button, 76); } /* View buttons */ box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_LIST, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, FALSE, TRUE, NAUTILUS_ACTION_VIEW_GRID, NULL); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); button = toolbar_create_toolbutton (self, TRUE, FALSE, "go-down-symbolic", _("View options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); gtk_container_add (GTK_CONTAINER (box), button); menu = gtk_ui_manager_get_widget (ui_manager, "/ViewMenu"); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_RAISED); gtk_style_context_add_class (gtk_widget_get_style_context (box), GTK_STYLE_CLASS_LINKED); gtk_container_add (GTK_CONTAINER (toolbar), box); if (rtl) { gtk_widget_set_margin_right (box, 12); } else { gtk_widget_set_margin_left (box, 12); } /* Action Menu */ button = toolbar_create_toolbutton (self, TRUE, FALSE, "emblem-system-symbolic", _("Location options")); gtk_widget_set_valign (button, GTK_ALIGN_CENTER); menu = gtk_ui_manager_get_widget (ui_manager, "/ActionMenu"); gtk_widget_set_halign (menu, GTK_ALIGN_END); gtk_menu_button_set_popup (GTK_MENU_BUTTON (button), menu); gtk_actionable_set_action_name (GTK_ACTIONABLE (button), "win.gear-menu"); g_signal_connect (menu, "key-press-event", G_CALLBACK (gear_menu_key_press), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 12); } else { gtk_widget_set_margin_left (button, 12); } /* Separator and Close */ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL); gtk_container_add (GTK_CONTAINER (toolbar), separator); if (rtl) { gtk_widget_set_margin_right (separator, 8); } else { gtk_widget_set_margin_left (separator, 8); } button = gtk_button_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_MENU); gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE); g_signal_connect (button, "clicked", G_CALLBACK (close_button_clicked), self); gtk_container_add (GTK_CONTAINER (toolbar), button); if (rtl) { gtk_widget_set_margin_right (button, 6); } else { gtk_widget_set_margin_left (button, 6); } g_signal_connect_swapped (nautilus_preferences, "changed::" NAUTILUS_PREFERENCES_ALWAYS_USE_LOCATION_ENTRY, G_CALLBACK (toolbar_update_appearance), self); gtk_widget_show_all (toolbar); toolbar_update_appearance (self); }