]> Pileus Git - ~andy/gtk/blobdiff - tests/testmultidisplay.c
tests: Add a test for loading images from file
[~andy/gtk] / tests / testmultidisplay.c
index 92c434fab7727eb7e8fa8eb686c132377267b9c0..aa78385c02b61882cfbcf534ae653d442ccac182 100644 (file)
@@ -1,7 +1,23 @@
-#include <strings.h>
+/* testmultidisplay.c
+ * Copyright (C) 2001 Sun Microsystems Inc.
+ * Author: Erwann Chenede <erwann.chenede@sun.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
 #include <gtk/gtk.h>
-#include <gtk/gtkstock.h>
-#include <gdk/gdk.h>
 
 gchar *screen2_name = NULL;
 
@@ -19,8 +35,7 @@ get_screen_response (GtkDialog *dialog,
 {
   if (response_id == GTK_RESPONSE_DELETE_EVENT)
     return;
-  if (screen2_name)
-    g_free (screen2_name);
+  g_free (screen2_name);
   screen2_name = g_strdup (gtk_entry_get_text (entry));
 }
 
@@ -41,27 +56,30 @@ make_selection_dialog (GdkScreen * screen,
                       GtkWidget * other_entry)
 {
   GtkWidget *window, *vbox;
+  GtkWidget *content_area;
   MyDoubleGtkEntry *double_entry = g_new (MyDoubleGtkEntry, 1);
   double_entry->e1 = GTK_ENTRY (entry);
   double_entry->e2 = GTK_ENTRY (other_entry);
 
   if (!screen)
-    screen = gdk_get_default_screen ();
+    screen = gdk_screen_get_default ();
 
-  window = gtk_widget_new (GTK_TYPE_DIALOG,
+  window = g_object_new (GTK_TYPE_DIALOG,
                           "screen", screen,
                           "user_data", NULL,
                           "type", GTK_WINDOW_TOPLEVEL,
                           "title", "MultiDisplay Cut & Paste",
                           "border_width", 10, NULL);
-  g_signal_connect (G_OBJECT (window), "destroy",
+  g_signal_connect (window, "destroy",
                    G_CALLBACK (gtk_main_quit), NULL);
 
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (window));
 
-  vbox = gtk_widget_new (GTK_TYPE_VBOX,
+  vbox = g_object_new (GTK_TYPE_BOX,
                         "border_width", 5,
+                         "orientation", GTK_ORIENTATION_VERTICAL,
                         NULL);
-  gtk_box_pack_start (GTK_BOX (GTK_DIALOG (window)->vbox), vbox, FALSE, FALSE, 0);
+  gtk_box_pack_start (GTK_BOX (content_area), vbox, FALSE, FALSE, 0);
 
   gtk_box_pack_start (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
   gtk_widget_grab_focus (entry);
@@ -72,7 +90,7 @@ make_selection_dialog (GdkScreen * screen,
                          NULL);
   gtk_dialog_set_default_response (GTK_DIALOG (window), GTK_RESPONSE_APPLY);
 
-  g_signal_connect (G_OBJECT (window), "response",
+  g_signal_connect (window, "response",
                    G_CALLBACK (entry_dialog_response), double_entry);
 
   gtk_widget_show_all (window);
@@ -83,6 +101,7 @@ main (int argc, char *argv[])
 {
   GtkWidget *dialog, *display_entry, *dialog_label;
   GtkWidget *entry, *entry2;
+  GtkWidget *content_area;
   GdkDisplay *dpy2;
   GdkScreen *scr2 = NULL;      /* Quiet GCC */
   gboolean correct_second_display = FALSE;
@@ -106,23 +125,24 @@ main (int argc, char *argv[])
   dialog_label =
     gtk_label_new ("Please enter the name of\nthe second display\n");
 
-  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), dialog_label);
-  gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox),
-                    display_entry);
-  gtk_signal_connect (GTK_OBJECT (dialog), "response",
-                     GTK_SIGNAL_FUNC (get_screen_response), display_entry);
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_add (GTK_CONTAINER (content_area), dialog_label);
+  gtk_container_add (GTK_CONTAINER (content_area), display_entry);
+  g_signal_connect (dialog, "response",
+                   G_CALLBACK (get_screen_response), display_entry);
 
   gtk_widget_grab_focus (display_entry);
-  gtk_widget_show_all (GTK_BIN (dialog)->child);
+  gtk_widget_show_all (gtk_bin_get_child (GTK_BIN (dialog)));
   
   while (!correct_second_display)
     {
       if (screen2_name)
        {
-         if (!g_strcasecmp (screen2_name, ""))
+         if (!g_ascii_strcasecmp (screen2_name, ""))
            g_printerr ("No display name, reverting to default display\n");
          
-         dpy2 = gdk_open_display (screen2_name);
+         dpy2 = gdk_display_open (screen2_name);
          if (dpy2)
            {
              scr2 = gdk_display_get_default_screen (dpy2);
@@ -144,11 +164,11 @@ main (int argc, char *argv[])
   
   gtk_widget_destroy (dialog);
 
-  entry = gtk_widget_new (GTK_TYPE_ENTRY,
+  entry = g_object_new (GTK_TYPE_ENTRY,
                          "activates_default", TRUE,
                          "visible", TRUE,
                          NULL);
-  entry2 = gtk_widget_new (GTK_TYPE_ENTRY,
+  entry2 = g_object_new (GTK_TYPE_ENTRY,
                           "activates_default", TRUE,
                           "visible", TRUE,
                           NULL);