[gtk+/rendering-cleanup: 118/141] API: gdk_pixbuf_get_from_drawable() => gdk_pixbuf_get_from_window()



commit 63b14d808b1bfca134a126ceefd56eb0f85151b1
Author: Benjamin Otte <otte redhat com>
Date:   Sat Aug 28 23:51:58 2010 +0200

    API: gdk_pixbuf_get_from_drawable() => gdk_pixbuf_get_from_window()
    
    The Colormap argument needed to be removed, so the renaming is just a
    side effect.

 demos/testpixbuf-color.c             |    4 +-
 demos/testpixbuf-save.c              |    8 ++--
 docs/reference/gdk/gdk3-sections.txt |    2 +-
 docs/tools/shooter.c                 |    4 +-
 gdk/gdk.symbols                      |    2 +-
 gdk/gdkpixbuf-drawable.c             |   56 +++++-----------------------------
 gdk/gdkpixbuf.h                      |    5 +--
 gtk/gtkcolorsel.c                    |   16 +++++-----
 8 files changed, 28 insertions(+), 69 deletions(-)
---
diff --git a/demos/testpixbuf-color.c b/demos/testpixbuf-color.c
index 003f333..5ce086c 100644
--- a/demos/testpixbuf-color.c
+++ b/demos/testpixbuf-color.c
@@ -112,8 +112,8 @@ main (int argc, char **argv)
 	gtk_init (&argc, &argv);
 
 	root = gdk_get_default_root_window ();
-	pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
-					       0, 0, 0, 0, 150, 160);
+	pixbuf = gdk_pixbuf_get_from_window (NULL, root,
+					     0, 0, 0, 0, 150, 160);
 
 	/* PASS */
 	g_debug ("try to save PNG with a profile");
diff --git a/demos/testpixbuf-save.c b/demos/testpixbuf-save.c
index c8a6679..f3e9f04 100644
--- a/demos/testpixbuf-save.c
+++ b/demos/testpixbuf-save.c
@@ -340,8 +340,8 @@ configure_cb (GtkWidget *drawing_area, GdkEventConfigure *evt, gpointer data)
                 GdkPixbuf *new_pixbuf;
 
                 root = gdk_get_default_root_window ();
-                new_pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
-                                                           0, 0, 0, 0, evt->width, evt->height);
+                new_pixbuf = gdk_pixbuf_get_from_window (NULL, root,
+                                                         0, 0, 0, 0, evt->width, evt->height);
                 g_object_set_data_full (G_OBJECT (drawing_area), "pixbuf", new_pixbuf,
                                         (GDestroyNotify) g_object_unref);
         }
@@ -361,8 +361,8 @@ main (int argc, char **argv)
         gtk_init (&argc, &argv);   
 
         root = gdk_get_default_root_window ();
