diff --git a/ChangeLog b/ChangeLog index af76a74d1..03d203dfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,9 @@ * src/document.c, src/keyfile.c, src/search.c, src/tools.c, src/utils.c, src/vte.c, tagmanager/tm_source_file.c: Replace remaining occurrences of '__func__' with 'G_STRFUNC'. + * plugins/geanyfunctions.h, src/dialogs.c, src/plugindata.h, + src/plugins.c: + Add dialogs_show_input_numeric() to the plugins API. 2009-01-20 Nick Treleaven diff --git a/plugins/geanyfunctions.h b/plugins/geanyfunctions.h index 6a651d2b4..b0244ff59 100644 --- a/plugins/geanyfunctions.h +++ b/plugins/geanyfunctions.h @@ -190,6 +190,8 @@ geany_functions->p_dialogs->show_msgbox #define dialogs_show_save_as \ geany_functions->p_dialogs->show_save_as +#define dialogs_show_input_numeric \ + geany_functions->p_dialogs->show_input_numeric #define msgwin_status_add \ geany_functions->p_msgwin->status_add #define msgwin_compiler_add \ diff --git a/src/dialogs.c b/src/dialogs.c index 6d86e0242..faa30eb1f 100644 --- a/src/dialogs.c +++ b/src/dialogs.c @@ -924,12 +924,30 @@ dialogs_show_input(const gchar *title, const gchar *label_text, const gchar *def } +/** + * Show an input box to enter a numerical value using a GtkSpinButton. + * + * @param title The dialog title. + * @param label_text The shown dialog label. + * @param value The default value for the spin button and the return location of the entered value. + * Must be non-NULL. + * @param min Minimum allowable value (see documentation for @a gtk_spin_button_new_with_range()). + * @param max Maximum allowable value (see documentation for @a gtk_spin_button_new_with_range()). + * @param step Increment added or subtracted by spinning the widget + * (see documentation for @a gtk_spin_button_new_with_range()). + * + * @return @a TRUE if a value was entered and the dialog closed with 'OK'. @a FALSE otherwise. + **/ gboolean dialogs_show_input_numeric(const gchar *title, const gchar *label_text, gdouble *value, gdouble min, gdouble max, gdouble step) { GtkWidget *dialog, *label, *spin, *vbox; gboolean res = FALSE; + g_return_val_if_fail(title != NULL, FALSE); + g_return_val_if_fail(label_text != NULL, FALSE); + g_return_val_if_fail(value != NULL, FALSE); + dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(main_widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, diff --git a/src/plugindata.h b/src/plugindata.h index 5c7b58839..cc447ccfa 100644 --- a/src/plugindata.h +++ b/src/plugindata.h @@ -45,7 +45,7 @@ enum { /** The Application Programming Interface (API) version, incremented * whenever any plugin data types are modified or appended to. */ - GEANY_API_VERSION = 127, + GEANY_API_VERSION = 128, /** The Application Binary Interface (ABI) version, incremented whenever * existing fields in the plugin data types have to be changed or reordered. */ @@ -393,6 +393,9 @@ typedef struct DialogFuncs gboolean (*show_question) (const gchar *text, ...); void (*show_msgbox) (gint type, const gchar *text, ...); gboolean (*show_save_as) (void); + gboolean (*dialogs_show_input_numeric) (const gchar *title, const gchar *label_text, + gdouble *value, gdouble min, gdouble max, gdouble step); + } DialogFuncs; diff --git a/src/plugins.c b/src/plugins.c index 996cb891f..0035a67da 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -231,7 +231,8 @@ static UIUtilsFuncs uiutils_funcs = { static DialogFuncs dialog_funcs = { &dialogs_show_question, &dialogs_show_msgbox, - &dialogs_show_save_as + &dialogs_show_save_as, + &dialogs_show_input_numeric }; /* Macro to prevent confusing macro being generated in geanyfunctions.h */