static void gth_file_source_queue_copy (GthFileSource *file_source, GthFileData *destination, GList *file_list, gboolean move, ProgressCallback progress_callback, DialogCallback dialog_callback, ReadyCallback ready_callback, gpointer data) { FileSourceAsyncOp *async_op; async_op = g_new0 (FileSourceAsyncOp, 1); async_op->file_source = file_source; async_op->op = FILE_SOURCE_OP_COPY; async_op->data.copy.destination = gth_file_data_dup (destination); async_op->data.copy.file_list = _g_file_list_dup (file_list); async_op->data.copy.move = move; async_op->data.copy.progress_callback = progress_callback; async_op->data.copy.dialog_callback = dialog_callback; async_op->data.copy.ready_callback = ready_callback; async_op->data.copy.data = data; file_source->priv->queue = g_list_append (file_source->priv->queue, async_op); }
void dlg_catalog_properties (GthBrowser *browser, GthFileData *file_data) { DialogData *data; g_return_if_fail (file_data != NULL); data = g_new0 (DialogData, 1); data->browser = browser; data->file_data = gth_file_data_dup (file_data); data->original_file = g_file_dup (data->file_data->file); data->builder = _gtk_builder_new_from_file ("catalog-properties.ui", "catalogs"); /* Set widgets data. */ data->dialog = g_object_new (GTK_TYPE_DIALOG, "title", _("Properties"), "transient-for", GTK_WINDOW (browser), "modal", TRUE, "destroy-with-parent", FALSE, "use-header-bar", _gtk_settings_get_dialogs_use_header (), NULL); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), _gtk_builder_get_widget (data->builder, "dialog_content")); gtk_dialog_add_buttons (GTK_DIALOG (data->dialog), _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _GTK_LABEL_SAVE, GTK_RESPONSE_OK, NULL); _gtk_dialog_add_class_to_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, GTK_STYLE_CLASS_SUGGESTED_ACTION); data->time_selector = gth_time_selector_new (); gth_time_selector_show_time (GTH_TIME_SELECTOR (data->time_selector), FALSE, FALSE); gtk_widget_show (data->time_selector); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_container_box")), data->time_selector, TRUE, TRUE, 0); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK), "clicked", G_CALLBACK (save_button_clicked_cb), data); g_signal_connect_swapped (gtk_dialog_get_widget_for_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_CANCEL), "clicked", G_CALLBACK (gtk_widget_destroy), data->dialog); /* run dialog. */ gtk_widget_grab_focus (GET_WIDGET ("name_entry")); gth_catalog_load_from_file_async (file_data->file, NULL, catalog_ready_cb, data); }
static void gth_media_viewer_page_real_update_info (GthViewerPage *base, GthFileData *file_data) { GthMediaViewerPage *self = GTH_MEDIA_VIEWER_PAGE (base); if (! _g_file_equal (self->priv->file_data->file, file_data->file)) return; _g_object_unref (self->priv->file_data); self->priv->file_data = gth_file_data_dup (file_data); }
static void gth_media_viewer_page_real_view (GthViewerPage *base, GthFileData *file_data) { GthMediaViewerPage *self; char *uri; self = (GthMediaViewerPage*) base; g_return_if_fail (file_data != NULL); if (! gstreamer_init ()) return; gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); if ((self->priv->file_data != NULL) && g_file_equal (file_data->file, self->priv->file_data->file) && (gth_file_data_get_mtime (file_data) == gth_file_data_get_mtime (self->priv->file_data))) { return; } /**/ _g_object_unref (self->priv->file_data); self->priv->file_data = gth_file_data_dup (file_data); self->priv->duration = 0; _g_object_unref (self->priv->icon); self->priv->icon = NULL; _gth_media_viewer_page_update_caption (self); /**/ gth_viewer_page_file_loaded (GTH_VIEWER_PAGE (self), TRUE); g_signal_handlers_block_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self); gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("adjustment_position")), 0.0); g_signal_handlers_unblock_by_func(GET_WIDGET ("adjustment_position"), position_value_changed_cb, self); reset_player_state (self); if (self->priv->playbin == NULL) return; gst_element_set_state (self->priv->playbin, GST_STATE_NULL); uri = g_file_get_uri (self->priv->file_data->file); g_object_set (G_OBJECT (self->priv->playbin), "uri", uri, NULL); gdk_threads_add_idle (set_to_paused, self); g_free (uri); }
static void gth_media_viewer_page_real_view (GthViewerPage *base, GthFileData *file_data) { GthMediaViewerPage *self; char *uri; self = (GthMediaViewerPage*) base; g_return_if_fail (file_data != NULL); if (! gstreamer_init ()) return; gth_viewer_page_focus (GTH_VIEWER_PAGE (self)); if ((self->priv->file_data != NULL) && g_file_equal (file_data->file, self->priv->file_data->file) && (gth_file_data_get_mtime (file_data) == gth_file_data_get_mtime (self->priv->file_data))) { return; } /**/ _g_object_unref (self->priv->file_data); self->priv->file_data = gth_file_data_dup (file_data); self->priv->duration = 0; self->priv->has_audio = FALSE; self->priv->has_video = FALSE; _g_object_unref (self->priv->icon); self->priv->icon = NULL; _gth_media_viewer_page_update_caption (self); /**/ g_signal_handlers_block_by_func(GET_WIDGET ("position_adjustment"), position_value_changed_cb, self); gtk_adjustment_set_value (GTK_ADJUSTMENT (GET_WIDGET ("position_adjustment")), 0.0); g_signal_handlers_unblock_by_func(GET_WIDGET ("position_adjustment"), position_value_changed_cb, self); reset_player_state (self); create_playbin (self); if (self->priv->playbin == NULL) return; uri = g_file_get_uri (self->priv->file_data->file); _gth_media_viewer_page_set_uri (self, uri, self->priv->visible ? GST_STATE_PLAYING : GST_STATE_PAUSED); g_free (uri); }
void dlg_catalog_properties (GthBrowser *browser, GthFileData *file_data) { DialogData *data; g_return_if_fail (file_data != NULL); data = g_new0 (DialogData, 1); data->browser = browser; data->file_data = gth_file_data_dup (file_data); data->original_file = g_file_dup (data->file_data->file); data->builder = _gtk_builder_new_from_file ("catalog-properties.ui", "catalogs"); data->dialog = GET_WIDGET ("properties_dialog"); /* Set widgets data. */ data->time_selector = gth_time_selector_new (); gth_time_selector_show_time (GTH_TIME_SELECTOR (data->time_selector), FALSE, FALSE); gtk_widget_show (data->time_selector); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("date_container_box")), data->time_selector, TRUE, TRUE, 0); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (G_OBJECT (GET_WIDGET ("save_button")), "clicked", G_CALLBACK (save_button_clicked_cb), data); g_signal_connect_swapped (G_OBJECT (GET_WIDGET ("cancel_button")), "clicked", G_CALLBACK (gtk_widget_destroy), data->dialog); g_signal_connect (G_OBJECT (GET_WIDGET ("help_button")), "clicked", G_CALLBACK (help_button_clicked_cb), data); /* run dialog. */ gtk_widget_grab_focus (GET_WIDGET ("name_entry")); gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser)); gtk_window_set_modal (GTK_WINDOW (data->dialog), TRUE); gth_catalog_load_from_file_async (file_data->file, NULL, catalog_ready_cb, data); }
static void gth_file_source_queue_reorder (GthFileSource *file_source, GthFileData *destination, GList *file_list, int dest_pos, ReadyCallback ready_callback, gpointer data) { FileSourceAsyncOp *async_op; async_op = g_new0 (FileSourceAsyncOp, 1); async_op->file_source = file_source; async_op->op = FILE_SOURCE_OP_REORDER; async_op->data.reorder.destination = gth_file_data_dup (destination); async_op->data.reorder.file_list = _g_file_list_dup (file_list); async_op->data.reorder.dest_pos = dest_pos; async_op->data.reorder.ready_callback = ready_callback; async_op->data.reorder.data = data; file_source->priv->queue = g_list_append (file_source->priv->queue, async_op); }
void gth_browser_activate_folder_context_paste_into_folder (GSimpleAction *action, GVariant *parameter, gpointer user_data) { GthBrowser *browser = GTH_BROWSER (user_data); GthFileData *file_data; PasteData *paste_data; file_data = gth_browser_get_folder_popup_file_data (browser); if (file_data == NULL) return; paste_data = g_new0 (PasteData, 1); paste_data->browser = g_object_ref (browser); paste_data->destination = gth_file_data_dup (file_data); gtk_clipboard_request_contents (gtk_widget_get_clipboard (GTK_WIDGET (browser), GDK_SELECTION_CLIPBOARD), GNOME_COPIED_FILES, clipboard_received_cb, paste_data); g_object_unref (file_data); }
void dlg_export_to_picasaweb (GthBrowser *browser, GList *file_list) { DialogData *data; GtkTreeSelection *selection; GList *scan; int n_total; goffset total_size; char *total_size_formatted; char *text; data = g_new0 (DialogData, 1); data->browser = browser; data->settings = g_settings_new (GTHUMB_PICASAWEB_SCHEMA); data->location = gth_file_data_dup (gth_browser_get_location_data (browser)); data->builder = _gtk_builder_new_from_file ("export-to-picasaweb.ui", "picasaweb"); data->dialog = _gtk_builder_get_widget (data->builder, "export_dialog"); data->cancellable = g_cancellable_new (); { GtkCellLayout *cell_layout; GtkCellRenderer *renderer; cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("name_treeviewcolumn")); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "icon-name", ALBUM_ICON_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", ALBUM_NAME_COLUMN, NULL); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "icon-name", ALBUM_EMBLEM_COLUMN, NULL); } _gtk_window_resize_to_fit_screen_height (data->dialog, 500); data->file_list = NULL; n_total = 0; total_size = 0; for (scan = file_list; scan; scan = scan->next) { GthFileData *file_data = scan->data; const char *mime_type; mime_type = gth_file_data_get_mime_type (file_data); if (g_content_type_equals (mime_type, "image/bmp") || g_content_type_equals (mime_type, "image/gif") || g_content_type_equals (mime_type, "image/jpeg") || g_content_type_equals (mime_type, "image/png")) { total_size += g_file_info_get_size (file_data->info); n_total++; data->file_list = g_list_prepend (data->file_list, g_object_ref (file_data)); } } data->file_list = g_list_reverse (data->file_list); if (data->file_list == NULL) { GError *error; gth_task_dialog (GTH_TASK (data->service), TRUE, NULL); error = g_error_new_literal (GTH_ERROR, GTH_ERROR_GENERIC, _("No valid file selected.")); _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not export the files"), error); g_clear_error (&error); destroy_dialog (data); return; } total_size_formatted = g_format_size (total_size); text = g_strdup_printf (g_dngettext (NULL, "%d file (%s)", "%d files (%s)", n_total), n_total, total_size_formatted); gtk_label_set_text (GTK_LABEL (GET_WIDGET ("images_info_label")), text); g_free (text); g_free (total_size_formatted); /* Set the widget data */ data->list_view = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NO_SELECTION, FALSE); gth_file_list_set_thumb_size (GTH_FILE_LIST (data->list_view), 112); gth_file_list_enable_thumbs (GTH_FILE_LIST (data->list_view), TRUE); gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->list_view), TRUE); gth_file_list_set_caption (GTH_FILE_LIST (data->list_view), "none"); gth_file_list_set_sort_func (GTH_FILE_LIST (data->list_view), gth_main_get_sort_type ("file::name")->cmp_func, FALSE); gtk_widget_show (data->list_view); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->list_view, TRUE, TRUE, 0); gth_file_list_set_files (GTH_FILE_LIST (data->list_view), data->file_list); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("album_liststore")), ALBUM_NAME_COLUMN, GTK_SORT_ASCENDING); gtk_widget_set_sensitive (GET_WIDGET ("upload_button"), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("resize_checkbutton")), g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_WIDTH) != -1); _gtk_combo_box_add_image_sizes (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")), g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_WIDTH), g_settings_get_int (data->settings, PREF_PICASAWEB_RESIZE_HEIGHT)); /* Set the signals handlers. */ g_signal_connect (data->dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (data->dialog, "response", G_CALLBACK (export_dialog_response_cb), data); g_signal_connect (GET_WIDGET ("add_album_button"), "clicked", G_CALLBACK (add_album_button_clicked_cb), data); g_signal_connect (GET_WIDGET ("edit_accounts_button"), "clicked", G_CALLBACK (edit_accounts_button_clicked_cb), data); g_signal_connect (GET_WIDGET ("account_combobox"), "changed", G_CALLBACK (account_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("resize_checkbutton"), "toggled", G_CALLBACK (resize_checkbutton_toggled_cb), data); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (GET_WIDGET ("albums_treeview"))); gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); g_signal_connect (selection, "changed", G_CALLBACK (albums_treeview_selection_changed_cb), data); update_sensitivity (data); data->service = picasa_web_service_new (data->cancellable, GTK_WIDGET (data->browser), data->dialog); g_signal_connect (data->service, "account-ready", G_CALLBACK (service_account_ready_cb), data); g_signal_connect (data->service, "accounts-changed", G_CALLBACK (service_accounts_changed_cb), data); data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser)); gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service)); web_service_autoconnect (WEB_SERVICE (data->service)); }
void dlg_import_from_flickr (FlickrServer *server, GthBrowser *browser) { DialogData *data; GthThumbLoader *thumb_loader; char *title; data = g_new0 (DialogData, 1); data->server = server; data->browser = browser; data->location = gth_file_data_dup (gth_browser_get_location_data (browser)); data->builder = _gtk_builder_new_from_file ("import-from-flickr.ui", "flicker_utils"); data->dialog = _gtk_builder_get_widget (data->builder, "import_dialog"); data->cancellable = g_cancellable_new (); { GtkCellLayout *cell_layout; GtkCellRenderer *renderer; cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("photoset_combobox")); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "icon-name", PHOTOSET_ICON_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", PHOTOSET_TITLE_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", PHOTOSET_N_PHOTOS_COLUMN, NULL); } /* Set the widget data */ data->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NORMAL, FALSE); thumb_loader = gth_file_list_get_thumb_loader (GTH_FILE_LIST (data->file_list)); gth_thumb_loader_set_use_cache (thumb_loader, FALSE); gth_thumb_loader_set_loader_func (thumb_loader, flickr_thumbnail_loader); gth_file_list_set_thumb_size (GTH_FILE_LIST (data->file_list), FLICKR_SIZE_THUMBNAIL); gth_file_list_enable_thumbs (GTH_FILE_LIST (data->file_list), TRUE); gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->file_list), TRUE); gth_file_list_set_caption (GTH_FILE_LIST (data->file_list), "none"); gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), flickr_photo_position_func, FALSE); gth_file_list_clear (GTH_FILE_LIST (data->file_list), _("No album selected")); gtk_widget_show (data->file_list); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->file_list, TRUE, TRUE, 0); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("photoset_liststore")), PHOTOSET_TITLE_COLUMN, GTK_SORT_ASCENDING); gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE); data->preferences_dialog = gth_import_preferences_dialog_new (); gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog)); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("destination_button_box")), gth_import_destination_button_new (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog)), TRUE, TRUE, 0); gtk_widget_show_all (GET_WIDGET ("destination_button_box")); title = g_strdup_printf (_("Import from %s"), data->server->display_name); gtk_window_set_title (GTK_WINDOW (data->dialog), title); g_free (title); _gtk_window_resize_to_fit_screen_height (data->dialog, 500); /* Set the signals handlers. */ g_signal_connect (data->dialog, "destroy", G_CALLBACK (import_dialog_destroy_cb), data); g_signal_connect (data->dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (data->dialog, "response", G_CALLBACK (import_dialog_response_cb), data); g_signal_connect (GET_WIDGET ("edit_accounts_button"), "clicked", G_CALLBACK (edit_accounts_button_clicked_cb), data); g_signal_connect (GET_WIDGET ("account_combobox"), "changed", G_CALLBACK (account_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("photoset_combobox"), "changed", G_CALLBACK (photoset_combobox_changed_cb), data); g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)), "file-selection-changed", G_CALLBACK (file_list_selection_changed_cb), data); update_selection_status (data); gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog), ""); data->service = flickr_service_new (server, data->cancellable, GTK_WIDGET (data->browser), data->dialog); g_signal_connect (data->service, "account-ready", G_CALLBACK (authentication_ready_cb), data); g_signal_connect (data->service, "accounts-changed", G_CALLBACK (authentication_accounts_changed_cb), data); data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser)); gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service)); web_service_autoconnect (WEB_SERVICE (data->service)); }
void dlg_export_to_flickr (FlickrServer *server, GthBrowser *browser, GList *file_list) { DialogData *data; GList *scan; int n_total; goffset total_size; char *total_size_formatted; char *text; char *title; data = g_new0 (DialogData, 1); data->server = server; data->browser = browser; data->settings = g_settings_new (GTHUMB_FLICKR_SCHEMA); data->location = gth_file_data_dup (gth_browser_get_location_data (browser)); data->builder = _gtk_builder_new_from_file ("export-to-flickr.ui", "flicker_utils"); data->cancellable = g_cancellable_new (); data->dialog = g_object_new (GTK_TYPE_DIALOG, "transient-for", GTK_WINDOW (browser), "modal", FALSE, "destroy-with-parent", FALSE, "use-header-bar", _gtk_settings_get_dialogs_use_header (), NULL); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), _gtk_builder_get_widget (data->builder, "dialog_content")); gtk_dialog_add_buttons (GTK_DIALOG (data->dialog), _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _GTK_LABEL_UPLOAD, GTK_RESPONSE_OK, NULL); _gtk_dialog_add_class_to_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, GTK_STYLE_CLASS_SUGGESTED_ACTION); { GtkCellLayout *cell_layout; GtkCellRenderer *renderer; data->photoset_combobox = gtk_combo_box_new_with_model_and_entry (GTK_TREE_MODEL (GET_WIDGET ("photoset_liststore"))); gtk_combo_box_set_entry_text_column (GTK_COMBO_BOX (data->photoset_combobox), PHOTOSET_TITLE_COLUMN); gtk_widget_show (data->photoset_combobox); gtk_container_add (GTK_CONTAINER (GET_WIDGET ("photoset_combobox_container")), data->photoset_combobox); cell_layout = GTK_CELL_LAYOUT (data->photoset_combobox); gtk_cell_layout_clear (cell_layout); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "icon-name", PHOTOSET_ICON_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", PHOTOSET_TITLE_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", PHOTOSET_N_PHOTOS_COLUMN, NULL); } data->file_list = NULL; n_total = 0; total_size = 0; for (scan = file_list; scan; scan = scan->next) { GthFileData *file_data = scan->data; const char *mime_type; mime_type = gth_file_data_get_mime_type (file_data); if (g_content_type_equals (mime_type, "image/bmp") || g_content_type_equals (mime_type, "image/gif") || g_content_type_equals (mime_type, "image/jpeg") || g_content_type_equals (mime_type, "image/png")) { total_size += g_file_info_get_size (file_data->info); n_total++; data->file_list = g_list_prepend (data->file_list, g_object_ref (file_data)); } } data->file_list = g_list_reverse (data->file_list); if (data->file_list == NULL) { GError *error; error = g_error_new_literal (GTH_ERROR, GTH_ERROR_GENERIC, _("No valid file selected.")); _gtk_error_dialog_from_gerror_show (GTK_WINDOW (browser), _("Could not export the files"), error); g_clear_error (&error); gtk_dialog_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_DELETE_EVENT); return; } total_size_formatted = g_format_size (total_size); text = g_strdup_printf (g_dngettext (NULL, "%d file (%s)", "%d files (%s)", n_total), n_total, total_size_formatted); gtk_label_set_text (GTK_LABEL (GET_WIDGET ("images_info_label")), text); g_free (text); g_free (total_size_formatted); _gtk_window_resize_to_fit_screen_height (data->dialog, 500); /* Set the widget data */ data->list_view = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NO_SELECTION, FALSE); gth_file_list_set_thumb_size (GTH_FILE_LIST (data->list_view), 112); gth_file_list_enable_thumbs (GTH_FILE_LIST (data->list_view), TRUE); gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->list_view), TRUE); gth_file_list_set_caption (GTH_FILE_LIST (data->list_view), "none"); gth_file_list_set_sort_func (GTH_FILE_LIST (data->list_view), gth_main_get_sort_type ("file::name")->cmp_func, FALSE); gtk_widget_show (data->list_view); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->list_view, TRUE, TRUE, 0); gth_file_list_set_files (GTH_FILE_LIST (data->list_view), data->file_list); gtk_entry_set_text (GTK_ENTRY (gtk_bin_get_child (GTK_BIN (data->photoset_combobox))), g_file_info_get_edit_name (data->location->info)); gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, FALSE); title = g_strdup_printf (_("Export to %s"), data->server->name); gtk_window_set_title (GTK_WINDOW (data->dialog), title); g_free (title); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("resize_checkbutton")), g_settings_get_int (data->settings, PREF_FLICKR_RESIZE_WIDTH) != -1); _gtk_combo_box_add_image_sizes (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")), g_settings_get_int (data->settings, PREF_FLICKR_RESIZE_WIDTH), g_settings_get_int (data->settings, PREF_FLICKR_RESIZE_HEIGHT)); /* Set the signals handlers. */ g_signal_connect (data->dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (data->dialog, "response", G_CALLBACK (export_dialog_response_cb), data); g_signal_connect (GET_WIDGET ("edit_accounts_button"), "clicked", G_CALLBACK (edit_accounts_button_clicked_cb), data); g_signal_connect (GET_WIDGET ("account_combobox"), "changed", G_CALLBACK (account_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("resize_checkbutton"), "toggled", G_CALLBACK (resize_checkbutton_toggled_cb), data); update_sensitivity (data); data->service = flickr_service_new (server, data->cancellable, GTK_WIDGET (data->browser), data->dialog); g_signal_connect (data->service, "account-ready", G_CALLBACK (authentication_ready_cb), data); g_signal_connect (data->service, "accounts-changed", G_CALLBACK (authentication_accounts_changed_cb), data); data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser)); gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service), GTH_TASK_FLAGS_DEFAULT); web_service_autoconnect (WEB_SERVICE (data->service)); }
void dlg_import_from_facebook (GthBrowser *browser) { DialogData *data; GthThumbLoader *thumb_loader; char *title; data = g_new0 (DialogData, 1); data->browser = browser; data->location = gth_file_data_dup (gth_browser_get_location_data (browser)); data->builder = _gtk_builder_new_from_file ("import-from-facebook.ui", "facebook"); data->cancellable = g_cancellable_new (); data->dialog = g_object_new (GTK_TYPE_DIALOG, "title", _("Import from Facebook"), "transient-for", GTK_WINDOW (browser), "modal", FALSE, "use-header-bar", _gtk_settings_get_dialogs_use_header (), NULL); gtk_container_add (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), _gtk_builder_get_widget (data->builder, "dialog_content")); gtk_dialog_add_buttons (GTK_DIALOG (data->dialog), _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _("_Import"), GTK_RESPONSE_OK, NULL); _gtk_dialog_add_class_to_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, GTK_STYLE_CLASS_SUGGESTED_ACTION); { GtkCellLayout *cell_layout; GtkCellRenderer *renderer; cell_layout = GTK_CELL_LAYOUT (GET_WIDGET ("album_combobox")); renderer = gtk_cell_renderer_pixbuf_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "icon-name", ALBUM_ICON_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, TRUE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", ALBUM_NAME_COLUMN, NULL); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (cell_layout, renderer, FALSE); gtk_cell_layout_set_attributes (cell_layout, renderer, "text", ALBUM_SIZE_COLUMN, NULL); } /* Set the widget data */ data->file_list = gth_file_list_new (gth_grid_view_new (), GTH_FILE_LIST_MODE_NORMAL, FALSE); thumb_loader = gth_file_list_get_thumb_loader (GTH_FILE_LIST (data->file_list)); gth_thumb_loader_set_use_cache (thumb_loader, FALSE); gth_thumb_loader_set_loader_func (thumb_loader, facebook_thumbnail_loader); gth_file_list_set_thumb_size (GTH_FILE_LIST (data->file_list), THUMBNAIL_SIZE); gth_file_list_enable_thumbs (GTH_FILE_LIST (data->file_list), TRUE); gth_file_list_set_ignore_hidden (GTH_FILE_LIST (data->file_list), TRUE); gth_file_list_set_caption (GTH_FILE_LIST (data->file_list), "none"); gth_file_list_set_sort_func (GTH_FILE_LIST (data->file_list), facebook_photo_position_func, FALSE); gth_file_list_clear (GTH_FILE_LIST (data->file_list), _("No album selected")); gtk_widget_show (data->file_list); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("images_box")), data->file_list, TRUE, TRUE, 0); gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GET_WIDGET ("album_liststore")), ALBUM_NAME_COLUMN, GTK_SORT_ASCENDING); gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, FALSE); data->preferences_dialog = gth_import_preferences_dialog_new (); gtk_window_set_transient_for (GTK_WINDOW (data->preferences_dialog), GTK_WINDOW (data->dialog)); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("destination_button_box")), gth_import_destination_button_new (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog)), TRUE, TRUE, 0); gtk_widget_show_all (GET_WIDGET ("destination_button_box")); title = g_strdup_printf (_("Import from %s"), _("Facebook")); gtk_window_set_title (GTK_WINDOW (data->dialog), title); g_free (title); _gtk_window_resize_to_fit_screen_height (data->dialog, 500); /* Set the signals handlers. */ g_signal_connect (data->dialog, "destroy", G_CALLBACK (import_dialog_destroy_cb), data); g_signal_connect (data->dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (data->dialog, "response", G_CALLBACK (import_dialog_response_cb), data); g_signal_connect (GET_WIDGET ("edit_accounts_button"), "clicked", G_CALLBACK (edit_accounts_button_clicked_cb), data); g_signal_connect (GET_WIDGET ("account_combobox"), "changed", G_CALLBACK (account_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("album_combobox"), "changed", G_CALLBACK (album_combobox_changed_cb), data); g_signal_connect (gth_file_list_get_view (GTH_FILE_LIST (data->file_list)), "file-selection-changed", G_CALLBACK (file_list_selection_changed_cb), data); update_selection_status (data); gth_import_preferences_dialog_set_event (GTH_IMPORT_PREFERENCES_DIALOG (data->preferences_dialog), ""); data->service = facebook_service_new (data->cancellable, GTK_WIDGET (data->browser), data->dialog); g_signal_connect (data->service, "account-ready", G_CALLBACK (authentication_ready_cb), data); g_signal_connect (data->service, "accounts-changed", G_CALLBACK (authentication_accounts_changed_cb), data); data->progress_dialog = gth_progress_dialog_new (GTK_WINDOW (data->browser)); gth_progress_dialog_add_task (GTH_PROGRESS_DIALOG (data->progress_dialog), GTH_TASK (data->service), GTH_TASK_FLAGS_DEFAULT); web_service_autoconnect (WEB_SERVICE (data->service)); }