From 1e2e106d70f27f92602cbbfb571c6ecd6a8b370c Mon Sep 17 00:00:00 2001 From: JosephMcc Date: Mon, 13 Feb 2017 17:31:58 -0800 Subject: [PATCH] filebrowser: Remove the back and forward toolbar dropdowns --- .../xed-file-browser-widget-ui.xml | 3 +- plugins/filebrowser/xed-file-browser-widget.c | 199 +----------------- 2 files changed, 5 insertions(+), 197 deletions(-) diff --git a/plugins/filebrowser/xed-file-browser-widget-ui.xml b/plugins/filebrowser/xed-file-browser-widget-ui.xml index 472fd18..cbbad99 100644 --- a/plugins/filebrowser/xed-file-browser-widget-ui.xml +++ b/plugins/filebrowser/xed-file-browser-widget-ui.xml @@ -1,6 +1,7 @@ - + + diff --git a/plugins/filebrowser/xed-file-browser-widget.c b/plugins/filebrowser/xed-file-browser-widget.c index ba6c8d0..994474c 100644 --- a/plugins/filebrowser/xed-file-browser-widget.c +++ b/plugins/filebrowser/xed-file-browser-widget.c @@ -149,9 +149,6 @@ struct _XedFileBrowserWidgetPrivate GList *locations; GList *current_location; gboolean changing_location; - GtkWidget *location_previous_menu; - GtkWidget *location_next_menu; - GtkWidget *current_location_menu_item; gboolean enable_delete; @@ -194,8 +191,6 @@ static void on_virtual_root_changed (XedFileBrowserStore *model, XedFileBrowserWidget *obj); static gboolean on_entry_filter_activate (XedFileBrowserWidget *obj); -static void on_location_jump_activate (GtkMenuItem *item, - XedFileBrowserWidget *obj); static void on_bookmarks_row_changed (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, @@ -373,11 +368,6 @@ xed_file_browser_widget_finalize (GObject *object) location_free ((Location *) (loc->data)); } - if (obj->priv->current_location_menu_item) - { - g_object_unref (obj->priv->current_location_menu_item); - } - g_list_free (obj->priv->locations); g_hash_table_destroy (obj->priv->bookmarks_hash); @@ -904,7 +894,6 @@ create_toolbar (XedFileBrowserWidget *obj, GError *error = NULL; GtkActionGroup *action_group; GtkWidget *toolbar; - GtkWidget *widget; GtkAction *action; gchar *ui_file; @@ -1008,44 +997,6 @@ create_toolbar (XedFileBrowserWidget *obj, gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU); - /* Previous directory menu tool item */ - obj->priv->location_previous_menu = gtk_menu_new (); - gtk_widget_show (obj->priv->location_previous_menu); - - widget = GTK_WIDGET (gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_BACK)); - gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget), obj->priv->location_previous_menu); - - g_object_set (widget, "label", _("Previous location"), NULL); - gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (widget), _("Go to previous location")); - gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (widget), _("Go to a previously opened location")); - - action = gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryPrevious"); - g_object_set (action, - "is_important", TRUE, - "short_label", _("Previous location"), - NULL); - gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 0); - - /* Next directory menu tool item */ - obj->priv->location_next_menu = gtk_menu_new (); - gtk_widget_show (obj->priv->location_next_menu); - - widget = GTK_WIDGET (gtk_menu_tool_button_new_from_stock (GTK_STOCK_GO_FORWARD)); - gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (widget), obj->priv->location_next_menu); - - g_object_set (widget, "label", _("Next location"), NULL); - gtk_tool_item_set_tooltip_text (GTK_TOOL_ITEM (widget), _("Go to next location")); - gtk_menu_tool_button_set_arrow_tooltip_text (GTK_MENU_TOOL_BUTTON (widget), _("Go to a previously opened location")); - - action = gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryNext"); - g_object_set (action, - "is_important", TRUE, - "short_label", _("Previous location"), - NULL); - gtk_activatable_set_related_action (GTK_ACTIVATABLE (widget), action); - gtk_toolbar_insert (GTK_TOOLBAR (toolbar), GTK_TOOL_ITEM (widget), 1); - gtk_box_pack_start (GTK_BOX (obj), toolbar, FALSE, FALSE, 0); gtk_widget_show (toolbar); @@ -1554,55 +1505,6 @@ get_topmost_file (GFile *file) return current; } -static GtkWidget * -create_goto_menu_item (XedFileBrowserWidget *obj, - GList *item, - GdkPixbuf *icon) -{ - GtkWidget *result; - GtkWidget *image; - gchar *unescape; - GdkPixbuf *pixbuf = NULL; - Location *loc; - - loc = (Location *) (item->data); - - if (!get_from_bookmark_file (obj, loc->virtual_root, &unescape, &pixbuf)) - { - unescape = xed_file_browser_utils_file_basename (loc->virtual_root); - - if (icon) - { - pixbuf = g_object_ref (icon); - } - } - - if (pixbuf) - { - image = gtk_image_new_from_pixbuf (pixbuf); - g_object_unref (pixbuf); - - gtk_widget_show (image); - - result = gtk_image_menu_item_new_with_label (unescape); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (result), image); - } - else - { - result = gtk_menu_item_new_with_label (unescape); - } - - g_object_set_data (G_OBJECT (result), LOCATION_DATA_KEY, item); - g_signal_connect (result, "activate", - G_CALLBACK (on_location_jump_activate), obj); - - gtk_widget_show (result); - - g_free (unescape); - - return result; -} - static GList * list_next_iterator (GList *list) { @@ -1631,12 +1533,7 @@ jump_to_location (XedFileBrowserWidget *obj, gboolean previous) { Location *loc; - GtkWidget *widget; - GList *children; - GList *child; GList *(*iter_func) (GList *); - GtkWidget *menu_from; - GtkWidget *menu_to; if (!obj->priv->locations) { @@ -1646,62 +1543,24 @@ jump_to_location (XedFileBrowserWidget *obj, if (previous) { iter_func = list_next_iterator; - menu_from = obj->priv->location_previous_menu; - menu_to = obj->priv->location_next_menu; } else { iter_func = list_prev_iterator; - menu_from = obj->priv->location_next_menu; - menu_to = obj->priv->location_previous_menu; } - children = gtk_container_get_children (GTK_CONTAINER (menu_from)); - child = children; + obj->priv->changing_location = TRUE; - /* This is the menuitem for the current location, which is the first - to be added to the menu */ - widget = obj->priv->current_location_menu_item; - - while (obj->priv->current_location != item) + if (obj->priv->current_location != item) { - if (widget) - { - /* Prepend the menu item to the menu */ - gtk_menu_shell_prepend (GTK_MENU_SHELL (menu_to), widget); - - g_object_unref (widget); - } - - widget = GTK_WIDGET (child->data); - - /* Make sure the widget isn't destroyed when removed */ - g_object_ref (widget); - gtk_container_remove (GTK_CONTAINER (menu_from), widget); - - obj->priv->current_location_menu_item = widget; + obj->priv->current_location = iter_func (obj->priv->current_location); if (obj->priv->current_location == NULL) { obj->priv->current_location = obj->priv->locations; - - if (obj->priv->current_location == item) - { - break; - } } - else - { - obj->priv->current_location = iter_func (obj->priv->current_location); - } - - child = child->next; } - g_list_free (children); - - obj->priv->changing_location = TRUE; - g_assert (obj->priv->current_location != NULL); loc = (Location *) (obj->priv->current_location->data); @@ -1715,9 +1574,6 @@ jump_to_location (XedFileBrowserWidget *obj, static void clear_next_locations (XedFileBrowserWidget *obj) { - GList *children; - GList *item; - if (obj->priv->current_location == NULL) { return; @@ -1729,15 +1585,6 @@ clear_next_locations (XedFileBrowserWidget *obj) obj->priv->locations = g_list_remove_link (obj->priv->locations, obj->priv->current_location->prev); } - children = gtk_container_get_children (GTK_CONTAINER (obj->priv->location_next_menu)); - - for (item = children; item; item = item->next) - { - gtk_container_remove (GTK_CONTAINER (obj->priv->location_next_menu), GTK_WIDGET (item->data)); - } - - g_list_free (children); - gtk_action_set_sensitive (gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryNext"), FALSE); } @@ -2614,15 +2461,6 @@ on_virtual_root_changed (XedFileBrowserStore *model, loc = g_slice_new (Location); loc->root = xed_file_browser_store_get_root (model); loc->virtual_root = g_object_ref (location); - - if (obj->priv->current_location) - { - /* Add current location to the menu so we can go back - to it later */ - gtk_menu_shell_prepend (GTK_MENU_SHELL (obj->priv->location_previous_menu), - obj->priv->current_location_menu_item); - } - obj->priv->locations = g_list_prepend (obj->priv->locations, loc); gtk_tree_model_get (GTK_TREE_MODEL (model), @@ -2631,11 +2469,6 @@ on_virtual_root_changed (XedFileBrowserStore *model, &pixbuf, -1); obj->priv->current_location = obj->priv->locations; - obj->priv->current_location_menu_item = create_goto_menu_item (obj, - obj->priv->current_location, - pixbuf); - - g_object_ref_sink (obj->priv->current_location_menu_item); if (pixbuf) { @@ -2690,12 +2523,7 @@ on_model_set (GObject *gobject, { GtkAction *action; - gtk_menu_shell_prepend (GTK_MENU_SHELL (obj->priv->location_previous_menu), - obj->priv->current_location_menu_item); - - g_object_unref (obj->priv->current_location_menu_item); obj->priv->current_location = NULL; - obj->priv->current_location_menu_item = NULL; action = gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryPrevious"); gtk_action_set_sensitive (action, TRUE); @@ -2914,27 +2742,6 @@ on_entry_filter_activate (XedFileBrowserWidget *obj) return FALSE; } -static void -on_location_jump_activate (GtkMenuItem *item, - XedFileBrowserWidget *obj) -{ - GList *location; - - location = g_object_get_data (G_OBJECT (item), LOCATION_DATA_KEY); - - if (obj->priv->current_location) - { - jump_to_location (obj, location, - g_list_position (obj->priv->locations, location) > - g_list_position (obj->priv->locations, obj->priv->current_location)); - } - else - { - jump_to_location (obj, location, TRUE); - } - -} - static void on_bookmarks_row_changed (GtkTreeModel *model, GtkTreePath *path,