aboutsummaryrefslogtreecommitdiffstats
path: root/e-util
diff options
context:
space:
mode:
Diffstat (limited to 'e-util')
-rw-r--r--e-util/ChangeLog8
-rw-r--r--e-util/e-dialog-widgets.c58
-rw-r--r--e-util/e-dialog-widgets.h3
3 files changed, 69 insertions, 0 deletions
diff --git a/e-util/ChangeLog b/e-util/ChangeLog
index 0ab1993a3b..1519cf9bdc 100644
--- a/e-util/ChangeLog
+++ b/e-util/ChangeLog
@@ -1,3 +1,11 @@
+2005-12-19 Chenthill Palanisamy <pchenthill@novell.com>
+
+ committing for David Trowbridge <trowbrds cs colorado edu>
+
+ * e-dialog-widgets.[ch] (e_dialog_combo_box_set),
+ (e_dialog_combo_box_get): Added new functions to get/set
+ combox values.
+
2005-12-18 Tor Lillqvist <tml@novell.com>
* e-dialog-utils.c (e_file_dialog_save_folder): Silence unused
diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c
index d245917682..6d17a3d1f1 100644
--- a/e-util/e-dialog-widgets.c
+++ b/e-util/e-dialog-widgets.c
@@ -28,6 +28,7 @@
#include <gtk/gtkmenu.h>
#include <gtk/gtkmenuitem.h>
#include <gtk/gtkoptionmenu.h>
+#include <gtk/gtkcombobox.h>
#include <gtk/gtkradiobutton.h>
#include <gtk/gtksignal.h>
#include <gtk/gtkspinbutton.h>
@@ -631,6 +632,63 @@ e_dialog_option_menu_get (GtkWidget *widget, const int *value_map)
}
/**
+ * e_dialog_combo_box_set:
+ * @widget: A #GtkComboBox.
+ * @value: Enumerated value.
+ * @value_map: Map from enumeration values to array indices.
+ *
+ * Sets the selected item in a #GtkComboBox. Please read the description of
+ * e_dialog_radio_set() to see how @value_map maps enumeration values to item
+ * indices.
+ **/
+void
+e_dialog_combo_box_set (GtkWidget *widget, int value, const int *value_map)
+{
+ int i;
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (GTK_IS_COMBO_BOX (widget));
+ g_return_if_fail (value_map != NULL);
+
+ i = value_to_index (value_map, value);
+
+ if (i != -1)
+ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), i);
+ else
+ g_message ("e_dialog_combo_box_set(): could not find value %d in value map!",
+ value);
+}
+
+/**
+ * e_dialog_combo_box_get:
+ * @widget: A #GtkComboBox.
+ * @value_map: Map from enumeration values to array indices.
+ *
+ * Queries the selected item in a #GtkComboBox. Please read the description
+ * of e_dialog_radio_set() to see how @value_map maps enumeration values to item
+ * indices.
+ *
+ * Return value: Enumeration value which corresponds to the selected item in the
+ * combo box.
+ **/
+int
+e_dialog_combo_box_get (GtkWidget *widget, const int *value_map)
+{
+ int i;
+
+ g_return_val_if_fail (widget != NULL, -1);
+ g_return_val_if_fail (GTK_IS_COMBO_BOX (widget), -1);
+ g_return_val_if_fail (value_map != NULL, -1);
+
+ i = index_to_value (value_map, gtk_combo_box_get_active (GTK_COMBO_BOX (widget)));
+ if (i == -1) {
+ g_message ("e_dialog_combo_box_get(): could not find index %d in value map!", i);
+ return -1;
+ }
+ return i;
+}
+
+/**
* e_dialog_dateedit_set:
* @widget: A #GnomeDateEdit widget.
* @t: Date/time value.
diff --git a/e-util/e-dialog-widgets.h b/e-util/e-dialog-widgets.h
index a006092e04..5d614d7f2a 100644
--- a/e-util/e-dialog-widgets.h
+++ b/e-util/e-dialog-widgets.h
@@ -44,6 +44,9 @@ int e_dialog_spin_get_int (GtkWidget *widget);
void e_dialog_option_menu_set (GtkWidget *widget, int value, const int *value_map);
int e_dialog_option_menu_get (GtkWidget *widget, const int *value_map);
+void e_dialog_combo_box_set (GtkWidget *widget, int value, const int *value_map);
+int e_dialog_combo_box_get (GtkWidget *widget, const int *value_map);
+
void e_dialog_dateedit_set (GtkWidget *widget, time_t t);
time_t e_dialog_dateedit_get (GtkWidget *widget);