diff options
author | Federico Mena Quintero <federico@ximian.com> | 2001-08-15 01:48:08 +0800 |
---|---|---|
committer | Federico Mena Quintero <federico@src.gnome.org> | 2001-08-15 01:48:08 +0800 |
commit | 84eb55399b9ac31c9b213316cf6cfff3df3a07f1 (patch) | |
tree | 8892989792c12fcda48b560f18730bfb71a8f78b /widgets/misc | |
parent | 250946204244dce6c91d99ce4f573ae3de2dcb7a (diff) | |
download | gsoc2013-evolution-84eb55399b9ac31c9b213316cf6cfff3df3a07f1.tar.gz gsoc2013-evolution-84eb55399b9ac31c9b213316cf6cfff3df3a07f1.tar.zst gsoc2013-evolution-84eb55399b9ac31c9b213316cf6cfff3df3a07f1.zip |
Correctness fixes for when the entry and submenu must be interchanged.
2001-08-14 Federico Mena Quintero <federico@ximian.com>
* e-search-bar.c (activate_by_subitems): Correctness fixes for
when the entry and submenu must be interchanged.
svn path=/trunk/; revision=12019
Diffstat (limited to 'widgets/misc')
-rw-r--r-- | widgets/misc/ChangeLog | 5 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 69 |
2 files changed, 50 insertions, 24 deletions
diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index ce4994f43f..00fe03d944 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,5 +1,10 @@ 2001-08-14 Federico Mena Quintero <federico@ximian.com> + * e-search-bar.c (activate_by_subitems): Correctness fixes for + when the entry and submenu must be interchanged. + +2001-08-14 Federico Mena Quintero <federico@ximian.com> + *Please* add accessor functions instead of just object arguments! * e-search-bar.c (e_search_bar_set_option_choice): New function. diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index ad5e07d523..5dd7ac1938 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -125,41 +125,69 @@ activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems if (subitems == NULL) { /* This item uses the entry. */ + /* Remove the menu */ + if (esb->suboption && esb->suboption_choice != -1) { + g_assert (esb->suboption->parent == esb->entry_box); + g_assert (!esb->entry || esb->entry->parent == NULL); + gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->suboption); + } + + /* Create and add the entry */ + if (esb->entry == NULL) { esb->entry = gtk_entry_new(); gtk_object_ref (GTK_OBJECT (esb->entry)); gtk_signal_connect (GTK_OBJECT (esb->entry), "activate", GTK_SIGNAL_FUNC (entry_activated_cb), esb); + gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry); gtk_widget_show(esb->entry); - esb->suboption_choice = 0; + esb->suboption_choice = -1; } - - if (esb->suboption_choice >= 0) { - if (esb->suboption != NULL) { - gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->suboption); - } - + if (esb->suboption_choice == -1) { + g_assert (esb->entry->parent == esb->entry_box); + g_assert (!esb->suboption || esb->suboption->parent == NULL); + } else { gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->entry); + esb->suboption_choice = -1; } - + gtk_entry_set_text (GTK_ENTRY (esb->entry), ""); - - esb->suboption_choice = -1; - } else { - + /* This item uses a submenu */ GtkWidget *menu; GtkWidget *menu_item; gint i; + /* Remove the entry */ + if (esb->entry && esb->suboption_choice == -1) { + g_assert (esb->entry->parent == esb->entry_box); + g_assert (!esb->suboption || esb->suboption->parent == NULL); + gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->entry); + } + + /* Create and add the menu */ + if (esb->suboption == NULL) { esb->suboption = gtk_option_menu_new (); gtk_object_ref (GTK_OBJECT (esb->suboption)); + gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption); gtk_widget_show (esb->suboption); + + esb->suboption_choice = subitems[0].id; } + if (esb->suboption_choice != -1) { + g_assert (esb->suboption->parent == esb->entry_box); + g_assert (!esb->entry || esb->entry->parent == NULL); + } else { + gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption); + esb->suboption_choice = subitems[0].id; + } + + /* Create the items */ + esb->suboption_menu = menu = gtk_menu_new (); for (i = 0; subitems[i].id != -1; ++i) { if (subitems[i].text) { @@ -176,8 +204,10 @@ activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems gtk_widget_set_sensitive (menu_item, FALSE); } - gtk_object_set_data (GTK_OBJECT (menu_item), "EsbItemId", GINT_TO_POINTER (item_id)); - gtk_object_set_data (GTK_OBJECT (menu_item), "EsbSubitemId", GINT_TO_POINTER (subitems[i].id)); + gtk_object_set_data (GTK_OBJECT (menu_item), "EsbItemId", + GINT_TO_POINTER (item_id)); + gtk_object_set_data (GTK_OBJECT (menu_item), "EsbSubitemId", + GINT_TO_POINTER (subitems[i].id)); gtk_signal_connect (GTK_OBJECT (menu_item), "activate", @@ -190,19 +220,10 @@ activate_by_subitems (ESearchBar *esb, gint item_id, ESearchBarSubitem *subitems gtk_option_menu_remove_menu (GTK_OPTION_MENU (esb->suboption)); gtk_option_menu_set_menu (GTK_OPTION_MENU (esb->suboption), menu); - - if (esb->entry != NULL) { - gtk_container_remove (GTK_CONTAINER (esb->entry_box), esb->entry); - } - - gtk_container_add (GTK_CONTAINER (esb->entry_box), esb->suboption); - - esb->suboption_choice = subitems[0].id; } - if (esb->activate_button) { + if (esb->activate_button) gtk_widget_set_sensitive (esb->activate_button, subitems == NULL); - } } static void |