Commit adf94ad4 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

automatically select the last viewed file on startup if "Go to last visited...

automatically select the last viewed file on startup if  "Go to last visited folder or catalogue" option is on

[bug #451883, new feature]
parent 77f50257
......@@ -42,6 +42,19 @@
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/general/startup_current_file</key>
<applyto>/apps/gthumb/general/startup_current_file</applyto>
<owner>gthumb</owner>
<type>string</type>
<default></default>
<locale name="C">
<short></short>
<long>
</long>
</locale>
</schema>
<schema>
<key>/schemas/apps/gthumb/general/active_extensions</key>
<applyto>/apps/gthumb/general/active_extensions</applyto>
......
......@@ -2085,8 +2085,15 @@ _gth_browser_close_final_step (gpointer user_data)
uri = g_file_get_uri (browser->priv->location->file);
eel_gconf_set_path (PREF_STARTUP_LOCATION, uri);
g_free (uri);
if (browser->priv->current_file != NULL) {
uri = g_file_get_uri (browser->priv->current_file->file);
eel_gconf_set_path (PREF_STARTUP_CURRENT_FILE, uri);
g_free (uri);
}
else
eel_gconf_set_path (PREF_STARTUP_CURRENT_FILE, NULL);
}
if (browser->priv->default_sort_type != NULL) {
......
......@@ -33,6 +33,7 @@ G_BEGIN_DECLS
#define PREF_GO_TO_LAST_LOCATION "/apps/gthumb/general/go_to_last_location"
#define PREF_USE_STARTUP_LOCATION "/apps/gthumb/general/use_startup_location"
#define PREF_STARTUP_LOCATION "/apps/gthumb/general/startup_location"
#define PREF_STARTUP_CURRENT_FILE "/apps/gthumb/general/startup_current_file"
#define PREF_ACTIVE_EXTENSIONS "/apps/gthumb/general/active_extensions"
#define PREF_STORE_METADATA_IN_FILES "/apps/gthumb/general/store_metadata_in_files"
......
......@@ -31,6 +31,7 @@
#include <clutter-gtk/clutter-gtk.h>
#endif
#include "eggsmclient.h"
#include "gconf-utils.h"
#include "glib-utils.h"
#include "gth-browser.h"
#include "gth-file-data.h"
......@@ -345,7 +346,8 @@ unique_app_message_received_cb (UniqueApp *unique_app,
static void
open_browser_window (GFile *location)
open_browser_window (GFile *location,
GFile *current_file)
{
#ifdef HAVE_UNIQUE
if (unique_app_is_running (gthumb_app)) {
......@@ -370,7 +372,10 @@ open_browser_window (GFile *location)
window = gth_browser_new (NULL);
if (! StartSlideshow)
gtk_window_present (GTK_WINDOW (window));
gth_browser_load_location (GTH_BROWSER (window), location);
if (current_file != NULL)
gth_browser_go_to (GTH_BROWSER (window), location, current_file);
else
gth_browser_load_location (GTH_BROWSER (window), location);
}
}
......@@ -457,10 +462,16 @@ prepare_application (void)
if (remaining_args == NULL) { /* No location specified. */
GFile *location;
char *current_file_uri;
GFile *current_file;
location = g_file_new_for_uri (gth_pref_get_startup_location ());
open_browser_window (location);
current_file_uri = eel_gconf_get_path (PREF_STARTUP_CURRENT_FILE, NULL);
current_file = g_file_new_for_uri (current_file_uri);
open_browser_window (location, current_file);
g_object_unref (current_file);
g_free (current_file_uri);
g_object_unref (location);
return;
......@@ -486,17 +497,17 @@ prepare_application (void)
location = gth_hook_invoke_get ("command-line-files", files);
if (location != NULL) {
open_browser_window (location);
open_browser_window (location, NULL);
g_object_unref (location);
}
else /* Open each file in a new window */
for (scan = files; scan; scan = scan->next)
open_browser_window ((GFile *) scan->data);
open_browser_window ((GFile *) scan->data, NULL);
/* Open each dir in a new window */
for (scan = dirs; scan; scan = scan->next)
open_browser_window ((GFile *) scan->data);
open_browser_window ((GFile *) scan->data, NULL);
_g_object_list_unref (dirs);
_g_object_list_unref (files);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment