[Goodies-commits] r6865 - in xfce4-screenshooter/trunk: . lib
Jerome Guelfucci
jeromeg at xfce.org
Sun Mar 8 12:05:29 CET 2009
Author: jeromeg
Date: 2009-03-08 11:05:28 +0000 (Sun, 08 Mar 2009)
New Revision: 6865
Modified:
xfce4-screenshooter/trunk/ChangeLog
xfce4-screenshooter/trunk/NEWS
xfce4-screenshooter/trunk/lib/screenshooter-actions.c
xfce4-screenshooter/trunk/lib/screenshooter-utils.c
Log:
Cancel region screenshots when Escape is pressed.
Modified: xfce4-screenshooter/trunk/ChangeLog
===================================================================
--- xfce4-screenshooter/trunk/ChangeLog 2009-03-08 09:44:45 UTC (rev 6864)
+++ xfce4-screenshooter/trunk/ChangeLog 2009-03-08 11:05:28 UTC (rev 6865)
@@ -1,5 +1,18 @@
2009-03-08 jeromeg
+ Now, when taking a region screenshot, the Escape key cancels everything.
+
+ * lib/screenshooter-actions.c: don't do anything if the screenshot is
+ NULL.
+ * lib/screenshooter-utils.c
+ - include the keysim header.
+ - (get_rectangle_screenshot):
+ + grab the keyboard.
+ + cancel the screenshot if escape is pressed.
+ + return NULL if the screenshot was cancelled.
+
+2009-03-08 jeromeg
+
* lib/screenshooter-dialogs.c (screenshooter_dialog_new): add some
padding for the new check box to separate it from the radio button
group.
Modified: xfce4-screenshooter/trunk/NEWS
===================================================================
--- xfce4-screenshooter/trunk/NEWS 2009-03-08 09:44:45 UTC (rev 6864)
+++ xfce4-screenshooter/trunk/NEWS 2009-03-08 11:05:28 UTC (rev 6865)
@@ -5,6 +5,8 @@
on screenshots.
- Add a CLI option to hide the mouse pointer on screenshots.
- Make the main dialog more compact by simplifying the user interface.
+ - When selecting a region to be screenshooted, you can now use the Escape
+ keyboard key to cancel the operation.
=== Version 1.5.1 ===
Modified: xfce4-screenshooter/trunk/lib/screenshooter-actions.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-03-08 09:44:45 UTC (rev 6864)
+++ xfce4-screenshooter/trunk/lib/screenshooter-actions.c 2009-03-08 11:05:28 UTC (rev 6865)
@@ -24,39 +24,43 @@
GdkPixbuf *screenshot =
screenshooter_take_screenshot (sd->region, sd->delay, sd->show_mouse);
- if (sd->action == SAVE)
+ if (screenshot != NULL)
{
- if (sd->screenshot_dir == NULL)
+ if (sd->action == SAVE)
{
- sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
+ if (sd->screenshot_dir == NULL)
+ {
+ sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
+ }
+
+ screenshooter_save_screenshot (screenshot,
+ sd->show_save_dialog,
+ sd->screenshot_dir);
}
+ else if (sd->action == CLIPBOARD)
+ {
+ screenshooter_copy_to_clipboard (screenshot);
+ }
+ else
+ {
+ gchar *tempdir = g_strdup (g_get_tmp_dir ());
- screenshooter_save_screenshot (screenshot,
- sd->show_save_dialog,
- sd->screenshot_dir);
- }
- else if (sd->action == CLIPBOARD)
- {
- screenshooter_copy_to_clipboard (screenshot);
- }
- else
- {
- gchar *tempdir = g_strdup (g_get_tmp_dir ());
+ gchar *screenshot_path =
+ screenshooter_save_screenshot (screenshot,
+ FALSE,
+ tempdir);
+ if (screenshot_path != NULL)
+ {
+ screenshooter_open_screenshot (screenshot_path, sd->app);
+ g_free (screenshot_path);
+ }
- gchar *screenshot_path =
- screenshooter_save_screenshot (screenshot,
- FALSE,
- tempdir);
- if (screenshot_path != NULL)
- {
- screenshooter_open_screenshot (screenshot_path, sd->app);
- g_free (screenshot_path);
+ if (tempdir != NULL)
+ g_free (tempdir);
}
- if (tempdir != NULL)
- g_free (tempdir);
+ g_object_unref (screenshot);
}
- g_object_unref (screenshot);
}
Modified: xfce4-screenshooter/trunk/lib/screenshooter-utils.c
===================================================================
--- xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-03-08 09:44:45 UTC (rev 6864)
+++ xfce4-screenshooter/trunk/lib/screenshooter-utils.c 2009-03-08 11:05:28 UTC (rev 6865)
@@ -19,6 +19,8 @@
#include "screenshooter-utils.h"
+#include <gdk/gdkkeysyms.h>
+
/* Prototypes */
@@ -215,7 +217,7 @@
GdkGCValues gc_values;
GdkGC *gc;
- GdkGrabStatus grabstatus;
+ GdkGrabStatus grabstatus_mouse, grabstatus_keyboard;
GdkGCValuesMask values_mask =
GDK_GC_FUNCTION | GDK_GC_FILL | GDK_GC_CLIP_MASK |
@@ -233,6 +235,7 @@
gboolean pressed = FALSE;
gboolean done = FALSE;
+ gboolean cancelled = FALSE;
gint x, y, w, h;
/*Set up graphics context for a XOR rectangle that will be drawn as
@@ -258,10 +261,13 @@
/* Change cursor to cross-hair */
TRACE ("Set the cursor");
- grabstatus = gdk_pointer_grab (root_window, FALSE, mask,
+ grabstatus_mouse = gdk_pointer_grab (root_window, FALSE, mask,
NULL, xhair_cursor, GDK_CURRENT_TIME);
+
+ grabstatus_keyboard = gdk_keyboard_grab (root_window, FALSE, GDK_CURRENT_TIME);
- while (!done && grabstatus == GDK_GRAB_SUCCESS)
+ while (!done && grabstatus_mouse == GDK_GRAB_SUCCESS
+ && grabstatus_keyboard == GDK_GRAB_SUCCESS)
{
gint x1, y1, x2, y2;
GdkEvent *event;
@@ -319,15 +325,16 @@
TRACE ("Mouse is moving");
if (w > 0 && h > 0)
-
- /* Remove the rectangle drawn previously */
+ {
+ /* Remove the rectangle drawn previously */
- TRACE ("Remove the rectangle drawn previously");
+ TRACE ("Remove the rectangle drawn previously");
- gdk_draw_rectangle (root_window,
- gc,
- FALSE,
- x, y, w, h);
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
+ x, y, w, h);
+ }
x2 = event->motion.x;
y2 = event->motion.y;
@@ -349,6 +356,32 @@
}
break;
+
+ case GDK_KEY_PRESS:
+ if (event->key.keyval == GDK_Escape)
+ {
+ TRACE ("Escape key was pressed, cancel the screenshot.");
+
+ if (pressed)
+ {
+ if (w > 0 && h > 0)
+ {
+ /* Remove the rectangle drawn previously */
+
+ TRACE ("Remove the rectangle drawn previously");
+
+ gdk_draw_rectangle (root_window,
+ gc,
+ FALSE,
+ x, y, w, h);
+ }
+ }
+
+ done = TRUE;
+ cancelled = TRUE;
+ }
+
+ break;
default:
break;
@@ -357,20 +390,29 @@
gdk_event_free (event);
}
- if (grabstatus == GDK_GRAB_SUCCESS)
+ if (grabstatus_mouse == GDK_GRAB_SUCCESS)
{
TRACE ("Ungrab the pointer");
gdk_pointer_ungrab(GDK_CURRENT_TIME);
}
+
+ if (grabstatus_keyboard == GDK_GRAB_SUCCESS)
+ {
+ TRACE ("Ungrab the keyboard");
+
+ gdk_keyboard_ungrab (GDK_CURRENT_TIME);
+ }
/* Get the screenshot's pixbuf */
- TRACE ("Get the pixbuf for the screenshot");
-
- screenshot = gdk_pixbuf_get_from_drawable (NULL, root_window, NULL,
- x, y, 0, 0, w, h);
-
+ if (!cancelled)
+ {
+ TRACE ("Get the pixbuf for the screenshot");
+
+ screenshot = gdk_pixbuf_get_from_drawable (NULL, root_window, NULL,
+ x, y, 0, 0, w, h);
+ }
if (gc!=NULL)
g_object_unref (gc);
More information about the Goodies-commits
mailing list