aboutsummaryrefslogtreecommitdiff
path: root/src/fs/gnunet-fs-gtk_namespace_manager.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fs/gnunet-fs-gtk_namespace_manager.c')
-rw-r--r--src/fs/gnunet-fs-gtk_namespace_manager.c63
1 files changed, 40 insertions, 23 deletions
diff --git a/src/fs/gnunet-fs-gtk_namespace_manager.c b/src/fs/gnunet-fs-gtk_namespace_manager.c
index 95763aef..69fe4969 100644
--- a/src/fs/gnunet-fs-gtk_namespace_manager.c
+++ b/src/fs/gnunet-fs-gtk_namespace_manager.c
@@ -50,15 +50,6 @@ struct GNUNET_GTK_NamespaceManagerContext
50 struct GNUNET_GTK_MainWindowContext *main_ctx; 50 struct GNUNET_GTK_MainWindowContext *main_ctx;
51}; 51};
52 52
53/**
54 * THIS IS EVIL! Used to avoid opening more than one ns manager
55 * at once. Could be fixed by saving a pointer to the ns manager window
56 * somewhere in the main gnunet-fs-gtk window, but main window does
57 * not have a context structure for such things at the moment, hence
58 * this VERY EVIL GLOBAL VARIABLE!
59 */
60static struct GNUNET_GTK_NamespaceManagerContext *ns_manager = NULL;
61
62#define GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN 0 53#define GNUNET_GTK_KNOWN_NAMESPACES_IS_MINE_COLUMN 0
63#define GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN 1 54#define GNUNET_GTK_KNOWN_NAMESPACES_RANK_COLUMN 1
64#define GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN 2 55#define GNUNET_GTK_KNOWN_NAMESPACES_NAME_COLUMN 2
@@ -763,7 +754,6 @@ GNUNET_GTK_namespace_manager_dialog_response_cb (GtkDialog *dialog,
763 free_lists_contents (ctx); 754 free_lists_contents (ctx);
764 gtk_widget_destroy (GTK_WIDGET (ctx->namespace_manager)); 755 gtk_widget_destroy (GTK_WIDGET (ctx->namespace_manager));
765 GNUNET_free (ctx); 756 GNUNET_free (ctx);
766 ns_manager = NULL;
767 } 757 }
768} 758}
769 759
@@ -898,17 +888,10 @@ known_ns_selection_changed (GtkTreeSelection *treeselection,
898 gtk_widget_set_sensitive (ctx->details_apply_button, FALSE); 888 gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
899} 889}
900 890
901 891GtkObject *
902 892GNUNET_GTK_namespace_manager_open (struct GNUNET_GTK_MainWindowContext *main_ctx)
903void
904GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
905 gpointer user_data)
906{ 893{
907 struct GNUNET_GTK_MainWindowContext *main_ctx = user_data; 894 struct GNUNET_GTK_NamespaceManagerContext *ctx;
908 struct GNUNET_GTK_NamespaceManagerContext *ctx;
909
910 if (ns_manager != NULL)
911 return;
912 895
913 ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceManagerContext)); 896 ctx = GNUNET_malloc (sizeof (struct GNUNET_GTK_NamespaceManagerContext));
914 ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_namespace_manager.glade", ctx); 897 ctx->builder = GNUNET_GTK_get_new_builder ("gnunet_fs_gtk_namespace_manager.glade", ctx);
@@ -916,7 +899,7 @@ GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
916 { 899 {
917 GNUNET_break (0); 900 GNUNET_break (0);
918 GNUNET_free (ctx); 901 GNUNET_free (ctx);
919 return; 902 return NULL;
920 } 903 }
921 904
922 ctx->main_ctx = main_ctx; 905 ctx->main_ctx = main_ctx;
@@ -967,12 +950,46 @@ GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
967 /* sort namespace order list by rank (initially) */ 950 /* sort namespace order list by rank (initially) */
968 sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN); 951 sort_order_list (ctx, GNUNET_GTK_NAMESPACE_ORDER_RANK_COLUMN);
969 952
970 ns_manager = ctx;
971
972 gtk_widget_set_sensitive (ctx->details_apply_button, FALSE); 953 gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
973 954
974 /* show dialog */ 955 /* show dialog */
975 gtk_window_present (GTK_WINDOW (ctx->namespace_manager)); 956 gtk_window_present (GTK_WINDOW (ctx->namespace_manager));
957 return GTK_OBJECT (ctx->namespace_manager);
958}
959
960void
961ns_manager_deleted (GtkObject *object, gpointer user_data)
962{
963 struct GNUNET_GTK_MainWindowContext *ctx = user_data;
964 g_signal_handler_disconnect (object, ctx->ns_manager_delete_handler_id);
965 g_object_unref (G_OBJECT (ctx->ns_manager));
966 ctx->ns_manager = NULL;
967 ctx->ns_manager_delete_handler_id = 0;
968 return;
969}
970
971void
972GNUNET_GTK_open_ns_manager (struct GNUNET_GTK_MainWindowContext *ctx)
973{
974 if (ctx->ns_manager != NULL)
975 {
976 gtk_window_present (GTK_WINDOW (ctx->ns_manager));
977 return;
978 }
979
980 ctx->ns_manager = GNUNET_GTK_namespace_manager_open (ctx);
981 if (ctx->ns_manager == NULL)
982 return;
983
984 g_object_ref (G_OBJECT (ctx->ns_manager));
985 ctx->ns_manager_delete_handler_id = g_signal_connect (G_OBJECT (ctx->ns_manager), "destroy", G_CALLBACK (ns_manager_deleted), ctx);
986}
987
988void
989GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
990 gpointer user_data)
991{
992 GNUNET_GTK_open_ns_manager (user_data);
976} 993}
977 994
978/* end of gnunet-fs-gtk_namespace_manager.c */ 995/* end of gnunet-fs-gtk_namespace_manager.c */