Commit 13d37cd0 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

implemented the --import-photos argument

parent 1802fdb9
......@@ -26,6 +26,7 @@
#include <glib-object.h>
#include <gthumb.h>
#include "actions.h"
#include "dlg-photo-importer.h"
#define BROWSER_DATA_KEY "photo-importer-browser-data"
......@@ -90,3 +91,11 @@ pi__gth_browser_construct_cb (GthBrowser *browser)
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
}
void
pi__import_photos_cb (GthBrowser *browser,
GFile *source)
{
dlg_photo_importer (browser, source);
}
......@@ -26,5 +26,7 @@
#include <gthumb.h>
void pi__gth_browser_construct_cb (GthBrowser *browser);
void pi__import_photos_cb (GthBrowser *browser,
GFile *source);
#endif /* CALLBACKS_H */
......@@ -134,6 +134,9 @@ destroy_dialog (gpointer user_data)
_g_object_list_unref (data->files);
_g_string_list_free (data->general_tests);
if (! data->import && ImportPhotos)
gth_window_close (GTH_WINDOW (data->browser));
g_free (data);
}
......
......@@ -54,6 +54,9 @@ gth_import_task_finalize (GObject *object)
self = GTH_IMPORT_TASK (object);
if (ImportPhotos)
gtk_window_present (GTK_WINDOW (self->priv->browser));
_g_object_list_unref (self->priv->files);
g_object_unref (self->priv->destination);
_g_object_unref (self->priv->destination_file);
......
......@@ -30,6 +30,7 @@
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
gth_hook_add_callback ("import-photos", 10, G_CALLBACK (pi__import_photos_cb), NULL);
gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (pi__gth_browser_construct_cb), NULL);
}
......
......@@ -1750,33 +1750,35 @@ _gth_browser_close_final_step (gpointer user_data)
/* Save visualization options only if the window is not maximized. */
state = gdk_window_get_state (GTK_WIDGET (browser)->window);
maximized = (state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
if (! maximized && GTK_WIDGET_VISIBLE (browser)) {
int width, height;
gdk_drawable_get_size (GTK_WIDGET (browser)->window, &width, &height);
eel_gconf_set_integer (PREF_UI_WINDOW_WIDTH, width);
eel_gconf_set_integer (PREF_UI_WINDOW_HEIGHT, height);
}
if (GTK_WIDGET_REALIZED (browser)) {
state = gdk_window_get_state (GTK_WIDGET (browser)->window);
maximized = (state & GDK_WINDOW_STATE_MAXIMIZED) != 0;
if (! maximized && GTK_WIDGET_VISIBLE (browser)) {
int width, height;
gdk_drawable_get_size (GTK_WIDGET (browser)->window, &width, &height);
eel_gconf_set_integer (PREF_UI_WINDOW_WIDTH, width);
eel_gconf_set_integer (PREF_UI_WINDOW_HEIGHT, height);
}
pos = gtk_paned_get_position (GTK_PANED (browser->priv->browser_container));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_BROWSER_SIDEBAR_WIDTH, pos);
pos = gtk_paned_get_position (GTK_PANED (browser->priv->browser_container));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_BROWSER_SIDEBAR_WIDTH, pos);
pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->viewer_pane));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, pos);
pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->viewer_pane));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_VIEWER_SIDEBAR_WIDTH, pos);
pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->browser_sidebar));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_PROPERTIES_HEIGHT, pos);
pos = _gtk_paned_get_position2 (GTK_PANED (browser->priv->browser_sidebar));
if (pos > 0)
eel_gconf_set_integer (PREF_UI_PROPERTIES_HEIGHT, pos);
}
/**/
gth_hook_invoke ("gth-browser-close", browser);
if (last_window) {
if (GTK_WIDGET_REALIZED (browser) && last_window) {
if (eel_gconf_get_boolean (PREF_GO_TO_LAST_LOCATION, TRUE)
&& (browser->priv->location != NULL))
{
......
......@@ -177,4 +177,13 @@ gth_main_register_default_hooks (void)
* @builder (GtkBuilder*): the dialog ui builder.
**/
gth_hook_register ("dlg-preferences-apply", 3);
/**
* Called at start up time if the --import-photos argument is
* specified.
*
* @browser (GthBrowser*): the main window.
* @file (GFile *): import from this location
**/
gth_hook_register ("import-photos", 2);
}
......@@ -199,7 +199,16 @@ unique_app_message_received_cb (UniqueApp *unique_app,
break;
case COMMAND_IMPORT_PHOTOS:
/* gth_browser_activate_action_file_camera_import (NULL, NULL); */
window = gth_window_get_current_window ();
if (window == NULL)
window = gth_browser_new (NULL);
uri = unique_message_data_get_text (message);
location = g_file_new_for_uri (uri);
gth_hook_invoke ("import-photos", window, location, NULL);
g_object_unref (location);
g_free (uri);
break;
default:
......@@ -236,6 +245,30 @@ open_browser_window (GFile *location)
}
static void
import_photos_from_location (GFile *location)
{
if (unique_app_is_running (gthumb_app)) {
UniqueMessageData *data;
char *uri;
data = unique_message_data_new ();
uri = g_file_get_uri (location);
unique_message_data_set_text (data, uri, -1);
unique_app_send_message (gthumb_app, COMMAND_IMPORT_PHOTOS, data);
g_free (uri);
unique_message_data_free (data);
}
else {
GtkWidget *window;
window = gth_browser_new (NULL);
gth_hook_invoke ("import-photos", window, location, NULL);
}
}
static void
prepare_application (void)
{
......@@ -279,6 +312,15 @@ prepare_application (void)
return;
}
if (ImportPhotos) {
GFile *location;
location = g_file_new_for_commandline_arg (remaining_args[0]);
import_photos_from_location (location);
return;
}
/* open each location in a new window */
for (i = 0; (arg = remaining_args[i]) != NULL; i++) {
......
......@@ -25,6 +25,11 @@
G_BEGIN_DECLS
extern gboolean NewWindow;
extern gboolean StartInFullscreen;
extern gboolean StartSlideshow;
extern gboolean ImportPhotos;
void gth_restart (void);
G_END_DECLS
......
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