[gimp] plug-ins: differentiate a delay before the area/window selection...
- From: Jehan Pagès <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: differentiate a delay before the area/window selection...
- Date: Sun, 10 Dec 2017 00:12:26 +0000 (UTC)
commit b57c89dd5dcaa08b5a9b422e49b249c689283e36
Author: Jehan <jehan girinstud io>
Date: Sun Dec 10 00:28:22 2017 +0100
plug-ins: differentiate a delay before the area/window selection...
... and a delay before the screenshot.
Until now, there was only delay before selection, which I changed in
commits d9cd4b61bc and 614bcf6d0a. Actually a delay before selection may
also be useful, for instance when you use a tablet without keyboard (no
alt-tab possible) and the window/area you wish to capture is behind GIMP
window. Then you'd want to interact with the desktop with the pointer
before the cursor changes for selection interaction.
I add some logics so that the selection delay doesn't show when it is
unecessary (for instance for full-screen screenshot, or when the window
screenshot is based on the active window, not click selection, like with
GNOME shell API).
plug-ins/screenshot/screenshot-gnome-shell.c | 15 ++-
plug-ins/screenshot/screenshot-kwin.c | 9 ++-
plug-ins/screenshot/screenshot-x11.c | 10 +-
plug-ins/screenshot/screenshot.c | 176 +++++++++++++++++++++-----
plug-ins/screenshot/screenshot.h | 4 +-
5 files changed, 168 insertions(+), 46 deletions(-)
---
diff --git a/plug-ins/screenshot/screenshot-gnome-shell.c b/plug-ins/screenshot/screenshot-gnome-shell.c
index a5b00e8..99afd8b 100644
--- a/plug-ins/screenshot/screenshot-gnome-shell.c
+++ b/plug-ins/screenshot/screenshot-gnome-shell.c
@@ -92,8 +92,8 @@ screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
switch (shootvals->shoot_type)
{
case SHOOT_ROOT:
- if (shootvals->select_delay > 0)
- screenshot_delay (shootvals->select_delay);
+ if (shootvals->screenshot_delay > 0)
+ screenshot_delay (shootvals->screenshot_delay);
method = "Screenshot";
args = g_variant_new ("(bbs)",
@@ -105,6 +105,9 @@ screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
break;
case SHOOT_REGION:
+ if (shootvals->select_delay > 0)
+ screenshot_delay (shootvals->select_delay);
+
retval = g_dbus_proxy_call_sync (proxy, "SelectArea", NULL,
G_DBUS_CALL_FLAGS_NONE,
-1, NULL, error);
@@ -134,14 +137,14 @@ screenshot_gnome_shell_shoot (ScreenshotValues *shootvals,
gdk_screen_get_monitor_at_point (screen,
(shootvals->x1 + shootvals->x2) / 2,
(shootvals->y1 + shootvals->y2) / 2);
- if (shootvals->select_delay > 0)
- screenshot_delay (shootvals->select_delay);
+ if (shootvals->screenshot_delay > 0)
+ screenshot_delay (shootvals->screenshot_delay);
break;
case SHOOT_WINDOW:
- if (shootvals->select_delay > 0)
- screenshot_delay (shootvals->select_delay);
+ if (shootvals->screenshot_delay > 0)
+ screenshot_delay (shootvals->screenshot_delay);
method = "ScreenshotWindow";
args = g_variant_new ("(bbbs)",
diff --git a/plug-ins/screenshot/screenshot-kwin.c b/plug-ins/screenshot/screenshot-kwin.c
index 7e1415c..6b60913 100644
--- a/plug-ins/screenshot/screenshot-kwin.c
+++ b/plug-ins/screenshot/screenshot-kwin.c
@@ -71,7 +71,8 @@ ScreenshotCapabilities
screenshot_kwin_get_capabilities (void)
{
return (SCREENSHOT_CAN_SHOOT_DECORATIONS |
- SCREENSHOT_CAN_SHOOT_POINTER);
+ SCREENSHOT_CAN_SHOOT_POINTER |
+ SCREENSHOT_CAN_PICK_WINDOW);
/* TODO: SCREENSHOT_CAN_SHOOT_REGION.
* The KDE API has "screenshotArea" method but no method to get
* coordinates could be found. See below.
@@ -97,6 +98,9 @@ screenshot_kwin_shoot (ScreenshotValues *shootvals,
switch (shootvals->shoot_type)
{
case SHOOT_ROOT:
+ if (shootvals->screenshot_delay > 0)
+ screenshot_delay (shootvals->screenshot_delay);
+
method = "screenshotFullscreen";
args = g_variant_new ("(b)", shootvals->show_cursor);
@@ -125,6 +129,9 @@ screenshot_kwin_shoot (ScreenshotValues *shootvals,
break;
case SHOOT_WINDOW:
+ if (shootvals->select_delay > 0)
+ screenshot_delay (shootvals->select_delay);
+
/* XXX I expected "screenshotWindowUnderCursor" method to be the
* right one, but it returns nothing, nor is there a file
* descriptor in argument. So I don't understand how to grab the
diff --git a/plug-ins/screenshot/screenshot-x11.c b/plug-ins/screenshot/screenshot-x11.c
index 82aeeaf..63c7cf1 100644
--- a/plug-ins/screenshot/screenshot-x11.c
+++ b/plug-ins/screenshot/screenshot-x11.c
@@ -543,7 +543,8 @@ screenshot_x11_get_capabilities (void)
capabilities |= SCREENSHOT_CAN_SHOOT_POINTER;
#endif
- capabilities |= SCREENSHOT_CAN_SHOOT_REGION;
+ capabilities |= SCREENSHOT_CAN_SHOOT_REGION |
+ SCREENSHOT_CAN_PICK_WINDOW;
return capabilities;
}
@@ -574,14 +575,17 @@ screenshot_x11_shoot (ScreenshotValues *shootvals,
if (shootvals->shoot_type != SHOOT_ROOT && ! shootvals->window_id)
{
+ if (shootvals->select_delay > 0)
+ screenshot_delay (shootvals->select_delay);
+
shootvals->window_id = select_window (shootvals, screen);
if (! shootvals->window_id)
return GIMP_PDB_CANCEL;
}
- if (shootvals->select_delay > 0)
- screenshot_delay (shootvals->select_delay);
+ if (shootvals->screenshot_delay > 0)
+ screenshot_delay (shootvals->screenshot_delay);
display = gdk_screen_get_display (screen);
diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c
index 0b7b379..69baa45 100644
--- a/plug-ins/screenshot/screenshot.c
+++ b/plug-ins/screenshot/screenshot.c
@@ -70,16 +70,18 @@ static gboolean shoot_delay_timeout (gpointer data);
/* Global Variables */
-static ScreenshotBackend backend = SCREENSHOT_BACKEND_NONE;
-static ScreenshotCapabilities capabilities = 0;
+static ScreenshotBackend backend = SCREENSHOT_BACKEND_NONE;
+static ScreenshotCapabilities capabilities = 0;
+static GtkWidget *select_delay_table = NULL;
static ScreenshotValues shootvals =
{
- SHOOT_WINDOW, /* root window */
+ SHOOT_WINDOW, /* root window */
TRUE, /* include WM decorations */
- 0, /* window ID */
- 0, /* monitor */
- 0, /* select delay */
+ 0, /* window ID */
+ 0, /* monitor */
+ 0, /* select delay */
+ 0, /* screenshot delay */
0, /* coords of region dragged out by pointer */
0,
0,
@@ -405,6 +407,19 @@ shoot_radio_button_toggled (GtkWidget *widget,
{
gimp_radio_button_update (widget, &shootvals.shoot_type);
+ if (select_delay_table)
+ {
+ if (shootvals.shoot_type == SHOOT_ROOT ||
+ (shootvals.shoot_type == SHOOT_WINDOW &&
+ ! (capabilities & SCREENSHOT_CAN_PICK_WINDOW)))
+ {
+ gtk_widget_hide (select_delay_table);
+ }
+ else
+ {
+ gtk_widget_show (select_delay_table);
+ }
+ }
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), shootvals.shoot_type);
}
@@ -413,7 +428,8 @@ shoot_dialog (GdkScreen **screen)
{
GtkWidget *dialog;
GtkWidget *main_vbox;
- GtkWidget *notebook;
+ GtkWidget *notebook1;
+ GtkWidget *notebook2;
GtkWidget *frame;
GtkWidget *vbox;
GtkWidget *hbox;
@@ -421,6 +437,7 @@ shoot_dialog (GdkScreen **screen)
GtkWidget *button;
GtkWidget *toggle;
GtkWidget *spinner;
+ GtkWidget *table;
GSList *radio_group = NULL;
GtkAdjustment *adj;
gboolean run;
@@ -449,12 +466,15 @@ shoot_dialog (GdkScreen **screen)
gtk_widget_show (main_vbox);
- /* Create delay hints notebook early */
- notebook = g_object_new (GTK_TYPE_NOTEBOOK,
- "show-border", FALSE,
- "show-tabs", FALSE,
- NULL);
-
+ /* Create delay hints notebooks early */
+ notebook1 = g_object_new (GTK_TYPE_NOTEBOOK,
+ "show-border", FALSE,
+ "show-tabs", FALSE,
+ NULL);
+ notebook2 = g_object_new (GTK_TYPE_NOTEBOOK,
+ "show-border", FALSE,
+ "show-tabs", FALSE,
+ NULL);
/* Area */
frame = gimp_frame_new (_("Area"));
@@ -478,7 +498,10 @@ shoot_dialog (GdkScreen **screen)
g_signal_connect (button, "toggled",
G_CALLBACK (shoot_radio_button_toggled),
- notebook);
+ notebook1);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (shoot_radio_button_toggled),
+ notebook2);
/* Window decorations */
if (capabilities & SCREENSHOT_CAN_SHOOT_DECORATIONS)
@@ -540,7 +563,10 @@ shoot_dialog (GdkScreen **screen)
g_signal_connect (button, "toggled",
G_CALLBACK (shoot_radio_button_toggled),
- notebook);
+ notebook1);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (shoot_radio_button_toggled),
+ notebook2);
/* Mouse pointer */
if (capabilities & SCREENSHOT_CAN_SHOOT_POINTER)
@@ -589,28 +615,44 @@ shoot_dialog (GdkScreen **screen)
g_signal_connect (button, "toggled",
G_CALLBACK (shoot_radio_button_toggled),
- notebook);
+ notebook1);
+ g_signal_connect (button, "toggled",
+ G_CALLBACK (shoot_radio_button_toggled),
+ notebook2);
}
- /* Delay */
frame = gimp_frame_new (_("Delay"));
- gtk_box_pack_start (GTK_BOX (main_vbox), frame, FALSE, FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (main_vbox), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
gtk_container_add (GTK_CONTAINER (frame), vbox);
gtk_widget_show (vbox);
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
- gtk_widget_show (hbox);
+ /* Selection delay */
+ table = gtk_table_new (2, 3, FALSE);
+ select_delay_table = table;
+ gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+ /* Check if this delay must be hidden from start. */
+ if (shootvals.shoot_type == SHOOT_REGION ||
+ (shootvals.shoot_type == SHOOT_WINDOW &&
+ capabilities & SCREENSHOT_CAN_PICK_WINDOW))
+ {
+ gtk_widget_show (select_delay_table);
+ }
+
+ label = gtk_label_new (_("Selection delay: "));
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ GTK_SHRINK, GTK_SHRINK, 0, 0);
+ gtk_widget_show (label);
adj = (GtkAdjustment *)
gtk_adjustment_new (shootvals.select_delay,
0.0, 100.0, 1.0, 5.0, 0.0);
spinner = gtk_spin_button_new (adj, 0, 0);
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), spinner, FALSE, FALSE, 0);
+ gtk_table_attach (GTK_TABLE (table), spinner, 1, 2, 0, 1,
+ GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (spinner);
g_signal_connect (adj, "value-changed",
@@ -619,27 +661,91 @@ shoot_dialog (GdkScreen **screen)
/* translators: this is the unit label of a spinbutton */
label = gtk_label_new (_("seconds"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 1.0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.1, 0.5);
gtk_widget_show (label);
- /* Delay hints */
- gtk_box_pack_start (GTK_BOX (vbox), notebook, FALSE, FALSE, 0);
- gtk_widget_show (notebook);
+ /* Selection delay hints */
+ gtk_table_attach (GTK_TABLE (table), notebook1, 0, 3, 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+ gtk_widget_show (notebook1);
- shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_ROOT,
- _("After the delay, the screenshot is taken."));
- shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_REGION,
+ /* No selection delay for full-screen. */
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook1), SHOOT_ROOT, "");
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook1), SHOOT_REGION,
_("After the delay, drag your mouse to select "
"the region for the screenshot."));
#ifdef G_OS_WIN32
- shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_WINDOW,
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook1), SHOOT_WINDOW,
_("Click in a window to snap it after delay."));
#else
- shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_WINDOW,
- _("At the end of the delay, click in a window "
- "to snap it."));
+ if (capabilities & SCREENSHOT_CAN_PICK_WINDOW)
+ {
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook1), SHOOT_WINDOW,
+ _("At the end of the delay, click in a window "
+ "to snap it."));
+ }
+ else
+ {
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook1), SHOOT_WINDOW, "");
+ }
#endif
- gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), shootvals.shoot_type);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook1), shootvals.shoot_type);
+
+ /* Screenshot delay */
+ table = gtk_table_new (2, 3, FALSE);
+ gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
+ gtk_widget_show (table);
+
+ label = gtk_label_new (_("Screenshot delay: "));
+ gtk_table_attach (GTK_TABLE (table), label, 0, 1, 0, 1,
+ GTK_SHRINK, GTK_SHRINK, 0, 0);
+ gtk_widget_show (label);
+
+ adj = (GtkAdjustment *)
+ gtk_adjustment_new (shootvals.screenshot_delay,
+ 0.0, 100.0, 1.0, 5.0, 0.0);
+ spinner = gtk_spin_button_new (adj, 0, 0);
+ gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinner), TRUE);
+ gtk_table_attach (GTK_TABLE (table), spinner, 1, 2, 0, 1,
+ GTK_SHRINK, GTK_SHRINK, 0, 0);
+ gtk_widget_show (spinner);
+
+ g_signal_connect (adj, "value-changed",
+ G_CALLBACK (gimp_int_adjustment_update),
+ &shootvals.screenshot_delay);
+
+ /* translators: this is the unit label of a spinbutton */
+ label = gtk_label_new (_("seconds"));
+ gtk_table_attach (GTK_TABLE (table), label, 2, 3, 0, 1,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 1.0, 0);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.1, 0.5);
+ gtk_widget_show (label);
+
+ /* Screenshot delay hints */
+ gtk_table_attach (GTK_TABLE (table), notebook2, 0, 3, 1, 2,
+ GTK_EXPAND | GTK_FILL, GTK_SHRINK, 0, 0);
+ gtk_widget_show (notebook2);
+
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook2), SHOOT_ROOT,
+ _("After the delay, the screenshot is taken."));
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook2), SHOOT_REGION,
+ _("Once the region is selected, it will be "
+ "captured after this delay."));
+ if (capabilities & SCREENSHOT_CAN_PICK_WINDOW)
+ {
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook2), SHOOT_WINDOW,
+ _("Once the window is selected, it will be "
+ "captured after this delay."));
+ }
+ else
+ {
+ shoot_dialog_add_hint (GTK_NOTEBOOK (notebook2), SHOOT_WINDOW,
+ _("After the delay, the active window "
+ "will be captured."));
+ }
+ gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook2), shootvals.shoot_type);
/* Color profile */
frame = gimp_int_radio_group_new (TRUE,
diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h
index 0f2de70..b8f80ad 100644
--- a/plug-ins/screenshot/screenshot.h
+++ b/plug-ins/screenshot/screenshot.h
@@ -34,7 +34,8 @@ typedef enum
SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0,
SCREENSHOT_CAN_SHOOT_POINTER = 0x1 << 1,
SCREENSHOT_CAN_PICK_NONINTERACTIVELY = 0x1 << 2,
- SCREENSHOT_CAN_SHOOT_REGION = 0x1 << 3
+ SCREENSHOT_CAN_SHOOT_REGION = 0x1 << 3,
+ SCREENSHOT_CAN_PICK_WINDOW = 0x1 << 4
} ScreenshotCapabilities;
typedef enum
@@ -57,6 +58,7 @@ typedef struct
guint window_id;
gint monitor;
guint select_delay;
+ guint screenshot_delay;
gint x1;
gint y1;
gint x2;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]