file-chooser: move location entry into same place as pathbar

https://bugzilla.gnome.org/show_bug.cgi?id=722211
This commit is contained in:
William Jon McCann 2014-04-08 13:13:01 -04:00 committed by Matthias Clasen
parent 1e925a85ca
commit 5c42068bb3
3 changed files with 163 additions and 213 deletions

View File

@ -34,6 +34,7 @@
#include "gtkclipboard.h"
#include "gtkcomboboxtext.h"
#include "gtkentry.h"
#include "gtkstack.h"
#include "gtkexpander.h"
#include "gtkfilechooserprivate.h"
#include "gtkfilechooserdialog.h"
@ -205,6 +206,7 @@ struct _GtkFileChooserWidgetPrivate {
GtkWidget *browse_widgets_box;
GtkWidget *browse_widgets_hpaned;
GtkWidget *browse_header_box;
GtkWidget *browse_header_stack;
GtkWidget *browse_files_box;
GtkWidget *browse_files_tree_view;
GtkWidget *browse_files_popup_menu;
@ -249,7 +251,6 @@ struct _GtkFileChooserWidgetPrivate {
GtkWidget *extra_align;
GtkWidget *extra_widget;
GtkWidget *location_button;
GtkWidget *location_entry_box;
GtkWidget *location_label;
GtkWidget *location_entry;
@ -484,6 +485,7 @@ static void recent_shortcut_handler (GtkFileChooserWidget *impl);
static void update_appearance (GtkFileChooserWidget *impl);
static void operation_mode_set (GtkFileChooserWidget *impl, OperationMode mode);
static void location_mode_set (GtkFileChooserWidget *impl, LocationMode new_mode);
static void set_current_filter (GtkFileChooserWidget *impl,
GtkFileFilter *filter);
@ -516,8 +518,6 @@ static void update_cell_renderer_attributes (GtkFileChooserWidget *impl);
static void load_remove_timer (GtkFileChooserWidget *impl, LoadState new_load_state);
static void browse_files_center_selected_row (GtkFileChooserWidget *impl);
static void location_button_toggled_cb (GtkToggleButton *toggle,
GtkFileChooserWidget *impl);
static void location_switch_to_path_bar (GtkFileChooserWidget *impl);
static void stop_loading_and_clear_list_model (GtkFileChooserWidget *impl,
@ -1143,6 +1143,8 @@ places_sidebar_open_location_cb (GtkPlacesSidebar *sidebar, GFile *location, Gtk
* in Nautilus, and do operation_mode_set (impl, OPERATION_MODE_SEARCH);
*/
location_mode_set (impl, LOCATION_MODE_PATH_BAR);
if (file_is_recent_uri (location))
operation_mode_set (impl, OPERATION_MODE_RECENT);
else
@ -2027,7 +2029,7 @@ location_switch_to_path_bar (GtkFileChooserWidget *impl)
priv->location_entry = NULL;
}
gtk_widget_hide (priv->browse_header_box);
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
}
/* Turns on the location entry. Can be called even if we are already in that
@ -2066,16 +2068,17 @@ location_switch_to_filename_entry (GtkFileChooserWidget *impl)
/* Done */
gtk_widget_show (priv->location_entry);
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "location");
gtk_widget_grab_focus (priv->location_entry);
}
/* Sets a new location mode. set_buttons determines whether the toggle button
* for the mode will also be changed.
/* Sets a new location mode.
*/
static void
location_mode_set (GtkFileChooserWidget *impl,
LocationMode new_mode,
gboolean set_button)
LocationMode new_mode)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
@ -2084,13 +2087,11 @@ location_mode_set (GtkFileChooserWidget *impl,
{
GtkWindow *toplevel;
GtkWidget *current_focus;
gboolean button_active;
gboolean switch_to_file_list;
switch (new_mode)
{
case LOCATION_MODE_PATH_BAR:
button_active = FALSE;
/* The location_entry will disappear when we switch to path bar mode. So,
* we'll focus the file list in that case, to avoid having a window with
@ -2113,7 +2114,6 @@ location_mode_set (GtkFileChooserWidget *impl,
break;
case LOCATION_MODE_FILENAME_ENTRY:
button_active = TRUE;
location_switch_to_filename_entry (impl);
break;
@ -2121,22 +2121,19 @@ location_mode_set (GtkFileChooserWidget *impl,
g_assert_not_reached ();
return;
}
if (set_button)
{
g_signal_handlers_block_by_func (priv->location_button,
G_CALLBACK (location_button_toggled_cb), impl);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->location_button), button_active);
g_signal_handlers_unblock_by_func (priv->location_button,
G_CALLBACK (location_button_toggled_cb), impl);
}
}
priv->location_mode = new_mode;
}
/* Callback used when the places sidebar needs us to enter a location */
static void
places_sidebar_show_enter_location_cb (GtkPlacesSidebar *sidebar,
GtkFileChooserWidget *impl)
{
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
}
static void
location_toggle_popup_handler (GtkFileChooserWidget *impl)
{
@ -2155,13 +2152,13 @@ location_toggle_popup_handler (GtkFileChooserWidget *impl)
*/
if (priv->location_mode == LOCATION_MODE_PATH_BAR)
{
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
}
else if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
{
if (gtk_widget_has_focus (priv->location_entry))
{
location_mode_set (impl, LOCATION_MODE_PATH_BAR, TRUE);
location_mode_set (impl, LOCATION_MODE_PATH_BAR);
}
else
{
@ -2170,31 +2167,6 @@ location_toggle_popup_handler (GtkFileChooserWidget *impl)
}
}
/* Callback used when one of the location mode buttons is toggled */
static void
location_button_toggled_cb (GtkToggleButton *toggle,
GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
gboolean is_active;
LocationMode new_mode;
is_active = gtk_toggle_button_get_active (toggle);
if (is_active)
{
g_assert (priv->location_mode == LOCATION_MODE_PATH_BAR);
new_mode = LOCATION_MODE_FILENAME_ENTRY;
}
else
{
g_assert (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY);
new_mode = LOCATION_MODE_PATH_BAR;
}
location_mode_set (impl, new_mode, FALSE);
}
typedef enum {
PATH_BAR_FOLDER_PATH,
PATH_BAR_SELECT_A_FOLDER,
@ -2583,11 +2555,9 @@ operation_mode_set_browse (GtkFileChooserWidget *impl)
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
gtk_widget_show (priv->location_button);
location_mode_set (impl, priv->location_mode, TRUE);
location_mode_set (impl, priv->location_mode);
if (priv->location_mode == LOCATION_MODE_FILENAME_ENTRY)
gtk_widget_show (priv->browse_header_box);
gtk_widget_show (priv->browse_header_box);
}
}
@ -2614,7 +2584,6 @@ operation_mode_set_recent (GtkFileChooserWidget *impl)
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
gtk_widget_hide (priv->location_button);
gtk_widget_hide (priv->browse_header_box);
}
@ -2669,7 +2638,6 @@ update_appearance (GtkFileChooserWidget *impl)
{
const char *text;
gtk_widget_hide (priv->location_button);
save_widgets_create (impl);
if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE)
@ -2689,9 +2657,8 @@ update_appearance (GtkFileChooserWidget *impl)
else if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
gtk_widget_show (priv->location_button);
save_widgets_destroy (impl);
location_mode_set (impl, priv->location_mode, TRUE);
location_mode_set (impl, priv->location_mode);
}
if (priv->location_entry)
@ -3190,7 +3157,6 @@ static void
settings_load (GtkFileChooserWidget *impl)
{
GtkFileChooserWidgetPrivate *priv = impl->priv;
LocationMode location_mode;
gboolean show_hidden;
gboolean show_size_column;
gboolean sort_directories_first;
@ -3202,7 +3168,6 @@ settings_load (GtkFileChooserWidget *impl)
settings = _gtk_file_chooser_get_settings_for_widget (GTK_WIDGET (impl));
location_mode = g_settings_get_enum (settings, SETTINGS_KEY_LOCATION_MODE);
show_hidden = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_HIDDEN);
show_size_column = g_settings_get_boolean (settings, SETTINGS_KEY_SHOW_SIZE_COLUMN);
sort_column = g_settings_get_enum (settings, SETTINGS_KEY_SORT_COLUMN);
@ -3211,8 +3176,6 @@ settings_load (GtkFileChooserWidget *impl)
startup_mode = g_settings_get_enum (settings, SETTINGS_KEY_STARTUP_MODE);
sort_directories_first = g_settings_get_boolean (settings, SETTINGS_KEY_SORT_DIRECTORIES_FIRST);
location_mode_set (impl, location_mode, TRUE);
gtk_file_chooser_set_show_hidden (GTK_FILE_CHOOSER (impl), show_hidden);
priv->show_size_column = show_size_column;
@ -6441,7 +6404,6 @@ search_setup_widgets (GtkFileChooserWidget *impl)
if (priv->action == GTK_FILE_CHOOSER_ACTION_OPEN ||
priv->action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER)
{
gtk_widget_hide (priv->location_button);
gtk_widget_hide (priv->browse_header_box);
}
@ -7037,7 +6999,7 @@ location_popup_handler (GtkFileChooserWidget *impl,
if (!path)
return;
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY, TRUE);
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
location_set_user_text (impl, path);
}
else if (priv->action == GTK_FILE_CHOOSER_ACTION_SAVE ||
@ -7530,11 +7492,12 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
/* A *lot* of widgets that we need to handle .... */
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_hpaned);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, places_sidebar);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_tree_view);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_header_stack);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_new_folder_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_path_bar_hbox);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_path_bar_size_group);
@ -7548,7 +7511,6 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, filter_combo);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, preview_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, extra_align);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_button);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_entry_box);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, location_label);
gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, list_name_column);
@ -7570,11 +7532,11 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
gtk_widget_class_bind_template_callback (widget_class, renderer_editing_canceled_cb);
gtk_widget_class_bind_template_callback (widget_class, renderer_edited_cb);
gtk_widget_class_bind_template_callback (widget_class, filter_combo_changed);
gtk_widget_class_bind_template_callback (widget_class, location_button_toggled_cb);
gtk_widget_class_bind_template_callback (widget_class, new_folder_button_clicked);
gtk_widget_class_bind_template_callback (widget_class, path_bar_clicked);
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_open_location_cb);
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_show_error_message_cb);
gtk_widget_class_bind_template_callback (widget_class, places_sidebar_show_enter_location_cb);
}
static void

