summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMike Newman <MikeGTN@src.gnome.org>2003-01-19 12:13:08 +0000
committerMike Newman <MikeGTN@src.gnome.org>2003-01-19 12:13:08 +0000
commit1e1dfef56ec71f732941398529cb1d8c79190c41 (patch)
treeb4362471602483b2a003f6ade6ac6332ca3df2ff /src
parentAdded da to ALL_LINGUAS. (diff)
downloadzenity-1e1dfef56ec71f732941398529cb1d8c79190c41.tar.gz
zenity-1e1dfef56ec71f732941398529cb1d8c79190c41.tar.bz2
zenity-1e1dfef56ec71f732941398529cb1d8c79190c41.zip
Add --editable option to --text-info, and return edited textbuffer contents on dialog close.
Diffstat (limited to 'src')
-rw-r--r--src/main.c24
-rw-r--r--src/text.c14
-rw-r--r--src/zenity.h2
3 files changed, 39 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index 0e762473..a8e1e0e4 100644
--- a/src/main.c
+++ b/src/main.c
@@ -65,6 +65,7 @@ enum {
OPTION_PROGRESS,
OPTION_QUESTION,
OPTION_TEXTINFO,
+ OPTION_TEXTEDIT,
OPTION_WARNING,
OPTION_TITLE,
OPTION_ICON,
@@ -517,6 +518,15 @@ struct poptOption text_options[] = {
N_("Open file"),
N_("FILENAME")
},
+ {
+ "editable",
+ '\0',
+ POPT_ARG_NONE,
+ NULL,
+ OPTION_TEXTEDIT,
+ N_("Allow changes to text"),
+ NULL
+ },
POPT_TABLEEND
};
@@ -727,6 +737,7 @@ zenity_init_parsing_options (void) {
results->calendar_data->month = 0;
results->calendar_data->year = 0;
results->calendar_data->dialog_text = NULL;
+ results->text_data->editable = FALSE;
results->tree_data->separator = g_strdup ("/");
results->progress_data->percentage = -1;
results->progress_data->pulsate = FALSE;
@@ -1108,6 +1119,19 @@ void zenity_parse_options_callback (poptContext ctx,
}
results->entry_data->visible = FALSE;
break;
+ case OPTION_TEXTEDIT:
+ if (results->mode != MODE_TEXTINFO) {
+ g_printerr (_("--editable is not supported for this dialog\n"));
+ zenity_free_parsing_options ();
+ exit (-1);
+ }
+ if (results->text_data->editable == TRUE) {
+ g_printerr (_("--editable given twice for the same dialog\n"));
+ zenity_free_parsing_options ();
+ exit (-1);
+ }
+ results->text_data->editable = TRUE;
+ break;
case OPTION_FILENAME:
case OPTION_TEXTFILE:
diff --git a/src/text.c b/src/text.c
index fe9747cb..02b2f109 100644
--- a/src/text.c
+++ b/src/text.c
@@ -25,6 +25,8 @@
#include "zenity.h"
#include "util.h"
+static ZenityTextData *zen_text_data;
+
static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data);
void
@@ -35,6 +37,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
+ zen_text_data = text_data;
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
if (glade_dialog == NULL) {
@@ -63,7 +66,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
if (zenity_util_fill_file_buffer (text_buffer, text_data->uri))
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
-
+ gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
+ if (text_data->editable) {
+ zen_text_data->buffer = text_buffer;
+ }
gtk_widget_show (dialog);
if (glade_dialog)
@@ -79,6 +85,12 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
switch (response) {
case GTK_RESPONSE_CLOSE:
+ if (zen_text_data->editable) {
+ GtkTextIter start,end;
+
+ gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end);
+ g_printerr (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0));
+ }
zen_data->exit_code = 0;
gtk_main_quit ();
break;
diff --git a/src/zenity.h b/src/zenity.h
index 813fbdd9..18da11ec 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -68,6 +68,8 @@ typedef struct {
typedef struct {
gchar *uri;
+ gboolean editable;
+ GtkTextBuffer *buffer;
} ZenityTextData;
typedef struct {
bgstack15