diff options
Diffstat (limited to 'src/identity/gnunet-identity-gtk.c')
-rw-r--r-- | src/identity/gnunet-identity-gtk.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/src/identity/gnunet-identity-gtk.c b/src/identity/gnunet-identity-gtk.c index 7c9f24bd..6b87e812 100644 --- a/src/identity/gnunet-identity-gtk.c +++ b/src/identity/gnunet-identity-gtk.c | |||
@@ -72,6 +72,111 @@ static GtkListStore *ls; | |||
72 | 72 | ||
73 | 73 | ||
74 | /** | 74 | /** |
75 | * We need to track active operations with the identity service. | ||
76 | */ | ||
77 | struct OperationContext | ||
78 | { | ||
79 | |||
80 | /** | ||
81 | * Kept in a DLL. | ||
82 | */ | ||
83 | struct OperationContext *next; | ||
84 | |||
85 | /** | ||
86 | * Kept in a DLL. | ||
87 | */ | ||
88 | struct OperationContext *prev; | ||
89 | |||
90 | /** | ||
91 | * Operation handle with the identity service. | ||
92 | */ | ||
93 | struct GNUNET_IDENTITY_Operation *op; | ||
94 | |||
95 | }; | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Identity operation was finished, clean up. | ||
100 | * | ||
101 | * @param cls the 'struct OperationContext' | ||
102 | * @param emsg error message (NULL on success) | ||
103 | */ | ||
104 | static void | ||
105 | operation_finished (void *cls, | ||
106 | const char *emsg) | ||
107 | { | ||
108 | struct OperationContext *oc = cls; | ||
109 | |||
110 | GNUNET_free (oc); | ||
111 | } | ||
112 | |||
113 | |||
114 | /** | ||
115 | * The user edited one of the names of the egos. Change it | ||
116 | * in the IDENTITY service. | ||
117 | * | ||
118 | * @param renderer renderer where the change happened | ||
119 | * @param path location in the model where the change happened | ||
120 | * @param new_text updated text | ||
121 | * @param user_data internal context (not used) | ||
122 | */ | ||
123 | void | ||
124 | GNUNET_GTK_namespace_organizer_namespaces_treeview_column_name_text_edited_cb | ||
125 | (GtkCellRendererText *renderer, | ||
126 | gchar *path, | ||
127 | gchar *new_text, | ||
128 | gpointer user_data) | ||
129 | { | ||
130 | GtkTreePath *treepath; | ||
131 | GtkTreeIter iter; | ||
132 | struct GNUNET_IDENTITY_Ego *ego; | ||
133 | gchar *old; | ||
134 | struct OperationContext *oc; | ||
135 | |||
136 | treepath = gtk_tree_path_new_from_string (path); | ||
137 | if (! gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), | ||
138 | &iter, | ||
139 | treepath)) | ||
140 | { | ||
141 | GNUNET_break (0); | ||
142 | gtk_tree_path_free (treepath); | ||
143 | return; | ||
144 | } | ||
145 | gtk_tree_path_free (treepath); | ||
146 | gtk_tree_model_get (GTK_TREE_MODEL (ls), | ||
147 | &iter, | ||
148 | IDENTITY_MC_NAME, &old, | ||
149 | IDENTITY_MC_EGO, &ego, | ||
150 | -1); | ||
151 | oc = GNUNET_new (struct OperationContext); | ||
152 | if (NULL == ego) | ||
153 | { | ||
154 | /* create operation */ | ||
155 | oc->op = GNUNET_IDENTITY_create (identity, | ||
156 | new_text, | ||
157 | &operation_finished, | ||
158 | oc); | ||
159 | } | ||
160 | else if (0 != strlen (new_text)) | ||
161 | { | ||
162 | /* rename operation */ | ||
163 | oc->op = GNUNET_IDENTITY_rename (identity, | ||
164 | old, new_text, | ||
165 | &operation_finished, | ||
166 | oc); | ||
167 | } | ||
168 | else | ||
169 | { | ||
170 | /* delete operation */ | ||
171 | oc->op = GNUNET_IDENTITY_delete (identity, | ||
172 | old, | ||
173 | &operation_finished, | ||
174 | oc); | ||
175 | } | ||
176 | } | ||
177 | |||
178 | |||
179 | /** | ||
75 | * Get cfg. | 180 | * Get cfg. |
76 | */ | 181 | */ |
77 | static const struct GNUNET_CONFIGURATION_Handle * | 182 | static const struct GNUNET_CONFIGURATION_Handle * |
@@ -208,6 +313,7 @@ static void | |||
208 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 313 | run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
209 | { | 314 | { |
210 | GtkWidget *main_window; | 315 | GtkWidget *main_window; |
316 | GtkTreeIter iter; | ||
211 | 317 | ||
212 | ml = cls; | 318 | ml = cls; |
213 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) | 319 | if (GNUNET_OK != GNUNET_GTK_main_loop_build_window (ml, NULL)) |
@@ -218,6 +324,11 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
218 | main_window = GTK_WIDGET (get_object ("GNUNET_GTK_identity_window")); | 324 | main_window = GTK_WIDGET (get_object ("GNUNET_GTK_identity_window")); |
219 | ls = GTK_LIST_STORE (get_object ("GNUNET_GTK_identity_liststore")); | 325 | ls = GTK_LIST_STORE (get_object ("GNUNET_GTK_identity_liststore")); |
220 | GNUNET_assert (NULL != ls); | 326 | GNUNET_assert (NULL != ls); |
327 | gtk_list_store_insert_with_values (ls, | ||
328 | &iter, G_MAXINT, | ||
329 | IDENTITY_MC_NAME, "<create>", | ||
330 | -1); | ||
331 | |||
221 | gtk_window_maximize (GTK_WINDOW (main_window)); | 332 | gtk_window_maximize (GTK_WINDOW (main_window)); |
222 | GNUNET_GTK_tray_icon_create (ml, | 333 | GNUNET_GTK_tray_icon_create (ml, |
223 | GTK_WINDOW (main_window), | 334 | GTK_WINDOW (main_window), |