[gthumb: 10/22] [picasaweb] allow to change account with the account combobox



commit e78cabf97af5f089261bdaaf9ec6a3f5ff90e067
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Jan 26 17:42:23 2010 +0100

    [picasaweb] allow to change account with the account combobox

 .../picasaweb/data/ui/export-to-picasaweb.ui       |    9 +--
 extensions/picasaweb/dlg-export-to-picasaweb.c     |   76 ++++++++-----------
 2 files changed, 36 insertions(+), 49 deletions(-)
---
diff --git a/extensions/picasaweb/data/ui/export-to-picasaweb.ui b/extensions/picasaweb/data/ui/export-to-picasaweb.ui
index fc061b3..9f2972c 100644
--- a/extensions/picasaweb/data/ui/export-to-picasaweb.ui
+++ b/extensions/picasaweb/data/ui/export-to-picasaweb.ui
@@ -20,11 +20,9 @@
     <columns>
       <!-- column-name email -->
       <column type="gchararray"/>
-      <!-- column-name type -->
-      <column type="gint"/>
       <!-- column-name name -->
       <column type="gchararray"/>
-      <!-- column-name icon name -->
+      <!-- column-name icon -->
       <column type="gchararray"/>
     </columns>
   </object>
@@ -83,13 +81,13 @@
                             <child>
                               <object class="GtkCellRendererPixbuf" id="cellrenderertext1"/>
                               <attributes>
-                                <attribute name="icon-name">3</attribute>
+                                <attribute name="icon-name">2</attribute>
                               </attributes>
                             </child>
                             <child>
                               <object class="GtkCellRendererText" id="cellrenderertext3"/>
                               <attributes>
-                                <attribute name="text">2</attribute>
+                                <attribute name="text">1</attribute>
                               </attributes>
                             </child>
                           </object>
@@ -111,6 +109,7 @@
                             </child>
                           </object>
                           <packing>
+                            <property name="expand">False</property>
                             <property name="position">1</property>
                           </packing>
                         </child>
diff --git a/extensions/picasaweb/dlg-export-to-picasaweb.c b/extensions/picasaweb/dlg-export-to-picasaweb.c
index 9ed54c9..55d57b0 100644
--- a/extensions/picasaweb/dlg-export-to-picasaweb.c
+++ b/extensions/picasaweb/dlg-export-to-picasaweb.c
@@ -39,16 +39,8 @@
 #define GET_WIDGET(x) (_gtk_builder_get_widget (data->builder, (x)))
 
 
-typedef enum {
-	ITEM_TYPE_COMMAND,
-	ITEM_TYPE_ENTRY,
-	ITEM_TYPE_SEPARATOR
-} ItemType;
-
-
 enum {
 	ACCOUNT_EMAIL_COLUMN,
-	ACCOUNT_TYPE_COLUMN,
 	ACCOUNT_NAME_COLUMN,
 	ACCOUNT_ICON_COLUMN
 };
@@ -147,26 +139,10 @@ update_account_list (DialogData *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_EMAIL_COLUMN, account,
-				    ACCOUNT_TYPE_COLUMN, ITEM_TYPE_ENTRY,
 				    ACCOUNT_NAME_COLUMN, account,
 				    -1);
 	}
 
-	/* FIXME
-	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_TYPE_COLUMN, ITEM_TYPE_SEPARATOR,
-			    -1);
-
-	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_EMAIL_COLUMN, NULL,
-			    ACCOUNT_TYPE_COLUMN, ITEM_TYPE_COMMAND,
-			    ACCOUNT_ICON_COLUMN, GTK_STOCK_EDIT,
-			    ACCOUNT_NAME_COLUMN, _("Edit Accounts..."),
-			    -1);
-	*/
-
 	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")), current_account);
 }
 
@@ -533,19 +509,6 @@ account_chooser_dialog_response_cb (GtkDialog *dialog,
 }
 
 
-static gboolean
-account_combobox_row_separator_func (GtkTreeModel *model,
-				     GtkTreeIter  *iter,
-				     gpointer      data)
-{
-	int item_type;
-
-	gtk_tree_model_get (model, iter, ACCOUNT_TYPE_COLUMN, &item_type, -1);
-
-	return item_type == ITEM_TYPE_SEPARATOR;
-}
-
-
 static void
 create_album_ready_cb (GObject      *source_object,
 		       GAsyncResult *result,
@@ -629,7 +592,6 @@ auto_select_account (DialogData *data)
 	gtk_widget_hide (data->dialog);
 
 	if (data->accounts != NULL) {
-		/* FIXME: remove comment when done
 		if (data->email != NULL) {
 			connect_to_server (data);
 		}
@@ -637,7 +599,7 @@ auto_select_account (DialogData *data)
 			data->email = g_strdup ((char *)data->accounts->data);
 			connect_to_server (data);
 		}
-		else {*/
+		else {
 			GtkWidget *dialog;
 
 			dialog = picasa_account_chooser_dialog_new (data->accounts, data->email);
@@ -650,7 +612,7 @@ auto_select_account (DialogData *data)
 			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));
-		/*}*/
+		}
 	}
 	else
 		account_properties_dialog (data, NULL);
@@ -711,6 +673,32 @@ edit_accounts_button_clicked_cb (GtkButton *button,
 
 
 static void
+account_combobox_changed_cb (GtkComboBox *widget,
+			     gpointer     user_data)
+{
+	DialogData  *data = user_data;
+	GtkTreeIter  iter;
+	char        *email;
+
+	if (! gtk_combo_box_get_active_iter (widget, &iter))
+		return;
+
+	gtk_tree_model_get (gtk_combo_box_get_model (widget),
+			    &iter,
+			    ACCOUNT_EMAIL_COLUMN, &email,
+			    -1);
+
+	if (g_strcmp0 (email, data->email) != 0) {
+		g_free (data->email);
+		data->email = email;
+		auto_select_account (data);
+	}
+	else
+		g_free (email);
+}
+
+
+static void
 albums_treeview_selection_changed_cb (GtkTreeSelection *treeselection,
 				      gpointer          user_data)
 {
@@ -736,10 +724,6 @@ dlg_export_to_picasaweb (GthBrowser *browser)
 
 	/* Set the widget data */
 
-	gtk_combo_box_set_row_separator_func (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")),
-					      account_combobox_row_separator_func,
-					      data,
-					      NULL);
 	gtk_widget_set_sensitive (GET_WIDGET ("upload_button"), FALSE);
 
 	/* Set the signals handlers. */
@@ -760,6 +744,10 @@ dlg_export_to_picasaweb (GthBrowser *browser)
 			  "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);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]