[gimp] app: clean up the dynamics editor



commit 88f2af98aa5da976b4a62553f89d94752d0f936f
Author: Michael Natterer <mitch gimp org>
Date:   Wed Nov 24 23:01:50 2010 +0100

    app: clean up the dynamics editor
    
    Also fix its sensitivity when a read-only data is set. Fixes bug
    curves).

 app/widgets/gimpdynamicseditor.c |  101 ++++++++++++++++++--------------------
 1 files changed, 48 insertions(+), 53 deletions(-)
---
diff --git a/app/widgets/gimpdynamicseditor.c b/app/widgets/gimpdynamicseditor.c
index 4d7ec30..e8efade 100644
--- a/app/widgets/gimpdynamicseditor.c
+++ b/app/widgets/gimpdynamicseditor.c
@@ -99,10 +99,8 @@ gimp_dynamics_editor_init (GimpDynamicsEditor *editor)
 {
   GimpDataEditor *data_editor = GIMP_DATA_EDITOR (editor);
   GimpDynamics   *dynamics;
-  GtkWidget      *fixed;
   GtkWidget      *input_labels[7];
-  GtkWidget      *frame;
-  gint            n_inputs = G_N_ELEMENTS (input_labels);
+  gint            n_inputs    = G_N_ELEMENTS (input_labels);
   gint            i;
 
   dynamics = editor->dynamics_model = g_object_new (GIMP_TYPE_DYNAMICS, NULL);
@@ -130,21 +128,18 @@ gimp_dynamics_editor_init (GimpDynamicsEditor *editor)
                                             editor->notebook,
                                             editor->check_grid);
 
-  frame = gimp_frame_new (_("Mapping matrix"));
-  gtk_notebook_append_page (GTK_NOTEBOOK (editor->notebook), frame, NULL);
-  gtk_widget_show (frame);
+  gtk_notebook_append_page (GTK_NOTEBOOK (editor->notebook),
+                            editor->check_grid, NULL);
+  gtk_widget_show (editor->check_grid);
 
   gimp_int_combo_box_prepend (GIMP_INT_COMBO_BOX (editor->view_selector),
-                              GIMP_INT_STORE_VALUE,    -1,
-                              GIMP_INT_STORE_LABEL,    _("Mapping matrix"),
-                              GIMP_INT_STORE_USER_DATA, frame,
+                              GIMP_INT_STORE_VALUE,     -1,
+                              GIMP_INT_STORE_LABEL,     _("Mapping matrix"),
+                              GIMP_INT_STORE_USER_DATA, editor->check_grid,
                               -1);
 
   gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (editor->view_selector), -1);
 
-  gtk_container_add (GTK_CONTAINER (frame), editor->check_grid);
-  gtk_widget_show (editor->check_grid);
-
   input_labels[0] = gtk_label_new (_("Pressure"));
   input_labels[1] = gtk_label_new (_("Velocity"));
   input_labels[2] = gtk_label_new (_("Direction"));
@@ -153,20 +148,14 @@ gimp_dynamics_editor_init (GimpDynamicsEditor *editor)
   input_labels[5] = gtk_label_new (_("Random"));
   input_labels[6] = gtk_label_new (_("Fade"));
 
-
-  fixed = gtk_fixed_new ();
-  gtk_table_attach (GTK_TABLE (editor->check_grid), fixed, 0, n_inputs + 2, 0, 1,
-                    GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
-  gtk_widget_show (fixed);
-
   for (i = 0; i < n_inputs; i++)
     {
       gtk_label_set_angle (GTK_LABEL (input_labels[i]), 90);
-      gtk_misc_set_alignment (GTK_MISC (input_labels[i]), 1.0, 1.0);
+      gtk_misc_set_alignment (GTK_MISC (input_labels[i]), 0.5, 1.0);
 
-      gtk_table_attach (GTK_TABLE(editor->check_grid), input_labels[i],
+      gtk_table_attach (GTK_TABLE (editor->check_grid), input_labels[i],
                         i + 1, i + 2, 0, 1,
-                        GTK_SHRINK, GTK_SHRINK, 0, 0);
+                        GTK_SHRINK | GTK_FILL, GTK_SHRINK | GTK_FILL, 0, 0);
       gtk_widget_show (input_labels[i]);
     }
 }
