[nautilus/placesview-update: 2/2] places-view: Update to latest gtk code



commit 2ad480f9cf470bc4c944adfc36dee332484b0b52
Author: Carlos Soriano <csoriano redhat com>
Date:   Tue Jan 22 16:57:36 2019 +0100

    places-view: Update to latest gtk code

 src/gtk/nautilusgtkplacesview.c           |  59 +++++++++++++
 src/gtk/nautilusgtkplacesview.ui          | 136 +-----------------------------
 src/gtk/nautilusgtkplacesviewprivate.h    |   3 +-
 src/gtk/nautilusgtkplacesviewrowprivate.h |  11 ++-
 4 files changed, 72 insertions(+), 137 deletions(-)
---
diff --git a/src/gtk/nautilusgtkplacesview.c b/src/gtk/nautilusgtkplacesview.c
index b72085ba9..11735a8a1 100644
--- a/src/gtk/nautilusgtkplacesview.c
+++ b/src/gtk/nautilusgtkplacesview.c
@@ -71,6 +71,7 @@ struct _NautilusGtkPlacesViewPrivate
   GtkWidget                     *recent_servers_stack;
   GtkWidget                     *stack;
   GtkWidget                     *server_adresses_popover;
+  GtkWidget                     *available_protocols_grid;
   GtkWidget                     *network_placeholder;
   GtkWidget                     *network_placeholder_label;
 
@@ -1604,6 +1605,54 @@ unmount_cb (GtkMenuItem      *item,
   unmount_mount (NAUTILUS_GTK_PLACES_VIEW (view), mount);
 }
 
+static void
+attach_protocol_row_to_grid (GtkGrid     *grid,
+                             const gchar *protocol_name,
+                             const gchar *protocol_prefix)
+{
+  GtkWidget *name_label;
+  GtkWidget *prefix_label;
+
+  name_label = gtk_label_new (protocol_name);
+  gtk_widget_set_halign (name_label, GTK_ALIGN_START);
+  gtk_grid_attach_next_to (grid, name_label, NULL, GTK_POS_BOTTOM, 1, 1);
+
+  prefix_label = gtk_label_new (protocol_prefix);
+  gtk_widget_set_halign (prefix_label, GTK_ALIGN_START);
+  gtk_grid_attach_next_to (grid, prefix_label, name_label, GTK_POS_RIGHT, 1, 1);
+}
+
+static void
+populate_available_protocols_grid (GtkGrid *grid)
+{
+  const gchar* const *supported_protocols;
+
+  supported_protocols = g_vfs_get_supported_uri_schemes (g_vfs_get_default ());
+
+  if (g_strv_contains (supported_protocols, "afp"))
+    attach_protocol_row_to_grid (grid, _("AppleTalk"), "afp://");
+
+  if (g_strv_contains (supported_protocols, "ftp"))
+    /* Translators: do not translate ftp:// and ftps:// */
+    attach_protocol_row_to_grid (grid, _("File Transfer Protocol"), _("ftp:// or ftps://"));
+
+  if (g_strv_contains (supported_protocols, "nfs"))
+    attach_protocol_row_to_grid (grid, _("Network File System"), "nfs://");
+
+  if (g_strv_contains (supported_protocols, "smb"))
+    attach_protocol_row_to_grid (grid, _("Samba"), "smb://");
+
+  if (g_strv_contains (supported_protocols, "ssh"))
+    /* Translators: do not translate sftp:// and ssh:// */
+    attach_protocol_row_to_grid (grid, _("SSH File Transfer Protocol"), _("sftp:// or ssh://"));
+
+  if (g_strv_contains (supported_protocols, "dav"))
+    /* Translators: do not translate dav:// and davs:// */
+    attach_protocol_row_to_grid (grid, _("WebDAV"), _("dav:// or davs://"));
+
+  gtk_widget_show_all (GTK_WIDGET (grid));
+}
+
 /* Constructs the popup menu if needed */
 static void
 build_popup_menu (NautilusGtkPlacesView    *view,
@@ -1854,6 +1903,13 @@ on_address_entry_text_changed (NautilusGtkPlacesView *view)
 
 out:
   gtk_widget_set_sensitive (priv->connect_button, supported);
+  if (scheme && !supported)
+    gtk_style_context_add_class (gtk_widget_get_style_context (priv->address_entry),
+                                 GTK_STYLE_CLASS_ERROR);
+  else
+    gtk_style_context_remove_class (gtk_widget_get_style_context (priv->address_entry),
+                                    GTK_STYLE_CLASS_ERROR);
+
   g_free (address);
   g_free (scheme);
 }
