summaryrefslogtreecommitdiff
path: root/mate-screenshot/mate-screenshot.c
diff options
context:
space:
mode:
authorinfirit <[email protected]>2014-11-10 17:46:47 +0100
committerinfirit <[email protected]>2014-11-10 17:46:47 +0100
commit435be8bdc4f0e9881b439825b16b29fecd02338e (patch)
treef310b6d7728ee49de111e067a74d000ed7f2b0a0 /mate-screenshot/mate-screenshot.c
parentc75635285af8b70a781c2314aa7b03b2af716835 (diff)
downloadmate-utils-435be8bdc4f0e9881b439825b16b29fecd02338e.tar.bz2
mate-utils-435be8bdc4f0e9881b439825b16b29fecd02338e.tar.xz
mate-screenshot: Several fixes taken from gnome-screenshot
Code taken from commits: screenshot: Rewrite event handling in area selection 772b9cc0774468ea21addb85ef843ee8dfef9e00 screenshot: add a workaround to avoid capturing the selection window 745eea03a3092fa055f76132971e3dd2bb4e8737 screenshot: Don't snap the selection 13741db3522aaac8be732567bca00d9c81929b72
Diffstat (limited to 'mate-screenshot/mate-screenshot.c')
-rw-r--r--mate-screenshot/mate-screenshot.c58
1 files changed, 30 insertions, 28 deletions
diff --git a/mate-screenshot/mate-screenshot.c b/mate-screenshot/mate-screenshot.c
index dcd325e4..45682b88 100644
--- a/mate-screenshot/mate-screenshot.c
+++ b/mate-screenshot/mate-screenshot.c
@@ -860,7 +860,10 @@ async_existence_job_free (AsyncExistenceJob *job)
g_free (job->base_uris[1]);
g_free (job->base_uris[2]);
- g_free (job->rectangle);
+
+ if (job->rectangle != NULL)
+ g_slice_free (GdkRectangle, job->rectangle);
+
g_slice_free (AsyncExistenceJob, job);
}
@@ -1050,35 +1053,11 @@ find_current_window (char **window_title)
return window;
}
-static GdkRectangle *
-find_rectangle (void)
-{
- GdkRectangle *rectangle;
-
- if (!take_area_shot)
- return NULL;
-
- rectangle = g_new0 (GdkRectangle, 1);
- if (screenshot_select_area (&rectangle->x, &rectangle->y,
- &rectangle->width, &rectangle->height))
- {
- g_assert (rectangle->width >= 0);
- g_assert (rectangle->height >= 0);
-
- return rectangle;
- }
- else
- {
- g_free (rectangle);
- return NULL;
- }
-}
-
static void
-prepare_screenshot (void)
+push_check_file_job (GdkRectangle *rectangle)
{
AsyncExistenceJob *job;
-
+
job = g_slice_new0 (AsyncExistenceJob);
job->base_uris[0] = last_save_dir;
/* we'll have to free these two */
@@ -1087,7 +1066,15 @@ prepare_screenshot (void)
job->iteration = 0;
job->type = TEST_LAST_DIR;
job->window = find_current_window (&window_title);
- job->rectangle = find_rectangle ();
+
+ if (rectangle != NULL)
+ {
+ job->rectangle = g_slice_new0 (GdkRectangle);
+ job->rectangle->x = rectangle->x;
+ job->rectangle->y = rectangle->y;
+ job->rectangle->width = rectangle->width;
+ job->rectangle->height = rectangle->height;
+ }
/* Check if the area selection was cancelled */
if (job->rectangle &&
@@ -1105,6 +1092,21 @@ prepare_screenshot (void)
}
+static void
+rectangle_found_cb (GdkRectangle *rectangle)
+{
+ push_check_file_job (rectangle);
+}
+
+static void
+prepare_screenshot (void)
+{
+ if (take_area_shot)
+ screenshot_select_area_async (rectangle_found_cb);
+ else
+ push_check_file_job (NULL);
+}
+
static gboolean
prepare_screenshot_timeout (gpointer data)
{