[gtk+/wip/carlosg/event-as-object: 20/23] gtk: s/gdk_event_free/g_object_unref/



commit bb72d37d1dc4b497a85fdc9d4125a34801ddae25
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Oct 31 13:45:41 2017 +0100

    gtk: s/gdk_event_free/g_object_unref/

 gtk/gtkbutton.c          |    4 ++--
 gtk/gtkdnd.c             |   23 +++++++----------------
 gtk/gtkdragsource.c      |    2 +-
 gtk/gtkentry.c           |    2 +-
 gtk/gtkgesture.c         |    4 ++--
 gtk/gtkimcontextsimple.c |    2 +-
 gtk/gtkmain.c            |    6 +++---
 gtk/gtkmenu.c            |    8 ++++----
 gtk/gtkmenubutton.c      |    2 +-
 gtk/gtkmenuitem.c        |    4 ++--
 gtk/gtkselection.c       |    2 +-
 gtk/gtktextview.c        |    4 ++--
 gtk/gtktreeview.c        |    4 ++--
 gtk/gtkwidget.c          |   10 +++++-----
 gtk/gtkwindow.c          |    4 ++--
 15 files changed, 36 insertions(+), 45 deletions(-)
---
diff --git a/gtk/gtkbutton.c b/gtk/gtkbutton.c
index 32764d8..d048763 100644
--- a/gtk/gtkbutton.c
+++ b/gtk/gtkbutton.c
@@ -324,14 +324,14 @@ touch_release_in_button (GtkButton *button)
 
   if (gdk_event_get_event_type (event) != GDK_TOUCH_END)
     {
-      gdk_event_free (event);
+      g_object_unref (event);
       return FALSE;
     }
 
   gdk_event_get_coords (event, &x, &y);
   gtk_widget_get_own_allocation (GTK_WIDGET (button), &allocation);
 
-  gdk_event_free (event);
+  g_object_unref (event);
 
   if (gdk_rectangle_contains_point (&allocation, x, y))
     return TRUE;
diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c
index 935cc22..0dd4d65 100644
--- a/gtk/gtkdnd.c
+++ b/gtk/gtkdnd.c
@@ -1460,7 +1460,7 @@ gtk_drag_begin_internal (GtkWidget          *widget,
  * 3. During a timeout handler, if you want to start a drag after the mouse
  * button is held down for some time.  Try to save the last event that you got
  * from the mouse, using gdk_event_copy(), and pass it to this function
- * (remember to free the event with gdk_event_free() when you are done).
+ * (remember to free the event with g_object_unref() when you are done).
  * If you can really not pass a real event, pass #NULL instead.
  *
  * Returns: (transfer none): the context for this drag
@@ -2056,7 +2056,7 @@ gtk_drag_source_info_destroy (GtkDragSourceInfo *info)
   g_object_unref (info->context);
 
   if (info->last_event)
-    gdk_event_free (info->last_event);
+    g_object_unref (info->last_event);
 }
 
 static gboolean
@@ -2092,8 +2092,7 @@ gtk_drag_update_idle (gpointer data)
                             possible_actions,
                             time))
         {
-          gdk_event_free ((GdkEvent *)info->last_event);
-          info->last_event = NULL;
+          g_clear_object (&info->last_event);
         }
   
       if (dest_window)
@@ -2145,11 +2144,7 @@ gtk_drag_update (GtkDragSourceInfo *info,
   info->cur_screen = screen;
   info->cur_x = x_root;
   info->cur_y = y_root;
-  if (info->last_event)
-    {
-      gdk_event_free ((GdkEvent *)info->last_event);
-      info->last_event = NULL;
-    }
+  g_clear_object (&info->last_event);
   if (event)
     info->last_event = gdk_event_copy ((GdkEvent *)event);
 
@@ -2177,13 +2172,9 @@ gtk_drag_end (GtkDragSourceInfo *info,
       g_source_remove (info->update_idle);
       info->update_idle = 0;
     }
-  
-  if (info->last_event)
-    {
-      gdk_event_free (info->last_event);
-      info->last_event = NULL;
-    }
-  
+
+  g_clear_object (&info->last_event);
+
   info->have_grab = FALSE;
   
   g_signal_handlers_disconnect_by_func (info->ipc_widget,
diff --git a/gtk/gtkdragsource.c b/gtk/gtkdragsource.c
index 6ed5e94..5518a72 100644
--- a/gtk/gtkdragsource.c
+++ b/gtk/gtkdragsource.c
@@ -99,7 +99,7 @@ gtk_drag_source_event_cb (GtkWidget *widget,
                                    site->actions, button, last_event,
                                    start_x, start_y);
 
-          gdk_event_free (last_event);
+          g_object_unref (last_event);
 
           return TRUE;
         }
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index 9ad20b2..433a482 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -8565,7 +8565,7 @@ popup_targets_received (GtkClipboard     *clipboard,
         }
     }
 
