filebrowser: Remove the back and forward toolbar dropdowns

This commit is contained in:
JosephMcc 2017-02-13 17:31:58 -08:00
parent c27e781132
commit 1e2e106d70
2 changed files with 5 additions and 197 deletions

View File

@ -1,6 +1,7 @@
<ui>
<toolbar name="ToolBar">
<placeholder name="Tool_Opt1"/>
<toolitem action="DirectoryPrevious"/>
<toolitem action="DirectoryNext"/>
<toolitem action="DirectoryUp"/>
<separator/>
<toolitem action="DirectoryRefresh"/>

View File

@ -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,61 +1543,23 @@ 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);
@ -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,