[gthumb] Added ability to import from and export to 23hq.com
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] Added ability to import from and export to 23hq.com
- Date: Sun, 11 Sep 2011 14:31:49 +0000 (UTC)
commit c1741c202e91560a07bfa224aed8a7340cc63730
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sat Sep 10 18:31:06 2011 +0200
Added ability to import from and export to 23hq.com
[bug #657269]
data/icons/hicolor/16x16/actions/Makefile.am | 9 ++--
.../hicolor/16x16/actions/site-twentythree.png | Bin 0 -> 520 bytes
extensions/flicker/actions.c | 43 +++++++++++++++++-
extensions/flicker/actions.h | 2 +
extensions/flicker/callbacks.c | 19 +++++++-
extensions/flicker/dlg-import-from-flickr.c | 16 +------
extensions/flicker/flickr-authentication.c | 6 +-
extensions/flicker/flickr-photo.c | 47 +++++++++++++++++++-
extensions/flicker/flickr-photo.h | 47 ++++++++++----------
extensions/flicker/flickr-service.c | 35 ++++++++++++--
extensions/flicker/flickr-service.h | 5 +-
extensions/flicker/flickr-types.h | 1 +
12 files changed, 173 insertions(+), 57 deletions(-)
---
diff --git a/data/icons/hicolor/16x16/actions/Makefile.am b/data/icons/hicolor/16x16/actions/Makefile.am
index 772c06f..03aeb91 100644
--- a/data/icons/hicolor/16x16/actions/Makefile.am
+++ b/data/icons/hicolor/16x16/actions/Makefile.am
@@ -6,18 +6,19 @@ iconsdir = $(themedir)/$(size)/$(context)
icons_DATA = \
browser-mode.png \
- facebook.png \
file-catalog.png \
file-library.png \
file-search.png \
- flickr.png \
histogram.png \
histogram-linear.png \
histogram-logarithmic.png \
image-navigator.png \
map.png \
- photobucket.png \
- picasaweb.png \
+ site-facebook.png \
+ site-flickr.png \
+ site-photobucket.png \
+ site-picasaweb.png \
+ site-twentythree.png \
tool-adjust-colors.png \
tool-crop.png \
tool-desaturate.png \
diff --git a/data/icons/hicolor/16x16/actions/site-twentythree.png b/data/icons/hicolor/16x16/actions/site-twentythree.png
new file mode 100644
index 0000000..626d797
Binary files /dev/null and b/data/icons/hicolor/16x16/actions/site-twentythree.png differ
diff --git a/extensions/flicker/actions.c b/extensions/flicker/actions.c
index 9ccc869..b7eac0e 100644
--- a/extensions/flicker/actions.c
+++ b/extensions/flicker/actions.c
@@ -29,13 +29,26 @@
static FlickrServer www_flickr_com = {
- "Flickr.com",
+ "Flickr",
"http://www.flickr.com",
"http://www.flickr.com/services/auth/",
"http://api.flickr.com/services/rest",
"http://api.flickr.com/services/upload/",
"8960706ee7f4151e893b11837e9c24ce",
- "1ff8d1e45c873423"
+ "1ff8d1e45c873423",
+ FALSE
+};
+
+
+static FlickrServer www_23hq_com = {
+ "23",
+ "http://www.23hq.com",
+ "http://www.23hq.com/services/auth/",
+ "http://www.23hq.com/services/rest",
+ "http://www.23hq.com/services/upload/",
+ "8960706ee7f4151e893b11837e9c24ce",
+ "1ff8d1e45c873423",
+ TRUE
};
@@ -63,3 +76,29 @@ gth_browser_activate_action_import_flicker (GtkAction *action,
{
dlg_import_from_flickr (&www_flickr_com, browser);
}
+
+
+void
+gth_browser_activate_action_export_23 (GtkAction *action,
+ GthBrowser *browser)
+{
+ GList *items;
+ GList *file_list;
+
+ items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+ file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+ if (file_list == NULL)
+ file_list = gth_file_store_get_visibles (gth_browser_get_file_store (browser));
+ dlg_export_to_flickr (&www_23hq_com, browser, file_list);
+
+ _g_object_list_unref (file_list);
+ _gtk_tree_path_list_free (items);
+}
+
+
+void
+gth_browser_activate_action_import_23 (GtkAction *action,
+ GthBrowser *browser)
+{
+ dlg_import_from_flickr (&www_23hq_com, browser);
+}
diff --git a/extensions/flicker/actions.h b/extensions/flicker/actions.h
index 6edd033..100da01 100644
--- a/extensions/flicker/actions.h
+++ b/extensions/flicker/actions.h
@@ -28,5 +28,7 @@
DEFINE_ACTION(gth_browser_activate_action_export_flicker)
DEFINE_ACTION(gth_browser_activate_action_import_flicker)
+DEFINE_ACTION(gth_browser_activate_action_export_23)
+DEFINE_ACTION(gth_browser_activate_action_import_23)
#endif /* ACTIONS_H */
diff --git a/extensions/flicker/callbacks.c b/extensions/flicker/callbacks.c
index d910ccb..dd5d66b 100644
--- a/extensions/flicker/callbacks.c
+++ b/extensions/flicker/callbacks.c
@@ -37,11 +37,13 @@ static const char *ui_info =
" <menu name='Import' action='ImportMenu'>"
" <placeholder name='Web_Services'>"
" <menuitem action='File_Import_Flicker'/>"
+" <menuitem action='File_Import_23'/>"
" </placeholder>"
" </menu>"
" <menu name='Export' action='ExportMenu'>"
" <placeholder name='Web_Services'>"
" <menuitem action='File_Export_Flicker'/>"
+" <menuitem action='File_Export_23'/>"
" </placeholder>"
" </menu>"
" </menu>"
@@ -49,20 +51,29 @@ static const char *ui_info =
" <popup name='ExportPopup'>"
" <placeholder name='Web_Services'>"
" <menuitem action='File_Export_Flicker'/>"
+" <menuitem action='File_Export_23'/>"
" </placeholder>"
" </popup>"
"</ui>";
static GtkActionEntry action_entries[] = {
- { "File_Import_Flicker", "flickr",
+ { "File_Import_Flicker", "site-flickr",
N_("_Flickr..."), NULL,
N_("Download photos from Flickr"),
G_CALLBACK (gth_browser_activate_action_import_flicker) },
- { "File_Export_Flicker", "flickr",
+ { "File_Export_Flicker", "site-flickr",
N_("_Flickr..."), NULL,
N_("Upload photos to Flickr"),
G_CALLBACK (gth_browser_activate_action_export_flicker) },
+ { "File_Import_23", "site-twentythree",
+ N_("_23..."), NULL,
+ N_("Download photos from 23"),
+ G_CALLBACK (gth_browser_activate_action_import_23) },
+ { "File_Export_23", "site-twentythree",
+ N_("_23..."), NULL,
+ N_("Upload photos to 23"),
+ G_CALLBACK (gth_browser_activate_action_export_23) },
};
@@ -107,5 +118,9 @@ fl__gth_browser_construct_cb (GthBrowser *browser)
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/File/Export/Web_Services/File_Export_Flicker")), TRUE);
gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ExportPopup/Web_Services/File_Export_Flicker")), TRUE);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/File/Import/Web_Services/File_Import_23")), TRUE);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/MenuBar/File/Export/Web_Services/File_Export_23")), TRUE);
+ gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (gtk_ui_manager_get_widget (gth_browser_get_ui_manager (browser), "/ExportPopup/Web_Services/File_Export_23")), TRUE);
+
g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
}
diff --git a/extensions/flicker/dlg-import-from-flickr.c b/extensions/flicker/dlg-import-from-flickr.c
index 1f68a9f..628bdbc 100644
--- a/extensions/flicker/dlg-import-from-flickr.c
+++ b/extensions/flicker/dlg-import-from-flickr.c
@@ -363,24 +363,12 @@ list_photos_ready_cb (GObject *source_object,
list = NULL;
for (scan = data->photos; scan; scan = scan->next) {
FlickrPhoto *photo = scan->data;
- const char *url;
GthFileData *file_data;
- url = NULL;
- if (photo->url_s != NULL)
- url = photo->url_s;
- else if (photo->url_m != NULL)
- url = photo->url_m;
- else if (photo->url_o != NULL)
- url = photo->url_o;
-
- if (url == NULL)
- url = photo->url_sq;
-
- if (url == NULL)
+ if (photo->url_o == NULL)
continue;
- file_data = gth_file_data_new_for_uri (url, (photo->mime_type != NULL) ? photo->mime_type : "image/jpeg");
+ file_data = gth_file_data_new_for_uri (photo->url_o, (photo->mime_type != NULL) ? photo->mime_type : "image/jpeg");
g_file_info_set_file_type (file_data->info, G_FILE_TYPE_REGULAR);
g_file_info_set_size (file_data->info, FAKE_SIZE); /* set a fake size to make the progress dialog work correctly */
g_file_info_set_attribute_object (file_data->info, "flickr::object", G_OBJECT (photo));
diff --git a/extensions/flicker/flickr-authentication.c b/extensions/flicker/flickr-authentication.c
index 84d57f5..2365a2d 100644
--- a/extensions/flicker/flickr-authentication.c
+++ b/extensions/flicker/flickr-authentication.c
@@ -161,7 +161,7 @@ flickr_authentication_new (FlickrConnection *conn,
self->priv->conn = g_object_ref (conn);
self->priv->service = g_object_ref (service);
self->priv->cancellable = _g_object_ref (cancellable);
- self->priv->accounts = flickr_accounts_load_from_file ();
+ self->priv->accounts = flickr_accounts_load_from_file (conn->server->name);
self->priv->account = flickr_accounts_find_default (self->priv->accounts);
self->priv->browser = browser;
self->priv->dialog = dialog;
@@ -254,7 +254,7 @@ upload_status_ready_cb (GObject *source_object,
show_authentication_error_dialog (self, &error);
return;
}
- flickr_accounts_save_to_file (self->priv->accounts, self->priv->account);
+ flickr_accounts_save_to_file (self->priv->conn->server->name, self->priv->accounts, self->priv->account);
g_signal_emit (self, flickr_authentication_signals[READY], 0, user);
@@ -693,7 +693,7 @@ account_manager_dialog_response_cb (GtkDialog *dialog,
}
else
g_signal_emit (self, flickr_authentication_signals[ACCOUNTS_CHANGED], 0);
- flickr_accounts_save_to_file (self->priv->accounts, self->priv->account);
+ flickr_accounts_save_to_file (self->priv->conn->server->name, self->priv->accounts, self->priv->account);
gtk_widget_destroy (GTK_WIDGET (dialog));
break;
diff --git a/extensions/flicker/flickr-photo.c b/extensions/flicker/flickr-photo.c
index 7cb1715..d1849d6 100644
--- a/extensions/flicker/flickr-photo.c
+++ b/extensions/flicker/flickr-photo.c
@@ -26,6 +26,11 @@
#include "flickr-photo.h"
+struct _FlickrPhotoPrivate {
+ FlickrServer *server;
+};
+
+
static gpointer flickr_photo_parent_class = NULL;
@@ -49,6 +54,7 @@ static void
flickr_photo_class_init (FlickrPhotoClass *klass)
{
flickr_photo_parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (FlickrPhotoPrivate));
G_OBJECT_CLASS (klass)->finalize = flickr_photo_finalize;
}
@@ -113,6 +119,8 @@ flickr_photo_dom_domizable_interface_init (DomDomizableIface *iface)
static void
flickr_photo_instance_init (FlickrPhoto *self)
{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, FLICKR_TYPE_PHOTO, FlickrPhotoPrivate);
+ self->priv->server = NULL;
}
@@ -152,9 +160,14 @@ flickr_photo_get_type (void)
FlickrPhoto *
-flickr_photo_new (void)
+flickr_photo_new (FlickrServer *server)
{
- return g_object_new (FLICKR_TYPE_PHOTO, NULL);
+ FlickrPhoto *self;
+
+ self = g_object_new (FLICKR_TYPE_PHOTO, NULL);
+ self->priv->server = server;
+
+ return self;
}
@@ -198,11 +211,24 @@ flickr_photo_set_is_primary (FlickrPhoto *self,
}
+static char *
+flickr_get_static_url (FlickrPhoto *self,
+ const char *subtype)
+{
+ if ((self->priv->server != NULL) && self->priv->server->automatic_urls)
+ return g_strdup_printf ("%s/%s/%s_%s%s.jpg", self->priv->server->url, self->server, self->id, self->secret, subtype);
+ else
+ return NULL;
+}
+
+
void
flickr_photo_set_url_sq (FlickrPhoto *self,
const char *value)
{
_g_strset (&self->url_sq, value);
+ if (self->url_sq == NULL)
+ self->url_sq = flickr_get_static_url (self, "_sq");
}
@@ -211,6 +237,8 @@ flickr_photo_set_url_t (FlickrPhoto *self,
const char *value)
{
_g_strset (&self->url_t, value);
+ if (self->url_t == NULL)
+ self->url_t = flickr_get_static_url (self, "_t");
}
@@ -219,6 +247,8 @@ flickr_photo_set_url_s (FlickrPhoto *self,
const char *value)
{
_g_strset (&self->url_s, value);
+ if (self->url_s == NULL)
+ self->url_s = flickr_get_static_url (self, "_s");
}
@@ -227,6 +257,8 @@ flickr_photo_set_url_m (FlickrPhoto *self,
const char *value)
{
_g_strset (&self->url_m, value);
+ if (self->url_m == NULL)
+ self->url_m = flickr_get_static_url (self, "_m");
}
@@ -235,6 +267,17 @@ flickr_photo_set_url_o (FlickrPhoto *self,
const char *value)
{
_g_strset (&self->url_o, value);
+ if (self->url_o == NULL)
+ self->url_o = flickr_get_static_url (self, "");
+
+ if (self->url_o == NULL) {
+ if (self->url_m != NULL)
+ _g_strset (&self->url_o, self->url_m);
+ else if (self->url_s != NULL)
+ _g_strset (&self->url_o, self->url_s);
+ else if (self->url_sq != NULL)
+ _g_strset (&self->url_o, self->url_sq);
+ }
}
diff --git a/extensions/flicker/flickr-photo.h b/extensions/flicker/flickr-photo.h
index 13a6dd1..abaa210 100644
--- a/extensions/flicker/flickr-photo.h
+++ b/extensions/flicker/flickr-photo.h
@@ -24,6 +24,7 @@
#include <glib.h>
#include <glib-object.h>
+#include "flickr-types.h"
G_BEGIN_DECLS
@@ -62,29 +63,29 @@ struct _FlickrPhotoClass {
};
GType flickr_photo_get_type (void);
-FlickrPhoto * flickr_photo_new (void);
-void flickr_photo_set_id (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_secret (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_server (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_title (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_is_primary (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_url_sq (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_url_t (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_url_s (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_url_m (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_url_o (FlickrPhoto *self,
- const char *value);
-void flickr_photo_set_original_format (FlickrPhoto *self,
- const char *value);
+FlickrPhoto * flickr_photo_new (FlickrServer *server);
+void flickr_photo_set_id (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_secret (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_server (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_title (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_is_primary (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_url_sq (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_url_t (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_url_s (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_url_m (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_url_o (FlickrPhoto *self,
+ const char *value);
+void flickr_photo_set_original_format (FlickrPhoto *self,
+ const char *value);
G_END_DECLS
diff --git a/extensions/flicker/flickr-service.c b/extensions/flicker/flickr-service.c
index cb35cdb..ae050c5 100644
--- a/extensions/flicker/flickr-service.c
+++ b/extensions/flicker/flickr-service.c
@@ -1100,16 +1100,37 @@ flickr_service_list_photos_finish (FlickrService *self,
/* utilities */
+/* Used for compatibility with the original Flickr uploader that used
+ * flickr.xml as filename */
+static char *
+get_server_accounts_filename (const char *server_name)
+{
+ char *name;
+ char *filename;
+
+ name = g_ascii_strdown (server_name, -1);
+ filename = g_strconcat (name, ".xml", NULL);
+
+ g_free (name);
+
+ return filename;
+}
+
+
GList *
-flickr_accounts_load_from_file (void)
+flickr_accounts_load_from_file (const char *server_name)
{
GList *accounts = NULL;
char *filename;
char *buffer;
+ char *accounts_filename;
gsize len;
DomDocument *doc;
- filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", "flickr.xml", NULL);
+ accounts_filename = get_server_accounts_filename (server_name);
+ filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", accounts_filename, NULL);
+ g_free (accounts_filename);
+
if (! g_file_get_contents (filename, &buffer, &len, NULL)) {
g_free (filename);
return NULL;
@@ -1166,7 +1187,8 @@ flickr_accounts_find_default (GList *accounts)
void
-flickr_accounts_save_to_file (GList *accounts,
+flickr_accounts_save_to_file (const char *server_name,
+ GList *accounts,
FlickrAccount *default_account)
{
DomDocument *doc;
@@ -1174,6 +1196,7 @@ flickr_accounts_save_to_file (GList *accounts,
GList *scan;
char *buffer;
gsize len;
+ char *accounts_filename;
char *filename;
GFile *file;
@@ -1192,8 +1215,9 @@ flickr_accounts_save_to_file (GList *accounts,
dom_element_append_child (root, node);
}
- gth_user_dir_make_dir_for_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", "flickr.xml", NULL);
- filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", "flickr.xml", NULL);
+ accounts_filename = get_server_accounts_filename (server_name);
+ gth_user_dir_make_dir_for_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", accounts_filename, NULL);
+ filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", accounts_filename, NULL);
file = g_file_new_for_path (filename);
buffer = dom_document_dump (doc, &len);
g_write_file (file, FALSE, G_FILE_CREATE_PRIVATE | G_FILE_CREATE_REPLACE_DESTINATION, buffer, len, NULL, NULL);
@@ -1201,5 +1225,6 @@ flickr_accounts_save_to_file (GList *accounts,
g_free (buffer);
g_object_unref (file);
g_free (filename);
+ g_free (accounts_filename);
g_object_unref (doc);
}
diff --git a/extensions/flicker/flickr-service.h b/extensions/flicker/flickr-service.h
index 6e111c7..fb20bbe 100644
--- a/extensions/flicker/flickr-service.h
+++ b/extensions/flicker/flickr-service.h
@@ -123,9 +123,10 @@ GList * flickr_service_list_photos_finish (FlickrService
/* utilities */
-GList * flickr_accounts_load_from_file (void);
+GList * flickr_accounts_load_from_file (const char *server_name);
FlickrAccount * flickr_accounts_find_default (GList *accounts);
-void flickr_accounts_save_to_file (GList *accounts,
+void flickr_accounts_save_to_file (const char *server_name,
+ GList *accounts,
FlickrAccount *default_account);
#endif /* FLICKR_SERVICE_H */
diff --git a/extensions/flicker/flickr-types.h b/extensions/flicker/flickr-types.h
index 8e30400..76177c7 100644
--- a/extensions/flicker/flickr-types.h
+++ b/extensions/flicker/flickr-types.h
@@ -55,6 +55,7 @@ typedef struct {
const char *upload_url;
const char *api_key;
const char *shared_secret;
+ gboolean automatic_urls;
} FlickrServer;
#endif /* FLICKR_TYPES_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]