]> Pileus Git - ~andy/gtk/blobdiff - gtk/gtkplug.c
gtkplug: Do not leak in gtk_plug_realize()
[~andy/gtk] / gtk / gtkplug.c
index 2f3b4e9badaf5eb2936157f46671460203a8faca..d3aacabcecdd5141684b55bcc3a832b1eae0b22d 100644 (file)
@@ -33,6 +33,7 @@
 #include "gtkintl.h"
 #include "gtkprivate.h"
 #include "gtkplugprivate.h"
+#include "gtkwidgetprivate.h"
 #include "gtkwindow.h"
 
 /**
@@ -310,7 +311,7 @@ gtk_plug_get_embedded (GtkPlug *plug)
  *
  * Retrieves the socket the plug is embedded in.
  *
- * Return value: the window of the socket, or %NULL
+ * Return value: (transfer none): the window of the socket, or %NULL
  *
  * Since: 2.14
  **/
@@ -335,7 +336,6 @@ _gtk_plug_add_to_socket (GtkPlug   *plug,
 {
   GtkPlugPrivate *priv;
   GtkWidget *widget;
-  gint w, h;
   
   g_return_if_fail (GTK_IS_PLUG (plug));
   g_return_if_fail (GTK_IS_SOCKET (socket_));
@@ -359,8 +359,9 @@ _gtk_plug_add_to_socket (GtkPlug   *plug,
       GdkWindow *window;
 
       window = gtk_widget_get_window (widget);
-      gdk_drawable_get_size (GDK_DRAWABLE (window), &w, &h);
-      gdk_window_reparent (window, priv->socket_window, -w, -h);
+      gdk_window_reparent (window, priv->socket_window,
+                           -gdk_window_get_width (window),
+                           -gdk_window_get_height (window));
     }
 
   gtk_widget_set_parent (widget, GTK_WIDGET (socket_));
@@ -418,7 +419,7 @@ _gtk_plug_remove_from_socket (GtkPlug   *plug,
   priv = plug->priv;
   widget = GTK_WIDGET (plug);
 
-  if (GTK_WIDGET_IN_REPARENT (widget))
+  if (_gtk_widget_get_in_reparent (widget))
     return;
 
   g_object_ref (plug);
@@ -428,12 +429,12 @@ _gtk_plug_remove_from_socket (GtkPlug   *plug,
   window = gtk_widget_get_window (widget);
 
   gdk_window_hide (window);
-  GTK_PRIVATE_SET_FLAG (plug, GTK_IN_REPARENT);
+  _gtk_widget_set_in_reparent (widget, TRUE);
   gdk_window_reparent (window,
                       gtk_widget_get_root_window (widget),
                       0, 0);
   gtk_widget_unparent (GTK_WIDGET (plug));
-  GTK_PRIVATE_UNSET_FLAG (plug, GTK_IN_REPARENT);
+  _gtk_widget_set_in_reparent (widget, FALSE);
   
   socket_->plug_widget = NULL;
   if (socket_->plug_window != NULL)
@@ -558,7 +559,7 @@ gtk_plug_new (GdkNativeWindow socket_id)
 
 /**
  * gtk_plug_new_for_display:
- * @display : the #GdkDisplay on which @socket_id is displayed
+ * @display: the #GdkDisplay on which @socket_id is displayed
  * @socket_id: the XID of the socket's window.
  * 
  * Create a new plug widget inside the #GtkSocket identified by socket_id.
@@ -652,7 +653,6 @@ gtk_plug_realize (GtkWidget *widget)
   /* this isn't right - we should match our parent's visual/colormap.
    * though that will require handling "foreign" colormaps */
   attributes.visual = gtk_widget_get_visual (widget);
-  attributes.colormap = gtk_widget_get_colormap (widget);
   attributes.event_mask = gtk_widget_get_events (widget);
   attributes.event_mask |= (GDK_EXPOSURE_MASK |
                            GDK_KEY_PRESS_MASK |
@@ -661,9 +661,9 @@ gtk_plug_realize (GtkWidget *widget)
                            GDK_LEAVE_NOTIFY_MASK |
                            GDK_STRUCTURE_MASK);
 
-  attributes_mask = GDK_WA_VISUAL | GDK_WA_COLORMAP;
+  attributes_mask = GDK_WA_VISUAL;
   attributes_mask |= (title ? GDK_WA_TITLE : 0);
-  attributes_mask |= (g_strdup (g_get_prgname ()) ? GDK_WA_WMCLASS : 0);
+  attributes_mask |= (wmclass_name ? GDK_WA_WMCLASS : 0);
 
   if (gtk_widget_is_toplevel (widget))
     {