Commit 80490a2c authored by Jehan's avatar Jehan

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.
parent 5289afad
......@@ -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
......
......@@ -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
......
......@@ -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);
}
......
......@@ -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
......
......@@ -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;
......
......@@ -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 "
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment