[gthumb: 4/22] [picasaweb] added ability to create an album
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb: 4/22] [picasaweb] added ability to create an album
- Date: Sat, 30 Jan 2010 23:19:36 +0000 (UTC)
commit 151d5db0a438c97169c0fb77831328d54ee0abdf
Author: Paolo Bacchilega <paobac src gnome org>
Date: Sun Jan 24 21:31:13 2010 +0100
[picasaweb] added ability to create an album
extensions/picasaweb/Makefile.am | 2 +
.../picasaweb/data/ui/export-to-picasaweb.ui | 129 +----------------
.../data/ui/picasa-web-account-chooser.ui | 70 +++++++++
.../data/ui/picasa-web-album-properties.ui | 101 +++++++++++++
extensions/picasaweb/dlg-export-to-picasaweb.c | 137 +++++++++++++++---
extensions/picasaweb/google-connection.c | 14 +-
extensions/picasaweb/google-connection.h | 1 +
extensions/picasaweb/gth-account-chooser-dialog.c | 74 +++++++++-
.../picasaweb/gth-account-properties-dialog.c | 23 +---
extensions/picasaweb/gth-album-properties-dialog.c | 155 ++++++++++++++++++++
extensions/picasaweb/gth-album-properties-dialog.h | 60 ++++++++
extensions/picasaweb/picasa-web-service.c | 6 +-
12 files changed, 587 insertions(+), 185 deletions(-)
---
diff --git a/extensions/picasaweb/Makefile.am b/extensions/picasaweb/Makefile.am
index d91c56b..cd636c1 100644
--- a/extensions/picasaweb/Makefile.am
+++ b/extensions/picasaweb/Makefile.am
@@ -18,6 +18,8 @@ libpicasaweb_la_SOURCES = \
gth-account-chooser-dialog.h \
gth-account-properties-dialog.c \
gth-account-properties-dialog.h \
+ gth-album-properties-dialog.c \
+ gth-album-properties-dialog.h \
main.c \
picasa-web-album.c \
picasa-web-album.h \
diff --git a/extensions/picasaweb/data/ui/export-to-picasaweb.ui b/extensions/picasaweb/data/ui/export-to-picasaweb.ui
index 2c7e1c1..294d1d6 100644
--- a/extensions/picasaweb/data/ui/export-to-picasaweb.ui
+++ b/extensions/picasaweb/data/ui/export-to-picasaweb.ui
@@ -156,7 +156,7 @@
<property name="visible">True</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkButton" id="button2">
+ <object class="GtkButton" id="add_album_button">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
@@ -261,131 +261,4 @@
<property name="visible">True</property>
<property name="stock">gtk-goto-top</property>
</object>
- <object class="GtkDialog" id="choose_account_dialog">
- <property name="border_width">5</property>
- <property name="type_hint">normal</property>
- <property name="has_separator">False</property>
- <child internal-child="vbox">
- <object class="GtkVBox" id="dialog-vbox2">
- <property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">2</property>
- <child>
- <object class="GtkVBox" id="vbox4">
- <property name="visible">True</property>
- <property name="border_width">5</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkHBox" id="hbox3">
- <property name="visible">True</property>
- <property name="spacing">6</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">A_ccount:</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkComboBox" id="choose_account_combobox">
- <property name="width_request">300</property>
- <property name="visible">True</property>
- <property name="model">account_liststore</property>
- <child>
- <object class="GtkCellRendererPixbuf" id="cellrenderertext2"/>
- <attributes>
- <attribute name="sensitive">4</attribute>
- <attribute name="icon-name">3</attribute>
- </attributes>
- </child>
- <child>
- <object class="GtkCellRendererText" id="cellrenderertext4"/>
- <attributes>
- <attribute name="sensitive">4</attribute>
- <attribute name="text">2</attribute>
- </attributes>
- </child>
- </object>
- <packing>
- <property name="position">1</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child internal-child="action_area">
- <object class="GtkHButtonBox" id="dialog-action_area2">
- <property name="visible">True</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button3">
- <property name="label">gtk-new</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="button4">
- <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">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkButton" id="button5">
- <property name="label">gtk-ok</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>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="pack_type">end</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- </child>
- <action-widgets>
- <action-widget response="1">button3</action-widget>
- <action-widget response="-6">button4</action-widget>
- <action-widget response="-5">button5</action-widget>
- </action-widgets>
- </object>
</interface>
diff --git a/extensions/picasaweb/data/ui/picasa-web-account-chooser.ui b/extensions/picasaweb/data/ui/picasa-web-account-chooser.ui
new file mode 100644
index 0000000..0fa20c5
--- /dev/null
+++ b/extensions/picasaweb/data/ui/picasa-web-account-chooser.ui
@@ -0,0 +1,70 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkListStore" id="account_liststore">
+ <columns>
+ <!-- column-name account -->
+ <column type="gchararray"/>
+ <!-- column-name type -->
+ <column type="gint"/>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name icon -->
+ <column type="gchararray"/>
+ <!-- column-name sensitive -->
+ <column type="gboolean"/>
+ </columns>
+ </object>
+ <object class="GtkVBox" id="account_chooser">
+ <property name="visible">True</property>
+ <property name="border_width">5</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">A_ccount:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBox" id="account_combobox">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="model">account_liststore</property>
+ <child>
+ <object class="GtkCellRendererPixbuf" id="cellrenderertext2"/>
+ <attributes>
+ <attribute name="sensitive">4</attribute>
+ <attribute name="icon-name">3</attribute>
+ </attributes>
+ </child>
+ <child>
+ <object class="GtkCellRendererText" id="cellrenderertext4"/>
+ <attributes>
+ <attribute name="sensitive">4</attribute>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>
diff --git a/extensions/picasaweb/data/ui/picasa-web-album-properties.ui b/extensions/picasaweb/data/ui/picasa-web-album-properties.ui
new file mode 100644
index 0000000..d877a1b
--- /dev/null
+++ b/extensions/picasaweb/data/ui/picasa-web-album-properties.ui
@@ -0,0 +1,101 @@
+<?xml version="1.0"?>
+<interface>
+ <requires lib="gtk+" version="2.16"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkVBox" id="album_properties">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="n_rows">2</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Name:</property>
+ <property name="use_underline">True</property>
+ <property name="mnemonic_widget">name_entry</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkEntry" id="name_entry">
+ <property name="width_request">300</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">●</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">_Visibility:</property>
+ <property name="use_underline">True</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkComboBox" id="visibility_combobox">
+ <property name="visible">True</property>
+ <property name="model">visibility_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="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <object class="GtkListStore" id="visibility_liststore">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes">Public</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes">Private</col>
+ </row>
+ </data>
+ </object>
+</interface>
diff --git a/extensions/picasaweb/dlg-export-to-picasaweb.c b/extensions/picasaweb/dlg-export-to-picasaweb.c
index 599ba53..50bceaf 100644
--- a/extensions/picasaweb/dlg-export-to-picasaweb.c
+++ b/extensions/picasaweb/dlg-export-to-picasaweb.c
@@ -29,6 +29,7 @@
#include "dlg-export-to-picasaweb.h"
#include "gth-account-chooser-dialog.h"
#include "gth-account-properties-dialog.h"
+#include "gth-album-properties-dialog.h"
#include "picasa-web-album.h"
#include "picasa-web-service.h"
@@ -81,7 +82,6 @@ static void
export_dialog_destroy_cb (GtkWidget *widget,
DialogData *data)
{
- picasa_web_accounts_save_to_file (data->albums);
if (data->conn != NULL)
gth_task_completed (GTH_TASK (data->conn), NULL);
@@ -93,7 +93,7 @@ export_dialog_destroy_cb (GtkWidget *widget,
g_free (data->password);
g_free (data->email);
_g_string_list_free (data->accounts);
- g_object_unref (data->builder);
+ _g_object_unref (data->builder);
g_free (data);
}
@@ -112,6 +112,7 @@ export_dialog_response_cb (GtkDialog *dialog,
case GTK_RESPONSE_DELETE_EVENT:
case GTK_RESPONSE_CANCEL:
+ picasa_web_accounts_save_to_file (data->accounts);
gtk_widget_destroy (data->dialog);
break;
@@ -125,6 +126,31 @@ export_dialog_response_cb (GtkDialog *dialog,
static void
+update_album_list (DialogData *data)
+{
+ GtkTreeIter iter;
+ GList *scan;
+
+ gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("album_liststore")));
+
+ for (scan = data->albums; scan; scan = scan->next) {
+ PicasaWebAlbum *album = scan->data;
+
+ gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter,
+ ALBUM_DATA_COLUMN, album,
+ ALBUM_TYPE_COLUMN, ITEM_TYPE_ENTRY,
+ ALBUM_ICON_COLUMN, "file-catalog",
+ ALBUM_NAME_COLUMN, album->title,
+ ALBUM_SENSITIVE_COLUMN, TRUE,
+ -1);
+ }
+
+ gtk_widget_set_sensitive (GET_WIDGET ("upload_button"), data->albums != NULL);
+}
+
+
+static void
show_export_dialog (DialogData *data)
{
GtkTreeIter iter;
@@ -168,26 +194,12 @@ show_export_dialog (DialogData *data)
gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")), current_account);
- /* Albums */
-
- gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("album_liststore")));
-
- for (scan = data->albums; scan; scan = scan->next) {
- PicasaWebAlbum *album = scan->data;
-
- gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter);
- gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter,
- ALBUM_DATA_COLUMN, album,
- ALBUM_TYPE_COLUMN, ITEM_TYPE_ENTRY,
- ALBUM_NAME_COLUMN, album->title,
- ALBUM_SENSITIVE_COLUMN, TRUE,
- -1);
- }
-
- gtk_widget_set_sensitive (GET_WIDGET ("upload_button"), data->albums != NULL);
+ update_album_list (data);
/**/
+ gth_task_dialog (GTH_TASK (data->conn), TRUE); /* FIXME */
+
gtk_window_set_transient_for (GTK_WINDOW (data->dialog), GTK_WINDOW (data->browser));
gtk_window_set_modal (GTK_WINDOW (data->dialog), FALSE);
gtk_window_present (GTK_WINDOW (data->dialog));
@@ -206,7 +218,7 @@ list_albums_ready_cb (GObject *source_object,
_g_object_list_unref (data->albums);
data->albums = picasa_web_service_list_albums_finish (picasaweb, result, &error);
if (error != NULL) {
- _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not connect to the server"), &error);
+ _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not get the album list"), &error);
gtk_widget_destroy (data->dialog);
return;
}
@@ -471,6 +483,83 @@ account_combobox_row_separator_func (GtkTreeModel *model,
}
+static void
+create_album_ready_cb (GObject *source_object,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ DialogData *data = user_data;
+ PicasaWebService *picasaweb = PICASA_WEB_SERVICE (source_object);
+ PicasaWebAlbum *album;
+ GError *error = NULL;
+
+ album = picasa_web_service_create_album_finish (picasaweb, result, &error);
+ if (error != NULL) {
+ _gtk_error_dialog_from_gerror_show (GTK_WINDOW (data->browser), _("Could not create the album"), &error);
+ return;
+ }
+
+ data->albums = g_list_append (data->albums, album);
+ update_album_list (data);
+}
+
+
+static void
+new_album_dialog_response_cb (GtkDialog *dialog,
+ int response_id,
+ gpointer user_data)
+{
+ DialogData *data = user_data;
+
+ switch (response_id) {
+ case GTK_RESPONSE_CANCEL:
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ break;
+
+ case GTK_RESPONSE_OK:
+ {
+ PicasaWebAlbum *album;
+
+ album = picasa_web_album_new ();
+ picasa_web_album_set_title (album, gth_album_properties_dialog_get_name (GTH_ALBUM_PROPERTIES_DIALOG (dialog)));
+ album->access = gth_album_properties_dialog_get_access (GTH_ALBUM_PROPERTIES_DIALOG (dialog));
+ picasa_web_service_create_album (data->picasaweb,
+ album,
+ data->cancellable,
+ create_album_ready_cb,
+ data);
+
+ g_object_unref (album);
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+
+static void
+add_album_button_clicked_cb (GtkButton *button,
+ gpointer user_data)
+{
+ DialogData *data = user_data;
+ GtkWidget *dialog;
+
+ dialog = gth_album_properties_dialog_new (NULL, PICASA_WEB_ACCESS_PUBLIC); /* FIXME: use the current catalog/folder name as default value */
+ g_signal_connect (dialog,
+ "response",
+ G_CALLBACK (new_album_dialog_response_cb),
+ data);
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("New Album"));
+ gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (data->browser));
+ gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
+ gtk_window_present (GTK_WINDOW (dialog));
+
+}
+
+
void
dlg_export_to_picasaweb (GthBrowser *browser)
{
@@ -499,9 +588,14 @@ dlg_export_to_picasaweb (GthBrowser *browser)
"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);
+ data->accounts = picasa_web_accounts_load_from_file ();
if (data->accounts != NULL) {
- if (data->accounts->next == NULL) {
+ if (data->accounts->next != NULL) { /* FIXME: == */
data->email = g_strdup ((char *)data->accounts->data);
connect_to_server (data);
}
@@ -514,6 +608,7 @@ dlg_export_to_picasaweb (GthBrowser *browser)
G_CALLBACK (account_chooser_dialog_response_cb),
data);
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Choose Account"));
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (browser));
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
gtk_window_present (GTK_WINDOW (dialog));
diff --git a/extensions/picasaweb/google-connection.c b/extensions/picasaweb/google-connection.c
index db78092..c25f4d3 100644
--- a/extensions/picasaweb/google-connection.c
+++ b/extensions/picasaweb/google-connection.c
@@ -120,7 +120,6 @@ google_connection_init (GoogleConnection *self)
self->priv->challange_url = NULL;
self->priv->cancellable = NULL;
self->priv->result = NULL;
-
}
@@ -231,9 +230,9 @@ get_keys_from_message_body (SoupBuffer *body)
static void
-connect_cb (SoupSession *session,
- SoupMessage *msg,
- gpointer user_data)
+connect_ready_cb (SoupSession *session,
+ SoupMessage *msg,
+ gpointer user_data)
{
GoogleConnection *self = user_data;
SoupBuffer *body;
@@ -305,14 +304,12 @@ connect_cb (SoupSession *session,
self->priv->token = g_strdup (g_hash_table_lookup (keys, "Auth"));
g_simple_async_result_set_op_res_gboolean (self->priv->result, TRUE);
}
- else {
+ else
g_simple_async_result_set_error (self->priv->result,
SOUP_HTTP_ERROR,
msg->status_code,
"%s",
soup_status_get_phrase (msg->status_code));
- g_simple_async_result_complete_in_idle (self->priv->result);
- }
g_simple_async_result_complete_in_idle (self->priv->result);
@@ -373,9 +370,8 @@ google_connection_connect (GoogleConnection *self,
msg = soup_form_request_new_from_hash ("POST",
"https://www.google.com/accounts/ClientLogin",
data_set);
- soup_session_queue_message (self->priv->session, msg, connect_cb, self);
+ soup_session_queue_message (self->priv->session, msg, connect_ready_cb, self);
- g_object_unref (msg);
g_hash_table_destroy (data_set);
}
diff --git a/extensions/picasaweb/google-connection.h b/extensions/picasaweb/google-connection.h
index 948f0d9..0e177bd 100644
--- a/extensions/picasaweb/google-connection.h
+++ b/extensions/picasaweb/google-connection.h
@@ -32,6 +32,7 @@
#include <gthumb.h>
#define GOOGLE_SERVICE_PICASA_WEB_ALBUM "lh2"
+#define ATOM_ENTRY_MIME_TYPE "application/atom+xml; charset=UTF-8; type=entry"
typedef enum {
GOOGLE_CONNECTION_ERROR_BAD_AUTHENTICATION,
diff --git a/extensions/picasaweb/gth-account-chooser-dialog.c b/extensions/picasaweb/gth-account-chooser-dialog.c
index 86deacd..e6e0436 100644
--- a/extensions/picasaweb/gth-account-chooser-dialog.c
+++ b/extensions/picasaweb/gth-account-chooser-dialog.c
@@ -24,12 +24,30 @@
#include <glib/gi18n.h>
#include "gth-account-chooser-dialog.h"
+#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+
+
+typedef enum {
+ ITEM_TYPE_COMMAND,
+ ITEM_TYPE_ENTRY,
+ ITEM_TYPE_SEPARATOR
+} ItemType;
+
+
+enum {
+ ACCOUNT_DATA_COLUMN,
+ ACCOUNT_TYPE_COLUMN,
+ ACCOUNT_NAME_COLUMN,
+ ACCOUNT_ICON_COLUMN,
+ ACCOUNT_SENSITIVE_COLUMN
+};
+
static gpointer parent_class = NULL;
struct _GthAccountChooserDialogPrivate {
- GList *accounts;
+ GtkBuilder *builder;
};
@@ -39,7 +57,8 @@ gth_account_chooser_dialog_finalize (GObject *object)
GthAccountChooserDialog *self;
self = GTH_ACCOUNT_CHOOSER_DIALOG (object);
- _g_string_list_free (self->priv->accounts);
+
+ _g_object_unref (self->priv->builder);
G_OBJECT_CLASS (parent_class)->finalize (object);
}
@@ -61,8 +80,30 @@ gth_account_chooser_dialog_class_init (GthAccountChooserDialogClass *klass)
static void
gth_account_chooser_dialog_init (GthAccountChooserDialog *self)
{
+ GtkWidget *content;
+
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_ACCOUNT_CHOOSER_DIALOG, GthAccountChooserDialogPrivate);
- self->priv->accounts = NULL;
+ self->priv->builder = _gtk_builder_new_from_file ("picasa-web-account-chooser.ui", "picasaweb");
+
+ gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 5);
+
+ content = _gtk_builder_get_widget (self->priv->builder, "account_chooser");
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0);
+
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_NEW,
+ GTH_ACCOUNT_CHOOSER_RESPONSE_NEW);
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL);
+ gtk_dialog_add_button (GTK_DIALOG (self),
+ GTK_STOCK_OK,
+ GTK_RESPONSE_OK);
+ gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
}
@@ -94,13 +135,38 @@ gth_account_chooser_dialog_get_type (void)
}
+static void
+gth_account_chooser_dialog_construct (GthAccountChooserDialog *self,
+ GList *accounts)
+{
+ GtkTreeIter iter;
+ GList *scan;
+
+ gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("account_liststore")));
+
+ for (scan = accounts; scan; scan = scan->next) {
+ char *account = scan->data;
+
+ gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("account_liststore")), &iter);
+ gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("account_liststore")), &iter,
+ ACCOUNT_DATA_COLUMN, account,
+ ACCOUNT_TYPE_COLUMN, ITEM_TYPE_ENTRY,
+ ACCOUNT_NAME_COLUMN, account,
+ ACCOUNT_SENSITIVE_COLUMN, TRUE,
+ -1);
+ }
+
+ gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")), 0);
+}
+
+
GtkWidget *
gth_account_chooser_dialog_new (GList *accounts)
{
GthAccountChooserDialog *self;
self = g_object_new (GTH_TYPE_ACCOUNT_CHOOSER_DIALOG, NULL);
- self->priv->accounts = _g_string_list_dup (accounts);
+ gth_account_chooser_dialog_construct (self, accounts);
return (GtkWidget *) self;
}
diff --git a/extensions/picasaweb/gth-account-properties-dialog.c b/extensions/picasaweb/gth-account-properties-dialog.c
index 0ed1924..bb26ff9 100644
--- a/extensions/picasaweb/gth-account-properties-dialog.c
+++ b/extensions/picasaweb/gth-account-properties-dialog.c
@@ -33,9 +33,6 @@ static gpointer parent_class = NULL;
struct _GthAccountPropertiesDialogPrivate {
GtkBuilder *builder;
- char *email;
- char *password;
- char *challange_url;
GCancellable *cancellable;
};
@@ -47,9 +44,6 @@ gth_account_properties_dialog_finalize (GObject *object)
self = GTH_ACCOUNT_PROPERTIES_DIALOG (object);
_g_object_unref (self->priv->builder);
- g_free (self->priv->email);
- g_free (self->priv->password);
- g_free (self->priv->challange_url);
g_object_unref (self->priv->cancellable);
G_OBJECT_CLASS (parent_class)->finalize (object);
@@ -75,9 +69,6 @@ gth_account_properties_dialog_init (GthAccountPropertiesDialog *self)
GtkWidget *content;
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_ACCOUNT_PROPERTIES_DIALOG, GthAccountPropertiesDialogPrivate);
- self->priv->email = NULL;
- self->priv->password = NULL;
- self->priv->challange_url = NULL;
self->priv->cancellable = g_cancellable_new ();
self->priv->builder = _gtk_builder_new_from_file ("picasa-web-account-properties.ui", "picasaweb");
@@ -162,22 +153,16 @@ gth_account_properties_dialog_construct (GthAccountPropertiesDialog *self,
const char *password,
const char *challange_url)
{
- if (email != NULL) {
- self->priv->email = g_strdup (email);
- gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("email_entry")), self->priv->email);
- }
+ if (email != NULL)
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("email_entry")), email);
- if (password != NULL) {
- self->priv->password = g_strdup (password);
- gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("password_entry")), self->priv->password);
- }
+ if (password != NULL)
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("password_entry")), password);
if (challange_url != NULL) {
char *url;
GFile *file;
- self->priv->challange_url = g_strdup (challange_url);
-
url = g_strconcat ("http://www.google.com/accounts/", challange_url, NULL);
file = g_file_new_for_uri (url);
g_load_file_async (file,
diff --git a/extensions/picasaweb/gth-album-properties-dialog.c b/extensions/picasaweb/gth-album-properties-dialog.c
new file mode 100644
index 0000000..418a710
--- /dev/null
+++ b/extensions/picasaweb/gth-album-properties-dialog.c
@@ -0,0 +1,155 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include "gth-album-properties-dialog.h"
+
+
+#define GET_WIDGET(x) (_gtk_builder_get_widget (self->priv->builder, (x)))
+
+
+static gpointer parent_class = NULL;
+
+
+struct _GthAlbumPropertiesDialogPrivate {
+ GtkBuilder *builder;
+};
+
+
+static void
+gth_album_properties_dialog_finalize (GObject *object)
+{
+ GthAlbumPropertiesDialog *self;
+
+ self = GTH_ALBUM_PROPERTIES_DIALOG (object);
+ _g_object_unref (self->priv->builder);
+
+ G_OBJECT_CLASS (parent_class)->finalize (object);
+}
+
+
+static void
+gth_album_properties_dialog_class_init (GthAlbumPropertiesDialogClass *klass)
+{
+ GObjectClass *object_class;
+
+ parent_class = g_type_class_peek_parent (klass);
+ g_type_class_add_private (klass, sizeof (GthAlbumPropertiesDialogPrivate));
+
+ object_class = (GObjectClass*) klass;
+ object_class->finalize = gth_album_properties_dialog_finalize;
+}
+
+
+static void
+gth_album_properties_dialog_init (GthAlbumPropertiesDialog *self)
+{
+ GtkWidget *content;
+
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_ALBUM_PROPERTIES_DIALOG, GthAlbumPropertiesDialogPrivate);
+ self->priv->builder = _gtk_builder_new_from_file ("picasa-web-album-properties.ui", "picasaweb");
+
+ gtk_window_set_resizable (GTK_WINDOW (self), FALSE);
+ gtk_dialog_set_has_separator (GTK_DIALOG (self), FALSE);
+ gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5);
+ gtk_container_set_border_width (GTK_CONTAINER (self), 5);
+
+ content = _gtk_builder_get_widget (self->priv->builder, "album_properties");
+ gtk_container_set_border_width (GTK_CONTAINER (content), 5);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0);
+
+ gtk_dialog_add_buttons (GTK_DIALOG (self),
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL);
+ gtk_dialog_set_default_response (GTK_DIALOG (self), GTK_RESPONSE_OK);
+}
+
+
+GType
+gth_album_properties_dialog_get_type (void)
+{
+ static GType type = 0;
+
+ if (type == 0) {
+ static const GTypeInfo g_define_type_info = {
+ sizeof (GthAlbumPropertiesDialogClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) gth_album_properties_dialog_class_init,
+ (GClassFinalizeFunc) NULL,
+ NULL,
+ sizeof (GthAlbumPropertiesDialog),
+ 0,
+ (GInstanceInitFunc) gth_album_properties_dialog_init,
+ NULL
+ };
+ type = g_type_register_static (GTK_TYPE_DIALOG,
+ "GthAlbumPropertiesDialog",
+ &g_define_type_info,
+ 0);
+ }
+
+ return type;
+}
+
+
+static void
+gth_album_properties_dialog_construct (GthAlbumPropertiesDialog *self,
+ const char *name,
+ PicasaWebAccess access)
+{
+ if (name != NULL)
+ gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("name_entry")), name);
+ gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("visibility_combobox")), (access == PICASA_WEB_ACCESS_PUBLIC) ? 0 : 1);
+}
+
+
+GtkWidget *
+gth_album_properties_dialog_new (const char *name,
+ PicasaWebAccess access)
+{
+ GthAlbumPropertiesDialog *self;
+
+ self = g_object_new (GTH_TYPE_ALBUM_PROPERTIES_DIALOG, NULL);
+ gth_album_properties_dialog_construct (self, name, access);
+
+ return (GtkWidget *) self;
+}
+
+
+const char *
+gth_album_properties_dialog_get_name (GthAlbumPropertiesDialog *self)
+{
+ return gtk_entry_get_text (GTK_ENTRY (GET_WIDGET ("name_entry")));
+}
+
+
+PicasaWebAccess
+gth_album_properties_dialog_get_access (GthAlbumPropertiesDialog *self)
+{
+ if (gtk_combo_box_get_active (GTK_COMBO_BOX (GET_WIDGET ("visibility_combobox"))) == 0)
+ return PICASA_WEB_ACCESS_PUBLIC;
+ else
+ return PICASA_WEB_ACCESS_PRIVATE;
+}
diff --git a/extensions/picasaweb/gth-album-properties-dialog.h b/extensions/picasaweb/gth-album-properties-dialog.h
new file mode 100644
index 0000000..420367c
--- /dev/null
+++ b/extensions/picasaweb/gth-album-properties-dialog.h
@@ -0,0 +1,60 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2010 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, write to the Free Software
+ * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef GTH_ALBUM_PROPERTIES_DIALOG_H
+#define GTH_ALBUM_PROPERTIES_DIALOG_H
+
+#include <gtk/gtk.h>
+#include <gthumb.h>
+#include "picasa-web-album.h"
+
+G_BEGIN_DECLS
+
+#define GTH_TYPE_ALBUM_PROPERTIES_DIALOG (gth_album_properties_dialog_get_type ())
+#define GTH_ALBUM_PROPERTIES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_ALBUM_PROPERTIES_DIALOG, GthAlbumPropertiesDialog))
+#define GTH_ALBUM_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTH_TYPE_ALBUM_PROPERTIES_DIALOG, GthAlbumPropertiesDialogClass))
+#define GTH_IS_ALBUM_PROPERTIES_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTH_TYPE_ALBUM_PROPERTIES_DIALOG))
+#define GTH_IS_ALBUM_PROPERTIES_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTH_TYPE_ALBUM_PROPERTIES_DIALOG))
+#define GTH_ALBUM_PROPERTIES_DIALOG_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GTH_TYPE_ALBUM_PROPERTIES_DIALOG, GthAlbumPropertiesDialogClass))
+
+typedef struct _GthAlbumPropertiesDialog GthAlbumPropertiesDialog;
+typedef struct _GthAlbumPropertiesDialogClass GthAlbumPropertiesDialogClass;
+typedef struct _GthAlbumPropertiesDialogPrivate GthAlbumPropertiesDialogPrivate;
+
+struct _GthAlbumPropertiesDialog {
+ GtkDialog parent_instance;
+ GthAlbumPropertiesDialogPrivate *priv;
+};
+
+struct _GthAlbumPropertiesDialogClass {
+ GtkDialogClass parent_class;
+};
+
+GType gth_album_properties_dialog_get_type (void);
+GtkWidget * gth_album_properties_dialog_new (const char *name,
+ PicasaWebAccess access);
+const char * gth_album_properties_dialog_get_name (GthAlbumPropertiesDialog *self);
+PicasaWebAccess gth_album_properties_dialog_get_access (GthAlbumPropertiesDialog *self);
+
+G_END_DECLS
+
+#endif /* GTH_ALBUM_PROPERTIES_DIALOG_H */
diff --git a/extensions/picasaweb/picasa-web-service.c b/extensions/picasaweb/picasa-web-service.c
index 4f23058..de8a47d 100644
--- a/extensions/picasaweb/picasa-web-service.c
+++ b/extensions/picasaweb/picasa-web-service.c
@@ -213,7 +213,6 @@ picasa_web_service_list_albums (PicasaWebService *self,
list_albums_ready_cb,
self);
- g_object_unref (msg);
g_free (url);
}
@@ -302,7 +301,7 @@ picasa_web_service_create_album (PicasaWebService *self,
url = g_strconcat ("http://picasaweb.google.com/data/feed/api/user/", self->priv->user_id, NULL);
msg = soup_message_new ("POST", url);
- soup_message_set_response (msg, "text/xml", SOUP_MEMORY_TAKE, buffer, len);
+ soup_message_set_request (msg, ATOM_ENTRY_MIME_TYPE, SOUP_MEMORY_TAKE, buffer, len);
google_connection_send_message (self->priv->conn,
msg,
cancellable,
@@ -312,7 +311,6 @@ picasa_web_service_create_album (PicasaWebService *self,
create_album_ready_cb,
self);
- g_object_unref (msg);
g_free (url);
g_object_unref (doc);
}
@@ -405,7 +403,7 @@ picasa_web_accounts_save_to_file (GList *accounts)
filename = gth_user_dir_get_file (GTH_DIR_CONFIG, GTHUMB_DIR, "accounts", "picasaweb.xml", NULL);
file = g_file_new_for_path (filename);
buffer = dom_document_dump (doc, &len);
- g_write_file (file, FALSE, 0, buffer, len, NULL, NULL);
+ g_write_file (file, FALSE, G_FILE_CREATE_PRIVATE|G_FILE_CREATE_REPLACE_DESTINATION, buffer, len, NULL, NULL);
g_free (buffer);
g_object_unref (file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]