aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2014-01-10 12:25:23 +0000
committerChristian Grothoff <christian@grothoff.org>2014-01-10 12:25:23 +0000
commitca8b1b7433ccf6c3a879578abaa22af16dae0b79 (patch)
treed8fe2fd988446237cb83989af6e1e69e385da4c4
parent8f2e873852c7d43804a777f537204400f80c9f14 (diff)
downloadgnunet-gtk-ca8b1b7433ccf6c3a879578abaa22af16dae0b79.tar.gz
gnunet-gtk-ca8b1b7433ccf6c3a879578abaa22af16dae0b79.zip
adding tooltips to highlight expiration times to gnunet-peerinfo-gtk
-rw-r--r--contrib/gnunet_peerinfo_gtk_main_window.glade18
-rw-r--r--src/peerinfo/gnunet-peerinfo-gtk.c111
2 files changed, 120 insertions, 9 deletions
diff --git a/contrib/gnunet_peerinfo_gtk_main_window.glade b/contrib/gnunet_peerinfo_gtk_main_window.glade
index d63e7e19..80a92c7a 100644
--- a/contrib/gnunet_peerinfo_gtk_main_window.glade
+++ b/contrib/gnunet_peerinfo_gtk_main_window.glade
@@ -204,7 +204,7 @@
204 </object> 204 </object>
205 </child> 205 </child>
206 <child> 206 <child>
207 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn"> 207 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_core_connectivity_treeviewcolumn">
208 <property name="spacing">2</property> 208 <property name="spacing">2</property>
209 <property name="sizing">autosize</property> 209 <property name="sizing">autosize</property>
210 <property name="widget">connected_image_core</property> 210 <property name="widget">connected_image_core</property>
@@ -220,7 +220,7 @@
220 </object> 220 </object>
221 </child> 221 </child>
222 <child> 222 <child>
223 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_plugin_treeviewcolumn"> 223 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_plugin_connectivity_treeviewcolumn">
224 <property name="widget">connected_image_plugin</property> 224 <property name="widget">connected_image_plugin</property>
225 <property name="reorderable">True</property> 225 <property name="reorderable">True</property>
226 <property name="sort_indicator">True</property> 226 <property name="sort_indicator">True</property>
@@ -234,7 +234,7 @@
234 </object> 234 </object>
235 </child> 235 </child>
236 <child> 236 <child>
237 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_core_timeout_treeviewcolumn"> 237 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_ats_connectivity_treeviewcolumn">
238 <property name="widget">connected_image_ats</property> 238 <property name="widget">connected_image_ats</property>
239 <child> 239 <child>
240 <object class="GtkCellRendererPixbuf" id="GNUNET_PEERINFO_GTK_main_window_ats_led_cellrendererpixbuf"/> 240 <object class="GtkCellRendererPixbuf" id="GNUNET_PEERINFO_GTK_main_window_ats_led_cellrendererpixbuf"/>
@@ -246,7 +246,7 @@
246 </object> 246 </object>
247 </child> 247 </child>
248 <child> 248 <child>
249 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_transport_led_treeviewcolumn"> 249 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_transport_connectivity_treeviewcolumn">
250 <property name="widget">connected_image_neighbours</property> 250 <property name="widget">connected_image_neighbours</property>
251 <property name="reorderable">True</property> 251 <property name="reorderable">True</property>
252 <property name="sort_indicator">True</property> 252 <property name="sort_indicator">True</property>
@@ -260,7 +260,7 @@
260 </object> 260 </object>
261 </child> 261 </child>
262 <child> 262 <child>
263 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_validation_led_treeviewcolumn"> 263 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_validation_status_treeviewcolumn">
264 <property name="widget">validated_image</property> 264 <property name="widget">validated_image</property>
265 <property name="reorderable">True</property> 265 <property name="reorderable">True</property>
266 <property name="sort_indicator">True</property> 266 <property name="sort_indicator">True</property>
@@ -305,7 +305,7 @@
305 </object> 305 </object>
306 </child> 306 </child>
307 <child> 307 <child>
308 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_column"> 308 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_bandwidth_in_column">
309 <property name="title">In</property> 309 <property name="title">In</property>
310 <property name="clickable">True</property> 310 <property name="clickable">True</property>
311 <property name="reorderable">True</property> 311 <property name="reorderable">True</property>
@@ -341,7 +341,7 @@
341 <property name="sort_indicator">True</property> 341 <property name="sort_indicator">True</property>
342 <property name="sort_column_id">11</property> 342 <property name="sort_column_id">11</property>
343 <child> 343 <child>
344 <object class="GtkCellRendererText" id="cellrenderertext1"/> 344 <object class="GtkCellRendererText" id="GNUNET_PEERINFO_GTK_main_window_plugin_name_cellrenderertext"/>
345 <attributes> 345 <attributes>
346 <attribute name="text">11</attribute> 346 <attribute name="text">11</attribute>
347 </attributes> 347 </attributes>
@@ -349,14 +349,14 @@
349 </object> 349 </object>
350 </child> 350 </child>
351 <child> 351 <child>
352 <object class="GtkTreeViewColumn" id="treeviewcolumn1"> 352 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_neighbour_state_treeviewcolumn">
353 <property name="sizing">autosize</property> 353 <property name="sizing">autosize</property>
354 <property name="title" translatable="yes">State</property> 354 <property name="title" translatable="yes">State</property>
355 <property name="reorderable">True</property> 355 <property name="reorderable">True</property>
356 <property name="sort_indicator">True</property> 356 <property name="sort_indicator">True</property>
357 <property name="sort_column_id">16</property> 357 <property name="sort_column_id">16</property>
358 <child> 358 <child>
359 <object class="GtkCellRendererText" id="cellrenderertext2"/> 359 <object class="GtkCellRendererText" id="GNUNET_PEERINFO_GTK_main_window_neighbour_state_cellrenderertext"/>
360 <attributes> 360 <attributes>
361 <attribute name="text">16</attribute> 361 <attribute name="text">16</attribute>
362 </attributes> 362 </attributes>
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c
index e9d5b8e9..71c3ff15 100644
--- a/src/peerinfo/gnunet-peerinfo-gtk.c
+++ b/src/peerinfo/gnunet-peerinfo-gtk.c
@@ -356,6 +356,36 @@ static GtkTreeStore *ts;
356 */ 356 */
357static struct GNUNET_CONTAINER_MultiPeerMap *friends; 357static struct GNUNET_CONTAINER_MultiPeerMap *friends;
358 358
359/**
360 * Tree view column for CORE connecitivity.
361 */
362static GtkTreeViewColumn *tvc_core_connectivity;
363
364/**
365 * Tree view column for TRANSPORT connecitivity.
366 */
367static GtkTreeViewColumn *tvc_transport_connectivity;
368
369/**
370 * Tree view column for ATS connecitivity.
371 */
372static GtkTreeViewColumn *tvc_ats_connectivity;
373
374/**
375 * Tree view column for plugin connecitivity.
376 */
377static GtkTreeViewColumn *tvc_plugin_connectivity;
378
379/**
380 * Tree view column for validation status
381 */
382static GtkTreeViewColumn *tvc_validation_status;
383
384/**
385 * Tree view column for neighbour_state
386 */
387static GtkTreeViewColumn *tvc_neighbour_state;
388
359 389
360#if HAVE_LIBUNIQUE 390#if HAVE_LIBUNIQUE
361static UniqueApp *unique_app; 391static UniqueApp *unique_app;
@@ -1070,6 +1100,74 @@ add_friend (void *cts,
1070 1100
1071 1101
1072/** 1102/**
1103 * Return the tooltip for the given coordinate.
1104 *
1105 * @param widget our tree view
1106 * @param x x-coordinate
1107 * @param y y-coordinate
1108 * @param keyboard_tip triggered by keyboard?
1109 * @param tooltip tooltip object to fill
1110 * @param data NULL
1111 * @return TRUE if a tooltip was provided
1112 */
1113static gboolean
1114query_tooltip_cb (GtkWidget *widget,
1115 gint x,
1116 gint y,
1117 gboolean keyboard_tip,
1118 GtkTooltip *tooltip,
1119 gpointer data)
1120{
1121 GtkTreeView *tv = GTK_TREE_VIEW (widget);
1122 GtkTreeModel *model = GTK_TREE_MODEL (ts);
1123 GtkTreeIter iter;
1124 GtkTreePath *path;
1125 GtkTreeViewColumn *column;
1126 int model_column = -1;
1127 gchar *tmp;
1128
1129 if (! gtk_tree_view_get_tooltip_context (tv, &x, &y,
1130 keyboard_tip,
1131 &model, &path, &iter))
1132 return FALSE;
1133 if (! gtk_tree_view_get_path_at_pos (tv, x, y, NULL, &column, NULL, NULL))
1134 return FALSE;
1135
1136 if (tvc_core_connectivity == column)
1137 model_column = -1;
1138 else if (tvc_plugin_connectivity == column)
1139 model_column = PEERINFO_MC_PLUGIN_CONNECTIVITY_TIMEOUT_AS_STRING;
1140 else if (tvc_ats_connectivity == column)
1141 model_column = PEERINFO_MC_PEERINFO_ADDRESS_EXPIRATION;
1142 else if (tvc_transport_connectivity == column)
1143 model_column = PEERINFO_MC_NEIGHBOUR_CONNECTIVITY_TIMEOUT_AS_STRING;
1144 else if (tvc_validation_status == column)
1145 model_column = PEERINFO_MC_VALIDATION_TIMEOUT_AS_STRING;
1146 else if (tvc_neighbour_state == column)
1147 model_column = PEERINFO_MC_NEIGHBOUR_STATE_TIMEOUT_AS_STRING;
1148 if (-1 == model_column)
1149 return FALSE;
1150
1151 gtk_tree_model_get (model,
1152 &iter,
1153 model_column, &tmp,
1154 -1);
1155 if (NULL == tmp)
1156 return FALSE;
1157 gtk_tooltip_set_text (tooltip,
1158 tmp);
1159 gtk_tree_view_set_tooltip_cell (tv,
1160 tooltip,
1161 path,
1162 column,
1163 NULL);
1164 g_free (tmp);
1165 gtk_tree_path_free (path);
1166 return TRUE;
1167}
1168
1169
1170/**
1073 * Actual main function run right after GNUnet's scheduler 1171 * Actual main function run right after GNUnet's scheduler
1074 * is initialized. Initializes up GTK and Glade. 1172 * is initialized. Initializes up GTK and Glade.
1075 * 1173 *
@@ -1081,6 +1179,7 @@ run (void *cts,
1081 const struct GNUNET_SCHEDULER_TaskContext *tc) 1179 const struct GNUNET_SCHEDULER_TaskContext *tc)
1082{ 1180{
1083 GtkWidget *main_window; 1181 GtkWidget *main_window;
1182 GtkTreeView *tv;
1084 1183
1085 ml = cts; 1184 ml = cts;
1086 if (GNUNET_OK != 1185 if (GNUNET_OK !=
@@ -1123,6 +1222,12 @@ run (void *cts,
1123 NULL); 1222 NULL);
1124 ats = GNUNET_ATS_performance_init (get_configuration (), 1223 ats = GNUNET_ATS_performance_init (get_configuration (),
1125 &status_cb, NULL); 1224 &status_cb, NULL);
1225 tvc_core_connectivity = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_core_connectivity_treeviewcolumn"));
1226 tvc_ats_connectivity = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_ats_connectivity_treeviewcolumn"));
1227 tvc_plugin_connectivity = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_plugin_connectivity_treeviewcolumn"));
1228 tvc_transport_connectivity = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_transport_connectivity_treeviewcolumn"));
1229 tvc_validation_status = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_validation_status_treeviewcolumn"));
1230 tvc_neighbour_state = GTK_TREE_VIEW_COLUMN (get_object ("GNUNET_PEERINFO_GTK_main_window_neighbour_state_treeviewcolumn"));
1126 /* setup main window */ 1231 /* setup main window */
1127 main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window")); 1232 main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window"));
1128 main_window = GNUNET_GTK_plug_me ("GNUNET_PEERINFO_GTK_PLUG", 1233 main_window = GNUNET_GTK_plug_me ("GNUNET_PEERINFO_GTK_PLUG",
@@ -1136,6 +1241,12 @@ run (void *cts,
1136 "gnunet-gtk" /* FIXME: different icon? */ , 1241 "gnunet-gtk" /* FIXME: different icon? */ ,
1137 "gnunet-peerinfo-gtk"); 1242 "gnunet-peerinfo-gtk");
1138 1243
1244 tv = GTK_TREE_VIEW (get_object ("GNUNET_PEERINFO_GTK_main_window_treeview"));
1245 g_object_set (tv, "has-tooltip", TRUE, NULL);
1246 g_signal_connect (tv, "query-tooltip",
1247 G_CALLBACK (query_tooltip_cb),
1248 NULL);
1249
1139#if HAVE_LIBUNIQUE 1250#if HAVE_LIBUNIQUE
1140 unique_app_watch_window (unique_app, GTK_WINDOW (main_window)); 1251 unique_app_watch_window (unique_app, GTK_WINDOW (main_window));
1141#endif 1252#endif