[contacts] Add a "--uid" option that sets the selected contact on startup
- From: Rob Bradford <rbradford src gnome org>
- To: svn-commits-list gnome org
- Subject: [contacts] Add a "--uid" option that sets the selected contact on startup
- Date: Mon, 8 Jun 2009 11:17:57 -0400 (EDT)
commit 00577366770b195a155cc1fb202b347f70a00c5c
Author: Rob Bradford <rob linux intel com>
Date: Mon Jun 8 15:35:02 2009 +0100
Add a "--uid" option that sets the selected contact on startup
This change adds a command line option that lets you specify a contact to set
as the selected contact on startup.
---
src/contacts-callbacks-ebook.c | 31 ++++++++++++++++++++++++++++---
src/contacts-defs.h | 1 +
src/contacts-main.c | 4 ++++
3 files changed, 33 insertions(+), 3 deletions(-)
diff --git a/src/contacts-callbacks-ebook.c b/src/contacts-callbacks-ebook.c
index b24ee00..5c458d9 100644
--- a/src/contacts-callbacks-ebook.c
+++ b/src/contacts-callbacks-ebook.c
@@ -204,10 +204,35 @@ contacts_sequence_complete_cb (EBookView *book_view, const GList *ids, ContactsD
GtkTreeSelection *selection =
gtk_tree_view_get_selection (GTK_TREE_VIEW (data->ui->contacts_treeview));
GtkTreeIter iter;
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model),
- &iter)) {
- gtk_tree_selection_select_iter (selection, &iter);
+
+ if (!data->uid_for_startup)
+ {
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model),
+ &iter)) {
+ gtk_tree_selection_select_iter (selection, &iter);
+ }
+ } else {
+ if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (model),
+ &iter)) {
+ do {
+ gchar *uid;
+ gtk_tree_model_get (GTK_TREE_MODEL (model),
+ &iter,
+ CONTACT_UID_COL,
+ &uid,
+ -1);
+
+ if (g_str_equal (uid, data->uid_for_startup))
+ {
+ gtk_tree_selection_select_iter (selection, &iter);
+ g_free (uid);
+ break;
+ }
+ g_free (uid);
+ } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (model), &iter));
+ }
}
+
data->initialising = FALSE;
gtk_tree_view_scroll_to_point (GTK_TREE_VIEW (data->ui->contacts_treeview), 0, 0);
}
diff --git a/src/contacts-defs.h b/src/contacts-defs.h
index 61ea494..b087fbc 100644
--- a/src/contacts-defs.h
+++ b/src/contacts-defs.h
@@ -112,6 +112,7 @@ typedef struct {
GtkListStore *contacts_liststore;
GtkTreeModelFilter *contacts_filter;
gboolean initialising;
+ gchar *uid_for_startup;
} ContactsData;
typedef struct {
diff --git a/src/contacts-main.c b/src/contacts-main.c
index 0745481..82dd803 100644
--- a/src/contacts-main.c
+++ b/src/contacts-main.c
@@ -171,12 +171,15 @@ main (int argc, char **argv)
static gint plug = 0;
GtkWidget *widget;
static gchar *uri = NULL;
+ static gchar *uid = NULL;
static GOptionEntry entries[] = {
{ "plug", 'p', 0, G_OPTION_ARG_INT, &plug,
"Socket ID of an XEmbed socket to plug into", NULL },
{ "uri", 'u', 0, G_OPTION_ARG_STRING, &uri,
"Uri to use rather than the system address book", NULL },
+ { "uid", 'c', 0, G_OPTION_ARG_STRING, &uid,
+ "UID of contact to select on boot", NULL },
{ NULL }
};
@@ -213,6 +216,7 @@ main (int argc, char **argv)
data = g_new0 (ContactsData, 1);
data->ui = g_new0 (ContactsUI, 1);
+ data->uid_for_startup = uid;
data->initialising = TRUE; /* initialising until contacts have been loaded for the first time */
bacon_message_connection_set_callback (
mc, (BaconMessageReceivedFunc)contacts_bacon_cb, data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]