[gthumb] facebook: allow to upload high resolution images
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] facebook: allow to upload high resolution images
- Date: Fri, 2 Sep 2011 13:36:11 +0000 (UTC)
commit 858649fc66927d2c9da75b18736c7065d2f0e5c4
Author: Paolo Bacchilega <paobac src gnome org>
Date: Fri Sep 2 12:51:41 2011 +0200
facebook: allow to upload high resolution images
[bug #652216]
extensions/facebook/Makefile.am | 3 +-
extensions/facebook/data/Makefile.am | 15 ++
.../facebook/data/gthumb-facebook.schemas.in | 17 ++
extensions/facebook/data/ui/export-to-facebook.ui | 263 ++++++++++++++------
extensions/facebook/dlg-export-to-facebook.c | 47 ++++
extensions/facebook/facebook-service.c | 14 +-
extensions/facebook/facebook-service.h | 1 +
extensions/facebook/preferences.h | 27 ++
8 files changed, 301 insertions(+), 86 deletions(-)
---
diff --git a/extensions/facebook/Makefile.am b/extensions/facebook/Makefile.am
index b31dbf8..0f45675 100644
--- a/extensions/facebook/Makefile.am
+++ b/extensions/facebook/Makefile.am
@@ -33,7 +33,8 @@ libfacebook_la_SOURCES = \
facebook-types.h \
facebook-user.c \
facebook-user.h \
- main.c
+ main.c \
+ preferences.h
libfacebook_la_CFLAGS = $(GTHUMB_CFLAGS) $(LIBSOUP_CFLAGS) $(GNOME_KEYRING_CFLAGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
libfacebook_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
diff --git a/extensions/facebook/data/Makefile.am b/extensions/facebook/data/Makefile.am
index c1713cf..75ed653 100644
--- a/extensions/facebook/data/Makefile.am
+++ b/extensions/facebook/data/Makefile.am
@@ -1,3 +1,18 @@
SUBDIRS = ui
+schemadir = @GCONF_SCHEMA_FILE_DIR@
+schema_in_files = gthumb-facebook.schemas.in
+schema_DATA = $(schema_in_files:.schemas.in=.schemas)
+
+ INTLTOOL_SCHEMAS_RULE@
+
+if GCONF_SCHEMAS_INSTALL
+install-data-local:
+ GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/extensions/facebook/data/$(schema_DATA)
+endif
+
+EXTRA_DIST = $(schema_in_files)
+
+CLEANFILES = $(schema_DATA)
+
-include $(top_srcdir)/git.mk
diff --git a/extensions/facebook/data/gthumb-facebook.schemas.in b/extensions/facebook/data/gthumb-facebook.schemas.in
new file mode 100644
index 0000000..daf83f9
--- /dev/null
+++ b/extensions/facebook/data/gthumb-facebook.schemas.in
@@ -0,0 +1,17 @@
+<gconfschemafile>
+ <schemalist>
+
+ <schema>
+ <key>/schemas/apps/gthumb/ext/facebook/max_resolution</key>
+ <applyto>/apps/gthumb/ext/facebook/max_resolution</applyto>
+ <owner>gthumb</owner>
+ <type>int</type>
+ <default>2048</default>
+ <locale name="C">
+ <short></short>
+ <long></long>
+ </locale>
+ </schema>
+
+ </schemalist>
+</gconfschemafile>
diff --git a/extensions/facebook/data/ui/export-to-facebook.ui b/extensions/facebook/data/ui/export-to-facebook.ui
index 28aa8bb..d96c90a 100644
--- a/extensions/facebook/data/ui/export-to-facebook.ui
+++ b/extensions/facebook/data/ui/export-to-facebook.ui
@@ -1,62 +1,151 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <requires lib="gtk+" version="2.16"/>
- <!-- interface-naming-policy project-wide -->
+ <requires lib="gtk+" version="2.24"/>
+ <object class="GtkListStore" id="account_liststore">
+ <columns>
+ <!-- column-name account -->
+ <column type="GObject"/>
+ <!-- column-name username -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkListStore" id="album_liststore">
+ <columns>
+ <!-- column-name data -->
+ <column type="GObject"/>
+ <!-- column-name icon -->
+ <column type="gchararray"/>
+ <!-- column-name title -->
+ <column type="gchararray"/>
+ <!-- column-name n_photos -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
<object class="GtkDialog" id="export_dialog">
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
<property name="title" translatable="yes">Export to Flickr</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox7">
+ <object class="GtkBox" id="dialog-vbox7">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
+ <child internal-child="action_area">
+ <object class="GtkButtonBox" id="dialog-action_area7">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="close_button">
+ <property name="label">gtk-cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="upload_button">
+ <property name="label" translatable="yes">_Upload</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="image">upload_image</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="button1">
+ <property name="label">gtk-help</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ <property name="secondary">True</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkVBox" id="hbox1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="border_width">5</property>
- <property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkVBox" id="images_box">
<property name="width_request">460</property>
<property name="height_request">340</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="images_info_label">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkTable" id="table2">
<property name="visible">True</property>
- <property name="n_rows">2</property>
+ <property name="can_focus">False</property>
+ <property name="n_rows">3</property>
<property name="n_columns">2</property>
<property name="column_spacing">6</property>
<property name="row_spacing">5</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="top_padding">6</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="yalign">0</property>
<property name="label" translatable="yes">_Account:</property>
@@ -72,15 +161,18 @@
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">3</property>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkComboBox" id="account_combobox">
<property name="width_request">300</property>
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="model">account_liststore</property>
<child>
<object class="GtkCellRendererText" id="cellrenderertext4"/>
@@ -90,6 +182,8 @@
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -99,20 +193,25 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Edit accounts</property>
+ <property name="use_action_appearance">False</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="stock">gtk-edit</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -125,6 +224,7 @@
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">A_lbum:</property>
<property name="use_underline">True</property>
@@ -138,13 +238,17 @@
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkComboBox" id="album_combobox">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="model">album_liststore</property>
</object>
<packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -154,9 +258,11 @@
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="tooltip_text" translatable="yes">Add a new album</property>
+ <property name="use_action_appearance">False</property>
<child>
<object class="GtkImage" id="image1">
<property name="visible">True</property>
+ <property name="can_focus">False</property>
<property name="stock">gtk-add</property>
</object>
</child>
@@ -175,76 +281,60 @@
<property name="bottom_attach">2</property>
</packing>
</child>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="tooltip_text" translatable="yes">Resize the images if larger then this size</property>
+ <property name="label" translatable="yes">_Resize to:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">resize_combobox</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="resize_combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="model">resize_liststore</property>
+ <property name="active">0</property>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext1"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area7">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="close_button">
- <property name="label">gtk-cancel</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="upload_button">
- <property name="label" translatable="yes">_Upload</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="image">upload_image</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="button1">
- <property name="label">gtk-help</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- <property name="secondary">True</property>
- </packing>
- </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -255,28 +345,39 @@
<action-widget response="-11">button1</action-widget>
</action-widgets>
</object>
- <object class="GtkImage" id="upload_image">
- <property name="visible">True</property>
- <property name="stock">gtk-goto-top</property>
- </object>
- <object class="GtkListStore" id="account_liststore">
+ <object class="GtkListStore" id="resize_liststore">
<columns>
- <!-- column-name account -->
- <column type="GObject"/>
- <!-- column-name username -->
+ <!-- column-name description -->
<column type="gchararray"/>
+ <!-- column-name size -->
+ <column type="gint"/>
</columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">720 x 720</col>
+ <col id="1">720</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1024 x 1024</col>
+ <col id="1">1024</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1280 x 1280</col>
+ <col id="1">1280</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">1600 x 1600</col>
+ <col id="1">1600</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">2048 x 2048</col>
+ <col id="1">2048</col>
+ </row>
+ </data>
</object>
- <object class="GtkListStore" id="album_liststore">
- <columns>
- <!-- column-name data -->
- <column type="GObject"/>
- <!-- column-name icon -->
- <column type="gchararray"/>
- <!-- column-name title -->
- <column type="gchararray"/>
- <!-- column-name n_photos -->
- <column type="gchararray"/>
- </columns>
+ <object class="GtkImage" id="upload_image">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="stock">gtk-goto-top</property>
</object>
</interface>
diff --git a/extensions/facebook/dlg-export-to-facebook.c b/extensions/facebook/dlg-export-to-facebook.c
index 1c31e73..04a02ae 100644
--- a/extensions/facebook/dlg-export-to-facebook.c
+++ b/extensions/facebook/dlg-export-to-facebook.c
@@ -28,6 +28,7 @@
#include "facebook-album-properties-dialog.h"
#include "facebook-service.h"
#include "facebook-user.h"
+#include "preferences.h"
#define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
@@ -48,6 +49,12 @@ enum {
};
+enum {
+ RESIZE_DESCRIPTION_COLUMN,
+ RESIZE_SIZE_COLUMN
+};
+
+
typedef struct {
GthBrowser *browser;
GthFileData *location;
@@ -201,6 +208,7 @@ export_dialog_response_cb (GtkDialog *dialog,
{
GtkTreeIter iter;
GList *file_list;
+ int max_resolution;
gtk_widget_hide (data->dialog);
gth_task_dialog (GTH_TASK (data->conn), FALSE, NULL);
@@ -213,10 +221,21 @@ export_dialog_response_cb (GtkDialog *dialog,
-1);
}
+ max_resolution = 0;
+ if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")), &iter)) {
+ gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox"))),
+ &iter,
+ RESIZE_SIZE_COLUMN, &max_resolution,
+ -1);
+ }
+
+ eel_gconf_set_integer (PREF_FACEBOOK_MAX_RESOLUTION, max_resolution);
+
file_list = gth_file_data_list_to_file_list (data->file_list);
facebook_service_upload_photos (data->service,
data->album,
file_list,
+ max_resolution,
data->cancellable,
upload_photos_ready_cb,
data);
@@ -571,6 +590,34 @@ dlg_export_to_facebook (GthBrowser *browser,
gtk_window_set_title (GTK_WINDOW (data->dialog), title);
g_free (title);
+ {
+ /* set the default resolution */
+
+ int default_resolution;
+ GtkTreeModel *tree_model;
+ GtkTreeIter iter;
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")), 0);
+
+ default_resolution = eel_gconf_get_integer (PREF_FACEBOOK_MAX_RESOLUTION, 2048);
+ tree_model = (GtkTreeModel *) gtk_builder_get_object (data->builder, "resize_liststore");
+ if (gtk_tree_model_get_iter_first (tree_model, &iter)) {
+ do {
+ int resolution;
+
+ gtk_tree_model_get (tree_model,
+ &iter,
+ RESIZE_SIZE_COLUMN, &resolution,
+ -1);
+ if (resolution == default_resolution) {
+ gtk_combo_box_set_active_iter (GTK_COMBO_BOX (GET_WIDGET ("resize_combobox")), &iter);
+ break;
+ }
+ }
+ while (gtk_tree_model_iter_next (tree_model, &iter));
+ }
+ }
+
/* Set the signals handlers. */
g_signal_connect (data->dialog,
diff --git a/extensions/facebook/facebook-service.c b/extensions/facebook/facebook-service.c
index dc4e390..19e1c80 100644
--- a/extensions/facebook/facebook-service.c
+++ b/extensions/facebook/facebook-service.c
@@ -30,11 +30,13 @@
#include "facebook-service.h"
#include "facebook-user.h"
-#define FACEBOOK_MAX_IMAGE_SIZE 720
+#define FACEBOOK_MIN_IMAGE_SIZE 720
+#define FACEBOOK_MAX_IMAGE_SIZE 2048
typedef struct {
FacebookAlbum *album;
GList *file_list;
+ int max_resolution;
FacebookVisibility visibility_level;
GCancellable *cancellable;
GAsyncReadyCallback callback;
@@ -756,7 +758,9 @@ upload_photo_file_buffer_ready_cb (void **buffer,
keys = g_hash_table_get_keys (data_set);
for (scan = keys; scan; scan = scan->next) {
char *key = scan->data;
- soup_multipart_append_form_string (multipart, key, g_hash_table_lookup (data_set, key));
+ char *value = g_hash_table_lookup (data_set, key);
+ if (value != NULL)
+ soup_multipart_append_form_string (multipart, key, value);
}
g_list_free (keys);
@@ -792,8 +796,8 @@ upload_photo_file_buffer_ready_cb (void **buffer,
height = gdk_pixbuf_get_height (pixbuf);
if (scale_keeping_ratio (&width,
&height,
- FACEBOOK_MAX_IMAGE_SIZE,
- FACEBOOK_MAX_IMAGE_SIZE,
+ self->priv->post_photos->max_resolution,
+ self->priv->post_photos->max_resolution,
FALSE))
{
tmp_pixbuf = _gdk_pixbuf_scale_simple_safe (pixbuf, width, height, GDK_INTERP_BILINEAR);
@@ -904,6 +908,7 @@ void
facebook_service_upload_photos (FacebookService *self,
FacebookAlbum *album,
GList *file_list, /* GFile list */
+ int max_resolution,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -913,6 +918,7 @@ facebook_service_upload_photos (FacebookService *self,
post_photos_data_free (self->priv->post_photos);
self->priv->post_photos = g_new0 (PostPhotosData, 1);
self->priv->post_photos->album = _g_object_ref (album);
+ self->priv->post_photos->max_resolution = CLAMP (max_resolution, FACEBOOK_MIN_IMAGE_SIZE, FACEBOOK_MAX_IMAGE_SIZE);
self->priv->post_photos->cancellable = _g_object_ref (cancellable);
self->priv->post_photos->callback = callback;
self->priv->post_photos->user_data = user_data;
diff --git a/extensions/facebook/facebook-service.h b/extensions/facebook/facebook-service.h
index 2f503de..6571cf3 100644
--- a/extensions/facebook/facebook-service.h
+++ b/extensions/facebook/facebook-service.h
@@ -87,6 +87,7 @@ FacebookAlbum * facebook_service_create_album_finish (FacebookService
void facebook_service_upload_photos (FacebookService *self,
FacebookAlbum *album,
GList *file_list, /* GFile list */
+ int max_resolution,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
diff --git a/extensions/facebook/preferences.h b/extensions/facebook/preferences.h
new file mode 100644
index 0000000..f95f128
--- /dev/null
+++ b/extensions/facebook/preferences.h
@@ -0,0 +1,27 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2011 Free Software Foundation, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef PREFERENCES_H
+#define PREFERENCES_H
+
+#define PREF_FACEBOOK_MAX_RESOLUTION "/apps/gthumb/ext/facebook/max_resolution"
+
+#endif /* PREFERENCES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]