Skip to content
Snippets Groups Projects
Commit 33d7824e authored by Jerome Guelfucci's avatar Jerome Guelfucci
Browse files

* src/main.c:

    - only read the preferences file once when using the application.
    - check if the directory name stored in the preferences still exists
      before trying to use it.
  * lib/screenshooter-actions.c: set home as the default folder for the
    file chooser, only use sd->screenshot_dir when we don't show the
    save dialog. This should be more transparent for the user.


(Old svn revision: 6370)
parent 9f513adb
No related branches found
No related tags found
No related merge requests found
2008-12-28 jeromeg
* src/main.c:
- only read the preferences file once when using the application.
- check if the directory name stored in the preferences still exists
before trying to use it.
* lib/screenshooter-actions.c: set home as the default folder for the
file chooser, only use sd->screenshot_dir when we don't show the
save dialog. This should be more transparent for the user.
2008-12-20 jeromeg 2008-12-20 jeromeg
* NEWS: updated. * NEWS: updated.
......
...@@ -26,9 +26,18 @@ void screenshooter_take_and_output_screenshot (ScreenshotData *sd) ...@@ -26,9 +26,18 @@ void screenshooter_take_and_output_screenshot (ScreenshotData *sd)
if (sd->action == SAVE) if (sd->action == SAVE)
{ {
screenshooter_save_screenshot (screenshot, if (sd->show_save_dialog == 1)
sd->show_save_dialog, {
sd->screenshot_dir); screenshooter_save_screenshot (screenshot,
1,
g_strdup (DEFAULT_SAVE_DIRECTORY));
}
else
{
screenshooter_save_screenshot (screenshot,
0,
sd->screenshot_dir);
}
} }
else if (sd->action == CLIPBOARD) else if (sd->action == CLIPBOARD)
{ {
......
...@@ -170,13 +170,20 @@ int main(int argc, char **argv) ...@@ -170,13 +170,20 @@ int main(int argc, char **argv)
if (rc_file != NULL) if (rc_file != NULL)
g_free (rc_file); g_free (rc_file);
/* Check if the directory read from the preferences is valid */
if (!g_file_test (sd->screenshot_dir, G_FILE_TEST_IS_DIR))
{
sd->screenshot_dir = g_strdup (DEFAULT_SAVE_DIRECTORY);
}
/* Print a message to advise to use help when a non existing cli option is /* Print a message to advise to use help when a non existing cli option is
passed to the executable. */ passed to the executable. */
if (!gtk_init_with_args(&argc, &argv, _(""), entries, PACKAGE, &cli_error)) if (!gtk_init_with_args(&argc, &argv, _(""), entries, PACKAGE, &cli_error))
{ {
if (cli_error != NULL) if (cli_error != NULL)
{ {
g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), g_print (_("%s: %s\nTry %s --help to see a full list of"
" available command line options.\n"),
PACKAGE, cli_error->message, PACKAGE_NAME); PACKAGE, cli_error->message, PACKAGE_NAME);
g_error_free (cli_error); g_error_free (cli_error);
return 1; return 1;
...@@ -189,99 +196,90 @@ int main(int argc, char **argv) ...@@ -189,99 +196,90 @@ int main(int argc, char **argv)
g_print ("%s\n", PACKAGE_STRING); g_print ("%s\n", PACKAGE_STRING);
return 0; return 0;
} }
/* If -w is given to the executable, grab the active window, else just /* If a mode cli option is given, take the screenshot accordingly. */
* grab the desktop.*/ if (fullscreen || window || region)
if (window)
{
sd->mode = ACTIVE_WINDOW;
}
else if (fullscreen)
{
sd->mode = FULLSCREEN;
}
else if (region)
{
sd->mode = RECTANGLE;
}
/* Wether to show the save dialog allowing to choose a filename and a save
location */
if (no_save_dialog)
{
sd->show_save_dialog = 0;
}
else
{ {
sd->show_save_dialog = 1; /* Set the region to be captured */
} if (window)
{
sd->mode = ACTIVE_WINDOW;
}
else if (fullscreen)
{
sd->mode = FULLSCREEN;
}
else if (region)
{
sd->mode = RECTANGLE;
}
/* Wether to show the save dialog allowing to choose a filename
* and a save location */
if (no_save_dialog)
{
sd->show_save_dialog = 0;
}
else
{
sd->show_save_dialog = 1;
}
sd->delay = delay; sd->delay = delay;
if (application != NULL) if (application != NULL)
{
sd->app = application;
sd->action = OPEN;
}
else
{
sd->app = g_strdup ("none");
sd->action = SAVE;
}
/* If the user gave a directory name, verify that it is valid */
if (screenshot_dir != NULL)
{
if (g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR))
{ {
/* Check if the path is absolute, if not make it absolute */ sd->app = application;
if (g_path_is_absolute (screenshot_dir)) sd->action = OPEN;
{ }
g_free (sd->screenshot_dir); else
{
sd->screenshot_dir = screenshot_dir; sd->app = g_strdup ("none");
sd->action = SAVE;
}
/* If the user gave a directory name, verify that it is valid */
if (screenshot_dir != NULL)
{
if (g_file_test (screenshot_dir, G_FILE_TEST_IS_DIR))
{
/* Check if the path is absolute, if not make it
* absolute */
if (g_path_is_absolute (screenshot_dir))
{
g_free (sd->screenshot_dir);
sd->screenshot_dir = screenshot_dir;
}
else
{
g_free (sd->screenshot_dir);
sd->screenshot_dir =
g_build_filename (g_get_current_dir (),
screenshot_dir,
NULL);
g_free (screenshot_dir);
}
} }
else else
{ {
g_free (sd->screenshot_dir); g_warning (_("%s is not a valid directory, the default"
" directory will be used."),
sd->screenshot_dir = screenshot_dir);
g_build_filename (g_get_current_dir (),
screenshot_dir,
NULL);
g_free (screenshot_dir); g_free (screenshot_dir);
} }
} }
else
{
g_warning (_("%s is not a valid directory, the default directory"
" will be used."),
screenshot_dir);
g_free (screenshot_dir);
}
}
/* If a mode cli option is given, take the screenshot accordingly. */
if (fullscreen || window || region)
{
screenshooter_take_and_output_screenshot (sd); screenshooter_take_and_output_screenshot (sd);
} }
/* Else we just show up the main application */ /* Else we just show up the main application */
else else
{ {
GtkWidget *dialog; GtkWidget *dialog;
rc_file = xfce_resource_lookup (XFCE_RESOURCE_CONFIG,
"xfce4/xfce4-screenshooter");
/* Read the preferences */
screenshooter_read_rc_file (rc_file, sd);
if (rc_file != NULL)
g_free (rc_file);
/* Set the dialog up */ /* Set the dialog up */
dialog = screenshooter_dialog_new (sd, FALSE); dialog = screenshooter_dialog_new (sd, FALSE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment