[Evolution-hackers] IM entry fields patch



Hello.

I'm Christian Hammond, from the Gaim project. I'm working on one of
the gaim<->evolution bounties, and have a couple of patches for your
review and, hopefully, acceptance into CVS.

The first patch adds the ability to set data types of
E_CONTACT_FIELD_TYPE_LIST in evolution-data-server.

The second patch adds fields to the Contact Editor window in evolution
so that a person's AIM, ICQ, Yahoo, MSN, and Jabber accounts can be
set.

Let me know if you'd like me to make any changes.

Thank you.

Christian

-- 
Christian Hammond         <>  The GNUpdate Project
chipx86 gnupdate org      <>  http://www.gnupdate.org/
   A seminar on time travel will be held two weeks ago.
Index: addressbook/libebook/e-contact.c
===================================================================
RCS file: /cvs/gnome/evolution-data-server/addressbook/libebook/e-contact.c,v
retrieving revision 1.3
diff -u -r1.3 e-contact.c
--- addressbook/libebook/e-contact.c	10 Nov 2003 17:18:56 -0000	1.3
+++ addressbook/libebook/e-contact.c	23 Nov 2003 22:53:26 -0000
@@ -761,6 +761,25 @@
 
 		info->struct_setter (contact, attr, data);
 	}
+	else if (info->t & E_CONTACT_FIELD_TYPE_LIST) {
+		EVCardAttribute *attr;
+		GList *values, *l;
+
+		attr = e_contact_get_first_attr (contact, info->vcard_field_name);
+
+		if (attr) {
+			e_vcard_attribute_remove_values (attr);
+		}
+		else {
+			attr = e_vcard_attribute_new (NULL, info->vcard_field_name);
+			e_vcard_add_attribute (E_VCARD (contact), attr);
+		}
+
+		values = g_value_get_pointer (value);
+
+		for (l = values; l != NULL; l = l->next)
+			e_vcard_attribute_add_value (attr, l->data);
+	}
 	else {
 		g_warning ("unhandled attribute `%s'", info->vcard_field_name);
 	}
Index: addressbook/gui/contact-editor/contact-editor.glade
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/contact-editor.glade,v
retrieving revision 1.41
diff -u -r1.41 contact-editor.glade
--- addressbook/gui/contact-editor/contact-editor.glade	21 Oct 2003 18:48:44 -0000	1.41
+++ addressbook/gui/contact-editor/contact-editor.glade	23 Nov 2003 22:51:36 -0000
@@ -328,7 +328,7 @@
 	    <widget class="GtkTable" id="table-contact-editor-general">
 	      <property name="border_width">6</property>
 	      <property name="visible">True</property>
-	      <property name="n_rows">14</property>
+	      <property name="n_rows">15</property>
 	      <property name="n_columns">8</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">6</property>
@@ -466,8 +466,8 @@
 		<packing>
 		  <property name="left_attach">2</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -591,8 +591,8 @@
 		<packing>
 		  <property name="left_attach">4</property>
 		  <property name="right_attach">8</property>
-		  <property name="top_attach">4</property>
-		  <property name="bottom_attach">5</property>
+		  <property name="top_attach">5</property>
+		  <property name="bottom_attach">6</property>
 		  <property name="y_padding">2</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -716,8 +716,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
@@ -729,8 +729,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">4</property>
-		  <property name="bottom_attach">5</property>
+		  <property name="top_attach">5</property>
+		  <property name="bottom_attach">6</property>
 		  <property name="y_padding">2</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -804,8 +804,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">7</property>
-		  <property name="bottom_attach">8</property>
+		  <property name="top_attach">8</property>
+		  <property name="bottom_attach">9</property>
 		  <property name="y_padding">2</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -835,8 +835,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">6</property>
-		  <property name="bottom_attach">7</property>
+		  <property name="top_attach">7</property>
+		  <property name="bottom_attach">8</property>
 		  <property name="x_options">expand|shrink|fill</property>
 		  <property name="y_options">shrink|fill</property>
 		</packing>
