Whitespace changes only.
[pspp] / src / ui / gui / psppire-selector.c
index cd122d7bfb5dcb345cc5efb3525613608cc7dbb8..a021d92190eba329705f1fca38713351d46c7c98 100644 (file)
@@ -111,7 +111,7 @@ psppire_selector_get_type (void)
       static const GTypeInfo psppire_selector_info =
       {
        sizeof (PsppireSelectorClass),
-       (GBaseInitFunc) NULL, 
+       (GBaseInitFunc) NULL,
         (GBaseFinalizeFunc) NULL,
        (GClassInitFunc)psppire_selector_class_init,
        (GClassFinalizeFunc) NULL,
@@ -133,8 +133,6 @@ static GObjectClass * parent_class = NULL;
 
 
 
-#define SELECTOR_DEBUGGING 0
-
 static void
 dump_hash_entry (gpointer key, gpointer value, gpointer obj)
 {
@@ -151,7 +149,7 @@ dump_hash_entry (gpointer key, gpointer value, gpointer obj)
 }
 
 /* This function is for debugging only */
-void 
+void
 psppire_selector_show_map (PsppireSelector *obj)
 {
   PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
@@ -189,7 +187,7 @@ psppire_selector_dispose (GObject *obj)
 
       sel->source_litem = NULL;
     }
-  
+
   g_object_unref (sel->dest);
   g_object_unref (sel->source);
 
@@ -213,9 +211,6 @@ static void on_click (GtkButton *b);
 static void on_realize (GtkWidget *selector);
 
 
-static void update_subjects (PsppireSelector *selector);
-
-
 static void
 psppire_selector_set_property (GObject         *object,
                               guint            prop_id,
@@ -232,15 +227,15 @@ psppire_selector_set_property (GObject         *object,
       break;
     case PROP_PRIMARY:
       selector->primary_requested = TRUE;
-      update_subjects (selector);
+      psppire_selector_update_subjects (selector);
       break;
     case PROP_SOURCE_WIDGET:
       selector->source = g_value_dup_object (value);
-      update_subjects (selector);
+      psppire_selector_update_subjects (selector);
       break;
     case PROP_DEST_WIDGET:
       selector->dest = g_value_dup_object (value);
-      update_subjects (selector);
+      psppire_selector_update_subjects (selector);
       break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -297,14 +292,14 @@ psppire_selector_class_init (PsppireSelectorClass *class)
                          FALSE,
                          G_PARAM_READWRITE);
 
-  GParamSpec *source_widget_spec = 
+  GParamSpec *source_widget_spec =
     g_param_spec_object ("source-widget",
                         "Source Widget",
                         "The widget to be used as the source for this selector",
                         GTK_TYPE_WIDGET,
                         G_PARAM_READWRITE);
 
-  GParamSpec *dest_widget_spec = 
+  GParamSpec *dest_widget_spec =
     g_param_spec_object ("dest-widget",
                         "Destination Widget",
                         "The widget to be used as the destination for this selector",
@@ -382,16 +377,16 @@ on_source_select (GtkTreeSelection *treeselection, gpointer data)
 
   set_direction (selector, PSPPIRE_SELECTOR_SOURCE_TO_DEST);
 
-  if ( selector->allow_selection )
+  if (selector->allow_selection)
     {
       gtk_widget_set_sensitive (GTK_WIDGET (selector),
                                selector->allow_selection (selector->source, selector->dest));
     }
-  else if ( GTK_IS_ENTRY (selector->dest) )
+  else if (GTK_IS_ENTRY (selector->dest))
     {
       gtk_widget_set_sensitive (GTK_WIDGET (selector),
                                gtk_tree_selection_count_selected_rows
-                               (treeselection) <= 1 );
+                               (treeselection) <= 1);
     }
 }
 
@@ -408,24 +403,24 @@ on_realize (GtkWidget *w)
   if (GTK_WIDGET_CLASS (parent_class)->realize)
     GTK_WIDGET_CLASS (parent_class)->realize (w);
 
-  if ( NULL == list)
+  if (NULL == list)
     return;
 
-  if ( g_list_first (list)->data == selector)
+  if (g_list_first (list)->data == selector)
     {
-      if ( selector->row_activate_id )
+      if (selector->row_activate_id)
        g_signal_handler_disconnect (selector->source, selector->row_activate_id);
 
-      selector->row_activate_id =  
+      selector->row_activate_id =
        g_signal_connect (selector->source, "row-activated", G_CALLBACK (on_row_activate), selector);
     }
 
   selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source));
 
-  if ( selector->source_select_id )
+  if (selector->source_select_id)
     g_signal_handler_disconnect (selection, selector->source_select_id);
 
