diff options
author | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-16 06:51:13 +0800 |
---|---|---|
committer | Ettore Perazzoli <ettore@src.gnome.org> | 2002-03-16 06:51:13 +0800 |
commit | c85ad2279bcfc8e85e6c6b5824e851da92173582 (patch) | |
tree | c0e77b54e2ed6a5fece1ff5469f7bd048636a329 | |
parent | 95c4e2623b6f22473ee4a304d485400728ed8b09 (diff) | |
download | gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar.gz gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar.bz2 gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar.lz gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar.xz gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.tar.zst gsoc2013-evolution-c85ad2279bcfc8e85e6c6b5824e851da92173582.zip |
[Start implementing the new Search Bar design.]
* e-search-bar.c (init): Init various members to NULL.
(set_dropdown): Removed.
(add_dropdown): Removed.
(set_menu): New.
(add_menu_items): New.
(set_option): No need to setup the dropdown size here anymore.
(verb_cb): Function implementing the search menu verbs.
(update_bonobo_menus): New.
(e_search_bar_set_ui_component): New.
* e-search-bar.h: Remove the dropdown button stuff from struct
ESearchBar. Add `uic' and `items' members.
* e-filter-bar.c (e_filter_bar_new): Get a @uic arg.
* folder-browser-factory.c (control_activate): Set the UI
component on the search bar.
* gui/tasks-control.c (tasks_control_activate): Call
`e_tasks_set_ui_component()' here to give it the
BonoboUIComponent.
(tasks_control_deactivate): Likewise, call it here to unset the
BonoboUIComponent.
* gui/e-tasks.c (e_tasks_set_ui_component): New.
* gui/calendar-commands.c (calendar_control_activate): Call
gnome_calendar_set_ui_component() here.
(calendar_control_deactivate): ...And here, with a NULL
BonoboUIComponent.
* gui/gnome-cal.c (gnome_calendar_set_ui_component): New.
* gui/component/addressbook.c (control_activate): Call
`e_search_bar_set_ui_component()' to set the BonoboUIComponent for
the search bar.
* gui/component/GNOME_Evolution_Addressbook.oaf.in: Add an icon
for the LDAP sources configuration control.
svn path=/trunk/; revision=16178
-rw-r--r-- | addressbook/ChangeLog | 6 | ||||
-rw-r--r-- | addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in | 2 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook.c | 2 | ||||
-rw-r--r-- | calendar/ChangeLog | 17 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.c | 7 | ||||
-rw-r--r-- | calendar/gui/calendar-commands.h | 4 | ||||
-rw-r--r-- | calendar/gui/e-tasks.c | 15 | ||||
-rw-r--r-- | calendar/gui/e-tasks.h | 5 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.c | 13 | ||||
-rw-r--r-- | calendar/gui/gnome-cal.h | 4 | ||||
-rw-r--r-- | calendar/gui/tasks-control.c | 9 | ||||
-rw-r--r-- | mail/ChangeLog | 6 | ||||
-rw-r--r-- | mail/folder-browser-factory.c | 4 | ||||
-rw-r--r-- | ui/ChangeLog | 2 | ||||
-rw-r--r-- | ui/evolution.xml | 4 | ||||
-rw-r--r-- | widgets/misc/ChangeLog | 17 | ||||
-rw-r--r-- | widgets/misc/e-filter-bar.c | 13 | ||||
-rw-r--r-- | widgets/misc/e-filter-bar.h | 7 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.c | 176 | ||||
-rw-r--r-- | widgets/misc/e-search-bar.h | 72 |
20 files changed, 268 insertions, 117 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index d809837a3d..feda786102 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,4 +1,8 @@ -2002-03-13 Ettore Perazzoli <ettore@ximian.com> +2002-03-15 Ettore Perazzoli <ettore@ximian.com> + + * gui/component/addressbook.c (control_activate): Call + `e_search_bar_set_ui_component()' to set the BonoboUIComponent for + the search bar. * gui/component/GNOME_Evolution_Addressbook.oaf.in: Add an icon for the LDAP sources configuration control. diff --git a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in index 764457a5e1..a8bcaa2ac1 100644 --- a/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in +++ b/addressbook/gui/component/GNOME_Evolution_Addressbook.oaf.in @@ -160,7 +160,7 @@ <oaf_attribute name="evolution:config_item:icon_name" type="string" value="evolution-contacts.png"/> - + <oaf_attribute name="description" type="string" _value="Configuration control for the Evolution Addressbook."/> diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c index 956edc915a..a0f9bda94b 100644 --- a/addressbook/gui/component/addressbook.c +++ b/addressbook/gui/component/addressbook.c @@ -395,6 +395,8 @@ control_activate (BonoboControl *control, bonobo_ui_component_set_container (uic, remote_ui_container); bonobo_object_release_unref (remote_ui_container, NULL); + e_search_bar_set_ui_component (view->search, uic); + bonobo_ui_component_add_verb_list_with_data ( uic, verbs, view); diff --git a/calendar/ChangeLog b/calendar/ChangeLog index 5d21a09727..05ff2c5bc5 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,20 @@ +2002-03-15 Ettore Perazzoli <ettore@ximian.com> + + * gui/tasks-control.c (tasks_control_activate): Call + `e_tasks_set_ui_component()' here to give it the + BonoboUIComponent. + (tasks_control_deactivate): Likewise, call it here to unset the + BonoboUIComponent. + + * gui/e-tasks.c (e_tasks_set_ui_component): New. + + * gui/calendar-commands.c (calendar_control_activate): Call + gnome_calendar_set_ui_component() here. + (calendar_control_deactivate): ...And here, with a NULL + BonoboUIComponent. + + * gui/gnome-cal.c (gnome_calendar_set_ui_component): New. + 2002-03-15 JP Rosevear <jpr@ximian.com> * gui/main.c: use bonobo exception macros to tidy diff --git a/calendar/gui/calendar-commands.c b/calendar/gui/calendar-commands.c index 8eb6a540e8..4165760231 100644 --- a/calendar/gui/calendar-commands.c +++ b/calendar/gui/calendar-commands.c @@ -686,6 +686,8 @@ calendar_control_activate (BonoboControl *control, uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); + gnome_calendar_set_ui_component (gcal, uic); + remote_uih = bonobo_control_get_remote_ui_container (control); bonobo_ui_component_set_container (uic, remote_uih); bonobo_object_release_unref (remote_uih, NULL); @@ -735,10 +737,13 @@ void calendar_control_deactivate (BonoboControl *control, GnomeCalendar *gcal) { FocusData *focus; + BonoboUIComponent *uic; - BonoboUIComponent *uic = bonobo_control_get_ui_component (control); + uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); + gnome_calendar_set_ui_component (gcal, uic); + focus = gtk_object_get_data (GTK_OBJECT (control), "focus_data"); g_assert (focus != NULL); diff --git a/calendar/gui/calendar-commands.h b/calendar/gui/calendar-commands.h index 14a86365d9..0a20ba6c69 100644 --- a/calendar/gui/calendar-commands.h +++ b/calendar/gui/calendar-commands.h @@ -25,9 +25,11 @@ #ifndef CALENDAR_COMMANDS_H #define CALENDAR_COMMANDS_H -#include <bonobo/bonobo-control.h> #include "gnome-cal.h" +#include <bonobo/bonobo-control.h> +#include <bonobo/bonobo-ui-component.h> + /* This tells all the calendars to reload the config settings. */ void update_all_config_settings (void); diff --git a/calendar/gui/e-tasks.c b/calendar/gui/e-tasks.c index b9443a2875..d98bdfea9c 100644 --- a/calendar/gui/e-tasks.c +++ b/calendar/gui/e-tasks.c @@ -125,8 +125,6 @@ e_tasks_init (ETasks *tasks) priv->query = NULL; priv->view_instance = NULL; priv->view_menus = NULL; - - setup_widgets (tasks); } /* Callback used when the selection changes in the table. */ @@ -244,6 +242,8 @@ e_tasks_construct (ETasks *tasks) priv = tasks->priv; + setup_widgets (tasks); + priv->client = cal_client_new (); if (!priv->client) return NULL; @@ -281,6 +281,17 @@ e_tasks_new (void) } +void +e_tasks_set_ui_component (ETasks *tasks, + BonoboUIComponent *ui_component) +{ + g_return_if_fail (E_IS_TASKS (tasks)); + g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component)); + + e_search_bar_set_ui_component (E_SEARCH_BAR (tasks->priv->search_bar), ui_component); +} + + static void e_tasks_destroy (GtkObject *object) { diff --git a/calendar/gui/e-tasks.h b/calendar/gui/e-tasks.h index 102369b682..b88e495dcc 100644 --- a/calendar/gui/e-tasks.h +++ b/calendar/gui/e-tasks.h @@ -56,10 +56,13 @@ struct _ETasksClass { GtkType e_tasks_get_type (void); -GtkWidget *e_tasks_construct (ETasks *tasks); +GtkWidget *e_tasks_construct (ETasks *tasks); GtkWidget *e_tasks_new (void); +void e_tasks_set_ui_component (ETasks *tasks, + BonoboUIComponent *ui_component); + gboolean e_tasks_open (ETasks *tasks, char *file); diff --git a/calendar/gui/gnome-cal.c b/calendar/gui/gnome-cal.c index 9ff815211e..165f79c70a 100644 --- a/calendar/gui/gnome-cal.c +++ b/calendar/gui/gnome-cal.c @@ -910,7 +910,6 @@ gnome_calendar_init (GnomeCalendar *gcal) priv->current_view_type = GNOME_CAL_DAY_VIEW; priv->range_selected = FALSE; - setup_widgets (gcal); priv->dn_query = NULL; priv->sexp = g_strdup ("#t"); /* Match all */ @@ -1683,6 +1682,8 @@ gnome_calendar_construct (GnomeCalendar *gcal) priv = gcal->priv; + setup_widgets (gcal); + /* * Calendar Folder Client. */ @@ -1747,6 +1748,16 @@ gnome_calendar_new (void) return GTK_WIDGET (gcal); } +void +gnome_calendar_set_ui_component (GnomeCalendar *gcal, + BonoboUIComponent *ui_component) +{ + g_return_if_fail (GNOME_IS_CALENDAR (gcal)); + g_return_if_fail (ui_component == NULL || BONOBO_IS_UI_COMPONENT (ui_component)); + + e_search_bar_set_ui_component (E_SEARCH_BAR (gcal->priv->search_bar), ui_component); +} + /** * gnome_calendar_get_cal_client: * @gcal: A calendar view. diff --git a/calendar/gui/gnome-cal.h b/calendar/gui/gnome-cal.h index 2c4eaaf0af..8a888420dc 100644 --- a/calendar/gui/gnome-cal.h +++ b/calendar/gui/gnome-cal.h @@ -31,6 +31,7 @@ #include <bonobo/bonobo-ui-component.h> #include <widgets/misc/e-calendar.h> #include <cal-client/cal-client.h> + #include "e-calendar-table.h" BEGIN_GNOME_DECLS @@ -82,6 +83,9 @@ GtkWidget *gnome_calendar_construct (GnomeCalendar *gcal); GtkWidget *gnome_calendar_new (void); +void gnome_calendar_set_ui_component (GnomeCalendar *cal, + BonoboUIComponent *ui_component); + ECalendarTable *gnome_calendar_get_task_pad (GnomeCalendar *gcal); CalClient *gnome_calendar_get_cal_client (GnomeCalendar *gcal); diff --git a/calendar/gui/tasks-control.c b/calendar/gui/tasks-control.c index 6ae2a45565..53e3eb239f 100644 --- a/calendar/gui/tasks-control.c +++ b/calendar/gui/tasks-control.c @@ -101,7 +101,7 @@ static void tasks_control_print_preview_cmd (BonoboUIComponent *uic, BonoboControl * -tasks_control_new (void) +tasks_control_new (void) { BonoboControl *control; GtkWidget *tasks; @@ -109,11 +109,11 @@ tasks_control_new (void) tasks = e_tasks_new (); if (!tasks) return NULL; - gtk_widget_show (tasks); control = bonobo_control_new (tasks); if (!control) { + gtk_widget_destroy (tasks); g_message ("control_factory_fn(): could not create the control!"); return NULL; } @@ -303,6 +303,8 @@ tasks_control_activate (BonoboControl *control, ETasks *tasks) uic = bonobo_control_get_ui_component (control); g_assert (uic != NULL); + e_tasks_set_ui_component (tasks, uic); + remote_uih = bonobo_control_get_remote_ui_container (control); bonobo_ui_component_set_container (uic, remote_uih); bonobo_object_release_unref (remote_uih, NULL); @@ -347,8 +349,11 @@ static void tasks_control_deactivate (BonoboControl *control, ETasks *tasks) { BonoboUIComponent *uic = bonobo_control_get_ui_component (control); + g_assert (uic != NULL); + e_tasks_set_ui_component (tasks, NULL); + e_tasks_discard_view_menus (tasks); /* Stop monitoring the "selection_changed" signal */ diff --git a/mail/ChangeLog b/mail/ChangeLog index ca252f840b..73fdb90ed4 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,8 @@ +2002-03-15 Ettore Perazzoli <ettore@ximian.com> + + * folder-browser-factory.c (control_activate): Set the UI + component on the search bar. + 2002-03-14 Dan Winship <danw@ximian.com> * component-factory.c (folder_types): Remove "mailstorage", since @@ -38,6 +43,7 @@ default size of the window, so we don't get this itty-bitty window the size of a quarter on the screen when it first gets shown. +>>>>>>> 1.2080 2002-03-12 Jeffrey Stedfast <fejj@ximian.com> * mail-display.c (on_link_clicked): Handle digest: urls. diff --git a/mail/folder-browser-factory.c b/mail/folder-browser-factory.c index 52f39a8218..395dc26ae8 100644 --- a/mail/folder-browser-factory.c +++ b/mail/folder-browser-factory.c @@ -99,6 +99,8 @@ control_activate (BonoboControl *control, if (fb->folder) mail_refresh_folder (fb->folder, NULL, NULL); + + e_search_bar_set_ui_component (E_SEARCH_BAR (fb->search), uic); } static void @@ -118,6 +120,8 @@ control_deactivate (BonoboControl *control, folder_browser_set_ui_component (fb, NULL); folder_browser_set_shell_view (fb, CORBA_OBJECT_NIL); + + e_search_bar_set_ui_component (E_SEARCH_BAR (fb->search), NULL); } static void diff --git a/ui/ChangeLog b/ui/ChangeLog index d02e260fa5..08850b1722 100644 --- a/ui/ChangeLog +++ b/ui/ChangeLog @@ -1,5 +1,7 @@ 2002-03-14 Ettore Perazzoli <ettore@ximian.com> + * evolution.xml: Add a "Search" menu. + * my-evolution.xml: Remove "Settings" item. 2002-03-14 JP Rosevear <jpr@ximian.com> diff --git a/ui/evolution.xml b/ui/evolution.xml index 9f20b1eddc..fc3de6a6b9 100644 --- a/ui/evolution.xml +++ b/ui/evolution.xml @@ -145,6 +145,10 @@ <menuitem name="PilotSettings" verb="" _label="_Pilot Settings..."/> </submenu> + <submenu name="Search" _label="_Search"> + <placeholder name="SearchBar"/> + </submenu> + <submenu name="Help" _label="_Help"> <placeholder name="BuiltMenuItems"/> diff --git a/widgets/misc/ChangeLog b/widgets/misc/ChangeLog index d383f0218a..a568847879 100644 --- a/widgets/misc/ChangeLog +++ b/widgets/misc/ChangeLog @@ -1,3 +1,20 @@ +2002-03-15 Ettore Perazzoli <ettore@ximian.com> + + * e-search-bar.c (init): Init various members to NULL. + (set_dropdown): Removed. + (add_dropdown): Removed. + (set_menu): New. + (add_menu_items): New. + (set_option): No need to setup the dropdown size here anymore. + (verb_cb): Function implementing the search menu verbs. + (update_bonobo_menus): New. + (e_search_bar_set_ui_component): New. + + * e-search-bar.h: Remove the dropdown button stuff from struct + ESearchBar. Add `uic' and `items' members. + + * e-filter-bar.c (e_filter_bar_new): Get a @uic arg. + 2002-03-15 Christopher James Lahey <clahey@ximian.com> * e-multi-config-dialog.c (init): Set horizontal scroll policy to diff --git a/widgets/misc/e-filter-bar.c b/widgets/misc/e-filter-bar.c index 9ff4c55aa0..f32a2c0ad9 100644 --- a/widgets/misc/e-filter-bar.c +++ b/widgets/misc/e-filter-bar.c @@ -149,7 +149,7 @@ menubar_activated (ESearchBar *esb, int id, void *data) GnomeDialog *gd; gd = (GnomeDialog *) rule_editor_new (efb->context, FILTER_SOURCE_INCOMING); - efb->save_dialogue = gd; + efb->save_dialogue = (GtkWidget *) gd; gtk_window_set_title (GTK_WINDOW (gd), _("Search Editor")); gtk_signal_connect (GTK_OBJECT (gd), "clicked", full_rule_editor_clicked, efb); gtk_signal_connect (GTK_OBJECT (gd), "destroy", rule_editor_destroyed, efb); @@ -460,8 +460,6 @@ context_changed (RuleContext *context, gpointer user_data) static void context_rule_removed (RuleContext *context, FilterRule *rule, gpointer user_data) { - EFilterBar *efb = E_FILTER_BAR (user_data); - /*gtk_signal_disconnect_by_func((GtkObject *)rule, rule_changed, efb);*/ } @@ -597,14 +595,17 @@ init (EFilterBar *efb) /* Object construction. */ EFilterBar * -e_filter_bar_new (RuleContext *context, const char *systemrules, const char *userrules, - EFilterBarConfigRule config, void *data) +e_filter_bar_new (RuleContext *context, + const char *systemrules, + const char *userrules, + EFilterBarConfigRule config, + void *data) { EFilterBar *bar; ESearchBarItem item = { NULL, -1, NULL }; bar = gtk_type_new (e_filter_bar_get_type ()); - + bar->context = context; gtk_object_ref (GTK_OBJECT (context)); diff --git a/widgets/misc/e-filter-bar.h b/widgets/misc/e-filter-bar.h index 45db51b7a8..7577236ee3 100644 --- a/widgets/misc/e-filter-bar.h +++ b/widgets/misc/e-filter-bar.h @@ -107,8 +107,11 @@ const char * strings[] = { GtkType e_filter_bar_get_type (void); -EFilterBar *e_filter_bar_new (RuleContext *context, const char *systemrules, const char *userrules, - EFilterBarConfigRule config, void *data); +EFilterBar *e_filter_bar_new (RuleContext *context, + const char *systemrules, + const char *userrules, + EFilterBarConfigRule config, + void *data); #ifdef __cplusplus } diff --git a/widgets/misc/e-search-bar.c b/widgets/misc/e-search-bar.c index c07c98fad2..ffca59e9a5 100644 --- a/widgets/misc/e-search-bar.c +++ b/widgets/misc/e-search-bar.c @@ -39,8 +39,11 @@ #include <libgnome/gnome-defs.h> #include <libgnome/gnome-i18n.h> +#include <bonobo/bonobo-ui-util.h> + +#include <stdlib.h> + #include "e-search-bar.h" -#include "e-dropdown-button.h" enum { @@ -97,12 +100,20 @@ emit_menu_activated (ESearchBar *esb, int item) /* Callbacks. */ static void -menubar_activated_cb (GtkWidget *widget, ESearchBar *esb) +search_verb_cb (BonoboUIComponent *ui_component, + void *data, + const char *verb_name) { + ESearchBar *esb; + const char *p; int id; - id = GPOINTER_TO_INT (gtk_object_get_data (GTK_OBJECT (widget), "EsbMenuId")); + esb = E_SEARCH_BAR (data); + p = strrchr (verb_name, ':'); + g_assert (p != NULL); + + id = atoi (p + 1); emit_menu_activated (esb, id); } @@ -299,63 +310,63 @@ copy_subitems (ESearchBarSubitem *subitems) } static void -add_dropdown (ESearchBar *esb, ESearchBarItem *items) +update_bonobo_menus (ESearchBar *esb) { - GtkWidget *menu = esb->dropdown_menu; - GtkWidget *item; - - if (items->text) { - char *str; - str = _(items->text); - if (str == items->text) { - /* It may be english string, or utf8 rule name */ - item = e_utf8_gtk_menu_item_new_with_label (GTK_MENU (menu), str); - } else - item = gtk_menu_item_new_with_label (str); - } else { - item = gtk_menu_item_new(); - gtk_widget_set_sensitive (item, FALSE); + GString *xml; + GSList *p; + char *verb_name; + + xml = g_string_new ("<placeholder name=\"SearchBar\">"); + + for (p = esb->menu_items; p != NULL; p = p->next) { + const ESearchBarItem *item; + + item = (const ESearchBarItem *) p->data; + + verb_name = g_strdup_printf ("ESearchBar:Activate:%d", item->id); + bonobo_ui_component_add_verb (esb->ui_component, verb_name, search_verb_cb, esb); + + if (item->text == NULL) { + g_string_append (xml, "<separator/>"); + } else { + char *encoded_label; + + encoded_label = bonobo_ui_util_encode_str (item->text); + g_string_sprintfa (xml, "<menuitem name=\"%s\" verb=\"%s\" label=\"%s\"/>", + verb_name, verb_name, encoded_label); + g_free (encoded_label); + } } - - gtk_widget_show (item); - gtk_menu_append (GTK_MENU (menu), item); - gtk_object_set_data (GTK_OBJECT (item), "EsbMenuId", GINT_TO_POINTER (items->id)); - gtk_signal_connect (GTK_OBJECT (item), "activate", - GTK_SIGNAL_FUNC (menubar_activated_cb), - esb); + + g_string_sprintfa (xml, "</placeholder>"); + + bonobo_ui_component_set (esb->ui_component, "/menu/Search", xml->str, NULL); + + g_string_free (xml, TRUE); + g_free (verb_name); } static void -set_dropdown (ESearchBar *esb, - ESearchBarItem *items) +set_menu (ESearchBar *esb, + ESearchBarItem *items) { - GtkWidget *menu; - GtkWidget *dropdown; int i; - menu = esb->dropdown_menu = gtk_menu_new (); - for (i = 0; items[i].id != -1; i++) - add_dropdown (esb, items + i); - - gtk_widget_show_all (menu); - - dropdown = e_dropdown_button_new (_("Sear_ch"), GTK_MENU (menu)); - gtk_widget_show (dropdown); - - if (esb->dropdown_holder == NULL) { - /* See the comment in `put_in_spacer_widget()' to understand - why we have to do this. */ - - esb->dropdown_holder = put_in_spacer_widget (dropdown); - esb->dropdown = dropdown; - gtk_widget_show (esb->dropdown_holder); + for (i = 0; items[i].id != -1; i++) { + ESearchBarItem *new_item; - gtk_box_pack_start (GTK_BOX (esb), esb->dropdown_holder, FALSE, FALSE, 0); - } else { - gtk_widget_destroy (esb->dropdown); - esb->dropdown = dropdown; - gtk_container_add (GTK_CONTAINER (esb->dropdown_holder), esb->dropdown); + g_assert (items[i].subitems == NULL); + + new_item = g_new (ESearchBarItem, 1); + new_item->text = items[i].text; + new_item->id = items[i].id; + new_item->subitems = NULL; + + esb->menu_items = g_slist_append (esb->menu_items, new_item); } + + if (esb->ui_component != NULL) + update_bonobo_menus (esb); } /* Frees an array of subitem information */ @@ -393,8 +404,6 @@ static void set_option (ESearchBar *esb, ESearchBarItem *items) { GtkWidget *menu; - GtkRequisition dropdown_requisition; - GtkRequisition option_requisition; int i; if (esb->option) { @@ -448,15 +457,6 @@ set_option (ESearchBar *esb, ESearchBarItem *items) gtk_option_menu_set_history (GTK_OPTION_MENU (esb->option), 0); gtk_widget_set_sensitive (esb->option, TRUE); - - /* Set the minimum height of this widget to that of the dropdown - button, for a better look. */ - g_assert (esb->dropdown != NULL); - - gtk_widget_size_request (esb->dropdown, &dropdown_requisition); - gtk_widget_size_request (esb->option, &option_requisition); - - gtk_container_set_border_width (GTK_CONTAINER (esb->dropdown), GTK_CONTAINER (esb->option)->border_width); } static void @@ -564,9 +564,14 @@ impl_destroy (GtkObject *object) g_return_if_fail (object != NULL); g_return_if_fail (E_IS_SEARCH_BAR (object)); - - /* These two we do need to unref, because we explicitly hold + + /* These three we do need to unref, because we explicitly hold references to them. */ + + if (esb->ui_component != NULL) { + bonobo_object_unref (BONOBO_OBJECT (esb->ui_component)); + esb->ui_component = NULL; + } if (esb->entry) gtk_object_unref (GTK_OBJECT (esb->entry)); if (esb->suboption) @@ -595,7 +600,7 @@ class_init (ESearchBarClass *klass) object_class->get_arg = impl_get_arg; object_class->destroy = impl_destroy; - klass->set_menu = set_dropdown; + klass->set_menu = set_menu; klass->set_option = set_option; gtk_object_add_arg_type ("ESearchBar::item_id", GTK_TYPE_ENUM, @@ -635,12 +640,23 @@ class_init (ESearchBarClass *klass) static void init (ESearchBar *esb) { - esb->dropdown = NULL; - esb->option = NULL; - esb->entry = NULL; + esb->ui_component = NULL; + esb->menu_items = NULL; + + esb->option = NULL; + esb->entry = NULL; + esb->suboption = NULL; - esb->item_id = 0; - esb->subitem_id = 0; + esb->option_menu = NULL; + esb->suboption_menu = NULL; + esb->dropdown_menu = NULL; + esb->activate_button = NULL; + esb->entry_box = NULL; + + esb->pending_activate = 0; + + esb->item_id = 0; + esb->subitem_id = 0; } @@ -664,7 +680,7 @@ e_search_bar_construct (ESearchBar *search_bar, g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); g_return_if_fail (menu_items != NULL); g_return_if_fail (option_items != NULL); - + gtk_box_set_spacing (GTK_BOX (search_bar), 1); e_search_bar_set_menu (search_bar, menu_items); @@ -709,7 +725,7 @@ e_search_bar_add_menu (ESearchBar *search_bar, ESearchBarItem *menu_item) g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); g_return_if_fail (menu_item != NULL); - add_dropdown (search_bar, menu_item); + set_menu (search_bar, menu_item); } void @@ -771,7 +787,7 @@ e_search_bar_new (ESearchBarItem *menu_items, ESearchBarItem *option_items) { GtkWidget *widget; - + g_return_val_if_fail (menu_items != NULL, NULL); g_return_val_if_fail (option_items != NULL, NULL); @@ -783,6 +799,22 @@ e_search_bar_new (ESearchBarItem *menu_items, } void +e_search_bar_set_ui_component (ESearchBar *search_bar, + BonoboUIComponent *ui_component) +{ + g_return_if_fail (E_IS_SEARCH_BAR (search_bar)); + + if (search_bar->ui_component != NULL) + bonobo_object_unref (BONOBO_OBJECT (search_bar->ui_component)); + + search_bar->ui_component = ui_component; + if (ui_component != NULL) { + bonobo_object_ref (BONOBO_OBJECT (ui_component)); + update_bonobo_menus (search_bar); + } +} + +void e_search_bar_set_menu_sensitive (ESearchBar *esb, int id, gboolean state) { int row; diff --git a/widgets/misc/e-search-bar.h b/widgets/misc/e-search-bar.h index 0787a332da..18c4b370c1 100644 --- a/widgets/misc/e-search-bar.h +++ b/widgets/misc/e-search-bar.h @@ -22,6 +22,8 @@ #include <gtk/gtkhbox.h> +#include <bonobo/bonobo-ui-component.h> + #ifdef __cplusplus extern "C" { #pragma } @@ -62,14 +64,16 @@ typedef struct _ESearchBarClass ESearchBarClass; struct _ESearchBar { GtkHBox parent; + + BonoboUIComponent *ui_component; + + GSList *menu_items; /* item specific fields */ - GtkWidget *dropdown; GtkWidget *option; GtkWidget *entry; GtkWidget *suboption; /* an option menu for the choices associated with some options */ - /* PRIVATE */ GtkWidget *dropdown_holder; /* holds the dropdown */ GtkWidget *option_menu; @@ -99,31 +103,45 @@ struct _ESearchBarClass GtkType e_search_bar_get_type (void); -void e_search_bar_set_menu (ESearchBar *search_bar, ESearchBarItem *menu_items); -void e_search_bar_add_menu (ESearchBar *search_bar, ESearchBarItem *menu_item); - -void e_search_bar_set_option (ESearchBar *search_bar, ESearchBarItem *option_items); -void e_search_bar_set_suboption (ESearchBar *search_bar, int option_id, - ESearchBarSubitem *subitems); - -void e_search_bar_construct (ESearchBar *search_bar, - ESearchBarItem *menu_items, - ESearchBarItem *option_items); -GtkWidget *e_search_bar_new (ESearchBarItem *menu_items, - ESearchBarItem *option_items); - -void e_search_bar_set_menu_sensitive(ESearchBar *search_bar, int id, gboolean state); - -void e_search_bar_set_item_id (ESearchBar *search_bar, int id); -int e_search_bar_get_item_id (ESearchBar *search_bar); - -void e_search_bar_set_subitem_id (ESearchBar *search_bar, int id); -int e_search_bar_get_subitem_id (ESearchBar *search_bar); - -void e_search_bar_set_ids (ESearchBar *search_bar, int item_id, int subitem_id); - -void e_search_bar_set_text (ESearchBar *search_bar, const char *text); -char *e_search_bar_get_text (ESearchBar *search_bar); +void e_search_bar_construct (ESearchBar *search_bar, + ESearchBarItem *menu_items, + ESearchBarItem *option_items); +GtkWidget *e_search_bar_new (ESearchBarItem *menu_items, + ESearchBarItem *option_items); + +void e_search_bar_set_ui_component (ESearchBar *search_bar, + BonoboUIComponent *ui_component); + +void e_search_bar_set_menu (ESearchBar *search_bar, + ESearchBarItem *menu_items); +void e_search_bar_add_menu (ESearchBar *search_bar, + ESearchBarItem *menu_item); + +void e_search_bar_set_option (ESearchBar *search_bar, + ESearchBarItem *option_items); +void e_search_bar_set_suboption (ESearchBar *search_bar, + int option_id, + ESearchBarSubitem *subitems); + +void e_search_bar_set_menu_sensitive (ESearchBar *search_bar, + int id, + gboolean state); + +void e_search_bar_set_item_id (ESearchBar *search_bar, + int id); +int e_search_bar_get_item_id (ESearchBar *search_bar); + +void e_search_bar_set_subitem_id (ESearchBar *search_bar, + int id); +int e_search_bar_get_subitem_id (ESearchBar *search_bar); + +void e_search_bar_set_ids (ESearchBar *search_bar, + int item_id, + int subitem_id); + +void e_search_bar_set_text (ESearchBar *search_bar, + const char *text); +char *e_search_bar_get_text (ESearchBar *search_bar); #ifdef __cplusplus } |