@@ -872,8 +872,8 @@
 		<packing>
 		  <property name="left_attach">6</property>
 		  <property name="right_attach">7</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1027,8 +1027,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">2</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1058,8 +1058,8 @@
 		<packing>
 		  <property name="left_attach">5</property>
 		  <property name="right_attach">6</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">6</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">7</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1088,8 +1088,8 @@
 		<packing>
 		  <property name="left_attach">7</property>
 		  <property name="right_attach">8</property>
-		  <property name="top_attach">9</property>
-		  <property name="bottom_attach">10</property>
+		  <property name="top_attach">10</property>
+		  <property name="bottom_attach">11</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
@@ -1101,8 +1101,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">11</property>
-		  <property name="bottom_attach">12</property>
+		  <property name="top_attach">12</property>
+		  <property name="bottom_attach">13</property>
 		  <property name="y_padding">2</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1115,8 +1115,8 @@
 		<packing>
 		  <property name="left_attach">4</property>
 		  <property name="right_attach">8</property>
-		  <property name="top_attach">11</property>
-		  <property name="bottom_attach">12</property>
+		  <property name="top_attach">12</property>
+		  <property name="bottom_attach">13</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
@@ -1153,46 +1153,6 @@
 	      </child>
 
 	      <child>
-		<widget class="Custom" id="custom1">
-		  <property name="visible">True</property>
-		  <property name="creation_function">e_create_image_widget</property>
-		  <property name="string1">malehead.png</property>
-		  <property name="string2"></property>
-		  <property name="int1">0</property>
-		  <property name="int2">0</property>
-		  <property name="last_modification_time">Thu, 18 May 2000 12:19:47 GMT</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">4</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options">fill</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="Custom" id="custom2">
-		  <property name="visible">True</property>
-		  <property name="creation_function">e_create_image_widget</property>
-		  <property name="string1">cellphone.png</property>
-		  <property name="string2"></property>
-		  <property name="int1">0</property>
-		  <property name="int2">0</property>
-		  <property name="last_modification_time">Thu, 18 May 2000 12:20:02 GMT</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">4</property>
-		  <property name="right_attach">5</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">4</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options">fill</property>
-		</packing>
-	      </child>
-
-	      <child>
 		<widget class="Custom" id="custom3">
 		  <property name="visible">True</property>
 		  <property name="creation_function">e_create_image_widget</property>
@@ -1205,8 +1165,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">7</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">8</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1225,8 +1185,8 @@
 		<packing>
 		  <property name="left_attach">4</property>
 		  <property name="right_attach">5</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">10</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">11</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1245,8 +1205,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">8</property>
-		  <property name="bottom_attach">10</property>
+		  <property name="top_attach">9</property>
+		  <property name="bottom_attach">11</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1288,8 +1248,8 @@
 		<packing>
 		  <property name="left_attach">5</property>
 		  <property name="right_attach">7</property>
-		  <property name="top_attach">6</property>
-		  <property name="bottom_attach">7</property>
+		  <property name="top_attach">7</property>
+		  <property name="bottom_attach">8</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1338,8 +1298,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">8</property>
-		  <property name="bottom_attach">9</property>
+		  <property name="top_attach">9</property>
+		  <property name="bottom_attach">10</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -1366,8 +1326,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">12</property>
-		  <property name="bottom_attach">13</property>
+		  <property name="top_attach">13</property>
+		  <property name="bottom_attach">14</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1386,8 +1346,8 @@
 		<packing>
 		  <property name="left_attach">0</property>
 		  <property name="right_attach">1</property>
-		  <property name="top_attach">12</property>
-		  <property name="bottom_attach">14</property>
+		  <property name="top_attach">13</property>
+		  <property name="bottom_attach">15</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1418,8 +1378,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">12</property>
-		  <property name="bottom_attach">13</property>
+		  <property name="top_attach">13</property>
+		  <property name="bottom_attach">14</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1455,8 +1415,8 @@
 		<packing>
 		  <property name="left_attach">7</property>
 		  <property name="right_attach">8</property>
