aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2013-10-07 18:48:20 +0000
committerChristian Grothoff <christian@grothoff.org>2013-10-07 18:48:20 +0000
commit369e278d9e3817774672fab38126dbdf59c9dc45 (patch)
tree3157b6e2d33c813baa5ae149dceffc7548653e3d
parentd81312d3f27cb390c23778619af3586de0679b5f (diff)
downloadgnunet-gtk-369e278d9e3817774672fab38126dbdf59c9dc45.tar.gz
gnunet-gtk-369e278d9e3817774672fab38126dbdf59c9dc45.zip
-display current friends, editing not yet supported
-rw-r--r--contrib/gnunet_peerinfo_gtk_main_window.glade44
-rw-r--r--src/peerinfo/Makefile.am2
-rw-r--r--src/peerinfo/gnunet-peerinfo-gtk.c52
3 files changed, 90 insertions, 8 deletions
diff --git a/contrib/gnunet_peerinfo_gtk_main_window.glade b/contrib/gnunet_peerinfo_gtk_main_window.glade
index f963e356..e325c6cf 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"?> 1<?xml version="1.0" encoding="UTF-8"?>
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 -->
@@ -27,36 +27,43 @@
27 </columns> 27 </columns>
28 </object> 28 </object>
29 <object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window"> 29 <object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window">
30 <property name="can_focus">False</property>
30 <property name="title" translatable="yes">gnunet-peerinfo-gtk</property> 31 <property name="title" translatable="yes">gnunet-peerinfo-gtk</property>
31 <property name="window_position">center</property> 32 <property name="window_position">center</property>
32 <property name="default_width">700</property> 33 <property name="default_width">700</property>
33 <property name="default_height">500</property> 34 <property name="default_height">500</property>
34 <property name="icon_name">gnunet-gtk</property> 35 <property name="icon_name">gnunet-gtk</property>
35 <signal name="delete_event" handler="GNUNET_PEERINFO_GTK_quit_cb" after="yes"/> 36 <signal name="delete-event" handler="GNUNET_PEERINFO_GTK_quit_cb" after="yes" swapped="no"/>
36 <child> 37 <child>
37 <object class="GtkVBox" id="GNUNET_PEERINFO_GTK_main_window_vbox"> 38 <object class="GtkVBox" id="GNUNET_PEERINFO_GTK_main_window_vbox">
38 <property name="visible">True</property> 39 <property name="visible">True</property>
39 <property name="orientation">vertical</property> 40 <property name="can_focus">False</property>
40 <child> 41 <child>
41 <object class="GtkMenuBar" id="GNUNET_PEERINFO_GTK_main_menu"> 42 <object class="GtkMenuBar" id="GNUNET_PEERINFO_GTK_main_menu">
42 <property name="visible">True</property> 43 <property name="visible">True</property>
44 <property name="can_focus">False</property>
43 <child> 45 <child>
44 <object class="GtkMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help"> 46 <object class="GtkMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help">
47 <property name="use_action_appearance">False</property>
45 <property name="visible">True</property> 48 <property name="visible">True</property>
49 <property name="can_focus">False</property>
46 <property name="label" translatable="yes">_Help</property> 50 <property name="label" translatable="yes">_Help</property>
47 <property name="use_underline">True</property> 51 <property name="use_underline">True</property>
48 <child type="submenu"> 52 <child type="submenu">
49 <object class="GtkMenu" id="GNUNET_PEERINFO_GTK_main_menu_help_abou"> 53 <object class="GtkMenu" id="GNUNET_PEERINFO_GTK_main_menu_help_abou">
50 <property name="visible">True</property> 54 <property name="visible">True</property>
55 <property name="can_focus">False</property>
51 <child> 56 <child>
52 <object class="GtkImageMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help_about"> 57 <object class="GtkImageMenuItem" id="GNUNET_PEERINFO_GTK_main_menu_help_about">
53 <property name="label">gtk-about</property> 58 <property name="label">gtk-about</property>
59 <property name="use_action_appearance">False</property>
54 <property name="visible">True</property> 60 <property name="visible">True</property>
61 <property name="can_focus">False</property>
55 <property name="tooltip_text" translatable="yes">Display information about this version of gnunet-peerinfo-gtk</property> 62 <property name="tooltip_text" translatable="yes">Display information about this version of gnunet-peerinfo-gtk</property>
56 <property name="accel_path">&lt;gnunet-peerinfo-gtk&gt;/Help/About</property> 63 <property name="accel_path">&lt;gnunet-peerinfo-gtk&gt;/Help/About</property>
57 <property name="use_underline">True</property> 64 <property name="use_underline">True</property>
58 <property name="use_stock">True</property> 65 <property name="use_stock">True</property>
59 <signal name="activate" handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb"/> 66 <signal name="activate" handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb" swapped="no"/>
60 </object> 67 </object>
61 </child> 68 </child>
62 </object> 69 </object>
@@ -66,6 +73,7 @@
66 </object> 73 </object>
67 <packing> 74 <packing>
68 <property name="expand">False</property> 75 <property name="expand">False</property>
76 <property name="fill">True</property>
69 <property name="position">0</property> 77 <property name="position">0</property>
70 </packing> 78 </packing>
71 </child> 79 </child>
@@ -106,9 +114,26 @@
106 </object> 114 </object>
107 </child> 115 </child>
108 <child> 116 <child>
117 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_friends_treeviewcolumn">
118 <property name="title" translatable="yes">Friend</property>
119 <property name="clickable">True</property>
120 <property name="reorderable">True</property>
121 <property name="sort_indicator">True</property>
122 <property name="sort_column_id">9</property>
123 <child>
124 <object class="GtkCellRendererToggle" id="GNUNET_PEERINFO_GTK_main_window_friends_cellrenderertoggle">
125 <signal name="toggled" handler="GNUNET_PEERINFO_GTK_main_window_friends_cellrenderertoggle_toggled_cb" swapped="no"/>
126 </object>
127 <attributes>
128 <attribute name="active">9</attribute>
129 </attributes>
130 </child>
131 </object>
132 </child>
133 <child>
109 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn"> 134 <object class="GtkTreeViewColumn" id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn">
110 <property name="sizing">fixed</property> 135 <property name="spacing">2</property>
111 <property name="fixed_width">20</property> 136 <property name="sizing">autosize</property>
112 <property name="reorderable">True</property> 137 <property name="reorderable">True</property>
113 <property name="sort_indicator">True</property> 138 <property name="sort_indicator">True</property>
114 <property name="sort_column_id">8</property> 139 <property name="sort_column_id">8</property>
@@ -185,6 +210,8 @@
185 </child> 210 </child>
186 </object> 211 </object>
187 <packing> 212 <packing>
213 <property name="expand">True</property>
214 <property name="fill">True</property>
188 <property name="position">1</property> 215 <property name="position">1</property>
189 </packing> 216 </packing>
190 </child> 217 </child>
@@ -203,4 +230,9 @@
203 <property name="page_increment">10</property> 230 <property name="page_increment">10</property>
204 <property name="page_size">10</property> 231 <property name="page_size">10</property>
205 </object> 232 </object>
233 <object class="GtkImage" id="connected_image">
234 <property name="visible">True</property>
235 <property name="can_focus">False</property>
236 <property name="stock">gtk-missing-image</property>
237 </object>
206</interface> 238</interface>
diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am
index ec4271fa..7643d316 100644
--- a/src/peerinfo/Makefile.am
+++ b/src/peerinfo/Makefile.am
@@ -18,7 +18,7 @@ gnunet_peerinfo_gtk_LDADD = \
18 $(top_builddir)/src/lib/libgnunetgtk.la \ 18 $(top_builddir)/src/lib/libgnunetgtk.la \
19 @GTK_LIBS@ \ 19 @GTK_LIBS@ \
20 @GLADE_LIBS@ @GNUNET_LIBS@ @unique_LIBS@ \ 20 @GLADE_LIBS@ @GNUNET_LIBS@ @unique_LIBS@ \
21 -lgnunetutil -lgnunetpeerinfo -lgnunettransport -lgnunetats \ 21 -lgnunetutil -lgnunetpeerinfo -lgnunettransport -lgnunetats -lgnunetfriends \
22 $(INTLLIBS) 22 $(INTLLIBS)
23gnunet_peerinfo_gtk_LDFLAGS = \ 23gnunet_peerinfo_gtk_LDFLAGS = \
24 -export-dynamic 24 -export-dynamic
diff --git a/src/peerinfo/gnunet-peerinfo-gtk.c b/src/peerinfo/gnunet-peerinfo-gtk.c
index 3a8e46b9..12d66124 100644
--- a/src/peerinfo/gnunet-peerinfo-gtk.c
+++ b/src/peerinfo/gnunet-peerinfo-gtk.c
@@ -1,6 +1,6 @@
1/* 1/*
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 (C) 2010, 2012 Christian Grothoff (and other contributing authors) 3 (C) 2010, 2012, 2013 Christian Grothoff (and other contributing authors)
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
@@ -27,6 +27,7 @@
27#include <gnunet/gnunet_peerinfo_service.h> 27#include <gnunet/gnunet_peerinfo_service.h>
28#include <gnunet/gnunet_transport_service.h> 28#include <gnunet/gnunet_transport_service.h>
29#include <gnunet/gnunet_ats_service.h> 29#include <gnunet/gnunet_ats_service.h>
30#include <gnunet/gnunet_friends_lib.h>
30#include "gnunet-peerinfo-gtk-flags.h" 31#include "gnunet-peerinfo-gtk-flags.h"
31 32
32#if HAVE_LIBUNIQUE 33#if HAVE_LIBUNIQUE
@@ -158,6 +159,11 @@ static GdkPixbuf *led_red;
158 */ 159 */
159static GtkListStore *ls; 160static GtkListStore *ls;
160 161
162/**
163 * Map of all of our friends.
164 */
165static struct GNUNET_CONTAINER_MultiPeerMap *friends;
166
161 167
162#if HAVE_LIBUNIQUE 168#if HAVE_LIBUNIQUE
163static UniqueApp *unique_app; 169static UniqueApp *unique_app;
@@ -384,6 +390,8 @@ peerinfo_processor (void *cls, const struct GNUNET_PeerIdentity *peer,
384 PEERINFO_MC_ADDRESS_AS_STRING, "", 390 PEERINFO_MC_ADDRESS_AS_STRING, "",
385 PEERINFO_MC_CONNECTIVITY_LED, led_red, 391 PEERINFO_MC_CONNECTIVITY_LED, led_red,
386 PEERINFO_MC_CONNECTED_STATUS, FALSE, 392 PEERINFO_MC_CONNECTED_STATUS, FALSE,
393 PEERINFO_MC_IS_FRIEND, GNUNET_CONTAINER_multipeermap_contains (friends,
394 peer),
387 -1); 395 -1);
388 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter); 396 path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter);
389 info = GNUNET_malloc (sizeof (struct PeerInfo)); 397 info = GNUNET_malloc (sizeof (struct PeerInfo));
@@ -446,6 +454,23 @@ status_cb (void *cls,
446 454
447 455
448/** 456/**
457 * The user has toggled the 'is friend' column for one of the peers.
458 * Update everything.
459 *
460 * @param cell_renderer the cell renderer that issued the toggle signal
461 * @param path which cell was toggled
462 * @param user_data our main window builder
463 */
464void
465GNUNET_PEERINFO_GTK_main_window_friends_cellrenderertoggle_toggled_cb (GtkCellRendererToggle *cell_renderer,
466 gchar *path,
467 gpointer user_data)
468{
469 GNUNET_break (0); // not implemented
470}
471
472
473/**
449 * Callback invoked if the application is supposed to exit. 474 * Callback invoked if the application is supposed to exit.
450 * 475 *
451 * @param object 476 * @param object
@@ -482,6 +507,24 @@ load_led (const char *color)
482 507
483 508
484/** 509/**
510 * Add a friend to our friends peer map.
511 *
512 * @param cls NULL
513 * @param friend the friend to add
514 */
515static void
516add_friend (void *cls,
517 const struct GNUNET_PeerIdentity *friend)
518{
519 GNUNET_break (GNUNET_YES ==
520 GNUNET_CONTAINER_multipeermap_put (friends,
521 friend,
522 "true",
523 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY));
524}
525
526
527/**
485 * Actual main function run right after GNUnet's scheduler 528 * Actual main function run right after GNUnet's scheduler
486 * is initialized. Initializes up GTK and Glade. 529 * is initialized. Initializes up GTK and Glade.
487 * 530 *
@@ -503,6 +546,13 @@ run (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
503 led_red = load_led ("red"); 546 led_red = load_led ("red");
504 GNUNET_GTK_set_icon_search_path (); 547 GNUNET_GTK_set_icon_search_path ();
505 GNUNET_GTK_setup_nls (); 548 GNUNET_GTK_setup_nls ();
549 friends = GNUNET_CONTAINER_multipeermap_create (128, GNUNET_NO);
550 if (GNUNET_OK !=
551 GNUNET_FRIENDS_parse (get_configuration (),
552 &add_friend,
553 NULL))
554 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
555 _("Failed to parse list of friends\n"));
506 peer2info = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO); 556 peer2info = GNUNET_CONTAINER_multipeermap_create (256, GNUNET_NO);
507 pnc = 557 pnc =
508 GNUNET_PEERINFO_notify (get_configuration (), 558 GNUNET_PEERINFO_notify (get_configuration (),