]> Pileus Git - ~andy/gtk/blobdiff - gtk/tests/builder.c
Change FSF Address
[~andy/gtk] / gtk / tests / builder.c
index 0a3f62539aa84c770cfde2a5a46024367c84c658..1422dfc92c4f9273077fdb86566f3bd201aca58c 100644 (file)
@@ -14,9 +14,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <string.h>
@@ -722,7 +720,6 @@ test_types (void)
     "  <object class=\"GtkHButtonBox\" id=\"hbuttonbox\"/>"
     "  <object class=\"GtkHBox\" id=\"hbox\"/>"
     "  <object class=\"GtkHPaned\" id=\"hpaned\"/>"
-    "  <object class=\"GtkHRuler\" id=\"hruler\"/>"
     "  <object class=\"GtkHScale\" id=\"hscale\"/>"
     "  <object class=\"GtkHScrollbar\" id=\"hscrollbar\"/>"
     "  <object class=\"GtkHSeparator\" id=\"hseparator\"/>"
@@ -749,7 +746,6 @@ test_types (void)
     "  <object class=\"GtkVScrollbar\" id=\"vscrollbar\"/>"
     "  <object class=\"GtkVSeparator\" id=\"vseparator\"/>"
     "  <object class=\"GtkViewport\" id=\"viewport\"/>"
-    "  <object class=\"GtkVRuler\" id=\"vruler\"/>"
     "  <object class=\"GtkVPaned\" id=\"vpaned\"/>"
     "  <object class=\"GtkVScale\" id=\"vscale\"/>"
     "  <object class=\"GtkWindow\" id=\"window\"/>"
@@ -1026,7 +1022,8 @@ test_children (void)
   vbox = gtk_builder_get_object (builder, "dialog1-vbox");
   content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
   g_assert (vbox != NULL);
-  g_assert (GTK_IS_VBOX (vbox));
+  g_assert (GTK_IS_BOX (vbox));
+  g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (vbox)) == GTK_ORIENTATION_VERTICAL);
   g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (gtk_widget_get_parent (GTK_WIDGET (vbox)))), "dialog1") == 0);
   g_assert (gtk_container_get_border_width (GTK_CONTAINER (vbox)) == 10);
   g_assert (strcmp (gtk_buildable_get_name (GTK_BUILDABLE (content_area)), "dialog1-vbox") == 0);
@@ -1034,7 +1031,8 @@ test_children (void)
   action_area = gtk_builder_get_object (builder, "dialog1-action_area");
   dialog_action_area = gtk_dialog_get_action_area (GTK_DIALOG (dialog));
   g_assert (action_area != NULL);
-  g_assert (GTK_IS_HBUTTON_BOX (action_area));
+  g_assert (GTK_IS_BUTTON_BOX (action_area));
+  g_assert (gtk_orientable_get_orientation (GTK_ORIENTABLE (action_area)) == GTK_ORIENTATION_HORIZONTAL);
   g_assert (gtk_widget_get_parent (GTK_WIDGET (action_area)) != NULL);
   g_assert (gtk_container_get_border_width (GTK_CONTAINER (action_area)) == 20);
   g_assert (dialog_action_area != NULL);
@@ -1050,7 +1048,7 @@ test_child_properties (void)
   GtkBuilder * builder;
   const gchar buffer1[] =
     "<interface>"
-    "  <object class=\"GtkVBox\" id=\"vbox1\">"
+    "  <object class=\"GtkBox\" id=\"vbox1\">"
     "    <child>"
     "      <object class=\"GtkLabel\" id=\"label1\"/>"
     "      <packing>"
@@ -1071,7 +1069,7 @@ test_child_properties (void)
   
   builder = builder_new_from_string (buffer1, -1, NULL);
   vbox = gtk_builder_get_object (builder, "vbox1");
-  g_assert (GTK_IS_VBOX (vbox));
+  g_assert (GTK_IS_BOX (vbox));
 
   label = gtk_builder_get_object (builder, "label1");
   g_assert (GTK_IS_LABEL (label));
@@ -1312,6 +1310,7 @@ test_combo_box (void)
   g_object_unref (builder);
 }
 
+#if 0
 static void
 test_combo_box_entry (void)
 {
@@ -1336,8 +1335,9 @@ test_combo_box_entry (void)
     "  </object>"
     "  <object class=\"GtkWindow\" id=\"window1\">"
     "    <child>"
-    "      <object class=\"GtkComboBoxEntry\" id=\"comboboxentry1\">"
+    "      <object class=\"GtkComboBox\" id=\"comboboxentry1\">"
     "        <property name=\"model\">liststore1</property>"
+    "        <property name=\"has-entry\">True</property>"
     "        <property name=\"visible\">True</property>"
     "        <child>"
     "          <object class=\"GtkCellRendererText\" id=\"renderer1\"/>"
@@ -1381,6 +1381,7 @@ test_combo_box_entry (void)
 
   g_object_unref (builder);
 }
