[gthumb] resize images: added ability to select the file format
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] resize images: added ability to select the file format
- Date: Sat, 9 Apr 2011 14:19:12 +0000 (UTC)
commit 14c9d9ccdbe423195b1c87015091a62be3967f21
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Apr 9 16:17:23 2011 +0200
resize images: added ability to select the file format
[new feature]
.../data/gthumb_resize_images.schemas.in | 12 +++
extensions/resize_images/data/ui/resize-images.ui | 66 +++++++++++++++++-
extensions/resize_images/dlg-resize-images.c | 72 +++++++++++++++++++-
extensions/resize_images/preferences.h | 1 +
4 files changed, 146 insertions(+), 5 deletions(-)
---
diff --git a/extensions/resize_images/data/gthumb_resize_images.schemas.in b/extensions/resize_images/data/gthumb_resize_images.schemas.in
index 318d733..82a59a3 100644
--- a/extensions/resize_images/data/gthumb_resize_images.schemas.in
+++ b/extensions/resize_images/data/gthumb_resize_images.schemas.in
@@ -61,5 +61,17 @@
</locale>
</schema>
+ <schema>
+ <key>/schemas/apps/gthumb/ext/resize_images/mime_type</key>
+ <applyto>/apps/gthumb/ext/resize_images/mime_type</applyto>
+ <owner>gthumb</owner>
+ <type>string</type>
+ <default></default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
</schemalist>
</gconfschemafile>
diff --git a/extensions/resize_images/data/ui/resize-images.ui b/extensions/resize_images/data/ui/resize-images.ui
index 76f0e87..7766003 100644
--- a/extensions/resize_images/data/ui/resize-images.ui
+++ b/extensions/resize_images/data/ui/resize-images.ui
@@ -222,9 +222,9 @@
<child>
<object class="GtkFileChooserButton" id="destination_filechooserbutton">
<property name="visible">True</property>
- <property name="create_folders">False</property>
- <property name="action">select-folder</property>
<property name="local_only">False</property>
+ <property name="action">select-folder</property>
+ <property name="create_folders">False</property>
<property name="title" translatable="yes">Choose destination folder</property>
</object>
<packing>
@@ -257,6 +257,58 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <object class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Format</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkAlignment" id="alignment3">
+ <property name="visible">True</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkComboBox" id="mime_type_combobox">
+ <property name="visible">True</property>
+ <property name="model">mime_type_liststore</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="pixbuf">0</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
@@ -346,4 +398,14 @@
</row>
</data>
</object>
+ <object class="GtkListStore" id="mime_type_liststore">
+ <columns>
+ <!-- column-name icon -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name mime_type -->
+ <column type="gchararray"/>
+ <!-- column-name description -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
</interface>
diff --git a/extensions/resize_images/dlg-resize-images.c b/extensions/resize_images/dlg-resize-images.c
index 244ea82..63061fd 100644
--- a/extensions/resize_images/dlg-resize-images.c
+++ b/extensions/resize_images/dlg-resize-images.c
@@ -31,6 +31,13 @@
#define DEFAULT_HEIGHT 480
+enum {
+ MIME_TYPE_COLUMN_ICON = 0,
+ MIME_TYPE_COLUMN_TYPE,
+ MIME_TYPE_COLUMN_DESCRIPTION
+};
+
+
GthUnit units[] = { GTH_UNIT_PIXELS, GTH_UNIT_PERCENTAGE };
@@ -121,9 +128,11 @@ static void
ok_clicked_cb (GtkWidget *widget,
DialogData *data)
{
- ResizeData *resize_data;
- GthTask *resize_task;
- GthTask *list_task;
+ ResizeData *resize_data;
+ GtkTreeIter iter;
+ char *mime_type;
+ GthTask *resize_task;
+ GthTask *list_task;
resize_data = g_new0 (ResizeData, 1);
resize_data->width = gtk_spin_button_get_value (GTK_SPIN_BUTTON (GET_WIDGET ("width_spinbutton")));
@@ -132,10 +141,16 @@ ok_clicked_cb (GtkWidget *widget,
resize_data->keep_aspect_ratio = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_ratio_checkbutton")));
resize_data->allow_swap = FALSE;
+ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("mime_type_combobox")), &iter);
+ gtk_tree_model_get (GTK_TREE_MODEL (GET_WIDGET ("mime_type_liststore")), &iter,
+ MIME_TYPE_COLUMN_TYPE, &mime_type,
+ -1);
+
eel_gconf_set_integer (PREF_RESIZE_IMAGES_SERIES_WIDTH, resize_data->width);
eel_gconf_set_integer (PREF_RESIZE_IMAGES_SERIES_HEIGHT, resize_data->height);
eel_gconf_set_enum (PREF_RESIZE_IMAGES_UNIT, GTH_TYPE_UNIT, resize_data->unit);
eel_gconf_set_boolean (PREF_RESIZE_IMAGES_KEEP_RATIO, resize_data->keep_aspect_ratio);
+ eel_gconf_set_string (PREF_RESIZE_IMAGES_MIME_TYPE, mime_type ? mime_type : "");
resize_task = gth_pixbuf_task_new (_("Resizing images"),
TRUE,
@@ -148,6 +163,7 @@ ok_clicked_cb (GtkWidget *widget,
data->file_list,
GTH_PIXBUF_TASK (resize_task));
gth_pixbuf_list_task_set_overwrite_mode (GTH_PIXBUF_LIST_TASK (list_task), GTH_OVERWRITE_ASK);
+ gth_pixbuf_list_task_set_output_mime_type (GTH_PIXBUF_LIST_TASK (list_task), mime_type);
if (data->use_destination) {
GFile *destination;
@@ -160,6 +176,7 @@ ok_clicked_cb (GtkWidget *widget,
g_object_unref (list_task);
g_object_unref (resize_task);
+ g_free (mime_type);
gtk_widget_destroy (data->dialog);
}
@@ -207,6 +224,7 @@ dlg_resize_images (GthBrowser *browser,
GList *file_list)
{
DialogData *data;
+ GArray *savers;
GthFileData *first_file_data;
if (gth_browser_get_dialog (browser, "resize_images") != NULL) {
@@ -234,6 +252,54 @@ dlg_resize_images (GthBrowser *browser,
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_ratio_checkbutton")), eel_gconf_get_boolean (PREF_RESIZE_IMAGES_KEEP_RATIO, TRUE));
update_sensitivity (data);
+ savers = gth_main_get_type_set ("pixbuf-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 = eel_gconf_get_string (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;
+ GthPixbufSaver *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_pixbuf_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);
+ }
+
first_file_data = (GthFileData *) data->file_list->data;
gtk_file_chooser_set_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")),
first_file_data->file,
diff --git a/extensions/resize_images/preferences.h b/extensions/resize_images/preferences.h
index 6b75533..c572acc 100644
--- a/extensions/resize_images/preferences.h
+++ b/extensions/resize_images/preferences.h
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
#define PREF_RESIZE_IMAGES_SERIES_HEIGHT "/apps/gthumb/ext/resize_images/height"
#define PREF_RESIZE_IMAGES_UNIT "/apps/gthumb/ext/resize_images/unit"
#define PREF_RESIZE_IMAGES_KEEP_RATIO "/apps/gthumb/ext/resize_images/keep_aspect_ratio"
+#define PREF_RESIZE_IMAGES_MIME_TYPE "/apps/gthumb/ext/resize_images/mime_type"
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]