aboutsummaryrefslogtreecommitdiffstats
path: root/e-util/e-dialog-widgets.c
diff options
context:
space:
mode:
Diffstat (limited to 'e-util/e-dialog-widgets.c')
-rw-r--r--e-util/e-dialog-widgets.c218
1 files changed, 109 insertions, 109 deletions
diff --git a/e-util/e-dialog-widgets.c b/e-util/e-dialog-widgets.c
index 36ade95803..20f7db5ce5 100644
--- a/e-util/e-dialog-widgets.c
+++ b/e-util/e-dialog-widgets.c
@@ -58,7 +58,7 @@ dialog_destroy_cb (DialogHooks *hooks, GObject *dialog)
{
g_slist_free (hooks->whooks);
hooks->whooks = NULL;
-
+
g_free (hooks);
g_object_set_data (dialog, "dialog-hooks", NULL);
}
@@ -70,14 +70,14 @@ static DialogHooks *
get_dialog_hooks (GtkWidget *dialog)
{
DialogHooks *hooks;
-
+
hooks = g_object_get_data ((GObject *) dialog, "dialog-hooks");
if (!hooks) {
hooks = g_new0 (DialogHooks, 1);
g_object_set_data ((GObject *) dialog, "dialog-hooks", hooks);
g_object_weak_ref ((GObject *) dialog, (GWeakNotify) dialog_destroy_cb, hooks);
}
-
+
return hooks;
}
@@ -88,11 +88,11 @@ static int
value_to_index (const int *value_map, int value)
{
int i;
-
+
for (i = 0; value_map[i] != -1; i++)
if (value_map[i] == value)
return i;
-
+
return -1;
}
@@ -103,15 +103,15 @@ static int
index_to_value (const int *value_map, int index)
{
int i;
-
+
/* We do this the hard way, i.e. not as a simple array reference, to
* check for correctness.
*/
-
+
for (i = 0; value_map[i] != -1; i++)
if (i == index)
return value_map[i];
-
+
return -1;
}
@@ -121,12 +121,12 @@ hook_radio (GtkWidget *dialog, GtkRadioButton *radio, gpointer value_var, gpoint
{
const int *value_map;
int *value;
-
+
/* Set the value */
-
+
value = (int *) value_var;
value_map = (const int *) info;
-
+
e_dialog_radio_set (GTK_WIDGET (radio), *value, value_map);
}
@@ -136,10 +136,10 @@ get_radio_value (GtkRadioButton *radio, gpointer value_var, gpointer info)
{
int *value;
const int *value_map;
-
+
value = (int *) value_var;
value_map = (const int *) info;
-
+
*value = e_dialog_radio_get (GTK_WIDGET (radio), value_map);
}
@@ -149,12 +149,12 @@ hook_option_menu (GtkWidget *dialog, GtkOptionMenu *omenu, gpointer value_var, g
{
const int *value_map;
int *value;
-
+
/* Set the value */
-
+
value = (int *) value_var;
value_map = (const int *) info;
-
+
e_dialog_option_menu_set (GTK_WIDGET (omenu), *value, value_map);
}
@@ -164,10 +164,10 @@ get_option_menu_value (GtkOptionMenu *omenu, gpointer value_var, gpointer info)
{
const int *value_map;
int *value;
-
+
value = (int *) value_var;
value_map = (const int *) info;
-
+
*value = e_dialog_option_menu_get (GTK_WIDGET (omenu), value_map);
}
@@ -176,9 +176,9 @@ static void
hook_toggle (GtkWidget *dialog, GtkToggleButton *toggle, gpointer value_var, gpointer info)
{
gboolean *value;
-
+
/* Set the value */
-
+
value = (gboolean *) value_var;
e_dialog_toggle_set (GTK_WIDGET (toggle), *value);
}
@@ -188,7 +188,7 @@ static void
get_toggle_value (GtkToggleButton *toggle, gpointer value_var, gpointer info)
{
gboolean *value;
-
+
value = (gboolean *) value_var;
*value = e_dialog_toggle_get (GTK_WIDGET (toggle));
}
@@ -199,14 +199,14 @@ hook_spin_button (GtkWidget *dialog, GtkSpinButton *spin, gpointer value_var, gp
{
double *value;
GtkAdjustment *adj;
-
+
/* Set the value */
-
+
value = (double *) value_var;
e_dialog_spin_set (GTK_WIDGET (spin), *value);
-
+
/* Hook to changed */
-
+
adj = gtk_spin_button_get_adjustment (spin);
}
@@ -215,7 +215,7 @@ static void
get_spin_button_value (GtkSpinButton *spin, gpointer value_var, gpointer info)
{
double *value;
-
+
value = (double *) value_var;
*value = e_dialog_spin_get_double (GTK_WIDGET (spin));
}
@@ -225,11 +225,11 @@ static void
hook_editable (GtkWidget *dialog, GtkEditable *editable, gpointer value_var, gpointer info)
{
char **value;
-
+
/* Set the value */
-
+
value = (char **) value_var;
-
+
e_dialog_editable_set (GTK_WIDGET (editable), *value);
}
@@ -238,11 +238,11 @@ static void
get_editable_value (GtkEditable *editable, gpointer value_var, gpointer data)
{
char **value;
-
+
value = (char **) value_var;
if (*value)
g_free (*value);
-
+
*value = e_dialog_editable_get (GTK_WIDGET (editable));
}
@@ -250,19 +250,19 @@ get_editable_value (GtkEditable *editable, gpointer value_var, gpointer data)
* e_dialog_editable_set:
* @widget: A #GtkEditable widget.
* @value: String value.
- *
+ *
* Sets the string value inside a #GtkEditable-derived widget.
**/
void
e_dialog_editable_set (GtkWidget *widget, const char *value)
{
int pos = 0;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_EDITABLE (widget));
-
+
gtk_editable_delete_text (GTK_EDITABLE (widget), 0, -1);
-
+
if (value)
gtk_editable_insert_text (GTK_EDITABLE (widget), value, strlen (value), &pos);
}
@@ -270,9 +270,9 @@ e_dialog_editable_set (GtkWidget *widget, const char *value)
/**
* e_dialog_editable_get:
* @widget: A #GtkEditable widget.
- *
+ *
* Queries the string value inside a #GtkEditable-derived widget.
- *
+ *
* Return value: String value. You should free it when you are done with it.
* This function can return NULL if the string could not be converted from
* GTK+'s encoding into UTF8.
@@ -282,7 +282,7 @@ e_dialog_editable_get (GtkWidget *widget)
{
g_return_val_if_fail (widget != NULL, NULL);
g_return_val_if_fail (GTK_IS_EDITABLE (widget), NULL);
-
+
return gtk_editable_get_chars (GTK_EDITABLE (widget), 0, -1);
}
@@ -291,7 +291,7 @@ e_dialog_editable_get (GtkWidget *widget)
* @widget: A #GtkRadioButton in a radio button group.
* @value: Enumerated value.
* @value_map: Map from enumeration values to array indices.
- *
+ *
* Sets the selected item in a radio group. The specified @widget can be any of
* the #GtkRadioButtons in the group. Each radio button should correspond to an
* enumeration value; the specified @value will be mapped to an integer from
@@ -305,24 +305,24 @@ e_dialog_radio_set (GtkWidget *widget, int value, const int *value_map)
{
GSList *group, *l;
int i;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_RADIO_BUTTON (widget));
g_return_if_fail (value_map != NULL);
-
+
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
-
+
i = value_to_index (value_map, value);
if (i != -1) {
/* Groups are built by prepending items, so the list ends up in reverse
* order; we need to flip the index around.
*/
i = g_slist_length (group) - i - 1;
-
+
l = g_slist_nth (group, i);
if (!l)
g_message ("e_dialog_radio_set(): could not find index %d in radio group!", i);
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (l->data), TRUE);
} else
g_message ("e_dialog_radio_set(): could not find value %d in value map!", value);
@@ -332,11 +332,11 @@ e_dialog_radio_set (GtkWidget *widget, int value, const int *value_map)
* e_dialog_radio_get:
* @widget: A #GtkRadioButton in a radio button group.
* @value_map: Map from enumeration values to array indices.
- *
+ *
* Queries the selected item in a #GtkRadioButton group. Please read the
* description of e_dialog_radio_set() to see how @value_map maps enumeration
* values to button indices.
- *
+ *
* Return value: Enumeration value which corresponds to the selected item in the
* radio group.
**/
@@ -345,33 +345,33 @@ e_dialog_radio_get (GtkWidget *widget, const int *value_map)
{
GSList *group, *l;
int i, v;
-
+
g_return_val_if_fail (widget != NULL, -1);
g_return_val_if_fail (GTK_IS_RADIO_BUTTON (widget), -1);
g_return_val_if_fail (value_map != NULL, -1);
-
+
group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
-
+
for (i = 0, l = group; l; l = l->next, i++) {
widget = GTK_WIDGET (l->data);
-
+
if (GTK_TOGGLE_BUTTON (widget)->active)
break;
}
-
+
g_return_val_if_fail (l != NULL, -1);
-
+
/* Groups are built by prepending items, so the list ends up in reverse
* order; we need to flip the index around.
*/
i = g_slist_length (group) - i - 1;
-
+
v = index_to_value (value_map, i);
if (v == -1) {
g_message ("e_dialog_radio_get(): could not find index %d in value map!", i);
return -1;
}
-
+
return v;
}
@@ -379,7 +379,7 @@ e_dialog_radio_get (GtkWidget *widget, const int *value_map)
* e_dialog_toggle_set:
* @widget: A #GtkToggleButton.
* @value: Toggle value.
- *
+ *
* Sets the value of a #GtkToggleButton-derived widget. This should not be used
* for radio buttons; it is more convenient to use use e_dialog_radio_set()
* instead.
@@ -389,18 +389,18 @@ e_dialog_toggle_set (GtkWidget *widget, gboolean value)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_TOGGLE_BUTTON (widget));
-
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
}
/**
* e_dialog_toggle_get:
* @widget: A #GtkToggleButton.
- *
+ *
* Queries the value of a #GtkToggleButton-derived widget. This should not be
* used for radio buttons; it is more convenient to use e_dialog_radio_get()
* instead.
- *
+ *
* Return value: Toggle value.
**/
gboolean
@@ -408,7 +408,7 @@ e_dialog_toggle_get (GtkWidget *widget)
{
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (widget), FALSE);
-
+
return GTK_TOGGLE_BUTTON (widget)->active;
}
@@ -416,19 +416,19 @@ e_dialog_toggle_get (GtkWidget *widget)
* e_dialog_spin_set:
* @widget: A #GtkSpinButton.
* @value: Numeric value.
- *
+ *
* Sets the value of a #GtkSpinButton widget.
**/
void
e_dialog_spin_set (GtkWidget *widget, double value)
{
GtkAdjustment *adj;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_SPIN_BUTTON (widget));
-
+
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
-
+
adj->value = value;
g_signal_emit_by_name (adj, "value_changed", 0);
}
@@ -436,19 +436,19 @@ e_dialog_spin_set (GtkWidget *widget, double value)
/**
* e_dialog_spin_get_double:
* @widget: A #GtkSpinButton.
- *
+ *
* Queries the floating-point value of a #GtkSpinButton widget.
- *
+ *
* Return value: Numeric value.
**/
double
e_dialog_spin_get_double (GtkWidget *widget)
{
GtkAdjustment *adj;
-
+
g_return_val_if_fail (widget != NULL, 0.0);
g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), 0.0);
-
+
adj = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget));
return adj->value;
}
@@ -456,19 +456,19 @@ e_dialog_spin_get_double (GtkWidget *widget)
/**
* e_dialog_spin_get_int:
* @widget: A #GtkSpinButton.
- *
+ *
* Queries the integer value of a #GtkSpinButton widget.
- *
+ *
* Return value: Numeric value.
**/
int
e_dialog_spin_get_int (GtkWidget *widget)
{
double value;
-
+
g_return_val_if_fail (widget != NULL, -1);
g_return_val_if_fail (GTK_IS_SPIN_BUTTON (widget), -1);
-
+
value = e_dialog_spin_get_double (widget);
return (int) floor (value);
}
@@ -478,7 +478,7 @@ e_dialog_spin_get_int (GtkWidget *widget)
* @widget: A #GtkOptionMenu.
* @value: Enumerated value.
* @value_map: Map from enumeration values to array indices.
- *
+ *
* Sets the selected item in a #GtkOptionMenu. Please read the description of
* e_dialog_radio_set() to see how @value_map maps enumeration values to item
* indices.
@@ -487,13 +487,13 @@ void
e_dialog_option_menu_set (GtkWidget *widget, int value, const int *value_map)
{
int i;
-
+
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_OPTION_MENU (widget));
g_return_if_fail (value_map != NULL);
-
+
i = value_to_index (value_map, value);
-
+
if (i != -1)
gtk_option_menu_set_history (GTK_OPTION_MENU (widget), i);
else
@@ -505,11 +505,11 @@ e_dialog_option_menu_set (GtkWidget *widget, int value, const int *value_map)
* e_dialog_option_menu_get:
* @widget: A #GtkOptionMenu.
* @value_map: Map from enumeration values to array indices.
- *
+ *
* Queries the selected item in a #GtkOptionMenu. 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
* option menu.
**/
@@ -522,31 +522,31 @@ e_dialog_option_menu_get (GtkWidget *widget, const int *value_map)
GList *l;
int i;
int v;
-
+
g_return_val_if_fail (widget != NULL, -1);
g_return_val_if_fail (GTK_IS_OPTION_MENU (widget), -1);
g_return_val_if_fail (value_map != NULL, -1);
-
+
menu = GTK_MENU (gtk_option_menu_get_menu (GTK_OPTION_MENU (widget)));
-
+
active = gtk_menu_get_active (menu);
g_return_val_if_fail (active != NULL, -1);
-
+
children = GTK_MENU_SHELL (menu)->children;
-
+
for (i = 0, l = children; l; l = l->next, i++) {
if (GTK_WIDGET (l->data) == active)
break;
}
-
+
g_return_val_if_fail (l != NULL, -1);
-
+
v = index_to_value (value_map, i);
if (v == -1) {
g_message ("e_dialog_option_menu_get(): could not find index %d in value map!", i);
return -1;
}
-
+
return v;
}
@@ -611,7 +611,7 @@ e_dialog_combo_box_get (GtkWidget *widget, const int *value_map)
* e_dialog_dateedit_set:
* @widget: A #GnomeDateEdit widget.
* @t: Date/time value.
- *
+ *
* Sets the value of a #GnomeDateEdit widget.
**/
void
@@ -619,16 +619,16 @@ e_dialog_dateedit_set (GtkWidget *widget, time_t t)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GNOME_IS_DATE_EDIT (widget));
-
+
gnome_date_edit_set_time (GNOME_DATE_EDIT (widget), t);
}
/**
* e_dialog_dateedit_get:
* @widget: A #GnomeDateEdit widget.
- *
+ *
* Queries the value of a #GnomeDateEdit widget.
- *
+ *
* Return value: Date/time value.
**/
time_t
@@ -636,7 +636,7 @@ e_dialog_dateedit_get (GtkWidget *widget)
{
g_return_val_if_fail (widget != NULL, -1);
g_return_val_if_fail (GNOME_IS_DATE_EDIT (widget), -1);
-
+
return gnome_date_edit_get_time (GNOME_DATE_EDIT (widget));
}
@@ -647,7 +647,7 @@ e_dialog_dateedit_get (GtkWidget *widget)
* @value_var: Pointer to the variable that the @widget will control.
* @info: NULL for most widgets, or an integer value map array (see
* e_dialog_radio_set() for details).
- *
+ *
* Hooks a widget from a dialog box to the variable it will modify. Supported
* widgets are: #GtkEditable (char *), #GtkRadioButton (int/value_map pair; see
* e_dialog_radio_set() for more information), #GtkTogglebutton (gboolean),
@@ -671,18 +671,18 @@ e_dialog_widget_hook_value (GtkWidget *dialog, GtkWidget *widget,
{
DialogHooks *hooks;
WidgetHook *wh;
-
+
g_return_val_if_fail (dialog != NULL, FALSE);
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (value_var != NULL, FALSE);
-
+
hooks = get_dialog_hooks (dialog);
-
+
/* First check if it is a "group" widget, like a radio button or an
* option menu. Then we check for normal ungrouped widgets.
*/
-
+
if (GTK_IS_RADIO_BUTTON (widget))
hook_radio (dialog, GTK_RADIO_BUTTON (widget), value_var, info);
else if (GTK_IS_OPTION_MENU (widget))
@@ -695,14 +695,14 @@ e_dialog_widget_hook_value (GtkWidget *dialog, GtkWidget *widget,
hook_editable (dialog, GTK_EDITABLE (widget), value_var, info);
else
return FALSE;
-
+
wh = g_new (WidgetHook, 1);
wh->widget = widget;
wh->value_var = value_var;
wh->info = info;
-
+
hooks->whooks = g_slist_prepend (hooks->whooks, wh);
-
+
return TRUE;
}
@@ -710,7 +710,7 @@ e_dialog_widget_hook_value (GtkWidget *dialog, GtkWidget *widget,
* e_dialog_get_values:
* @dialog: A dialog box whose widgets have been hooked to the appropriate
* variables with e_dialog_widget_hook_value().
- *
+ *
* Makes every widget in a @dialog that was hooked with
* e_dialog_widget_hook_value() apply its value to its corresponding variable.
* The typical usage is to call this function in the handler for the "OK" button
@@ -721,16 +721,16 @@ e_dialog_get_values (GtkWidget *dialog)
{
DialogHooks *hooks;
GSList *l;
-
+
g_return_if_fail (dialog != NULL);
-
+
hooks = get_dialog_hooks (dialog);
-
+
for (l = hooks->whooks; l; l = l->next) {
WidgetHook *wh;
-
+
wh = l->data;
-
+
if (GTK_IS_RADIO_BUTTON (wh->widget))
get_radio_value (GTK_RADIO_BUTTON (wh->widget), wh->value_var, wh->info);
else if (GTK_IS_OPTION_MENU (wh->widget))
@@ -754,10 +754,10 @@ e_dialog_get_values (GtkWidget *dialog)
* @value_var: Pointer to the variable that the widget will control.
* @info: NULL for most widgets, or an integer value map array (see
* e_dialog_radio_set() for details).
- *
+ *
* Similar to e_dialog_widget_hook_value(), but uses the widget from a #GladeXML
* data structure.
- *
+ *
* Return value: TRUE if the type of the specified widget is supported, FALSE
* otherwise.
**/
@@ -766,19 +766,19 @@ e_dialog_xml_widget_hook_value (GladeXML *xml, GtkWidget *dialog, const char *wi
gpointer value_var, gpointer info)
{
GtkWidget *widget;
-
+
g_return_val_if_fail (xml != NULL, FALSE);
g_return_val_if_fail (GLADE_IS_XML (xml), FALSE);
g_return_val_if_fail (dialog != NULL, FALSE);
g_return_val_if_fail (widget_name != NULL, FALSE);
g_return_val_if_fail (value_var != NULL, FALSE);
-
+
widget = glade_xml_get_widget (xml, widget_name);
if (!widget) {
g_message ("e_dialog_xml_widget_hook_value(): could not find widget `%s' in "
"Glade data!", widget_name);
return FALSE;
}
-
+
return e_dialog_widget_hook_value (dialog, widget, value_var, info);
}