gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r19650 - gnunet-gtk/src/fs


From: gnunet
Subject: [GNUnet-SVN] r19650 - gnunet-gtk/src/fs
Date: Thu, 2 Feb 2012 19:44:08 +0100

Author: grothoff
Date: 2012-02-02 19:44:08 +0100 (Thu, 02 Feb 2012)
New Revision: 19650

Modified:
   gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c
Log:
-starting to clean up dropdown code

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-02-02 18:33:27 UTC (rev 19649)
+++ gnunet-gtk/src/fs/gnunet-fs-gtk_main-window-namespace-dropdown.c    
2012-02-02 18:44:08 UTC (rev 19650)
@@ -26,10 +26,15 @@
 #include "gnunet-fs-gtk_common.h"
 #include "gnunet-fs-gtk.h"
 
-
+/**
+ *
+ */
 static guint namespace_selector_window_leave_timeout_source;
 
 
+/**
+ *
+ */
 void
 main_window_search_namespace_dropdown_button_toggled_cb (GtkToggleButton *
                                                          togglebutton,
@@ -82,18 +87,10 @@
 }
 
 
+/**
+ *
+ */
 gboolean
-namespace_selector_window_leave_timeout_cb (gpointer user_data)
-{
-  GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (user_data);
-
-  /* This will eventually hide the namespace selector */
-  gtk_toggle_button_set_active (toggle_button, FALSE);
-  return FALSE;
-}
-
-
-gboolean
 main_window_search_namespace_dropdown_button_enter_notify_event_cb (GtkWidget *
                                                                     widget,
                                                                     GdkEvent *
@@ -107,6 +104,23 @@
 }
 
 
+/**
+ *
+ */
+static gboolean
+namespace_selector_window_leave_timeout_cb (gpointer user_data)
+{
+  GtkToggleButton *toggle_button = GTK_TOGGLE_BUTTON (user_data);
+
+  /* This will eventually hide the namespace selector */
+  gtk_toggle_button_set_active (toggle_button, FALSE);
+  return FALSE;
+}
+
+
+/**
+ *
+ */
 gboolean
 namespace_selector_window_leave_notify_event_cb (GtkWidget * widget,
                                                  GdkEvent * event,
@@ -137,8 +151,10 @@
 }
 
 
-
-gboolean
+/**
+ *
+ */
+static gboolean
 get_selected_namespace_treepath_iter_model_widget (GtkBuilder * builder,
                                                    GtkTreePath ** p_treepath,
                                                    GtkTreeIter * p_iter,
@@ -190,11 +206,15 @@
   return TRUE;
 }
 