-  g_clear_pointer (&info->trigger_event, gdk_event_free);
+  g_clear_object (&info->trigger_event);
   g_object_unref (entry);
   g_slice_free (PopupInfo, info);
 }
diff --git a/gtk/gtkgesture.c b/gtk/gtkgesture.c
index 8c7ed95..fddbe23 100644
--- a/gtk/gtkgesture.c
+++ b/gtk/gtkgesture.c
@@ -529,7 +529,7 @@ _gtk_gesture_update_point (GtkGesture     *gesture,
     }
 
   if (data->event)
-    gdk_event_free (data->event);
+    g_object_unref (data->event);
 
   data->event = gdk_event_copy (event);
   _update_touchpad_deltas (data);
@@ -912,7 +912,7 @@ free_point_data (gpointer data)
   PointData *point = data;
 
   if (point->event)
-    gdk_event_free (point->event);
+    g_object_unref (point->event);
 
   g_free (point);
 }
diff --git a/gtk/gtkimcontextsimple.c b/gtk/gtkimcontextsimple.c
index 06bdfb4..c72eed8 100644
--- a/gtk/gtkimcontextsimple.c
+++ b/gtk/gtkimcontextsimple.c
@@ -1057,7 +1057,7 @@ no_sequence_matches (GtkIMContextSimple *context_simple,
           gdk_event_set_keyval (tmp_event, priv->compose_buffer[len + i]);
          
          gtk_im_context_filter_keypress (context, (GdkEventKey *)tmp_event);
-         gdk_event_free (tmp_event);
+         g_object_unref (tmp_event);
        }
 
       return gtk_im_context_filter_keypress (context, event);
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index a64dd44..5ea7bc9 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1349,7 +1349,7 @@ synth_crossing (GtkWidget       *widget,
   event->crossing.detail = notify_type;
 
   gtk_widget_event (widget, event);
-  gdk_event_free (event);
+  g_object_unref (event);
 }
 
 static GtkWidget *
@@ -1865,7 +1865,7 @@ gtk_main_do_event (GdkEvent *event)
   g_list_free_1 (tmp_list);
 
   if (rewritten_event)
-    gdk_event_free (rewritten_event);
+    g_object_unref (rewritten_event);
 }
 
 /**
@@ -2285,7 +2285,7 @@ gtk_device_grab_remove (GtkWidget *widget,
  *
  * Returns: (transfer full) (nullable): a copy of the current event, or
  *     %NULL if there is no current event. The returned event must be
- *     freed with gdk_event_free().
+ *     freed with g_object_unref().
  */
 GdkEvent*
 gtk_get_current_event (void)
diff --git a/gtk/gtkmenu.c b/gtk/gtkmenu.c
index cf80a08..e001212 100644
--- a/gtk/gtkmenu.c
+++ b/gtk/gtkmenu.c
@@ -1696,7 +1696,7 @@ gtk_menu_popup_internal (GtkMenu             *menu,
         menu_shell->priv->ignore_enter = TRUE;
 
       source_device = gdk_event_get_source_device (current_event);
-      gdk_event_free (current_event);
+      g_object_unref (current_event);
     }
   else
     menu_shell->priv->ignore_enter = TRUE;
@@ -1998,7 +1998,7 @@ gtk_menu_popup_at_rect (GtkMenu            *menu,
                            button,
                            activate_time);
 
