[gimp] plug-ins: move screenshot delay function to the main screenshot.[ch]



commit 7a98b9e0432b2249de9ec350e4664f0da3b07c2a
Author: Michael Natterer <mitch gimp org>
Date:   Tue Mar 29 23:34:51 2016 +0200

    plug-ins: move screenshot delay function to the main screenshot.[ch]
    
    so it can be used from all backends.

 plug-ins/screenshot/screenshot-x11.c |   28 +------------------
 plug-ins/screenshot/screenshot.c     |   50 +++++++++++++++++++++++++---------
 plug-ins/screenshot/screenshot.h     |    3 ++
 3 files changed, 41 insertions(+), 40 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index 2677212..1090b9c 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -54,9 +54,6 @@ static gint32     create_image         (cairo_surface_t  *surface,
                                         cairo_region_t   *shape,
                                         const gchar      *name);
 
-static void       shoot_delay          (gint32            delay);
-static gboolean   shoot_delay_callback (gpointer          data);
-
 
 /* Allow the user to select a window or a region with the mouse */
 
@@ -584,7 +581,7 @@ screenshot_x11_shoot (ScreenshotValues *shootvals,
     screen = gdk_screen_get_default ();
 
   if (shootvals->select_delay > 0)
-    shoot_delay (shootvals->select_delay);
+    screenshot_delay (shootvals->select_delay);
 
   if (shootvals->shoot_type != SHOOT_ROOT && ! shootvals->window_id)
     {
@@ -682,27 +679,4 @@ screenshot_x11_shoot (ScreenshotValues *shootvals,
   return GIMP_PDB_SUCCESS;
 }
 
-
-/*  delay functions  */
-
-static void
-shoot_delay (gint delay)
-{
-  g_timeout_add (1000, shoot_delay_callback, &delay);
-  gtk_main ();
-}
-
-static gboolean
-shoot_delay_callback (gpointer data)
-{
-  gint *seconds_left = data;
-
-  (*seconds_left)--;
-
-  if (!*seconds_left)
-    gtk_main_quit ();
-
-  return *seconds_left;
-}
-
 #endif /* GDK_WINDOWING_X11 */
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 24f6c29..a416644 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -130,18 +130,19 @@ static const guint8 screenshot_icon[] =
 #endif
 
 
-static void                query              (void);
-static void                run                (const gchar      *name,
-                                               gint              nparams,
-                                               const GimpParam  *param,
-                                               gint             *nreturn_vals,
-                                               GimpParam       **return_vals);
+static void                query               (void);
+static void                run                 (const gchar      *name,
+                                                gint              nparams,
+                                                const GimpParam  *param,
+                                                gint             *nreturn_vals,
+                                                GimpParam       **return_vals);
 
-static GimpPDBStatusType   shoot              (GdkScreen        *screen,
-                                               gint32           *image_ID);
+static GimpPDBStatusType   shoot               (GdkScreen        *screen,
+                                                gint32           *image_ID);
 
-static gboolean            shoot_dialog       (GdkScreen       **screen);
-static gboolean            shoot_quit_timeout (gpointer          data);
+static gboolean            shoot_dialog        (GdkScreen       **screen);
+static gboolean            shoot_quit_timeout  (gpointer          data);
+static gboolean            shoot_delay_timeout (gpointer          data);
 
 
 /* Global Variables */
@@ -208,13 +209,12 @@ query (void)
                           "passed as a parameter.  The last four parameters "
                           "are optional and can be used to specify the corners "
                           "of the region to be grabbed."
-#ifdef PLATFORM_OSX
-                          "On Mac OS X, when called non-interactively, the plugin"
+                          "On Mac OS X or on gnome-shell, "
+                          "when called non-interactively, the plugin"
                           "only can take screenshots of the entire root window."
                           "Grabbing a window or a region is not supported"
                           "non-interactively. To grab a region or a particular"
                           "window, you need to use the interactive mode."
-#endif
                           ,
                           "Sven Neumann <sven gimp org>, "
                           "Henrik Brix Andersen <brix gimp org>,"
@@ -661,3 +661,27 @@ shoot_quit_timeout (gpointer data)
 
   return FALSE;
 }
+
+
+static gboolean
+shoot_delay_timeout (gpointer data)
+{
+  gint *seconds_left = data;
+
+  (*seconds_left)--;
+
+  if (!*seconds_left)
+    gtk_main_quit ();
+
+  return *seconds_left;
+}
+
+
+/*  public functions  */
+
+void
+screenshot_delay (gint seconds)
+{
+  g_timeout_add (1000, shoot_delay_timeout, &seconds);
+  gtk_main ();
+}
diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h
index 1848a50..1535493 100644
--- a/plug-ins/screenshot/screenshot.h
+++ b/plug-ins/screenshot/screenshot.h
@@ -55,4 +55,7 @@ typedef struct
 } ScreenshotValues;
 
 
+void   screenshot_delay (gint seconds);
+
+
 #endif /* __SCREENSHOT_H__ */


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