View File

@ -17,48 +17,6 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
<object class="GtkBox" id="browse_header_box">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="border_width">10</property>
<property name="spacing">12</property>
<child>
<object class="GtkBox" id="location_entry_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="location_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Location:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkPaned" id="browse_widgets_hpaned">
<property name="visible">True</property>
@ -71,8 +29,10 @@
<property name="hscrollbar_policy">never</property>
<property name="shadow_type">none</property>
<property name="local_only">True</property>
<property name="show_enter_location">True</property>
<signal name="open-location" handler="places_sidebar_open_location_cb" swapped="no"/>
<signal name="show-error-message" handler="places_sidebar_show_error_message_cb" swapped="no"/>
<signal name="show-enter-location" handler="places_sidebar_show_enter_location_cb" swapped="no"/>
</object>
<packing>
<property name="resize">False</property>
@ -86,58 +46,141 @@
<property name="orientation">vertical</property>
<property name="spacing">0</property>
<child>
<object class="GtkBox" id="browse_path_bar_hbox">
<property name="visible">True</property>
<object class="GtkBox" id="browse_header_box">
<property name="visible">False</property>
<property name="can_focus">False</property>
<property name="spacing">12</property>
<property name="orientation">vertical</property>
<property name="border_width">6</property>
<property name="spacing">12</property>
<child>
<object class="GtkToggleButton" id="location_button">
<object class="GtkStack" id="browse_header_stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Type a file name</property>
<property name="image">location_button_image</property>
<child internal-child="accessible">
<object class="AtkObject" id="location_button-atkobject">
<property name="AtkObject::accessible-name" translatable="yes">Type a file name</property>
</object>
</child>
<signal name="toggled" handler="location_button_toggled_cb" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkPathBar" id="browse_path_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<signal name="path-clicked" handler="path_bar_clicked" after="yes" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="browse_select_a_folder_info_bar">
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area1">
<property name="transition-type">crossfade</property>
<property name="transition-duration">200</property>
<child>
<object class="GtkBox" id="browse_path_bar_hbox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage" id="browse_select_a_folder_icon">
<object class="GtkPathBar" id="browse_path_bar">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">folder</property>
<property name="icon_size">1</property>
<signal name="path-clicked" handler="path_bar_clicked" after="yes" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkInfoBar" id="browse_select_a_folder_info_bar">
<property name="app_paintable">True</property>
<property name="can_focus">False</property>
<child internal-child="content_area">
<object class="GtkBox" id="infobar-content_area1">
<property name="can_focus">False</property>
<property name="border_width">8</property>
<property name="spacing">16</property>
<child>
<object class="GtkImage" id="browse_select_a_folder_icon">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="icon_name">folder</property>
<property name="icon_size">1</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="browse_select_a_folder_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">message</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="browse_special_mode_icon">
<property name="can_focus">False</property>
<property name="icon_name">image-missing</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="browse_special_mode_label">
<property name="can_focus">False</property>
<property name="label">special</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="browse_new_folder_button">
<property name="label" translatable="yes">Create Fo_lder</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="new_folder_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">5</property>
</packing>
</child>
</object>
<packing>
<property name="name">pathbar</property>
</packing>
</child>
<child>
<object class="GtkBox" id="location_entry_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no-show-all">True</property>
<property name="spacing">12</property>
<child>
<object class="GtkLabel" id="location_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">_Location:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
@ -146,77 +189,25 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="browse_select_a_folder_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label">message</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
<placeholder/>
</child>
</object>
</child>
<child internal-child="action_area">
<object class="GtkButtonBox" id="infobar-action_area1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<property name="layout_style">end</property>
</object>
<packing>
<property name="name">location</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkImage" id="browse_special_mode_icon">
<property name="can_focus">False</property>
<property name="icon_name">image-missing</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="browse_special_mode_label">
<property name="can_focus">False</property>
<property name="label">special</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">4</property>
</packing>
</child>
<child>
<object class="GtkButton" id="browse_new_folder_button">
<property name="label" translatable="yes">Create Fo_lder</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_underline">True</property>
<signal name="clicked" handler="new_folder_button_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">5</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@ -396,7 +387,6 @@
<object class="GtkSizeGroup" id="browse_path_bar_size_group">
<property name="mode">vertical</property>
<widgets>
<widget name="location_button"/>
<widget name="browse_path_bar"/>
<widget name="browse_select_a_folder_info_bar"/>
<widget name="browse_special_mode_icon"/>

View File

@ -1,7 +1,5 @@
N_("_Location:");
N_("Type a file name");
N_("Type a file name");
N_("Create Fo_lder");
N_("_Location:");
N_("Files");
N_("Name");
N_("Size");