[gimp] plug-ins: add a SCREENSHOT_CAN_SHOOT_WINDOW capability.
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: add a SCREENSHOT_CAN_SHOOT_WINDOW capability.
- Date: Sat, 16 Dec 2017 20:58:47 +0000 (UTC)
commit 80490a2c07aacb85f6d58db027c25ddfe6311eeb
Author: Jehan <jehan girinstud io>
Date: Sat Dec 16 21:54:49 2017 +0100
plug-ins: add a SCREENSHOT_CAN_SHOOT_WINDOW capability.
And add the relevant option for when such capability is absent. Right
now it is absent only from the new Freedesktop API.
plug-ins/screenshot/screenshot-gnome-shell.c | 3 +-
plug-ins/screenshot/screenshot-kwin.c | 1 +
plug-ins/screenshot/screenshot-osx.c | 1 +
plug-ins/screenshot/screenshot-win32.c | 3 +-
plug-ins/screenshot/screenshot-x11.c | 1 +
plug-ins/screenshot/screenshot.c | 135 ++++++++++++++------------
plug-ins/screenshot/screenshot.h | 3 +-
7 files changed, 84 insertions(+), 63 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-gnome-shell.c b/plug-ins/screenshot/screenshot-gnome-shell.c
index 99afd8b..aa6e5da 100644
--- a/plug-ins/screenshot/screenshot-gnome-shell.c
+++ b/plug-ins/screenshot/screenshot-gnome-shell.c
@@ -71,7 +71,8 @@ screenshot_gnome_shell_get_capabilities (void)
{
return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
SCREENSHOT_CAN_SHOOT_POINTER |
- SCREENSHOT_CAN_SHOOT_REGION);
+ SCREENSHOT_CAN_SHOOT_REGION |
+ SCREENSHOT_CAN_SHOOT_WINDOW);
}
GimpPDBStatusType
diff --git a/plug-ins/screenshot/screenshot-kwin.c b/plug-ins/screenshot/screenshot-kwin.c
index ab74d64..075996e 100644
--- a/plug-ins/screenshot/screenshot-kwin.c
+++ b/plug-ins/screenshot/screenshot-kwin.c
@@ -72,6 +72,7 @@ screenshot_kwin_get_capabilities (void)
{
return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
SCREENSHOT_CAN_SHOOT_POINTER |
+ SCREENSHOT_CAN_SHOOT_WINDOW |
SCREENSHOT_CAN_PICK_WINDOW);
/* TODO: SCREENSHOT_CAN_SHOOT_REGION.
* The KDE API has "screenshotArea" method but no method to get
diff --git a/plug-ins/screenshot/screenshot-osx.c b/plug-ins/screenshot/screenshot-osx.c
index 8a5b7df..d2711c6 100644
--- a/plug-ins/screenshot/screenshot-osx.c
+++ b/plug-ins/screenshot/screenshot-osx.c
@@ -68,6 +68,7 @@ screenshot_osx_get_capabilities (void)
return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
SCREENSHOT_CAN_SHOOT_POINTER |
SCREENSHOT_CAN_SHOOT_REGION |
+ SCREENSHOT_CAN_SHOOT_WINDOW |
SCREENSHOT_CAN_PICK_WINDOW |
SCREENSHOT_CAN_DELAY_WINDOW_SHOT);
}
diff --git a/plug-ins/screenshot/screenshot-win32.c b/plug-ins/screenshot/screenshot-win32.c
index 05519b9..277f9a5 100644
--- a/plug-ins/screenshot/screenshot-win32.c
+++ b/plug-ins/screenshot/screenshot-win32.c
@@ -127,7 +127,8 @@ screenshot_win32_available (void)
ScreenshotCapabilities
screenshot_win32_get_capabilities (void)
{
- return (SCREENSHOT_CAN_SHOOT_DECORATIONS);
+ return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
+ SCREENSHOT_CAN_SHOOT_WINDOW);
}
GimpPDBStatusType
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index b905255..620c2d8 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -544,6 +544,7 @@ screenshot_x11_get_capabilities (void)
#endif
capabilities |= SCREENSHOT_CAN_SHOOT_REGION |
+ SCREENSHOT_CAN_SHOOT_WINDOW |
SCREENSHOT_CAN_PICK_WINDOW |
SCREENSHOT_CAN_DELAY_WINDOW_SHOT;
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 7fa4a2e..b5d5278 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -234,6 +234,18 @@ run (const gchar *name,
gimp_get_data (PLUG_IN_PROC, &shootvals);
shootvals.window_id = 0;
+ if ((shootvals.shoot_type == SHOOT_WINDOW &&
+ ! (capabilities & SCREENSHOT_CAN_SHOOT_WINDOW)) ||
+ (shootvals.shoot_type == SHOOT_REGION &&
+ ! (capabilities & SCREENSHOT_CAN_SHOOT_REGION)))
+ {
+ /* Shoot root is the only type of shoot which is definitely
+ * shared by all screenshot backends (basically just snap the
+ * whole display setup).
+ */
+ shootvals.shoot_type = SHOOT_ROOT;
+ }
+
/* Get information from the dialog */
if (! shoot_dialog (&screen))
status = GIMP_PDB_CANCEL;
@@ -508,70 +520,73 @@ shoot_dialog (GdkScreen **screen)
gtk_widget_show (vbox);
/* Single window */
- button = gtk_radio_button_new_with_mnemonic (radio_group,
- _("Take a screenshot of "
- "a single _window"));
- radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
- gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
- gtk_widget_show (button);
-
- g_object_set_data (G_OBJECT (button), "gimp-item-data",
- GINT_TO_POINTER (SHOOT_WINDOW));
-
- g_signal_connect (button, "toggled",
- G_CALLBACK (shoot_radio_button_toggled),
- notebook1);
- g_signal_connect (button, "toggled",
- G_CALLBACK (shoot_radio_button_toggled),
- notebook2);
-
- /* Window decorations */
- if (capabilities & SCREENSHOT_CAN_SHOOT_DECORATIONS)
+ if (capabilities & SCREENSHOT_CAN_SHOOT_WINDOW)
{
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
-
- toggle = gtk_check_button_new_with_mnemonic (_("Include window _decoration"));
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
- shootvals.decorate);
- gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
- gtk_widget_show (toggle);
+ button = gtk_radio_button_new_with_mnemonic (radio_group,
+ _("Take a screenshot of "
+ "a single _window"));
+ radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
+ gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ gtk_widget_show (button);
- g_signal_connect (toggle, "toggled",
- G_CALLBACK (gimp_toggle_button_update),
- &shootvals.decorate);
+ g_object_set_data (G_OBJECT (button), "gimp-item-data",
+ GINT_TO_POINTER (SHOOT_WINDOW));
- g_object_bind_property (button, "active",
- 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);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (shoot_radio_button_toggled),
+ notebook1);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (shoot_radio_button_toggled),
+ notebook2);
- 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);
+ /* Window decorations */
+ if (capabilities & SCREENSHOT_CAN_SHOOT_DECORATIONS)
+ {
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ toggle = gtk_check_button_new_with_mnemonic (_("Include window _decoration"));
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
+ shootvals.decorate);
+ gtk_box_pack_start (GTK_BOX (hbox), toggle, TRUE, TRUE, 24);
+ gtk_widget_show (toggle);
+
+ g_signal_connect (toggle, "toggled",
+ G_CALLBACK (gimp_toggle_button_update),
+ &shootvals.decorate);
+
+ g_object_bind_property (button, "active",
+ 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);
+ }
- 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);
}
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
- shootvals.shoot_type == SHOOT_WINDOW);
-
/* Whole screen */
button = gtk_radio_button_new_with_mnemonic (radio_group,
_("Take a screenshot of "
diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h
index 8b8bb5f..3ce07f7 100644
--- a/plug-ins/screenshot/screenshot.h
+++ b/plug-ins/screenshot/screenshot.h
@@ -40,7 +40,8 @@ typedef enum
SCREENSHOT_CAN_PICK_WINDOW = 0x1 << 4,
/* SHOOT_WINDOW + SCREENSHOT_CAN_PICK_WINDOW only: if a delay can be
* inserted in-between selection click and actual snapshot. */
- SCREENSHOT_CAN_DELAY_WINDOW_SHOT = 0x1 << 5
+ SCREENSHOT_CAN_DELAY_WINDOW_SHOT = 0x1 << 5,
+ SCREENSHOT_CAN_SHOOT_WINDOW = 0x1 << 6
} ScreenshotCapabilities;
typedef enum
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]