@@ -2301,6 +2357,7 @@ nautilus_gtk_places_view_class_init (NautilusGtkPlacesViewClass *klass)
   gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, recent_servers_stack);
   gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, stack);
   gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, 
server_adresses_popover);
+  gtk_widget_class_bind_template_child_private (widget_class, NautilusGtkPlacesView, 
available_protocols_grid);
 
   gtk_widget_class_bind_template_callback (widget_class, on_address_entry_text_changed);
   gtk_widget_class_bind_template_callback (widget_class, on_address_entry_show_help_pressed);
@@ -2325,6 +2382,8 @@ nautilus_gtk_places_view_init (NautilusGtkPlacesView *self)
   priv->space_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
   gtk_widget_init_template (GTK_WIDGET (self));
+
+  populate_available_protocols_grid (GTK_GRID (priv->available_protocols_grid));
 }
 
 /**
diff --git a/src/gtk/nautilusgtkplacesview.ui b/src/gtk/nautilusgtkplacesview.ui
index 737b3349a..c5e785854 100644
--- a/src/gtk/nautilusgtkplacesview.ui
+++ b/src/gtk/nautilusgtkplacesview.ui
@@ -65,7 +65,7 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid">
+          <object class="GtkGrid" id="available_protocols_grid">
             <property name="visible">1</property>
             <property name="margin-top">12</property>
             <property name="hexpand">1</property>
@@ -86,72 +86,6 @@
                 <property name="top-attach">0</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">AppleTalk</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">File Transfer Protocol</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">Network File System</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">Samba</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">SSH File Transfer Protocol</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">WebDAV</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">6</property>
-              </packing>
-            </child>
             <child>
               <object class="GtkLabel">
                 <property name="visible">1</property>
@@ -166,72 +100,6 @@
                 <property name="top-attach">0</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label">afp://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes" comments="Translators: do not translate ftp:// and 
ftps://">ftp:// or ftps://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label">nfs://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">3</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes">smb://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">4</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes" comments="Translators: do not translate sftp:// 
and ssh://">sftp:// or ssh://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">5</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">1</property>
-                <property name="label" translatable="yes" comments="Translators: do not translate dav:// and 
davs://">dav:// or davs://</property>
-                <property name="xalign">0</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">6</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="position">3</property>
@@ -380,7 +248,7 @@
             <child>
               <object class="GtkImage">
                 <property name="visible">1</property>
-                <property name="pixel-size">80</property>
+                <property name="pixel-size">72</property>
                 <property name="icon-name">edit-find-symbolic</property>
                 <style>
                   <class name="dim-label"/>
diff --git a/src/gtk/nautilusgtkplacesviewprivate.h b/src/gtk/nautilusgtkplacesviewprivate.h
index b9506b73a..92f1dd92f 100644
--- a/src/gtk/nautilusgtkplacesviewprivate.h
+++ b/src/gtk/nautilusgtkplacesviewprivate.h
@@ -22,6 +22,7 @@
 #if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
 #endif
 
+
 G_BEGIN_DECLS
 
 #define NAUTILUS_TYPE_GTK_PLACES_VIEW        (nautilus_gtk_places_view_get_type ())
@@ -79,4 +80,4 @@ GtkWidget *        nautilus_gtk_places_view_new                           (void)
 
 G_END_DECLS
 
-#endif
\ No newline at end of file
+#endif /* NAUTILUS_GTK_PLACES_VIEW_H */
diff --git a/src/gtk/nautilusgtkplacesviewrowprivate.h b/src/gtk/nautilusgtkplacesviewrowprivate.h
index 8d6fb9fcd..fb32e1c67 100644
--- a/src/gtk/nautilusgtkplacesviewrowprivate.h
+++ b/src/gtk/nautilusgtkplacesviewrowprivate.h
@@ -16,7 +16,12 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#pragma once
+#ifndef NAUTILUS_GTK_PLACES_VIEW_ROW_H
+#define NAUTILUS_GTK_PLACES_VIEW_ROW_H
+
+#if !defined (__GTK_H_INSIDE__) && !defined (GTK_COMPILATION)
+#endif
+
 
 G_BEGIN_DECLS
 
@@ -51,4 +56,6 @@ void               nautilus_gtk_places_view_row_set_path_size_group       (Nauti
 void               nautilus_gtk_places_view_row_set_space_size_group      (NautilusGtkPlacesViewRow   *row,
                                                                   GtkSizeGroup       *group);
 
-G_END_DECLS
\ No newline at end of file
+G_END_DECLS
+
+#endif /* NAUTILUS_GTK_PLACES_VIEW_ROW_H */


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