aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-03-20 06:54:52 +0000
committerChristian Grothoff <christian@grothoff.org>2012-03-20 06:54:52 +0000
commit126ea1e6938aafc72715ecb85b6061c5719cbb87 (patch)
tree9c4783e7958744568fafb8e7a1984f8a3fee616e
parent4d4b906ac2f35d42f6b66a5c042588b3ab76c3b5 (diff)
downloadgnunet-gtk-126ea1e6938aafc72715ecb85b6061c5719cbb87.tar.gz
gnunet-gtk-126ea1e6938aafc72715ecb85b6061c5719cbb87.zip
-LRN: Don-t block signal propagation
-rw-r--r--contrib/gnunet_peerinfo_gtk_main_window.glade47
-rw-r--r--src/fs/gnunet-fs-gtk_event-handler.c22
-rw-r--r--src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c2
-rw-r--r--src/peerinfo/gnunet-peerinfo-gtk.c111
4 files changed, 117 insertions, 65 deletions
diff --git a/contrib/gnunet_peerinfo_gtk_main_window.glade b/contrib/gnunet_peerinfo_gtk_main_window.glade
index 02caa760..cb9aeed1 100644
--- a/contrib/gnunet_peerinfo_gtk_main_window.glade
+++ b/contrib/gnunet_peerinfo_gtk_main_window.glade
@@ -1,4 +1,4 @@
1<?xml version="1.0" encoding="UTF-8"?> 1<?xml version="1.0"?>
2<interface> 2<interface>
3 <requires lib="gtk+" version="2.20"/> 3 <requires lib="gtk+" version="2.20"/>
4 <!-- interface-naming-policy project-wide --> 4 <!-- interface-naming-policy project-wide -->
@@ -18,46 +18,43 @@
18 <column type="guint64"/> 18 <column type="guint64"/>
19 <!-- column-name addresses --> 19 <!-- column-name addresses -->
20 <column type="gchararray"/> 20 <column type="gchararray"/>
21 <!-- column-name connectivity_led -->
22 <column type="GdkPixbuf"/>
23 <!-- column-name connected_status -->
24 <column type="gboolean"/>
21 </columns> 25 </columns>
22 </object> 26 </object>
23 <object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window"> 27 <object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window">
24 <property name="can_focus">False</property>
25 <property name="title" translatable="yes">gnunet-peerinfo-gtk</property> 28 <property name="title" translatable="yes">gnunet-peerinfo-gtk</property>
26 <property name="window_position">center</property> 29 <property name="window_position">center</property>
27 <property name="default_width">700</property> 30 <property name="default_width">700</property>
28 <property name="default_height">500</property> 31 <property name="default_height">500</property>
29 <property name="icon_name">gnunet-gtk</property> 32 <property name="icon_name">gnunet-gtk</property>
30 <signal name="delete-event" handler="GNUNET_PEERINFO_GTK_quit_cb" after="yes" swapped="no"/> 33 <signal name="delete_event" handler="GNUNET_PEERINFO_GTK_quit_cb" after="yes"/>
31 <child> 34 <child>
32 <object class="GtkVBox" id="GNUNET_PEERINFO_GTK_main_window_vbox"> 35 <object class="GtkVBox" id="GNUNET_PEERINFO_GTK_main_window_vbox">
33 <property name="visible">True</property> 36 <property name="visible">True</property>
34 <property name="can_focus">False</property> 37 <property name="orientation">vertical</property>
35 <child> 38 <child>
36 <object class="GtkMenuBar" id="GNUNET_PEERINFO_GTK_main_menu"> 39 <object class="GtkMenuBar" id="GNUNET_PEERINFO_GTK_main_menu">
37 <property name="visible">True</property> 40 <property name="visible">True</property>
38 <property name="can_focus">False</property>
39 <child> 41 <child>
40 <object class="GtkMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help"> 42 <object class="GtkMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help">
41 <property name="visible">True</property> 43 <property name="visible">True</property>
42 <property name="can_focus">False</property>
43 <property name="use_action_appearance">False</property>
44 <property name="label" translatable="yes">_Help</property> 44 <property name="label" translatable="yes">_Help</property>
45 <property name="use_underline">True</property> 45 <property name="use_underline">True</property>
46 <child type="submenu"> 46 <child type="submenu">
47 <object class="GtkMenu" id="GNUNET_PEERINFO_GTK_main_menu_help_abou"> 47 <object class="GtkMenu" id="GNUNET_PEERINFO_GTK_main_menu_help_abou">
48 <property name="visible">True</property> 48 <property name="visible">True</property>
49 <property name="can_focus">False</property>
50 <child> 49 <child>
51 <object class="GtkImageMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help_about"> 50 <object class="GtkImageMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help_about">
52 <property name="label">gtk-about</property> 51 <property name="label">gtk-about</property>
53 <property name="visible">True</property> 52 <property name="visible">True</property>
54 <property name="can_focus">False</property>
55 <property name="tooltip_text" translatable="yes">Display information about this version of gnunet-peerinfo-gtk</property> 53 <property name="tooltip_text" translatable="yes">Display information about this version of gnunet-peerinfo-gtk</property>
56 <property name="use_action_appearance">False</property>
57 <property name="accel_path">&lt;gnunet-peerinfo-gtk&gt;/Help/About</property> 54 <property name="accel_path">&lt;gnunet-peerinfo-gtk&gt;/Help/About</property>
58 <property name="use_underline">True</property> 55 <property name="use_underline">True</property>
59 <property name="use_stock">True</property> 56 <property name="use_stock">True</property>
60 <signal name="activate" handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb" swapped="no"/> 57 <signal name="activate" handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb"/>
61 </object> 58 </object>
62 </child> 59 </child>
63 </object> 60 </object>
@@ -67,7 +64,6 @@
67 </object> 64 </object>
68 <packing> 65 <packing>
69 <property name="expand">False</property> 66 <property name="expand">False</property>
70 <property name="fill">True</property>
71 <property name="position">0</property> 67 <property name="position">0</property>
72 </packing> 68 </packing>
73 </child> 69 </child>
@@ -92,7 +88,7 @@
92 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_name_column"> 88 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_name_column">
93 <property name="spacing">5</property> 89 <property name="spacing">5</property>
94 <property name="sizing">autosize</property> 90 <property name="sizing">autosize</property>
95 <property name="title" translatable="yes">Peer</property> 91 <property name="title">Peer</property>
96 <property name="reorderable">True</property> 92 <property name="reorderable">True</property>
97 <property name="sort_indicator">True</property> 93 <property name="sort_indicator">True</property>
98 <property name="sort_column_id">0</property> 94 <property name="sort_column_id">0</property>
@@ -108,8 +104,23 @@
108 </object> 104 </object>
109 </child> 105 </child>
110 <child> 106 <child>
107 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn">
108 <property name="sizing">fixed</property>
109 <property name="fixed_width">20</property>
110 <property name="reorderable">True</property>
111 <property name="sort_indicator">True</property>
112 <property name="sort_column_id">8</property>
113 <child>
114 <object class="GtkCellRendererPixbuf" id="GNUNET_PEERINFO_GTK_main_window_led_cellrendererpixbuf"/>
115 <attributes>
116 <attribute name="pixbuf">7</attribute>
117 </attributes>
118 </child>
119 </object>
120 </child>
121 <child>
111 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_column"> 122 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_column">
112 <property name="title" translatable="yes">In</property> 123 <property name="title">In</property>
113 <property name="clickable">True</property> 124 <property name="clickable">True</property>
114 <property name="reorderable">True</property> 125 <property name="reorderable">True</property>
115 <property name="sort_indicator">True</property> 126 <property name="sort_indicator">True</property>
@@ -125,7 +136,7 @@
125 </child> 136 </child>
126 <child> 137 <child>
127 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_out_treeviewcolumn"> 138 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_out_treeviewcolumn">
128 <property name="title" translatable="yes">Out</property> 139 <property name="title">Out</property>
129 <property name="clickable">True</property> 140 <property name="clickable">True</property>
130 <property name="sort_order">descending</property> 141 <property name="sort_order">descending</property>
131 <property name="sort_column_id">5</property> 142 <property name="sort_column_id">5</property>
@@ -140,7 +151,7 @@
140 <child> 151 <child>
141 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_country_column"> 152 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_country_column">
142 <property name="sizing">autosize</property> 153 <property name="sizing">autosize</property>
143 <property name="title" translatable="yes">Country</property> 154 <property name="title">Country</property>
144 <property name="clickable">True</property> 155 <property name="clickable">True</property>
145 <property name="reorderable">True</property> 156 <property name="reorderable">True</property>
146 <property name="sort_indicator">True</property> 157 <property name="sort_indicator">True</property>
@@ -156,7 +167,7 @@
156 <child> 167 <child>
157 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_address_treeviewcolumn"> 168 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_address_treeviewcolumn">
158 <property name="sizing">autosize</property> 169 <property name="sizing">autosize</property>
159 <property name="title" translatable="yes">Addresses</property> 170 <property name="title">Addresses</property>
160 <property name="expand">True</property> 171 <property name="expand">True</property>
161 <property name="clickable">True</property> 172 <property name="clickable">True</property>
162 <property name="sort_column_id">6</property> 173 <property name="sort_column_id">6</property>
@@ -172,8 +183,6 @@
172 </child> 183 </child>
173 </object> 184 </object>
174 <packing> 185 <packing>
175 <property name="expand">True</property>
176 <property name="fill">True</property>
177 <property name="position">1</property> 186 <property name="position">1</property>
178 </packing> 187 </packing>
179 </child> 188 </child>
diff --git a/src/fs/gnunet-fs-gtk_event-handler.c b/src/fs/gnunet-fs-gtk_event-handler.c
index 4c588547..c6044090 100644
--- a/src/fs/gnunet-fs-gtk_event-handler.c
+++ b/src/fs/gnunet-fs-gtk_event-handler.c
@@ -739,8 +739,8 @@ GNUNET_FS_GTK_search_treeview_popup_menu (GtkWidget *widget,
739 * @param widget the GtkTreeView with the search result list 739 * @param widget the GtkTreeView with the search result list
740 * @param event the event, we only care about button events 740 * @param event the event, we only care about button events
741 * @param user_data the 'struct SearchTab' the widget is in 741 * @param user_data the 'struct SearchTab' the widget is in
742 * @return FALSE if no menu could be popped up, 742 * @return FALSE to propagate the event further,
743 * TRUE if there is now a pop-up menu 743 * TRUE to stop the propagation
744 */ 744 */
745gboolean 745gboolean
746GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget, 746GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget,
@@ -765,10 +765,11 @@ GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget,
765 if (! gtk_tree_model_get_iter (tm, &iter, path)) 765 if (! gtk_tree_model_get_iter (tm, &iter, path))
766 return FALSE; /* not sure how we got a path but no iter... */ 766 return FALSE; /* not sure how we got a path but no iter... */
767 gtk_tree_path_free (path); 767 gtk_tree_path_free (path);
768 return search_list_popup (tm, tab, 768 search_list_popup (tm, tab,
769 event_button->button, 769 event_button->button,
770 event_button->time, 770 event_button->time,
771 &iter); 771 &iter);
772 return FALSE;
772} 773}
773 774
774 775
@@ -2767,14 +2768,14 @@ GNUNET_FS_GTK_publish_treeview_popup_menu (GtkWidget *widget,
2767 2768
2768 2769
2769/** 2770/**
2770 * We got a right-click on the search result list. Display the context 2771 * We got a button press on the search result list. Display the context
2771 * menu. 2772 * menu.
2772 * 2773 *
2773 * @param widget the GtkTreeView with the search result list 2774 * @param widget the GtkTreeView with the search result list
2774 * @param event the event, we only care about button events 2775 * @param event the event, we only care about button events
2775 * @param user_data the 'struct SearchTab' the widget is in 2776 * @param user_data the 'struct SearchTab' the widget is in
2776 * @return FALSE if no menu could be popped up, 2777 * @return FALSE to propagate the event further,
2777 * TRUE if there is now a pop-up menu 2778 * TRUE to stop the event propagation.
2778 */ 2779 */
2779gboolean 2780gboolean
2780GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget, 2781GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget,
@@ -2799,10 +2800,11 @@ GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget,
2799 if (! gtk_tree_model_get_iter (tm, &iter, path)) 2800 if (! gtk_tree_model_get_iter (tm, &iter, path))
2800 return FALSE; /* not sure how we got a path but no iter... */ 2801 return FALSE; /* not sure how we got a path but no iter... */
2801 gtk_tree_path_free (path); 2802 gtk_tree_path_free (path);
2802 return publish_list_popup (tm, tab, 2803 publish_list_popup (tm, tab,
2803 event_button->button, 2804 event_button->button,
2804 event_button->time, 2805 event_button->time,
2805 &iter); 2806 &iter);
2807 return FALSE; /* propagate further, to focus on the item (for example) */
2806} 2808}
2807 2809
2808 2810
diff --git a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
index f209415d..f5ecc1ab 100644
--- a/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
+++ b/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
@@ -163,7 +163,7 @@ GNUNET_GTK_main_window_metadata_treeview_button_press_event_cb (GtkWidget *
163 do_metadata_popup_menu (event->button, 163 do_metadata_popup_menu (event->button,
164 event->time, 164 event->time,
165 user_data); 165 user_data);
166 return TRUE; 166 return FALSE;
167} 167}
168 168
169 169
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c
index 6d8569e8..85df3f3b 100644
--- a/src/peerinfo/gnunet-peerinfo-gtk.c
+++ b/src/peerinfo/gnunet-peerinfo-gtk.c
@@ -68,7 +68,17 @@ enum PEERINFO_ModelColumns
68 /** 68 /**
69 * A gchararray 69 * A gchararray
70 */ 70 */
71 PEERINFO_MC_ADDRESS_AS_STRING = 6 71 PEERINFO_MC_ADDRESS_AS_STRING = 6,
72
73 /**
74 * A GdkPixbuf
75 */
76 PEERINFO_MC_CONNECTIVITY_LED = 7,
77
78 /**
79 * A gboolean
80 */
81 PEERINFO_MC_CONNECTED_STATUS = 8
72 }; 82 };
73 83
74 84
@@ -124,6 +134,22 @@ static struct GNUNET_CONTAINER_MultiHashMap *peer2info;
124 */ 134 */
125static int tray_only; 135static int tray_only;
126 136
137/**
138 * Green status led (connected)
139 */
140static GdkPixbuf *led_green;
141
142/**
143 * Red status led (disconnected)
144 */
145static GdkPixbuf *led_red;
146
147/**
148 * Main window list store.
149 */
150static GtkListStore *ls;
151
152
127 153
128/** 154/**
129 * Get cfg. 155 * Get cfg.
@@ -212,19 +238,15 @@ static void
212peer_address_string_cb (void *cls, const char *address) 238peer_address_string_cb (void *cls, const char *address)
213{ 239{
214 struct PeerInfo *info = cls; 240 struct PeerInfo *info = cls;
215 GtkListStore *ls;
216 GtkTreeModel *tm;
217 GtkTreeIter iter; 241 GtkTreeIter iter;
218 GtkTreePath *path; 242 GtkTreePath *path;
219 char *country; 243 char *country;
220 const char *colon; 244 const char *colon;
221 const char *dot; 245 const char *dot;
222 246
223 ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
224 tm = GTK_TREE_MODEL (ls);
225 path = gtk_tree_row_reference_get_path (info->rr); 247 path = gtk_tree_row_reference_get_path (info->rr);
226 GNUNET_assert (NULL != path); 248 GNUNET_assert (NULL != path);
227 GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); 249 GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
228 gtk_tree_path_free (path); 250 gtk_tree_path_free (path);
229 if (NULL == address) 251 if (NULL == address)
230 { 252 {
@@ -235,6 +257,8 @@ peer_address_string_cb (void *cls, const char *address)
235 PEERINFO_MC_COUNTRY_NAME, NULL, 257 PEERINFO_MC_COUNTRY_NAME, NULL,
236 PEERINFO_MC_COUNTRY_FLAG, NULL, 258 PEERINFO_MC_COUNTRY_FLAG, NULL,
237 PEERINFO_MC_ADDRESS_AS_STRING, "<no address>", 259 PEERINFO_MC_ADDRESS_AS_STRING, "<no address>",
260 PEERINFO_MC_CONNECTIVITY_LED, led_green,
261 PEERINFO_MC_CONNECTED_STATUS, TRUE,
238 -1); 262 -1);
239 info->tos = NULL; 263 info->tos = NULL;
240 return; 264 return;
@@ -255,6 +279,8 @@ peer_address_string_cb (void *cls, const char *address)
255 PEERINFO_MC_COUNTRY_NAME, country, 279 PEERINFO_MC_COUNTRY_NAME, country,
256 PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag (country), 280 PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag (country),
257 PEERINFO_MC_ADDRESS_AS_STRING, address, 281 PEERINFO_MC_ADDRESS_AS_STRING, address,
282 PEERINFO_MC_CONNECTIVITY_LED, led_green,
283 PEERINFO_MC_CONNECTED_STATUS, TRUE,
258 -1); 284 -1);
259 GNUNET_free (country); 285 GNUNET_free (country);
260 info->got_address = GNUNET_YES; 286 info->got_address = GNUNET_YES;
@@ -273,28 +299,28 @@ peer_address_cb (void *cls, const struct GNUNET_PeerIdentity *peer,
273 const struct GNUNET_HELLO_Address *address) 299 const struct GNUNET_HELLO_Address *address)
274{ 300{
275 struct PeerInfo *info = cls; 301 struct PeerInfo *info = cls;
276 GtkListStore *ls;
277 GtkTreeModel *tm;
278 GtkTreeIter iter; 302 GtkTreeIter iter;
279 GtkTreePath *path; 303 GtkTreePath *path;
280 304
305 path = gtk_tree_row_reference_get_path (info->rr);
306 GNUNET_assert (NULL != path);
307 GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
308 gtk_tree_path_free (path);
281 if (NULL == address) 309 if (NULL == address)
282 { 310 {
283 /* disconnect */ 311 /* disconnect */
284 ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
285 tm = GTK_TREE_MODEL (ls);
286 path = gtk_tree_row_reference_get_path (info->rr);
287 GNUNET_assert (NULL != path);
288 GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path));
289 gtk_tree_path_free (path);
290 gtk_list_store_set (ls, &iter, 312 gtk_list_store_set (ls, &iter,
291 PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0, 313 PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0,
292 PEERINFO_MC_COUNTRY_NAME, NULL, 314 PEERINFO_MC_CONNECTIVITY_LED, led_red,
293 PEERINFO_MC_COUNTRY_FLAG, NULL, 315 PEERINFO_MC_CONNECTED_STATUS, FALSE,
294 PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>",
295 -1); 316 -1);
296 return; 317 return;
297 } 318 }
319 gtk_list_store_set (ls, &iter,
320 PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
321 PEERINFO_MC_CONNECTIVITY_LED, led_green,
322 PEERINFO_MC_CONNECTED_STATUS, TRUE,
323 -1);
298 if (NULL != info->tos) 324 if (NULL != info->tos)
299 GNUNET_TRANSPORT_address_to_string_cancel (info->tos); 325 GNUNET_TRANSPORT_address_to_string_cancel (info->tos);
300 info->got_address = GNUNET_NO; 326 info->got_address = GNUNET_NO;
@@ -319,21 +345,12 @@ peerinfo_processor (void *cls, const struct GNUNET_PeerIdentity *peer,
319 const struct GNUNET_HELLO_Message *hello, 345 const struct GNUNET_HELLO_Message *hello,
320 const char *err_msg) 346 const char *err_msg)
321{ 347{
322 GtkListStore *ls;
323 GtkTreeModel *tm;
324 GtkTreeIter iter; 348 GtkTreeIter iter;
325 char *npid; 349 char *npid;
326 struct GNUNET_CRYPTO_HashAsciiEncoded enc; 350 struct GNUNET_CRYPTO_HashAsciiEncoded enc;
327 struct PeerInfo *info; 351 struct PeerInfo *info;
328 GtkTreePath *path; 352 GtkTreePath *path;
329 353
330 ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
331 if (NULL == ls)
332 {
333 GNUNET_break (0);
334 return;
335 }
336 tm = GTK_TREE_MODEL (ls);
337 info = GNUNET_CONTAINER_multihashmap_get (peer2info, &peer->hashPubKey); 354 info = GNUNET_CONTAINER_multihashmap_get (peer2info, &peer->hashPubKey);
338 if (NULL == info) 355 if (NULL == info)
339 { 356 {
@@ -348,11 +365,13 @@ peerinfo_processor (void *cls, const struct GNUNET_PeerIdentity *peer,
348 PEERINFO_MC_COUNTRY_FLAG, NULL, 365 PEERINFO_MC_COUNTRY_FLAG, NULL,
349 PEERINFO_MC_BANDWIDTH_IN, (guint64) 0, 366 PEERINFO_MC_BANDWIDTH_IN, (guint64) 0,
350 PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0, 367 PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0,
351 PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>", 368 PEERINFO_MC_ADDRESS_AS_STRING, "",
369 PEERINFO_MC_CONNECTIVITY_LED, led_red,
370 PEERINFO_MC_CONNECTED_STATUS, FALSE,
352 -1); 371 -1);
353 path = gtk_tree_model_get_path (tm, &iter); 372 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter);
354 info = GNUNET_malloc (sizeof (struct PeerInfo)); 373 info = GNUNET_malloc (sizeof (struct PeerInfo));
355 info->rr = gtk_tree_row_reference_new (tm, path); 374 info->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path);
356 GNUNET_assert (NULL != info->rr); 375 GNUNET_assert (NULL != info->rr);
357 gtk_tree_path_free (path); 376 gtk_tree_path_free (path);
358 GNUNET_CONTAINER_multihashmap_put (peer2info, &peer->hashPubKey, info, 377 GNUNET_CONTAINER_multihashmap_put (peer2info, &peer->hashPubKey, info,
@@ -388,19 +407,15 @@ status_cb (void *cls,
388 uint32_t ats_count) 407 uint32_t ats_count)
389{ 408{
390 struct PeerInfo *info; 409 struct PeerInfo *info;
391 GtkListStore *ls;
392 GtkTreeModel *tm;
393 GtkTreeIter iter; 410 GtkTreeIter iter;
394 GtkTreePath *path; 411 GtkTreePath *path;
395 412
396 info = GNUNET_CONTAINER_multihashmap_get (peer2info, &address->peer.hashPubKey); 413 info = GNUNET_CONTAINER_multihashmap_get (peer2info, &address->peer.hashPubKey);
397 if (NULL == info) 414 if (NULL == info)
398 return; /* should rarely happen... */ 415 return; /* should rarely happen... */
399 ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
400 tm = GTK_TREE_MODEL (ls);
401 path = gtk_tree_row_reference_get_path (info->rr); 416 path = gtk_tree_row_reference_get_path (info->rr);
402 GNUNET_assert (NULL != path); 417 GNUNET_assert (NULL != path);
403 GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path)); 418 GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter, path));
404 gtk_tree_path_free (path); 419 gtk_tree_path_free (path);
405 gtk_list_store_set (ls, &iter, 420 gtk_list_store_set (ls, &iter,
406 PEERINFO_MC_BANDWIDTH_IN, (guint64) ntohl (bandwidth_in.value__), 421 PEERINFO_MC_BANDWIDTH_IN, (guint64) ntohl (bandwidth_in.value__),
@@ -425,6 +440,29 @@ GNUNET_PEERINFO_GTK_quit_cb (GObject * object, gpointer user_data)
425 440
426 441
427/** 442/**
443 * Load LED image from resource file.
444 *
445 * @param color color of the LED to load
446 * @return the image as a GdkPixbuf
447 */
448static GdkPixbuf *
449load_led (const char *color)
450{
451 GdkPixbuf *pixbuf;
452 char *dir;
453 char *fn;
454
455 dir = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR);
456 GNUNET_asprintf (&fn, "%s%s.png", dir,
457 color);
458 GNUNET_free (dir);
459 pixbuf = gdk_pixbuf_new_from_file (fn, NULL);
460 GNUNET_free (fn);
461 return pixbuf;
462}
463
464
465/**
428 * Actual main function run right after GNUnet's scheduler 466 * Actual main function run right after GNUnet's scheduler
429 * is initialized. Initializes up GTK and Glade. 467 * is initialized. Initializes up GTK and Glade.
430 * 468 *
@@ -442,7 +480,8 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
442 { 480 {
443 return; 481 return;
444 } 482 }
445 483 led_green = load_led ("green");
484 led_red = load_led ("red");
446 GNUNET_GTK_set_icon_search_path (); 485 GNUNET_GTK_set_icon_search_path ();
447 GNUNET_GTK_setup_nls (); 486 GNUNET_GTK_setup_nls ();
448 peer2info = GNUNET_CONTAINER_multihashmap_create (256); 487 peer2info = GNUNET_CONTAINER_multihashmap_create (256);
@@ -457,6 +496,8 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
457 ats = GNUNET_ATS_performance_init (get_configuration (), &status_cb, NULL); 496 ats = GNUNET_ATS_performance_init (get_configuration (), &status_cb, NULL);
458 /* setup main window */ 497 /* setup main window */
459 main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window")); 498 main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window"));
499 ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
500 GNUNET_assert (NULL != ls);
460 gtk_window_maximize (GTK_WINDOW (main_window)); 501 gtk_window_maximize (GTK_WINDOW (main_window));
461 GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window), 502 GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
462 "gnunet-gtk" /* FIXME: different icon? */ , 503 "gnunet-gtk" /* FIXME: different icon? */ ,