Add dialogs_show_input_numeric().

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2708 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Enrico Tröger 2008-06-19 14:31:09 +00:00
parent ce216561ae
commit f1de93b6f7
3 changed files with 52 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2008-06-19 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
* src/dialogs.c, src/dialogs.c:
Add dialogs_show_input_numeric().
2008-06-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com> 2008-06-18 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>
* src/build.c, src/utils.c, src/win32.c, src/ui_utils.h, src/build.h, * src/build.c, src/utils.c, src/win32.c, src/ui_utils.h, src/build.h,

View File

@ -815,6 +815,13 @@ on_input_entry_activate(GtkEntry *entry, GtkDialog *dialog)
} }
static void
on_input_numeric_activate(GtkEntry *entry, GtkDialog *dialog)
{
gtk_dialog_response(dialog, GTK_RESPONSE_ACCEPT);
}
static void static void
on_input_dialog_response(GtkDialog *dialog, on_input_dialog_response(GtkDialog *dialog,
gint response, gint response,
@ -918,6 +925,42 @@ dialogs_show_input(const gchar *title, const gchar *label_text, const gchar *def
} }
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;
dialog = gtk_dialog_new_with_buttons(title, GTK_WINDOW(main_widgets.window),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
GTK_STOCK_OK, GTK_RESPONSE_ACCEPT, NULL);
gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
vbox = ui_dialog_vbox_new(GTK_DIALOG(dialog));
gtk_widget_set_name(dialog, "GeanyDialog");
label = gtk_label_new(label_text);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
spin = gtk_spin_button_new_with_range(min, max, step);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(spin), *value);
g_signal_connect(spin, "activate", G_CALLBACK(on_input_numeric_activate), dialog);
gtk_container_add(GTK_CONTAINER(vbox), label);
gtk_container_add(GTK_CONTAINER(vbox), spin);
gtk_widget_show_all(vbox);
if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
{
*value = gtk_spin_button_get_value(GTK_SPIN_BUTTON(spin));
res = TRUE;
}
gtk_widget_destroy(dialog);
return res;
}
void dialogs_show_goto_line() void dialogs_show_goto_line()
{ {
GtkWidget *dialog, *label, *entry, *vbox; GtkWidget *dialog, *label, *entry, *vbox;

View File

@ -48,6 +48,9 @@ void dialogs_show_color(gchar *colour);
GtkWidget *dialogs_show_input(const gchar *title, const gchar *label_text, GtkWidget *dialogs_show_input(const gchar *title, const gchar *label_text,
const gchar *default_text, gboolean persistent, InputCallback input_cb); const gchar *default_text, gboolean persistent, InputCallback input_cb);
gboolean dialogs_show_input_numeric(const gchar *title, const gchar *label_text,
gdouble *value, gdouble min, gdouble max, gdouble step);
void dialogs_show_goto_line(void); void dialogs_show_goto_line(void);
void dialogs_show_file_properties(GeanyDocument *doc); void dialogs_show_file_properties(GeanyDocument *doc);