plug-ins: convert screenshot-win32 to gegl

and do some repairs.
This commit is contained in:
Hartmut Kuhse 2016-05-28 17:56:14 +02:00
parent 49c81ffc44
commit 4a7d1e59f9
4 changed files with 45 additions and 56 deletions

View File

@ -100,17 +100,6 @@ typedef struct {
GtkWidget *delay_spinner; GtkWidget *delay_spinner;
} WinSnapInterface; } WinSnapInterface;
/* The dialog data */
static WinSnapInterface winsnapintf =
{
#ifdef CAN_SET_DECOR
NULL,
#endif
NULL,
NULL,
NULL
};
/* We create a DIB section to hold the grabbed area. The scanlines in /* We create a DIB section to hold the grabbed area. The scanlines in
* DIB sections are aligned ona LONG (four byte) boundary. Its pixel * DIB sections are aligned ona LONG (four byte) boundary. Its pixel
* data is in RGB (BGR actually) format, three bytes per pixel. * data is in RGB (BGR actually) format, three bytes per pixel.
@ -135,8 +124,7 @@ screenshot_win32_available (void)
ScreenshotCapabilities ScreenshotCapabilities
screenshot_win32_get_capabilities (void) screenshot_win32_get_capabilities (void)
{ {
return (SCREENSHOT_CAN_SHOOT_DECORATIONS | return (SCREENSHOT_CAN_SHOOT_DECORATIONS);
SCREENSHOT_CAN_SHOOT_POINTER);
} }
GimpPDBStatusType GimpPDBStatusType
@ -212,12 +200,12 @@ flipRedAndBlueBytes(int width, int height)
static void static void
sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect) sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect)
{ {
int width, height; int width, height;
int imageType, layerType; int imageType, layerType;
gint32 new_image_id; gint32 new_image_id;
gint32 layer_id; gint32 layer_id;
GimpPixelRgn pixel_rgn; GeglBuffer *buffer;
GimpDrawable *drawable; GeglRectangle *rectangle;
/* Our width and height */ /* Our width and height */
width = (rect.right - rect.left); width = (rect.right - rect.left);
@ -244,20 +232,22 @@ sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect)
layerType, 100, GIMP_NORMAL_MODE); layerType, 100, GIMP_NORMAL_MODE);
gimp_image_insert_layer(new_image_id, layer_id, -1, 0); gimp_image_insert_layer(new_image_id, layer_id, -1, 0);
/* Get our drawable */ /* make rectangle */
drawable = gimp_drawable_get(layer_id); rectangle = g_new (GeglRectangle, 1);
rectangle->x = 0;
rectangle->y = 0;
rectangle->width = ROUND4(width);
rectangle->height = height;
gimp_tile_cache_size(ROUND4(width) * gimp_tile_height() * 3); /* get the buffer */
buffer = gimp_drawable_get_buffer (layer_id);
/* Initialize a pixel region for writing to the image */ /* fill the buffer */
gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, gegl_buffer_set (buffer, rectangle, 0, NULL, (guchar *) capBytes, GEGL_AUTO_ROWSTRIDE);
ROUND4(width), height, TRUE, FALSE);
gimp_pixel_rgn_set_rect(&pixel_rgn, (guchar *) capBytes, /* flushing data */
0, 0, ROUND4(width), height); gegl_buffer_flush (buffer);
/* HB: update data BEFORE size change */
gimp_drawable_flush(drawable);
/* Now resize the layer down to the correct size if necessary. */ /* Now resize the layer down to the correct size if necessary. */
if (width != ROUND4(width)) { if (width != ROUND4(width)) {
gimp_layer_resize (layer_id, width, height, 0, 0); gimp_layer_resize (layer_id, width, height, 0, 0);
@ -288,19 +278,6 @@ doWindowCapture(void)
winsnapWinMain(); winsnapWinMain();
} }
/*
* doRootWindowCapture
*
* Capture the root window
* ENTRY POINT FOR WINSNAP ROOT
*/
static void
doRootWindowCapture(void)
{
/* Do the window capture */
doCapture(0);
}
/****************************************************************** /******************************************************************
* Debug stuff * Debug stuff
******************************************************************/ ******************************************************************/

View File

@ -430,10 +430,14 @@ shoot_dialog (GdkScreen **screen)
shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_REGION, shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_REGION,
_("After the delay, drag your mouse to select " _("After the delay, drag your mouse to select "
"the region for the screenshot.")); "the region for the screenshot."));
#ifdef G_OS_WIN32
shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_WINDOW,
_("Click in a window to snap it after delay."));
#else
shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_WINDOW, shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), SHOOT_WINDOW,
_("At the end of the delay, click in a window " _("At the end of the delay, click in a window "
"to snap it.")); "to snap it."));
#endif
gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), shootvals.shoot_type); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), shootvals.shoot_type);
/* Area */ /* Area */
@ -527,20 +531,23 @@ shoot_dialog (GdkScreen **screen)
shootvals.shoot_type == SHOOT_ROOT); shootvals.shoot_type == SHOOT_ROOT);
/* dragged region */ /* dragged region */
button = gtk_radio_button_new_with_mnemonic (radio_group, if (capabilities & SCREENSHOT_CAN_SHOOT_REGION)
_("Select a _region to grab")); {
radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); button = gtk_radio_button_new_with_mnemonic (radio_group,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), _("Select a _region to grab"));
shootvals.shoot_type == SHOOT_REGION); radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button),
gtk_widget_show (button); shootvals.shoot_type == SHOOT_REGION);
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", g_object_set_data (G_OBJECT (button), "gimp-item-data",
GINT_TO_POINTER (SHOOT_REGION)); GINT_TO_POINTER (SHOOT_REGION));
g_signal_connect (button, "toggled", g_signal_connect (button, "toggled",
G_CALLBACK (shoot_radio_button_toggled), G_CALLBACK (shoot_radio_button_toggled),
notebook); notebook);
}
/* Delay */ /* Delay */
frame = gimp_frame_new (_("Delay")); frame = gimp_frame_new (_("Delay"));

View File

@ -32,7 +32,8 @@ typedef enum
{ {
SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0, SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0,
SCREENSHOT_CAN_SHOOT_POINTER = 0x1 << 1, SCREENSHOT_CAN_SHOOT_POINTER = 0x1 << 1,
SCREENSHOT_CAN_PICK_NONINTERACTIVELY = 0x1 << 2 SCREENSHOT_CAN_PICK_NONINTERACTIVELY = 0x1 << 2,
SCREENSHOT_CAN_SHOOT_REGION = 0x1 << 3
} ScreenshotCapabilities; } ScreenshotCapabilities;
typedef enum typedef enum

View File

@ -10921,6 +10921,10 @@ msgstr ""
"aus." "aus."
#: ../plug-ins/screenshot/screenshot.c:434 #: ../plug-ins/screenshot/screenshot.c:434
msgid "Click in a window to snap it after delay."
msgstr "Klicken Sie in das am Ende der Verzögerung zu fotografierende Fenster."
#: ../plug-ins/screenshot/screenshot.c:437
msgid "At the end of the delay, click in a window to snap it." msgid "At the end of the delay, click in a window to snap it."
msgstr "Klicken Sie am Ende der Verzögerung in das zu fotografierende Fenster." msgstr "Klicken Sie am Ende der Verzögerung in das zu fotografierende Fenster."