diff options
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_egos.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_egos.c | 73 |
1 files changed, 50 insertions, 23 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_egos.c b/src/conversation/gnunet-conversation-gtk_egos.c index 29aa3501..5136a938 100644 --- a/src/conversation/gnunet-conversation-gtk_egos.c +++ b/src/conversation/gnunet-conversation-gtk_egos.c | |||
@@ -20,7 +20,7 @@ | |||
20 | 20 | ||
21 | /** | 21 | /** |
22 | * @file src/conversation/gnunet-conversation-gtk_egos.c | 22 | * @file src/conversation/gnunet-conversation-gtk_egos.c |
23 | * @brief | 23 | * @brief Manages the list of egos for selecting our caller-ID |
24 | * @author yids | 24 | * @author yids |
25 | * @author hark | 25 | * @author hark |
26 | * @author Christian Grothoff | 26 | * @author Christian Grothoff |
@@ -30,19 +30,19 @@ | |||
30 | 30 | ||
31 | 31 | ||
32 | /** | 32 | /** |
33 | * Columns in the #zone_liststore. | 33 | * Columns in the #ego_liststore. |
34 | */ | 34 | */ |
35 | enum ZoneListstoreValues | 35 | enum EgoListstoreValues |
36 | { | 36 | { |
37 | /** | 37 | /** |
38 | * Human-readable name of the ego. | 38 | * Human-readable name of the ego. |
39 | */ | 39 | */ |
40 | ZONE_LS_NAME = 0, | 40 | EGO_LS_NAME = 0, |
41 | 41 | ||
42 | /** | 42 | /** |
43 | * Handel to the ego (of type `struct GNUNET_IDENTITY_Ego *ego`). | 43 | * Handel to the ego (of type `struct GNUNET_IDENTITY_Ego *ego`). |
44 | */ | 44 | */ |
45 | ZONE_LS_EGO = 1 | 45 | EGO_LS_EGO = 1 |
46 | }; | 46 | }; |
47 | 47 | ||
48 | 48 | ||
@@ -52,10 +52,14 @@ enum ZoneListstoreValues | |||
52 | static struct GNUNET_IDENTITY_Handle *id; | 52 | static struct GNUNET_IDENTITY_Handle *id; |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * list of zones | 55 | * list of egos |
56 | */ | 56 | */ |
57 | static GtkListStore *zone_liststore; | 57 | static GtkListStore *ego_liststore; |
58 | 58 | ||
59 | /** | ||
60 | * Default ego to pre-select. | ||
61 | */ | ||
62 | static char *default_ego; | ||
59 | 63 | ||
60 | /** | 64 | /** |
61 | * Obtain the currently selected ego. | 65 | * Obtain the currently selected ego. |
@@ -63,18 +67,19 @@ static GtkListStore *zone_liststore; | |||
63 | * @return NULL if no ego is selected | 67 | * @return NULL if no ego is selected |
64 | */ | 68 | */ |
65 | struct GNUNET_IDENTITY_Ego * | 69 | struct GNUNET_IDENTITY_Ego * |
66 | GCG_EGOS_get_selected_ego (void) | 70 | GCG_EGOS_get_selected_ego () |
67 | { | 71 | { |
68 | struct GNUNET_IDENTITY_Ego *ego; | 72 | struct GNUNET_IDENTITY_Ego *ego; |
69 | GtkTreeIter iter; | 73 | GtkTreeIter iter; |
70 | GtkComboBox *cb; | 74 | GtkComboBox *cb; |
71 | 75 | ||
72 | cb = GTK_COMBO_BOX (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_combobox")); | 76 | cb = GTK_COMBO_BOX (GCG_get_main_window_object |
77 | ("gnunet_conversation_gtk_ego_combobox")); | ||
73 | gtk_combo_box_get_active_iter (cb, | 78 | gtk_combo_box_get_active_iter (cb, |
74 | &iter); | 79 | &iter); |
75 | gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), | 80 | gtk_tree_model_get (GTK_TREE_MODEL (ego_liststore), |
76 | &iter, | 81 | &iter, |
77 | ZONE_LS_EGO, &ego, | 82 | EGO_LS_EGO, &ego, |
78 | -1); | 83 | -1); |
79 | return ego; | 84 | return ego; |
80 | } | 85 | } |
@@ -97,20 +102,33 @@ identity_cb (void *cls, | |||
97 | GtkTreeIter iter; | 102 | GtkTreeIter iter; |
98 | GtkTreeRowReference *rr; | 103 | GtkTreeRowReference *rr; |
99 | GtkTreePath *path; | 104 | GtkTreePath *path; |
105 | GtkComboBox *cb; | ||
100 | 106 | ||
101 | rr = *ctx; | 107 | rr = *ctx; |
102 | if (NULL == rr) | 108 | if (NULL == rr) |
103 | { | 109 | { |
104 | /* new identity */ | 110 | /* new identity */ |
105 | GNUNET_assert (NULL != name); | 111 | GNUNET_assert (NULL != name); |
106 | gtk_list_store_insert_with_values (zone_liststore, | 112 | gtk_list_store_insert_with_values (ego_liststore, |
107 | &iter, -1, | 113 | &iter, -1, |
108 | ZONE_LS_NAME, name, | 114 | EGO_LS_NAME, name, |
109 | ZONE_LS_EGO, ego, | 115 | EGO_LS_EGO, ego, |
110 | -1); | 116 | -1); |
111 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore), | 117 | if ( (NULL != default_ego) && |
118 | (0 == strcmp (name, | ||
119 | default_ego)) ) | ||
120 | { | ||
121 | /* found the ego that we were supposed to use by default, select | ||
122 | it! */ | ||
123 | GNUNET_free (default_ego); | ||
124 | default_ego = NULL; | ||
125 | cb = GTK_COMBO_BOX (GCG_get_main_window_object | ||
126 | ("gnunet_conversation_gtk_ego_combobox")); | ||
127 | gtk_combo_box_set_active_iter (cb, &iter); | ||
128 | } | ||
129 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ego_liststore), | ||
112 | &iter); | 130 | &iter); |
113 | rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (zone_liststore), | 131 | rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ego_liststore), |
114 | path); | 132 | path); |
115 | gtk_tree_path_free (path); | 133 | gtk_tree_path_free (path); |
116 | *ctx = rr; | 134 | *ctx = rr; |
@@ -118,7 +136,7 @@ identity_cb (void *cls, | |||
118 | } | 136 | } |
119 | /* existing ego, locate and execute rename/delete */ | 137 | /* existing ego, locate and execute rename/delete */ |
120 | path = gtk_tree_row_reference_get_path (rr); | 138 | path = gtk_tree_row_reference_get_path (rr); |
121 | gtk_tree_model_get_iter (GTK_TREE_MODEL (zone_liststore), | 139 | gtk_tree_model_get_iter (GTK_TREE_MODEL (ego_liststore), |
122 | &iter, | 140 | &iter, |
123 | path); | 141 | path); |
124 | gtk_tree_path_free (path); | 142 | gtk_tree_path_free (path); |
@@ -127,26 +145,30 @@ identity_cb (void *cls, | |||
127 | /* deletion operation */ | 145 | /* deletion operation */ |
128 | gtk_tree_row_reference_free (rr); | 146 | gtk_tree_row_reference_free (rr); |
129 | *ctx = NULL; | 147 | *ctx = NULL; |
130 | gtk_list_store_remove (zone_liststore, | 148 | gtk_list_store_remove (ego_liststore, |
131 | &iter); | 149 | &iter); |
132 | return; | 150 | return; |
133 | } | 151 | } |
134 | /* rename operation */ | 152 | /* rename operation */ |
135 | gtk_list_store_set (zone_liststore, | 153 | gtk_list_store_set (ego_liststore, |
136 | &iter, | 154 | &iter, |
137 | ZONE_LS_NAME, &name, | 155 | EGO_LS_NAME, &name, |
138 | -1); | 156 | -1); |
139 | } | 157 | } |
140 | 158 | ||
141 | 159 | ||
142 | /** | 160 | /** |
143 | * Initialize the ego list | 161 | * Initialize the ego list |
162 | * | ||
163 | * @param ego_name default ego to pre-select | ||
144 | */ | 164 | */ |
145 | void | 165 | void |
146 | GCG_EGOS_init () | 166 | GCG_EGOS_init (const char *ego_name) |
147 | { | 167 | { |
148 | zone_liststore | 168 | default_ego = GNUNET_strdup (ego_name); |
149 | = GTK_LIST_STORE (GCG_get_main_window_object ("gnunet_conversation_gtk_contacts_zone_liststore")); | 169 | ego_liststore |
170 | = GTK_LIST_STORE (GCG_get_main_window_object | ||
171 | ("gnunet_conversation_gtk_ego_liststore")); | ||
150 | id = GNUNET_IDENTITY_connect (GCG_get_configuration (), | 172 | id = GNUNET_IDENTITY_connect (GCG_get_configuration (), |
151 | &identity_cb, | 173 | &identity_cb, |
152 | NULL); | 174 | NULL); |
@@ -164,6 +186,11 @@ GCG_EGOS_shutdown () | |||
164 | GNUNET_IDENTITY_disconnect (id); | 186 | GNUNET_IDENTITY_disconnect (id); |
165 | id = NULL; | 187 | id = NULL; |
166 | } | 188 | } |
189 | if (NULL != default_ego) | ||
190 | { | ||
191 | GNUNET_free (default_ego); | ||
192 | default_ego = NULL; | ||
193 | } | ||
167 | } | 194 | } |
168 | 195 | ||
169 | /* end of gnunet-conversation-gtk_egos.c */ | 196 | /* end of gnunet-conversation-gtk_egos.c */ |