-		  <property name="top_attach">5</property>
-		  <property name="bottom_attach">9</property>
+		  <property name="top_attach">6</property>
+		  <property name="bottom_attach">10</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
@@ -1472,8 +1432,8 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">8</property>
-		  <property name="bottom_attach">9</property>
+		  <property name="top_attach">9</property>
+		  <property name="bottom_attach">10</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
@@ -1497,8 +1457,8 @@
 		<packing>
 		  <property name="left_attach">1</property>
 		  <property name="right_attach">3</property>
-		  <property name="top_attach">9</property>
-		  <property name="bottom_attach">10</property>
+		  <property name="top_attach">10</property>
+		  <property name="bottom_attach">11</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options"></property>
 		</packing>
@@ -1515,12 +1475,124 @@
 		<packing>
 		  <property name="left_attach">3</property>
 		  <property name="right_attach">4</property>
-		  <property name="top_attach">9</property>
-		  <property name="bottom_attach">10</property>
+		  <property name="top_attach">10</property>
+		  <property name="bottom_attach">11</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options">fill</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="Custom" id="custom2">
+		  <property name="visible">True</property>
+		  <property name="creation_function">e_create_image_widget</property>
+		  <property name="string1">cellphone.png</property>
+		  <property name="string2"></property>
+		  <property name="int1">0</property>
+		  <property name="int2">0</property>
+		  <property name="last_modification_time">Thu, 18 May 2000 12:20:02 GMT</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">4</property>
+		  <property name="right_attach">5</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">5</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
+
+	      <child>
+		<widget class="Custom" id="custom1">
+		  <property name="visible">True</property>
+		  <property name="creation_function">e_create_image_widget</property>
+		  <property name="string1">malehead.png</property>
+		  <property name="string2"></property>
+		  <property name="int1">0</property>
+		  <property name="int2">0</property>
+		  <property name="last_modification_time">Thu, 18 May 2000 12:19:47 GMT</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">0</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options">fill</property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkLabel" id="label-im1">
+		  <property name="visible">True</property>
+		  <property name="label" translatable="yes">A_IM account:</property>
+		  <property name="use_underline">True</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_LEFT</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">1</property>
+		  <property name="yalign">0.5</property>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">5</property>
+		  <property name="right_attach">6</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkButton" id="button-im1">
+		  <property name="visible">True</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+
+		  <child>
+		    <widget class="GtkArrow" id="arrow7">
+		      <property name="visible">True</property>
+		      <property name="arrow_type">GTK_ARROW_DOWN</property>
+		      <property name="shadow_type">GTK_SHADOW_OUT</property>
+		      <property name="xalign">0.5</property>
+		      <property name="yalign">0.5</property>
+		      <property name="xpad">0</property>
+		      <property name="ypad">0</property>
+		    </widget>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">6</property>
+		  <property name="right_attach">7</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="x_options">fill</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkEntry" id="entry-im1">
+		  <property name="visible">True</property>
+		  <property name="can_focus">True</property>
+		  <property name="editable">True</property>
+		  <property name="visibility">True</property>
+		  <property name="max_length">0</property>
+		  <property name="text" translatable="yes"></property>
+		  <property name="has_frame">True</property>
+		  <property name="invisible_char" translatable="yes">*</property>
+		  <property name="activates_default">False</property>
+		</widget>
+		<packing>
+		  <property name="left_attach">7</property>
+		  <property name="right_attach">8</property>
+		  <property name="top_attach">4</property>
+		  <property name="bottom_attach">5</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
 	    </widget>
 	    <packing>
 	      <property name="tab_expand">False</property>
Index: addressbook/gui/contact-editor/e-contact-editor.c
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.c,v
retrieving revision 1.153
diff -u -r1.153 e-contact-editor.c
--- addressbook/gui/contact-editor/e-contact-editor.c	21 Oct 2003 18:48:45 -0000	1.153
+++ addressbook/gui/contact-editor/e-contact-editor.c	23 Nov 2003 22:51:37 -0000
@@ -76,6 +76,7 @@
 static void e_contact_editor_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
 static void e_contact_editor_dispose (GObject *object);
 
+static void _im_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
 static void _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
 static void _phone_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
 static void _address_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor);
