aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2002-03-16 06:51:13 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2002-03-16 06:51:13 +0800
commitc85ad2279bcfc8e85e6c6b5824e851da92173582 (patch)
treec0e77b54e2ed6a5fece1ff5469f7bd048636a329 /widgets
parent95c4e2623b6f22473ee4a304d485400728ed8b09 (diff)
downloadgsoc2013-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
Diffstat (limited to 'widgets')
-rw-r--r--widgets/misc/ChangeLog17
-rw-r--r--widgets/misc/e-filter-bar.c13
-rw-r--r--widgets/misc/e-filter-bar.h7
-rw-r--r--widgets/misc/e-search-bar.c176
-rw-r--r--widgets/misc/e-search-bar.h72
5 files changed, 178 insertions, 107 deletions
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
}