[Xfce4-commits] [apps/xfce4-screenshooter] 04/04: Extended save function to also take files (Bug #14156)
noreply at xfce.org
noreply at xfce.org
Sat Jan 5 22:27:22 CET 2019
This is an automated email from the git hooks/post-receive script.
a n d r e p u s h e d a c o m m i t t o b r a n c h m a s t e r
in repository apps/xfce4-screenshooter.
commit 64998063015cf66c6d186feae0ae2d81ff320f69
Author: Arthur Jansen <arthurj155 at gmail.com>
Date: Sat Jan 5 18:26:02 2019 -0300
Extended save function to also take files (Bug #14156)
---
lib/screenshooter-actions.c | 43 +++++++++++++++++++---------------
lib/screenshooter-dialogs.c | 56 ++++++++++++++++++++++-----------------------
lib/screenshooter-dialogs.h | 5 ++--
lib/screenshooter-global.h | 1 +
src/main.c | 16 +++++--------
5 files changed, 60 insertions(+), 61 deletions(-)
diff --git a/lib/screenshooter-actions.c b/lib/screenshooter-actions.c
index 3504954..a96dc37 100644
--- a/lib/screenshooter-actions.c
+++ b/lib/screenshooter-actions.c
@@ -70,26 +70,31 @@ action_idle (ScreenshotData *sd)
if (sd->action & SAVE)
{
- const gchar *save_location;
-
- if (sd->screenshot_dir == NULL)
- sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
-
- save_location = screenshooter_save_screenshot (sd->screenshot,
- sd->screenshot_dir,
- sd->title,
- sd->timestamp,
- TRUE,
- TRUE);
-
- if (save_location)
+ if (!sd->path_is_dir)
+ screenshooter_save_screenshot_to (sd->screenshot, sd->screenshot_dir);
+ else
{
- const gchar *temp;
-
- g_free (sd->screenshot_dir);
- temp = g_path_get_dirname (save_location);
- sd->screenshot_dir = g_build_filename ("file://", temp, NULL);
- TRACE ("New save directory: %s", sd->screenshot_dir);
+ const gchar *save_location;
+
+ if (sd->screenshot_dir == NULL)
+ sd->screenshot_dir = screenshooter_get_xdg_image_dir_uri ();
+
+ save_location = screenshooter_save_screenshot (sd->screenshot,
+ sd->screenshot_dir,
+ sd->title,
+ sd->timestamp,
+ TRUE,
+ TRUE);
+
+ if (save_location)
+ {
+ const gchar *temp;
+
+ g_free (sd->screenshot_dir);
+ temp = g_path_get_dirname (save_location);
+ sd->screenshot_dir = g_build_filename ("file://", temp, NULL);
+ TRACE ("New save directory: %s", sd->screenshot_dir);
+ }
}
}
else
diff --git a/lib/screenshooter-dialogs.c b/lib/screenshooter-dialogs.c
index af69b6a..41aef94 100644
--- a/lib/screenshooter-dialogs.c
+++ b/lib/screenshooter-dialogs.c
@@ -93,9 +93,6 @@ static gchar
static void
save_screenshot_to_remote_location (GdkPixbuf *screenshot,
GFile *save_file);
-static gchar
-*save_screenshot_to (GdkPixbuf *screenshot,
- const gchar *save_uri);
@@ -610,30 +607,6 @@ save_screenshot_to_remote_location (GdkPixbuf *screenshot, GFile *save_file)
g_free (save_path);
}
-static gchar
-*save_screenshot_to (GdkPixbuf *screenshot, const gchar *save_uri)
-{
- GFile *save_file = g_file_new_for_uri (save_uri);
- gchar *result = NULL;
-
- if (save_uri == NULL)
- {
- g_object_unref (save_file);
- return NULL;
- }
-
- /* If the URI is a local one, we save directly */
-
- if (!screenshooter_is_remote_uri (save_uri))
- result = save_screenshot_to_local_path (screenshot, save_file);
- else
- save_screenshot_to_remote_location (screenshot, save_file);
-
- g_object_unref (save_file);
-
- return result;
-}
-
static void
preview_drag_begin (GtkWidget *widget, GdkDragContext *context, gpointer data)
{
@@ -1184,7 +1157,7 @@ gchar
{
g_free (save_uri);
save_uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (chooser));
- result = save_screenshot_to (screenshot, save_uri);
+ result = screenshooter_save_screenshot_to (screenshot, save_uri);
}
else
result = NULL;
@@ -1192,9 +1165,34 @@ gchar
gtk_widget_destroy (chooser);
}
else
- result = save_screenshot_to (screenshot, save_uri);
+ result = screenshooter_save_screenshot_to (screenshot, save_uri);
g_free (save_uri);
return result;
}
+
+gchar
+*screenshooter_save_screenshot_to (GdkPixbuf *screenshot,
+ const gchar *save_uri)
+{
+ GFile *save_file = g_file_new_for_uri (save_uri);
+ gchar *result = NULL;
+
+ if (save_uri == NULL)
+ {
+ g_object_unref (save_file);
+ return NULL;
+ }
+
+ /* If the URI is a local one, we save directly */
+
+ if (!screenshooter_is_remote_uri (save_uri))
+ result = save_screenshot_to_local_path (screenshot, save_file);
+ else
+ save_screenshot_to_remote_location (screenshot, save_file);
+
+ g_object_unref (save_file);
+
+ return result;
+}
diff --git a/lib/screenshooter-dialogs.h b/lib/screenshooter-dialogs.h
index 33121a3..823330a 100644
--- a/lib/screenshooter-dialogs.h
+++ b/lib/screenshooter-dialogs.h
@@ -45,8 +45,7 @@ gchar *screenshooter_save_screenshot (GdkPixbuf *screenshot,
gboolean timestamp,
gboolean save_dialog,
gboolean show_preview);
-
-
-
+gchar *screenshooter_save_screenshot_to (GdkPixbuf *screenshot,
+ const gchar *save_uri);
#endif
diff --git a/lib/screenshooter-global.h b/lib/screenshooter-global.h
index 1fc1c75..6280298 100644
--- a/lib/screenshooter-global.h
+++ b/lib/screenshooter-global.h
@@ -50,6 +50,7 @@ typedef struct
gboolean action_specified;
gboolean region_specified;
gboolean timestamp;
+ gboolean path_is_dir;
gchar *screenshot_dir;
gchar *title;
gchar *app;
diff --git a/src/main.c b/src/main.c
index 5e92cc3..a6ebb38 100644
--- a/src/main.c
+++ b/src/main.c
@@ -306,16 +306,12 @@ int main (int argc, char **argv)
{
default_save_dir = g_file_new_for_commandline_arg (screenshot_dir);
- if (G_LIKELY (g_file_query_exists (default_save_dir, NULL)))
- {
- g_free (sd->screenshot_dir);
- sd->screenshot_dir = g_file_get_uri (default_save_dir);
- sd->action_specified = TRUE;
- }
- else
- screenshooter_error (_("%s is not a valid directory, the default"
- " directory will be used."),
- screenshot_dir);
+ sd->action_specified = TRUE;
+ g_free (sd->screenshot_dir);
+ sd->screenshot_dir = g_file_get_uri (default_save_dir);
+
+ // Check if given path is a directory
+ sd->path_is_dir = g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR);
g_object_unref (default_save_dir);
g_free (screenshot_dir);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list