@@ -136,6 +137,22 @@
 	E_CONTACT_PHONE_TTYTDD,
 };
 
+static EContactField ims[] = {
+	E_CONTACT_IM_AIM,
+	E_CONTACT_IM_JABBER,
+	E_CONTACT_IM_YAHOO,
+	E_CONTACT_IM_MSN,
+	E_CONTACT_IM_ICQ
+};
+
+static const char *im_labels[] = {
+	N_("AIM account"),
+	N_("Jabber account"),
+	N_("Yahoo account"),
+	N_("MSN account"),
+	N_("ICQ account")
+};
+
 static EContactField emails[] = {
 	E_CONTACT_EMAIL_1,
 	E_CONTACT_EMAIL_2,
@@ -279,6 +296,7 @@
 	connect_arrow_button_signal(editor, "button-phone3", G_CALLBACK (_phone_arrow_pressed));
 	connect_arrow_button_signal(editor, "button-phone4", G_CALLBACK (_phone_arrow_pressed));
 	connect_arrow_button_signal(editor, "button-address", G_CALLBACK (_address_arrow_pressed));
+	connect_arrow_button_signal(editor, "button-im1", G_CALLBACK (_im_arrow_pressed));
 	connect_arrow_button_signal(editor, "button-email1", G_CALLBACK (_email_arrow_pressed));
 }
 
@@ -319,6 +337,21 @@
 }
 
 static void
+im_entry_changed (GtkWidget *widget, EContactEditor *editor)
+{
+	GtkEntry *entry = GTK_ENTRY(widget);
+	GList *l;
+
+	l = g_list_append(NULL, (char*)gtk_entry_get_text(entry));
+
+	e_contact_set(editor->contact, editor->im_choice, l);
+
+	g_list_free(l);
+
+	widget_changed (widget, editor);
+}
+
+static void
 email_entry_changed (GtkWidget *widget, EContactEditor *editor)
 {
 	GtkEntry *entry = GTK_ENTRY(widget);
@@ -633,6 +666,15 @@
 }
 
 static void
+set_entry_changed_signal_im(EContactEditor *editor, char *id)
+{
+	GtkWidget *widget = glade_xml_get_widget(editor->gui, id);
+	if (widget && GTK_IS_ENTRY(widget))
+		g_signal_connect(widget, "changed",
+				 G_CALLBACK (im_entry_changed), editor);
+}
+
+static void
 set_entry_changed_signal_email(EContactEditor *editor, char *id)
 {
 	GtkWidget *widget = glade_xml_get_widget(editor->gui, id);
@@ -684,6 +726,8 @@
 	set_entry_changed_signal_phone(editor, "entry-phone3");
 	set_entry_changed_signal_phone(editor, "entry-phone4");
 
+	set_entry_changed_signal_im(editor, "entry-im1");
+
 	set_entry_changed_signal_email(editor, "entry-email1");
 
 	widget = glade_xml_get_widget(editor->gui, "text-address");
@@ -1254,6 +1298,7 @@
 		list = add_to_tab_order(list, gui, "entry-phone2");
 		list = add_to_tab_order(list, gui, "entry-phone3");
 		list = add_to_tab_order(list, gui, "entry-phone4");
+		list = add_to_tab_order(list, gui, "entry-im1");
 
 		list = add_to_tab_order(list, gui, "entry-email1");
 		list = add_to_tab_order(list, gui, "alignment-htmlmail");
@@ -1278,6 +1323,7 @@
 	char *icon_path;
 
 	e_contact_editor->email_info = NULL;
+	e_contact_editor->im_info = NULL;
 	e_contact_editor->phone_info = NULL;
 	e_contact_editor->address_info = NULL;
 	e_contact_editor->email_popup = NULL;
@@ -1289,6 +1335,7 @@
 	e_contact_editor->name = e_contact_name_new();
 	e_contact_editor->company = g_strdup("");
 	
+	e_contact_editor->im_choice = E_CONTACT_IM_AIM;
 	e_contact_editor->email_choice = E_CONTACT_EMAIL_1;
 	e_contact_editor->phone_choice[0] = E_CONTACT_PHONE_BUSINESS;
 	e_contact_editor->phone_choice[1] = E_CONTACT_PHONE_HOME;
@@ -1401,6 +1448,14 @@
 		g_list_free(e_contact_editor->email_list);
 		e_contact_editor->email_list = NULL;
 	}
