gtk+ r20997 - in trunk: . docs/reference docs/reference/gtk gtk
- From: matthiasc svn gnome org
- To: svn-commits-list gnome org
- Subject: gtk+ r20997 - in trunk: . docs/reference docs/reference/gtk gtk
- Date: Mon, 4 Aug 2008 23:40:36 +0000 (UTC)
Author: matthiasc
Date: Mon Aug 4 23:40:36 2008
New Revision: 20997
URL: http://svn.gnome.org/viewvc/gtk+?rev=20997&view=rev
Log:
2008-08-04 Matthias Clasen <mclasen redhat com>
Bug 382291 â Automatically dim the combobox when the model is empty
* gtk/gtk.symbols:
* gtkcombobox.[hc]: Add a GtkComboBox::button-sensitivity
property with getter and setter to control the sensitity of
empty combo boxes. Patch by Carlos Garnacho, Sven Herzberg,
Christian Dywan and others.
* README.in: Add a note about automatic combobox sensitivity.
Modified:
trunk/ChangeLog
trunk/README.in
trunk/docs/reference/ChangeLog
trunk/docs/reference/gtk/gtk-sections.txt
trunk/gtk/gtk.symbols
trunk/gtk/gtkcombobox.c
trunk/gtk/gtkcombobox.h
Modified: trunk/README.in
==============================================================================
--- trunk/README.in (original)
+++ trunk/README.in Mon Aug 4 23:40:36 2008
@@ -42,6 +42,12 @@
the GtkFileSystem interface is no longer available, nor the filechooser
will load any GtkFileSystem implementation.
+* GtkComboBox now renders the popdown button insensitive when
+ the model is empty. Applications which want to populate the list
+ only before displaying it can set gtk_combo_box_set_button_sensitivity
+ to GTK_SENSITIVITY_ON, so that the button is always sensitive or
+ GTK_SENSITIVITY_OFF to make it insensitive respectively.
+
Release notes for 2.12
======================
Modified: trunk/docs/reference/gtk/gtk-sections.txt
==============================================================================
--- trunk/docs/reference/gtk/gtk-sections.txt (original)
+++ trunk/docs/reference/gtk/gtk-sections.txt Mon Aug 4 23:40:36 2008
@@ -895,6 +895,8 @@
gtk_combo_box_get_title
gtk_combo_box_set_focus_on_click
gtk_combo_box_get_focus_on_click
+gtk_combo_box_set_button_sensitivity
+gtk_combo_box_get_button_sensitivity
<SUBSECTION Standard>
GTK_TYPE_COMBO_BOX
GTK_COMBO_BOX
Modified: trunk/gtk/gtk.symbols
==============================================================================
--- trunk/gtk/gtk.symbols (original)
+++ trunk/gtk/gtk.symbols Mon Aug 4 23:40:36 2008
@@ -853,6 +853,7 @@
gtk_combo_box_get_popup_accessible
gtk_combo_box_get_row_separator_func
gtk_combo_box_get_row_span_column
+gtk_combo_box_get_button_sensitivity
gtk_combo_box_get_title
gtk_combo_box_get_type G_GNUC_CONST
gtk_combo_box_get_wrap_width
@@ -872,6 +873,7 @@
gtk_combo_box_set_model
gtk_combo_box_set_row_separator_func
gtk_combo_box_set_row_span_column
+gtk_combo_box_set_button_sensitivity
gtk_combo_box_set_title
gtk_combo_box_set_wrap_width
#endif
Modified: trunk/gtk/gtkcombobox.c
==============================================================================
--- trunk/gtk/gtkcombobox.c (original)
+++ trunk/gtk/gtkcombobox.c Mon Aug 4 23:40:36 2008
@@ -120,6 +120,7 @@
guint editing_canceled : 1;
guint auto_scroll : 1;
guint focus_on_click : 1;
+ guint button_sensitivity : 2;
GtkTreeViewRowSeparatorFunc row_separator_func;
gpointer row_separator_data;
@@ -201,7 +202,8 @@
PROP_TEAROFF_TITLE,
PROP_HAS_FRAME,
PROP_FOCUS_ON_CLICK,
- PROP_POPUP_SHOWN
+ PROP_POPUP_SHOWN,
+ PROP_BUTTON_SENSITIVITY
};
static guint combo_box_signals[LAST_SIGNAL] = {0,};
@@ -822,6 +824,24 @@
FALSE,
GTK_PARAM_READABLE));
+
+ /**
+ * GtkComboBox:button-sensitivity:
+ *
+ * Whether the dropdown button is sensitive when
+ * the model is empty.
+ *
+ * Since: 2.14
+ */
+ g_object_class_install_property (object_class,
+ PROP_BUTTON_SENSITIVITY,
+ g_param_spec_enum ("button-sensitivity",
+ P_("Button Sensitivity"),
+ P_("Whether the dropdown button is sensitive when the model is empty"),
+ GTK_TYPE_SENSITIVITY_TYPE,
+ GTK_SENSITIVITY_AUTO,
+ GTK_PARAM_READWRITE));
+
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("appears-as-list",
P_("Appears as list"),
@@ -919,6 +939,7 @@
priv->editing_canceled = FALSE;
priv->auto_scroll = FALSE;
priv->focus_on_click = TRUE;
+ priv->button_sensitivity = GTK_SENSITIVITY_AUTO;
combo_box->priv = priv;
@@ -979,6 +1000,11 @@
gtk_combo_box_popdown (combo_box);
break;
+ case PROP_BUTTON_SENSITIVITY:
+ gtk_combo_box_set_button_sensitivity (combo_box,
+ g_value_get_enum (value));
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -1035,6 +1061,10 @@
g_value_set_boolean (value, combo_box->priv->popup_shown);
break;
+ case PROP_BUTTON_SENSITIVITY:
+ g_value_set_enum (value, combo_box->priv->button_sensitivity);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -3122,6 +3152,32 @@
}
static void
+gtk_combo_box_update_sensitivity (GtkComboBox *combo_box)
+{
+ GtkTreeIter iter;
+ gboolean sensitive = TRUE; /* fool code checkers */
+
+ switch (combo_box->priv->button_sensitivity)
+ {
+ case GTK_SENSITIVITY_ON:
+ sensitive = TRUE;
+ break;
+ case GTK_SENSITIVITY_OFF:
+ sensitive = FALSE;
+ break;
+ case GTK_SENSITIVITY_AUTO:
+ sensitive = combo_box->priv->model &&
+ gtk_tree_model_get_iter_first (combo_box->priv->model, &iter);
+ break;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ gtk_widget_set_sensitive (combo_box->priv->button, sensitive);
+}
+
+static void
gtk_combo_box_model_row_inserted (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
@@ -3133,6 +3189,8 @@
gtk_combo_box_list_popup_resize (combo_box);
else
gtk_combo_box_menu_row_inserted (model, path, iter, user_data);
+
+ gtk_combo_box_update_sensitivity (combo_box);
}
static void
@@ -3154,6 +3212,8 @@
gtk_combo_box_list_popup_resize (combo_box);
else
gtk_combo_box_menu_row_deleted (model, path, user_data);
+
+ gtk_combo_box_update_sensitivity (combo_box);
}
static void
@@ -4945,6 +5005,8 @@
combo_box->priv->model);
out:
+ gtk_combo_box_update_sensitivity (combo_box);
+
g_object_notify (G_OBJECT (combo_box), "model");
}
@@ -5670,6 +5732,55 @@
gtk_widget_queue_draw (GTK_WIDGET (combo_box));
}
+/**
+ * gtk_combo_box_set_button_sensitivity:
+ * @combo_box: a #GtkComboBox
+ * @sensitivity: specify the sensitivity of the dropdown button
+ *
+ * Sets whether the dropdown button of the combo box should be
+ * always sensitive (%GTK_SENSITIVITY_ON), never sensitive (%GTK_SENSITIVITY_OFF)
+ * or only if there is at least one item to display (%GTK_SENSITIVITY_AUTO).
+ *
+ * Since: 2.14
+ **/
+void
+gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
+ GtkSensitivityType sensitivity)
+{
+ g_return_if_fail (GTK_IS_COMBO_BOX (combo_box));
+
+ if (combo_box->priv->button_sensitivity != sensitivity)
+ {
+ combo_box->priv->button_sensitivity = sensitivity;
+ gtk_combo_box_update_sensitivity (combo_box);
+
+ g_object_notify (G_OBJECT (combo_box), "button-sensitivity");
+ }
+}
+
+/**
+ * gtk_combo_box_get_button_sensitivity:
+ * @combo_box: a #GtkComboBox
+ *
+ * Returns whether the combo box sets the dropdown button
+ * sensitive or not when there are no items in the model.
+ *
+ * Return Value: %GTK_SENSITIVITY_ON if the dropdown button
+ * is sensitive when the model is empty, %GTK_SENSITIVITY_OFF
+ * if the button is always insensitive or
+ * %GTK_SENSITIVITY_AUTO if it is only sensitive as long as
+ * the model has one item to be selected.
+ *
+ * Since: 2.14
+ **/
+GtkSensitivityType
+gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box)
+{
+ g_return_val_if_fail (GTK_IS_COMBO_BOX (combo_box), FALSE);
+
+ return combo_box->priv->button_sensitivity;
+}
+
/**
* gtk_combo_box_set_focus_on_click:
Modified: trunk/gtk/gtkcombobox.h
==============================================================================
--- trunk/gtk/gtkcombobox.h (original)
+++ trunk/gtk/gtkcombobox.h Mon Aug 4 23:40:36 2008
@@ -114,6 +114,10 @@
gpointer data,
GDestroyNotify destroy);
+void gtk_combo_box_set_button_sensitivity (GtkComboBox *combo_box,
+ GtkSensitivityType sensitivity);
+GtkSensitivityType gtk_combo_box_get_button_sensitivity (GtkComboBox *combo_box);
+
/* convenience -- text */
GtkWidget *gtk_combo_box_new_text (void);
void gtk_combo_box_append_text (GtkComboBox *combo_box,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]