Updating branch refs/heads/master to 24b4274ed286948ee6e1e7b9ead825529bb0a51b (commit) from 062b0f1f7443308430ec246387e3408a79a1e8d7 (commit)
commit 24b4274ed286948ee6e1e7b9ead825529bb0a51b Author: Stephan Arts <step...@xfce.org> Date: Sat Sep 26 17:56:58 2009 +0200 Add option to load all images in a folder ChangeLog | 5 +++++ src/main.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- src/settings.c | 18 ++++++++++++++++++ 3 files changed, 69 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8aea31a..e90a328 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2009-09-26 Stephan Arts <step...@xfce.org> + * src/main.c, + src/settings.c: Add option to load all images in a folder + +2009-09-26 Stephan Arts <step...@xfce.org> + * src/main_window.c, src/image_list.c, src/thumbnailbar.c: Images can only be opened once diff --git a/src/main.c b/src/main.c index df9fbec..81f1d38 100644 --- a/src/main.c +++ b/src/main.c @@ -47,6 +47,7 @@ typedef struct { gchar **argv; gint iter; RsttoMainWindow *window; + gboolean open_entire_folder; } RsttoOpenFiles; static gboolean @@ -116,6 +117,7 @@ main(int argc, char **argv) rof.argv = argv; rof.iter = 1; rof.window = RSTTO_MAIN_WINDOW (window); + rof.open_entire_folder = rstto_settings_get_boolean_property (settings, "open-entire-folder"); g_idle_add ((GSourceFunc )cb_rstto_open_files, &rof); @@ -136,10 +138,35 @@ main(int argc, char **argv) static gboolean cb_rstto_open_files (RsttoOpenFiles *rof) { - GFile *file; + GFile *file, *p_file, *child_file; GFileInfo *file_info; - const gchar *content_type; - if (rof->iter < rof->argc) + const gchar *content_type, *filename; + + GFileEnumerator *file_enumarator = NULL; + + if ((rof->argc > 2) || (rof->open_entire_folder == FALSE)) + { + if (rof->iter < rof->argc) + { + file = g_file_new_for_commandline_arg (rof->argv[rof->iter]); + if (file) + { + file_info = g_file_query_info (file, "standard::content-type", 0, NULL, NULL); + if (file_info) + { + content_type = g_file_info_get_attribute_string (file_info, "standard::content-type"); + + if (strncmp (content_type, "image/", 6) == 0) + { + rstto_image_list_add_file (rof->image_list, file, NULL); + } + } + } + rof->iter++; + return TRUE; + } + } + else { file = g_file_new_for_commandline_arg (rof->argv[rof->iter]); if (file) @@ -155,8 +182,22 @@ cb_rstto_open_files (RsttoOpenFiles *rof) } } } - rof->iter++; - return TRUE; + p_file = g_file_get_parent (file); + file_enumarator = g_file_enumerate_children (p_file, "standard::*", 0, NULL, NULL); + for(file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL); file_info != NULL; file_info = g_file_enumerator_next_file (file_enumarator, NULL, NULL)) + { + filename = g_file_info_get_name (file_info); + content_type = g_file_info_get_content_type (file_info); + child_file = g_file_get_child (p_file, filename); + + if (strncmp (content_type, "image/", 6) == 0) + { + rstto_image_list_add_file (rof->image_list, child_file, NULL); + } + + g_object_unref (child_file); + g_object_unref (file_info); + } } return FALSE; } diff --git a/src/settings.c b/src/settings.c index 5629fc5..cc9c7ab 100644 --- a/src/settings.c +++ b/src/settings.c @@ -73,6 +73,7 @@ enum PROP_SLIDESHOW_TIMEOUT, PROP_SCROLLWHEEL_PRIMARY_ACTION, PROP_SCROLLWHEEL_SECONDARY_ACTION, + PROP_OPEN_ENTIRE_FOLDER, }; GType @@ -110,6 +111,7 @@ struct _RsttoSettingsPriv gboolean show_thumbnailbar; gboolean show_preview; gboolean hide_thumbnailbar_fullscreen; + gboolean open_entire_folder; gchar *navigationbar_position; guint preload_images; gboolean enable_cache; @@ -154,6 +156,7 @@ rstto_settings_init (GObject *object) xfconf_g_property_bind (settings->priv->channel, "/window/height", G_TYPE_UINT, settings, "window-height"); xfconf_g_property_bind (settings->priv->channel, "/file/current-uri", G_TYPE_STRING, settings, "current-uri"); + xfconf_g_property_bind (settings->priv->channel, "/file/open-entire-folder", G_TYPE_BOOLEAN, settings, "open-entire-folder"); xfconf_g_property_bind (settings->priv->channel, "/window/show-file-toolbar", G_TYPE_BOOLEAN, settings, "show-file-toolbar"); xfconf_g_property_bind (settings->priv->channel, "/window/show-navigation-toolbar", G_TYPE_BOOLEAN, settings, "show-nav-toolbar"); @@ -250,6 +253,15 @@ rstto_settings_class_init (GObjectClass *object_class) PROP_HIDE_THUMBNAILBAR_FULLSCREEN, pspec); + pspec = g_param_spec_boolean ("open-entire-folder", + "", + "", + TRUE, + G_PARAM_READWRITE); + g_object_class_install_property (object_class, + PROP_OPEN_ENTIRE_FOLDER, + pspec); + pspec = g_param_spec_string ("navigationbar-position", "", "", @@ -462,6 +474,9 @@ rstto_settings_set_property (GObject *object, case PROP_HIDE_THUMBNAILBAR_FULLSCREEN: settings->priv->hide_thumbnailbar_fullscreen = g_value_get_boolean (value); break; + case PROP_OPEN_ENTIRE_FOLDER: + settings->priv->open_entire_folder= g_value_get_boolean (value); + break; case PROP_NAVBAR_POSITION: str_val = g_value_get_string (value); @@ -557,6 +572,9 @@ rstto_settings_get_property (GObject *object, case PROP_HIDE_THUMBNAILBAR_FULLSCREEN: g_value_set_boolean (value, settings->priv->hide_thumbnailbar_fullscreen); break; + case PROP_OPEN_ENTIRE_FOLDER: + g_value_set_boolean (value, settings->priv->open_entire_folder); + break; case PROP_NAVBAR_POSITION: g_value_set_string (value, settings->priv->navigationbar_position); break; _______________________________________________ Xfce4-commits mailing list Xfce4-commits@xfce.org http://foo-projects.org/mailman/listinfo/xfce4-commits