+	if (e_contact_editor->im_info) {
+		g_free(e_contact_editor->im_info);
+		e_contact_editor->im_info = NULL;
+	}
+	if (e_contact_editor->im_popup) {
+		g_object_unref(e_contact_editor->im_popup);
+		e_contact_editor->im_popup = NULL;
+	}
 	if (e_contact_editor->email_info) {
 		g_free(e_contact_editor->email_info);
 		e_contact_editor->email_info = NULL;
@@ -1750,6 +1805,27 @@
 }
 
 static void
+e_contact_editor_build_im_ui (EContactEditor *editor)
+{
+	int i;
+
+	if (editor->im_list == NULL) {
+		for (i = 0; i < G_N_ELEMENTS (ims); i++)
+			editor->im_list = g_list_append(editor->im_list, g_strdup(im_labels[i]));
+	}
+	if (editor->im_info == NULL) {
+		e_contact_editor_build_ui_info(editor->im_list, &editor->im_info);
+
+		if ( editor->im_popup )
+			g_object_unref(editor->im_popup);
+
+		editor->im_popup = gnome_popup_menu_new(editor->im_info);
+		g_object_ref (editor->im_popup);
+		gtk_object_sink (GTK_OBJECT (editor->im_popup));
+	}
+}
+
+static void
 e_contact_editor_build_email_ui (EContactEditor *editor)
 {
 	int i;
@@ -1844,6 +1920,37 @@
 }
 
 static void
