]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkselection.c
Remove GtkObject completely
[~andy/gtk] / gtk / gtkselection.c
index 5c7db9cc7fceaf7944076372df3a1e64c5cf5282..0a18fba6b74cddd55417ff406d683143d3ffac9f 100644 (file)
@@ -57,6 +57,7 @@
 #include "gdk.h"
 
 #include "gtkmain.h"
+#include "gtkdebug.h"
 #include "gtkselection.h"
 #include "gtktextbufferrichtext.h"
 #include "gtkintl.h"
@@ -70,8 +71,6 @@
 #include "win32/gdkwin32.h"
 #endif
 
-#include "gtkalias.h"
-
 #undef DEBUG_SELECTION
 
 /* Maximum size of a sent chunk, in bytes. Also the default size of
@@ -666,7 +665,7 @@ gtk_selection_owner_set_for_display (GdkDisplay   *display,
   if (widget == NULL)
     window = NULL;
   else
-    window = widget->window;
+    window = gtk_widget_get_window (widget);
 
   tmp_list = current_selections;
   while (tmp_list)
@@ -721,8 +720,8 @@ gtk_selection_owner_set_for_display (GdkDisplay   *display,
       if (old_owner && old_owner != widget)
        {
          GdkEvent *event = gdk_event_new (GDK_SELECTION_CLEAR);
-         
-         event->selection.window = g_object_ref (old_owner->window);
+
+          event->selection.window = g_object_ref (gtk_widget_get_window (old_owner));
          event->selection.selection = selection;
          event->selection.time = time;
          
@@ -895,7 +894,7 @@ gtk_selection_add_target (GtkWidget     *widget,
   list = gtk_selection_target_list_get (widget, selection);
   gtk_target_list_add (list, target, 0, info);
 #ifdef GDK_WINDOWING_WIN32
-  gdk_win32_selection_add_targets (widget->window, selection, 1, &target);
+  gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, 1, &target);
 #endif
 }
 
@@ -931,7 +930,7 @@ gtk_selection_add_targets (GtkWidget            *widget,
 
     for (i = 0; i < ntargets; ++i)
       atoms[i] = gdk_atom_intern (targets[i].target, FALSE);
-    gdk_win32_selection_add_targets (widget->window, selection, ntargets, atoms);
+    gdk_win32_selection_add_targets (gtk_widget_get_window (widget), selection, ntargets, atoms);
     g_free (atoms);
   }
 #endif
@@ -1105,7 +1104,7 @@ gtk_selection_convert (GtkWidget *widget,
   /* Otherwise, we need to go through X */
   
   current_retrievals = g_list_append (current_retrievals, info);
-  gdk_selection_convert (widget->window, selection, target, time_);
+  gdk_selection_convert (gtk_widget_get_window (widget), selection, target, time_);
   gdk_threads_add_timeout (1000,
       (GSourceFunc) gtk_selection_retrieval_timeout, info);
   
@@ -1226,7 +1225,7 @@ gtk_selection_data_get_length (GtkSelectionData *selection_data)
  *
  * Retrieves the display of the selection.
  *
- * Returns: the display of the selection.
+ * Returns: (transfer none): the display of the selection.
  *
  * Since: 2.14
  **/
@@ -1659,7 +1658,7 @@ gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
  * 
  * Gets the contents of the selection data as a #GdkPixbuf.
  * 
- * Return value: if the selection data contained a recognized
+ * Return value: (transfer full): if the selection data contained a recognized
  *   image type and it could be converted to a #GdkPixbuf, a 
  *   newly allocated pixbuf is returned, otherwise %NULL.
  *   If the result is non-%NULL it must be freed with g_object_unref().
@@ -2300,10 +2299,10 @@ _gtk_selection_request (GtkWidget *widget,
                                                 event->time);
          g_free (mult_atoms);
          g_slice_free (GtkIncrInfo, info);
-          gdk_error_trap_pop ();
+          gdk_error_trap_pop_ignored ();
          return TRUE;
        }
-      gdk_error_trap_pop ();
+      gdk_error_trap_pop_ignored ();
 
       /* This is annoying; the ICCCM doesn't specify the property type
        * used for the property contents, so the autoconversion for
@@ -2518,7 +2517,7 @@ _gtk_selection_incr_event (GdkWindow         *window,
   g_message ("PropertyDelete, property %ld", event->atom);
 #endif
 
-  selection_max_size = GTK_SELECTION_MAX_SIZE (gdk_drawable_get_display (window));  
+  selection_max_size = GTK_SELECTION_MAX_SIZE (gdk_window_get_display (window));  
 
   /* Now find the appropriate ongoing INCR */
   tmp_list = current_incrs;
