Wishlist Solution: Dbl Clk in addressbook



>> Description:
>> It'd be nice to be able to simply double-click each person I'd like to
>> mail to, rather than clicking them once, and then clicking the arrow... :)

I have added this feature to the address book.  You can now double click an
addres in the book_clist and add_clist windows to move the address to the other
list.  I have also re-oriented the "Cancel" and "Okay" buttons to.  I have
included the diff results below.

? addressbook.patch
? src/.libs
Index: src/address-book.c
===================================================================
RCS file: /cvs/gnome/balsa/src/address-book.c,v
retrieving revision 1.27
diff -u -r1.27 address-book.c
--- src/address-book.c	2000/09/15 15:26:18	1.27
+++ src/address-book.c	2000/09/26 07:48:53
@@ -40,6 +40,7 @@
 static gint ab_okay_cb(GtkWidget * widget, gpointer data);
 static void ab_clear_clist(GtkCList * clist);
 static void ab_switch_cb(GtkWidget * widget, gpointer data);
+static void ab_select_row_event(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data);
 /*#define AB_ADD_CB_USED*/
 #ifdef AB_ADD_CB_USED
 static gint ab_add_cb(GtkWidget * widget, gpointer data);
@@ -151,6 +152,38 @@
 }
 
 
+static void 
+ab_select_row_event(GtkWidget * widget, gint row, gint column, GdkEventButton *event, gpointer data)
+{
+	fprintf (stderr, "Row %d, Column %d\n", row, column); 
+
+	if ( GTK_CLIST(data) &&
+		(event->type==GDK_2BUTTON_PRESS || event->type==GDK_3BUTTON_PRESS) ) 
+	{
+		/* ensure that the list item clicked is only item selected */
+	    	/* CLEANUP: Could probably combine this code with code in 
+		 * ab_switch_cb into a function call */
+		GtkWidget      *from = GTK_WIDGET(data);
+		GtkWidget      *to = (data == book_clist) ? add_clist : book_clist;
+		gint 		num;
+		gchar           *listdata[2];
+		LibBalsaAddress *addy_data;
+
+		addy_data = LIBBALSA_ADDRESS(gtk_clist_get_row_data(GTK_CLIST(from), row));
+
+		listdata[0] = addy_data->id; 
+		if ( addy_data->address_list )
+			listdata[1] = addy_data->address_list->data;
+		else    
+			listdata[1] = "";
+
+		gtk_clist_remove(GTK_CLIST(from), row);
+
+		num = gtk_clist_append(GTK_CLIST(to), listdata);
+		gtk_clist_set_row_data(GTK_CLIST(to), num, (gpointer)addy_data);
+	}
+}
+
 static void
 ab_switch_cb(GtkWidget * widget, gpointer data)
 {
@@ -344,7 +377,7 @@
 	titles[1]=_(titles[1]);
 #endif
 
-	dialog = gnome_dialog_new(_("Address Book"), GNOME_STOCK_BUTTON_CANCEL, GNOME_STOCK_BUTTON_OK, NULL); 
+	dialog = gnome_dialog_new(_("Address Book"), GNOME_STOCK_BUTTON_OK, GNOME_STOCK_BUTTON_CANCEL, NULL); 
 
         /* If we have something in the data, then the addressbook was opened
          * from a message window */
@@ -357,8 +390,8 @@
                 gnome_dialog_set_parent (GNOME_DIALOG (dialog), 
                                          GTK_WINDOW (widget->parent->parent) );
 
-	gnome_dialog_button_connect(GNOME_DIALOG(dialog), 0, GTK_SIGNAL_FUNC(ab_cancel_cb), (gpointer) dialog); 
-	gnome_dialog_button_connect(GNOME_DIALOG(dialog), 1, GTK_SIGNAL_FUNC(ab_okay_cb), (gpointer) dialog); 
+	gnome_dialog_button_connect(GNOME_DIALOG(dialog), 0, GTK_SIGNAL_FUNC(ab_okay_cb), (gpointer) dialog); 
+	gnome_dialog_button_connect(GNOME_DIALOG(dialog), 1, GTK_SIGNAL_FUNC(ab_cancel_cb), (gpointer) dialog); 
 	vbox = GNOME_DIALOG(dialog)->vbox; 
 
 	book_clist = gtk_clist_new_with_titles(2, titles); 
@@ -418,12 +451,15 @@
 	gtk_box_pack_start(GTK_BOX(box2), find_entry, FALSE, FALSE, 0); 
 	
 	scrolled_window = gtk_scrolled_window_new(NULL, NULL); 
+
 	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_window), 
 				       GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); 
 	gtk_box_pack_start(GTK_BOX(box2), scrolled_window, TRUE, TRUE, 0); 
 	gtk_container_add(GTK_CONTAINER(scrolled_window), book_clist); 
 	gtk_widget_set_usize(scrolled_window, 300, 250);
 	
+	gtk_signal_connect(GTK_OBJECT(book_clist), "select_row", GTK_SIGNAL_FUNC(ab_select_row_event), (gpointer) book_clist);
+
 	/* 
 	 * Only display this part of * the window when we're adding to a composing 
 	 * message. 
@@ -453,6 +489,8 @@
 		gtk_clist_set_selection_mode(GTK_CLIST(add_clist), GTK_SELECTION_MULTIPLE); 
 		gtk_clist_column_titles_passive(GTK_CLIST(add_clist)); 
 		gtk_widget_set_usize(scrolled_window, 300, 250); 
+
+		gtk_signal_connect(GTK_OBJECT(add_clist), "select_row", GTK_SIGNAL_FUNC(ab_select_row_event), (gpointer) add_clist);
 	} 
 
 	hbox = gtk_hbutton_box_new(); 


================================
  James A. Laska
  email: jal233@psu.edu
================================




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