[gtk+/wip/gbsneto/other-locations] filechooserwidget: use places view to manage fixed devices



commit 202e285e915cad32905accbf832c99cfd0735b3e
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Jul 5 22:28:53 2015 -0300

    filechooserwidget: use places view to manage fixed devices
    
    The file chooser widget is the base implementation for many
    file management widgets in Gtk+, and provides the core user
    interface used throughout other widgets.
    
    Previous changes introduced GtkPlacesView, a widget crafted
    specifically to manage permanent devices and networks, and
    modified the places sidebar widget to stop handling fixed
    devices by adding an "Other Locations..." item. Up to now,
    however, these changes are isolated from each other since
    the bundled file manager widgets ignore the sidebar requests
    for external management of fixed devices and networks.
    
    To fix that, make the file chooser widget be aware of the
    GtkPlacesSidebar::show-other-locations signal and, when
    requested, show places view to manage the fixed devices.

 gtk/gtkfilechooserwidget.c     |   20 ++++++++++++++++++++
 gtk/ui/gtkfilechooserwidget.ui |   13 +++++++++++++
 2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index aa9ecda..66c734f 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -56,6 +56,7 @@
 #include "gtkpathbar.h"
 #include "gtkplacessidebar.h"
 #include "gtkplacessidebarprivate.h"
+#include "gtkplacesview.h"
 #include "gtkprivate.h"
 #include "gtkrecentmanager.h"
 #include "gtkscrolledwindow.h"
@@ -256,6 +257,7 @@ struct _GtkFileChooserWidgetPrivate {
   char *browse_files_last_selected_name;
 
   GtkWidget *places_sidebar;
+  GtkWidget *places_view;
   StartupMode startup_mode;
 
   /* OPERATION_MODE_SEARCH */
@@ -2683,6 +2685,21 @@ location_mode_set (GtkFileChooserWidget *impl,
   g_object_notify (G_OBJECT (impl), "subtitle");
 }
 
+/* Callback used when the places sidebar asks us to show other locations */
+static void
+places_sidebar_show_other_locations_cb (GtkPlacesSidebar     *sidebar,
+                                        GtkFileChooserWidget *impl)
+{
+  GtkFileChooserWidgetPrivate *priv = impl->priv;
+
+  gtk_stack_set_visible_child_name (GTK_STACK (priv->browse_files_stack), "other_locations");
+
+  priv->preview_widget_active = FALSE;
+
+  gtk_revealer_set_reveal_child (GTK_REVEALER (priv->browse_header_revealer), FALSE);
+  update_preview_widget_visibility (impl);
+}
+
 static void
 location_toggle_popup_handler (GtkFileChooserWidget *impl)
 {
@@ -2809,6 +2826,7 @@ set_local_only (GtkFileChooserWidget *impl,
         _gtk_file_chooser_entry_set_local_only (GTK_FILE_CHOOSER_ENTRY (priv->location_entry), local_only);
 
       gtk_places_sidebar_set_local_only (GTK_PLACES_SIDEBAR (priv->places_sidebar), local_only);
+      gtk_places_view_set_local_only (GTK_PLACES_VIEW (priv->places_view), local_only);
 
       if (local_only && priv->current_folder &&
            !_gtk_file_has_native_path (priv->current_folder))
@@ -8161,6 +8179,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
   gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_widgets_hpaned);
   gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, browse_files_stack);
   gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, places_sidebar);
+  gtk_widget_class_bind_template_child_private (widget_class, GtkFileChooserWidget, places_view);
   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_stack);
@@ -8211,6 +8230,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
   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_other_locations_cb);
   gtk_widget_class_bind_template_callback (widget_class, search_entry_activate_cb);
   gtk_widget_class_bind_template_callback (widget_class, search_entry_stop_cb);
   gtk_widget_class_bind_template_callback (widget_class, new_folder_popover_active);
diff --git a/gtk/ui/gtkfilechooserwidget.ui b/gtk/ui/gtkfilechooserwidget.ui
index 8389bff..7b1dfbc 100644
--- a/gtk/ui/gtkfilechooserwidget.ui
+++ b/gtk/ui/gtkfilechooserwidget.ui
@@ -17,11 +17,13 @@
                 <property name="can_focus">False</property>
                 <property name="hscrollbar_policy">never</property>
                 <property name="local_only">True</property>
+                <property name="show_other_locations">True</property>
                 <style>
                   <class name="sidebar"/>
                 </style>
                 <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-other-locations" handler="places_sidebar_show_other_locations_cb" 
swapped="no"/
               </object>
               <packing>
                 <property name="resize">False</property>
@@ -240,6 +242,17 @@
                           </packing>
                         </child>
                         <child>
+                          <object class="GtkPlacesView" id="places_view">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="local_only">True</property>
+                            <signal name="open-location" handler="places_sidebar_open_location_cb" 
swapped="no"/>
+                          </object>
+                          <packing>
+                            <property name="name">other_locations</property>
+                          </packing>
+                        </child>
+                        <child>
                           <object class="GtkGrid">
                             <property name="visible">True</property>
                             <property name="row_spacing">12</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]