+
+/**
+ *
+ */
 void
 namespace_selector_treeview_cursor_changed_cb (GtkWidget * widget,
                                                gpointer user_data)
 {
-  GtkBuilder *builder;
+  GtkBuilder *builder  = GTK_BUILDER (user_data);
   GtkToggleButton *toggle_button;
   GtkLabel *sel_namespace_label;
   GtkTreeModel *model;
@@ -203,8 +223,6 @@
   GtkEntry *search_entry;
   GtkTreeRowReference *ref, *old;
 
-  builder = GTK_BUILDER (user_data);
-
   toggle_button =
       GTK_TOGGLE_BUTTON (gtk_builder_get_object
                          (builder,
@@ -252,7 +270,11 @@
   gtk_toggle_button_set_active (toggle_button, FALSE);
 }
 
-GtkTreeRowReference *
+
+/**
+ *
+ */
+static GtkTreeRowReference *
 get_ns_selected_row (GtkTreeView * tree)
 {
   GtkTreeSelection *sel;
@@ -273,6 +295,10 @@
   return ref;
 }
 
+
+/**
+ *
+ */
 gboolean
 namespace_selector_treeview_button_press_event_cb (GtkWidget * widget,
                                                    GdkEvent * event,
@@ -292,6 +318,10 @@
   return FALSE;
 }
 
+
+/**
+ *
+ */
 gboolean
 namespace_selector_treeview_button_release_event_cb (GtkWidget * widget,
                                                      GdkEvent * event,
@@ -323,7 +353,6 @@
 }
 
 
-
 /**
  * Add pseudonym data to tree store
  *
@@ -389,8 +418,12 @@
     else
       description = NULL;
   }
-  gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 0, ns_name, 1,
-                                     nsid, 2, root, 3, description, -1);
+  gtk_tree_store_insert_with_values (ts, &iter, NULL, G_MAXINT, 
+                                    0, ns_name, 
+                                    1, nsid, 
+                                    2, root,
+                                    3, description, 
+                                    -1);
   GNUNET_free (ns_name);
   GNUNET_free_non_null (root);
   GNUNET_free_non_null (description);
@@ -398,17 +431,20 @@
 }
 
 
+/**
+ * Startup hook to initialize the namespace dropdown widget.
+ *
+ * @param widget the main window
+ * @param user_data the builder for the main window
+ */
 void
 GNUNET_GTK_main_window_realize_cb (GtkWidget * widget, gpointer user_data)
 {
+  GtkBuilder *builder = GTK_BUILDER (user_data);
   GtkTreeIter iter;
-  GtkTreeView *namespace_tree;
   GtkTreeStore *namespace_treestore;
-  GtkBuilder *builder;
-  GtkWidget *namespace_selector_window;
 
-  builder = GTK_BUILDER (user_data);
-
+  /* FIXME: can't we do the button initialization when we create the main 
window? */
   /* Make sure button class is realized */
   g_type_class_unref (g_type_class_ref (GTK_TYPE_BUTTON));
   /* GNUnet main window assumes that images on buttons are visible,
@@ -416,43 +452,45 @@
    */
   g_object_set (gtk_settings_get_default (), "gtk-button-images", TRUE, NULL);
 
-  namespace_treestore =
+  /* setup namespace treestore */
+  {
+    namespace_treestore =
       GTK_TREE_STORE (GNUNET_FS_GTK_get_main_window_object
                       ("main_window_search_namespace_treestore"));
-  namespace_tree =
-      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
-                     ("namespace_selector_treeview"));
+    
+    /* FIXME: find a way to manage pseudonyms.
+     * Right now the list will be filled with ALL and ANY pseudonyms that we
+     * find, these are held as files in a special directory.
+     * I don't see an easy way to ignore certain pseudonyms in that directory,
+     * and that require for pseudonym management. Also, pseudonyms are 
presented
+     * in arbitrary order. We must either sort them (by name?) or let the user
+     * drag them around to change the order in which they appear in the list.
+     * All that is not possible with a simple "files in a directory" concept.
+     */
+    gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 
G_MAXINT,
+                                      0, "Any", 1, NULL, 2, "", 3,
+                                      "Do not search in any particular 
namespace",
+                                      -1);
+    /* FIXME: when do we unregister? */
+    GNUNET_PSEUDONYM_discovery_callback_register 
(GNUNET_FS_GTK_get_configuration (), 
+                                                 &add_namespace_to_ts,
+                                                 namespace_treestore);
+  }
 
-  /* FIXME: find a way to manage pseudonyms.
-   * Right now the list will be filled with ALL and ANY pseudonyms that we
-   * find, these are held as files in a special directory.
-   * I don't see an easy way to ignore certain pseudonyms in that directory,
-   * and that require for pseudonym management. Also, pseudonyms are presented
-   * in arbitrary order. We must either sort them (by name?) or let the user
-   * drag them around to change the order in which they appear in the list.
-   * All that is not possible with a simple "files in a directory" concept.
-   */
-  gtk_tree_store_insert_with_values (namespace_treestore, &iter, NULL, 
G_MAXINT,
-                                     0, "Any", 1, NULL, 2, "", 3,
-                                     "Do not search in any particular 
namespace",
-                                     -1);
-  /*
-   * GNUNET_PSEUDONYM_list_all (GNUNET_FS_GTK_get_configuration (),
-   * &add_namespace_to_ts, namespace_treestore);
-   */
-  /* FIXME: when do we unregister? */
-  GNUNET_PSEUDONYM_discovery_callback_register 
(GNUNET_FS_GTK_get_configuration (), 
-                                               &add_namespace_to_ts,
-                                                namespace_treestore);
-
-  /* FIXME: read currently selected namespace from somewhere instead of 
selecting 0th item */
+  /* select the first item and update the label */
+  /* FIXME: is this even necessary? If the first item is "Any", we can
+     just have the label have the right default, or not? */
   if (gtk_tree_model_get_iter_first
       (GTK_TREE_MODEL (namespace_treestore), &iter))
   {
     gchar *value;
     GtkLabel *sel_namespace_label;
     GtkTreePath *treepath = gtk_tree_path_new_first ();
+    GtkTreeView *namespace_tree;
 
+    namespace_tree =
+      GTK_TREE_VIEW (GNUNET_FS_GTK_get_main_window_object
+                     ("namespace_selector_treeview"));
     gtk_tree_selection_select_iter (gtk_tree_view_get_selection
                                     (namespace_tree), &iter);
     sel_namespace_label =
@@ -463,13 +501,16 @@
     gtk_tree_path_free (treepath);
   }
 
-  /* How the window (to trigger certain events) and immediately hide it */
-  namespace_selector_window =
+  /* show the window (to trigger certain events) and immediately hide it */
+  {
+    GtkWidget *namespace_selector_window;
+
+    namespace_selector_window =
       GTK_WIDGET (gtk_builder_get_object
                   (builder, "namespace_selector_window"));
-  gtk_widget_show (namespace_selector_window);
-  gtk_widget_hide (namespace_selector_window);
-
+    gtk_widget_show (namespace_selector_window);
+    gtk_widget_hide (namespace_selector_window);
+  }
 }
 
 




reply via email to

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