void gth_pref_initialize (void) { GSettings *settings; if (Preferences == NULL) Preferences = g_new0 (GthPreferences, 1); /* desktop background */ settings = g_settings_new (GNOME_DESKTOP_BACKGROUND_SCHEMA); Preferences->wallpaper_filename = g_settings_get_string(settings, PREF_BACKGROUND_PICTURE_URI); Preferences->wallpaper_options = g_settings_get_string(settings, PREF_BACKGROUND_PICTURE_OPTIONS); g_object_unref (settings); /* startup location */ settings = g_settings_new (GTHUMB_BROWSER_SCHEMA); Preferences->startup_location = NULL; if (g_settings_get_boolean (settings, PREF_BROWSER_USE_STARTUP_LOCATION) || g_settings_get_boolean (settings, PREF_BROWSER_GO_TO_LAST_LOCATION)) { char *startup_location; startup_location = _g_settings_get_uri (settings, PREF_BROWSER_STARTUP_LOCATION); if (startup_location == NULL) { GFile *file; file = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)); startup_location = g_file_get_uri (file); g_object_unref (file); } if (startup_location == NULL) startup_location = g_strdup (get_home_uri ()); gth_pref_set_startup_location (startup_location); g_free (startup_location); } else { char *current_dir; char *current_uri; current_dir = g_get_current_dir (); current_uri = g_filename_to_uri (current_dir, NULL, NULL); gth_pref_set_startup_location (current_uri); g_free (current_uri); g_free (current_dir); } g_object_unref (settings); }
static int gth_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { char **argv; int argc; GOptionContext *context; GError *error = NULL; const char *arg; int i; GList *files; GList *dirs; GFile *location; gboolean singleton; GList *scan; argv = g_application_command_line_get_arguments (command_line, &argc); /* parse command line options */ context = gth_application_create_option_context (); if (! g_option_context_parse (context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (context); return EXIT_FAILURE; } g_option_context_free (context); g_strfreev (argv); gdk_notify_startup_complete (); /* exec the command line */ if (ImportPhotos) { GFile *location = NULL; if (remaining_args != NULL) location = g_file_new_for_commandline_arg (remaining_args[0]); import_photos_from_location (location); return 0; } if (remaining_args == NULL) { /* No location specified. */ GFile *location; GSettings *settings; char *file_to_select_uri; GFile *file_to_select; location = g_file_new_for_uri (gth_pref_get_startup_location ()); settings = g_settings_new (GTHUMB_BROWSER_SCHEMA); file_to_select_uri = _g_settings_get_uri (settings, PREF_BROWSER_STARTUP_CURRENT_FILE); if (file_to_select_uri != NULL) file_to_select = g_file_new_for_uri (file_to_select_uri); else file_to_select = NULL; open_browser_window (location, file_to_select, TRUE); _g_object_unref (file_to_select); g_free (file_to_select_uri); g_object_unref (settings); g_object_unref (location); return 0; } /* At least a location was specified */ files = NULL; dirs = NULL; for (i = 0; (arg = remaining_args[i]) != NULL; i++) { GFile *location; GFileType file_type; location = g_file_new_for_commandline_arg (arg); file_type = _g_file_get_standard_type (location); if (file_type == G_FILE_TYPE_REGULAR) files = g_list_prepend (files, location); else dirs = g_list_prepend (dirs, location); } files = g_list_reverse (files); dirs = g_list_reverse (dirs); location = gth_hook_invoke_get ("command-line-files", files); if (location != NULL) { open_browser_window (location, NULL, FALSE); g_object_unref (location); } else { /* Open each file in a new window */ singleton = (files != NULL) && (files->next == NULL); for (scan = files; scan; scan = scan->next) open_browser_window ((GFile *) scan->data, NULL, ! singleton); } /* Open each dir in a new window */ for (scan = dirs; scan; scan = scan->next) open_browser_window ((GFile *) scan->data, NULL, TRUE); _g_object_list_unref (dirs); _g_object_list_unref (files); return 0; }
void dlg_web_exporter (GthBrowser *browser, GList *file_list) { DialogData *data; int i; int active_index; char *default_sort_type; GList *sort_types; GList *scan; char *caption; char *s_value; if (gth_browser_get_dialog (browser, "web_exporter") != NULL) { gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "web_exporter"))); return; } data = g_new0 (DialogData, 1); data->browser = browser; data->file_list = _g_object_list_ref (file_list); data->builder = _gtk_builder_new_from_file ("web-album-exporter.ui", "webalbums"); data->settings = g_settings_new (PIX_WEBALBUMS_SCHEMA); data->dialog = _gtk_builder_get_widget (data->builder, "web_album_dialog"); gth_browser_set_dialog (browser, "web_exporter", data->dialog); g_object_set_data (G_OBJECT (data->dialog), "dialog_data", data); data->thumbnail_caption_chooser = gth_metadata_chooser_new (GTH_METADATA_ALLOW_IN_FILE_LIST); gtk_widget_show (data->thumbnail_caption_chooser); gtk_container_add (GTK_CONTAINER (GET_WIDGET ("thumbnail_caption_scrolledwindow")), data->thumbnail_caption_chooser); data->image_attributes_chooser = gth_metadata_chooser_new (GTH_METADATA_ALLOW_IN_PROPERTIES_VIEW); gtk_widget_show (data->image_attributes_chooser); gtk_container_add (GTK_CONTAINER (GET_WIDGET ("image_caption_scrolledwindow")), data->image_attributes_chooser); /* Set widgets data. */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("copy_images_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_COPY_IMAGES)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("resize_images_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_RESIZE_IMAGES)); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("images_per_index_spinbutton")), g_settings_get_int (data->settings, PREF_WEBALBUMS_IMAGES_PER_INDEX)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_index_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_SINGLE_INDEX)); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("cols_spinbutton")), g_settings_get_int (data->settings, PREF_WEBALBUMS_COLUMNS)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("adapt_column_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_ADAPT_TO_WIDTH)); _gtk_combo_box_add_image_sizes (GTK_COMBO_BOX (GET_WIDGET ("resize_images_combobox")), g_settings_get_int (data->settings, PREF_WEBALBUMS_RESIZE_WIDTH), g_settings_get_int (data->settings, PREF_WEBALBUMS_RESIZE_HEIGHT)); default_sort_type = g_settings_get_string (data->settings, PREF_WEBALBUMS_SORT_TYPE); active_index = 0; sort_types = gth_main_get_all_sort_types (); for (i = 0, scan = sort_types; scan; scan = scan->next, i++) { GthFileDataSort *sort_type = scan->data; GtkTreeIter iter; if (g_str_equal (sort_type->name, default_sort_type)) active_index = i; gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("sort_liststore")), &iter); gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("sort_liststore")), &iter, SORT_TYPE_COLUMN_DATA, sort_type, SORT_TYPE_COLUMN_NAME, _(sort_type->display_name), -1); } g_list_free (sort_types); gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("sort_combobox")), active_index); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("reverse_order_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_SORT_INVERSE)); g_free (default_sort_type); gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("header_entry")), g_file_info_get_edit_name (gth_browser_get_location_data (browser)->info)); s_value = g_settings_get_string (data->settings, PREF_WEBALBUMS_FOOTER); gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("footer_entry")), s_value); g_free (s_value); s_value = g_settings_get_string (data->settings, PREF_WEBALBUMS_IMAGE_PAGE_FOOTER); gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("image_page_footer_entry")), s_value); g_free (s_value); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("thumbnail_caption_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_ENABLE_THUMBNAIL_CAPTION)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("image_description_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_ENABLE_IMAGE_DESCRIPTION)); caption = g_settings_get_string (data->settings, PREF_WEBALBUMS_THUMBNAIL_CAPTION); gth_metadata_chooser_set_selection (GTH_METADATA_CHOOSER (data->thumbnail_caption_chooser), caption); g_free (caption); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("image_attributes_checkbutton")), g_settings_get_boolean (data->settings, PREF_WEBALBUMS_ENABLE_IMAGE_ATTRIBUTES)); caption = g_settings_get_string (data->settings, PREF_WEBALBUMS_IMAGE_ATTRIBUTES); gth_metadata_chooser_set_selection (GTH_METADATA_CHOOSER (data->image_attributes_chooser), caption); g_free (caption); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("theme_liststore")), THEME_COLUMN_NAME, GTK_SORT_ASCENDING); load_themes (data); update_sensitivity (data); { char *destination; destination = _g_settings_get_uri (data->settings, PREF_WEBALBUMS_DESTINATION); if (destination == NULL) destination = g_strdup (get_home_uri ()); gtk_file_chooser_set_uri (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")), destination); g_free (destination); } /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (GET_WIDGET ("ok_button"), "clicked", G_CALLBACK (ok_clicked_cb), data); g_signal_connect (GET_WIDGET ("help_button"), "clicked", G_CALLBACK (help_clicked_cb), data); g_signal_connect_swapped (GET_WIDGET ("cancel_button"), "clicked", G_CALLBACK (gtk_widget_destroy), data->dialog); g_signal_connect_swapped (GET_WIDGET ("copy_images_checkbutton"), "clicked", G_CALLBACK (update_sensitivity), data); g_signal_connect_swapped (GET_WIDGET ("resize_images_checkbutton"), "clicked", G_CALLBACK (update_sensitivity), data); g_signal_connect (GET_WIDGET ("header_entry"), "icon-press", G_CALLBACK (footer_entry_icon_press_cb), data); g_signal_connect (GET_WIDGET ("footer_entry"), "icon-press", G_CALLBACK (footer_entry_icon_press_cb), data); g_signal_connect (GET_WIDGET ("image_page_header_entry"), "icon-press", G_CALLBACK (footer_entry_icon_press_cb), data); g_signal_connect (GET_WIDGET ("image_page_footer_entry"), "icon-press", G_CALLBACK (footer_entry_icon_press_cb), data); g_signal_connect_swapped (GET_WIDGET ("single_index_checkbutton"), "toggled", G_CALLBACK (update_sensitivity), data); g_signal_connect_swapped (GET_WIDGET ("adapt_column_checkbutton"), "toggled", G_CALLBACK (update_sensitivity), data); g_signal_connect_swapped (GET_WIDGET ("image_attributes_checkbutton"), "toggled", G_CALLBACK (update_sensitivity), data); g_signal_connect_swapped (GET_WIDGET ("thumbnail_caption_checkbutton"), "toggled", G_CALLBACK (update_sensitivity), data); /* Run dialog. */ gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser)); gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE); gtk_widget_show (data->dialog); }