[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20624 - in gnunet-gtk: contrib src/fs src/peerinfo
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20624 - in gnunet-gtk: contrib src/fs src/peerinfo |
Date: |
Tue, 20 Mar 2012 07:54:52 +0100 |
Author: grothoff
Date: 2012-03-20 07:54:52 +0100 (Tue, 20 Mar 2012)
New Revision: 20624
Modified:
gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
Log:
-LRN: Don-t block signal propagation
Modified: gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade 2012-03-20
06:53:57 UTC (rev 20623)
+++ gnunet-gtk/contrib/gnunet_peerinfo_gtk_main_window.glade 2012-03-20
06:54:52 UTC (rev 20624)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="UTF-8"?>
+<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="2.20"/>
<!-- interface-naming-policy project-wide -->
@@ -18,46 +18,43 @@
<column type="guint64"/>
<!-- column-name addresses -->
<column type="gchararray"/>
+ <!-- column-name connectivity_led -->
+ <column type="GdkPixbuf"/>
+ <!-- column-name connected_status -->
+ <column type="gboolean"/>
</columns>
</object>
<object class="GtkWindow" id="GNUNET_PEERINFO_GTK_main_window">
- <property name="can_focus">False</property>
<property name="title" translatable="yes">gnunet-peerinfo-gtk</property>
<property name="window_position">center</property>
<property name="default_width">700</property>
<property name="default_height">500</property>
<property name="icon_name">gnunet-gtk</property>
- <signal name="delete-event" handler="GNUNET_PEERINFO_GTK_quit_cb"
after="yes" swapped="no"/>
+ <signal name="delete_event" handler="GNUNET_PEERINFO_GTK_quit_cb"
after="yes"/>
<child>
<object class="GtkVBox" id="GNUNET_PEERINFO_GTK_main_window_vbox">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
<child>
<object class="GtkMenuBar" id="GNUNET_PEERINFO_GTK_main_menu">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
<object class="GtkMenuItem"
id="GNUNET_PEERINFO_GTK_main_menu_help">
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="use_action_appearance">False</property>
<property name="label" translatable="yes">_Help</property>
<property name="use_underline">True</property>
<child type="submenu">
<object class="GtkMenu"
id="GNUNET_PEERINFO_GTK_main_menu_help_abou">
<property name="visible">True</property>
- <property name="can_focus">False</property>
<child>
<object class="GtkImageMenuItem"
id="GNUNET_PEERINFO_GTK_main_menu_help_about">
<property name="label">gtk-about</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
<property name="tooltip_text"
translatable="yes">Display information about this version of
gnunet-peerinfo-gtk</property>
- <property name="use_action_appearance">False</property>
<property
name="accel_path"><gnunet-peerinfo-gtk>/Help/About</property>
<property name="use_underline">True</property>
<property name="use_stock">True</property>
- <signal name="activate"
handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb" swapped="no"/>
+ <signal name="activate"
handler="GNUNET_PEERINFO_GTK_main_menu_help_about_activate_cb"/>
</object>
</child>
</object>
@@ -67,7 +64,6 @@
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
@@ -92,7 +88,7 @@
<object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_name_column">
<property name="spacing">5</property>
<property name="sizing">autosize</property>
- <property name="title" translatable="yes">Peer</property>
+ <property name="title">Peer</property>
<property name="reorderable">True</property>
<property name="sort_indicator">True</property>
<property name="sort_column_id">0</property>
@@ -108,8 +104,23 @@
</object>
</child>
<child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_connectivity_treeviewcolumn">
+ <property name="sizing">fixed</property>
+ <property name="fixed_width">20</property>
+ <property name="reorderable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">8</property>
+ <child>
+ <object class="GtkCellRendererPixbuf"
id="GNUNET_PEERINFO_GTK_main_window_led_cellrendererpixbuf"/>
+ <attributes>
+ <attribute name="pixbuf">7</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
<object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_bandwidth_column">
- <property name="title" translatable="yes">In</property>
+ <property name="title">In</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_indicator">True</property>
@@ -125,7 +136,7 @@
</child>
<child>
<object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_bandwidth_out_treeviewcolumn">
- <property name="title" translatable="yes">Out</property>
+ <property name="title">Out</property>
<property name="clickable">True</property>
<property name="sort_order">descending</property>
<property name="sort_column_id">5</property>
@@ -140,7 +151,7 @@
<child>
<object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_country_column">
<property name="sizing">autosize</property>
- <property name="title"
translatable="yes">Country</property>
+ <property name="title">Country</property>
<property name="clickable">True</property>
<property name="reorderable">True</property>
<property name="sort_indicator">True</property>
@@ -156,7 +167,7 @@
<child>
<object class="GtkTreeViewColumn"
id="GNUNET_PEERINFO_GTK_main_window_address_treeviewcolumn">
<property name="sizing">autosize</property>
- <property name="title"
translatable="yes">Addresses</property>
+ <property name="title">Addresses</property>
<property name="expand">True</property>
<property name="clickable">True</property>
<property name="sort_column_id">6</property>
@@ -172,8 +183,6 @@
</child>
</object>
<packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-03-20 06:53:57 UTC
(rev 20623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-03-20 06:54:52 UTC
(rev 20624)
@@ -739,8 +739,8 @@
* @param widget the GtkTreeView with the search result list
* @param event the event, we only care about button events
* @param user_data the 'struct SearchTab' the widget is in
- * @return FALSE if no menu could be popped up,
- * TRUE if there is now a pop-up menu
+ * @return FALSE to propagate the event further,
+ * TRUE to stop the propagation
*/
gboolean
GNUNET_FS_GTK_search_treeview_button_press_event (GtkWidget * widget,
@@ -765,10 +765,11 @@
if (! gtk_tree_model_get_iter (tm, &iter, path))
return FALSE; /* not sure how we got a path but no iter... */
gtk_tree_path_free (path);
- return search_list_popup (tm, tab,
+ search_list_popup (tm, tab,
event_button->button,
event_button->time,
&iter);
+ return FALSE;
}
@@ -2767,14 +2768,14 @@
/**
- * We got a right-click on the search result list. Display the context
+ * We got a button press on the search result list. Display the context
* menu.
*
* @param widget the GtkTreeView with the search result list
* @param event the event, we only care about button events
* @param user_data the 'struct SearchTab' the widget is in
- * @return FALSE if no menu could be popped up,
- * TRUE if there is now a pop-up menu
+ * @return FALSE to propagate the event further,
+ * TRUE to stop the event propagation.
*/
gboolean
GNUNET_FS_GTK_publish_treeview_button_press_event (GtkWidget * widget,
@@ -2799,10 +2800,11 @@
if (! gtk_tree_model_get_iter (tm, &iter, path))
return FALSE; /* not sure how we got a path but no iter... */
gtk_tree_path_free (path);
- return publish_list_popup (tm, tab,
- event_button->button,
- event_button->time,
- &iter);
+ publish_list_popup (tm, tab,
+ event_button->button,
+ event_button->time,
+ &iter);
+ return FALSE; /* propagate further, to focus on the item (for example) */
}
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
2012-03-20 06:53:57 UTC (rev 20623)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-meta-data-context-menu.c
2012-03-20 06:54:52 UTC (rev 20624)
@@ -163,7 +163,7 @@
do_metadata_popup_menu (event->button,
event->time,
user_data);
- return TRUE;
+ return FALSE;
}
Modified: gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c
===================================================================
--- gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2012-03-20 06:53:57 UTC
(rev 20623)
+++ gnunet-gtk/src/peerinfo/gnunet-peerinfo-gtk.c 2012-03-20 06:54:52 UTC
(rev 20624)
@@ -68,7 +68,17 @@
/**
* A gchararray
*/
- PEERINFO_MC_ADDRESS_AS_STRING = 6
+ PEERINFO_MC_ADDRESS_AS_STRING = 6,
+
+ /**
+ * A GdkPixbuf
+ */
+ PEERINFO_MC_CONNECTIVITY_LED = 7,
+
+ /**
+ * A gboolean
+ */
+ PEERINFO_MC_CONNECTED_STATUS = 8
};
@@ -124,8 +134,24 @@
*/
static int tray_only;
+/**
+ * Green status led (connected)
+ */
+static GdkPixbuf *led_green;
/**
+ * Red status led (disconnected)
+ */
+static GdkPixbuf *led_red;
+
+/**
+ * Main window list store.
+ */
+static GtkListStore *ls;
+
+
+
+/**
* Get cfg.
*/
static const struct GNUNET_CONFIGURATION_Handle *
@@ -212,19 +238,15 @@
peer_address_string_cb (void *cls, const char *address)
{
struct PeerInfo *info = cls;
- GtkListStore *ls;
- GtkTreeModel *tm;
GtkTreeIter iter;
GtkTreePath *path;
char *country;
const char *colon;
const char *dot;
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- tm = GTK_TREE_MODEL (ls);
path = gtk_tree_row_reference_get_path (info->rr);
GNUNET_assert (NULL != path);
- GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path));
+ GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter,
path));
gtk_tree_path_free (path);
if (NULL == address)
{
@@ -235,6 +257,8 @@
PEERINFO_MC_COUNTRY_NAME, NULL,
PEERINFO_MC_COUNTRY_FLAG, NULL,
PEERINFO_MC_ADDRESS_AS_STRING, "<no address>",
+ PEERINFO_MC_CONNECTIVITY_LED, led_green,
+ PEERINFO_MC_CONNECTED_STATUS, TRUE,
-1);
info->tos = NULL;
return;
@@ -255,6 +279,8 @@
PEERINFO_MC_COUNTRY_NAME, country,
PEERINFO_MC_COUNTRY_FLAG, GNUNET_PEERINFO_GTK_get_flag
(country),
PEERINFO_MC_ADDRESS_AS_STRING, address,
+ PEERINFO_MC_CONNECTIVITY_LED, led_green,
+ PEERINFO_MC_CONNECTED_STATUS, TRUE,
-1);
GNUNET_free (country);
info->got_address = GNUNET_YES;
@@ -273,28 +299,28 @@
const struct GNUNET_HELLO_Address *address)
{
struct PeerInfo *info = cls;
- GtkListStore *ls;
- GtkTreeModel *tm;
GtkTreeIter iter;
GtkTreePath *path;
+ path = gtk_tree_row_reference_get_path (info->rr);
+ GNUNET_assert (NULL != path);
+ GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter,
path));
+ gtk_tree_path_free (path);
if (NULL == address)
{
/* disconnect */
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- tm = GTK_TREE_MODEL (ls);
- path = gtk_tree_row_reference_get_path (info->rr);
- GNUNET_assert (NULL != path);
- GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path));
- gtk_tree_path_free (path);
gtk_list_store_set (ls, &iter,
PEERINFO_MC_NUMBER_OF_ADDRESSES, (guint) 0,
- PEERINFO_MC_COUNTRY_NAME, NULL,
- PEERINFO_MC_COUNTRY_FLAG, NULL,
- PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>",
+ PEERINFO_MC_CONNECTIVITY_LED, led_red,
+ PEERINFO_MC_CONNECTED_STATUS, FALSE,
-1);
return;
}
+ gtk_list_store_set (ls, &iter,
+ PEERINFO_MC_NUMBER_OF_ADDRESSES, 1,
+ PEERINFO_MC_CONNECTIVITY_LED, led_green,
+ PEERINFO_MC_CONNECTED_STATUS, TRUE,
+ -1);
if (NULL != info->tos)
GNUNET_TRANSPORT_address_to_string_cancel (info->tos);
info->got_address = GNUNET_NO;
@@ -319,21 +345,12 @@
const struct GNUNET_HELLO_Message *hello,
const char *err_msg)
{
- GtkListStore *ls;
- GtkTreeModel *tm;
GtkTreeIter iter;
char *npid;
struct GNUNET_CRYPTO_HashAsciiEncoded enc;
struct PeerInfo *info;
GtkTreePath *path;
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- if (NULL == ls)
- {
- GNUNET_break (0);
- return;
- }
- tm = GTK_TREE_MODEL (ls);
info = GNUNET_CONTAINER_multihashmap_get (peer2info, &peer->hashPubKey);
if (NULL == info)
{
@@ -348,11 +365,13 @@
PEERINFO_MC_COUNTRY_FLAG, NULL,
PEERINFO_MC_BANDWIDTH_IN, (guint64) 0,
PEERINFO_MC_BANDWIDTH_OUT, (guint64) 0,
- PEERINFO_MC_ADDRESS_AS_STRING, "<disconnected>",
+ PEERINFO_MC_ADDRESS_AS_STRING, "",
+ PEERINFO_MC_CONNECTIVITY_LED, led_red,
+ PEERINFO_MC_CONNECTED_STATUS, FALSE,
-1);
- path = gtk_tree_model_get_path (tm, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (ls), &iter);
info = GNUNET_malloc (sizeof (struct PeerInfo));
- info->rr = gtk_tree_row_reference_new (tm, path);
+ info->rr = gtk_tree_row_reference_new (GTK_TREE_MODEL (ls), path);
GNUNET_assert (NULL != info->rr);
gtk_tree_path_free (path);
GNUNET_CONTAINER_multihashmap_put (peer2info, &peer->hashPubKey, info,
@@ -388,19 +407,15 @@
uint32_t ats_count)
{
struct PeerInfo *info;
- GtkListStore *ls;
- GtkTreeModel *tm;
GtkTreeIter iter;
GtkTreePath *path;
info = GNUNET_CONTAINER_multihashmap_get (peer2info,
&address->peer.hashPubKey);
if (NULL == info)
return; /* should rarely happen... */
- ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
- tm = GTK_TREE_MODEL (ls);
path = gtk_tree_row_reference_get_path (info->rr);
GNUNET_assert (NULL != path);
- GNUNET_assert (TRUE == gtk_tree_model_get_iter (tm, &iter, path));
+ GNUNET_assert (TRUE == gtk_tree_model_get_iter (GTK_TREE_MODEL (ls), &iter,
path));
gtk_tree_path_free (path);
gtk_list_store_set (ls, &iter,
PEERINFO_MC_BANDWIDTH_IN, (guint64) ntohl
(bandwidth_in.value__),
@@ -425,6 +440,29 @@
/**
+ * Load LED image from resource file.
+ *
+ * @param color color of the LED to load
+ * @return the image as a GdkPixbuf
+ */
+static GdkPixbuf *
+load_led (const char *color)
+{
+ GdkPixbuf *pixbuf;
+ char *dir;
+ char *fn;
+
+ dir = GNUNET_GTK_installation_get_path (GNUNET_OS_IPK_DATADIR);
+ GNUNET_asprintf (&fn, "%s%s.png", dir,
+ color);
+ GNUNET_free (dir);
+ pixbuf = gdk_pixbuf_new_from_file (fn, NULL);
+ GNUNET_free (fn);
+ return pixbuf;
+}
+
+
+/**
* Actual main function run right after GNUnet's scheduler
* is initialized. Initializes up GTK and Glade.
*
@@ -442,7 +480,8 @@
{
return;
}
-
+ led_green = load_led ("green");
+ led_red = load_led ("red");
GNUNET_GTK_set_icon_search_path ();
GNUNET_GTK_setup_nls ();
peer2info = GNUNET_CONTAINER_multihashmap_create (256);
@@ -457,6 +496,8 @@
ats = GNUNET_ATS_performance_init (get_configuration (), &status_cb, NULL);
/* setup main window */
main_window = GTK_WIDGET (get_object ("GNUNET_PEERINFO_GTK_main_window"));
+ ls = GTK_LIST_STORE (get_object ("GNUNET_PEERINFO_GTK_list_store"));
+ GNUNET_assert (NULL != ls);
gtk_window_maximize (GTK_WINDOW (main_window));
GNUNET_GTK_tray_icon_create (GTK_WINDOW (main_window),
"gnunet-gtk" /* FIXME: different icon? */ ,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20624 - in gnunet-gtk: contrib src/fs src/peerinfo,
gnunet <=