+#endif
 
 static void
 test_cell_view (void)
@@ -1718,7 +1719,7 @@ test_window (void)
 static void
 test_value_from_string (void)
 {
-  GValue value = { 0 };
+  GValue value = G_VALUE_INIT;
   GError *error = NULL;
   GtkBuilder *builder;
 
@@ -2500,11 +2501,9 @@ test_file (const gchar *filename)
 
       if (GTK_IS_DIALOG (obj))
        {
-         int response;
-
          g_print ("Running dialog %s.\n",
                   gtk_widget_get_name (GTK_WIDGET (obj)));
-         response = gtk_dialog_run (GTK_DIALOG (obj));
+         gtk_dialog_run (GTK_DIALOG (obj));
        }
       else if (GTK_IS_WINDOW (obj))
        {
@@ -2571,6 +2570,79 @@ test_message_area (void)
   g_object_unref (builder);
 }
 
+static void
+test_gmenu (void)
+{
+  GtkBuilder *builder;
+  GObject *obj, *obj1;
+  const gchar buffer[] =
+    "<interface>"
+    "  <object class=\"GtkWindow\" id=\"window\">"
+    "  </object>"
+    "  <menu id='edit-menu'>"
+    "    <section>"
+    "      <item>"
+    "        <attribute name='label'>Undo</attribute>"
+    "        <attribute name='action'>undo</attribute>"
+    "      </item>"
+    "      <item>"
+    "        <attribute name='label'>Redo</attribute>"
+    "        <attribute name='action'>redo</attribute>"
+    "      </item>"
+    "    </section>"
+    "    <section></section>"
+    "    <section>"
+    "      <attribute name='label'>Copy &amp; Paste</attribute>"
+    "      <item>"
+    "        <attribute name='label'>Cut</attribute>"
+    "        <attribute name='action'>cut</attribute>"
+    "      </item>"
+    "      <item>"
+    "        <attribute name='label'>Copy</attribute>"
+    "        <attribute name='action'>copy</attribute>"
+    "      </item>"
+    "      <item>"
+    "        <attribute name='label'>Paste</attribute>"
+    "        <attribute name='action'>paste</attribute>"
+    "      </item>"
+    "    </section>"
+    "    <item><link name='section' id='blargh'>"
+    "      <item>"
+    "        <attribute name='label'>Bold</attribute>"
+    "        <attribute name='action'>bold</attribute>"
+    "      </item>"
+    "      <submenu>"
+    "        <attribute name='label'>Language</attribute>"
+    "        <item>"
+    "          <attribute name='label'>Latin</attribute>"
+    "          <attribute name='action'>lang</attribute>"
+    "          <attribute name='target'>'latin'</attribute>"
+    "        </item>"
+    "        <item>"
+    "          <attribute name='label'>Greek</attribute>"
+    "          <attribute name='action'>lang</attribute>"
+    "          <attribute name='target'>'greek'</attribute>"
+    "        </item>"
+    "        <item>"
+    "          <attribute name='label'>Urdu</attribute>"
+    "          <attribute name='action'>lang</attribute>"
+    "          <attribute name='target'>'urdu'</attribute>"
+    "        </item>"
+    "      </submenu>"
+    "    </link></item>"
+    "  </menu>"
+    "</interface>";
+
+  builder = builder_new_from_string (buffer, -1, NULL);
+  obj = gtk_builder_get_object (builder, "window");
+  g_assert (GTK_IS_WINDOW (obj));
+  obj1 = gtk_builder_get_object (builder, "edit-menu");
+  g_assert (G_IS_MENU_MODEL (obj1));
+  obj1 = gtk_builder_get_object (builder, "blargh");
+  g_assert (G_IS_MENU_MODEL (obj1));
+  g_object_unref (builder);
+}
+
 int
 main (int argc, char **argv)
 {
@@ -2600,7 +2672,9 @@ main (int argc, char **argv)
   g_test_add_func ("/Builder/TreeView Column", test_treeview_column);
   g_test_add_func ("/Builder/IconView", test_icon_view);
   g_test_add_func ("/Builder/ComboBox", test_combo_box);
+#if 0
   g_test_add_func ("/Builder/ComboBox Entry", test_combo_box_entry);
+#endif
   g_test_add_func ("/Builder/CellView", test_cell_view);
   g_test_add_func ("/Builder/Dialog", test_dialog);
   g_test_add_func ("/Builder/Accelerators", test_accelerators);
@@ -2615,6 +2689,7 @@ main (int argc, char **argv)
   g_test_add_func ("/Builder/Menus", test_menus);
   g_test_add_func ("/Builder/MessageArea", test_message_area);
   g_test_add_func ("/Builder/MessageDialog", test_message_dialog);
+  g_test_add_func ("/Builder/GMenu", test_gmenu);
 
   return g_test_run();
 }