]> Pileus Git - ~andy/gtk/blobdiff - tests/testdnd.c
testgtk: Remove GtkAlignment usage from progressbar test
[~andy/gtk] / tests / testdnd.c
index 9913564470413d1d3512d72915dcd1d223707558..2011578f6dafb79fa78df5ed3724e9475945d253 100644 (file)
@@ -13,9 +13,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 "config.h"
@@ -335,7 +333,7 @@ target_drag_motion     (GtkWidget          *widget,
           G_OBJECT_TYPE_NAME (source_widget) :
           "NULL");
 
-  tmp_list = context->targets;
+  tmp_list = gdk_drag_context_list_targets (context);
   while (tmp_list)
     {
       char *name = gdk_atom_name (GDK_POINTER_TO_ATOM (tmp_list->data));
@@ -345,7 +343,8 @@ target_drag_motion     (GtkWidget          *widget,
       tmp_list = tmp_list->next;
     }
 
-  gdk_drag_status (context, context->suggested_action, time);
+  gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time);
+
   return TRUE;
 }
 
@@ -361,10 +360,10 @@ target_drag_drop     (GtkWidget          *widget,
 
   gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);
 
-  if (context->targets)
+  if (gdk_drag_context_list_targets (context))
     {
-      gtk_drag_get_data (widget, context, 
-                        GDK_POINTER_TO_ATOM (context->targets->data), 
+      gtk_drag_get_data (widget, context,
+                        GDK_POINTER_TO_ATOM (gdk_drag_context_list_targets (context)->data),
                         time);
       return TRUE;
     }
@@ -495,13 +494,13 @@ popup_cb (gpointer data)
       if (!popup_window)
        {
          GtkWidget *button;
-         GtkWidget *table;
+         GtkWidget *grid;
          int i, j;
          
          popup_window = gtk_window_new (GTK_WINDOW_POPUP);
          gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);
 
-         table = gtk_table_new (3,3, FALSE);
+         grid = gtk_grid_new ();
 
          for (i=0; i<3; i++)
            for (j=0; j<3; j++)
@@ -509,9 +508,9 @@ popup_cb (gpointer data)
                char buffer[128];
                g_snprintf(buffer, sizeof(buffer), "%d,%d", i, j);
                button = gtk_button_new_with_label (buffer);
-               gtk_table_attach (GTK_TABLE (table), button, i, i+1, j, j+1,
-                                 GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                                 0, 0);
+                gtk_widget_set_hexpand (button, TRUE);
+                gtk_widget_set_vexpand (button, TRUE);
+               gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
 
                gtk_drag_dest_set (button,
                                   GTK_DEST_DEFAULT_ALL,
@@ -523,8 +522,8 @@ popup_cb (gpointer data)
                                  G_CALLBACK (popup_leave), NULL);
              }
 
-         gtk_widget_show_all (table);
-         gtk_container_add (GTK_CONTAINER (popup_window), table);
+         gtk_widget_show_all (grid);
+         gtk_container_add (GTK_CONTAINER (popup_window), grid);
 
        }
       gtk_widget_show (popup_window);
@@ -575,19 +574,15 @@ source_drag_data_delete  (GtkWidget          *widget,
 void
 test_init (void)
 {
-  if (g_file_test ("../gdk-pixbuf/libpixbufloader-pnm.la",
-                  G_FILE_TEST_EXISTS))
-    {
-      g_setenv ("GDK_PIXBUF_MODULE_FILE", "../gdk-pixbuf/loaders.cache", TRUE);
-      g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE);
-    }
+  if (g_file_test ("../modules/input/immodules.cache", G_FILE_TEST_EXISTS))
+    g_setenv ("GTK_IM_MODULE_FILE", "../modules/input/immodules.cache", TRUE);
 }
 
 int 
 main (int argc, char **argv)
 {
   GtkWidget *window;
-  GtkWidget *table;
+  GtkWidget *grid;
   GtkWidget *label;
   GtkWidget *pixmap;
   GtkWidget *button;
@@ -602,8 +597,8 @@ main (int argc, char **argv)
                    G_CALLBACK (gtk_main_quit), NULL);
 
   
-  table = gtk_table_new (2, 2, FALSE);
-  gtk_container_add (GTK_CONTAINER (window), table);
+  grid = gtk_grid_new ();
+  gtk_container_add (GTK_CONTAINER (window), grid);
 
   drag_icon = gdk_pixbuf_new_from_xpm_data (drag_icon_xpm);
   trashcan_open = gdk_pixbuf_new_from_xpm_data (trashcan_open_xpm);
@@ -619,9 +614,9 @@ main (int argc, char **argv)
   g_signal_connect (label, "drag_data_received",
                    G_CALLBACK( label_drag_data_received), NULL);
 
-  gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
-                   GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                   0, 0);
+  gtk_widget_set_hexpand (label, TRUE);
+  gtk_widget_set_vexpand (label, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
 
   label = gtk_label_new ("Popup\n");
 
@@ -630,9 +625,9 @@ main (int argc, char **argv)
                     target_table, n_targets - 1, /* no rootwin */
                     GDK_ACTION_COPY | GDK_ACTION_MOVE);
 
-  gtk_table_attach (GTK_TABLE (table), label, 1, 2, 1, 2,
-                   GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                   0, 0);
+  gtk_widget_set_hexpand (label, TRUE);
+  gtk_widget_set_vexpand (label, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
 
   g_signal_connect (label, "drag_motion",
                    G_CALLBACK (popsite_motion), NULL);
@@ -641,9 +636,9 @@ main (int argc, char **argv)
   
   pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
   gtk_drag_dest_set (pixmap, 0, NULL, 0, 0);
-  gtk_table_attach (GTK_TABLE (table), pixmap, 1, 2, 0, 1,
-                   GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                   0, 0);
+  gtk_widget_set_hexpand (pixmap, TRUE);
+  gtk_widget_set_vexpand (pixmap, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
 
   g_signal_connect (pixmap, "drag_leave",
                    G_CALLBACK (target_drag_leave), NULL);
@@ -668,9 +663,9 @@ main (int argc, char **argv)
 
   g_object_unref (drag_icon);
 
-  gtk_table_attach (GTK_TABLE (table), button, 0, 1, 1, 2,
-                   GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL,
-                   0, 0);
+  gtk_widget_set_hexpand (button, TRUE);
+  gtk_widget_set_vexpand (button, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
 
   g_signal_connect (button, "drag_data_get",
                    G_CALLBACK (source_drag_data_get), NULL);