From 4a7d1e59f9a6ca72bb3690cb0ea41345dab3e41e Mon Sep 17 00:00:00 2001 From: Hartmut Kuhse Date: Sat, 28 May 2016 17:56:14 +0200 Subject: [PATCH] plug-ins: convert screenshot-win32 to gegl and do some repairs. --- plug-ins/screenshot/screenshot-win32.c | 61 ++++++++------------------ plug-ins/screenshot/screenshot.c | 33 ++++++++------ plug-ins/screenshot/screenshot.h | 3 +- po-plug-ins/de.po | 4 ++ 4 files changed, 45 insertions(+), 56 deletions(-) diff --git a/plug-ins/screenshot/screenshot-win32.c b/plug-ins/screenshot/screenshot-win32.c index 23330359a4..4a8854747c 100644 --- a/plug-ins/screenshot/screenshot-win32.c +++ b/plug-ins/screenshot/screenshot-win32.c @@ -100,17 +100,6 @@ typedef struct { GtkWidget *delay_spinner; } 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 * DIB sections are aligned ona LONG (four byte) boundary. Its pixel * data is in RGB (BGR actually) format, three bytes per pixel. @@ -135,8 +124,7 @@ screenshot_win32_available (void) ScreenshotCapabilities screenshot_win32_get_capabilities (void) { - return (SCREENSHOT_CAN_SHOOT_DECORATIONS | - SCREENSHOT_CAN_SHOOT_POINTER); + return (SCREENSHOT_CAN_SHOOT_DECORATIONS); } GimpPDBStatusType @@ -212,12 +200,12 @@ flipRedAndBlueBytes(int width, int height) static void sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect) { - int width, height; - int imageType, layerType; - gint32 new_image_id; - gint32 layer_id; - GimpPixelRgn pixel_rgn; - GimpDrawable *drawable; + int width, height; + int imageType, layerType; + gint32 new_image_id; + gint32 layer_id; + GeglBuffer *buffer; + GeglRectangle *rectangle; /* Our width and height */ width = (rect.right - rect.left); @@ -244,20 +232,22 @@ sendBMPToGimp(HBITMAP hBMP, HDC hDC, RECT rect) layerType, 100, GIMP_NORMAL_MODE); gimp_image_insert_layer(new_image_id, layer_id, -1, 0); - /* Get our drawable */ - drawable = gimp_drawable_get(layer_id); + /* make rectangle */ + 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 */ - gimp_pixel_rgn_init(&pixel_rgn, drawable, 0, 0, - ROUND4(width), height, TRUE, FALSE); + /* fill the buffer */ + gegl_buffer_set (buffer, rectangle, 0, NULL, (guchar *) capBytes, GEGL_AUTO_ROWSTRIDE); - gimp_pixel_rgn_set_rect(&pixel_rgn, (guchar *) capBytes, - 0, 0, ROUND4(width), height); + /* flushing data */ + 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. */ if (width != ROUND4(width)) { gimp_layer_resize (layer_id, width, height, 0, 0); @@ -288,19 +278,6 @@ doWindowCapture(void) winsnapWinMain(); } -/* - * doRootWindowCapture - * - * Capture the root window - * ENTRY POINT FOR WINSNAP ROOT - */ -static void -doRootWindowCapture(void) -{ - /* Do the window capture */ - doCapture(0); -} - /****************************************************************** * Debug stuff ******************************************************************/ diff --git a/plug-ins/screenshot/screenshot.c b/plug-ins/screenshot/screenshot.c index 2d35e41242..6d35eed629 100644 --- a/plug-ins/screenshot/screenshot.c +++ b/plug-ins/screenshot/screenshot.c @@ -430,10 +430,14 @@ shoot_dialog (GdkScreen **screen) shoot_dialog_add_hint (GTK_NOTEBOOK (notebook), 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, + _("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.")); - +#endif gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), shootvals.shoot_type); /* Area */ @@ -527,20 +531,23 @@ shoot_dialog (GdkScreen **screen) shootvals.shoot_type == SHOOT_ROOT); /* dragged region */ - button = gtk_radio_button_new_with_mnemonic (radio_group, - _("Select a _region to grab")); - radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), - shootvals.shoot_type == SHOOT_REGION); - gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_widget_show (button); + if (capabilities & SCREENSHOT_CAN_SHOOT_REGION) + { + button = gtk_radio_button_new_with_mnemonic (radio_group, + _("Select a _region to grab")); + radio_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)); + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (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", - GINT_TO_POINTER (SHOOT_REGION)); + g_object_set_data (G_OBJECT (button), "gimp-item-data", + GINT_TO_POINTER (SHOOT_REGION)); - g_signal_connect (button, "toggled", - G_CALLBACK (shoot_radio_button_toggled), - notebook); + g_signal_connect (button, "toggled", + G_CALLBACK (shoot_radio_button_toggled), + notebook); + } /* Delay */ frame = gimp_frame_new (_("Delay")); diff --git a/plug-ins/screenshot/screenshot.h b/plug-ins/screenshot/screenshot.h index 39fb5fe596..1b16905165 100644 --- a/plug-ins/screenshot/screenshot.h +++ b/plug-ins/screenshot/screenshot.h @@ -32,7 +32,8 @@ typedef enum { SCREENSHOT_CAN_SHOOT_DECORATIONS = 0x1 << 0, 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; typedef enum diff --git a/po-plug-ins/de.po b/po-plug-ins/de.po index b5da8abdcc..8272655fb8 100644 --- a/po-plug-ins/de.po +++ b/po-plug-ins/de.po @@ -10921,6 +10921,10 @@ msgstr "" "aus." #: ../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." msgstr "Klicken Sie am Ende der Verzögerung in das zu fotografierende Fenster."