filebrowser: Remove the back and forward toolbar dropdowns
This commit is contained in:
parent
c27e781132
commit
1e2e106d70
|
@ -1,6 +1,7 @@
|
||||||
<ui>
|
<ui>
|
||||||
<toolbar name="ToolBar">
|
<toolbar name="ToolBar">
|
||||||
<placeholder name="Tool_Opt1"/>
|
<toolitem action="DirectoryPrevious"/>
|
||||||
|
<toolitem action="DirectoryNext"/>
|
||||||
<toolitem action="DirectoryUp"/>
|
<toolitem action="DirectoryUp"/>
|
||||||
<separator/>
|
<separator/>
|
||||||
<toolitem action="DirectoryRefresh"/>
|
<toolitem action="DirectoryRefresh"/>
|
||||||
|
|
|
@ -149,9 +149,6 @@ struct _XedFileBrowserWidgetPrivate
|
||||||
GList *locations;
|
GList *locations;
|
||||||
GList *current_location;
|
GList *current_location;
|
||||||
gboolean changing_location;
|
gboolean changing_location;
|
||||||
GtkWidget *location_previous_menu;
|
|
||||||
GtkWidget *location_next_menu;
|
|
||||||
GtkWidget *current_location_menu_item;
|
|
||||||
|
|
||||||
gboolean enable_delete;
|
gboolean enable_delete;
|
||||||
|
|
||||||
|
@ -194,8 +191,6 @@ static void on_virtual_root_changed (XedFileBrowserStore *model,
|
||||||
XedFileBrowserWidget *obj);
|
XedFileBrowserWidget *obj);
|
||||||
|
|
||||||
static gboolean on_entry_filter_activate (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,
|
static void on_bookmarks_row_changed (GtkTreeModel *model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
GtkTreeIter *iter,
|
GtkTreeIter *iter,
|
||||||
|
@ -373,11 +368,6 @@ xed_file_browser_widget_finalize (GObject *object)
|
||||||
location_free ((Location *) (loc->data));
|
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_list_free (obj->priv->locations);
|
||||||
|
|
||||||
g_hash_table_destroy (obj->priv->bookmarks_hash);
|
g_hash_table_destroy (obj->priv->bookmarks_hash);
|
||||||
|
@ -904,7 +894,6 @@ create_toolbar (XedFileBrowserWidget *obj,
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
GtkActionGroup *action_group;
|
GtkActionGroup *action_group;
|
||||||
GtkWidget *toolbar;
|
GtkWidget *toolbar;
|
||||||
GtkWidget *widget;
|
|
||||||
GtkAction *action;
|
GtkAction *action;
|
||||||
gchar *ui_file;
|
gchar *ui_file;
|
||||||
|
|
||||||
|
@ -1008,44 +997,6 @@ create_toolbar (XedFileBrowserWidget *obj,
|
||||||
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
|
||||||
gtk_toolbar_set_icon_size (GTK_TOOLBAR (toolbar), GTK_ICON_SIZE_MENU);
|
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_box_pack_start (GTK_BOX (obj), toolbar, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (toolbar);
|
gtk_widget_show (toolbar);
|
||||||
|
|
||||||
|
@ -1554,55 +1505,6 @@ get_topmost_file (GFile *file)
|
||||||
return current;
|
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 *
|
static GList *
|
||||||
list_next_iterator (GList *list)
|
list_next_iterator (GList *list)
|
||||||
{
|
{
|
||||||
|
@ -1631,12 +1533,7 @@ jump_to_location (XedFileBrowserWidget *obj,
|
||||||
gboolean previous)
|
gboolean previous)
|
||||||
{
|
{
|
||||||
Location *loc;
|
Location *loc;
|
||||||
GtkWidget *widget;
|
|
||||||
GList *children;
|
|
||||||
GList *child;
|
|
||||||
GList *(*iter_func) (GList *);
|
GList *(*iter_func) (GList *);
|
||||||
GtkWidget *menu_from;
|
|
||||||
GtkWidget *menu_to;
|
|
||||||
|
|
||||||
if (!obj->priv->locations)
|
if (!obj->priv->locations)
|
||||||
{
|
{
|
||||||
|
@ -1646,61 +1543,23 @@ jump_to_location (XedFileBrowserWidget *obj,
|
||||||
if (previous)
|
if (previous)
|
||||||
{
|
{
|
||||||
iter_func = list_next_iterator;
|
iter_func = list_next_iterator;
|
||||||
menu_from = obj->priv->location_previous_menu;
|
|
||||||
menu_to = obj->priv->location_next_menu;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
iter_func = list_prev_iterator;
|
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));
|
obj->priv->changing_location = TRUE;
|
||||||
child = children;
|
|
||||||
|
|
||||||
/* This is the menuitem for the current location, which is the first
|
if (obj->priv->current_location != item)
|
||||||
to be added to the menu */
|
|
||||||
widget = obj->priv->current_location_menu_item;
|
|
||||||
|
|
||||||
while (obj->priv->current_location != item)
|
|
||||||
{
|
{
|
||||||
if (widget)
|
obj->priv->current_location = iter_func (obj->priv->current_location);
|
||||||
{
|
|
||||||
/* 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;
|
|
||||||
|
|
||||||
if (obj->priv->current_location == NULL)
|
if (obj->priv->current_location == NULL)
|
||||||
{
|
{
|
||||||
obj->priv->current_location = obj->priv->locations;
|
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);
|
g_assert (obj->priv->current_location != NULL);
|
||||||
|
|
||||||
|
@ -1715,9 +1574,6 @@ jump_to_location (XedFileBrowserWidget *obj,
|
||||||
static void
|
static void
|
||||||
clear_next_locations (XedFileBrowserWidget *obj)
|
clear_next_locations (XedFileBrowserWidget *obj)
|
||||||
{
|
{
|
||||||
GList *children;
|
|
||||||
GList *item;
|
|
||||||
|
|
||||||
if (obj->priv->current_location == NULL)
|
if (obj->priv->current_location == NULL)
|
||||||
{
|
{
|
||||||
return;
|
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);
|
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,
|
gtk_action_set_sensitive (gtk_action_group_get_action (obj->priv->action_group_sensitive,
|
||||||
"DirectoryNext"), FALSE);
|
"DirectoryNext"), FALSE);
|
||||||
}
|
}
|
||||||
|
@ -2614,15 +2461,6 @@ on_virtual_root_changed (XedFileBrowserStore *model,
|
||||||
loc = g_slice_new (Location);
|
loc = g_slice_new (Location);
|
||||||
loc->root = xed_file_browser_store_get_root (model);
|
loc->root = xed_file_browser_store_get_root (model);
|
||||||
loc->virtual_root = g_object_ref (location);
|
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);
|
obj->priv->locations = g_list_prepend (obj->priv->locations, loc);
|
||||||
|
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (model),
|
gtk_tree_model_get (GTK_TREE_MODEL (model),
|
||||||
|
@ -2631,11 +2469,6 @@ on_virtual_root_changed (XedFileBrowserStore *model,
|
||||||
&pixbuf, -1);
|
&pixbuf, -1);
|
||||||
|
|
||||||
obj->priv->current_location = obj->priv->locations;
|
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)
|
if (pixbuf)
|
||||||
{
|
{
|
||||||
|
@ -2690,12 +2523,7 @@ on_model_set (GObject *gobject,
|
||||||
{
|
{
|
||||||
GtkAction *action;
|
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 = NULL;
|
||||||
obj->priv->current_location_menu_item = NULL;
|
|
||||||
|
|
||||||
action = gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryPrevious");
|
action = gtk_action_group_get_action (obj->priv->action_group_sensitive, "DirectoryPrevious");
|
||||||
gtk_action_set_sensitive (action, TRUE);
|
gtk_action_set_sensitive (action, TRUE);
|
||||||
|
@ -2914,27 +2742,6 @@ on_entry_filter_activate (XedFileBrowserWidget *obj)
|
||||||
return FALSE;
|
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
|
static void
|
||||||
on_bookmarks_row_changed (GtkTreeModel *model,
|
on_bookmarks_row_changed (GtkTreeModel *model,
|
||||||
GtkTreePath *path,
|
GtkTreePath *path,
|
||||||
|
|
Loading…
Reference in New Issue