diff options
author | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
---|---|---|
committer | ng0 <ng0@n0.is> | 2019-05-15 15:51:29 +0000 |
commit | 51cf7682ce12732f75365e2766f481132b3baaee (patch) | |
tree | a3f0a8e08c6e93a17216dc66236ad3e157878cd9 /src/conversation/gnunet-conversation-gtk_egos.c | |
parent | f85786c61f2f03c6e3d2d7f00a6b1446bab3c41e (diff) | |
download | gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.tar.gz gnunet-gtk-51cf7682ce12732f75365e2766f481132b3baaee.zip |
clang-format all C code. Add symlink of clang-format to bootstrap.
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_egos.c')
-rw-r--r-- | src/conversation/gnunet-conversation-gtk_egos.c | 79 |
1 files changed, 31 insertions, 48 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_egos.c b/src/conversation/gnunet-conversation-gtk_egos.c index 716d7cdf..08801ced 100644 --- a/src/conversation/gnunet-conversation-gtk_egos.c +++ b/src/conversation/gnunet-conversation-gtk_egos.c | |||
@@ -74,14 +74,14 @@ GCG_EGOS_get_selected_ego () | |||
74 | GtkTreeIter iter; | 74 | GtkTreeIter iter; |
75 | GtkComboBox *cb; | 75 | GtkComboBox *cb; |
76 | 76 | ||
77 | cb = GTK_COMBO_BOX (GCG_get_main_window_object | 77 | cb = GTK_COMBO_BOX ( |
78 | ("gnunet_conversation_gtk_ego_combobox")); | 78 | GCG_get_main_window_object ("gnunet_conversation_gtk_ego_combobox")); |
79 | if (! gtk_combo_box_get_active_iter (cb, | 79 | if (! gtk_combo_box_get_active_iter (cb, &iter)) |
80 | &iter)) | ||
81 | return NULL; | 80 | return NULL; |
82 | gtk_tree_model_get (GTK_TREE_MODEL (ego_liststore), | 81 | gtk_tree_model_get (GTK_TREE_MODEL (ego_liststore), |
83 | &iter, | 82 | &iter, |
84 | EGO_LS_EGO, &ego, | 83 | EGO_LS_EGO, |
84 | &ego, | ||
85 | -1); | 85 | -1); |
86 | return ego; | 86 | return ego; |
87 | } | 87 | } |
@@ -118,51 +118,43 @@ identity_cb (void *cls, | |||
118 | /* new identity */ | 118 | /* new identity */ |
119 | GNUNET_assert (NULL != name); | 119 | GNUNET_assert (NULL != name); |
120 | gtk_list_store_insert_with_values (ego_liststore, | 120 | gtk_list_store_insert_with_values (ego_liststore, |
121 | &iter, -1, | 121 | &iter, |
122 | EGO_LS_NAME, name, | 122 | -1, |
123 | EGO_LS_EGO, ego, | 123 | EGO_LS_NAME, |
124 | name, | ||
125 | EGO_LS_EGO, | ||
126 | ego, | ||
124 | -1); | 127 | -1); |
125 | cb = GTK_COMBO_BOX (GCG_get_main_window_object | 128 | cb = GTK_COMBO_BOX ( |
126 | ("gnunet_conversation_gtk_ego_combobox")); | 129 | GCG_get_main_window_object ("gnunet_conversation_gtk_ego_combobox")); |
127 | if ( (! gtk_combo_box_get_active_iter (cb, | 130 | if ((! gtk_combo_box_get_active_iter (cb, &iter2)) && |
128 | &iter2)) && | 131 | ((NULL == default_ego) || (0 == strcmp (name, default_ego)))) |
129 | ( (NULL == default_ego) || | ||
130 | (0 == strcmp (name, | ||
131 | default_ego))) ) | ||
132 | { | 132 | { |
133 | /* found the ego that we were supposed to use by default, select | 133 | /* found the ego that we were supposed to use by default, select |
134 | it! */ | 134 | it! */ |
135 | gtk_combo_box_set_active_iter (cb, | 135 | gtk_combo_box_set_active_iter (cb, &iter); |
136 | &iter); | ||
137 | } | 136 | } |
138 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ego_liststore), | 137 | path = gtk_tree_model_get_path (GTK_TREE_MODEL (ego_liststore), &iter); |
139 | &iter); | 138 | rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ego_liststore), path); |
140 | rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ego_liststore), | ||
141 | path); | ||
142 | gtk_tree_path_free (path); | 139 | gtk_tree_path_free (path); |
143 | *ctx = rr; | 140 | *ctx = rr; |
144 | return; | 141 | return; |
145 | } | 142 | } |
146 | /* existing ego, locate and execute rename/delete */ | 143 | /* existing ego, locate and execute rename/delete */ |
147 | path = gtk_tree_row_reference_get_path (rr); | 144 | path = gtk_tree_row_reference_get_path (rr); |
148 | GNUNET_assert (gtk_tree_model_get_iter (GTK_TREE_MODEL (ego_liststore), | 145 | GNUNET_assert ( |
149 | &iter, | 146 | gtk_tree_model_get_iter (GTK_TREE_MODEL (ego_liststore), &iter, path)); |
150 | path)); | ||
151 | gtk_tree_path_free (path); | 147 | gtk_tree_path_free (path); |
152 | if (NULL == name) | 148 | if (NULL == name) |
153 | { | 149 | { |
154 | /* deletion operation */ | 150 | /* deletion operation */ |
155 | gtk_tree_row_reference_free (rr); | 151 | gtk_tree_row_reference_free (rr); |
156 | *ctx = NULL; | 152 | *ctx = NULL; |
157 | gtk_list_store_remove (ego_liststore, | 153 | gtk_list_store_remove (ego_liststore, &iter); |
158 | &iter); | ||
159 | return; | 154 | return; |
160 | } | 155 | } |
161 | /* rename operation */ | 156 | /* rename operation */ |
162 | gtk_list_store_set (ego_liststore, | 157 | gtk_list_store_set (ego_liststore, &iter, EGO_LS_NAME, &name, -1); |
163 | &iter, | ||
164 | EGO_LS_NAME, &name, | ||
165 | -1); | ||
166 | } | 158 | } |
167 | 159 | ||
168 | 160 | ||
@@ -175,7 +167,7 @@ identity_cb (void *cls, | |||
175 | */ | 167 | */ |
176 | void | 168 | void |
177 | gnunet_conversation_gtk_ego_copy_button_clicked_cb (GtkButton *button, | 169 | gnunet_conversation_gtk_ego_copy_button_clicked_cb (GtkButton *button, |
178 | gpointer user_data) | 170 | gpointer user_data) |
179 | { | 171 | { |
180 | struct GNUNET_IDENTITY_Ego *ego; | 172 | struct GNUNET_IDENTITY_Ego *ego; |
181 | const gchar *label; | 173 | const gchar *label; |
@@ -185,21 +177,15 @@ gnunet_conversation_gtk_ego_copy_button_clicked_cb (GtkButton *button, | |||
185 | char *uri; | 177 | char *uri; |
186 | GtkClipboard *cb; | 178 | GtkClipboard *cb; |
187 | 179 | ||
188 | label = gtk_entry_get_text (GTK_ENTRY | 180 | label = gtk_entry_get_text (GTK_ENTRY ( |
189 | (GCG_get_main_window_object | 181 | GCG_get_main_window_object ("gnunet_conversation_gtk_ego_label_entry"))); |
190 | ("gnunet_conversation_gtk_ego_label_entry"))); | 182 | GNUNET_break ((NULL != label) && (0 != strlen (label))); |
191 | GNUNET_break ( (NULL != label) && | ||
192 | (0 != strlen (label)) ); | ||
193 | ego = GCG_EGOS_get_selected_ego (); | 183 | ego = GCG_EGOS_get_selected_ego (); |
194 | GNUNET_break (NULL != ego); | 184 | GNUNET_break (NULL != ego); |
195 | priv = GNUNET_IDENTITY_ego_get_private_key (ego); | 185 | priv = GNUNET_IDENTITY_ego_get_private_key (ego); |
196 | GNUNET_CRYPTO_ecdsa_key_get_public (priv, | 186 | GNUNET_CRYPTO_ecdsa_key_get_public (priv, &pub); |
197 | &pub); | ||
198 | zkey = GNUNET_GNSRECORD_pkey_to_zkey (&pub); | 187 | zkey = GNUNET_GNSRECORD_pkey_to_zkey (&pub); |
199 | GNUNET_asprintf (&uri, | 188 | GNUNET_asprintf (&uri, "gnunet://gns/%s.%s/", label, zkey); |
200 | "gnunet://gns/%s.%s/", | ||
201 | label, | ||
202 | zkey); | ||
203 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); | 189 | cb = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); |
204 | gtk_clipboard_set_text (cb, uri, -1); | 190 | gtk_clipboard_set_text (cb, uri, -1); |
205 | gtk_clipboard_store (cb); | 191 | gtk_clipboard_store (cb); |
@@ -217,12 +203,9 @@ GCG_EGOS_init (const char *ego_name) | |||
217 | { | 203 | { |
218 | if (NULL != ego_name) | 204 | if (NULL != ego_name) |
219 | default_ego = GNUNET_strdup (ego_name); | 205 | default_ego = GNUNET_strdup (ego_name); |
220 | ego_liststore | 206 | ego_liststore = GTK_LIST_STORE ( |
221 | = GTK_LIST_STORE (GCG_get_main_window_object | 207 | GCG_get_main_window_object ("gnunet_conversation_gtk_ego_liststore")); |
222 | ("gnunet_conversation_gtk_ego_liststore")); | 208 | id = GNUNET_IDENTITY_connect (GCG_get_configuration (), &identity_cb, NULL); |
223 | id = GNUNET_IDENTITY_connect (GCG_get_configuration (), | ||
224 | &identity_cb, | ||
225 | NULL); | ||
226 | } | 209 | } |
227 | 210 | ||
228 | 211 | ||