From cb8fd3a3304144f2d6c6c9842d00af6ac9ec3910 Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Mon, 31 Mar 2003 15:43:49 +0000 Subject: Remove folder-selector button initialization. (e_select_names_new): * gui/component/select-names/e-select-names.c (e_select_names_init): Remove folder-selector button initialization. (e_select_names_new): Initialize folder-selector button here, using the passed-in EvolutionShellClient rather than depending on a global variable. * gui/component/select-names/e-select-names-manager.c (e_select_names_manager_activate_dialog): take an EvolutionShellClient and pass it to e_select_names_new(). * gui/component/select-names/e-select-names-bonobo.c (impl_SelectNames_activate_dialog): get a pointer to the shell from bonobo-activation, create a shell_client, and pass it to e_select_names_manager_activate_dialog. svn path=/trunk/; revision=20597 --- .../component/select-names/e-select-names-bonobo.c | 19 ++++- .../select-names/e-select-names-manager.c | 6 +- .../select-names/e-select-names-manager.h | 1 + .../gui/component/select-names/e-select-names.c | 80 +++++++++------------- .../gui/component/select-names/e-select-names.h | 18 ++--- 5 files changed, 63 insertions(+), 61 deletions(-) (limited to 'addressbook/gui') diff --git a/addressbook/gui/component/select-names/e-select-names-bonobo.c b/addressbook/gui/component/select-names/e-select-names-bonobo.c index c98af87683..0f18614c1a 100644 --- a/addressbook/gui/component/select-names/e-select-names-bonobo.c +++ b/addressbook/gui/component/select-names/e-select-names-bonobo.c @@ -27,13 +27,18 @@ #include "e-select-names-bonobo.h" #include "e-simple-card-bonobo.h" +#include + #include #include +#include #include #include #include +#include "evolution-shell-client.h" + #include "Evolution-Addressbook-SelectNames.h" #include "e-select-names-manager.h" @@ -359,11 +364,23 @@ impl_SelectNames_activate_dialog (PortableServer_Servant servant, { ESelectNamesBonobo *select_names; ESelectNamesBonoboPrivate *priv; + EvolutionShellClient *shell_client; + GNOME_Evolution_Shell shell; select_names = E_SELECT_NAMES_BONOBO (bonobo_object (servant)); priv = select_names->priv; - e_select_names_manager_activate_dialog (priv->manager, section_id); + shell = bonobo_activation_activate_from_id ( + "OAFIID:GNOME_Evolution_Shell", + Bonobo_ACTIVATION_FLAG_EXISTING_ONLY, + NULL, ev); + if (BONOBO_EX (ev)) + return; + + shell_client = evolution_shell_client_new (shell); + e_select_names_manager_activate_dialog (priv->manager, shell_client, + section_id); + g_object_unref (shell_client); } diff --git a/addressbook/gui/component/select-names/e-select-names-manager.c b/addressbook/gui/component/select-names/e-select-names-manager.c index 98e1ff5a2c..b53cf924f2 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.c +++ b/addressbook/gui/component/select-names/e-select-names-manager.c @@ -476,9 +476,8 @@ db_listener (EConfigListener *db, const char *key, /** * e_select_names_manager_new: - * @VCard: a string in vCard format * - * Returns: a new #ESelectNamesManager that wraps the @VCard. + * Returns: a new #ESelectNamesManager */ ESelectNamesManager * e_select_names_manager_new (void) @@ -605,6 +604,7 @@ clear_widget (gpointer data, GObject *where_object_was) void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, + EvolutionShellClient *shell_client, const char *id) { g_return_if_fail (E_IS_SELECT_NAMES_MANAGER (manager)); @@ -621,7 +621,7 @@ e_select_names_manager_activate_dialog (ESelectNamesManager *manager, GList *iter; - manager->names = E_SELECT_NAMES (e_select_names_new ()); + manager->names = E_SELECT_NAMES (e_select_names_new (shell_client)); for (iter = manager->sections; iter != NULL; iter = g_list_next (iter)) { ESelectNamesManagerSection *section = iter->data; diff --git a/addressbook/gui/component/select-names/e-select-names-manager.h b/addressbook/gui/component/select-names/e-select-names-manager.h index f5fb4aa451..b48f597cb3 100644 --- a/addressbook/gui/component/select-names/e-select-names-manager.h +++ b/addressbook/gui/component/select-names/e-select-names-manager.h @@ -62,6 +62,7 @@ ESelectNamesModel *e_select_names_manager_get_source (ESelectNames GtkWidget *e_select_names_manager_create_entry (ESelectNamesManager *manager, const char *id); void e_select_names_manager_activate_dialog (ESelectNamesManager *manager, + EvolutionShellClient *shell_client, const char *id); /* Standard Gtk function */ GType e_select_names_manager_get_type (void); diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c index 7de212b8fc..a189077c92 100644 --- a/addressbook/gui/component/select-names/e-select-names.c +++ b/addressbook/gui/component/select-names/e-select-names.c @@ -48,15 +48,13 @@ #include #include "e-util/e-sexp.h" -static void e_select_names_init (ESelectNames *card); +static void e_select_names_init (ESelectNames *names); static void e_select_names_class_init (ESelectNamesClass *klass); static void e_select_names_dispose (GObject *object); static void update_query (GtkWidget *widget, ESelectNames *e_select_names); static void sync_table_and_models (ESelectNamesModel *triggering_model, ESelectNames *esl); -extern EvolutionShellClient *global_shell_client; - static GtkDialogClass *parent_class = NULL; #define PARENT_TYPE gtk_dialog_get_type() @@ -478,12 +476,6 @@ e_select_names_init (ESelectNames *e_select_names) { GladeXML *gui; GtkWidget *widget, *button; - const char *selector_types[] = { "contacts/*", NULL }; - char *filename; - char *contacts_uri; - EConfigListener *db; - - db = e_book_get_config_database(); gui = glade_xml_new (EVOLUTION_GLADEDIR "/select-names.glade", NULL, NULL); e_select_names->gui = gui; @@ -559,25 +551,7 @@ e_select_names_init (ESelectNames *e_select_names) g_signal_connect(button, "clicked", G_CALLBACK(update_query), e_select_names); - contacts_uri = e_config_listener_get_string_with_default (db, "/apps/evolution/addressbook/select_names/last_used_uri", NULL, NULL); - if (!contacts_uri) { - contacts_uri = e_config_listener_get_string_with_default (db, "/apps/evolution/shell/default_folders/contacts_uri", - NULL, NULL); - } - if (!contacts_uri || !contacts_uri[0]) { - if (contacts_uri) - g_free (contacts_uri); - filename = g_build_filename (g_get_home_dir(), "evolution/local/Contacts", NULL); - contacts_uri = g_strdup_printf("file://%s", filename); - g_free (filename); - } - button = glade_xml_get_widget (gui, "folder-selector"); - evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button), - global_shell_client, - _("Find contact in"), - contacts_uri, - selector_types); if (button && EVOLUTION_IS_FOLDER_SELECTOR_BUTTON (button)) g_signal_connect(button, "selected", G_CALLBACK(folder_selected), e_select_names); @@ -588,10 +562,6 @@ e_select_names_init (ESelectNames *e_select_names) g_signal_connect (e_table_scrolled_get_table (e_select_names->table), "selection_change", G_CALLBACK (selection_change), e_select_names); selection_change (e_table_scrolled_get_table (e_select_names->table), e_select_names); - - addressbook_model_set_uri(e_select_names, e_select_names->model, contacts_uri); - - g_free (contacts_uri); } static void e_select_names_child_free(char *key, ESelectNamesChild *child, ESelectNames *e_select_names) @@ -656,10 +626,35 @@ e_select_names_dispose (GObject *object) } GtkWidget* -e_select_names_new (void) +e_select_names_new (EvolutionShellClient *shell_client) { - GtkWidget *widget = g_object_new (E_TYPE_SELECT_NAMES, NULL); - return widget; + ESelectNames *e_select_names; + const char *selector_types[] = { "contacts/*", NULL }; + char *contacts_uri; + GtkWidget *button; + EConfigListener *db; + + e_select_names = g_object_new (E_TYPE_SELECT_NAMES, NULL); + + db = e_book_get_config_database (); + contacts_uri = e_config_listener_get_string_with_default ( + db, "/apps/evolution/addressbook/select_names/last_used_uri", + NULL, NULL); + if (!contacts_uri) + contacts_uri = g_strdup (e_book_get_default_book_uri ()); + + button = glade_xml_get_widget (e_select_names->gui, "folder-selector"); + evolution_folder_selector_button_construct (EVOLUTION_FOLDER_SELECTOR_BUTTON (button), + shell_client, + _("Find contact in"), + contacts_uri, + selector_types); + + addressbook_model_set_uri(e_select_names, e_select_names->model, contacts_uri); + + g_free (contacts_uri); + + return GTK_WIDGET (e_select_names); } static void @@ -707,7 +702,9 @@ section_right_click_cb (ETable *et, int row, int col, GdkEvent *ev, ESelectNames } void -e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, ESelectNamesModel *source) +e_select_names_add_section (ESelectNames *e_select_names, + const char *name, const char *id, + ESelectNamesModel *source) { ESelectNamesChild *child; GtkWidget *button; @@ -814,19 +811,6 @@ e_select_names_add_section(ESelectNames *e_select_names, char *name, char *id, E sync_table_and_models (child->source, e_select_names); } -static void * -card_copy(const void *value, void *closure) -{ - g_object_ref((gpointer)value); - return (void *)value; -} - -static void -card_free(void *value, void *closure) -{ - g_object_unref((gpointer)value); -} - void e_select_names_set_default (ESelectNames *e_select_names, const char *id) diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h index 609aa00f01..8e672da92a 100644 --- a/addressbook/gui/component/select-names/e-select-names.h +++ b/addressbook/gui/component/select-names/e-select-names.h @@ -27,10 +27,10 @@ #include #include -#include +#include "evolution-shell-client.h" +#include "e-addressbook-model.h" #include "e-select-names-model.h" -#include "e-util/e-list.h" #ifdef __cplusplus extern "C" { @@ -85,15 +85,15 @@ struct _ESelectNamesClass }; -GtkWidget *e_select_names_new (void); +GtkWidget *e_select_names_new (EvolutionShellClient *shell_client); GType e_select_names_get_type (void); -void e_select_names_add_section (ESelectNames *e_select_names, - char *name, - char *id, - ESelectNamesModel *source); -void e_select_names_set_default (ESelectNames *e_select_names, - const char *id); +void e_select_names_add_section (ESelectNames *e_select_names, + const char *name, + const char *id, + ESelectNamesModel *source); +void e_select_names_set_default (ESelectNames *e_select_names, + const char *id); #ifdef __cplusplus } -- cgit