aboutsummaryrefslogtreecommitdiffstats
path: root/addressbook
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@ximian.com>2002-04-25 01:57:27 +0800
committerChris Lahey <clahey@src.gnome.org>2002-04-25 01:57:27 +0800
commit9678428593ad57ea4f802ff4b9ee1440c3f75605 (patch)
tree0a64d8d8550a5be4e055f069f88fb93ccbba303f /addressbook
parent38e985a2e4257006e6f0d1f0c1b2097a6394e888 (diff)
downloadgsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar.gz
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar.bz2
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar.lz
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar.xz
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.tar.zst
gsoc2013-evolution-9678428593ad57ea4f802ff4b9ee1440c3f75605.zip
Added a "Browse..." button to switch to a different addressbook folder.
2002-04-24 Christopher James Lahey <clahey@ximian.com> * gui/component/select-names/e-select-names.c, gui/component/select-names/e-select-names.h, gui/component/select-names/select-names.glade (folder_browse): Added a "Browse..." button to switch to a different addressbook folder. * gui/widgets/e-addressbook-util.c (e_addressbook_transfer_cards): Moved extern EvolutionShellClient out of this function so that it'd be more readable. svn path=/trunk/; revision=16574
Diffstat (limited to 'addressbook')
-rw-r--r--addressbook/ChangeLog12
-rw-r--r--addressbook/gui/component/select-names/e-select-names.c85
-rw-r--r--addressbook/gui/component/select-names/e-select-names.h3
-rw-r--r--addressbook/gui/component/select-names/select-names.glade26
-rw-r--r--addressbook/gui/widgets/e-addressbook-util.c3
5 files changed, 112 insertions, 17 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog
index 29e25d0b5e..ab522330b1 100644
--- a/addressbook/ChangeLog
+++ b/addressbook/ChangeLog
@@ -1,3 +1,15 @@
+2002-04-24 Christopher James Lahey <clahey@ximian.com>
+
+ * gui/component/select-names/e-select-names.c,
+ gui/component/select-names/e-select-names.h,
+ gui/component/select-names/select-names.glade (folder_browse):
+ Added a "Browse..." button to switch to a different addressbook
+ folder.
+
+ * gui/widgets/e-addressbook-util.c (e_addressbook_transfer_cards):
+ Moved extern EvolutionShellClient out of this function so that
+ it'd be more readable.
+
2002-04-23 Christopher James Lahey <clahey@ximian.com>
* gui/component/select-names/e-select-names.c,
diff --git a/addressbook/gui/component/select-names/e-select-names.c b/addressbook/gui/component/select-names/e-select-names.c
index 2cb4409b18..782905de23 100644
--- a/addressbook/gui/component/select-names/e-select-names.c
+++ b/addressbook/gui/component/select-names/e-select-names.c
@@ -72,6 +72,15 @@ typedef struct {
GtkWidget *label;
} ESelectNamesChild;
+struct _ESelectNamesFolder {
+ char *description;
+ char *display_name;
+ char *uri;
+ char *physicalUri;
+ char *path;
+ int count;
+};
+
GtkType
e_select_names_get_type (void)
{
@@ -152,7 +161,7 @@ set_book_with_model_data(EBook *book, EBookStatus status, EAddressbookModel *mod
}
static void
-addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model, char *uri)
+addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model, const char *uri, ESelectNamesFolder *e_folder)
{
EBook *book;
@@ -169,6 +178,7 @@ addressbook_model_set_uri(ESelectNames *e_select_names, EAddressbookModel *model
gtk_object_ref(GTK_OBJECT(e_select_names));
gtk_object_ref(GTK_OBJECT(model));
addressbook_load_uri(book, uri, (EBookCallback) set_book, e_select_names);
+ e_select_names->current_folder = e_folder;
} else {
gtk_object_ref(GTK_OBJECT(model));
addressbook_load_uri(book, uri, (EBookCallback) set_book_with_model_data, model);
@@ -308,7 +318,7 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n
filename = gnome_util_prepend_user_home("evolution/local/Contacts/addressbook.db");
uri = g_strdup_printf("file://%s", filename);
- addressbook_model_set_uri(NULL, model, uri);
+ addressbook_model_set_uri(NULL, model, uri, NULL);
g_free(uri);
g_free(filename);
@@ -337,19 +347,14 @@ e_addressbook_create_ebook_table(char *name, char *string1, char *string2, int n
return table;
}
-typedef struct {
- char *description;
- char *display_name;
- char *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->uri);
+ g_free(e_folder->physicalUri);
+ g_free(e_folder->path);
g_free(e_folder);
}
@@ -358,12 +363,13 @@ 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, e_select_names->model, e_folder->uri);
+ addressbook_model_set_uri(e_select_names, e_select_names->model, e_folder->uri, e_folder);
}
typedef struct {
ESelectNames *names;
GtkWidget *menu;
+ int count;
} NamesAndMenu;
static void
@@ -393,6 +399,8 @@ add_menu_item (gpointer key,
gtk_signal_connect (GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (e_select_names_option_activated),
e_select_names);
+
+ e_folder->count = nnm->count++;
}
static void
@@ -409,6 +417,7 @@ update_option_menu(ESelectNames *e_select_names)
nnm.names = e_select_names;
nnm.menu = menu;
+ nnm.count = 0;
g_hash_table_foreach (e_select_names->folders,
add_menu_item,
@@ -442,8 +451,13 @@ new_folder (EvolutionStorageListener *storage_listener,
e_folder->uri = g_strdup_printf ("%s/addressbook.db", folder->physicalUri);
else
e_folder->uri = g_strdup(folder->physicalUri);
+ e_folder->physicalUri = g_strdup(folder->physicalUri);
+ e_folder->path = g_strdup (path);
+ e_folder->count = -1;
g_hash_table_insert(e_select_names->folders,
- g_strdup(path), e_folder);
+ e_folder->path, e_folder);
+ g_hash_table_insert(e_select_names->folders_by_uri,
+ e_folder->physicalUri, e_folder);
update_option_menu(e_select_names);
}
}
@@ -454,12 +468,12 @@ removed_folder (EvolutionStorageListener *storage_listener,
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)) {
+ if ((e_folder = g_hash_table_lookup(e_select_names->folders, path))) {
+ g_hash_table_remove(e_select_names->folders_by_uri,
+ e_folder->physicalUri);
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);
}
}
@@ -548,6 +562,41 @@ select_entry_changed (GtkWidget *widget, ESelectNames *e_select_names)
}
}
+extern EvolutionShellClient *global_shell_client;
+
+static void
+folder_browse (GtkWidget *widget, ESelectNames *e_select_names)
+{
+ const char *allowed_types[] = { "contacts", NULL };
+ GNOME_Evolution_Folder *folder;
+ const char *current_uri = "";
+ ESelectNamesFolder *e_folder;
+
+ if (e_select_names->current_folder && e_select_names->current_folder->physicalUri) {
+ current_uri = e_select_names->current_folder->physicalUri;
+ }
+
+ evolution_shell_client_user_select_folder (global_shell_client,
+ GTK_WINDOW (gtk_widget_get_toplevel (widget)),
+ _("Find contact in"), current_uri,
+ allowed_types,
+ &folder);
+ if (!folder)
+ return;
+
+ if ((e_folder = g_hash_table_lookup(e_select_names->folders_by_uri, folder->physicalUri))) {
+ GtkWidget *option;
+
+ option = glade_xml_get_widget (e_select_names->gui,
+ "optionmenu-folder");
+ if (e_folder->count != -1 && option) {
+ gtk_option_menu_set_history (GTK_OPTION_MENU (option), e_folder->count);
+ }
+
+ addressbook_model_set_uri(e_select_names, e_select_names->model, e_folder->uri, e_folder);
+ }
+}
+
static void
hookup_listener (ESelectNames *e_select_names,
@@ -769,7 +818,13 @@ e_select_names_init (ESelectNames *e_select_names)
gtk_signal_connect(GTK_OBJECT(button), "clicked",
GTK_SIGNAL_FUNC(update_query), e_select_names);
+ button = glade_xml_get_widget (gui, "button-browse");
+ if (button && GTK_IS_BUTTON (button))
+ gtk_signal_connect(GTK_OBJECT(button), "clicked",
+ GTK_SIGNAL_FUNC(folder_browse), e_select_names);
+
e_select_names->folders = g_hash_table_new(g_str_hash, g_str_equal);
+ e_select_names->folders_by_uri = g_hash_table_new(g_str_hash, g_str_equal);
e_select_names_hookup_shell_listeners (e_select_names);
@@ -804,6 +859,8 @@ e_select_names_destroy (GtkObject *object)
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);
+ g_hash_table_destroy(e_select_names->folders);
+ g_hash_table_destroy(e_select_names->folders_by_uri);
g_free(e_select_names->def);
}
diff --git a/addressbook/gui/component/select-names/e-select-names.h b/addressbook/gui/component/select-names/e-select-names.h
index 90b0229766..443784ee9e 100644
--- a/addressbook/gui/component/select-names/e-select-names.h
+++ b/addressbook/gui/component/select-names/e-select-names.h
@@ -56,6 +56,7 @@ extern "C" {
typedef struct _ESelectNames ESelectNames;
typedef struct _ESelectNamesClass ESelectNamesClass;
+typedef struct _ESelectNamesFolder ESelectNamesFolder;
struct _ESelectNames
{
@@ -77,7 +78,9 @@ struct _ESelectNames
EvolutionStorageListener *local_listener;
EvolutionStorageListener *other_contacts_listener;
GHashTable *folders;
+ GHashTable *folders_by_uri;
char *def;
+ ESelectNamesFolder *current_folder;
};
struct _ESelectNamesClass
diff --git a/addressbook/gui/component/select-names/select-names.glade b/addressbook/gui/component/select-names/select-names.glade
index 2a6f1960c9..59c8d31364 100644
--- a/addressbook/gui/component/select-names/select-names.glade
+++ b/addressbook/gui/component/select-names/select-names.glade
@@ -137,7 +137,7 @@
<name>table5</name>
<border_width>3</border_width>
<rows>2</rows>
- <columns>2</columns>
+ <columns>3</columns>
<homogeneous>False</homogeneous>
<row_spacing>3</row_spacing>
<column_spacing>3</column_spacing>
@@ -226,7 +226,7 @@
<last_modification_time>Tue, 19 Feb 2002 23:06:24 GMT</last_modification_time>
<child>
<left_attach>1</left_attach>
- <right_attach>2</right_attach>
+ <right_attach>3</right_attach>
<top_attach>1</top_attach>
<bottom_attach>2</bottom_attach>
<xpad>0</xpad>
@@ -239,6 +239,28 @@
<yfill>True</yfill>
</child>
</widget>
+
+ <widget>
+ <class>GtkButton</class>
+ <name>button-browse</name>
+ <can_focus>True</can_focus>
+ <label>_Browse...</label>
+ <relief>GTK_RELIEF_NORMAL</relief>
+ <child>
+ <left_attach>2</left_attach>
+ <right_attach>3</right_attach>
+ <top_attach>0</top_attach>
+ <bottom_attach>1</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>
diff --git a/addressbook/gui/widgets/e-addressbook-util.c b/addressbook/gui/widgets/e-addressbook-util.c
index 13d219af33..b1c40bd483 100644
--- a/addressbook/gui/widgets/e-addressbook-util.c
+++ b/addressbook/gui/widgets/e-addressbook-util.c
@@ -322,11 +322,12 @@ got_book_cb (EBook *book, gpointer closure)
process_unref (process);
}
+extern EvolutionShellClient *global_shell_client;
+
void
e_addressbook_transfer_cards (EBook *source, GList *cards /* adopted */, gboolean delete_from_source, GtkWindow *parent_window)
{
const char *allowed_types[] = { "contacts", NULL };
- extern EvolutionShellClient *global_shell_client;
GNOME_Evolution_Folder *folder;
static char *last_uri = NULL;
CardCopyProcess *process;