return ret;
}
+/**
+ * ws_combo_box_text_and_pointer convenience functions
+ * (Code adapted from GtkComboBox.c)
+ */
+
/**
* ws_combo_box_new_text_and_pointer:
*
GtkCellRenderer *cell;
GtkListStore *store;
- store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
+ /* The list store for the GtkComboBox has 3 columns:
+ 0: text string for display in GtkComboBox list;
+ 1: pointer (data) associated with the entry;
+ 2: True/False depending upon whether this entry is selectable ("sensitive" attribute).
+ */
+ store = gtk_list_store_new(3, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN);
combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL (store));
g_object_unref(store);
cell = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_box), cell, TRUE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_box), cell,
- "text", 0,
+ "text", 0, "sensitive", 2,
NULL);
return combo_box;
}
/**
- * ws_combo_box_append_text_and_pointer:
+ * ws_combo_box_append_text_and_pointer_with_sensitivity:
* @param combo_box A #GtkComboBox constructed using ws_combo_box_new_text_and_pointer()
* @param text A string to be displayed as an entry in the dropdown list of the combo_box
* @param ptr A pointer to be associated with this entry of the combo_box
+ * @param sensitive TRUE/FALSE to set sensitivity of the entry
*
- * Appends text and ptr to the list of strings and pointers stored in combo_box. Note that
+ * Appends text and ptr to the list of strings and pointers stored in combo_box.
+ * The sensitivity of the row will be set as requested. Note that
* you can only use this function with combo boxes constructed with
* ws_combo_box_new_text_and_pointer().
*/
void
-ws_combo_box_append_text_and_pointer (GtkComboBox *combo_box,
- const gchar *text,
- const gpointer ptr)
+ws_combo_box_append_text_and_pointer_with_sensitivity (GtkComboBox *combo_box,
+ const gchar *text,
+ const gpointer ptr,
+ const gboolean sensitive)
{
GtkTreeIter iter;
GtkListStore *store;
store = GTK_LIST_STORE(gtk_combo_box_get_model(combo_box));
gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, 0, text, 1, ptr, -1);
+ gtk_list_store_set(store, &iter, 0, text, 1, ptr, 2, sensitive, -1);
}
+/**
+ * ws_combo_box_append_text_and_pointer:
+ * @param combo_box A #GtkComboBox constructed using ws_combo_box_new_text_and_pointer()
+ * @param text A string to be displayed as an entry in the dropdown list of the combo_box
+ * @param ptr A pointer to be associated with this entry of the combo_box
+ *
+ * Appends text and ptr to the list of strings and pointers stored in combo_box. Note that
+ * you can only use this function with combo boxes constructed with
+ * ws_combo_box_new_text_and_pointer().
+ */
+void ws_combo_box_append_text_and_pointer (GtkComboBox *combo_box,
+ const gchar *text,
+ const gpointer ptr)
+{
+ ws_combo_box_append_text_and_pointer_with_sensitivity(combo_box, text, ptr, TRUE);
+}
+
+
/**
* ws_combo_box_get_active_pointer:
* @param combo_box A #GtkComboBox constructed using ws_combo_box_new_text_and_pointer()
{
gtk_combo_box_set_active(combo_box, idx);
}
-
-
*/
void ws_combo_box_clear_text_and_pointer(GtkComboBox *combo_box);
+/**
+ * ws_combo_box_append_text_and_pointer_with_sensitivity:
+ * @param combo_box A #GtkComboBox constructed using ws_combo_box_new_text_and_pointer()
+ * @param text A string to be displayed as an entry in the dropdown list of the combo_box
+ * @param ptr A pointer to be associated with this entry of the combo_box
+ * @param sensitive TRUE/FALSE to set sensitivity of the entry
+ *
+ * Appends text and ptr to the list of strings and pointers stored in combo_box.
+ * The sensitivity of the row will be set as requested. Note that
+ * you can only use this function with combo boxes constructed with
+ * ws_combo_box_new_text_and_pointer().
+ */
+void
+ws_combo_box_append_text_and_pointer_with_sensitivity (GtkComboBox *combo_box,
+ const gchar *text,
+ const gpointer ptr,
+ const gboolean sensitive);
+
/**
* ws_combo_box_append_text_and_pointer:
* @param combo_box A #GtkComboBox constructed using ws_combo_box_new_text_and_pointer()