+_im_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor)
+{
+	int i;
+	int result;
+
+	e_contact_editor_build_im_ui (editor);
+
+	for(i = 0; i < G_N_ELEMENTS (ims); i++) {
+		GList *list = e_contact_get(editor->contact, ims[i]);
+		gboolean checked;
+		checked = (list != NULL);
+
+		gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(editor->im_info[i].widget),
+					       checked);
+	}
+	
+	result = _arrow_pressed (widget, button, editor, editor->im_popup, &editor->im_list, &editor->im_info, "label-im1");
+	
+	if (result != -1) {
+		GtkWidget *entry = glade_xml_get_widget (editor->gui, "entry-im1");
+		editor->im_choice = ims[result];
+
+		set_fields (editor);
+
+		/* make sure the buttons/entry is/are sensitive */
+		enable_widget (glade_xml_get_widget (editor->gui, "label-im1"), TRUE);
+		enable_widget (entry, editor->editable);
+	}
+}
+
+static void
 _email_arrow_pressed (GtkWidget *widget, GdkEventButton *button, EContactEditor *editor)
 {
 	int i;
@@ -1937,6 +2044,8 @@
 	const char *oldstring = gtk_entry_get_text(entry);
 	if (!string)
 		string = "";
+	printf("oldstring = '%s'\n", oldstring);
+	printf("string = '%s'\n", string);
 	if (strcmp(string, oldstring)) {
 		g_signal_handlers_block_matched (entry,
 						 G_SIGNAL_MATCH_DATA,
@@ -1976,7 +2085,17 @@
 	entry = glade_xml_get_widget(editor->gui, "entry-phone4");
 	if (entry && GTK_IS_ENTRY(entry))
 		set_phone_field(editor, entry, e_contact_get_const(editor->contact, editor->phone_choice[3]));
-	
+
+	entry = glade_xml_get_widget(editor->gui, "entry-im1");
+	if (entry && GTK_IS_ENTRY(entry)) {
+		GList *values = e_contact_get(editor->contact, editor->im_choice);
+
+		if (values && values->data)
+			set_field(editor, GTK_ENTRY(entry), values->data);
+		else
+			set_field(editor, GTK_ENTRY(entry), NULL);
+	}
+
 	entry = glade_xml_get_widget(editor->gui, "entry-email1");
 	if (entry && GTK_IS_ENTRY(entry))
 		set_field(editor, GTK_ENTRY(entry), e_contact_get_const(editor->contact, editor->email_choice));
@@ -2185,10 +2304,15 @@
 		g_hash_table_insert (dropdown_hash,
 				     (char*)e_contact_field_name(phones[i]),
 				     editor->phone_info[i].widget);
+	e_contact_editor_build_im_ui (editor);
+	for (i = 0; i < G_N_ELEMENTS (ims); i ++)
+		g_hash_table_insert (dropdown_hash,
+				     (char*)e_contact_field_name(ims[i]),
+				     editor->im_info[i].widget);
 	e_contact_editor_build_email_ui (editor);
 	for (i = 0; i < G_N_ELEMENTS (emails); i ++)
 		g_hash_table_insert (dropdown_hash,
-				     (char*)e_contact_field_name(phones[i]),
+				     (char*)e_contact_field_name(emails[i]),
 				     editor->email_info[i].widget);
 #if notyet
 	e_contact_editor_build_address_ui (editor);
@@ -2212,6 +2336,8 @@
 		enable_widget (glade_xml_get_widget (editor->gui, widget_name), FALSE);
 		g_free (widget_name);
 	}
+	enable_widget (glade_xml_get_widget (editor->gui, "label-im1"), FALSE);
+	enable_widget (glade_xml_get_widget (editor->gui, "entry-im1"), FALSE);
 	enable_widget (glade_xml_get_widget (editor->gui, "label-email1"), FALSE);
 	enable_widget (glade_xml_get_widget (editor->gui, "entry-email1"), FALSE);
 	enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-htmlmail"), FALSE);
@@ -2260,6 +2386,10 @@
 			enable_widget (glade_xml_get_widget (editor->gui, "checkbutton-mailingaddress"), editor->editable);
 			enable_widget (glade_xml_get_widget (editor->gui, "text-address"), editor->editable);
 		}
+		else if (!strcmp (field, e_contact_field_name (editor->im_choice))) {
+			enable_widget (glade_xml_get_widget (editor->gui, "label-im1"), TRUE);
+			enable_widget (glade_xml_get_widget (editor->gui, "entry-im1"), TRUE);
+		}
 		else for (i = 0; i < 4; i ++) {
 			if (!strcmp (field, e_contact_field_name (editor->phone_choice[i]))) {
 				widget_name = g_strdup_printf ("label-phone%d", i+1);
@@ -2325,6 +2455,11 @@
 		g_free (entry);
 	}
 
+	/* handle the im dropdown entry */
+	entry = "entry-im1";
+	enable_widget (glade_xml_get_widget(editor->gui, entry),
+		       editor->editable);
+
 	/* handle the email dropdown entry */
 	entry = "entry-email1";
 	enable_widget (glade_xml_get_widget(editor->gui, entry),
Index: addressbook/gui/contact-editor/e-contact-editor.h
===================================================================
RCS file: /cvs/gnome/evolution/addressbook/gui/contact-editor/e-contact-editor.h,v
retrieving revision 1.36
diff -u -r1.36 e-contact-editor.h
--- addressbook/gui/contact-editor/e-contact-editor.h	7 Nov 2003 05:51:33 -0000	1.36
+++ addressbook/gui/contact-editor/e-contact-editor.h	23 Nov 2003 22:51:37 -0000
@@ -62,12 +62,15 @@
 	
 	GladeXML *gui;
 	GtkWidget *app;
+	GnomeUIInfo *im_info;
 	GnomeUIInfo *email_info;
 	GnomeUIInfo *phone_info;
 	GnomeUIInfo *address_info;
+	GtkWidget *im_popup;
 	GtkWidget *email_popup;
 	GtkWidget *phone_popup;
 	GtkWidget *address_popup;
+	GList *im_list;
 	GList *email_list;
 	GList *phone_list;
 	GList *address_list;
@@ -75,6 +78,7 @@
 	EContactName *name;
 	char *company;
 
+	EContactField im_choice;
 	EContactField email_choice;
 	EContactField phone_choice[4];
 	EContactField address_choice;

Attachment: pgpA1WOfxyDlO.pgp
Description: PGP signature



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