New API function to take a screenshot of a window
authorAlberto Garcia <agarcia@igalia.com>
Wed, 18 Mar 2009 17:47:59 +0000 (18:47 +0100)
committerAlberto Garcia <agarcia@igalia.com>
Fri, 15 May 2009 15:13:50 +0000 (17:13 +0200)
* hildon/hildon-gtk.h
* hildon/hildon-gtk.c (hildon_gtk_window_take_screenshot):
New API function to take a screenshot of a window

Fixes: NB#106374 (Need API to take a loading screenshot)

ChangeLog
hildon/hildon-gtk.c
hildon/hildon-gtk.h

index 41af5d2..d81531c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-05-15  Alberto Garcia  <agarcia@igalia.com>
+
+       * hildon/hildon-gtk.h
+       * hildon/hildon-gtk.c (hildon_gtk_window_take_screenshot):
+       New API function to take a screenshot of a window
+
+       Fixes: NB#106374 (Need API to take a loading screenshot)
+
 2009-05-15  Alejandro Pinheiro  <apinheiro@igalia.com>
 
        * hildon/hildon-time-selector.c
index 5881fb7..448be93 100644 (file)
@@ -442,6 +442,41 @@ hildon_gtk_window_set_portrait_flags            (GtkWindow           *window,
 }
 
 /**
+ * hildon_gtk_window_take_screenshot:
+ * @window: a #GtkWindow
+ * @take: %TRUE to take a screenshot, %FALSE to destroy the existing one.
+ *
+ * Tells the window manager to take a screenshot of @window, or to
+ * destroy the existing one. @window must be mapped.
+ **/
+void
+hildon_gtk_window_take_screenshot               (GtkWindow *window,
+                                                 gboolean   take)
+{
+    GdkEventClient *ev;
+    GdkWindow *rootwin;
+
+    g_return_if_fail (GTK_IS_WINDOW (window));
+    g_return_if_fail (GTK_WIDGET_MAPPED (window));
+
+    rootwin = gdk_screen_get_root_window (gtk_window_get_screen (window));
+
+    ev = (GdkEventClient *) gdk_event_new (GDK_CLIENT_EVENT);
+    ev->window = g_object_ref (rootwin);
+    ev->send_event = TRUE;
+    ev->message_type = gdk_atom_intern ("_HILDON_LOADING_SCREENSHOT", FALSE);
+    ev->data_format = 32;
+    ev->data.l[0] = take ? 1 : 0;
+    ev->data.l[1] = GDK_WINDOW_XID (GTK_WIDGET (window)->window);
+    ev->data.l[2] = 0;
+
+    gdk_event_send_client_message ((GdkEvent *) ev, GDK_WINDOW_XWINDOW (rootwin));
+
+    gdk_event_free ((GdkEvent *) ev);
+}
+
+
+/**
  * hildon_gtk_hscale_new:
  *
  * Creates a new horizontal scale widget that lets the user select
index dd608b8..4816bfc 100644 (file)
@@ -79,6 +79,9 @@ void
 hildon_gtk_window_set_portrait_flags            (GtkWindow           *window,
                                                  HildonPortraitFlags  portrait_flags);
 
+void
+hildon_gtk_window_take_screenshot               (GtkWindow *window,
+                                                 gboolean   take);
 GtkWidget*
 hildon_gtk_hscale_new                           (void);