forked from AuroraMiddleware/gtk
file chooser: Use a revealer
Use a revealer to manage the visibility of the header area where we show the pathbar, the location entry or search. This is a bit smoother, and makes search more similar to a search bar.
This commit is contained in:
parent
15bb9acc8a
commit
916cf8f61e
@ -83,6 +83,7 @@
|
||||
#include "gtkscrollable.h"
|
||||
#include "gtkadjustment.h"
|
||||
#include "gtkpopover.h"
|
||||
#include "gtkrevealer.h"
|
||||
|
||||
#include <cairo-gobject.h>
|
||||
#include <errno.h>
|
||||
@ -214,6 +215,7 @@ struct _GtkFileChooserWidgetPrivate {
|
||||
/* The file browsing widgets */
|
||||
GtkWidget *browse_widgets_box;
|
||||
GtkWidget *browse_widgets_hpaned;
|
||||
GtkWidget *browse_header_revealer;
|
||||
GtkWidget *browse_header_box;
|
||||
GtkWidget *browse_header_stack;
|
||||
GtkWidget *browse_files_box;
|
||||
@ -2152,11 +2154,7 @@ location_switch_to_filename_entry (GtkFileChooserWidget *impl)
|
||||
priv->operation_mode == OPERATION_MODE_RECENT)
|
||||
return;
|
||||
|
||||
/* Box */
|
||||
|
||||
gtk_widget_show (priv->browse_header_box);
|
||||
|
||||
/* Entry */
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), TRUE);
|
||||
|
||||
if (!priv->location_entry)
|
||||
{
|
||||
@ -2164,12 +2162,8 @@ location_switch_to_filename_entry (GtkFileChooserWidget *impl)
|
||||
gtk_box_pack_start (GTK_BOX (priv->location_entry_box), priv->location_entry, TRUE, TRUE, 0);
|
||||
}
|
||||
|
||||
/* Configure the entry */
|
||||
|
||||
_gtk_file_chooser_entry_set_base_folder (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), priv->current_folder);
|
||||
|
||||
/* Done */
|
||||
|
||||
gtk_widget_show (priv->location_entry);
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "location");
|
||||
@ -2482,8 +2476,6 @@ location_bar_update (GtkFileChooserWidget *impl)
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_set_visible (priv->browse_header_box, visible);
|
||||
|
||||
if (visible)
|
||||
{
|
||||
if (priv->create_folders
|
||||
@ -2531,6 +2523,7 @@ operation_mode_set_enter_location (GtkFileChooserWidget *impl)
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "location");
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), TRUE);
|
||||
location_bar_update (impl);
|
||||
gtk_widget_set_sensitive (priv->filter_combo, TRUE);
|
||||
location_mode_set (impl, LOCATION_MODE_FILENAME_ENTRY);
|
||||
@ -2544,6 +2537,7 @@ operation_mode_set_browse (GtkFileChooserWidget *impl)
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), TRUE);
|
||||
location_bar_update (impl);
|
||||
gtk_widget_set_sensitive (priv->filter_combo, TRUE);
|
||||
gtk_tree_view_column_set_visible (priv->list_location_column, FALSE);
|
||||
@ -2559,6 +2553,7 @@ operation_mode_set_search (GtkFileChooserWidget *impl)
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "search");
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), TRUE);
|
||||
location_bar_update (impl);
|
||||
search_setup_widgets (impl);
|
||||
gtk_entry_grab_focus_without_selecting (GTK_ENTRY (priv->search_entry));
|
||||
@ -2582,6 +2577,7 @@ operation_mode_set_recent (GtkFileChooserWidget *impl)
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "list");
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_header_stack), "pathbar");
|
||||
gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), FALSE);
|
||||
location_bar_update (impl);
|
||||
recent_start_loading (impl);
|
||||
file = g_file_new_for_uri ("recent:///");
|
||||
@ -7508,6 +7504,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
|
||||
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_revealer);
|
||||
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);
|
||||
|
@ -19,7 +19,6 @@
|
||||
<property name="hscrollbar_policy">never</property>
|
||||
<property name="local_only">True</property>
|
||||
<property name="show_enter_location">True</property>
|
||||
<property name="show_recent">True</property>
|
||||
<style>
|
||||
<class name="sidebar"/>
|
||||
</style>
|
||||
@ -37,109 +36,116 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<child>
|
||||
<object class="GtkBox" id="browse_header_box">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<style>
|
||||
<class name="search-bar"/>
|
||||
</style>
|
||||
<object class="GtkRevealer" id="browse_header_revealer">
|
||||
<property name="visible">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<child>
|
||||
<object class="GtkStack" id="browse_header_stack">
|
||||
<object class="GtkBox" id="browse_header_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="spacing">12</property>
|
||||
<style>
|
||||
<class name="search-bar"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkBox" id="browse_path_bar_hbox">
|
||||
<object class="GtkStack" id="browse_header_stack">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<object class="GtkPathBar" id="browse_path_bar">
|
||||
<object class="GtkBox" id="browse_path_bar_hbox">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<signal name="path-clicked" handler="path_bar_clicked" after="yes" swapped="no"/>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
<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>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="browse_new_folder_button">
|
||||
<property name="label" translatable="yes">Create _Folder</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="popover">new_folder_popover</property>
|
||||
<signal name="notify::active" handler="new_folder_popover_active"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">True</property>
|
||||
<property name="name">pathbar</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkMenuButton" id="browse_new_folder_button">
|
||||
<property name="label" translatable="yes">Create _Folder</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="popover">new_folder_popover</property>
|
||||
<signal name="notify::active" handler="new_folder_popover_active"/>
|
||||
<object class="GtkBox" id="location_entry_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="no-show-all">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">False</property>
|
||||
<property name="pack_type">end</property>
|
||||
<property name="position">1</property>
|
||||
<property name="name">location</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="search_entry_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="no-show-all">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<signal name="search-changed" handler="search_entry_activate_cb" swapped="yes"/>
|
||||
<signal name="stop-search" handler="search_entry_stop_cb" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="current_location_radio">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="label" translatable="yes">Home</property>
|
||||
<signal name="toggled" handler="search_entry_activate_cb" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="group">current_location_radio</property>
|
||||
<property name="label" translatable="yes">All Files</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">search</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="no-show-all">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">location</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="search_entry_box">
|
||||
<property name="visible">True</property>
|
||||
<property name="no-show-all">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<property name="border_width">6</property>
|
||||
<child>
|
||||
<object class="GtkSearchEntry" id="search_entry">
|
||||
<property name="visible">True</property>
|
||||
<property name="hexpand">True</property>
|
||||
<signal name="search-changed" handler="search_entry_activate_cb" swapped="yes"/>
|
||||
<signal name="stop-search" handler="search_entry_stop_cb" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">True</property>
|
||||
<style>
|
||||
<class name="linked"/>
|
||||
</style>
|
||||
<child>
|
||||
<object class="GtkRadioButton" id="current_location_radio">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="label" translatable="yes">Home</property>
|
||||
<signal name="toggled" handler="search_entry_activate_cb" swapped="yes"/>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkRadioButton">
|
||||
<property name="visible">True</property>
|
||||
<property name="draw-indicator">False</property>
|
||||
<property name="group">current_location_radio</property>
|
||||
<property name="label" translatable="yes">All Files</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">search</property>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="fill">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
|
Loading…
Reference in New Issue
Block a user