gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r20183 - in gnunet-gtk: contrib src/fs


From: gnunet
Subject: [GNUnet-SVN] r20183 - in gnunet-gtk: contrib src/fs
Date: Thu, 1 Mar 2012 19:38:45 +0100

Author: grothoff
Date: 2012-03-01 19:38:45 +0100 (Thu, 01 Mar 2012)
New Revision: 20183

Modified:
   gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
   gnunet-gtk/src/fs/gnunet-fs-gtk.c
   gnunet-gtk/src/fs/gnunet-fs-gtk.h
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
   gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
Log:
-LRN: Use destory signal to enforce ns manager singledness
, NS manager button in namespace dropdown list


Modified: gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade
===================================================================
--- gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade  2012-03-01 18:24:07 UTC 
(rev 20182)
+++ gnunet-gtk/contrib/gnunet_fs_gtk_main_window.glade  2012-03-01 18:38:45 UTC 
(rev 20183)
@@ -773,41 +773,65 @@
     <signal name="leave_notify_event" 
handler="GNUNET_FS_GTK_search_namespace_selector_window_leave_notify_event_cb"/>
     <signal name="enter_notify_event" 
handler="GNUNET_FS_GTK_search_namespace_dropdown_button_enter_notify_event_cb"/>
     <child>
-      <object class="GtkTreeView" id="namespace_selector_treeview">
-        <property name="visible">True</property>
-        <property name="can_focus">True</property>
-        <property name="is_focus">True</property>
-        <property 
name="model">main_window_search_namespace_treestore</property>
-        <property name="headers_clickable">False</property>
-        <property name="search_column">0</property>
-        <property name="hover_selection">True</property>
-        <property name="hover_expand">True</property>
-        <property name="tooltip_column">3</property>
-        <signal name="button_press_event" 
handler="GNUNET_FS_GTK_namespace_selector_treeview_button_press_event_cb"/>
-        <signal name="button_release_event" 
handler="GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb"/>
+      <object class="GtkVBox" id="namespace_selector_main_vbox">
         <child>
-          <object class="GtkTreeViewColumn" id="name_column">
-            <property name="sizing">autosize</property>
-            <property name="title">Name</property>
+          <object class="GtkTreeView" id="namespace_selector_treeview">
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="is_focus">True</property>
+            <property 
name="model">main_window_search_namespace_treestore</property>
+            <property name="headers_clickable">False</property>
+            <property name="search_column">0</property>
+            <property name="hover_selection">True</property>
+            <property name="hover_expand">True</property>
+            <property name="tooltip_column">3</property>
+            <signal name="button_press_event" 
handler="GNUNET_FS_GTK_namespace_selector_treeview_button_press_event_cb"/>
+            <signal name="button_release_event" 
handler="GNUNET_FS_GTK_namespace_selector_treeview_button_release_event_cb"/>
             <child>
-              <object class="GtkCellRendererText" 
id="namespace_selector_name_column_text_cell"/>
-              <attributes>
-                <attribute name="text">0</attribute>
-              </attributes>
+              <object class="GtkTreeViewColumn" id="name_column">
+                <property name="sizing">autosize</property>
+                <property name="title">Name</property>
+                <child>
+                  <object class="GtkCellRendererText" 
id="namespace_selector_name_column_text_cell"/>
+                  <attributes>
+                    <attribute name="text">0</attribute>
+                  </attributes>
+                </child>
+              </object>
             </child>
+            <child>
+              <object class="GtkTreeViewColumn" id="key_column">
+                <property name="sizing">autosize</property>
+                <property name="title">Root</property>
+                <child>
+                  <object class="GtkCellRendererText" 
id="namespace_selector_key_column_text_cell"/>
+                  <attributes>
+                    <attribute name="text">2</attribute>
+                  </attributes>
+                </child>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkTreeViewColumn" id="key_column">
-            <property name="sizing">autosize</property>
-            <property name="title">Root</property>
-            <child>
-              <object class="GtkCellRendererText" 
id="namespace_selector_key_column_text_cell"/>
-              <attributes>
-                <attribute name="text">2</attribute>
-              </attributes>
-            </child>
+          <object class="GtkButton" 
id="namespace_selector_manage_namespaces_button">
+            <property name="label" translatable="yes">_Manage 
namespaces</property>
+            <property name="visible">True</property>
+            <property name="can_focus">True</property>
+            <property name="receives_default">False</property>
+            <property name="use_underline">True</property>
+            <signal name="clicked" 
handler="namespace_selector_manage_namespaces_button_clicked_cb"/>
           </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">False</property>