-  g_clear_pointer (&current_event, gdk_event_free);
+  g_clear_object (&current_event);
 }
 
 /**
@@ -2091,7 +2091,7 @@ gtk_menu_popup_at_widget (GtkMenu        *menu,
                            button,
                            activate_time);
 
-  g_clear_pointer (&current_event, gdk_event_free);
+  g_clear_object (&current_event);
 }
 
 /**
@@ -2158,7 +2158,7 @@ gtk_menu_popup_at_pointer (GtkMenu        *menu,
                           GDK_GRAVITY_NORTH_WEST,
                           trigger_event);
 
-  g_clear_pointer (&current_event, gdk_event_free);
+  g_clear_object (&current_event);
 }
 
 static void
diff --git a/gtk/gtkmenubutton.c b/gtk/gtkmenubutton.c
index 3a7e9b3..5e7d965 100644
--- a/gtk/gtkmenubutton.c
+++ b/gtk/gtkmenubutton.c
@@ -423,7 +423,7 @@ gtk_menu_button_toggled (GtkToggleButton *button)
             gtk_menu_shell_select_first (GTK_MENU_SHELL (priv->menu), FALSE);
 
           if (event)
-            gdk_event_free (event);
+            g_object_unref (event);
         }
     }
   else if (priv->popover)
diff --git a/gtk/gtkmenuitem.c b/gtk/gtkmenuitem.c
index d9ef5bb..7402f08 100644
--- a/gtk/gtkmenuitem.c
+++ b/gtk/gtkmenuitem.c
@@ -1178,7 +1178,7 @@ gtk_real_menu_item_select (GtkMenuItem *menu_item)
   if (current_event)
     {
       source_device = gdk_event_get_source_device (current_event);
-      gdk_event_free (current_event);
+      g_object_unref (current_event);
     }
 
   if ((!source_device ||
@@ -1516,7 +1516,7 @@ gtk_menu_item_popup_timeout (gpointer data)
 
   priv->timer = 0;
 
-  g_clear_pointer (&info->trigger_event, gdk_event_free);
+  g_clear_object (&info->trigger_event);
   g_slice_free (PopupInfo, info);
 
   return FALSE;
diff --git a/gtk/gtkselection.c b/gtk/gtkselection.c
index 611c09e..dda16cc 100644
--- a/gtk/gtkselection.c
+++ b/gtk/gtkselection.c
@@ -756,7 +756,7 @@ gtk_selection_owner_set_for_display (GdkDisplay   *display,
           gdk_event_set_selection (event, gtk_widget_get_window (old_owner), selection, time);
          gtk_widget_event (old_owner, event);
 
-         gdk_event_free (event);
+         g_object_unref (event);
        }
       return TRUE;
     }
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 913a435..133c9d4 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -8836,7 +8836,7 @@ gtk_text_view_value_changed (GtkAdjustment *adjustment,
           if (gdk_event_get_event_type (current_event) == GDK_SCROLL)
             move_mark_to_pointer_and_scroll (text_view, "insert");
 
-          gdk_event_free (current_event);
+          g_object_unref (current_event);
         }
     }
 
@@ -9357,7 +9357,7 @@ popup_targets_received (GtkClipboard     *clipboard,
         }
     }
 
-  g_clear_pointer (&info->trigger_event, gdk_event_free);
+  g_clear_object (&info->trigger_event);
   g_object_unref (text_view);
   g_slice_free (PopupInfo, info);
 }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index e56d882..f0e808c 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -5806,7 +5806,7 @@ gtk_tree_view_key_press (GtkWidget   *widget,
           /* Because we keep the focus on the treeview, we need to forward the
            * key events to the entry, when it is visible. */
           gtk_widget_event (search_window, new_event);
-          gdk_event_free (new_event);
+          g_object_unref (new_event);
 
           g_signal_handler_disconnect (tree_view->priv->search_entry,
                                        popup_menu_id);
@@ -10742,7 +10742,7 @@ send_focus_change (GtkWidget *widget,
 
       gtk_widget_send_focus_change (widget, fevent);
 
-      gdk_event_free (fevent);
+      g_object_unref (fevent);
     }
 
   g_list_free (devices);
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index 17657a1..1154e30 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -3514,7 +3514,7 @@ _gtk_widget_emulate_press (GtkWidget      *widget,
 
   /* Perform propagation state starting from the next child in the chain */
   gtk_propagate_event_internal (event_widget, press, next_child);
-  gdk_event_free (press);
+  g_object_unref (press);
 }
 
 static const GdkEvent *
@@ -6662,7 +6662,7 @@ _gtk_widget_captured_event (GtkWidget      *widget,
   g_object_unref (widget);
 
 out:
-  gdk_event_free (event_copy);
+  g_object_unref (event_copy);
 
   return return_val;
 }
@@ -6780,7 +6780,7 @@ gtk_widget_event_internal (GtkWidget      *widget,
 
   if (return_val == FALSE)
     return_val |= _gtk_widget_run_controllers (widget, event_copy, GTK_PHASE_BUBBLE);
-  gdk_event_free (event_copy);
+  g_object_unref (event_copy);
 
   return return_val;
 }
@@ -10597,7 +10597,7 @@ synth_crossing (GtkWidget       *widget,
   if (widget)
     gtk_widget_event_internal (widget, event);
 
-  gdk_event_free (event);
+  g_object_unref (event);
 }
 
 /*
@@ -13570,7 +13570,7 @@ gtk_widget_get_opacity (GtkWidget *widget)
  *
  *   gtk_widget_send_focus_change (widget, fevent);
  *
- *   gdk_event_free (event);
+ *   g_object_unref (event);
  * ]|
  *
  * Returns: the return value from the event signal emission: %TRUE
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 436429f..9fded45 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -1354,7 +1354,7 @@ send_delete_event (gpointer data)
   priv->delete_event_handler = 0;
 
   gtk_main_do_event (event);
-  gdk_event_free (event);
+  g_object_unref (event);
 
   return G_SOURCE_REMOVE;
 }
@@ -7645,7 +7645,7 @@ do_focus_change (GtkWidget *widget,
 
       gtk_widget_send_focus_change (widget, fevent);
 
-      gdk_event_free (fevent);
+      g_object_unref (fevent);
     }
 
   g_list_free (devices);


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