soylent r97 - trunk/src
- From: treitter svn gnome org
- To: svn-commits-list gnome org
- Subject: soylent r97 - trunk/src
- Date: Sat, 8 Mar 2008 21:09:31 +0000 (GMT)
Author: treitter
Date: Sat Mar 8 21:09:31 2008
New Revision: 97
URL: http://svn.gnome.org/viewvc/soylent?rev=97&view=rev
Log:
Clean up the code to set the Detail Add button sensitivity
Modified:
trunk/src/soylent-browser-person-view.c
trunk/src/soylent-browser-person-view.h
trunk/src/soylent-browser.c
Modified: trunk/src/soylent-browser-person-view.c
==============================================================================
--- trunk/src/soylent-browser-person-view.c (original)
+++ trunk/src/soylent-browser-person-view.c Sat Mar 8 21:09:31 2008
@@ -881,41 +881,96 @@
}
/* Set the sensitivity of the Detail Add button based on whether there are
- * unsaved changes */
-void
-btn_detail_add_update (GtkWidget *widget, gpointer user_data)
+ * unsaved changes in the simple entry field (non-Mailing Address).
+ *
+ * Return TRUE for success, FALSE for any failure. */
+gboolean
+btn_detail_add_update_simple (GtkEntry *entry_simple, gpointer user_data)
{
+ gboolean retval = FALSE;
SoylentBrowser *browser = NULL;
GladeXML *wtree = NULL;
GtkWidget *btn_detail_add = NULL;
- const gchar *detail_value = NULL;
+
+ g_return_val_if_fail (user_data != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (user_data), retval);
+ */
browser = (SoylentBrowser*) user_data;
wtree = soylent_browser_get_widget_tree (browser);
+ btn_detail_add = (glade_xml_get_widget (wtree, "btn_detail_add"));
+ if (strlen (gtk_entry_get_text (entry_simple)) > 0)
+ {
+ gtk_widget_set_sensitive (btn_detail_add, TRUE);
+ }
+ else
+ {
+ gtk_widget_set_sensitive (btn_detail_add, FALSE);
+ }
+
+ retval = TRUE;
+
+ return retval;
+}
+
+/* Set the sensitivity of the Detail Add button based on whether there are
+ * unsaved changes in the Mailing Address fields.
+ *
+ * Return TRUE for success, FALSE for any failure. */
+gboolean
+btn_detail_add_update_mail (GtkWidget *widget_mail, gpointer user_data)
+{
+ const gchar *entry_names[] = {"entry_person_mail_add_po",
+ "entry_person_mail_add_locality",
+ "entry_person_mail_add_region",
+ "entry_person_mail_add_code",
+ "entry_person_mail_add_country",};
+ gboolean retval = FALSE;
+ SoylentBrowser *browser = NULL;
+ GladeXML *wtree = NULL;
+ GtkWidget *btn_detail_add = NULL;
+ gboolean new_details_non_empty = FALSE;
+ guint num_entries = ARRAY_LEN (entry_names);
+ guint i = 0;
+
+ g_return_val_if_fail (user_data != NULL, retval);
+ /* FIXME: uncomment once SoylentBrowser is a GObject:
+ g_return_val_if_fail (SOYLENT_IS_BROWSER (user_data), retval);
+ */
+
+ browser = (SoylentBrowser*) user_data;
+ wtree = soylent_browser_get_widget_tree (browser);
btn_detail_add = (glade_xml_get_widget (wtree, "btn_detail_add"));
- /* FIXME: the mail details needs to check all fields -- if we fill in 2
- * fields, then erase one, this will desensify the Add button */
- if (GTK_IS_ENTRY (widget))
+ for (i = 0; !new_details_non_empty && (i < num_entries); i++)
{
- detail_value = gtk_entry_get_text (GTK_ENTRY (widget));
+ GtkEntry *entry_cur = NULL;
+
+ entry_cur = GTK_ENTRY (glade_xml_get_widget (wtree, entry_names[i]));
+ new_details_non_empty = (strlen (gtk_entry_get_text (entry_cur)) > 0);
}
- else if (GTK_IS_TEXT_BUFFER (widget))
+
+ if (!new_details_non_empty)
{
+ GtkTextView *tv_add_street = NULL;
+ GtkTextBuffer *tb_add_street = NULL;
GtkTextIter start;
GtkTextIter end;
- gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (widget), &start, &end);
- detail_value = gtk_text_buffer_get_text (GTK_TEXT_BUFFER (widget), &start,
- &end, FALSE);
- }
- else
- {
- g_warning ("expected a GtkEntry or GtkTextView");
+ tv_add_street = GTK_TEXT_VIEW (glade_xml_get_widget
+ (wtree,
+ "tv_person_mail_add_street"));
+ tb_add_street = gtk_text_view_get_buffer (tv_add_street);
+ gtk_text_buffer_get_bounds (tb_add_street, &start, &end);
+ new_details_non_empty = (strlen (gtk_text_buffer_get_text (tb_add_street,
+ &start, &end,
+ FALSE))
+ > 0);
}
- if (strlen (detail_value) > 0)
+ if (new_details_non_empty)
{
gtk_widget_set_sensitive (btn_detail_add, TRUE);
}
@@ -923,8 +978,14 @@
{
gtk_widget_set_sensitive (btn_detail_add, FALSE);
}
+
+ retval = TRUE;
+
+ return retval;
}
+
+
/* Hide the Person editor window
*
* Return TRUE for success, FALSE for any failure */
Modified: trunk/src/soylent-browser-person-view.h
==============================================================================
--- trunk/src/soylent-browser-person-view.h (original)
+++ trunk/src/soylent-browser-person-view.h Sat Mar 8 21:09:31 2008
@@ -71,7 +71,10 @@
gpointer user_data);
/* Setup/update sections of the person view UI with latest data from e-d-s */
-void btn_detail_add_update (GtkWidget *widget, gpointer user_data);
+gboolean btn_detail_add_update_simple (GtkEntry *entry_simple,
+ gpointer user_data);
+gboolean btn_detail_add_update_mail (GtkWidget *widget_mail,
+ gpointer user_data);
gboolean soylent_browser_person_detail_add_cbox_setup
(SoylentBrowser *browser,
gboolean skip_domain_cbox);
Modified: trunk/src/soylent-browser.c
==============================================================================
--- trunk/src/soylent-browser.c (original)
+++ trunk/src/soylent-browser.c Sat Mar 8 21:09:31 2008
@@ -1569,22 +1569,22 @@
/* general */
{"cbox_detail_domain", "changed",
soylent_browser_person_detail_add_cbox_update, CB_DATA_SIMPLE, browser},
- {"entry_detail_add", "changed", btn_detail_add_update, CB_DATA_SIMPLE,
- browser},
+ {"entry_detail_add", "changed", btn_detail_add_update_simple,
+ CB_DATA_SIMPLE, browser},
{"btn_detail_add", "clicked", soylent_browser_person_detail_add_commit,
CB_DATA_SIMPLE, browser},
/* postal mail */
- {"tv_person_mail_add_street", "changed", btn_detail_add_update,
+ {"tv_person_mail_add_street", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
- {"entry_person_mail_add_po", "changed", btn_detail_add_update,
+ {"entry_person_mail_add_po", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
- {"entry_person_mail_add_locality", "changed", btn_detail_add_update,
+ {"entry_person_mail_add_locality", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
- {"entry_person_mail_add_code", "changed", btn_detail_add_update,
+ {"entry_person_mail_add_code", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
- {"entry_person_mail_add_region", "changed", btn_detail_add_update,
+ {"entry_person_mail_add_region", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
- {"entry_person_mail_add_country", "changed", btn_detail_add_update,
+ {"entry_person_mail_add_country", "changed", btn_detail_add_update_mail,
CB_DATA_SIMPLE, browser},
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]