aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-11-07 05:56:52 +0800
committerChris Lahey <clahey@src.gnome.org>2000-11-07 05:56:52 +0800
commit9c651d480e354610f80f18b9af73bb3401745f59 (patch)
treedaa4c8fd7b763f44d44fbe3b1c31611010894887 /addressbook
parenta2dda6941a6f6012a41833fd0c928b5a1fa0cd29 (diff)
downloadgsoc2013-evolution-9c651d480e354610f80f18b9af73bb3401745f59.tar.gz
gsoc2013-evolution-9c651d480e354610f80f18b9af73bb3401745f59.tar.zst
gsoc2013-evolution-9c651d480e354610f80f18b9af73bb3401745f59.zip
Switched from EAddressbookSearch to ESearchBar.
2000-11-06 Christopher James Lahey <clahey@helixcode.com> * gui/component/addressbook.c: Switched from EAddressbookSearch to ESearchBar. * gui/widgets/Makefile.am, gui/widgets/e-addressbook-search.c, gui/widgets/e-addressbook-search.h: Removed EAddressbookSearch. This has been moved to filter/ and renamed ESearchBar. * printing/e-contact-print-envelope.c: Forgot to set the font. This works for me now. svn path=/trunk/; revision=6455
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/gui/component/addressbook.c80
-rw-r--r--addressbook/gui/widgets/Makefile.am2
-rw-r--r--addressbook/gui/widgets/e-addressbook-search.c333
-rw-r--r--addressbook/gui/widgets/e-addressbook-search.h83
-rw-r--r--addressbook/printing/e-contact-print-envelope.c1
6 files changed, 66 insertions, 445 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 44793f2277..8d8097b2a8 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,15 @@
+2000-11-06 Christopher James Lahey <clahey@helixcode.com>
+
+ * gui/component/addressbook.c: Switched from EAddressbookSearch to
+ ESearchBar.
+
+ * gui/widgets/Makefile.am, gui/widgets/e-addressbook-search.c,
+ gui/widgets/e-addressbook-search.h: Removed EAddressbookSearch.
+ This has been moved to filter/ and renamed ESearchBar.
+
+ * printing/e-contact-print-envelope.c: Forgot to set the font.
+ This works for me now.
+
2000-11-06 Ettore Perazzoli <ettore@helixcode.com>
* gui/component/select-names/e-select-names-bonobo.c
diff --git a/addressbook/gui/component/addressbook.c b/addressbook/gui/component/addressbook.c
index 1645dd849b..5ce49871ba 100644
--- a/addressbook/gui/component/addressbook.c
+++ b/addressbook/gui/component/addressbook.c
@@ -22,7 +22,7 @@
#include "addressbook/gui/search/e-addressbook-search-dialog.h"
#include "addressbook/gui/widgets/e-addressbook-view.h"
-#include "addressbook/gui/widgets/e-addressbook-search.h"
+#include "filter/e-search-bar.h"
#include <select-names/e-select-names.h>
#include <select-names/e-select-names-manager.h>
@@ -41,7 +41,7 @@
typedef struct {
EAddressbookView *view;
- EAddressbookSearch *search;
+ ESearchBar *search;
GtkWidget *vbox;
BonoboControl *control;
BonoboPropertyBag *properties;
@@ -492,28 +492,72 @@ set_prop (BonoboPropertyBag *bag,
}
}
+enum {
+ ESB_SHOW_ALL,
+ ESB_ADVANCED,
+};
+
+static ESearchBarItem addressbook_search_menu_items[] = {
+ { N_("Show All"), ESB_SHOW_ALL },
+ { NULL, 0 },
+ { N_("Advanced..."), ESB_ADVANCED},
+ { NULL, -1 }
+};
+
+static void
+addressbook_menu_activated (ESearchBar *esb, int id, AddressbookView *view)
+{
+ EBook *book;
+ switch (id) {
+ case ESB_SHOW_ALL:
+ e_addressbook_view_show_all(view->view);
+ break;
+ case ESB_ADVANCED:
+ gtk_object_get(GTK_OBJECT(view->view),
+ "book", &book,
+ NULL);
+ g_assert (E_IS_BOOK (book));
+
+ gtk_widget_show(e_addressbook_search_dialog_new(book));
+ break;
+ }
+}
+
+enum {
+ ESB_ANY,
+ ESB_FULL_NAME,
+ ESB_EMAIL,
+};
+
+static ESearchBarItem addressbook_search_option_items[] = {
+ { N_("Any field contains"), ESB_ANY },
+ { N_("Name contains"), ESB_FULL_NAME },
+ { N_("Email contains"), ESB_EMAIL },
+ { NULL, -1 }
+};
+
static void
-addressbook_query_changed (EAddressbookSearch *eas, AddressbookView *view)
+addressbook_query_changed (ESearchBar *esb, AddressbookView *view)
{
char *search_word, *search_query;
int search_type;
- gtk_object_get(GTK_OBJECT(eas),
+ gtk_object_get(GTK_OBJECT(esb),
"text", &search_word,
"option_choice", &search_type,
NULL);
if (search_word && strlen (search_word)) {
switch (search_type) {
- case 0:
+ case ESB_ANY:
search_query = g_strdup_printf ("(contains \"x-evolution-any-field\" \"%s\")",
search_word);
break;
- case 1:
+ case ESB_FULL_NAME:
search_query = g_strdup_printf ("(contains \"full_name\" \"%s\")",
search_word);
break;
- case 2:
+ case ESB_EMAIL:
search_query = g_strdup_printf ("(contains \"email\" \"%s\")",
search_word);
break;
@@ -532,25 +576,6 @@ addressbook_query_changed (EAddressbookSearch *eas, AddressbookView *view)
g_free (search_word);
}
-static void
-addressbook_menu_activated (EAddressbookSearch *eas, int id, AddressbookView *view)
-{
- EBook *book;
- switch (id) {
- case 0:
- e_addressbook_view_show_all(view->view);
- break;
- case 1:
- gtk_object_get(GTK_OBJECT(view->view),
- "book", &book,
- NULL);
- g_assert (E_IS_BOOK (book));
-
- gtk_widget_show(e_addressbook_search_dialog_new(book));
- break;
- }
-}
-
BonoboControl *
addressbook_factory_new_control (void)
{
@@ -569,7 +594,8 @@ addressbook_factory_new_control (void)
/* Create the control. */
view->control = bonobo_control_new(view->vbox);
- view->search = E_ADDRESSBOOK_SEARCH(e_addressbook_search_new());
+ view->search = E_SEARCH_BAR(e_search_bar_new(addressbook_search_menu_items,
+ addressbook_search_option_items));
gtk_box_pack_start (GTK_BOX (view->vbox), GTK_WIDGET (view->search),
FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (view->search), "query_changed",
diff --git a/addressbook/gui/widgets/Makefile.am b/addressbook/gui/widgets/Makefile.am
index 91e361bee1..03bd9a4d6e 100644
--- a/addressbook/gui/widgets/Makefile.am
+++ b/addressbook/gui/widgets/Makefile.am
@@ -18,8 +18,6 @@ noinst_LIBRARIES = \
libeminicard_a_SOURCES = \
e-addressbook-model.c \
e-addressbook-model.h \
- e-addressbook-search.c \
- e-addressbook-search.h \
e-addressbook-view.c \
e-addressbook-view.h \
e-minicard-control.c \
diff --git a/addressbook/gui/widgets/e-addressbook-search.c b/addressbook/gui/widgets/e-addressbook-search.c
deleted file mode 100644
index e58e72d560..0000000000
--- a/addressbook/gui/widgets/e-addressbook-search.c
+++ /dev/null
@@ -1,333 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * e-addressbook-search.c
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include <config.h>
-#include <gnome.h>
-
-#include "e-addressbook-search.h"
-#include <gal/widgets/e-unicode.h>
-
-static void e_addressbook_search_init (EAddressbookSearch *card);
-static void e_addressbook_search_class_init (EAddressbookSearchClass *klass);
-static void e_addressbook_search_set_arg (GtkObject *o, GtkArg *arg, guint arg_id);
-static void e_addressbook_search_get_arg (GtkObject *object, GtkArg *arg, guint arg_id);
-static void e_addressbook_search_destroy (GtkObject *object);
-
-enum {
- QUERY_CHANGED,
- MENU_ACTIVATED,
-
- LAST_SIGNAL
-};
-
-static gint eas_signals [LAST_SIGNAL] = { 0, };
-
-static GtkHBoxClass *parent_class = NULL;
-
-/* The arguments we take */
-enum {
- ARG_0,
- ARG_OPTION_CHOICE,
- ARG_TEXT,
-};
-
-GtkType
-e_addressbook_search_get_type (void)
-{
- static GtkType type = 0;
-
- if (!type) {
- static const GtkTypeInfo info =
- {
- "EAddressbookSearch",
- sizeof (EAddressbookSearch),
- sizeof (EAddressbookSearchClass),
- (GtkClassInitFunc) e_addressbook_search_class_init,
- (GtkObjectInitFunc) e_addressbook_search_init,
- /* reserved_1 */ NULL,
- /* reserved_2 */ NULL,
- (GtkClassInitFunc) NULL,
- };
-
- type = gtk_type_unique (gtk_hbox_get_type (), &info);
- }
-
- return type;
-}
-
-static void
-e_addressbook_search_class_init (EAddressbookSearchClass *klass)
-{
- GtkObjectClass *object_class;
-
- object_class = GTK_OBJECT_CLASS(klass);
-
- parent_class = gtk_type_class (gtk_hbox_get_type ());
-
- object_class->set_arg = e_addressbook_search_set_arg;
- object_class->get_arg = e_addressbook_search_get_arg;
- object_class->destroy = e_addressbook_search_destroy;
-
- gtk_object_add_arg_type ("EAddressbookSearch::option_choice", GTK_TYPE_ENUM,
- GTK_ARG_READWRITE, ARG_OPTION_CHOICE);
- gtk_object_add_arg_type ("EAddressbookSearch::text", GTK_TYPE_STRING,
- GTK_ARG_READWRITE, ARG_TEXT);
-
- eas_signals [QUERY_CHANGED] =
- gtk_signal_new ("query_changed",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EAddressbookSearchClass, query_changed),
- gtk_marshal_NONE__NONE,
- GTK_TYPE_NONE, 0);
-
- eas_signals [MENU_ACTIVATED] =
- gtk_signal_new ("menu_activated",
- GTK_RUN_LAST,
- object_class->type,
- GTK_SIGNAL_OFFSET (EAddressbookSearchClass, menu_activated),
- gtk_marshal_NONE__INT,
- GTK_TYPE_NONE, 1, GTK_TYPE_INT);
-
- gtk_object_class_add_signals (object_class, eas_signals, LAST_SIGNAL);
-}
-
-static void
-eas_query_changed(EAddressbookSearch *eas)
-{
- gtk_signal_emit(GTK_OBJECT (eas),
- eas_signals [QUERY_CHANGED]);
-}
-
-static void
-eas_menu_activated(EAddressbookSearch *eas, int item)
-{
- gtk_signal_emit(GTK_OBJECT (eas),
- eas_signals [MENU_ACTIVATED],
- item);
-}
-
-static void
-eas_menubar_activated(GtkWidget *widget, EAddressbookSearch *eas)
-{
- int id = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (widget), "EasMenuId"));
-
- eas_menu_activated(eas, id);
-}
-
-typedef enum {
- EAS_CLEAR = 0,
-} EasMenuId;
-
-
-typedef struct {
- char *text;
- char *name;
- int id;
-} EasMenuItem;
-
-static EasMenuItem eas_menu_items[] = {
- { N_("Show All"), "all", 0 },
- { NULL, "sep", -1 },
- { N_("Advanced"), "advanced", 1},
- { NULL, NULL, 0 }
-};
-
-static void
-eas_pack_menubar(EAddressbookSearch *eas)
-{
- GtkWidget *menu, *menuitem;
- int i;
-
- menu = gtk_menu_new ();
- for (i = 0; eas_menu_items[i].name; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(eas_menu_items[i].text));
-
- gtk_menu_append (GTK_MENU (menu), item);
-
- gtk_object_set_data (GTK_OBJECT (item), "EasMenuId", GINT_TO_POINTER(eas_menu_items[i].id));
-
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (eas_menubar_activated),
- eas);
- }
- gtk_widget_show_all (menu);
-
- menuitem = gtk_menu_item_new_with_label(_("Search"));
- gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu);
-
- gtk_widget_show (menuitem);
-
- gtk_menu_bar_append (GTK_MENU_BAR(eas->menubar), menuitem);
- gtk_widget_set_sensitive (eas->menubar, TRUE);
-}
-
-typedef enum {
- EAS_ANY = 0,
- EAS_FULL_NAME = 1,
- EAS_EMAIL = 2,
-} EasChoiceId;
-
-
-typedef struct {
- char *text;
- char *name;
- int id;
-} EasChoice;
-
-static EasChoice eas_choices[] = {
- { N_("Any field contains"), "x-evolution-any-field", EAS_ANY },
- { N_("Name contains"), "full_name", EAS_FULL_NAME },
- { N_("Email contains"), "email", EAS_EMAIL },
- { NULL, NULL, 0 }
-};
-
-static void
-eas_option_activated(GtkWidget *widget, EAddressbookSearch *eas)
-{
- int id = GPOINTER_TO_INT(gtk_object_get_data (GTK_OBJECT (widget), "EasChoiceId"));
-
- eas->option_choice = id;
- eas_query_changed(eas);
-}
-
-static void
-eas_entry_activated(GtkWidget *widget, EAddressbookSearch *eas)
-{
- eas_query_changed(eas);
-}
-
-static void
-eas_pack_option_menu(EAddressbookSearch *eas)
-{
- GtkWidget *menu;
- int i;
-
- menu = gtk_menu_new ();
- for (i = 0; eas_choices[i].name; i++) {
- GtkWidget *item;
-
- item = gtk_menu_item_new_with_label (_(eas_choices[i].text));
-
- gtk_menu_append (GTK_MENU (menu), item);
-
- gtk_object_set_data (GTK_OBJECT (item), "EasChoiceId", GINT_TO_POINTER(eas_choices[i].id));
-
- gtk_signal_connect (GTK_OBJECT (item), "activate",
- GTK_SIGNAL_FUNC (eas_option_activated),
- eas);
- }
- gtk_widget_show_all (menu);
-
- gtk_option_menu_set_menu (GTK_OPTION_MENU (eas->option),
- menu);
- gtk_option_menu_set_history (GTK_OPTION_MENU (eas->option), 0);
- gtk_widget_set_sensitive (eas->option, TRUE);
-}
-
-static void
-e_addressbook_search_init (EAddressbookSearch *eas)
-{
- GtkWidget *spacer;
-
- gtk_box_set_spacing(GTK_BOX(eas), GNOME_PAD);
-
- eas->menubar = gtk_menu_bar_new();
- eas_pack_menubar(eas);
- gtk_widget_show(eas->menubar);
- gtk_box_pack_start(GTK_BOX(eas), eas->menubar, FALSE, FALSE, 0);
-
- eas->option = gtk_option_menu_new();
- eas_pack_option_menu(eas);
- gtk_widget_show(eas->option);
- gtk_box_pack_start(GTK_BOX(eas), eas->option, FALSE, FALSE, 0);
-
- eas->entry = gtk_entry_new();
- gtk_signal_connect (GTK_OBJECT (eas->entry), "activate",
- GTK_SIGNAL_FUNC (eas_entry_activated), eas);
- gtk_widget_show(eas->entry);
- gtk_box_pack_start(GTK_BOX(eas), eas->entry, TRUE, TRUE, 0);
- eas->option_choice = 0;
-
- spacer = gtk_drawing_area_new();
- gtk_widget_show(spacer);
- gtk_box_pack_start(GTK_BOX(eas), spacer, FALSE, FALSE, 0);
- gtk_widget_set_usize(spacer, 100, 1);
-}
-
-static void
-e_addressbook_search_destroy (GtkObject *object)
-{
- if (GTK_OBJECT_CLASS(parent_class)->destroy)
- GTK_OBJECT_CLASS(parent_class)->destroy(object);
-}
-
-GtkWidget*
-e_addressbook_search_new (void)
-{
- GtkWidget *widget = GTK_WIDGET (gtk_type_new (e_addressbook_search_get_type ()));
- return widget;
-}
-
-static void
-e_addressbook_search_get_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EAddressbookSearch *eas = E_ADDRESSBOOK_SEARCH(object);
-
- switch (arg_id) {
- case ARG_OPTION_CHOICE:
- GTK_VALUE_ENUM (*arg) = eas->option_choice;
- break;
-
- case ARG_TEXT:
- GTK_VALUE_STRING (*arg) = e_utf8_gtk_editable_get_text(GTK_EDITABLE(eas->entry));
- break;
-
- default:
- arg->type = GTK_TYPE_INVALID;
- break;
- }
-}
-
-static void
-e_addressbook_search_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
-{
- EAddressbookSearch *eas = E_ADDRESSBOOK_SEARCH(object);
-
- switch (arg_id) {
- case ARG_OPTION_CHOICE:
- eas->option_choice = GTK_VALUE_ENUM (*arg);
- gtk_option_menu_set_history (GTK_OPTION_MENU (eas->option), eas->option_choice);
- eas_query_changed(eas);
- break;
-
- case ARG_TEXT:
- e_utf8_gtk_editable_set_text(GTK_EDITABLE(eas->entry), GTK_VALUE_STRING (*arg));
- eas_query_changed(eas);
- break;
-
- default:
- break;
- }
-}
diff --git a/addressbook/gui/widgets/e-addressbook-search.h b/addressbook/gui/widgets/e-addressbook-search.h
deleted file mode 100644
index 5b229ee03e..0000000000
--- a/addressbook/gui/widgets/e-addressbook-search.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/* e-addressbook-search.h
- * Copyright (C) 2000 Helix Code, Inc.
- * Author: Chris Lahey <clahey@helixcode.com>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-#ifndef __E_ADDRESSBOOK_SEARCH_H__
-#define __E_ADDRESSBOOK_SEARCH_H__
-
-#include <gnome.h>
-#include "addressbook/backend/ebook/e-book.h"
-
-#ifdef __cplusplus
-extern "C" {
-#pragma }
-#endif /* __cplusplus */
-
-/* EAddressbookSearch - A card displaying information about a contact.
- *
- * The following arguments are available:
- *
- * name type read/write description
- * --------------------------------------------------------------------------------
- */
-
-#define E_ADDRESSBOOK_SEARCH_TYPE (e_addressbook_search_get_type ())
-#define E_ADDRESSBOOK_SEARCH(obj) (GTK_CHECK_CAST ((obj), E_ADDRESSBOOK_SEARCH_TYPE, EAddressbookSearch))
-#define E_ADDRESSBOOK_SEARCH_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), E_ADDRESSBOOK_SEARCH_TYPE, EAddressbookSearchClass))
-#define E_IS_ADDRESSBOOK_SEARCH(obj) (GTK_CHECK_TYPE ((obj), E_ADDRESSBOOK_SEARCH_TYPE))
-#define E_IS_ADDRESSBOOK_SEARCH_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), E_ADDRESSBOOK_SEARCH_TYPE))
-
-typedef enum {
- E_ADDRESSBOOK_SEARCH_NONE, /* initialized to this */
- E_ADDRESSBOOK_SEARCH_TABLE,
- E_ADDRESSBOOK_SEARCH_MINICARD
-} EAddressbookSearchType;
-
-
-typedef struct _EAddressbookSearch EAddressbookSearch;
-typedef struct _EAddressbookSearchClass EAddressbookSearchClass;
-
-struct _EAddressbookSearch
-{
- GtkHBox parent;
-
- /* item specific fields */
- GtkWidget *menubar;
- GtkWidget *option;
- GtkWidget *entry;
- int option_choice;
-};
-
-struct _EAddressbookSearchClass
-{
- GtkHBoxClass parent_class;
-
- void (*query_changed) (EAddressbookSearch *search);
- void (*menu_activated) (EAddressbookSearch *search, int item);
-};
-
-GtkWidget *e_addressbook_search_new (void);
-GtkType e_addressbook_search_get_type (void);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /* __E_ADDRESSBOOK_SEARCH_H__ */
diff --git a/addressbook/printing/e-contact-print-envelope.c b/addressbook/printing/e-contact-print-envelope.c
index c702728e4e..5a2c695582 100644
--- a/addressbook/printing/e-contact-print-envelope.c
+++ b/addressbook/printing/e-contact-print-envelope.c
@@ -114,6 +114,7 @@ static void
ecpe_linelist_print(GnomePrintContext *pc, GnomeFont *font, char *address, EcpeLine *linelist, double x, double y)
{
int i;
+ gnome_print_setfont(pc, font);
for (i = 0; linelist[i].length != -1; i++) {
gnome_print_moveto(pc, x, y + gnome_font_get_ascender(font));
gnome_print_show_sized (pc, address + linelist[i].start, linelist[i].length);