@@ -204,6 +193,9 @@ gimp_dynamics_editor_set_data (GimpDataEditor *editor,
                                GimpData       *data)
 {
   GimpDynamicsEditor *dynamics_editor = GIMP_DYNAMICS_EDITOR (editor);
+  GtkTreeModel       *model;
+  GtkTreeIter         iter;
+  gboolean            iter_valid;
 
   if (editor->data)
     g_signal_handlers_disconnect_by_func (editor->data,
@@ -231,8 +223,20 @@ gimp_dynamics_editor_set_data (GimpDataEditor *editor,
                         editor);
     }
 
-  gtk_widget_set_sensitive (dynamics_editor->check_grid,
-                            editor->data_editable);
+  model = gtk_combo_box_get_model (GTK_COMBO_BOX (dynamics_editor->view_selector));
+
+  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
+       iter_valid;
+       iter_valid = gtk_tree_model_iter_next (model, &iter))
+    {
+      gpointer widget;
+
+      gtk_tree_model_get (model, &iter,
+                          GIMP_INT_STORE_USER_DATA, &widget,
+                          -1);
+
+      gtk_widget_set_sensitive (widget, editor->data_editable);
+    }
 }
 
 
@@ -319,42 +323,33 @@ gimp_dynamics_editor_add_output_row (GObject     *config,
 
   button = dynamics_check_button_new (config, "use-pressure",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config, "use-velocity",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config, "use-direction",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config,  "use-tilt",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config,  "use-wheel",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config, "use-random",
                                       table, column, row);
-
   column++;
 
   button = dynamics_check_button_new (config, "use-fade",
                                       table, column, row);
-
   column++;
 }
 
-
-
 static GtkWidget *
 dynamics_check_button_new (GObject     *config,
                            const gchar *property_name,
@@ -378,22 +373,22 @@ gimp_dynamics_editor_init_output_editors (GimpDynamics *dynamics,
                                           GtkWidget    *notebook,
                                           GtkWidget    *check_grid)
 {
-  GimpIntStore    *list = GIMP_INT_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (view_selector)));
-  GtkTreeModel    *model = GTK_TREE_MODEL(list);
-  GtkWidget       *output_editor;
-  GtkTreeIter      iter;
-  gboolean         iter_valid;
-  gint             i = 1;
+  GtkTreeModel *model = gtk_combo_box_get_model (GTK_COMBO_BOX (view_selector));
+  GimpIntStore *list  = GIMP_INT_STORE (model);
+  GtkTreeIter   iter;
+  gboolean      iter_valid;
+  gint          i;
 
-  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter);
+  for (iter_valid = gtk_tree_model_get_iter_first (model, &iter), i = 1;
        iter_valid;
-       iter_valid = gtk_tree_model_iter_next (model, &iter))
+       iter_valid = gtk_tree_model_iter_next (model, &iter), i++)
     {
       gint                output_type;
       gchar              *label;
       GimpDynamicsOutput *output;
+      GtkWidget          *output_editor;
 
-      gtk_tree_model_get (GTK_TREE_MODEL(model), &iter,
+      gtk_tree_model_get (GTK_TREE_MODEL (model), &iter,
                           GIMP_INT_STORE_VALUE, &output_type,
                           GIMP_INT_STORE_LABEL, &label,
                           -1);
@@ -405,15 +400,14 @@ gimp_dynamics_editor_init_output_editors (GimpDynamics *dynamics,
       gtk_notebook_append_page (GTK_NOTEBOOK (notebook), output_editor, NULL);
       gtk_widget_show (output_editor);
 
-      gtk_list_store_set(GTK_LIST_STORE(list), &iter,
-                         GIMP_INT_STORE_USER_DATA, output_editor,
-                         -1);
+      gtk_list_store_set (GTK_LIST_STORE (list), &iter,
+                          GIMP_INT_STORE_USER_DATA, output_editor,
+                          -1);
 
       gimp_dynamics_editor_add_output_row (G_OBJECT (output),
                                            label,
                                            GTK_TABLE (check_grid),
                                            i);
-      i++;
 
       g_free (label);
   }
@@ -427,16 +421,17 @@ static void
 gimp_dynamics_editor_view_changed (GtkComboBox *combo,
                                    GtkWidget   *notebook)
 {
-  GtkTreeModel *model = GTK_TREE_MODEL(gtk_combo_box_get_model(GTK_COMBO_BOX(combo)));
+  GtkTreeModel *model = gtk_combo_box_get_model (combo);
   GtkTreeIter   iter;
+  gpointer      widget;
   gint          page;
-  GValue        value = { 0, };
 
-  gtk_combo_box_get_active_iter (GTK_COMBO_BOX(combo), &iter);
+  gtk_combo_box_get_active_iter (GTK_COMBO_BOX (combo), &iter);
+
+  gtk_tree_model_get (model, &iter,
+                      GIMP_INT_STORE_USER_DATA, &widget,
+                      -1);
+  page = gtk_notebook_page_num (GTK_NOTEBOOK (notebook), widget);
 
-  gtk_tree_model_get_value (model, &iter, GIMP_INT_STORE_USER_DATA, &value);
-  page = gtk_notebook_page_num (GTK_NOTEBOOK(notebook),
-                                GTK_WIDGET(g_value_get_pointer(&value)));
-  gtk_notebook_set_current_page (GTK_NOTEBOOK(notebook),
-                                 page);
+  gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), page);
 }



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