static void zoom_quality_radiobutton_toggled_cb (GtkToggleButton *button, BrowserData *data) { g_settings_set_enum (data->settings, PREF_IMAGE_VIEWER_ZOOM_QUALITY, (button == GET_WIDGET ("zoom_quality_high_radiobutton")) ? GTH_ZOOM_QUALITY_HIGH : GTH_ZOOM_QUALITY_LOW); }
void btn_about_config_clicked(GtkButton *button, gpointer user_data) { gtk_dialog_run(GTK_DIALOG(GET_WIDGET(DIALOG_ABOUT))); gtk_widget_hide(GET_WIDGET(DIALOG_ABOUT)); }
void radio_switch_to_config_toggled(GtkToggleButton *toggle, gpointer user_data) { gtk_widget_set_sensitive(GET_WIDGET(COMBOBOX_SWITCH_TO_CONFIG), TRUE); button_property_changed(GTK_WIDGET(toggle), user_data); }
static void update_width_height_properties (DialogData *data) { GthUnit unit; unit = units[gtk_combo_box_get_active (GTK_COMBO_BOX (GET_WIDGET ("unit_combobox")))]; if (unit == GTH_UNIT_PERCENTAGE) { gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), 2); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), 2); g_signal_handler_block (GET_WIDGET ("height_spinbutton"), data->height_spinbutton_event); g_signal_handler_block (GET_WIDGET ("width_spinbutton"), data->width_spinbutton_event); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_percentage); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_percentage); g_signal_handler_unblock (GET_WIDGET ("height_spinbutton"), data->height_spinbutton_event); g_signal_handler_unblock (GET_WIDGET ("width_spinbutton"), data->width_spinbutton_event); } else if (unit == GTH_UNIT_PIXELS) { gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), 0); gtk_spin_button_set_digits (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), 0); g_signal_handler_block (GET_WIDGET ("height_spinbutton"), data->height_spinbutton_event); g_signal_handler_block (GET_WIDGET ("width_spinbutton"), data->width_spinbutton_event); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_pixel); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_pixel); g_signal_handler_unblock (GET_WIDGET ("height_spinbutton"), data->height_spinbutton_event); g_signal_handler_unblock (GET_WIDGET ("width_spinbutton"), data->width_spinbutton_event); } }
void dlg_resize_images (GthBrowser *browser, GList *file_list) { DialogData *data; GArray *savers; GthFileData *first_file_data; GthUnit unit; int default_width_in_pixels; int default_height_in_pixels; if (gth_browser_get_dialog (browser, "resize_images") != NULL) { gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "resize_images"))); return; } data = g_new0 (DialogData, 1); data->browser = browser; data->builder = _gtk_builder_new_from_file ("resize-images.ui", "resize_images"); data->settings = g_settings_new (GTHUMB_RESIZE_IMAGES_SCHEMA); data->file_list = gth_file_data_list_dup (file_list); data->use_destination = TRUE; /* Get the widgets. */ data->dialog = _gtk_builder_get_widget (data->builder, "resize_images_dialog"); gth_browser_set_dialog (browser, "resize_images", data->dialog); g_object_set_data (G_OBJECT (data->dialog), "dialog_data", data); /* Set widgets data. */ first_file_data = (GthFileData *) data->file_list->data; _gtk_file_chooser_set_file_parent (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")), first_file_data->file, NULL); unit = g_settings_get_enum (data->settings, PREF_RESIZE_IMAGES_UNIT); gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("unit_combobox")), unit); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_ratio_checkbutton")), g_settings_get_boolean (data->settings, PREF_RESIZE_IMAGES_KEEP_RATIO)); default_width_in_pixels = DEFAULT_WIDTH_PIXELS; default_height_in_pixels = DEFAULT_HEIGHT_PIXELS; if (data->file_list->next == NULL) { GthMetadataProvider *provider; int width; int height; provider = g_object_new (GTH_TYPE_METADATA_PROVIDER_IMAGE, NULL); gth_metadata_provider_read (provider, first_file_data, "image::width,image::height", NULL); width = g_file_info_get_attribute_int32 (first_file_data->info, "image::width"); height = g_file_info_get_attribute_int32 (first_file_data->info, "image::height"); if ((width > 0) && (height > 0)) { data->known_ratio = TRUE; data->ratio = (double) width / height; default_width_in_pixels = width; default_height_in_pixels = height; } g_object_unref (provider); } if (unit == GTH_UNIT_PERCENTAGE) { data->latest_width_in_pixel = default_width_in_pixels; data->latest_height_in_pixel = default_height_in_pixels; data->latest_width_in_percentage = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_WIDTH); data->latest_height_in_percentage = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_HEIGHT); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_percentage); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_percentage); } else if (unit == GTH_UNIT_PIXELS) { data->latest_width_in_percentage = DEFAULT_WIDTH_PERCENTAGE; data->latest_height_in_percentage = DEFAULT_HEIGHT_PERCENTAGE; data->latest_width_in_pixel = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_WIDTH); data->latest_height_in_pixel = g_settings_get_int (data->settings, PREF_RESIZE_IMAGES_SERIES_HEIGHT); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")), data->latest_width_in_pixel); gtk_spin_button_set_value (GTK_SPIN_BUTTON (GET_WIDGET ("height_spinbutton")), data->latest_height_in_pixel); } savers = gth_main_get_type_set ("image-saver"); if (savers != NULL) { GtkListStore *list_store; GtkTreeIter iter; char *default_mime_type; GthIconCache *icon_cache; int i; list_store = (GtkListStore *) GET_WIDGET ("mime_type_liststore"); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, MIME_TYPE_COLUMN_ICON, NULL, MIME_TYPE_COLUMN_TYPE, NULL, MIME_TYPE_COLUMN_DESCRIPTION, _("Keep the original format"), -1); gtk_combo_box_set_active_iter (GTK_COMBO_BOX (GET_WIDGET ("mime_type_combobox")), &iter); default_mime_type = g_settings_get_string (data->settings, PREF_RESIZE_IMAGES_MIME_TYPE); icon_cache = gth_icon_cache_new_for_widget (data->dialog, GTK_ICON_SIZE_MENU); for (i = 0; i < savers->len; i++) { GType saver_type; GthImageSaver *saver; const char *mime_type; GdkPixbuf *pixbuf; saver_type = g_array_index (savers, GType, i); saver = g_object_new (saver_type, NULL); mime_type = gth_image_saver_get_mime_type (saver); pixbuf = gth_icon_cache_get_pixbuf (icon_cache, g_content_type_get_icon (mime_type)); gtk_list_store_append (list_store, &iter); gtk_list_store_set (list_store, &iter, MIME_TYPE_COLUMN_ICON, pixbuf, MIME_TYPE_COLUMN_TYPE, mime_type, MIME_TYPE_COLUMN_DESCRIPTION, g_content_type_get_description (mime_type), -1); if (strcmp (default_mime_type, mime_type) == 0) gtk_combo_box_set_active_iter (GTK_COMBO_BOX (GET_WIDGET ("mime_type_combobox")), &iter); g_object_unref (pixbuf); g_object_unref (saver); } gth_icon_cache_free (icon_cache); g_free (default_mime_type); } /* 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), G_OBJECT (data->dialog)); g_signal_connect (GET_WIDGET ("unit_combobox"), "changed", G_CALLBACK (unit_combobox_changed_cb), data); g_signal_connect (GET_WIDGET ("use_destination_checkbutton"), "toggled", G_CALLBACK (use_destination_checkbutton_toggled_cb), data); data->width_spinbutton_event = g_signal_connect (GET_WIDGET ("width_spinbutton"), "value-changed", G_CALLBACK (width_spinbutton_value_changed_cb), data); data->height_spinbutton_event = g_signal_connect (GET_WIDGET ("height_spinbutton"), "value-changed", G_CALLBACK (height_spinbutton_value_changed_cb), data); /* Run dialog. */ update_width_height_properties (data); width_spinbutton_value_changed_cb (NULL, data); if (GTH_IS_FILE_SOURCE_VFS (gth_browser_get_location_source (browser))) gtk_widget_hide (GET_WIDGET ("use_destination_checkbutton")); 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); }
static void update_enabled_disabled_cardinality (BrowserData *data) { GtkTreeModel *tree_model; GtkTreeIter iter; GtkTreeRowReference *enabled_iter = NULL; GtkTreeRowReference *disabled_iter = NULL; GtkTreePath *path; if (! data->enabled_disabled_cardinality_changed) return; tree_model = GTK_TREE_MODEL (GET_WIDGET ("category_liststore")); if (gtk_tree_model_get_iter_first (tree_model, &iter)) { do { char *category_id; gtk_tree_model_get (tree_model, &iter, CATEGORY_ID_COLUMN, &category_id, -1); if (g_strcmp0 (category_id, EXTENSION_CATEGORY_ENABLED) == 0) { path = gtk_tree_model_get_path (tree_model, &iter); enabled_iter = gtk_tree_row_reference_new (tree_model, path); gtk_tree_path_free (path); } if (g_strcmp0 (category_id, EXTENSION_CATEGORY_DISABLED) == 0) { path = gtk_tree_model_get_path (tree_model, &iter); disabled_iter = gtk_tree_row_reference_new (tree_model, path); gtk_tree_path_free (path); } g_free (category_id); } while (gtk_tree_model_iter_next (tree_model, &iter)); } path = gtk_tree_row_reference_get_path (enabled_iter); if (path != NULL) { if (gtk_tree_model_get_iter (tree_model, &iter, path)) { char *s; s = g_strdup_printf (CARDINALITY_FORMAT, get_category_cardinality (data, EXTENSION_CATEGORY_ENABLED)); gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter, CATEGORY_CARDINALITY_COLUMN, s, -1); g_free (s); } gtk_tree_path_free (path); } path = gtk_tree_row_reference_get_path (disabled_iter); if (path != NULL) { if (gtk_tree_model_get_iter (tree_model, &iter, path)) { char *s; s = g_strdup_printf (CARDINALITY_FORMAT, get_category_cardinality (data, EXTENSION_CATEGORY_DISABLED)); gtk_list_store_set (GTK_LIST_STORE (tree_model), &iter, CATEGORY_CARDINALITY_COLUMN, s, -1); g_free (s); } gtk_tree_path_free (path); } gtk_tree_row_reference_free (enabled_iter); gtk_tree_row_reference_free (disabled_iter); data->enabled_disabled_cardinality_changed = FALSE; }
void extensions__dlg_preferences_construct_cb (GtkWidget *dialog, GthBrowser *browser, GtkBuilder *dialog_builder) { BrowserData *data; GthExtensionManager *manager; GList *extensions; GList *descriptions; GList *scan; char **all_active_extensions; int i; GtkWidget *label; GtkWidget *page; data = g_new0 (BrowserData, 1); data->builder = _gtk_builder_new_from_file ("extensions-preferences.ui", NULL); data->settings = g_settings_new (GTHUMB_GENERAL_SCHEMA); data->dialog = dialog; data->enabled_disabled_cardinality_changed = FALSE; /* save the active extensions to decide if a restart is needed */ manager = gth_main_get_default_extension_manager (); data->active_extensions = NULL; all_active_extensions = g_settings_get_strv (data->settings, PREF_GENERAL_ACTIVE_EXTENSIONS); for (i = 0; all_active_extensions[i] != NULL; i++) { char *name = all_active_extensions[i]; GthExtensionDescription *description; description = gth_extension_manager_get_description (manager, name); if ((description == NULL) || description->mandatory || description->hidden) continue; data->active_extensions = g_list_prepend (data->active_extensions, g_strdup (name)); } data->active_extensions = g_list_reverse (data->active_extensions); g_strfreev (all_active_extensions); /* the extensions list */ data->extensions_list = gtk_list_box_new (); gtk_list_box_set_selection_mode (GTK_LIST_BOX (data->extensions_list), GTK_SELECTION_NONE); gtk_list_box_set_filter_func (GTK_LIST_BOX (data->extensions_list), extensions_list_filter_func, data, NULL); extensions = gth_extension_manager_get_extensions (manager); descriptions = NULL; for (scan = extensions; scan; scan = scan->next) { const char *name = scan->data; GthExtensionDescription *description; description = gth_extension_manager_get_description (manager, name); if ((description == NULL) || description->mandatory || description->hidden) continue; descriptions = g_list_prepend (descriptions, description); } descriptions = g_list_sort (descriptions, sort_extensions_by_name); for (scan = descriptions; scan; scan = scan->next) { GthExtensionDescription *description = scan->data; if (scan != descriptions) _gtk_list_box_add_separator (GTK_LIST_BOX (data->extensions_list)); gtk_container_add (GTK_CONTAINER (data->extensions_list), create_extensions_row (description, data)); } gtk_widget_show (data->extensions_list); gtk_container_add (GTK_CONTAINER (GET_WIDGET ("extensions_list_scrolledwindow")), data->extensions_list); g_list_free (descriptions); g_list_free (extensions); /* the category combobox */ add_category_combobox_columns (GET_WIDGET ("category_combobox"), data); data->current_category = g_strdup (EXTENSION_CATEGORY_ALL); for (i = 0; extension_category[i].id != NULL; i++) { GtkTreeIter iter; gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("category_liststore")), &iter); if (strcmp (extension_category[i].id, EXTENSION_CATEGORY_SEPARATOR) == 0) gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("category_liststore")), &iter, CATEGORY_SEPARATOR_COLUMN, TRUE, -1); else { char *cardinality; cardinality = g_strdup_printf (CARDINALITY_FORMAT, get_category_cardinality (data, extension_category[i].id)); gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("category_liststore")), &iter, CATEGORY_NAME_COLUMN, _(extension_category[i].name), CATEGORY_ID_COLUMN, extension_category[i].id, /* CATEGORY_ICON_COLUMN, extension_category[i].icon, */ CATEGORY_SEPARATOR_COLUMN, FALSE, CATEGORY_CARDINALITY_COLUMN, cardinality, -1); g_free (cardinality); } } gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (GET_WIDGET ("category_combobox")), category_view_separator_func, data, NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("category_combobox")), 0); /* Set the signals handlers. */ g_signal_connect (GET_WIDGET ("category_combobox"), "changed", G_CALLBACK (category_combobox_changed_cb), data); /* add the page to the preferences dialog */ label = gtk_label_new (_("Extensions")); gtk_widget_show (label); page = _gtk_builder_get_widget (data->builder, "preferences_page"); gtk_widget_show (page); gtk_notebook_append_page (GTK_NOTEBOOK (_gtk_builder_get_widget (dialog_builder, "notebook")), page, label); g_object_set_data_full (G_OBJECT (dialog), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free); }
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->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; if (data->conn != NULL) gth_task_dialog (GTH_TASK (data->conn), TRUE); 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); destroy_dialog (data); return; } total_size_formatted = g_format_size_for_display (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_FILE_LIST_TYPE_NO_SELECTION, FALSE); gth_file_list_set_thumb_size (GTH_FILE_LIST (data->list_view), 112); gth_file_view_set_spacing (GTH_FILE_VIEW (gth_file_list_get_view (GTH_FILE_LIST (data->list_view))), 0); gth_file_list_enable_thumbs (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); /* Set the signals handlers. */ g_signal_connect (data->dialog, "delete-event", G_CALLBACK (gtk_widget_hide_on_delete), 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); 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); data->accounts = picasa_web_accounts_load_from_file (&data->email); auto_select_account (data); }
static void gth_image_saver_webp_save_options (GthImageSaver *base) { GthImageSaverWebp *self = GTH_IMAGE_SAVER_WEBP (base); g_settings_set_int (self->priv->settings, PREF_WEBP_QUALITY, (int) gtk_adjustment_get_value (GTK_ADJUSTMENT (GET_WIDGET ("quality_adjustment")))); g_settings_set_int (self->priv->settings, PREF_WEBP_METHOD, (int) gtk_adjustment_get_value (GTK_ADJUSTMENT (GET_WIDGET ("method_adjustment")))); g_settings_set_boolean (self->priv->settings, PREF_WEBP_LOSSLESS, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("lossless_checkbutton")))); }
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), GTH_TASK_FLAGS_DEFAULT); web_service_autoconnect (WEB_SERVICE (data->service)); }
static void import_dialog_response_cb (GtkDialog *dialog, int response_id, gpointer user_data) { DialogData *data = user_data; switch (response_id) { case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: gth_file_list_cancel (GTH_FILE_LIST (data->file_list), (DataFunc) gtk_widget_destroy, data->dialog); break; case GTK_RESPONSE_OK: { GtkTreeIter iter; FlickrPhotoset *photoset; GList *file_list; if (! gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("photoset_combobox")), &iter)) { gtk_widget_set_sensitive (GET_WIDGET ("download_button"), FALSE); return; } gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("photoset_liststore")), &iter, PHOTOSET_DATA_COLUMN, &photoset, -1); file_list = get_files_to_download (data); if (file_list != NULL) { GSettings *settings; GFile *destination; gboolean single_subfolder; GthSubfolderType subfolder_type; GthSubfolderFormat subfolder_format; char *custom_format; GthTask *task; settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA); destination = gth_import_preferences_get_destination (); subfolder_type = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_TYPE); subfolder_format = g_settings_get_enum (settings, PREF_IMPORTER_SUBFOLDER_FORMAT); single_subfolder = g_settings_get_boolean (settings, PREF_IMPORTER_SUBFOLDER_SINGLE); custom_format = g_settings_get_string (settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT); task = gth_import_task_new (data->browser, file_list, destination, subfolder_type, subfolder_format, single_subfolder, custom_format, (photoset->title != NULL ? photoset->title : ""), NULL, FALSE, FALSE, FALSE); gth_browser_exec_task (data->browser, task, GTH_TASK_FLAGS_DEFAULT); gtk_widget_destroy (data->dialog); g_object_unref (task); _g_object_unref (destination); g_object_unref (settings); } _g_object_list_unref (file_list); g_object_unref (photoset); } break; default: break; } }
void dlg_preferences (GthBrowser *browser) { DialogData *data; GtkWidget *notebook; GList *children; GList *scan; int page_num; GtkWidget *list_box; GtkTreeSelection *selection; if (gth_browser_get_dialog (browser, "preferences") != NULL) { gtk_window_present (GTK_WINDOW (gth_browser_get_dialog (browser, "preferences"))); return; } data = g_new0 (DialogData, 1); data->browser = browser; data->builder = _gtk_builder_new_from_file ("preferences.ui", NULL); data->dialog = GET_WIDGET ("preferences_dialog"); gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (data->dialog))), 0); gth_browser_set_dialog (browser, "preferences", data->dialog); gth_hook_invoke ("dlg-preferences-construct", data->dialog, data->browser, data->builder); /* widgets */ list_box = GET_WIDGET ("tabs_listbox"); notebook = GET_WIDGET ("notebook"); children = gtk_container_get_children (GTK_CONTAINER (notebook)); page_num = 0; for (scan = children; scan; scan = scan->next) { GtkWidget *child = scan->data; const char *name; GtkWidget *row; GtkWidget *box; GtkWidget *label; name = gtk_notebook_get_tab_label_text (GTK_NOTEBOOK (notebook), child); if (name == NULL) continue; if (scan != children) _gtk_list_box_add_separator (GTK_LIST_BOX (list_box)); row = gtk_list_box_row_new (); g_object_set_data (G_OBJECT (row), "gth.page_num", GINT_TO_POINTER (page_num)); gtk_widget_show (row); gtk_container_add (GTK_CONTAINER (list_box), row); box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_container_set_border_width (GTK_CONTAINER (box), 10); gtk_widget_show (box); gtk_container_add (GTK_CONTAINER (row), box); label = gtk_label_new (name); gtk_label_set_ellipsize (GTK_LABEL(label), PANGO_ELLIPSIZE_END); gtk_widget_show (label); gtk_container_add (GTK_CONTAINER (box), label); page_num += 1; } /* Set the signals handlers. */ g_signal_connect (data->dialog, "destroy", G_CALLBACK (destroy_cb), data); g_signal_connect (list_box, "row-activated", G_CALLBACK (list_box_row_activated_cb), data); /* run dialog. */ gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (browser)); gtk_widget_show (data->dialog); }
static GtkWidget * gth_file_tool_sharpen_get_options (GthFileTool *base) { GthFileToolSharpen *self; GtkWidget *window; GtkWidget *viewer_page; GtkWidget *viewer; GtkWidget *options; GtkWidget *image_navigator; self = (GthFileToolSharpen *) base; window = gth_file_tool_get_window (base); viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window)); if (! GTH_IS_IMAGE_VIEWER_PAGE (viewer_page)) return NULL; cairo_surface_destroy (self->priv->source); cairo_surface_destroy (self->priv->destination); viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page)); self->priv->source = cairo_surface_reference (gth_image_viewer_get_current_image (GTH_IMAGE_VIEWER (viewer))); if (self->priv->source == NULL) return NULL; self->priv->destination = NULL; self->priv->first_allocation = TRUE; self->priv->builder = _gtk_builder_new_from_file ("sharpen-options.ui", "file_tools"); options = _gtk_builder_get_widget (self->priv->builder, "options"); gtk_widget_show (options); self->priv->preview = gth_image_viewer_new (); gth_image_viewer_set_reset_scrollbars (GTH_IMAGE_VIEWER (self->priv->preview), FALSE); gth_image_viewer_set_fit_mode (GTH_IMAGE_VIEWER (self->priv->preview), GTH_FIT_NONE); gth_image_viewer_set_zoom_change (GTH_IMAGE_VIEWER (self->priv->preview), GTH_ZOOM_CHANGE_KEEP_PREV); gth_image_viewer_set_zoom (GTH_IMAGE_VIEWER (self->priv->preview), 1.0); gth_image_viewer_enable_zoom_with_keys (GTH_IMAGE_VIEWER (self->priv->preview), FALSE); gth_image_viewer_set_surface (GTH_IMAGE_VIEWER (self->priv->preview), self->priv->source, -1, -1); image_navigator = gth_image_navigator_new (GTH_IMAGE_VIEWER (self->priv->preview)); gtk_widget_show_all (image_navigator); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("preview_hbox")), image_navigator, TRUE, TRUE, 0); self->priv->amount_adj = gth_color_scale_label_new (GET_WIDGET ("amount_hbox"), GTK_LABEL (GET_WIDGET ("amount_label")), GTH_COLOR_SCALE_DEFAULT, DEFAULT_AMOUNT, 0.0, 500.0, 1.0, 1.0, "%.0f"); self->priv->radius_adj = gth_color_scale_label_new (GET_WIDGET ("radius_hbox"), GTK_LABEL (GET_WIDGET ("radius_label")), GTH_COLOR_SCALE_DEFAULT, DEFAULT_RADIUS, 0.0, 10.0, 1.0, 1.0, "%.0f"); self->priv->threshold_adj = gth_color_scale_label_new (GET_WIDGET ("threshold_hbox"), GTK_LABEL (GET_WIDGET ("threshold_label")), GTH_COLOR_SCALE_DEFAULT, DEFAULT_THRESHOLD, 0.0, 255.0, 1.0, 1.0, "%.0f"); g_signal_connect (GET_WIDGET ("ok_button"), "clicked", G_CALLBACK (ok_button_clicked_cb), self); g_signal_connect_swapped (GET_WIDGET ("cancel_button"), "clicked", G_CALLBACK (gth_file_tool_cancel), self); g_signal_connect (GET_WIDGET ("reset_button"), "clicked", G_CALLBACK (reset_button_clicked_cb), self); g_signal_connect (G_OBJECT (self->priv->radius_adj), "value-changed", G_CALLBACK (value_changed_cb), self); g_signal_connect (G_OBJECT (self->priv->amount_adj), "value-changed", G_CALLBACK (value_changed_cb), self); g_signal_connect (G_OBJECT (self->priv->threshold_adj), "value-changed", G_CALLBACK (value_changed_cb), self); g_signal_connect (GTH_IMAGE_VIEWER (self->priv->preview)->hadj, "value-changed", G_CALLBACK (value_changed_cb), self); g_signal_connect (GTH_IMAGE_VIEWER (self->priv->preview)->vadj, "value-changed", G_CALLBACK (value_changed_cb), self); g_signal_connect (GET_WIDGET ("preview_checkbutton"), "clicked", G_CALLBACK (preview_checkbutton_toggled_cb), self); g_signal_connect_after (self->priv->preview, "size-allocate", G_CALLBACK (preview_size_allocate_cb), self); return options; }
/* * MUST BE CALLED AFTER WIDGETS ARE INITIALIZED!! * Fills keycodes into comboboxes */ int keycodes_parse(void) { FILE *fp; gchar buffer[512]; gchar *code; int mod; if ((fp = fopen(KEYCODE_FILE_PATH, "r")) == 0) { fprintf(stderr, "Error: keycodes_parse could not open %s: %s\n", KEYCODE_FILE_PATH, g_strerror(errno)); return -1; } mods = (gchar **) malloc(sizeof(gchar *)); keycodes = (gchar **) malloc(sizeof(gchar *)); mods[0] = g_strdup("NONE"); keycodes[0] = g_strdup("NONE"); keycodes_entry_add(keycodes[0]); num_mods++; num_keycodes++; while (fgets(buffer, 511, fp) != NULL) { mod = 0; g_strchug(buffer); if (strlen(buffer) == 0) continue; g_strdelimit(buffer, " \t", '\0'); code = g_strndup(buffer, 60); /* -------- Add the keycodes straight to the comboboxes --------- */ if (strcasecmp("KEY_LEFTCTRL", code) == 0) mod=1; else if (strcasecmp("KEY_RIGHTCTRL", code) == 0) mod=1; else if (strcasecmp("KEY_LEFTSHIFT", code) == 0) mod=1; else if (strcasecmp("KEY_RIGHTSHIFT", code) == 0) mod=1; else if (strcasecmp("KEY_LEFTALT", code) == 0) mod=1; else if (strcasecmp("KEY_RIGHTALT", code) == 0) mod=1; else if (strcasecmp("KEY_RIGHTCTRL", code) == 0) mod=1; else if (strcasecmp("KEY_LEFTMETA", code) == 0) mod=1; else if (strcasecmp("KEY_RIGHTMETA", code) == 0) mod=1; if (mod == 1) { gtk_combo_box_append_text(GTK_COMBO_BOX(GET_WIDGET(COMBOBOX_MOD1_CONFIG)), code); gtk_combo_box_append_text(GTK_COMBO_BOX(GET_WIDGET(COMBOBOX_MOD2_CONFIG)), code); gtk_combo_box_append_text(GTK_COMBO_BOX(GET_WIDGET(COMBOBOX_MOD3_CONFIG)), code); mods = (gchar **) realloc(mods, (num_mods+1) * sizeof(gchar *)); mods[num_mods++] = code; } else { keycodes_entry_add(code); //gtk_combo_box_append_text(GTK_COMBO_BOX(GET_WIDGET(COMBOBOX_KEYCODE_CONFIG)), code); keycodes = (gchar **) realloc(keycodes, (num_keycodes+1) * sizeof(gchar *)); keycodes[num_keycodes++] = code; } /* ---------------------------------------------------------------*/ } fclose(fp); return 1; }