diff options
author | Christopher James Lahey <clahey@helixcode.com> | 2001-01-05 07:20:44 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-01-05 07:20:44 +0800 |
commit | 3596cc5df5ac3e995a61e68bf2d61053688dbf7e (patch) | |
tree | e3fe6f6ebedcc7d0cbc7a266e178f353979cab40 /addressbook | |
parent | 5ff5cd81532edda57a0793273fee0cdadef07dd9 (diff) | |
download | gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar.gz gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar.bz2 gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar.lz gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar.xz gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.tar.zst gsoc2013-evolution-3596cc5df5ac3e995a61e68bf2d61053688dbf7e.zip |
Added this function.
2001-01-04 Christopher James Lahey <clahey@helixcode.com>
* gui/component/addressbook-component.c,
gui/component/addressbook-component.h
(addressbook_component_get_shell_client): Added this function.
* gui/component/select-names/e-select-names.c,
gui/component/select-names/e-select-names.h: Added code for the
ability to switch between different folders. This doesn't work
yet.
* gui/component/select-names/select-names.glade,
gui/component/select-names/select-names.glade.h: Added an option
menu to this dialog.
svn path=/trunk/; revision=7262
Diffstat (limited to 'addressbook')
-rw-r--r-- | addressbook/ChangeLog | 15 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-component.c | 8 | ||||
-rw-r--r-- | addressbook/gui/component/addressbook-component.h | 6 | ||||
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names.c | 200 | ||||
-rw-r--r-- | addressbook/gui/component/select-names/e-select-names.h | 4 | ||||
-rw-r--r-- | addressbook/gui/component/select-names/select-names.glade | 39 | ||||
-rw-r--r-- | addressbook/gui/component/select-names/select-names.glade.h | 8 |
7 files changed, 259 insertions, 21 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 1138adf072..9ee2d4b6bd 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,18 @@ +2001-01-04 Christopher James Lahey <clahey@helixcode.com> + + * gui/component/addressbook-component.c, + gui/component/addressbook-component.h + (addressbook_component_get_shell_client): Added this function. + + * gui/component/select-names/e-select-names.c, + gui/component/select-names/e-select-names.h: Added code for the + ability to switch between different folders. This doesn't work + yet. + + * gui/component/select-names/select-names.glade, + gui/component/select-names/select-names.glade.h: Added an option + menu to this dialog. + 2001-01-04 JP Rosevear <jpr@helixcode.com> * conduit/Makefile.am: Fix hard coded library names that were diff --git a/addressbook/gui/component/addressbook-component.c b/addressbook/gui/component/addressbook-component.c index 209c965e8d..934496418c 100644 --- a/addressbook/gui/component/addressbook-component.c +++ b/addressbook/gui/component/addressbook-component.c @@ -38,10 +38,14 @@ #define GNOME_EVOLUTION_ADDRESSBOOK_COMPONENT_FACTORY_ID "OAFIID:GNOME_Evolution_Addressbook_ShellComponentFactory" -/* Nasty hack for filters to be able to find folders */ -/* Not even used with addressbook??? */ EvolutionShellClient *global_shell_client; +EvolutionShellClient * +addressbook_component_get_shell_client (void) +{ + return global_shell_client; +} + static BonoboGenericFactory *factory = NULL; static const EvolutionShellComponentFolderType folder_types[] = { diff --git a/addressbook/gui/component/addressbook-component.h b/addressbook/gui/component/addressbook-component.h index ec37da694a..ea0d8b9a46 100644 --- a/addressbook/gui/component/addressbook-component.h +++ b/addressbook/gui/component/addressbook-component.h @@ -24,6 +24,10 @@ #ifndef _ADDRESSBOOK_COMPONENT_H #define _ADDRESSBOOK_COMPONENT_H -void addressbook_component_factory_init (void); +#include "evolution-shell-component.h" +#include "evolution-storage.h" + +void addressbook_component_factory_init (void); +EvolutionShellClient *addressbook_component_get_shell_client (void); #endif /* _ADDRESSBOOK_COMPONENT_H */ diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index bfce088bdf..f25b385485 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -27,6 +27,8 @@ #include <addressbook/gui/component/e-cardlist-model.h> #include <addressbook/backend/ebook/e-book.h> #include "e-select-names-table-model.h" +#include <shell/evolution-shell-client.h> +#include <addressbook/gui/component/addressbook-component.h> static void e_select_names_init (ESelectNames *card); static void e_select_names_class_init (ESelectNamesClass *klass); @@ -110,16 +112,24 @@ set_book(EBook *book, EBookStatus status, ETableModel *model) { gtk_object_set(GTK_OBJECT(model), "book", book, - "query", "(contains \"email\" \"\")", NULL); gtk_object_unref(GTK_OBJECT(book)); } +static void +addressbook_model_set_uri(ETableModel *model, char *uri) +{ + EBook *book; + book = e_book_new(); + gtk_object_ref(GTK_OBJECT(model)); + gtk_object_ref(GTK_OBJECT(book)); + e_book_load_uri(book, uri, (EBookCallback) set_book, model); +} + GtkWidget * e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int num1, int num2) { ETableModel *model; - EBook *book; GtkWidget *table; char *filename; char *uri; @@ -127,14 +137,15 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n model = e_addressbook_model_new(); gtk_object_set(GTK_OBJECT(model), "editable", FALSE, + "query", "(contains \"email\" \"\")", NULL); - book = e_book_new(); - gtk_object_ref(GTK_OBJECT(model)); - gtk_object_ref(GTK_OBJECT(book)); + filename = gnome_util_prepend_user_home("evolution/local/Contacts/addressbook.db"); uri = g_strdup_printf("file://%s", filename); - e_book_load_uri(book, uri, (EBookCallback) set_book, model); + + addressbook_model_set_uri(model, uri); + g_free(uri); g_free(filename); table = e_table_scrolled_new (model, NULL, SPEC, NULL); @@ -147,6 +158,176 @@ static void set_current_selection(ETableScrolled *table, int row, ESelectNames *names) { names->currently_selected = row; + +} + +typedef struct { + char *description; + char *display_name; + char *physical_uri; + +} ESelectNamesFolder; + +static void +e_select_names_folder_free(ESelectNamesFolder *e_folder) +{ + g_free(e_folder->description ); + g_free(e_folder->display_name); + g_free(e_folder->physical_uri); + g_free(e_folder); +} + +static void +e_select_names_option_activated(GtkWidget *widget, ESelectNames *e_select_names) +{ + ESelectNamesFolder *e_folder = gtk_object_get_data (GTK_OBJECT (widget), "EsnChoiceFolder"); + + addressbook_model_set_uri(e_select_names->model, e_folder->physical_uri); +} + +typedef struct { + ESelectNames *names; + GtkWidget *menu; +} NamesAndMenu; + +static void +add_menu_item (gpointer key, + gpointer value, + gpointer user_data) +{ + GtkWidget *menu; + GtkWidget *item; + ESelectNamesFolder *e_folder; + NamesAndMenu *nnm; + ESelectNames *e_select_names; + + nnm = user_data; + e_folder = value; + menu = nnm->menu; + e_select_names = nnm->names; + + item = gtk_menu_item_new_with_label (e_folder->display_name); + gtk_menu_append (GTK_MENU (menu), item); + gtk_object_set_data (GTK_OBJECT (item), "EsnChoiceFolder", e_folder); + + gtk_signal_connect (GTK_OBJECT (item), "activate", + GTK_SIGNAL_FUNC (e_select_names_option_activated), + e_select_names); +} + +static void +update_option_menu(ESelectNames *e_select_names) +{ + GtkWidget *menu; + GtkWidget *option; + + option = glade_xml_get_widget (e_select_names->gui, + "optionmenu-folder"); + if (option) { + NamesAndMenu nnm; + menu = gtk_menu_new (); + + nnm.names = e_select_names; + nnm.menu = menu; + + g_hash_table_foreach (e_select_names->folders, + add_menu_item, + &nnm); + + gtk_widget_show_all (menu); + + gtk_option_menu_set_menu (GTK_OPTION_MENU (option), + menu); + gtk_option_menu_set_history (GTK_OPTION_MENU (option), 0); + gtk_widget_set_sensitive (option, TRUE); + } +} + +static void +new_folder (EvolutionStorageListener *storage_listener, + const char *path, + const GNOME_Evolution_Folder *folder, + ESelectNames *e_select_names) +{ + if (!strcmp(folder->type, "contacts")) { + ESelectNamesFolder *e_folder = g_new(ESelectNamesFolder, 1); + e_folder->description = g_strdup(folder->description ); + e_folder->display_name = g_strdup(folder->display_name); + e_folder->physical_uri = g_strdup(folder->physical_uri); + g_hash_table_insert(e_select_names->folders, + g_strdup(path), e_folder); + update_option_menu(e_select_names); + } +} + +static void +update_folder (EvolutionStorageListener *storage_listener, + const char *path, + const char *display_name, + ESelectNames *e_select_names) +{ + ESelectNamesFolder *e_folder = g_hash_table_lookup(e_select_names->folders, path); + if (e_folder) { + g_free(e_folder->display_name); + e_folder->display_name = g_strdup(e_folder->display_name); + update_option_menu(e_select_names); + } +} + +static void +removed_folder (EvolutionStorageListener *storage_listener, + const char *path, + ESelectNames *e_select_names) +{ + ESelectNamesFolder *e_folder; + char *orig_path; + + if (g_hash_table_lookup_extended(e_select_names->folders, path, (void **) &orig_path, (void **) &e_folder)) { + g_hash_table_remove(e_select_names->folders, path); + e_select_names_folder_free(e_folder); + g_free(orig_path); + update_option_menu(e_select_names); + } +} + +static void +e_select_names_hookup_shell_listener (ESelectNames *e_select_names) +{ + GNOME_Evolution_Storage storage; + GNOME_Evolution_StorageListener listener; + CORBA_Environment ev; + + CORBA_exception_init(&ev); + + storage = (GNOME_Evolution_Storage) (evolution_shell_client_get_local_storage(addressbook_component_get_shell_client())); + e_select_names->listener = evolution_storage_listener_new(); + + listener = evolution_storage_listener_corba_objref(e_select_names->listener); + + gtk_signal_connect(GTK_OBJECT(e_select_names->listener), "new_folder", + GTK_SIGNAL_FUNC(new_folder), e_select_names); + gtk_signal_connect(GTK_OBJECT(e_select_names->listener), "update_folder", + GTK_SIGNAL_FUNC(update_folder), e_select_names); + gtk_signal_connect(GTK_OBJECT(e_select_names->listener), "removed_folder", + GTK_SIGNAL_FUNC(removed_folder), e_select_names); + + GNOME_Evolution_Storage_addListener(storage, listener, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("e_select_names_init: Exception adding listener to " + "remote GNOME_Evolution_Storage interface.\n"); + CORBA_exception_free (&ev); + return; + } + + bonobo_object_release_unref(storage, &ev); + if (ev._major != CORBA_NO_EXCEPTION) { + g_warning ("e_select_names_init: Exception unref'ing " + "remote GNOME_Evolution_Storage interface.\n"); + CORBA_exception_free (&ev); + return; + } + + CORBA_exception_free(&ev); } static void @@ -182,6 +363,10 @@ e_select_names_init (ESelectNames *e_select_names) e_select_names->currently_selected = -1; + e_select_names->folders = g_hash_table_new(g_str_hash, g_str_equal); + + e_select_names_hookup_shell_listener (e_select_names); + gtk_signal_connect(GTK_OBJECT(e_table_scrolled_get_table(e_select_names->table)), "cursor_change", GTK_SIGNAL_FUNC(set_current_selection), e_select_names); } @@ -198,6 +383,9 @@ static void e_select_names_destroy (GtkObject *object) { ESelectNames *e_select_names = E_SELECT_NAMES(object); + gtk_signal_disconnect_by_data(GTK_OBJECT(e_select_names->listener), e_select_names); + gtk_object_unref(GTK_OBJECT(e_select_names->listener)); + gtk_object_unref(GTK_OBJECT(e_select_names->gui)); g_hash_table_foreach(e_select_names->children, (GHFunc) e_select_names_child_free, e_select_names); g_hash_table_destroy(e_select_names->children); diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h index dba100e8f0..ce89791861 100644 --- a/addressbook/gui/component/select-names/e-select-names.h +++ b/addressbook/gui/component/select-names/e-select-names.h @@ -28,6 +28,8 @@ #include <gal/e-table/e-table-scrolled.h> #include "e-select-names-model.h" +#include <shell/evolution-storage-listener.h> + #ifdef __cplusplus extern "C" { #pragma } @@ -62,6 +64,8 @@ struct _ESelectNames ETableScrolled *table; ETableModel *model; int currently_selected; + EvolutionStorageListener *listener; + GHashTable *folders; }; struct _ESelectNamesClass diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade index 90ca93bd3a..063d39c1fa 100644 --- a/addressbook/gui/component/select-names/select-names.glade +++ b/addressbook/gui/component/select-names/select-names.glade @@ -80,7 +80,7 @@ <widget> <class>GtkTable</class> <name>table-top</name> - <rows>3</rows> + <rows>4</rows> <columns>2</columns> <homogeneous>False</homogeneous> <row_spacing>6</row_spacing> @@ -99,8 +99,8 @@ <child> <left_attach>0</left_attach> <right_attach>1</right_attach> - <top_attach>1</top_attach> - <bottom_attach>2</bottom_attach> + <top_attach>2</top_attach> + <bottom_attach>3</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>True</xexpand> @@ -134,6 +134,7 @@ <visible>False</visible> <can_focus>True</can_focus> <label>Find...</label> + <relief>GTK_RELIEF_NORMAL</relief> <child> <padding>0</padding> <expand>False</expand> @@ -145,7 +146,7 @@ <widget> <class>GtkAccelLabel</class> <name>accellabel1</name> - <label>Select name from List:</label> + <label>Select name from:</label> <justify>GTK_JUSTIFY_LEFT</justify> <wrap>False</wrap> <xalign>0</xalign> @@ -178,8 +179,8 @@ <child> <left_attach>0</left_attach> <right_attach>1</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>True</xexpand> @@ -202,8 +203,8 @@ <child> <left_attach>1</left_attach> <right_attach>2</right_attach> - <top_attach>2</top_attach> - <bottom_attach>3</bottom_attach> + <top_attach>3</top_attach> + <bottom_attach>4</bottom_attach> <xpad>0</xpad> <ypad>0</ypad> <xexpand>True</xexpand> @@ -240,6 +241,28 @@ </child> </widget> </widget> + + <widget> + <class>GtkOptionMenu</class> + <name>optionmenu1</name> + <can_focus>True</can_focus> + <items></items> + <initial_choice>0</initial_choice> + <child> + <left_attach>0</left_attach> + <right_attach>1</right_attach> + <top_attach>1</top_attach> + <bottom_attach>2</bottom_attach> + <xpad>0</xpad> + <ypad>0</ypad> + <xexpand>False</xexpand> + <yexpand>False</yexpand> + <xshrink>False</xshrink> + <yshrink>False</yshrink> + <xfill>True</xfill> + <yfill>False</yfill> + </child> + </widget> </widget> </widget> </widget> diff --git a/addressbook/gui/component/select-names/select-names.glade.h b/addressbook/gui/component/select-names/select-names.glade.h index 6ef09ad7c2..432ceac23d 100644 --- a/addressbook/gui/component/select-names/select-names.glade.h +++ b/addressbook/gui/component/select-names/select-names.glade.h @@ -1,10 +1,10 @@ /* - * Translatable strings file generated by extract-ui. - * Add this file to your project's POTFILES.in + * Translatable strings file generated by Glade. + * Add this file to your project's POTFILES.in. * DO NOT compile it as part of your application. */ +gchar *s = N_("Select Names"); gchar *s = N_("Find..."); +gchar *s = N_("Select name from:"); gchar *s = N_("Message Recipients"); -gchar *s = N_("Select Names"); -gchar *s = N_("Select name from List:"); |