Move Code Around
This commit is contained in:
parent
58787016ce
commit
c9ff7f17aa
@ -35,7 +35,7 @@
|
||||
gint
|
||||
main (gint argc, gchar **argv) {
|
||||
ZenityParsingOptions *results;
|
||||
gint retval;
|
||||
gint retval;
|
||||
|
||||
#ifdef HAVE_LOCALE_H
|
||||
setlocale (LC_ALL, "");
|
||||
|
12
src/option.c
12
src/option.c
@ -64,6 +64,7 @@ static gboolean zenity_list_mid_search;
|
||||
/* Text Dialog Options */
|
||||
static gboolean zenity_text_active;
|
||||
static gchar *zenity_text_font;
|
||||
static gchar *zenity_text_save_filename;
|
||||
|
||||
static GOptionEntry general_options[] = {{"title",
|
||||
'\0',
|
||||
@ -292,6 +293,13 @@ static GOptionEntry text_options[] = {{"text-info",
|
||||
&zenity_general_dialog_no_wrap,
|
||||
"Do not enable text wrapping",
|
||||
NULL},
|
||||
{"save-filename",
|
||||
'\0',
|
||||
0,
|
||||
G_OPTION_ARG_STRING,
|
||||
&zenity_text_save_filename,
|
||||
"Set the initial filename for text save dialog",
|
||||
"TEXT"},
|
||||
{NULL}};
|
||||
|
||||
static ZenityParsingOptions *results;
|
||||
@ -338,6 +346,8 @@ zenity_option_free (void) {
|
||||
|
||||
if (zenity_text_font)
|
||||
g_free (zenity_text_font);
|
||||
if (zenity_text_save_filename)
|
||||
g_free (zenity_text_save_filename);
|
||||
|
||||
g_option_context_free (ctx);
|
||||
}
|
||||
@ -426,6 +436,7 @@ zenity_text_pre_callback (GOptionContext *context, GOptionGroup *group,
|
||||
gpointer data, GError **error) {
|
||||
zenity_text_active = FALSE;
|
||||
zenity_text_font = NULL;
|
||||
zenity_text_save_filename = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -561,6 +572,7 @@ zenity_text_post_callback (GOptionContext *context, GOptionGroup *group,
|
||||
results->text_data->uri = zenity_general_uri;
|
||||
results->text_data->no_wrap = zenity_general_dialog_no_wrap;
|
||||
results->text_data->font = zenity_text_font;
|
||||
results->text_data->save_filename = zenity_text_save_filename;
|
||||
} else {
|
||||
if (zenity_text_font)
|
||||
zenity_option_error (
|
||||
|
11
src/text.c
11
src/text.c
@ -174,8 +174,6 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) {
|
||||
} else
|
||||
zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW (text_view));
|
||||
|
||||
g_object_set_data (G_OBJECT (dialog), "text_buffer", text_buffer);
|
||||
|
||||
if (data->extra_label) {
|
||||
gint i = 0;
|
||||
while (data->extra_label[i] != NULL) {
|
||||
@ -243,8 +241,10 @@ zenity_save (GtkWidget *widget, GtkWindow *parent_window) {
|
||||
|
||||
gtk_file_chooser_set_do_overwrite_confirmation (chooser, TRUE);
|
||||
|
||||
gtk_file_chooser_set_current_name (
|
||||
chooser, "minecraft-pi-reborn-crash.log");
|
||||
if (zen_text_data->save_filename) {
|
||||
gtk_file_chooser_set_current_name (
|
||||
chooser, zen_text_data->save_filename);
|
||||
}
|
||||
|
||||
res = gtk_native_dialog_run (GTK_NATIVE_DIALOG (dialog));
|
||||
if (res == GTK_RESPONSE_ACCEPT) {
|
||||
@ -255,8 +255,7 @@ zenity_save (GtkWidget *widget, GtkWindow *parent_window) {
|
||||
char *text;
|
||||
|
||||
filename = gtk_file_chooser_get_filename (chooser);
|
||||
buffer = GTK_TEXT_BUFFER (
|
||||
g_object_get_data (G_OBJECT (widget), "text_buffer"));
|
||||
buffer = zen_text_data->buffer;
|
||||
gtk_text_buffer_get_start_iter (buffer, &start);
|
||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
|
||||
|
@ -41,6 +41,7 @@ typedef struct {
|
||||
gchar *uri;
|
||||
gboolean no_wrap;
|
||||
gchar *font;
|
||||
gchar *save_filename;
|
||||
GtkTextBuffer *buffer;
|
||||
} ZenityTextData;
|
||||
|
||||
|
Reference in New Issue
Block a user