+            <property name="position">1</property>
+          </packing>
         </child>
       </object>
     </child>

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-03-01 18:24:07 UTC (rev 20182)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.c   2012-03-01 18:38:45 UTC (rev 20183)
@@ -173,7 +173,7 @@
 void
 GNUNET_GTK_quit_cb (GObject * object, gpointer user_data)
 {
-  struct GNUNET_GTK_MainWindowContext *main_context;
+  struct GNUNET_GTK_MainWindowContext *main_context = user_data;
 
   main_window_save_position (main_context->main_window);
 

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk.h
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk.h   2012-03-01 18:24:07 UTC (rev 20182)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk.h   2012-03-01 18:38:45 UTC (rev 20183)
@@ -56,6 +56,8 @@
   GtkTreeRowReference *ns_selector_pushed_row;
   GtkTreeRowReference *selected_ns_row;
   int ns_callback_registered;
+  GtkObject *ns_manager;
+  gulong ns_manager_delete_handler_id;
 };
 
 /**

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 18:24:07 UTC (rev 20182)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c    
2012-03-01 18:38:45 UTC (rev 20183)
@@ -25,6 +25,7 @@
  */
 #include "gnunet-fs-gtk_common.h"
 #include "gnunet-fs-gtk.h"
+#include "gnunet-fs-gtk_event-handler.h"
 
 /**
  * How long until we automatically hide the drop-down if the cursor is outside 
the bounds?
@@ -435,4 +436,10 @@
   GNUNET_free_non_null (selected_ns_id);
 }
 
+void
+namespace_selector_manage_namespaces_button_clicked_cb (GtkButton *button, 
gpointer user_data)
+{
+  GNUNET_GTK_open_ns_manager (user_data);
+}
+
 /* end of gnunet-fs-gtk_main-window-namespace-dropdown.c */

Modified: gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c
===================================================================
--- gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c 2012-03-01 18:24:07 UTC 
(rev 20182)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_namespace_manager.c 2012-03-01 18:38:45 UTC 
(rev 20183)
@@ -50,15 +50,6 @@
   struct GNUNET_GTK_MainWindowContext *main_ctx;
 };
 
-/**
- * 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
@@ -763,7 +754,6 @@
     free_lists_contents (ctx);
     gtk_widget_destroy (GTK_WIDGET (ctx->namespace_manager));
     GNUNET_free (ctx);
-    ns_manager = NULL;
   }
 }
 
@@ -898,25 +888,18 @@
   gtk_widget_set_sensitive (ctx->details_apply_button, FALSE);
 }
 
-
-
-void
-GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
-    gpointer user_data)
+GtkObject *
+GNUNET_GTK_namespace_manager_open (struct GNUNET_GTK_MainWindowContext 
*main_ctx)
 {
-  struct GNUNET_GTK_MainWindowContext *main_ctx = user_data;
-    struct GNUNET_GTK_NamespaceManagerContext *ctx;
+  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;
+    return NULL;
   }
 
   ctx->main_ctx = main_ctx;
@@ -967,12 +950,46 @@
   /* 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));
+  return GTK_OBJECT (ctx->namespace_manager);
 }
 
+void
+ns_manager_deleted (GtkObject *object, gpointer user_data)
+{
+  struct GNUNET_GTK_MainWindowContext *ctx = user_data;
+  g_signal_handler_disconnect (object, ctx->ns_manager_delete_handler_id);
+  g_object_unref (G_OBJECT (ctx->ns_manager));
+  ctx->ns_manager = NULL;
+  ctx->ns_manager_delete_handler_id = 0;
+  return;
+}
+
+void
+GNUNET_GTK_open_ns_manager (struct GNUNET_GTK_MainWindowContext *ctx)
+{
+  if (ctx->ns_manager != NULL)
+  {
+    gtk_window_present (GTK_WINDOW (ctx->ns_manager));
+    return;
+  }
+
+  ctx->ns_manager = GNUNET_GTK_namespace_manager_open (ctx);
+  if (ctx->ns_manager == NULL)
+    return;
+
+  g_object_ref (G_OBJECT (ctx->ns_manager));
+  ctx->ns_manager_delete_handler_id = g_signal_connect (G_OBJECT 
(ctx->ns_manager), "destroy", G_CALLBACK (ns_manager_deleted), ctx);
+}
+
+void
+GNUNET_GTK_main_menu_file_manage_pseudonyms_activate_cb (GtkMenuItem *menuitem,
+    gpointer user_data)
+{
+  GNUNET_GTK_open_ns_manager (user_data);
+}
+
 /* end of gnunet-fs-gtk_namespace_manager.c */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]