[gimp] Bug 784890 - Being able to take a screenshot of a single window and...



commit 24c2bdf61cd28a8920ea415c117fc5867b7de648
Author: Jehan <jehan girinstud io>
Date:   Tue Jul 18 15:04:09 2017 +0200

    Bug 784890 - Being able to take a screenshot of a single window and...
    
    ... include mouse pointer.
    This is working find and tested under GNOME which already had the code
    for it (was only missing the GUI). I added the feature in OSX and X11,
    though it is untested. Windows does not seem to have the capability (at
    least according to screenshot_win32_get_capabilities() in our code).

 plug-ins/screenshot/screenshot-osx.c |    2 ++
 plug-ins/screenshot/screenshot-x11.c |    3 ++-
 plug-ins/screenshot/screenshot.c     |   31 ++++++++++++++++++++++++++++++-
 3 files changed, 34 insertions(+), 2 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-osx.c b/plug-ins/screenshot/screenshot-osx.c
index 74e1466..403ea3d 100644
--- a/plug-ins/screenshot/screenshot-osx.c
+++ b/plug-ins/screenshot/screenshot-osx.c
@@ -94,6 +94,8 @@ screenshot_osx_shoot (ScreenshotValues  *shootvals,
         mode = "-iwo";
       else
         mode = "-iw";
+      if (shootvals->show_cursor)
+        cursor = "-C";
       break;
 
     case SHOOT_ROOT:
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index cd9e0dd..d68b0f8 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -672,7 +672,8 @@ screenshot_x11_shoot (ScreenshotValues  *shootvals,
   /* FIXME: Some time might have passed until we get here.
    *        The cursor image should be grabbed together with the screenshot.
    */
-  if (shootvals->shoot_type == SHOOT_ROOT && shootvals->show_cursor)
+  if ((shootvals->shoot_type == SHOOT_ROOT ||
+       shootvals->shoot_type == SHOOT_WINDOW) && shootvals->show_cursor)
     add_cursor_image (*image_ID, display);
 
   profile = gimp_screen_get_color_profile (screen, monitor);
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 332ab65..47608a7 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -416,6 +416,7 @@ shoot_dialog (GdkScreen **screen)
   GSList        *radio_group = NULL;
   GtkAdjustment *adj;
   gboolean       run;
+  GtkWidget     *cursor_toggle = NULL;
 
   gimp_ui_init (PLUG_IN_BINARY, FALSE);
 
@@ -456,7 +457,7 @@ shoot_dialog (GdkScreen **screen)
   gtk_container_add (GTK_CONTAINER (frame), vbox);
   gtk_widget_show (vbox);
 
-  /*  Aingle window  */
+  /*  Single window  */
   button = gtk_radio_button_new_with_mnemonic (radio_group,
                                                _("Take a screenshot of "
                                                  "a single _window"));
@@ -492,6 +493,28 @@ shoot_dialog (GdkScreen **screen)
                               toggle, "sensitive",
                               G_BINDING_SYNC_CREATE);
     }
+  /*  Mouse pointer  */
+  if (capabilities & SCREENSHOT_CAN_SHOOT_POINTER)
+    {
+      hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+      gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+      gtk_widget_show (hbox);
+
+      cursor_toggle = gtk_check_button_new_with_mnemonic (_("Include _mouse pointer"));
+      gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (cursor_toggle),
+                                    shootvals.show_cursor);
+      gtk_box_pack_start (GTK_BOX (hbox), cursor_toggle, TRUE, TRUE, 24);
+      gtk_widget_show (cursor_toggle);
+
+      g_signal_connect (cursor_toggle, "toggled",
+                        G_CALLBACK (gimp_toggle_button_update),
+                        &shootvals.show_cursor);
+
+      g_object_bind_property (button, "active",
+                              cursor_toggle, "sensitive",
+                              G_BINDING_SYNC_CREATE);
+    }
+
 
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
                                 shootvals.shoot_type == SHOOT_WINDOW);
@@ -528,6 +551,12 @@ shoot_dialog (GdkScreen **screen)
                         G_CALLBACK (gimp_toggle_button_update),
                         &shootvals.show_cursor);
 
+      if (cursor_toggle)
+        {
+          g_object_bind_property (cursor_toggle, "active",
+                                  toggle, "active",
+                                  G_BINDING_BIDIRECTIONAL);
+        }
       g_object_bind_property (button, "active",
                               toggle, "sensitive",
                               G_BINDING_SYNC_CREATE);


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