-        pixbuf = gdk_pixbuf_get_from_drawable (NULL, root, NULL,
-                                               0, 0, 0, 0, 150, 160);
+        pixbuf = gdk_pixbuf_get_from_window (NULL, root,
+                                             0, 0, 0, 0, 150, 160);
    
         window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
         g_signal_connect (window, "delete_event",
diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt
index dfbdb03..bbd3804 100644
--- a/docs/reference/gdk/gdk3-sections.txt
+++ b/docs/reference/gdk/gdk3-sections.txt
@@ -242,7 +242,7 @@ gdk_screen_get_type
 <SECTION>
 <TITLE>Pixbufs</TITLE>
 <FILE>pixbufs</FILE>
-gdk_pixbuf_get_from_drawable
+gdk_pixbuf_get_from_window
 gdk_pixbuf_get_from_surface
 </SECTION>
 
diff --git a/docs/tools/shooter.c b/docs/tools/shooter.c
index d73117b..4b31f03 100644
--- a/docs/tools/shooter.c
+++ b/docs/tools/shooter.c
@@ -163,8 +163,8 @@ take_window_shot (Window   child,
   if (y_orig + height > gdk_screen_height ())
     height = gdk_screen_height () - y_orig;
 
-  tmp = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
-				      x, y, 0, 0, width, height);
+  tmp = gdk_pixbuf_get_from_window (NULL, window,
+				    x, y, 0, 0, width, height);
 
   if (include_decoration)
     tmp2 = remove_shaped_area (tmp, xid);
diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols
index c1ea644..7ba93f1 100644
--- a/gdk/gdk.symbols
+++ b/gdk/gdk.symbols
@@ -801,7 +801,7 @@ gdk_pango_layout_line_get_clip_region
 
 #if IN_HEADER(__GDK_PIXBUF_H__)
 #if IN_FILE(__GDK_PIXBUF_DRAWABLE_C__)
-gdk_pixbuf_get_from_drawable
+gdk_pixbuf_get_from_window
 gdk_pixbuf_get_from_surface
 #endif
 #endif
diff --git a/gdk/gdkpixbuf-drawable.c b/gdk/gdkpixbuf-drawable.c
index 6cc35fc..c9a8464 100644
--- a/gdk/gdkpixbuf-drawable.c
+++ b/gdk/gdkpixbuf-drawable.c
@@ -34,10 +34,9 @@
 /* Exported functions */
 
 /**
- * gdk_pixbuf_get_from_drawable:
+ * gdk_pixbuf_get_from_window:
  * @dest: (allow-none): Destination pixbuf, or %NULL if a new pixbuf should be created.
  * @src: Source drawable.
- * @cmap: A colormap if @src doesn't have one set.
  * @src_x: Source X coordinate within drawable.
  * @src_y: Source Y coordinate within drawable.
  * @dest_x: Destination X coordinate in pixbuf, or 0 if @dest is NULL.
@@ -50,11 +49,6 @@
  * image data from a server-side drawable to a client-side RGB(A) buffer.
  * This allows you to efficiently read individual pixels on the client side.
  * 
- * If the drawable @src has no colormap (gdk_drawable_get_colormap()
- * returns %NULL), then a suitable colormap must be specified.
- * If the drawable has a colormap, the @cmap argument will be
- * ignored.
- *
  * If the specified destination pixbuf @dest is %NULL, then this
  * function will create an RGB pixbuf with 8 bits per channel and no
  * alpha, with the same size specified by the @width and @height
@@ -86,27 +80,16 @@
  * pixbuf with a reference count of 1 if no destination pixbuf was specified, or %NULL on error
  **/
 GdkPixbuf *
-gdk_pixbuf_get_from_drawable (GdkPixbuf   *dest,
-			      GdkDrawable *src,
-			      GdkColormap *cmap,
-			      int src_x,  int src_y,
-			      int dest_x, int dest_y,
-			      int width,  int height)
+gdk_pixbuf_get_from_window (GdkPixbuf   *dest,
+                            GdkWindow   *src,
+                            int src_x,  int src_y,
+                            int dest_x, int dest_y,
+                            int width,  int height)
 {
   cairo_surface_t *surface;
-  int depth;
   
-  /* General sanity checks */
-
-  g_return_val_if_fail (src != NULL, NULL);
-
-  if (GDK_IS_WINDOW (src))
-    /* FIXME: this is not perfect, since is_viewable() only tests
-     * recursively up the Gdk parent window tree, but stops at
-     * foreign windows or Gdk toplevels.  I.e. if a window manager
-     * unmapped one of its own windows, this won't work.
-     */
-    g_return_val_if_fail (gdk_window_is_viewable (src), NULL);
+  g_return_val_if_fail (GDK_IS_WINDOW (src), NULL);
+  g_return_val_if_fail (gdk_window_is_viewable (src), NULL);
 
   if (!dest)
     g_return_val_if_fail (dest_x == 0 && dest_y == 0, NULL);
@@ -118,29 +101,6 @@ gdk_pixbuf_get_from_drawable (GdkPixbuf   *dest,
       g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (dest) == 8, NULL);
     }
 
-  if (cmap == NULL)
-    cmap = gdk_drawable_get_colormap (src);
-
-  depth = gdk_drawable_get_depth (src);
-  
-  if (depth != 1 && cmap == NULL)
-    {
-      g_warning ("%s: Source drawable has no colormap; either pass "
-                 "in a colormap, or set the colormap on the drawable "
-                 "with gdk_drawable_set_colormap()", G_STRLOC);
-      return NULL;
-    }
-  
-  if (cmap != NULL && depth != cmap->visual->depth)
-    {
-      g_warning ("%s: Depth of the source drawable is %d where as "
-                 "the visual depth of the colormap passed is %d",
-                 G_STRLOC, depth, cmap->visual->depth);
-      return NULL;
-    } 
- 
-  /* Coordinate sanity checks */
-  
   surface = _gdk_drawable_ref_cairo_surface (src);
   dest = gdk_pixbuf_get_from_surface (dest,
                                       surface,
diff --git a/gdk/gdkpixbuf.h b/gdk/gdkpixbuf.h
index 99e718d..6b21078 100644
--- a/gdk/gdkpixbuf.h
+++ b/gdk/gdkpixbuf.h
@@ -38,9 +38,8 @@
 G_BEGIN_DECLS
 
 /* Fetching a region from a drawable */
-GdkPixbuf *gdk_pixbuf_get_from_drawable (GdkPixbuf   *dest,
-					 GdkDrawable *src,
-					 GdkColormap *cmap,
+GdkPixbuf *gdk_pixbuf_get_from_window   (GdkPixbuf   *dest,
+					 GdkWindow   *window,
 					 int          src_x,
 					 int          src_y,
 					 int          dest_x,
diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c
index 09688b4..38789eb 100644
--- a/gtk/gtkcolorsel.c
+++ b/gtk/gtkcolorsel.c
@@ -1683,10 +1683,10 @@ grab_color_at_pointer (GdkScreen *screen,
   
   priv = colorsel->private_data;
   
-  pixbuf = gdk_pixbuf_get_from_drawable (NULL, root_window, NULL,
-                                         x_root, y_root,
-                                         0, 0,
-                                         1, 1);
+  pixbuf = gdk_pixbuf_get_from_window (NULL, root_window,
+                                       x_root, y_root,
+                                       0, 0,
+                                       1, 1);
   if (!pixbuf)
     {
       gint x, y;
@@ -1694,10 +1694,10 @@ grab_color_at_pointer (GdkScreen *screen,
       GdkWindow *window = gdk_display_get_window_at_device_position (display, device, &x, &y);
       if (!window)
 	return;
-      pixbuf = gdk_pixbuf_get_from_drawable (NULL, window, NULL,
-                                             x, y,
-                                             0, 0,
-                                             1, 1);
+      pixbuf = gdk_pixbuf_get_from_window (NULL, window,
+                                           x, y,
+                                           0, 0,
+                                           1, 1);
       if (!pixbuf)
 	return;
     }



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