Kaydet (Commit) 819bf8e9 authored tarafından Enrico Tröger's avatar Enrico Tröger

Add special variant dialogs_show_input_goto_line() to use a normal GtkEntry…

Add special variant dialogs_show_input_goto_line() to use a normal GtkEntry together with dialogs_show_input_goto_line() for text input.

git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@4893 ea778897-0a13-0410-b9d1-a72fbfd435f5
üst 658b552f
...@@ -5,6 +5,9 @@ ...@@ -5,6 +5,9 @@
* src/ui_utils.h, src/ui_utils.c: * src/ui_utils.h, src/ui_utils.c:
Add public, generic callback ui_editable_insert_text_callback() Add public, generic callback ui_editable_insert_text_callback()
to restrict GtkEntry text inputs to +/- and numeric values only. to restrict GtkEntry text inputs to +/- and numeric values only.
* src/dialogsh, src/dialogs.c:
Add special variant dialogs_show_input_goto_line() to use a normal
GtkEntry together with dialogs_show_input_goto_line() for text input.
2010-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de> 2010-05-08 Enrico Tröger <enrico(dot)troeger(at)uvena(dot)de>
......
...@@ -838,7 +838,8 @@ on_input_dialog_response(GtkDialog *dialog, ...@@ -838,7 +838,8 @@ on_input_dialog_response(GtkDialog *dialog,
static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox, static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox,
const gchar *label_text, const gchar *default_text, gboolean persistent) const gchar *label_text, const gchar *default_text, gboolean persistent,
GCallback insert_text_cb)
{ {
GtkWidget *entry; GtkWidget *entry;
...@@ -873,6 +874,8 @@ static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox, ...@@ -873,6 +874,8 @@ static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox,
gtk_entry_set_max_length(GTK_ENTRY(entry), 255); gtk_entry_set_max_length(GTK_ENTRY(entry), 255);
gtk_entry_set_width_chars(GTK_ENTRY(entry), 30); gtk_entry_set_width_chars(GTK_ENTRY(entry), 30);
if (insert_text_cb != NULL)
g_signal_connect(entry, "insert-text", insert_text_cb, NULL);
g_signal_connect(entry, "activate", G_CALLBACK(on_input_entry_activate), dialog); g_signal_connect(entry, "activate", G_CALLBACK(on_input_entry_activate), dialog);
g_signal_connect(dialog, "show", G_CALLBACK(on_input_dialog_show), entry); g_signal_connect(dialog, "show", G_CALLBACK(on_input_dialog_show), entry);
g_signal_connect(dialog, "response", G_CALLBACK(on_input_dialog_response), entry); g_signal_connect(dialog, "response", G_CALLBACK(on_input_dialog_response), entry);
...@@ -886,7 +889,7 @@ static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox, ...@@ -886,7 +889,7 @@ static void add_input_widgets(GtkWidget *dialog, GtkWidget *vbox,
* Returns: the dialog widget. */ * Returns: the dialog widget. */
static GtkWidget * static GtkWidget *
dialogs_show_input_full(const gchar *title, const gchar *label_text, const gchar *default_text, dialogs_show_input_full(const gchar *title, const gchar *label_text, const gchar *default_text,
gboolean persistent, GeanyInputCallback input_cb) gboolean persistent, GeanyInputCallback input_cb, GCallback insert_text_cb)
{ {
GtkWidget *dialog, *vbox; GtkWidget *dialog, *vbox;
...@@ -900,7 +903,7 @@ dialogs_show_input_full(const gchar *title, const gchar *label_text, const gchar ...@@ -900,7 +903,7 @@ dialogs_show_input_full(const gchar *title, const gchar *label_text, const gchar
g_object_set_data(G_OBJECT(dialog), "has_combo", GINT_TO_POINTER(persistent)); g_object_set_data(G_OBJECT(dialog), "has_combo", GINT_TO_POINTER(persistent));
g_object_set_data(G_OBJECT(dialog), "input_cb", (gpointer) input_cb); g_object_set_data(G_OBJECT(dialog), "input_cb", (gpointer) input_cb);
add_input_widgets(dialog, vbox, label_text, default_text, persistent); add_input_widgets(dialog, vbox, label_text, default_text, persistent, insert_text_cb);
if (persistent) if (persistent)
{ {
...@@ -922,7 +925,7 @@ GtkWidget * ...@@ -922,7 +925,7 @@ GtkWidget *
dialogs_show_input_persistent(const gchar *title, const gchar *label_text, const gchar *default_text, dialogs_show_input_persistent(const gchar *title, const gchar *label_text, const gchar *default_text,
GeanyInputCallback input_cb) GeanyInputCallback input_cb)
{ {
return dialogs_show_input_full(title, label_text, default_text, TRUE, input_cb); return dialogs_show_input_full(title, label_text, default_text, TRUE, input_cb, NULL);
} }
...@@ -940,7 +943,20 @@ gchar *dialogs_show_input(const gchar *title, const gchar *label_text, ...@@ -940,7 +943,20 @@ gchar *dialogs_show_input(const gchar *title, const gchar *label_text,
const gchar *default_text) const gchar *default_text)
{ {
dialog_input = NULL; dialog_input = NULL;
dialogs_show_input_full(title, label_text, default_text, FALSE, on_dialog_input); dialogs_show_input_full(title, label_text, default_text, FALSE, on_dialog_input, NULL);
return NVL(dialog_input, g_strdup(default_text));
}
/* Returns: newly allocated string - a copy of either the entry text or default_text.
* Specialised variant for Goto Line dialog. */
gchar *dialogs_show_input_goto_line(const gchar *title, const gchar *label_text,
const gchar *default_text)
{
dialog_input = NULL;
dialogs_show_input_full(
title, label_text, default_text, FALSE, on_dialog_input,
G_CALLBACK(ui_editable_insert_text_callback));
return NVL(dialog_input, g_strdup(default_text)); return NVL(dialog_input, g_strdup(default_text));
} }
......
...@@ -48,6 +48,9 @@ void dialogs_show_color(gchar *colour); ...@@ -48,6 +48,9 @@ void dialogs_show_color(gchar *colour);
gchar *dialogs_show_input(const gchar *title, const gchar *label_text, gchar *dialogs_show_input(const gchar *title, const gchar *label_text,
const gchar *default_text); const gchar *default_text);
gchar *dialogs_show_input_goto_line(const gchar *title, const gchar *label_text,
const gchar *default_text);
GtkWidget *dialogs_show_input_persistent(const gchar *title, const gchar *label_text, GtkWidget *dialogs_show_input_persistent(const gchar *title, const gchar *label_text,
const gchar *default_text, GeanyInputCallback input_cb); const gchar *default_text, GeanyInputCallback input_cb);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment