[gtk+/composite-templates: 12/18] Reworked GtkDialog and GtkMessageDialog xml template into a GResource



commit 567114e055fee9dbe1e7a14826cfba5807177e23
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Mon Jul 2 17:51:47 2012 -0300

    Reworked GtkDialog and GtkMessageDialog xml template into a GResource

 gtk/Makefile.am                 |    3 +-
 gtk/gtk.gresource.xml           |    2 +
 gtk/gtkdialog.c                 |   29 +-------------
 gtk/gtkdialog.tmpl.glade        |   22 +++++++++++
 gtk/gtkmessagedialog.c          |   80 +--------------------------------------
 gtk/gtkmessagedialog.tmpl.glade |   74 ++++++++++++++++++++++++++++++++++++
 6 files changed, 104 insertions(+), 106 deletions(-)
---
diff --git a/gtk/Makefile.am b/gtk/Makefile.am
index 397fa4f..b335c0f 100644
--- a/gtk/Makefile.am
+++ b/gtk/Makefile.am
@@ -1112,7 +1112,8 @@ gtktypebuiltins.c: @REBUILD@ $(gtk_public_h_sources) $(deprecated_h_sources) gtk
 gtkresources.h: gtk.gresource.xml
 	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/gtk.gresource.xml \
 		--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-header --manual-register
-gtkresources.c: gtk.gresource.xml gtk-default.css gtk-win32.css gtk-win32-xp.css gtk-win32-base.css gtk-win32-classic.css $(DND_CURSORS)
+gtkresources.c: gtk.gresource.xml \
+         $(shell $(GLIB_COMPILE_RESOURCES) --generate-dependencies gtk.gresource.xml)
 	$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/gtk.gresource.xml \
 		--target=$@ --sourcedir=$(srcdir) --c-name _gtk --generate-source --manual-register
 
diff --git a/gtk/gtk.gresource.xml b/gtk/gtk.gresource.xml
index 939d35f..fb90f36 100644
--- a/gtk/gtk.gresource.xml
+++ b/gtk/gtk.gresource.xml
@@ -11,5 +11,7 @@
     <file alias="cursor/dnd-none.png">cursor_dnd_none.png</file>
     <file alias="cursor/dnd-move.png">cursor_dnd_move.png</file>
     <file alias="cursor/dnd-copy.png">cursor_dnd_copy.png</file>
+    <file preprocess="xml-stripblanks">gtkdialog.tmpl.glade</file>
+    <file preprocess="xml-stripblanks">gtkmessagedialog.tmpl.glade</file>
   </gresource>
 </gresources>
diff --git a/gtk/gtkdialog.c b/gtk/gtkdialog.c
index 4c19eef..0284bd2 100644
--- a/gtk/gtkdialog.c
+++ b/gtk/gtkdialog.c
@@ -207,31 +207,6 @@ static void      gtk_dialog_buildable_custom_finished    (GtkBuildable  *buildab
                                                           const gchar   *tagname,
                                                           gpointer       user_data);
 
-
-static const gchar *gtk_dialog_template =
-  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-  "<interface>"
-  "  <requires lib=\"gtk+\" version=\"2.20\"/>"
-  "  <child>"
-  "  <object class=\"GtkBox\" id=\"vbox\">"
-  "    <property name=\"visible\">True</property>"
-  "    <property name=\"orientation\">GTK_ORIENTATION_VERTICAL</property>"
-  "    <child>"
-  "      <object class=\"GtkButtonBox\" id=\"action_area\">"
-  "        <property name=\"orientation\">GTK_ORIENTATION_HORIZONTAL</property>"
-  "        <property name=\"visible\">True</property>"
-  "        <property name=\"layout_style\">end</property>"
-  "      </object>"
-  "      <packing>"
-  "        <property name=\"expand\">False</property>"
-  "        <property name=\"pack_type\">end</property>"
-  "        <property name=\"position\">0</property>"
-  "      </packing>"
-  "    </child>"
-  "  </object>"
-  "  </child>"
-  "</interface>";
-
 enum {
   RESPONSE,
   CLOSE,
@@ -402,8 +377,8 @@ gtk_dialog_class_init (GtkDialogClass *class)
   gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
 
   gtk_container_class_set_template (GTK_CONTAINER_CLASS (class),
-                                    gtk_dialog_template,
-                                    GTK_CONTAINER_TEMPLATE_STRING);
+                                    "/org/gtk/libgtk/gtkdialog.tmpl.glade",
+                                    GTK_CONTAINER_TEMPLATE_RESOURCE);
 
   gtk_container_class_declare_internal_child (container_class, TRUE,
                                               G_STRUCT_OFFSET (GtkDialogPrivate, vbox),
diff --git a/gtk/gtkdialog.tmpl.glade b/gtk/gtkdialog.tmpl.glade
new file mode 100644
index 0000000..6c69d2e
--- /dev/null
+++ b/gtk/gtkdialog.tmpl.glade
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.20"/>
+  <child>
+  <object class="GtkBox" id="vbox">
+    <property name="visible">True</property>
+    <property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+    <child>
+      <object class="GtkButtonBox" id="action_area">
+        <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+        <property name="visible">True</property>
+        <property name="layout_style">end</property>
+      </object>
+      <packing>
+        <property name="expand">False</property>
+        <property name="pack_type">end</property>
+        <property name="position">0</property>
+      </packing>
+    </child>
+  </object>
+  </child>
+</interface>
diff --git a/gtk/gtkmessagedialog.c b/gtk/gtkmessagedialog.c
index cf40e75..e99f1b1 100644
--- a/gtk/gtkmessagedialog.c
+++ b/gtk/gtkmessagedialog.c
@@ -124,82 +124,6 @@ static void     gtk_message_dialog_get_property (GObject          *object,
 static void     gtk_message_dialog_add_buttons  (GtkMessageDialog *message_dialog,
 						 GtkButtonsType    buttons);
 
-static const gchar *gtk_message_dialog_template = 
-  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
-  "<interface>"
-  "  <requires lib=\"gtk+\" version=\"2.20\"/>"
-  "  <child internal-child=\"vbox\">"
-  "    <object class=\"GtkBox\" id=\"vbox\">"
-  "      <property name=\"spacing\">14</property>"
-  "      <child>"
-  "        <object class=\"GtkBox\" id=\"hbox1\">"
-  "          <property name=\"visible\">True</property>"
-  "          <property name=\"border_width\">5</property>"
-  "          <property name=\"spacing\">12</property>"
-  "          <property name=\"orientation\">GTK_ORIENTATION_HORIZONTAL</property>"
-  "          <child>"
-  "            <object class=\"GtkImage\" id=\"image\">"
-  "              <property name=\"visible\">True</property>"
-  "              <property name=\"yalign\">0</property>"
-  "              <property name=\"icon-size\">6</property>"
-  "            </object>"
-  "            <packing>"
-  "              <property name=\"expand\">False</property>"
-  "              <property name=\"fill\">False</property>"
-  "              <property name=\"position\">0</property>"
-  "            </packing>"
-  "          </child>"
-  "          <child>"
-  "            <object class=\"GtkBox\" id=\"vbox1\">"
-  "              <property name=\"visible\">True</property>"
-  "              <property name=\"spacing\">12</property>"
-  "              <property name=\"orientation\">GTK_ORIENTATION_HORIZONTAL</property>"
-  "              <child>"
-  "                <object class=\"GtkLabel\" id=\"label\">"
-  "                  <property name=\"visible\">True</property>"
-  "                  <property name=\"xalign\">0</property>"
-  "                  <property name=\"yalign\">0</property>"
-  "                  <property name=\"label\" translatable=\"yes\">primary message</property>"
-  "                  <property name=\"wrap\">True</property>"
-  "                  <property name=\"selectable\">True</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=\"secondary_label\">"
-  "                  <property name=\"visible\">False</property>"
-  "                  <property name=\"no_show_all\">True</property>"
-  "                  <property name=\"xalign\">0</property>"
-  "                  <property name=\"yalign\">0</property>"
-  "                  <property name=\"label\" translatable=\"yes\">secondary message</property>"
-  "                  <property name=\"wrap\">True</property>"
-  "                  <property name=\"selectable\">True</property>"
-  "                </object>"
-  "                <packing>"
-  "                  <property name=\"position\">1</property>"
-  "                </packing>"
-  "              </child>"
-  "            </object>"
-  "            <packing>"
-  "              <property name=\"position\">1</property>"
-  "            </packing>"
-  "          </child>"
-  "        </object>"
-  "      </child>"
-  "      <child internal-child=\"action_area\">"
-  "        <object class=\"GtkButtonBox\" id=\"action_area\">"
-  "          <property name=\"border_width\">5</property>"
-  "          <property name=\"spacing\">6</property>"
-  "        </object>"
-  "      </child>"
-  "    </object>"
-  "  </child>"
-  "</interface>";
-
 enum {
   PROP_0,
   PROP_MESSAGE_TYPE,
@@ -368,8 +292,8 @@ gtk_message_dialog_class_init (GtkMessageDialogClass *class)
   g_type_class_add_private (gobject_class, sizeof (GtkMessageDialogPrivate));
 
   gtk_container_class_set_template (GTK_CONTAINER_CLASS (class),
-                                    gtk_message_dialog_template,
-                                    GTK_CONTAINER_TEMPLATE_STRING);
+                                    "/org/gtk/libgtk/gtkmessagedialog.tmpl.glade",
+                                    GTK_CONTAINER_TEMPLATE_RESOURCE);
 
   gtk_container_class_declare_internal_child (container_class, TRUE,
                                               G_STRUCT_OFFSET (GtkMessageDialogPrivate, label),
diff --git a/gtk/gtkmessagedialog.tmpl.glade b/gtk/gtkmessagedialog.tmpl.glade
new file mode 100644
index 0000000..8213c9b
--- /dev/null
+++ b/gtk/gtkmessagedialog.tmpl.glade
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="2.20"/>
+  <child internal-child="vbox">
+    <object class="GtkBox" id="vbox">
+      <property name="spacing">14</property>
+      <child>
+        <object class="GtkBox" id="hbox1">
+          <property name="visible">True</property>
+          <property name="border_width">5</property>
+          <property name="spacing">12</property>
+          <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+          <child>
+            <object class="GtkImage" id="image">
+              <property name="visible">True</property>
+              <property name="yalign">0</property>
+              <property name="icon-size">6</property>
+            </object>
+            <packing>
+              <property name="expand">False</property>
+              <property name="fill">False</property>
+              <property name="position">0</property>
+            </packing>
+          </child>
+          <child>
+            <object class="GtkBox" id="vbox1">
+              <property name="visible">True</property>
+              <property name="spacing">12</property>
+              <property name="orientation">GTK_ORIENTATION_HORIZONTAL</property>
+              <child>
+                <object class="GtkLabel" id="label">
+                  <property name="visible">True</property>
+                  <property name="xalign">0</property>
+                  <property name="yalign">0</property>
+                  <property name="label" translatable="yes">primary message</property>
+                  <property name="wrap">True</property>
+                  <property name="selectable">True</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="secondary_label">
+                  <property name="visible">False</property>
+                  <property name="no_show_all">True</property>
+                  <property name="xalign">0</property>
+                  <property name="yalign">0</property>
+                  <property name="label" translatable="yes">secondary message</property>
+                  <property name="wrap">True</property>
+                  <property name="selectable">True</property>
+                </object>
+                <packing>
+                  <property name="position">1</property>
+                </packing>
+              </child>
+            </object>
+            <packing>
+              <property name="position">1</property>
+            </packing>
+          </child>
+        </object>
+      </child>
+      <child internal-child="action_area">
+        <object class="GtkButtonBox" id="action_area">
+          <property name="border_width">5</property>
+          <property name="spacing">6</property>
+        </object>
+      </child>
+    </object>
+  </child>
+</interface>



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