gnome-terminal r2609 - trunk/src



Author: chpe
Date: Thu May 29 19:38:19 2008
New Revision: 2609
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2609&view=rev

Log:
Fix button sensitivity update on selection change in the profile manager.


Modified:
   trunk/src/terminal-app.c

Modified: trunk/src/terminal-app.c
==============================================================================
--- trunk/src/terminal-app.c	(original)
+++ trunk/src/terminal-app.c	Thu May 29 19:38:19 2008
@@ -641,8 +641,6 @@
                                       NULL, NULL);
   gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
                                GTK_TREE_VIEW_COLUMN (column));
-  
-  profile_list_treeview_refill (tree_view);
 
   return tree_view;
 }
@@ -1264,60 +1262,46 @@
 }
 
 static void
-manage_profiles_destroyed_callback (GtkWidget   *manage_profiles_dialog,
-                                    TerminalApp *app)
+profile_list_selection_changed_cb (GtkTreeSelection *selection,
+                                   TerminalApp *app)
 {
-  app->manage_profiles_dialog = NULL;
-  app->manage_profiles_list = NULL;
-  app->manage_profiles_new_button = NULL;
-  app->manage_profiles_edit_button = NULL;
-  app->manage_profiles_delete_button = NULL;
-  app->manage_profiles_default_menu = NULL;
-}
+  gboolean selected;
 
-static void
-count_selected_profiles_func (GtkTreeModel      *model,
-                              GtkTreePath       *path,
-                              GtkTreeIter       *iter,
-                              gpointer           data)
-{
-  int *count = data;
+  selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
+  g_print ("selection %d\n", selected);
 
-  *count += 1;
+  gtk_widget_set_sensitive (app->manage_profiles_edit_button, selected);
+  gtk_widget_set_sensitive (app->manage_profiles_delete_button,
+                            selected &&
+                            terminal_app_get_profile_count (app) > 1);
 }
 
 static void
-selection_changed_callback (GtkTreeSelection *selection,
-                            TerminalApp      *app)
+profile_list_response_cb (GtkWidget *dialog,
+                          int        id,
+                          TerminalApp *app)
 {
-  int count;
-
-  count = 0;
-  gtk_tree_selection_selected_foreach (selection,
-                                       count_selected_profiles_func,
-                                       &count);
-
-  gtk_widget_set_sensitive (app->manage_profiles_edit_button,
-                            count == 1);
-  gtk_widget_set_sensitive (app->manage_profiles_delete_button,
-                            count > 0);
+  g_assert (app->manage_profiles_dialog == dialog);
+  
+  if (id == GTK_RESPONSE_HELP)
+    {
+      terminal_util_show_help ("gnome-terminal-manage-profiles", GTK_WINDOW (dialog));
+      return;
+    }
+    
+  gtk_widget_destroy (dialog);
 }
 
 static void
-manage_profiles_response_cb (GtkDialog *dialog,
-                             int        id,
-                             void      *data)
+profile_list_destroyed_cb (GtkWidget   *manage_profiles_dialog,
+                           TerminalApp *app)
 {
-  TerminalApp *app;
-
-  app = data;
-
-  g_assert (app->manage_profiles_dialog == GTK_WIDGET (dialog));
-  
-  if (id == GTK_RESPONSE_HELP)
-    terminal_util_show_help ("gnome-terminal-manage-profiles", GTK_WINDOW (dialog));
-  else
-    gtk_widget_destroy (GTK_WIDGET (dialog));
+  app->manage_profiles_dialog = NULL;
+  app->manage_profiles_list = NULL;
+  app->manage_profiles_new_button = NULL;
+  app->manage_profiles_edit_button = NULL;
+  app->manage_profiles_delete_button = NULL;
+  app->manage_profiles_default_menu = NULL;
 }
 
 void
@@ -1357,12 +1341,19 @@
   app->manage_profiles_edit_button = GTK_WIDGET (edit_button);
   app->manage_profiles_delete_button  = GTK_WIDGET (remove_button);
 
-  g_signal_connect (dialog, "response", G_CALLBACK (manage_profiles_response_cb), app);
-  g_signal_connect (dialog, "destroy", G_CALLBACK (manage_profiles_destroyed_callback), app);
+  g_signal_connect (dialog, "response", G_CALLBACK (profile_list_response_cb), app);
+  g_signal_connect (dialog, "destroy", G_CALLBACK (profile_list_destroyed_cb), app);
 
   app->manage_profiles_list = profile_list_treeview_create (app);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (app->manage_profiles_list));
+  g_signal_connect (selection, "changed", G_CALLBACK (profile_list_selection_changed_cb), app);
+
+  profile_list_treeview_refill (app->manage_profiles_list);
+
   g_signal_connect (app->manage_profiles_list, "row-activated",
                     G_CALLBACK (profile_list_row_activated_cb), app);
+
   gtk_container_add (GTK_CONTAINER (tree_view_container), app->manage_profiles_list);
   gtk_widget_show (app->manage_profiles_list);
 
@@ -1389,11 +1380,6 @@
       
   gtk_widget_grab_focus (app->manage_profiles_list);
 
-  /* Monitor selection for sensitivity */
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (app->manage_profiles_list));
-  selection_changed_callback (selection, app);
-  g_signal_connect (selection, "changed", G_CALLBACK (selection_changed_callback), app);
-
   gtk_window_set_transient_for (GTK_WINDOW (app->manage_profiles_dialog),
                                 transient_parent);
 



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