[gcalctool] Don't allow headings to be selected in convert from combobox



commit c83afc47991a79179ddf1e536660b483376b5b29
Author: Robert Ancell <robert ancell canonical com>
Date:   Wed Nov 24 09:22:53 2010 +1100

    Don't allow headings to be selected in convert from combobox

 src/math-buttons.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/math-buttons.c b/src/math-buttons.c
index 85cd735..209d900 100644
--- a/src/math-buttons.c
+++ b/src/math-buttons.c
@@ -838,6 +838,17 @@ target_currency_changed_cb(MathEquation *equation, GParamSpec *spec, MathButtons
 }
 
 
+static void
+convert_from_cell_data_func(GtkCellLayout   *cell_layout,
+                            GtkCellRenderer *cell,
+                            GtkTreeModel    *tree_model,
+                            GtkTreeIter     *iter,
+                            gpointer         data)
+{
+    g_object_set(cell, "sensitive", !gtk_tree_model_iter_has_child(tree_model, iter), NULL);
+}
+
+
 static GtkWidget *
 load_mode(MathButtons *buttons, ButtonMode mode)
 {
@@ -998,6 +1009,10 @@ load_mode(MathButtons *buttons, ButtonMode mode)
         renderer = gtk_cell_renderer_text_new();
         gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(buttons->priv->convert_from_combo), renderer, TRUE);
         gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(buttons->priv->convert_from_combo), renderer, "text", 0);
+        gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(buttons->priv->convert_from_combo),
+                                           renderer,
+                                           convert_from_cell_data_func,
+                                           NULL, NULL);
 
         buttons->priv->convert_to_combo = GET_WIDGET(builder, "convert_to_combo");
         renderer = gtk_cell_renderer_text_new();



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