aboutsummaryrefslogtreecommitdiff
path: root/src/conversation/gnunet-conversation-gtk_zones.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/conversation/gnunet-conversation-gtk_zones.c')
-rw-r--r--src/conversation/gnunet-conversation-gtk_zones.c34
1 files changed, 21 insertions, 13 deletions
diff --git a/src/conversation/gnunet-conversation-gtk_zones.c b/src/conversation/gnunet-conversation-gtk_zones.c
index d0e824f0..bfb8d2e6 100644
--- a/src/conversation/gnunet-conversation-gtk_zones.c
+++ b/src/conversation/gnunet-conversation-gtk_zones.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2013-2014 GNUnet e.V. 3 Copyright (C) 2013-2014, 2018 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published 6 it under the terms of the GNU General Public License as published
@@ -66,10 +66,11 @@ static char *default_ego;
66/** 66/**
67 * Obtain the currently selected zone. 67 * Obtain the currently selected zone.
68 * 68 *
69 * @param name[out] set to the name of the ego
69 * @return NULL if no ego is selected 70 * @return NULL if no ego is selected
70 */ 71 */
71struct GNUNET_IDENTITY_Ego * 72struct GNUNET_IDENTITY_Ego *
72GCG_ZONES_get_selected_zone () 73GCG_ZONES_get_selected_zone (const char **name)
73{ 74{
74 struct GNUNET_IDENTITY_Ego *ego; 75 struct GNUNET_IDENTITY_Ego *ego;
75 GtkTreeIter iter; 76 GtkTreeIter iter;
@@ -79,10 +80,14 @@ GCG_ZONES_get_selected_zone ()
79 ("gnunet_conversation_gtk_contacts_zone_combobox")); 80 ("gnunet_conversation_gtk_contacts_zone_combobox"));
80 if (! gtk_combo_box_get_active_iter (cb, 81 if (! gtk_combo_box_get_active_iter (cb,
81 &iter)) 82 &iter))
83 {
84 *name = NULL;
82 return NULL; 85 return NULL;
86 }
83 gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore), 87 gtk_tree_model_get (GTK_TREE_MODEL (zone_liststore),
84 &iter, 88 &iter,
85 ZONE_LS_EGO, &ego, 89 ZONE_LS_EGO, &ego,
90 ZONE_LS_NAME, name,
86 -1); 91 -1);
87 return ego; 92 return ego;
88} 93}
@@ -103,6 +108,7 @@ identity_cb (void *cls,
103 const char *name) 108 const char *name)
104{ 109{
105 GtkTreeIter iter; 110 GtkTreeIter iter;
111 GtkTreeIter iter2;
106 GtkTreeRowReference *rr; 112 GtkTreeRowReference *rr;
107 GtkTreePath *path; 113 GtkTreePath *path;
108 GtkComboBox *cb; 114 GtkComboBox *cb;
@@ -122,17 +128,18 @@ identity_cb (void *cls,
122 ZONE_LS_NAME, name, 128 ZONE_LS_NAME, name,
123 ZONE_LS_EGO, ego, 129 ZONE_LS_EGO, ego,
124 -1); 130 -1);
125 if ( (NULL != default_ego) && 131 cb = GTK_COMBO_BOX (GCG_get_main_window_object
126 (0 == strcmp (name, 132 ("gnunet_conversation_gtk_contacts_zone_combobox"));
127 default_ego)) ) 133 if ( (! gtk_combo_box_get_active_iter (cb,
134 &iter2)) &&
135 ( (NULL == default_ego) ||
136 (0 == strcmp (name,
137 default_ego)) ) )
128 { 138 {
129 /* found the ego that we were supposed to use by default, select 139 /* found an ego (or the ego) that we were supposed to use by
130 it! */ 140 default, select it! */
131 GNUNET_free (default_ego); 141 gtk_combo_box_set_active_iter (cb,
132 default_ego = NULL; 142 &iter);
133 cb = GTK_COMBO_BOX (GCG_get_main_window_object
134 ("gnunet_conversation_gtk_contacts_zone_combobox"));
135 gtk_combo_box_set_active_iter (cb, &iter);
136 } 143 }
137 path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore), 144 path = gtk_tree_model_get_path (GTK_TREE_MODEL (zone_liststore),
138 &iter); 145 &iter);
@@ -173,7 +180,8 @@ identity_cb (void *cls,
173void 180void
174GCG_ZONES_init (const char *ego_name) 181GCG_ZONES_init (const char *ego_name)
175{ 182{
176 default_ego = GNUNET_strdup (ego_name); 183 if (NULL != ego_name)
184 default_ego = GNUNET_strdup (ego_name);
177 zone_liststore 185 zone_liststore
178 = GTK_LIST_STORE (GCG_get_main_window_object 186 = GTK_LIST_STORE (GCG_get_main_window_object
179 ("gnunet_conversation_gtk_contacts_zone_liststore")); 187 ("gnunet_conversation_gtk_contacts_zone_liststore"));