-  selector->source_select_id = 
+  selector->source_select_id =
     g_signal_connect (selection, "changed", G_CALLBACK (on_source_select), selector);
 }
 
@@ -473,7 +468,7 @@ set_direction (PsppireSelector *selector, enum psppire_selector_dir d)
 
   /* FIXME: Need to reverse the arrow direction if an RTL locale is in
      effect */
-  if ( d == PSPPIRE_SELECTOR_SOURCE_TO_DEST )
+  if (d == PSPPIRE_SELECTOR_SOURCE_TO_DEST)
     {
       switch (selector->orientation)
        {
@@ -559,7 +554,7 @@ static void
 de_select_selection_tree_view (PsppireSelector *selector)
 {
   GtkTreeSelection* selection =
-    gtk_tree_view_get_selection ( GTK_TREE_VIEW (selector->dest));
+    gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->dest));
 
   GtkTreeModel *model =
     gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
@@ -569,7 +564,7 @@ de_select_selection_tree_view (PsppireSelector *selector)
   de_select_tree_model (selection, model);
 }
 
-static void 
+static void
 de_select_tree_model (GtkTreeSelection *selection, GtkTreeModel *model)
 {
   GList *item;
@@ -633,13 +628,13 @@ de_select_selection (PsppireSelector *selector)
 {
   selector->selecting = TRUE;
 
-  if ( GTK_IS_TREE_VIEW (selector->dest ) )
+  if (GTK_IS_TREE_VIEW (selector->dest))
     de_select_selection_tree_view (selector);
 
-  else if ( GTK_IS_ENTRY (selector->dest))
+  else if (GTK_IS_ENTRY (selector->dest))
     de_select_selection_entry (selector);
 
-  else if ( PSPPIRE_IS_MEANS_LAYER (selector->dest))
+  else if (PSPPIRE_IS_MEANS_LAYER (selector->dest))
     de_select_selection_means_layer (selector);
 
   else
@@ -659,7 +654,7 @@ select_selection (PsppireSelector *selector)
 {
   GList *item ;
   GtkTreeSelection* selection =
-    gtk_tree_view_get_selection ( GTK_TREE_VIEW (selector->source));
+    gtk_tree_view_get_selection (GTK_TREE_VIEW (selector->source));
 
   GList *selected_rows = gtk_tree_selection_get_selected_rows (selection, NULL);
 
@@ -669,7 +664,7 @@ select_selection (PsppireSelector *selector)
 
   g_return_if_fail (selector->select_items);
 
-  if (selector->allow_selection && 
+  if (selector->allow_selection &&
       ! selector->allow_selection (selector->source, selector->dest))
     return;
 
@@ -693,7 +688,7 @@ select_selection (PsppireSelector *selector)
                              selector->dest,
                              childmodel,
                              selector->select_user_data
-                             );
+                       );
     }
 
   g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
@@ -783,7 +778,7 @@ is_source_item_visible (GtkTreeModel *childmodel,
     {
       PsppireSelector *selector = list->data;
 
-      if ( selector->filter && selector->filter (childmodel, iter, selector))
+      if (selector->filter && selector->filter (childmodel, iter, selector))
        return FALSE;
 
       list = list->next;
@@ -800,10 +795,10 @@ set_tree_view_source (PsppireSelector *selector)
   GList *list = NULL;
 
   PsppireSelectorClass *class = g_type_class_peek (PSPPIRE_SELECTOR_TYPE);
-  
-  if ( ! (list = g_hash_table_lookup (class->source_hash, selector->source)))
+
+  if (! (list = g_hash_table_lookup (class->source_hash, selector->source)))
     {
-      /* Base case:  This widget is currently not the source of 
+      /* Base case:  This widget is currently not the source of
         any selector.  Create a hash entry and make this selector
         the first selector in the list */
 
@@ -817,9 +812,9 @@ set_tree_view_source (PsppireSelector *selector)
     {  /* Append this selector to the list and push the <source,list>
          pair onto the hash table */
 
-      if ( NULL == g_list_find (list, selector) )
+      if (NULL == g_list_find (list, selector))
        {
-         if ( selector->primary_requested )
+         if (selector->primary_requested)
            {
              list = g_list_prepend (list, selector);
              selector->source_litem = list;
@@ -843,7 +838,7 @@ update_model (
               GtkTreeView *source,
               GParamSpec *psp,
               PsppireSelector *selector
-              )
+)
 {
   GtkTreeModel *model = gtk_tree_view_get_model (source);
 
@@ -852,14 +847,14 @@ update_model (
   if (model && (model == g_object_get_data (G_OBJECT (source), "model-copy")))
     return;
 
-  if (model != NULL) 
-    {      
-      GtkTreeModel *new_model = gtk_tree_model_filter_new (model, NULL); 
+  if (model != NULL)
+    {
+      GtkTreeModel *new_model = gtk_tree_model_filter_new (model, NULL);
 
-      g_object_set_data (G_OBJECT (source), "model-copy", new_model);  
+      g_object_set_data (G_OBJECT (source), "model-copy", new_model);
 
       gtk_tree_view_set_model (source, new_model);
-  
+
       gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (new_model),
                                               is_source_item_visible,
                                               selector,
@@ -890,7 +885,7 @@ on_dest_data_change (GtkTreeModel *tree_model,
 {
   PsppireSelector *selector = user_data;
 
-  if ( selector->selecting) return;
+  if (selector->selecting) return;
 
   refilter (selector);
 }
@@ -903,7 +898,7 @@ on_dest_data_delete (GtkTreeModel *tree_model,
 {
   PsppireSelector *selector = user_data;
 
-  if ( selector->selecting ) return;
+  if (selector->selecting) return;
 
   refilter (selector);
 }
@@ -920,19 +915,19 @@ on_dest_model_changed (PsppireSelector *selector)
 {
   GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (selector->dest));
 
-  if (model == NULL) 
+  if (model == NULL)
     return;
 
   g_signal_connect (model, "row-changed", G_CALLBACK (on_dest_data_change),
                    selector);
-  
+
   g_signal_connect (model, "row-deleted", G_CALLBACK (on_dest_data_delete),
                    selector);
 
   g_signal_connect (selector, "destroy", G_CALLBACK (remove_selector_handlers), model);
-  
-  if ( selector->selecting ) return;
-  
+
+  if (selector->selecting) return;
+
   refilter (selector);
 }
 
@@ -1005,7 +1000,7 @@ set_entry_dest (PsppireSelector *selector,
 static void
 set_default_filter (PsppireSelector *selector)
 {
-  if ( selector->filter == NULL)
+  if (selector->filter == NULL)
     {
       if  (GTK_IS_TREE_VIEW (selector->dest))
        selector->filter = is_item_in_dest;
@@ -1013,36 +1008,36 @@ set_default_filter (PsppireSelector *selector)
 }
 
 
-static void
-update_subjects (PsppireSelector *selector)
+void
+psppire_selector_update_subjects (PsppireSelector *selector)
 {
-  if ( NULL == selector->dest )
+  if (NULL == selector->dest)
     return;
 
   set_default_filter (selector);
 
-  if ( NULL == selector->source )
+  if (NULL == selector->source)
     return;
 
-  if ( GTK_IS_TREE_VIEW (selector->source))
+  if (GTK_IS_TREE_VIEW (selector->source))
     {
       set_tree_view_source (selector);
 
-      g_signal_connect (selector->source, "notify::model", 
-                              G_CALLBACK (update_model), selector); 
+      g_signal_connect (selector->source, "notify::model",
+                              G_CALLBACK (update_model), selector);
 
       update_model (GTK_TREE_VIEW (selector->source), 0, selector);
     }
   else
     g_error ("Unsupported source widget: %s", G_OBJECT_TYPE_NAME (selector->source));
 
-  if ( NULL == selector->dest)
+  if (NULL == selector->dest)
     ;
-  else if  ( GTK_IS_TREE_VIEW (selector->dest))
+  else if  (GTK_IS_TREE_VIEW (selector->dest))
     {
       set_tree_view_dest (selector, GTK_TREE_VIEW (selector->dest));
     }
-  else if ( GTK_IS_ENTRY (selector->dest))
+  else if (GTK_IS_ENTRY (selector->dest))
     {
       set_entry_dest (selector, GTK_ENTRY (selector->dest));
     }
@@ -1058,16 +1053,15 @@ update_subjects (PsppireSelector *selector)
     g_error ("Unsupported destination widget: %s", G_OBJECT_TYPE_NAME (selector->dest));
 
 
-  /* FIXME: Remove this dependency */
-  if ( PSPPIRE_IS_DICT_VIEW (selector->source) )
+  if (PSPPIRE_IS_DICT_VIEW (selector->source) && selector->select_items == NULL)
     {
       GObjectClass *class = G_OBJECT_GET_CLASS (selector);
       GType type = G_OBJECT_TYPE (selector->dest);
 
-      SelectItemsFunc *func  = 
+      SelectItemsFunc *func  =
        g_hash_table_lookup (PSPPIRE_SELECTOR_CLASS (class)->default_selection_funcs, (gpointer) type);
 
-      if ( func )
+      if (func)
        psppire_selector_set_select_func (PSPPIRE_SELECTOR (selector),
                                          func, NULL);
     }