[nautilus/wip/apoos-maximus/gsoc2020: 4/29] properties-window: Add composite widget template




commit f754f758f901427d668a84745918df8923a852fc
Author: Apoorv Sachan <apoorv 99 sachan gmail com>
Date:   Sun May 24 20:43:28 2020 +0530

    properties-window: Add composite widget template
    
    For now, only the outermost containers, GtkWindow down to GtkNotebook,
    have been defined in the GtkBuilder UI file.
    
    The Basic, Permissions, and Open With tabs, along with their content,
    are still built and inserted programaically. They are going to be
    ported accross the next series commits.

 src/nautilus-properties-window.c               | 33 ++++++++---------
 src/resources/nautilus.gresource.xml           |  1 +
 src/resources/ui/nautilus-properties-window.ui | 49 ++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 19 deletions(-)
---
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 8e3b23d03..b4dc4d762 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -5047,11 +5047,8 @@ create_properties_window (StartupData *startup_data)
 {
     NautilusPropertiesWindow *window;
     GList *l;
-    GtkWidget *content_box;
 
     window = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_new (NAUTILUS_TYPE_PROPERTIES_WINDOW,
-                                                         "type-hint", GDK_WINDOW_TYPE_HINT_DIALOG,
-                                                         "modal", TRUE,
                                                          NULL));
 
     window->original_files = nautilus_file_list_copy (startup_data->original_files);
@@ -5133,17 +5130,6 @@ create_properties_window (StartupData *startup_data)
                                  0);
     }
 
-    /* Create the notebook tabs. */
-    content_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-    window->notebook = GTK_NOTEBOOK (gtk_notebook_new ());
-    gtk_notebook_set_show_border (window->notebook, FALSE);
-    gtk_container_add (GTK_CONTAINER (window), content_box);
-    gtk_widget_show (GTK_WIDGET (window->notebook));
-    gtk_box_pack_start (GTK_BOX (content_box),
-                        GTK_WIDGET (window->notebook),
-                        TRUE, TRUE, 0);
-    gtk_widget_show (GTK_WIDGET (content_box));
-
     /* Create the pages. */
     create_basic_page (window);
 
@@ -5778,26 +5764,35 @@ select_image_button_callback (GtkWidget                *widget,
 }
 
 static void
-nautilus_properties_window_class_init (NautilusPropertiesWindowClass *class)
+nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass)
 {
     GtkBindingSet *binding_set;
+    GtkWidgetClass *widget_class;
+    GObjectClass *oclass;
 
-    G_OBJECT_CLASS (class)->finalize = real_finalize;
-    GTK_WIDGET_CLASS (class)->destroy = real_destroy;
+    widget_class = GTK_WIDGET_CLASS (klass);
+    oclass = G_OBJECT_CLASS (klass);
+    oclass->finalize = real_finalize;
+    widget_class->destroy = real_destroy;
 
-    binding_set = gtk_binding_set_by_class (class);
+    binding_set = gtk_binding_set_by_class (klass);
     g_signal_new ("close",
-                  G_OBJECT_CLASS_TYPE (class),
+                  G_OBJECT_CLASS_TYPE (klass),
                   G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
                   0, NULL, NULL,
                   g_cclosure_marshal_VOID__VOID,
                   G_TYPE_NONE, 0);
     gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0,
                                   "close", 0);
+
+    gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/nautilus/ui/nautilus-properties-window.ui");
+
+    gtk_widget_class_bind_template_child (widget_class, NautilusPropertiesWindow, notebook);
 }
 
 static void
 nautilus_properties_window_init (NautilusPropertiesWindow *window)
 {
+    gtk_widget_init_template (GTK_WIDGET (window));
     g_signal_connect (window, "close", G_CALLBACK (gtk_window_close), NULL);
 }
diff --git a/src/resources/nautilus.gresource.xml b/src/resources/nautilus.gresource.xml
index e89c9c78f..75dc62d46 100644
--- a/src/resources/nautilus.gresource.xml
+++ b/src/resources/nautilus.gresource.xml
@@ -20,6 +20,7 @@
     <file>gtk/help-overlay.ui</file>
     <file>ui/nautilus-batch-rename-dialog.ui</file>
     <file>ui/nautilus-batch-rename-dialog-menu.ui</file>
+    <file>ui/nautilus-properties-window.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesview.ui">../gtk/nautilusgtkplacesview.ui</file>
     <file alias="gtk/ui/nautilusgtkplacesviewrow.ui">../gtk/nautilusgtkplacesviewrow.ui</file>
     <file alias="icons/thumbnail_frame.png">../../icons/thumbnail_frame.png</file>
diff --git a/src/resources/ui/nautilus-properties-window.ui b/src/resources/ui/nautilus-properties-window.ui
new file mode 100644
index 000000000..22bda2da6
--- /dev/null
+++ b/src/resources/ui/nautilus-properties-window.ui
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.2 -->
+<interface>
+  <requires lib="gtk+" version="3.20"/>
+  <template class="NautilusPropertiesWindow" parent="GtkWindow">
+    <property name="can_focus">False</property>
+    <property name="modal">True</property>
+    <property name="type_hint">dialog</property>
+    <child type="titlebar">
+      <placeholder/>
+    </child>
+    <child>
+      <object class="GtkBox" id="content_box">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <child>
+          <object class="GtkNotebook" id="notebook">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="show_border">False</property>
+            <child>
+              <placeholder/>
+            </child>
+            <child type="tab">
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child type="tab">
+              <placeholder/>
+            </child>
+            <child>
+              <placeholder/>
+            </child>
+            <child type="tab">
+              <placeholder/>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>


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