@@ -2672,21 +2671,24 @@ gtk_selection_incr_timeout (GtkIncrInfo *info)
  *************************************************************/
 
 gboolean
-_gtk_selection_notify (GtkWidget              *widget,
+_gtk_selection_notify (GtkWidget        *widget,
                       GdkEventSelection *event)
 {
   GList *tmp_list;
   GtkRetrievalInfo *info = NULL;
+  GdkWindow *window;
   guchar  *buffer = NULL;
   gint length;
   GdkAtom type;
   gint   format;
-  
+
 #ifdef DEBUG_SELECTION
   g_message ("Initial receipt of selection %ld, target %ld (property = %ld)",
             event->selection, event->target, event->property);
 #endif
-  
+
+  window = gtk_widget_get_window (widget);
+
   tmp_list = current_retrievals;
   while (tmp_list)
     {
@@ -2700,7 +2702,7 @@ _gtk_selection_notify (GtkWidget         *widget,
     return FALSE;
 
   if (event->property != GDK_NONE)
-    length = gdk_selection_property_get (widget->window, &buffer, 
+    length = gdk_selection_property_get (window, &buffer,
                                         &type, &format);
   else
     length = 0; /* silence gcc */
@@ -2724,8 +2726,8 @@ _gtk_selection_notify (GtkWidget         *widget,
       info->notify_time = event->time;
       info->idle_time = 0;
       info->offset = 0;                /* Mark as OK to proceed */
-      gdk_window_set_events (widget->window,
-                            gdk_window_get_events (widget->window)
+      gdk_window_set_events (window,
+                             gdk_window_get_events (window)
                             | GDK_PROPERTY_CHANGE_MASK);
     }
   else
@@ -2739,9 +2741,9 @@ _gtk_selection_notify (GtkWidget         *widget,
                                      type, format, 
                                      buffer, length, event->time);
     }
-  
-  gdk_property_delete (widget->window, event->property);
-  
+
+  gdk_property_delete (window, event->property);
+
   g_free (buffer);
   
   return TRUE;
@@ -2766,6 +2768,7 @@ _gtk_selection_property_notify (GtkWidget *widget,
 {
   GList *tmp_list;
   GtkRetrievalInfo *info = NULL;
+  GdkWindow *window;
   guchar *new_buffer;
   int length;
   GdkAtom type;
@@ -2802,11 +2805,12 @@ _gtk_selection_property_notify (GtkWidget       *widget,
     return FALSE;
   
   info->idle_time = 0;
-  
-  length = gdk_selection_property_get (widget->window, &new_buffer, 
+
+  window = gtk_widget_get_window (widget);
+  length = gdk_selection_property_get (window, &new_buffer,
                                       &type, &format);
-  gdk_property_delete (widget->window, event->atom);
-  
+  gdk_property_delete (window, event->atom);
+
   /* We could do a lot better efficiency-wise by paying attention to
      what length was sent in the initial INCR transaction, instead of
      doing memory allocation at every step. But its only guaranteed to
@@ -3112,31 +3116,13 @@ gtk_selection_data_free (GtkSelectionData *data)
   g_slice_free (GtkSelectionData, data);
 }
 
-GType
-gtk_selection_data_get_type (void)
-{
-  static GType our_type = 0;
-  
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static (I_("GtkSelectionData"),
-                                            (GBoxedCopyFunc) gtk_selection_data_copy,
-                                            (GBoxedFreeFunc) gtk_selection_data_free);
-
-  return our_type;
-}
-
-GType
-gtk_target_list_get_type (void)
-{
-  static GType our_type = 0;
+G_DEFINE_BOXED_TYPE (GtkSelectionData, gtk_selection_data,
+                     gtk_selection_data_copy,
+                     gtk_selection_data_free)
 
-  if (our_type == 0)
-    our_type = g_boxed_type_register_static (I_("GtkTargetList"),
-                                            (GBoxedCopyFunc) gtk_target_list_ref,
-                                            (GBoxedFreeFunc) gtk_target_list_unref);
-
-  return our_type;
-}
+G_DEFINE_BOXED_TYPE (GtkTargetList, gtk_target_list,
+                     gtk_target_list_ref,
+                     gtk_target_list_unref)
 
 static int 
 gtk_selection_bytes_per_item (gint format)
@@ -3157,6 +3143,3 @@ gtk_selection_bytes_per_item (gint format)
     }
   return 0;
 }
-
-#define __GTK_SELECTION_C__
-#include "gtkaliasdef.c"