[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r20155 - in gnunet-gtk: contrib src/fs
From: |
gnunet |
Subject: |
[GNUnet-SVN] r20155 - in gnunet-gtk: contrib src/fs |
Date: |
Thu, 1 Mar 2012 09:26:33 +0100 |
Author: grothoff
Date: 2012-03-01 09:26:33 +0100 (Thu, 01 Mar 2012)
New Revision: 20155
Added:
gnunet-gtk/contrib/gnunet_fs_gtk_namespace_manager.glade
gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
Modified:
gnunet-gtk/contrib/Makefile.am
gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
gnunet-gtk/src/fs/Makefile.am
gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
gnunet-gtk/src/fs/gnunet-fs-gtk_common.h
gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
Log:
LRN: updates to pseudonym API from #1952, adding namespace manager
Modified: gnunet-gtk/contrib/Makefile.am
===================================================================
--- gnunet-gtk/contrib/Makefile.am 2012-03-01 08:24:17 UTC (rev 20154)
+++ gnunet-gtk/contrib/Makefile.am 2012-03-01 08:26:33 UTC (rev 20155)
@@ -17,6 +17,7 @@
gnunet_fs_gtk_create_namespace_dialog.glade \
gnunet_fs_gtk_download_as_dialog.glade \
gnunet_fs_gtk_main_window.glade \
+ gnunet_fs_gtk_namespace_manager.glade \
gnunet_fs_gtk_edit_publication.glade \
gnunet_fs_gtk_open_directory_dialog.glade \
gnunet_fs_gtk_open_url_dialog.glade \
Modified: gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade 2012-03-01 08:24:17 UTC
(rev 20154)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade 2012-03-01 08:26:33 UTC
(rev 20155)
@@ -250,6 +250,15 @@
</object>
</child>
<child>
+ <object class="GtkMenuItem"
id="GNUNET_GTK_main_menu_file_manage_pseudonyms">
+ <property name="visible">True</property>
+ <property name="tooltip_text" translatable="yes">Opens
namespace manager dialog to adjust the list of namespaces you want to use, as
well as get detailed information about all discovered namespaces.</property>
+ <property name="label" translatable="yes">_Manage
namespaces</property>
+ <property name="use_underline">True</property>
+ <signal name="activate"
handler="GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb"/>
+ </object>
+ </child>
+ <child>
<object class="GtkSeparatorMenuItem"
id="GNUNET_GTK_main_menu_file_sep3">
<property name="visible">True</property>
</object>
Added: gnunet-gtk/contrib/gnunet_fs_gtk_namespace_manager.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_namespace_manager.glade
(rev 0)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_namespace_manager.glade 2012-03-01
08:26:33 UTC (rev 20155)
@@ -0,0 +1,628 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="2.24"/>
+ <!-- interface-naming-policy project-wide -->
+ <object class="GtkListStore"
id="GNUNET_GTK_namespace_manager_known_liststore">
+ <columns>
+ <!-- column-name IsMine -->
+ <column type="gboolean"/>
+ <!-- column-name Rank -->
+ <column type="gint"/>
+ <!-- column-name NamespaceName -->
+ <column type="gchararray"/>
+ <!-- column-name NamespaceKey -->
+ <column type="gchararray"/>
+ <!-- column-name NamespaceKeyBinary -->
+ <column type="gpointer"/>
+ <!-- column-name OrderListRowReference -->
+ <column type="gpointer"/>
+ <!-- column-name MetaData -->
+ <column type="gpointer"/>
+ <!-- column-name NonUniqueName -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_known_namespaces_hadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_known_namespaces_vadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_namespace_details_hadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkDialog" id="GNUNET_GTK_namespace_manager_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="has_separator">True</property>
+ <signal name="response"
handler="GNUNET_GTK_namespace_manager_dialog_response_cb" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="GNUNET_GTK_namespace_manager_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="spacing">2</property>
+ <child internal-child="action_area">
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_manager_action_area">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_apply_button">
+ <property name="label">gtk-apply</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Saves all
changes made in this dialog to disk without closing the dialog.</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_ok_button">
+ <property name="label">gtk-ok</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Saves all
changes made in this dialog to disk and closes the dialog.</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_cancel_button">
+ <property name="label">gtk-cancel</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Closes the
dialog. Changes made in this dialog will not be preserved.</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="pack_type">end</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVPaned"
id="GNUNET_GTK_namespace_manager_main_vpaned">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkHPaned"
id="GNUNET_GTK_namespace_manager_top_hpaned">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <child>
+ <object class="GtkVBox"
id="GNUNET_GTK_namespace_manager_known_namespaces_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_namespace_manager_known_namespaces_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Known
namespaces:
+Select a namespace to see its complete metadata. Click "Delete" to delete
(forget) namespace.
+Namespace names are editable.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow"
id="GNUNET_GTK_namespace_manager_known_namespaces_scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_known_namespaces_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_known_namespaces_vadj</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView"
id="GNUNET_GTK_namespace_manager_known_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="model">GNUNET_GTK_namespace_manager_known_liststore</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_known_namespaces_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_known_namespaces_vadj</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">2</property>
+ <property name="show_expanders">False</property>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_is_mine_column">
+ <property name="title" translatable="yes">Is
mine</property>
+ <property name="clickable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">0</property>
+ <child>
+ <object class="GtkCellRendererToggle"
id="GNUNET_GTK_namespace_manager_is_mine_toggle">
+ <property
name="activatable">False</property>
+ </object>
+ <attributes>
+ <attribute name="active">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_rank_column">
+ <property name="title"
translatable="yes">Rank</property>
+ <property name="clickable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">1</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_rank_text"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_namespace_name_column">
+ <property name="title"
translatable="yes">Name</property>
+ <property name="clickable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">2</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_name_text">
+ <property name="editable">True</property>
+ <signal name="editing-started"
handler="GNUNET_GTK_namespace_manager_name_text_editing_started_cb"
swapped="no"/>
+ <signal name="edited"
handler="GNUNET_GTK_namespace_manager_name_text_edited_cb" swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_namespace_id_column">
+ <property name="title"
translatable="yes">Identifier</property>
+ <property name="clickable">True</property>
+ <property name="sort_indicator">True</property>
+ <property name="sort_column_id">3</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_id_text"/>
+ <attributes>
+ <attribute name="text">3</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_manager_known_namespaces_buttonbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="extension_events">cursor</property>
+ <property name="border_width">5</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_known_namespaces_delete_button">
+ <property name="label">gtk-delete</property>
+ <property
name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text"
translatable="yes">Makes GNUnet "forget" about selected known namespace.
+However, GNUnet will be able to learn about this namespace, if it ever
discovers it again.</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_known_namespaces_delete_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_known_namespaces_swap_rank_button">
+ <property name="label" translatable="yes">Swap
_Rank</property>
+ <property
name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text"
translatable="yes">Changes the rank value of the selected namespace in "Known
namespaces" list.
+If it had rank 0, it's given rank -1, otherwise the sign of its rank is
flipped.
+Only namespaces with positive ranks are displayed in "Namespace order"
list.</property>
+ <property name="use_underline">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_known_namespaces_swap_rank_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox"
id="GNUNET_GTK_namespace_manager_namespace_order_vbox_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_namespace_manager_namespace_order_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Namespace
order:
+Drag rows to change namespace order, click "Apply" to save it.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow"
id="GNUNET_GTK_namespace_manager_namespace_order_scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_namespace_order_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_namespace_order_vadj</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView"
id="GNUNET_GTK_namespace_manager_namespace_order_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="model">GNUNET_GTK_namespace_manager_namespace_order_liststore</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_namespace_order_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_namespace_order_vadj</property>
+ <property name="headers_clickable">False</property>
+ <property name="reorderable">True</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <property name="rubber_banding">True</property>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_namespace_order_rank_column">
+ <property name="title"
translatable="yes">Rank</property>
+ <property name="clickable">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_order_column_clicked_cb"
swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_order_rank_text"/>
+ <attributes>
+ <attribute name="text">0</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_namespace_order_name_column">
+ <property name="title"
translatable="yes">Name</property>
+ <property name="clickable">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_order_column_clicked_cb"
swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_order_name_text"/>
+ <attributes>
+ <attribute name="text">1</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_namespace_order_identifier_column">
+ <property name="title"
translatable="yes">Identifier</property>
+ <property name="clickable">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_order_column_clicked_cb"
swapped="no"/>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_order_identifier_text"/>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_manager_namespace_order_buttonbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_namespace_order_apply">
+ <property name="label">gtk-apply</property>
+ <property
name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text"
translatable="yes">Convert the order in which namespaces are arranged in
"Namespace order" list to ranks.
+Top namespace is assigned rank 0, namespace below it - rank 1, and so
on.</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_order_apply_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox"
id="GNUNET_GTK_namespace_manager_namespace_details_vbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkLabel"
id="GNUNET_GTK_namespace_manager_namespace_details_label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">Selected
namespace details:
+Metadata can be <s>added,</s> deleted and edited. Click "Apply" to
save metadata changes.</property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow"
id="GNUNET_GTK_namespace_manager_namespace_details_scrolledwindow">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_namespace_details_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_namespace_details_vadj</property>
+ <property name="hscrollbar_policy">automatic</property>
+ <property name="vscrollbar_policy">automatic</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkTreeView"
id="GNUNET_GTK_namespace_manager_namespace_details_treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property
name="model">GNUNET_GTK_namespace_manager_namespace_details_liststore</property>
+ <property
name="hadjustment">GNUNET_GTK_namespace_manager_namespace_details_hadj</property>
+ <property
name="vadjustment">GNUNET_GTK_namespace_manager_namespace_details_vadj</property>
+ <property name="headers_clickable">False</property>
+ <property name="rules_hint">True</property>
+ <property name="search_column">0</property>
+ <property name="show_expanders">False</property>
+ <property name="rubber_banding">True</property>
+ <property name="enable_grid_lines">both</property>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_details_type_column">
+ <property name="title"
translatable="yes">Type</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_details_type_text">
+ <signal name="edited"
handler="GNUNET_GTK_namespace_manager_namespace_details_type_text_edited_cb"
swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="text">2</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkTreeViewColumn"
id="GNUNET_GTK_namespace_manager_details_value_column">
+ <property name="title"
translatable="yes">Value</property>
+ <child>
+ <object class="GtkCellRendererText"
id="GNUNET_GTK_namespace_manager_namespace_details_value_text">
+ <property name="editable">True</property>
+ <signal name="edited"
handler="GNUNET_GTK_namespace_manager_namespace_details_value_text_edited_cb"
swapped="no"/>
+ </object>
+ <attributes>
+ <attribute name="text">5</attribute>
+ </attributes>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHButtonBox"
id="GNUNET_GTK_namespace_manager_namespace_details_buttonbox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="spacing">5</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_namespace_details_add_button">
+ <property name="label">gtk-add</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text" translatable="yes">Adds
a new metadata Type=Value pair to the list.
+This functionality is not available at the moment.</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_details_add_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_namespace_details_delete_button">
+ <property name="label">gtk-delete</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text"
translatable="yes">Removes selected Type=Value pair from metadata list.
+The change will not last unless you click on "Apply" button before closing the
window or selecing some other known namespace.</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_details_delete_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton"
id="GNUNET_GTK_namespace_manager_namespace_details_apply_button">
+ <property name="label">gtk-apply</property>
+ <property name="use_action_appearance">False</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="tooltip_text"
translatable="yes">Applies changes made in metadata list to currently selected
known namespace.</property>
+ <property name="use_stock">True</property>
+ <signal name="clicked"
handler="GNUNET_GTK_namespace_manager_namespace_details_apply_button_clicked_cb"
swapped="no"/>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="resize">True</property>
+ <property name="shrink">False</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget
response="-10">GNUNET_GTK_namespace_manager_apply_button</action-widget>
+ <action-widget
response="-5">GNUNET_GTK_namespace_manager_ok_button</action-widget>
+ <action-widget
response="-6">GNUNET_GTK_namespace_manager_cancel_button</action-widget>
+ </action-widgets>
+ </object>
+ <object class="GtkListStore"
id="GNUNET_GTK_namespace_manager_namespace_details_liststore">
+ <columns>
+ <!-- column-name PluginName -->
+ <column type="gchararray"/>
+ <!-- column-name TypeBin -->
+ <column type="gint"/>
+ <!-- column-name Type -->
+ <column type="gchararray"/>
+ <!-- column-name Format -->
+ <column type="gint"/>
+ <!-- column-name DataMime -->
+ <column type="gchararray"/>
+ <!-- column-name Value -->
+ <column type="gchararray"/>
+ </columns>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_namespace_details_vadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_namespace_order_hadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkListStore"
id="GNUNET_GTK_namespace_manager_namespace_order_liststore">
+ <columns>
+ <!-- column-name Rank -->
+ <column type="gint"/>
+ <!-- column-name Name -->
+ <column type="gchararray"/>
+ <!-- column-name Identifier -->
+ <column type="gchararray"/>
+ <!-- column-name IdentifierBin -->
+ <column type="gpointer"/>
+ <!-- column-name KnownListRowReference -->
+ <column type="gpointer"/>
+ </columns>
+ </object>
+ <object class="GtkAdjustment"
id="GNUNET_GTK_namespace_manager_namespace_order_vadj">
+ <property name="upper">100</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+</interface>
Modified: gnunet-gtk/src/fs/Makefile.am
===================================================================
--- gnunet-gtk/src/fs/Makefile.am 2012-03-01 08:24:17 UTC (rev 20154)
+++ gnunet-gtk/src/fs/Makefile.am 2012-03-01 08:26:33 UTC (rev 20155)
@@ -25,7 +25,8 @@
gnunet-fs-gtk_open-directory.c \
gnunet-fs-gtk_open-uri.c \
gnunet-fs-gtk_publish-dialog.c \
- gnunet-fs-gtk_publish-edit-dialog.c gnunet-fs-gtk_publish-edit-dialog.h
+ gnunet-fs-gtk_publish-edit-dialog.c gnunet-fs-gtk_publish-edit-dialog.h \
+ gnunet-fs-gtk_namespace_manager.c gnunet-fs-gtk_namespace_manager.h
gnunet_fs_gtk_LDADD = \
$(top_builddir)/src/lib/libgnunetgtk.la \
@GTK_LIBS@ \
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_common.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2012-03-01 08:24:17 UTC (rev
20154)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_common.c 2012-03-01 08:26:33 UTC (rev
20155)
@@ -416,5 +416,117 @@
GNUNET_break (0);
}
+/* Largest rating value among all namespaces. INT_MIN means "undefined" */
+static int largest_namespace_rating = INT_MIN;
+
+/**
+ * Helper function for finding the largest namespace rating.
+ *
+ * @param cls closure
+ * @param pseudonym pseudonym hash
+ * @param md metadata container
+ * @param rating rating
+ * @return GNUNET_OK to keep iterating
+ */
+static int
+find_largest_namespace_rating_iterator (void *cls,
+ const GNUNET_HashCode *pseudonym, const char *name,
+ const char *unique_name,
+ const struct GNUNET_CONTAINER_MetaData *md, int rating)
+{
+ int *largest = cls;
+ if (*largest < rating)
+ *largest = rating;
+ return GNUNET_OK;
+}
+
+/**
+ * Finds largest namespace rating.
+ * Used to calculate a rating for newly discovered namespaces.
+ * Returns from cache, if possible.
+ *
+ * @return largest namespace rating. Might be negative and even. INT_MIN means
+ * that no namespaces are known.
+ */
+int
+GNUNET_GTK_find_largest_namespace_rating ()
+{
+ if (largest_namespace_rating != INT_MIN)
+ return largest_namespace_rating;
+ (void) GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (),
+ find_largest_namespace_rating_iterator, &largest_namespace_rating);
+ return largest_namespace_rating;
+}
+
+/**
+ * Sets largest namespace rating.
+ * Used to change cached largest namespace rating, when namespace list
+ * was changed in a way that is easy to track.
+ * If namespace list was changed in a way that makes it difficult to
+ * decide upon the new value, set new value to INT_MIN.
+ *
+ * @param new_value new value for the rating.
+ */
+void
+GNUNET_GTK_set_largest_namespace_rating (int new_value)
+{
+ largest_namespace_rating = new_value;
+}
+
+/**
+ * Converts a GtkTreeRowReference to a GtkTreeIter.
+ *
+ * @param rr row reference
+ * @param iter pointer to an iter structure to fill
+ * @return GNUNET_OK if iter was filled, GNUNET_SYSERR otherwise
+ */
+int
+GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, GtkTreeIter *iter)
+{
+ int result = GNUNET_SYSERR;
+ if (rr != NULL)
+ {
+ if (gtk_tree_row_reference_valid (rr))
+ {
+ GtkTreePath *path;
+ GtkTreeModel *model;
+ path = gtk_tree_row_reference_get_path (rr);
+ model = gtk_tree_row_reference_get_model (rr);
+ if (path != NULL && model != NULL)
+ {
+ if (gtk_tree_model_get_iter (model,
+ iter, path))
+ result = GNUNET_OK;
+ gtk_tree_path_free (path);
+ }
+ }
+ }
+ return result;
+}
+
+/**
+ * Creates a GtkTreeRowReference from a GtkTreeIter.
+ *
+ * @param model a model to reference
+ * @param iter an iter that points to a row in the model
+ * @return newly created reference or NULL in case of error
+ */
+GtkTreeRowReference *
+GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, GtkTreeIter *iter)
+{
+ GtkTreeRowReference *result = NULL;
+ if (iter != NULL && model != NULL)
+ {
+ GtkTreePath *path = gtk_tree_model_get_path (model, iter);
+ if (path != NULL)
+ {
+ result = gtk_tree_row_reference_new (model, path);
+ gtk_tree_path_free (path);
+ }
+ }
+ return result;
+}
+
+
/* end of gnunet-fs-gtk-common.c */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_common.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_common.h 2012-03-01 08:24:17 UTC (rev
20154)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_common.h 2012-03-01 08:26:33 UTC (rev
20155)
@@ -147,5 +147,48 @@
void
GNUNET_FS_GTK_handle_uri (const struct GNUNET_FS_Uri *uri);
+/**
+ * Finds largest namespace rating.
+ * Used to calculate a rating for newly discovered namespaces.
+ * Returns from cache, if possible.
+ *
+ * @return largest namespace rating. Might be negative and even. INT_MIN means
+ * that no namespaces are known.
+ */
+int
+GNUNET_GTK_find_largest_namespace_rating ();
+
+/**
+ * Sets largest namespace rating.
+ * Used to change cached largest namespace rating, when namespace list
+ * was changed in a way that is easy to track.
+ * If namespace list was changed in a way that makes it difficult to
+ * decide upon the new value, set new value to INT_MIN.
+ *
+ * @param new_value new value for the rating.
+ */
+void
+GNUNET_GTK_set_largest_namespace_rating (int new_value);
+
+/**
+ * Converts a GtkTreeRowReference to a GtkTreeIter.
+ *
+ * @param rr row reference
+ * @param iter pointer to an iter structure to fill
+ * @return GNUNET_OK if iter was filled, GNUNET_SYSERR otherwise
+ */
+int
+GNUNET_GTK_get_iter_from_reference (GtkTreeRowReference *rr, GtkTreeIter
*iter);
+
+/**
+ * Creates a GtkTreeRowReference from a GtkTreeIter.
+ *
+ * @param model a model to reference
+ * @param iter an iter that points to a row in the model
+ * @return newly created reference or NULL in case of error
+ */
+GtkTreeRowReference *
+GNUNET_GTK_get_reference_from_iter (GtkTreeModel *model, GtkTreeIter *iter);
+
#endif
/* end of gnunet-fs-gtk-common.h */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-03-01 08:24:17 UTC
(rev 20154)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_event-handler.c 2012-03-01 08:26:33 UTC
(rev 20155)
@@ -27,6 +27,7 @@
#include "gnunet-fs-gtk_common.h"
#include "gnunet-fs-gtk_download-save-as.h"
#include "gnunet-fs-gtk_event-handler.h"
+#include "gnunet-fs-gtk_namespace_manager.h"
/**
@@ -3030,5 +3031,12 @@
return NULL;
}
+void
+GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
+ gpointer user_data)
+{
+ GNUNET_GTK_namespace_manager_open ();
+}
+
/* end of gnunet-fs-gtk-event_handler.c */
Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
2012-03-01 08:24:17 UTC (rev 20154)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
2012-03-01 08:26:33 UTC (rev 20155)
@@ -322,11 +322,12 @@
*/
static int
add_namespace_to_ts (void *cls, const GNUNET_HashCode * pseudonym,
+ const char *name, const char *unique_name,
const struct GNUNET_CONTAINER_MetaData *md, int rating)
{
GtkTreeStore *ts = cls;
char *root;
- char *ns_name;
+ char *ns_name, *unique_ns_name;
GNUNET_HashCode *nsid;
char *description;
int desc_is_a_dup;
@@ -335,9 +336,14 @@
struct GNUNET_FS_Uri *uri;
GtkTreeIter iter;
- ns_name =
- GNUNET_PSEUDONYM_id_to_name (GNUNET_FS_GTK_get_configuration (),
- pseudonym);
+ if (rating < 0)
+ return GNUNET_OK;
+
+ GNUNET_PSEUDONYM_get_info (GNUNET_FS_GTK_get_configuration (),
+ pseudonym, NULL, NULL, &ns_name, NULL);
+ unique_ns_name = GNUNET_PSEUDONYM_name_uniquify (
+ GNUNET_FS_GTK_get_configuration (), pseudonym, ns_name, NULL);
+ GNUNET_free (ns_name);
nsid = GNUNET_malloc (sizeof (GNUNET_HashCode));
*nsid = *pseudonym;
root = NULL;
@@ -352,13 +358,13 @@
GNUNET_FS_uri_destroy (uri);
}
description = GNUNET_FS_GTK_get_description_from_metadata (md,
&desc_is_a_dup);
- gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT,
- 0, ns_name,
- 1, nsid,
+ gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT,
+ 0, unique_ns_name,
+ 1, nsid,
2, root,
- 3, description,
+ 3, description,
-1);
- GNUNET_free (ns_name);
+ GNUNET_free (unique_ns_name);
GNUNET_free_non_null (root);
GNUNET_free (description);
return GNUNET_OK;
Added: gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
(rev 0)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c 2012-03-01 08:26:33 UTC
(rev 20155)
@@ -0,0 +1,970 @@
+/*
+ This file is part of GNUnet
+ (C) 2005, 2006, 2010, 2012 Christian Grothoff (and other contributing
authors)
+
+ GNUnet is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ GNUnet is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with GNUnet; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+*/
+
+/**
+ * @file src/fs/gnunet-fs-gtk_namespace_manager.c
+ * @author LRN
+ */
+#include "gnunet-fs-gtk_common.h"
+#include "gnunet-fs-gtk.h"
+#include <gnunet/gnunet_util_lib.h>
+#include <gnunet/gnunet_fs_service.h>
+
+struct GNUNET_GTK_NamespaceManagerContext
+{
+ GtkBuilder *builder;
+ GtkWidget *known_ns;
+ GtkWidget *ns_order;
+ GtkWidget *ns_details;
+ GtkTreeSelection *known_ns_sel;
+ GtkTreeSelection *ns_order_sel;
+ GtkTreeSelection *ns_details_sel;
+ GtkListStore *ns_order_store;
+ GtkListStore *known_ns_store;
+ GtkListStore *ns_details_store;
+ GtkWindow *namespace_manager;
+ GtkTreeViewColumn *order_rank;
+ GtkTreeViewColumn *order_name;
+ GtkTreeViewColumn *order_id;
+ GtkWidget *details_apply_button;
+ GtkWidget *details_delete_button;
+ int sort_direction;
+ struct GNUNET_CONTAINER_MetaData *uneditable_md;
+};
+
+/**
+ * THIS IS EVIL! Used to avoid opening more than one ns manager
+ * at once. Could be fixed by saving a pointer to the ns manager window
+ * somewhere in the main gnunet-fs-gtk window, but main window does
+ * not have a context structure for such things at the moment, hence
+ * this VERY EVIL GLOBAL VARIABLE!
+ */
+static struct GNUNET_GTK_NamespaceManagerContext *ns_manager = NULL;
+
+#define GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN 0
+#define GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN 1
+#define GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN 2
+#define GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_COLUMN 3
+#define GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN 4
+#define GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN 5
+#define GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN 6
+#define GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN 7
+
+#define GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN 0
+#define GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN 1
+#define GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN 2
+#define GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_BIN_COLUMN 3
+#define GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN 4
+
+#define GNUNET_GTK_NAMESPACE_DETAILS_PLUGIN_NAME_COLUMN 0
+#define GNUNET_GTK_NAMESPACE_DETAILS_TYPE_BIN_COLUMN 1
+#define GNUNET_GTK_NAMESPACE_DETAILS_TYPE_COLUMN 2
+#define GNUNET_GTK_NAMESPACE_DETAILS_FORMAT_COLUMN 3
+#define GNUNET_GTK_NAMESPACE_DETAILS_DATA_MIME_COLUMN 4
+#define GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN 5
+
+static void
+sort_order_list (struct GNUNET_GTK_NamespaceManagerContext *ctx,
+ int sort_column)
+{
+ int sorted = GNUNET_NO;
+ GtkTreeIter iter;
+ gint i;
+ gint row_count;
+ gint *row_indices, *row_ints;
+ gchar **row_strings;
+
+ ctx->sort_direction = ctx->sort_direction <= 0 ? 1 : 0;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->ns_order_store), NULL);
+ if (TRUE != gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
+ ctx->ns_order_store), &iter))
+ return;
+
+ row_indices = g_new0 (gint, row_count);
+ row_ints = g_new0 (gint, row_count);
+ row_strings = g_new0 (gchar *, row_count);
+
+ for (i = 0; i < row_count; i++)
+ {
+ int an_int;
+ char *a_string;
+ row_indices[i] = i;
+ switch (sort_column)
+ {
+ case GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN:
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &iter,
+ sort_column, &an_int, -1);
+ row_ints[i] = an_int;
+ row_strings[i] = NULL;
+ break;
+ case GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN:
+ case GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN:
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &iter,
+ sort_column, &a_string, -1);
+ row_strings[i] = a_string;
+ break;
+ default:
+ row_strings[i] = NULL;
+ break;
+ }
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->ns_order_store), &iter))
+ break;
+ }
+
+ while (sorted != GNUNET_YES)
+ {
+ sorted = GNUNET_YES;
+ for (i = 0; i < row_count - 1; i++)
+ {
+ int cmp_result;
+
+ switch (sort_column)
+ {
+ case GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN:
+ cmp_result = row_ints[i] <= row_ints[i + 1] ? 0 : 1;
+ break;
+ case GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN:
+ case GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN:
+ /* FIXME: name can be UTF-8-encoded, use UTF-8-aware comparison func */
+ cmp_result = strcmp (row_strings[i], row_strings[i + 1]);
+ break;
+ default:
+ break;
+ }
+
+ if (((ctx->sort_direction <= 0) && (cmp_result <= 0)) ||
+ ((ctx->sort_direction > 0) && (cmp_result > 0)))
+ {
+ int tmp_int, tmp_index;
+ char *tmp_string;
+ tmp_index = row_indices[i];
+ tmp_int = row_ints[i];
+ tmp_string = row_strings[i];
+ row_indices[i] = row_indices[i + 1];
+ row_ints[i] = row_ints[i + 1];
+ row_strings[i] = row_strings[i + 1];
+ row_ints[i + 1] = tmp_int;
+ row_strings[i + 1] = tmp_string;
+ row_indices[i + 1] = tmp_index;
+ sorted = GNUNET_NO;
+ }
+ }
+ }
+
+ gtk_list_store_reorder (ctx->ns_order_store, row_indices);
+
+ g_free (row_indices);
+ for (i = 0; i < row_count; i++)
+ g_free (row_strings[i]);
+ g_free (row_strings);
+ g_free (row_ints);
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_order_column_clicked_cb (
+ GtkTreeViewColumn *treeviewcolumn, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ if (treeviewcolumn == ctx->order_rank)
+ {
+ sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN);
+ }
+ else if (treeviewcolumn == ctx->order_name)
+ {
+ sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN);
+ }
+ else if (treeviewcolumn == ctx->order_id)
+ {
+ sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN);
+ }
+}
+
+void
+GNUNET_GTK_namespace_manager_known_namespaces_delete_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter;
+ GNUNET_HashCode *nsid;
+ GtkTreeRowReference *order_row, *known_row;
+ struct GNUNET_CONTAINER_MetaData *md;
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->known_ns_sel, NULL,
&iter))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, &order_row,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, &md,
+ -1);
+ GNUNET_CONTAINER_meta_data_destroy (md);
+ gtk_list_store_remove (ctx->known_ns_store, &iter);
+ if (order_row != NULL)
+ {
+ if (GNUNET_OK == GNUNET_GTK_get_iter_from_reference (order_row, &iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &iter,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, &known_row, -1);
+ gtk_list_store_remove (ctx->ns_order_store, &iter);
+ if (known_row != NULL)
+ gtk_tree_row_reference_free (known_row);
+ }
+ gtk_tree_row_reference_free (order_row);
+ }
+ GNUNET_free (nsid);
+
+ gtk_list_store_clear (ctx->ns_details_store);
+ GNUNET_CONTAINER_meta_data_destroy (ctx->uneditable_md);
+ ctx->uneditable_md = NULL;
+}
+
+void
+GNUNET_GTK_namespace_manager_known_namespaces_swap_rank_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter known_iter, order_iter;
+ GNUNET_HashCode *nsid;
+ int32_t old_rank, new_rank;
+ GtkTreeRowReference *order_row, *known_row;
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->known_ns_sel, NULL,
&known_iter))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN, &old_rank,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, &order_row,
+ -1);
+
+ if (old_rank == 0)
+ new_rank = -1;
+ else
+ new_rank = -old_rank;
+
+ gtk_list_store_set (ctx->known_ns_store, &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN, new_rank,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, NULL,
+ -1);
+
+ if (order_row != NULL)
+ {
+ if (new_rank < 0)
+ {
+ if (GNUNET_OK == GNUNET_GTK_get_iter_from_reference (order_row,
&order_iter))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &order_iter,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, &known_row,
-1);
+ gtk_list_store_remove (ctx->ns_order_store, &order_iter);
+ if (known_row != NULL)
+ gtk_tree_row_reference_free (known_row);
+ }
+ }
+ gtk_tree_row_reference_free (order_row);
+ }
+ if (new_rank >= 0)
+ {
+ char *name, *identifier;
+ if (order_row != NULL)
+ {
+ /* This should not happen */
+ GNUNET_break (0);
+ }
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN, &name,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_COLUMN, &identifier,
+ -1);
+ known_row = GNUNET_GTK_get_reference_from_iter (GTK_TREE_MODEL (
+ ctx->known_ns_store), &known_iter);
+ gtk_list_store_insert_with_values (ctx->ns_order_store, &order_iter,
G_MAXINT,
+ GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN, new_rank,
+ GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN, name,
+ GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN, identifier,
+ GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_BIN_COLUMN, nsid,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, known_row,
+ -1);
+ g_free (name);
+ g_free (identifier);
+ order_row = GNUNET_GTK_get_reference_from_iter (GTK_TREE_MODEL
(ctx->ns_order_store),
+ &order_iter);
+ gtk_list_store_set (ctx->known_ns_store, &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, order_row, -1);
+ }
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_order_apply_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter;
+ gint i;
+ gint row_count;
+ GtkTreeRowReference *known_row;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->ns_order_store), NULL);
+ if (TRUE != gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
+ ctx->ns_order_store), &iter))
+ return;
+
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_list_store_set (ctx->ns_order_store, &iter,
+ GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN, i, -1);
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &iter,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, &known_row, -1);
+ if (known_row == NULL)
+ {
+ /* This is not supposed to happen. What to do? */
+ GNUNET_break (0);
+ }
+ else
+ {
+ GtkTreeIter known_iter;
+ if (GNUNET_OK == GNUNET_GTK_get_iter_from_reference (known_row,
&known_iter))
+ {
+ gtk_list_store_set (ctx->known_ns_store, &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN, i,
+ -1);
+ }
+ }
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->ns_order_store), &iter))
+ break;
+ }
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_details_add_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ /* FIXME: add a row to the details list. Disabled at the moment, since
+ * metadata type selection is not implemented.
+ */
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_details_delete_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter;
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->ns_details_sel, NULL,
&iter))
+ return;
+
+ gtk_list_store_remove (ctx->ns_details_store, &iter);
+ gtk_widget_set_sensitive (ctx->details_apply_button, TRUE);
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_details_apply_button_clicked_cb (
+ GtkButton *button, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter, known_iter;
+ gint i;
+ gint row_count;
+ struct GNUNET_CONTAINER_MetaData *md, *old_md;
+ char *plugin_name;
+ int type;
+ char *type_name;
+ int format;
+ char *data_mime_type;
+ char *data;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->ns_details_store), NULL);
+ if ((row_count > 0) && (TRUE != gtk_tree_model_get_iter_first (
+ GTK_TREE_MODEL (ctx->ns_details_store), &iter)))
+ {
+ /* This should not happen */
+ return;
+ }
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->known_ns_sel, NULL,
+ &known_iter))
+ {
+ /* This should not happen */
+ return;
+ }
+
+ md = GNUNET_CONTAINER_meta_data_create ();
+
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_details_store), &iter,
+ GNUNET_GTK_NAMESPACE_DETAILS_PLUGIN_NAME_COLUMN, &plugin_name,
+ GNUNET_GTK_NAMESPACE_DETAILS_TYPE_BIN_COLUMN, &type,
+ GNUNET_GTK_NAMESPACE_DETAILS_TYPE_COLUMN, &type_name,
+ GNUNET_GTK_NAMESPACE_DETAILS_FORMAT_COLUMN, &format,
+ GNUNET_GTK_NAMESPACE_DETAILS_DATA_MIME_COLUMN, &data_mime_type,
+ GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN, &data,
+ -1);
+ GNUNET_CONTAINER_meta_data_insert (md, plugin_name,
+ type, format, data_mime_type, data, strlen (data) + 1);
+ g_free (plugin_name);
+ g_free (type_name);
+ g_free (data_mime_type);
+ g_free (data);
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->ns_details_store), &iter))
+ break;
+ }
+ GNUNET_CONTAINER_meta_data_merge (md,
+ (const struct GNUNET_CONTAINER_MetaData *) ctx->uneditable_md);
+
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, &old_md,
+ -1);
+ GNUNET_CONTAINER_meta_data_destroy (old_md);
+ gtk_list_store_set (ctx->known_ns_store, &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, md,
+ -1);
+ gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
+}
+
+void
+GNUNET_GTK_namespace_manager_name_text_editing_started_cb (
+ GtkCellRenderer *renderer, GtkCellEditable *editable, gchar *path,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+
+ if (GTK_IS_ENTRY (editable))
+ {
+ GtkTreePath *tree_path;
+ GtkTreeIter iter;
+ char *non_unique_name = NULL;
+ GtkEntry *entry = GTK_ENTRY (editable);
+
+ tree_path = gtk_tree_path_new_from_string (path);
+ if (tree_path != NULL)
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->known_ns_store),
+ &iter, tree_path))
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN,
&non_unique_name,
+ -1);
+ }
+ gtk_tree_path_free (tree_path);
+ }
+ if (non_unique_name == NULL)
+ {
+ gtk_cell_editable_editing_done (editable);
+ return;
+ }
+ gtk_entry_set_text (entry, non_unique_name);
+ g_free (non_unique_name);
+ }
+}
+
+void
+GNUNET_GTK_namespace_manager_name_text_edited_cb (
+ GtkCellRendererText *renderer, gchar *path, gchar *new_text,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ char *unique_name;
+ GtkTreeRowReference *order_row;
+
+ if (strlen (new_text) == 0)
+ return;
+
+ GtkTreePath *tree_path;
+ GtkTreeIter iter;
+ tree_path = gtk_tree_path_new_from_string (path);
+ if (tree_path != NULL)
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->known_ns_store),
+ &iter, tree_path))
+ {
+ GNUNET_HashCode *nsid;
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, &order_row,
+ -1);
+
+ unique_name = GNUNET_PSEUDONYM_name_uniquify (
+ GNUNET_FS_GTK_get_configuration (), nsid, new_text, NULL);
+
+ gtk_list_store_set (ctx->known_ns_store, &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN, new_text,
+ GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN, unique_name,
+ -1);
+
+ if (order_row != NULL)
+ {
+ GtkTreeIter order_iter;
+ if (GNUNET_OK == GNUNET_GTK_get_iter_from_reference (order_row,
&order_iter))
+ {
+ gtk_list_store_set (ctx->ns_order_store, &order_iter,
+ GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN, unique_name,
+ -1);
+ }
+ }
+
+ GNUNET_free (unique_name);
+ }
+ gtk_tree_path_free (tree_path);
+ }
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_details_type_text_edited_cb (
+ GtkCellRendererText *renderer, gchar *path, gchar *new_text,
+ gpointer user_data)
+{
+ /* Changing metadata type is more difficult than simply entering a
+ * new string, see publication editing dialog. So this is disabled
+ * for now. In fact, it's not going to be a Text renderer when it's done.
+ */
+ /*
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
+ GtkTreeIter iter;
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->ns_details_store),
+ &iter, path))
+ {
+ gtk_list_store_set (ctx->ns_details_store, &iter,
+ GNUNET_GTK_NAMESPACE_DETAILS_TYPE_COLUMN, new_text,
+ -1);
+ }
+ */
+}
+
+void
+GNUNET_GTK_namespace_manager_namespace_details_value_text_edited_cb (
+ GtkCellRendererText *renderer, gchar *path, gchar *new_text,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreePath *tree_path;
+ GtkTreeIter iter;
+ tree_path = gtk_tree_path_new_from_string (path);
+ if (tree_path != NULL)
+ {
+ if (gtk_tree_model_get_iter (GTK_TREE_MODEL (ctx->ns_details_store),
+ &iter, tree_path))
+ {
+ char *old_text;
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_details_store), &iter,
+ GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN, &old_text,
+ -1);
+ if (strcmp (old_text, new_text) != 0)
+ {
+ gtk_list_store_set (ctx->ns_details_store, &iter,
+ GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN, new_text,
+ -1);
+ gtk_widget_set_sensitive (ctx->details_apply_button, TRUE);
+ }
+ g_free (old_text);
+ }
+ gtk_tree_path_free (tree_path);
+ }
+}
+
+/**
+ * Iterator over all known pseudonyms.
+ * Populate "known ns" and "ns order" lists.
+ *
+ * @param cls closure
+ * @param pseudonym hash code of public key of pseudonym
+ * @param md meta data known about the pseudonym
+ * @param rating the local rating of the pseudonym
+ * @return GNUNET_OK to continue iteration, GNUNET_SYSERR to abort
+ */
+static int
+populate_known_ns_list (void *cls, const GNUNET_HashCode *pseudonym,
+ const char *name, const char *unique_name,
+ const struct GNUNET_CONTAINER_MetaData *md, int rating)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
+ GNUNET_HashCode *nsid;
+ struct GNUNET_CRYPTO_HashAsciiEncoded identifier;
+ GtkTreeIter known_iter, order_iter;
+ struct GNUNET_CONTAINER_MetaData *md_copy;
+ char *non_null_name, *non_null_unique_name;
+
+ nsid = GNUNET_malloc (sizeof (GNUNET_HashCode));
+ *nsid = *pseudonym;
+
+ GNUNET_CRYPTO_hash_to_enc (nsid, &identifier);
+
+ GNUNET_PSEUDONYM_get_info (GNUNET_FS_GTK_get_configuration (),
+ nsid, NULL, NULL, &non_null_name, NULL);
+ non_null_unique_name = GNUNET_PSEUDONYM_name_uniquify (
+ GNUNET_FS_GTK_get_configuration (), nsid, non_null_name, NULL);
+
+ md_copy = GNUNET_CONTAINER_meta_data_duplicate (md);
+
+ gtk_list_store_insert_with_values (ctx->known_ns_store, &known_iter,
G_MAXINT,
+ GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN, FALSE,
+ GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN, rating,
+ GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN, non_null_unique_name,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_COLUMN, identifier.encoding,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, NULL,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, md_copy,
+ GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN, non_null_name,
+ -1);
+
+ if (rating >= 0)
+ {
+ GtkTreeRowReference *rr = GNUNET_GTK_get_reference_from_iter
(GTK_TREE_MODEL (
+ ctx->known_ns_store), &known_iter);
+ gtk_list_store_insert_with_values (ctx->ns_order_store, &order_iter,
G_MAXINT,
+ GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN, rating,
+ GNUNET_GTK_NAMESPACE_ORDER_NAME_COLUMN, non_null_unique_name,
+ GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_COLUMN, identifier.encoding,
+ GNUNET_GTK_NAMESPACE_ORDER_IDENTIFIER_BIN_COLUMN, nsid,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, rr,
+ -1);
+ rr = GNUNET_GTK_get_reference_from_iter (GTK_TREE_MODEL
(ctx->ns_order_store),
+ &order_iter);
+ gtk_list_store_set (ctx->known_ns_store, &known_iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, rr, -1);
+ }
+ GNUNET_free (non_null_name);
+ GNUNET_free (non_null_unique_name);
+
+ return GNUNET_OK;
+}
+
+static void
+apply_known_ns_changes (struct GNUNET_GTK_NamespaceManagerContext *ctx)
+{
+ GtkTreeIter iter;
+ gint i;
+ gint row_count;
+ GNUNET_HashCode *nsid;
+ char *name;
+ int32_t rank;
+ struct GNUNET_CONTAINER_MetaData *md;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->known_ns_store), NULL);
+ if (TRUE != gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
+ ctx->known_ns_store), &iter))
+ return;
+
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_NON_UNIQUE_NAME_COLUMN, &name,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, &md,
+ GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN, &rank,
+ -1);
+ GNUNET_PSEUDONYM_set_info (GNUNET_FS_GTK_get_configuration (),
+ nsid, name, md, rank);
+ g_free (name);
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->known_ns_store), &iter))
+ break;
+ }
+}
+
+static void
+free_lists_contents (struct GNUNET_GTK_NamespaceManagerContext *ctx)
+{
+ GtkTreeIter iter;
+ gint i;
+ gint row_count;
+ GNUNET_HashCode *nsid;
+ GtkTreeRowReference *order_row;
+ struct GNUNET_CONTAINER_MetaData *md;
+
+ row_count = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (
+ ctx->known_ns_store), NULL);
+ if (TRUE != gtk_tree_model_get_iter_first (GTK_TREE_MODEL (
+ ctx->known_ns_store), &iter))
+ return;
+
+ for (i = 0; i < row_count; i++)
+ {
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &nsid,
+ GNUNET_GTK_KNOWN_NAMESPACES_ORDER_ROW_REFERENCE_COLUMN, &order_row,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, &md,
+ -1);
+ if (order_row != NULL)
+ {
+ GtkTreeIter order_iter;
+ if (GNUNET_OK == GNUNET_GTK_get_iter_from_reference (order_row,
&order_iter))
+ {
+ GtkTreeRowReference *known_row;
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->ns_order_store), &order_iter,
+ GNUNET_GTK_NAMESPACE_ORDER_KNOWN_ROW_REFERENCE_COLUMN, &known_row,
+ -1);
+ if (known_row != NULL)
+ gtk_tree_row_reference_free (known_row);
+ }
+ gtk_tree_row_reference_free (order_row);
+ }
+ GNUNET_CONTAINER_meta_data_destroy (md);
+ GNUNET_free (nsid);
+ if (TRUE != gtk_tree_model_iter_next (GTK_TREE_MODEL (
+ ctx->known_ns_store), &iter))
+ break;
+ }
+
+ gtk_list_store_clear (ctx->ns_order_store);
+ gtk_list_store_clear (ctx->known_ns_store);
+ gtk_list_store_clear (ctx->ns_details_store);
+ if (ctx->uneditable_md != NULL)
+ GNUNET_CONTAINER_meta_data_destroy (ctx->uneditable_md);
+}
+
+void
+GNUNET_GTK_namespace_manager_dialog_response_cb (GtkDialog *dialog,
+ gint response_id, gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ switch (response_id)
+ {
+ case GTK_RESPONSE_APPLY:
+ case GTK_RESPONSE_OK:
+ apply_known_ns_changes (ctx);
+ break;
+ default:
+ break;
+ }
+ switch (response_id)
+ {
+ case GTK_RESPONSE_APPLY:
+ break;
+ case GTK_RESPONSE_OK:
+ case GTK_RESPONSE_CANCEL:
+ default:
+ free_lists_contents (ctx);
+ gtk_widget_destroy (GTK_WIDGET (ctx->namespace_manager));
+ GNUNET_free (ctx);
+ ns_manager = NULL;
+ }
+}
+
+
+static gboolean
+mark_as_mine (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter,
+ gpointer data)
+{
+ const GNUNET_HashCode *mine_id = data;
+ const GNUNET_HashCode *ns_id;
+
+ gtk_tree_model_get (model, iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IDENTIFIER_BIN_COLUMN, &ns_id, -1);
+
+ if (memcmp (ns_id, mine_id, sizeof (GNUNET_HashCode)) != 0)
+ return FALSE;
+
+ gtk_list_store_set (GTK_LIST_STORE (model), iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN, TRUE, -1);
+ return TRUE;
+}
+
+/**
+ * Callback with information about local (!) namespaces.
+ * Contains the names of the local namespace and the global
+ * ID.
+ *
+ * @param cls closure
+ * @param name human-readable identifier of the namespace
+ * @param id hash identifier for the namespace
+ */
+static void
+mark_namespaces_as_mine (void *cls, const char *name,
+ const GNUNET_HashCode * id)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
+
+ gtk_tree_model_foreach (GTK_TREE_MODEL (ctx->known_ns_store), mark_as_mine,
+ (gpointer) id);
+}
+
+/**
+ * Type of a function that libextractor calls for each
+ * meta data item found.
+ *
+ * @param cls closure (user-defined)
+ * @param plugin_name name of the plugin that produced this value;
+ * special values can be used (i.e. '<zlib>' for zlib being
+ * used in the main libextractor library and yielding
+ * meta data).
+ * @param type libextractor-type describing the meta data
+ * @param format basic format information about data
+ * @param data_mime_type mime-type of data (not of the original file);
+ * can be NULL (if mime-type is not known)
+ * @param data actual meta-data found
+ * @param data_len number of bytes in data
+ * @return 0 to continue extracting, 1 to abort
+ */
+static int
+populate_details_list (void *cls, const char *plugin_name,
+ enum EXTRACTOR_MetaType type, enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type, const char *data, size_t data_len)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = cls;
+ const char *type_name;
+ char *data_utf8;
+
+ if (format == EXTRACTOR_METAFORMAT_UTF8 ||
+ format == EXTRACTOR_METAFORMAT_C_STRING)
+ {
+ type_name = EXTRACTOR_metatype_to_string (type);
+ /* TODO: translate type_name using dgettext? */
+ data_utf8 = GNUNET_FS_GTK_dubious_meta_to_utf8 (format, data, data_len);
+ if (data != NULL)
+ {
+ gtk_list_store_insert_with_values (ctx->ns_details_store, NULL, G_MAXINT,
+ GNUNET_GTK_NAMESPACE_DETAILS_PLUGIN_NAME_COLUMN, plugin_name,
+ GNUNET_GTK_NAMESPACE_DETAILS_TYPE_BIN_COLUMN, type,
+ GNUNET_GTK_NAMESPACE_DETAILS_TYPE_COLUMN, type_name,
+ GNUNET_GTK_NAMESPACE_DETAILS_FORMAT_COLUMN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ GNUNET_GTK_NAMESPACE_DETAILS_DATA_MIME_COLUMN, data_mime_type,
+ GNUNET_GTK_NAMESPACE_DETAILS_VALUE_COLUMN, data_utf8,
+ -1);
+ GNUNET_free (data_utf8);
+ return 0;
+ }
+ }
+ GNUNET_CONTAINER_meta_data_insert (ctx->uneditable_md,
+ plugin_name, type, format, data_mime_type, data, data_len);
+ return 0;
+}
+
+static void
+ns_details_selection_changed (GtkTreeSelection *treeselection,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter;
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->ns_details_sel, NULL,
&iter))
+ {
+ gtk_widget_set_sensitive (ctx->details_delete_button, FALSE);
+ return;
+ }
+
+ gtk_widget_set_sensitive (ctx->details_delete_button, TRUE);
+}
+
+static void
+known_ns_selection_changed (GtkTreeSelection *treeselection,
+ gpointer user_data)
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx = user_data;
+ GtkTreeIter iter;
+ const struct GNUNET_CONTAINER_MetaData *md;
+
+ if (FALSE == gtk_tree_selection_get_selected (ctx->known_ns_sel, NULL,
&iter))
+ return;
+
+ gtk_tree_model_get (GTK_TREE_MODEL (ctx->known_ns_store), &iter,
+ GNUNET_GTK_KNOWN_NAMESPACES_METADATA_COLUMN, &md,
+ -1);
+ if (ctx->uneditable_md != NULL)
+ GNUNET_CONTAINER_meta_data_clear (ctx->uneditable_md);
+ else
+ ctx->uneditable_md = GNUNET_CONTAINER_meta_data_create ();
+ gtk_list_store_clear (ctx->ns_details_store);
+ gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
+ GNUNET_CONTAINER_meta_data_iterate ((const struct GNUNET_CONTAINER_MetaData
*) md,
+ populate_details_list, ctx);
+ gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
+}
+
+void
+GNUNET_GTK_namespace_manager_open ()
+{
+ struct GNUNET_GTK_NamespaceManagerContext *ctx;
+
+ if (ns_manager != NULL)
+ return;
+
+ ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceManagerContext));
+ ctx->builder = GNUNET_GTK_get_new_builder
("gnunet_fs_gtk_namespace_manager.glade", ctx);
+ if (ctx->builder == NULL)
+ {
+ GNUNET_break (0);
+ GNUNET_free (ctx);
+ return;
+ }
+
+ /* initialize widget references */
+ ctx->known_ns = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_manager_known_treeview"));
+ ctx->ns_order = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_manager_namespace_order_treeview"));
+ ctx->ns_details = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_manager_namespace_details_treeview"));
+ ctx->known_ns_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ ctx->known_ns));
+ ctx->ns_order_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ ctx->ns_order));
+ ctx->ns_details_sel = gtk_tree_view_get_selection (GTK_TREE_VIEW (
+ ctx->ns_details));
+ ctx->ns_order_store = GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (ctx->ns_order)));
+ ctx->known_ns_store = GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (ctx->known_ns)));
+ ctx->ns_details_store = GTK_LIST_STORE (gtk_tree_view_get_model (
+ GTK_TREE_VIEW (ctx->ns_details)));
+ ctx->namespace_manager = GTK_WINDOW (gtk_builder_get_object (
+ ctx->builder, "GNUNET_GTK_namespace_manager_dialog"));
+ ctx->details_apply_button = GTK_WIDGET (gtk_builder_get_object (ctx->builder,
+ "GNUNET_GTK_namespace_manager_namespace_details_apply_button"));
+ ctx->details_delete_button = GTK_WIDGET (gtk_builder_get_object
(ctx->builder,
+ "GNUNET_GTK_namespace_manager_namespace_details_delete_button"));
+ ctx->order_rank = gtk_tree_view_get_column (GTK_TREE_VIEW (ctx->ns_order),
0);
+ ctx->order_name = gtk_tree_view_get_column (GTK_TREE_VIEW (ctx->ns_order),
1);
+ ctx->order_id = gtk_tree_view_get_column (GTK_TREE_VIEW (ctx->ns_order), 2);
+
+ /* connect signals; FIXME-GTK3: these could be connected with (modern) Glade
*/
+ g_signal_connect (G_OBJECT (ctx->known_ns_sel), "changed",
+ G_CALLBACK (known_ns_selection_changed), ctx);
+ g_signal_connect (G_OBJECT (ctx->ns_details_sel), "changed",
+ G_CALLBACK (ns_details_selection_changed), ctx);
+
+ /* populate namespace model */
+ (void) GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (),
+ populate_known_ns_list, ctx);
+
+ /* mark our own namespaces as such */
+ GNUNET_FS_namespace_list (GNUNET_FS_GTK_get_fs_handle (),
+ mark_namespaces_as_mine, ctx);
+
+ /* sort namespace order list by rank (initially) */
+ sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN);
+
+ ns_manager = ctx;
+
+ gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
+
+ /* show dialog */
+ gtk_window_present (GTK_WINDOW (ctx->namespace_manager));
+}
+
+/* end of gnunet-fs-gtk_namespace_manager.c */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r20155 - in gnunet-gtk: contrib src/fs,
gnunet <=