Add --editable option to --text-info, and return edited textbuffer contents on dialog close.
This commit is contained in:
parent
3eafefdeb0
commit
1e1dfef56e
@ -1,6 +1,8 @@
|
|||||||
2003-01-19 Ole Laursen <olau@hardworking.dk>
|
2003-01-19 Mike Newman <mike@gtnorthern.demon.co.uk>
|
||||||
|
|
||||||
* configure.in: Added da to ALL_LINGUAS.
|
* src/main.c, src/text.c, src/zenity.h: add an --editable
|
||||||
|
option to --text-info. If set, return the contents of the
|
||||||
|
text buffer on dialog close.
|
||||||
|
|
||||||
2003-01-18 Glynn Foster <glynn.foster@sun.com>
|
2003-01-18 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
@ -629,6 +629,13 @@
|
|||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term><varname>--editable</varname></term>
|
||||||
|
<listitem>
|
||||||
|
<para>Allow the displayed text to be edited and returned when the dialog is closed.</para>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
<figure id="zenity-text-screenshot">
|
<figure id="zenity-text-screenshot">
|
||||||
|
24
src/main.c
24
src/main.c
@ -65,6 +65,7 @@ enum {
|
|||||||
OPTION_PROGRESS,
|
OPTION_PROGRESS,
|
||||||
OPTION_QUESTION,
|
OPTION_QUESTION,
|
||||||
OPTION_TEXTINFO,
|
OPTION_TEXTINFO,
|
||||||
|
OPTION_TEXTEDIT,
|
||||||
OPTION_WARNING,
|
OPTION_WARNING,
|
||||||
OPTION_TITLE,
|
OPTION_TITLE,
|
||||||
OPTION_ICON,
|
OPTION_ICON,
|
||||||
@ -517,6 +518,15 @@ struct poptOption text_options[] = {
|
|||||||
N_("Open file"),
|
N_("Open file"),
|
||||||
N_("FILENAME")
|
N_("FILENAME")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"editable",
|
||||||
|
'\0',
|
||||||
|
POPT_ARG_NONE,
|
||||||
|
NULL,
|
||||||
|
OPTION_TEXTEDIT,
|
||||||
|
N_("Allow changes to text"),
|
||||||
|
NULL
|
||||||
|
},
|
||||||
POPT_TABLEEND
|
POPT_TABLEEND
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -727,6 +737,7 @@ zenity_init_parsing_options (void) {
|
|||||||
results->calendar_data->month = 0;
|
results->calendar_data->month = 0;
|
||||||
results->calendar_data->year = 0;
|
results->calendar_data->year = 0;
|
||||||
results->calendar_data->dialog_text = NULL;
|
results->calendar_data->dialog_text = NULL;
|
||||||
|
results->text_data->editable = FALSE;
|
||||||
results->tree_data->separator = g_strdup ("/");
|
results->tree_data->separator = g_strdup ("/");
|
||||||
results->progress_data->percentage = -1;
|
results->progress_data->percentage = -1;
|
||||||
results->progress_data->pulsate = FALSE;
|
results->progress_data->pulsate = FALSE;
|
||||||
@ -1108,6 +1119,19 @@ void zenity_parse_options_callback (poptContext ctx,
|
|||||||
}
|
}
|
||||||
results->entry_data->visible = FALSE;
|
results->entry_data->visible = FALSE;
|
||||||
break;
|
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_FILENAME:
|
||||||
case OPTION_TEXTFILE:
|
case OPTION_TEXTFILE:
|
||||||
|
|
||||||
|
14
src/text.c
14
src/text.c
@ -25,6 +25,8 @@
|
|||||||
#include "zenity.h"
|
#include "zenity.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
|
static ZenityTextData *zen_text_data;
|
||||||
|
|
||||||
static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -35,6 +37,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data)
|
|||||||
GtkWidget *text_view;
|
GtkWidget *text_view;
|
||||||
GtkTextBuffer *text_buffer;
|
GtkTextBuffer *text_buffer;
|
||||||
|
|
||||||
|
zen_text_data = text_data;
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
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");
|
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
|
||||||
if (zenity_util_fill_file_buffer (text_buffer, text_data->uri))
|
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_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);
|
gtk_widget_show (dialog);
|
||||||
|
|
||||||
if (glade_dialog)
|
if (glade_dialog)
|
||||||
@ -79,6 +85,12 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
|
|||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_CLOSE:
|
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;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
@ -68,6 +68,8 @@ typedef struct {
|
|||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
|
gboolean editable;
|
||||||
|
GtkTextBuffer *buffer;
|
||||||
} ZenityTextData;
|
} ZenityTextData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
Reference in New Issue
Block a user