From dbe5c76eb0241a143c365f0f2731830e04fe1cc7 Mon Sep 17 00:00:00 2001 From: Chris Toshok Date: Fri, 13 Sep 2002 10:02:24 +0000 Subject: [ Fixes bug #30250 ] handle "Unnamed Lists" here by setting their name to 2002-09-13 Chris Toshok [ Fixes bug #30250 ] * backend/ebook/e-destination.c (e_destination_get_name): handle "Unnamed Lists" here by setting their name to _("Unnamed List'). * backend/ebook/e-card-simple.c (e_card_simple_get): same. * gui/contact-list-editor/e-contact-list-editor.c (is_named): new function, return TRUE if the name field is filled in. (prompt_to_save_changes): return TRUE if the list isn't named (meaning it's not saveable.) (command_state_changed): saving requires a name. (add_email_cb): always call command_state_changed. (remove_entry_cb): same. (list_name_changed_cb): same. (visible_addrs_toggled_cb): same. (table_drag_data_received_cb): same. svn path=/trunk/; revision=18059 --- .../contact-list-editor/e-contact-list-editor.c | 50 +++++++++++++--------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/contact-list-editor/e-contact-list-editor.c b/addressbook/gui/contact-list-editor/e-contact-list-editor.c index e75d8d35e8..5dd61ebec4 100644 --- a/addressbook/gui/contact-list-editor/e-contact-list-editor.c +++ b/addressbook/gui/contact-list-editor/e-contact-list-editor.c @@ -390,10 +390,25 @@ save_card (EContactListEditor *cle, gboolean should_close) } } +static gboolean +is_named (EContactListEditor *editor) +{ + char *string = e_utf8_gtk_editable_get_chars(GTK_EDITABLE (editor->list_name_entry), 0, -1); + gboolean named = FALSE; + + if (string && *string) { + named = TRUE; + } + + g_free (string); + + return named; +} + static gboolean prompt_to_save_changes (EContactListEditor *editor) { - if (!editor->changed) + if (!editor->changed || !is_named (editor)) return TRUE; switch (e_addressbook_prompt_save_dialog (GTK_WINDOW(editor->app))) { @@ -718,10 +733,9 @@ add_email_cb (GtkWidget *w, EContactListEditor *editor) gtk_entry_set_text (GTK_ENTRY(editor->email_entry), ""); - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } + editor->changed = TRUE; + + command_state_changed (editor); } static void @@ -735,28 +749,22 @@ remove_entry_cb (GtkWidget *w, EContactListEditor *editor) { e_table_selected_row_foreach (e_table_scrolled_get_table(E_TABLE_SCROLLED(editor->table)), (EForeachFunc)remove_row, editor); - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } + editor->changed = TRUE; + command_state_changed (editor); } static void list_name_changed_cb (GtkWidget *w, EContactListEditor *editor) { - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } + editor->changed = TRUE; + command_state_changed (editor); } static void visible_addrs_toggled_cb (GtkWidget *w, EContactListEditor *editor) { - if (!editor->changed) { - editor->changed = TRUE; - command_state_changed (editor); - } + editor->changed = TRUE; + command_state_changed (editor); } static void @@ -878,7 +886,7 @@ table_drag_data_received_cb (ETable *table, int row, int col, gtk_adjustment_set_value (adj, adj->upper); } - if (changed && !editor->changed) { + if (changed) { editor->changed = TRUE; command_state_changed (editor); } @@ -887,15 +895,17 @@ table_drag_data_received_cb (ETable *table, int row, int col, static void command_state_changed (EContactListEditor *editor) { + gboolean named = is_named (editor); + bonobo_ui_component_set_prop (editor->uic, "/commands/ContactListEditorSaveClose", "sensitive", - editor->changed && editor->editable ? "1" : "0", NULL); + editor->changed && named && editor->editable ? "1" : "0", NULL); bonobo_ui_component_set_prop (editor->uic, "/commands/ContactListEditorSave", "sensitive", - editor->changed && editor->editable ? "1" : "0", NULL); + editor->changed && named && editor->editable ? "1" : "0", NULL); bonobo_ui_component_set_prop (editor->uic, "/commands/ContactListEditorDelete", -- cgit