From 48c1564ac5ef431e9111606e40488d04a96f3059 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 3 Jan 2003 13:26:04 +0000 Subject: Initial revision --- src/Makefile.am | 28 ++ src/calendar.c | 90 +++++ src/entry.c | 94 +++++ src/fileselection.c | 80 +++++ src/main.c | 834 +++++++++++++++++++++++++++++++++++++++++++ src/msg.c | 117 ++++++ src/progress.c | 139 ++++++++ src/text.c | 83 +++++ src/tree.c | 208 +++++++++++ src/util.c | 158 +++++++++ src/util.h | 26 ++ src/zenity.glade | 999 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 95 +++++ 13 files changed, 2951 insertions(+) create mode 100644 src/Makefile.am create mode 100644 src/calendar.c create mode 100644 src/entry.c create mode 100644 src/fileselection.c create mode 100644 src/main.c create mode 100644 src/msg.c create mode 100644 src/progress.c create mode 100644 src/text.c create mode 100644 src/tree.c create mode 100644 src/util.c create mode 100644 src/util.h create mode 100644 src/zenity.glade create mode 100644 src/zenity.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 00000000..11e0816c --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,28 @@ +bin_PROGRAMS = zenity + +zenity_SOURCES = \ + main.c \ + zenity.h \ + calendar.c \ + msg.c \ + fileselection.c \ + entry.c \ + text.c \ + progress.c \ + tree.c \ + util.h \ + util.c + +INCLUDES = \ + $(ZENITY_CFLAGS) \ + -I$(includedir) \ + -DGNOMELOCALEDIR=\""$(zenitylocaledir)"\" \ + -DZENITY_DATADIR=\""$(datadir)/zenity"\" + +zenity_LDADD = \ + $(ZENITY_LIBS) + +gladedir = $(datadir)/zenity + +glade_DATA = \ + zenity.glade diff --git a/src/calendar.c b/src/calendar.c new file mode 100644 index 00000000..4cdf4811 --- /dev/null +++ b/src/calendar.c @@ -0,0 +1,90 @@ +/* + * calendar.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) +{ + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *calendar; + GtkWidget *text; + + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + + calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + + if (cal_data->month != 0 && cal_data->year !=0) + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); + if (cal_data->day) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/entry.c b/src/entry.c new file mode 100644 index 00000000..3816a502 --- /dev/null +++ b/src/entry.c @@ -0,0 +1,94 @@ +/* + * entry.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_entry (ZenityData *data, ZenityEntryData *entry_data) +{ + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text; + GtkWidget *entry; + + glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + /* FIXME: Come up with a nice default window icon */; + + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + + entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->visible == FALSE) + g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/fileselection.c b/src/fileselection.c new file mode 100644 index 00000000..52c0021a --- /dev/null +++ b/src/fileselection.c @@ -0,0 +1,80 @@ +/* + * fileselection.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_fileselection (ZenityData *data, ZenityFileData *file_data) +{ + GladeXML *glade_dialog; + GtkWidget *dialog; + + glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + + if (file_data->uri) + gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/main.c b/src/main.c new file mode 100644 index 00000000..cf17d7dd --- /dev/null +++ b/src/main.c @@ -0,0 +1,834 @@ +/* + * main.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include "config.h" +#include "zenity.h" +#include + +typedef enum { + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_LAST +} ZenityDialogMode; + +typedef struct { + ZenityDialogMode mode; + ZenityData *data; + + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; +} ZenityParsingOptions; + +enum { + OPTION_CALENDAR = 1, + OPTION_ENTRY, + OPTION_ERROR, + OPTION_FILE, + OPTION_LIST, + OPTION_PROGRESS, + OPTION_QUESTION, + OPTION_TEXTINFO, + OPTION_WARNING, + OPTION_TITLE, + OPTION_ICON, + OPTION_CALENDARTEXT, + OPTION_DAY, + OPTION_MONTH, + OPTION_YEAR, + OPTION_ENTRYTEXT, + OPTION_INPUTTEXT, + OPTION_HIDETEXT, + OPTION_ERRORTEXT, + OPTION_FILENAME, + OPTION_COLUMN, + OPTION_CHECKLIST, + OPTION_RADIOLIST, + OPTION_PROGRESSTEXT, + OPTION_PERCENTAGE, + OPTION_QUESTIONTEXT, + OPTION_TEXTFILE, + OPTION_WARNINGTEXT, + OPTION_ABOUT, + OPTION_VERSION, + OPTION_LAST, +}; + +static void zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); + +struct poptOption options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "calendar", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CALENDAR, + N_("Display calendar dialog"), + NULL + }, + { + "entry", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ENTRY, + N_("Display text entry dialog"), + NULL + }, + { + "error", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ERROR, + N_("Display error dialog"), + NULL + }, + { + "file-selection", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_FILE, + N_("Display file selection dialog"), + NULL + }, + { + "list", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LIST, + N_("Display list dialog"), + NULL + }, + { + "progress", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PROGRESS, + N_("Display progress indication dialog"), + NULL + }, + { + "question", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_QUESTION, + N_("Display question dialog"), + NULL + }, + { + "text-info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTINFO, + N_("Display text information dialog"), + NULL + }, + { + "warning", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_WARNING, + N_("Display warning dialog"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption general_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "title", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TITLE, + N_("Set the dialog title"), + N_("TITLE") + }, + { + "window-icon", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ICON, + N_("Set the window icon"), + N_("ICONPATH") + }, + POPT_TABLEEND +}; + +struct poptOption calendar_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_CALENDARTEXT, + N_("Set the dialog text"), + NULL + }, + { + "day", + '\0', + POPT_ARG_INT, + NULL, + OPTION_DAY, + N_("Set the calendar day"), + NULL + }, + { + "month", + '\0', + POPT_ARG_INT, + NULL, + OPTION_MONTH, + N_("Set the calendar month"), + NULL + }, + { + "year", + '\0', + POPT_ARG_INT, + NULL, + OPTION_YEAR, + N_("Set the calendar year"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption entry_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ENTRYTEXT, + N_("Set the dialog text"), + NULL + }, + { + "entry-text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INPUTTEXT, + N_("Set the entry text"), + NULL + }, + { + "hide-text", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_HIDETEXT, + N_("Hide the entry text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption error_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ERRORTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption file_selection_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_FILENAME, + N_("Set the filename"), + N_("FILENAME") + }, + POPT_TABLEEND +}; + +struct poptOption list_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_COLUMN, + N_("Set the column header"), + NULL + }, + { + "checklist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CHECKLIST, + N_("Use check boxes for first column"), + NULL + }, + { + "radiolist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_RADIOLIST, + N_("Use radio buttons for first column"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption progress_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PROGRESSTEXT, + N_("Set the dialog text"), + NULL + }, + { + "percentage", + '\0', + POPT_ARG_INT, + NULL, + OPTION_PERCENTAGE, + N_("Set initial percentage"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption question_options[] = { + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_QUESTIONTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption text_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TEXTFILE, + N_("Open file"), + N_("FILENAME") + }, + POPT_TABLEEND +}; + +struct poptOption warning_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_WARNINGTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption miscellaneous_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "about", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ABOUT, + N_("About zenity"), + NULL + }, + { + "version", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_VERSION, + N_("Print version"), + NULL + }, + POPT_TABLEEND +}; + +struct poptOption application_options[] = { + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + options, + 0, + N_("Dialog options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + general_options, + 0, + N_("General options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + calendar_options, + 0, + N_("Calendar options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + entry_options, + 0, + N_("Text entry options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + error_options, + 0, + N_("Error options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + file_selection_options, + 0, + N_("File selection options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + list_options, + 0, + N_("List options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + progress_options, + 0, + N_("Progress options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + question_options, + 0, + N_("Question options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + text_options, + 0, + N_("Text options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + warning_options, + 0, + N_("Warning options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + miscellaneous_options, + 0, + N_("Miscellaneous options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + poptHelpOptions, + 0, + N_("Help options"), + NULL + }, + POPT_TABLEEND +}; + +ZenityParsingOptions *results; + +gint +main (gint argc, gchar **argv) { + poptContext ctx; + int nextopt; + ZenityData *general; + ZenityCalendarData *cal_data; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + results = g_new0 (ZenityParsingOptions, 1); + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->entry_data->visible = TRUE; + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); + results->tree_data->checkbox = FALSE; + results->tree_data->radiobox = FALSE; + + /* FIXME: popt doesn't like passing stuff through data + * but it doesn't seem to cope with the data that I try + * to pass in, not quite sure why though. If someone knows + * what I'm doing wrong, we could probably put this back: + * options[0].descrip = (void*) results; + */ + + ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); + poptSetOtherOptionHelp(ctx, "[OPTIONS] ..."); + poptReadDefaultConfig(ctx, TRUE); + while((nextopt = poptGetNextOpt(ctx)) > 0) + /*nothing*/; + + gtk_init (&argc, &argv); + + if (argc < 2) + exit (1); + + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + zenity_msg (results->data, results->msg_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + zenity_tree (results->data, results->tree_data); + break; + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + default: + break; + } + + poptFreeContext(ctx); + exit (0); +} + +static +void zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data) +{ + gint i = 0; + if (reason == POPT_CALLBACK_REASON_POST) { + return; + } + else if (reason != POPT_CALLBACK_REASON_OPTION) + return; + + switch (opt->val & POPT_ARG_MASK) { + + case OPTION_CALENDAR: + results->mode = MODE_CALENDAR; + break; + case OPTION_ENTRY: + results->mode = MODE_ENTRY; + break; + case OPTION_ERROR: + results->mode = MODE_ERROR; + results->msg_data->mode = ZENITY_MSG_ERROR; + break; + case OPTION_FILE: + results->mode = MODE_FILE; + break; + case OPTION_LIST: + results->mode = MODE_LIST; + break; + case OPTION_PROGRESS: + results->mode = MODE_PROGRESS; + break; + case OPTION_QUESTION: + results->mode = MODE_QUESTION; + results->msg_data->mode = ZENITY_MSG_QUESTION; + break; + case OPTION_TEXTINFO: + results->mode = MODE_TEXTINFO; + break; + case OPTION_WARNING: + results->mode = MODE_WARNING; + results->msg_data->mode = ZENITY_MSG_WARNING; + break; + case OPTION_TITLE: + results->data->dialog_title = g_strdup (arg); + break; + case OPTION_ICON: + results->data->window_icon = g_strdup (arg); + break; + case OPTION_CALENDARTEXT: + case OPTION_ENTRYTEXT: + case OPTION_ERRORTEXT: + case OPTION_QUESTIONTEXT: + case OPTION_PROGRESSTEXT: + case OPTION_WARNINGTEXT: + switch (results->mode) { + case MODE_CALENDAR: + results->calendar_data->dialog_text = g_strdup (arg); + break; + case MODE_ENTRY: + results->entry_data->dialog_text = g_strdup (arg); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + results->msg_data->dialog_text = g_strdup (arg); + break; + case MODE_PROGRESS: + results->progress_data->dialog_text = g_strdup (arg); + break; + default: + break; + } + break; + case OPTION_DAY: + results->calendar_data->day = atoi (arg); + break; + case OPTION_MONTH: + results->calendar_data->month = atoi (arg); + break; + case OPTION_YEAR: + results->calendar_data->year = atoi (arg); + break; + case OPTION_INPUTTEXT: + results->entry_data->entry_text = g_strdup (arg); + break; + case OPTION_HIDETEXT: + results->entry_data->visible = FALSE; + break; + case OPTION_FILENAME: + case OPTION_TEXTFILE: + switch (results->mode) { + case MODE_FILE: + results->file_data->uri = g_strdup (arg); + break; + case MODE_TEXTINFO: + results->text_data->uri = g_strdup (arg); + break; + default: + break; + } + break; + case OPTION_COLUMN: + break; + case OPTION_CHECKLIST: + results->tree_data->checkbox = TRUE; + break; + case OPTION_RADIOLIST: + results->tree_data->radiobox = TRUE; + break; + case OPTION_PERCENTAGE: + results->progress_data->percentage = atoi (arg); + break; + case OPTION_ABOUT: + results->mode = MODE_LAST; + break; + case OPTION_VERSION: + results->mode = MODE_LAST; + g_print ("%s\n", VERSION); + break; + default: + break; + } +} diff --git a/src/msg.c b/src/msg.c new file mode 100644 index 00000000..a8e5c2de --- /dev/null +++ b/src/msg.c @@ -0,0 +1,117 @@ +/* + * msg.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) +{ + GladeXML *glade_dialog; + GtkWidget *dialog; + GtkWidget *text; + + switch (msg_data->mode) { + + case ZENITY_MSG_WARNING: + glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + break; + + case ZENITY_MSG_QUESTION: + glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + break; + + case ZENITY_MSG_ERROR: + glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + break; + + default: + g_assert_not_reached (); + break; + } + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + GdkPixbuf *pixbuf = NULL; + switch (msg_data->mode) { + + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); + break; + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); + break; + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); + break; + default: + break; + } + } + + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/progress.c b/src/progress.c new file mode 100644 index 00000000..21305917 --- /dev/null +++ b/src/progress.c @@ -0,0 +1,139 @@ +/* + * progress.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include +#include "zenity.h" +#include "util.h" + +static guint timer; +static GladeXML *glade_dialog; + +static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); +static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); + +void zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data); + +gint +zenity_progress_timeout (gpointer data) +{ + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); + return TRUE; +} + +int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) +{ + GtkWidget *dialog; + GtkWidget *text; + GtkWidget *progress_bar; + GIOChannel *giochannel; + guint input; + + glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); + } + + text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); + + progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + + giochannel = g_io_channel_unix_new (0); + + if (progress_data->pulsate != TRUE) { + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); + } + else { + input = g_io_add_watch (giochannel, G_IO_IN | G_IO_HUP, zenity_progress_pulsate_bar, NULL); + timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); + } + + g_io_channel_unref (giochannel); + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +static gboolean +zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data) +{ + gchar buf[1024]; + + if (!feof (stdin)) { + GtkWidget *button; + gtk_timeout_remove (timer); + g_io_channel_shutdown (giochannel, 0, NULL); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + gtk_widget_set_sensitive (button, FALSE); + return FALSE; + } + + fgets (buf, sizeof (buf)-1, stdin); + return TRUE; +} + +static gboolean +zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data) +{ + /* FIXME: Do nothing at the moment */ +} + +void +zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/text.c b/src/text.c new file mode 100644 index 00000000..0d2dbe11 --- /dev/null +++ b/src/text.c @@ -0,0 +1,83 @@ +/* + * text.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "zenity.h" +#include "util.h" + +void zenity_text_dialog_response (GtkWindow *window, int button, gpointer data); + +int zenity_text (ZenityData *data, ZenityTextData *text_data) +{ + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text_view; + GtkTextBuffer *text_buffer; + + glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + ; + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); + + text_buffer = gtk_text_buffer_new (NULL); + 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_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_text_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_CLOSE: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/tree.c b/src/tree.c new file mode 100644 index 00000000..c5eef5a4 --- /dev/null +++ b/src/tree.c @@ -0,0 +1,208 @@ +/* + * tree.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + * Jonathan Blanford + * Kristian Rietveld + */ + +#include +#include "zenity.h" +#include "util.h" + +#define MAX_ELEMENTS_BEFORE_SCROLLING 8 + +static GladeXML *glade_dialog; + +enum +{ + NAME_COLUMN, + DESCRIPTION_COLUMN, + N_COLUMNS +}; + +void zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data); + +static void +zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data) +{ + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + gboolean value; + + model = GTK_TREE_MODEL (data); + path = gtk_tree_path_new_from_string (path_string); + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, NAME_COLUMN, &value, -1); + + value = !value; + gtk_list_store_set (GTK_LIST_STORE (model), &iter, NAME_COLUMN, value, -1); + + gtk_tree_path_free (path); +} + +static gboolean +count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +{ + gint *rows = data; + + (*rows)++; + return FALSE; +} + +static void +zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv) +{ + GtkTreeModel *model; + GtkTreeIter iter; + gint i = 0; + + model = gtk_tree_view_get_model (tree_view); + gtk_tree_model_foreach (model, count_rows_foreach, &i); + + while (i<10) { + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + NAME_COLUMN, "TRUE", + DESCRIPTION_COLUMN, "This is the bar above foobar", + -1); + + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + } + i++; + } +} + +int +zenity_tree (ZenityData *data, ZenityTreeData *tree_data) +{ + GtkWidget *dialog; + GtkWidget *tree_view; + GtkTreeViewColumn *column; + GtkListStore *model; + + glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); + + if (glade_dialog == NULL) + return FALSE; + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); + + tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + + if (tree_data->checkbox || tree_data->radiobox) + model = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING); + else + model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); + + if (tree_data->checkbox) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_toggle_new (); + g_signal_connect (cell_renderer, "toggled", + G_CALLBACK (zenity_tree_toggled_callback), model); + + column = gtk_tree_view_column_new_with_attributes (NULL, + cell_renderer, + "active", NAME_COLUMN, NULL); + } + else if (tree_data->radiobox) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_toggle_new (); + g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); + g_signal_connect (cell_renderer, "toggled", + G_CALLBACK (zenity_tree_toggled_callback), model); + + column = gtk_tree_view_column_new_with_attributes (NULL, + cell_renderer, + "active", NAME_COLUMN, NULL); + + } + else { + column = gtk_tree_view_column_new_with_attributes (tree_data->column_one_header, + gtk_cell_renderer_text_new (), + "text", NAME_COLUMN, NULL); + gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN); + } + + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + column = gtk_tree_view_column_new_with_attributes (tree_data->column_two_header, + gtk_cell_renderer_text_new (), + "text", DESCRIPTION_COLUMN, NULL); + gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN); + gtk_tree_view_column_set_resizable (column, TRUE); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); + + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL); + + gtk_widget_show (dialog); + gtk_main (); + + if (glade_dialog) + g_object_unref (glade_dialog); + + return TRUE; +} + +void +zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data) +{ + GError *error = NULL; + + switch (button) { + case GTK_RESPONSE_OK: + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + gtk_main_quit (); + break; + + default: + break; + } +} diff --git a/src/util.c b/src/util.c new file mode 100644 index 00000000..b9116acb --- /dev/null +++ b/src/util.c @@ -0,0 +1,158 @@ +/* + * util.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + * Havoc Pennington + */ + +#include +#include +#include "config.h" +#include "util.h" + +GladeXML* +zenity_util_load_glade_file (const gchar *widget_root) +{ + GladeXML *xml = NULL; + + if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, + G_FILE_TEST_EXISTS)) { + /* Try current dir, for debugging */ + xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE); + } + + if (xml == NULL) + xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE); + + if (xml == NULL) { + g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH); + return NULL; + } + + return xml; +} + +gboolean +zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) +{ + GtkTextIter iter, end; + FILE* f; + gchar buf[2048]; + gint remaining = 0; + + if (filename == NULL) + return FALSE; + + f = fopen (filename, "r"); + + if (f == NULL) { + g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno)); + return FALSE; + } + + gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); + + while (!feof (f)) { + gint count; + const char *leftover; + int to_read = 2047 - remaining; + + count = fread (buf + remaining, 1, to_read, f); + buf[count + remaining] = '\0'; + + g_utf8_validate (buf, count + remaining, &leftover); + + g_assert (g_utf8_validate (buf, leftover - buf, NULL)); + gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); + + remaining = (buf + remaining + count) - leftover; + g_memmove (buf, leftover, remaining); + + if (remaining > 6 || count < to_read) + break; + } + + if (remaining) { + g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename); + return FALSE; + } + + /* We had a newline in the buffer to begin with. (The buffer always contains + * a newline, so we delete to the end of the buffer to clean up. + */ + gtk_text_buffer_get_end_iter (buffer, &end); + gtk_text_buffer_delete (buffer, &iter, &end); + + gtk_text_buffer_set_modified (buffer, FALSE); + + return TRUE; +} + +static GList * +zenity_util_list_from_char_array (const char **s) +{ + GList *list = NULL; + gint i; + + for (i = 0; s[i]; i++) { + GdkPixbuf *pixbuf; + + pixbuf = gdk_pixbuf_new_from_file (s[i], NULL); + if (pixbuf) + list = g_list_prepend (list, pixbuf); + } + + return list; +} + +static void +zenity_util_free_list (GList *list) +{ + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); +} + +void +zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename) +{ + const gchar *filenames[2] = { NULL}; + GList *list; + + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WINDOW (widget)); + + if (filename == NULL) + return; + + filenames[0] = filename; + list = zenity_util_list_from_char_array (filenames); + gtk_window_set_icon_list (GTK_WINDOW (widget), list); + zenity_util_free_list (list); +} + +void +zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id) +{ + GdkPixbuf *pixbuf; + + pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL); + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); +} diff --git a/src/util.h b/src/util.h new file mode 100644 index 00000000..3f9d8e1d --- /dev/null +++ b/src/util.h @@ -0,0 +1,26 @@ +#ifndef UTIL_H +#define UTIL_H + +#include +#include + +G_BEGIN_DECLS + +#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" +#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" +#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL)) + +GladeXML* zenity_util_load_glade_file (const gchar *widget_root); + +gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, + const gchar *filename); + +void zenity_util_set_window_icon (GtkWidget *widget, + const gchar *filename); + +void zenity_util_set_window_icon_from_stock (GtkWidget *widget, + const gchar *stock_id); + +G_END_DECLS + +#endif /* UTIL_H */ diff --git a/src/zenity.glade b/src/zenity.glade new file mode 100644 index 00000000..27b3cf1b --- /dev/null +++ b/src/zenity.glade @@ -0,0 +1,999 @@ + + + + + + + True + zenity_calendar_dialog_title + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 4 + + + + True + zenity_calendar_text + False + True + GTK_JUSTIFY_LEFT + True + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 12 + True + True + + + + + + True + C_alendar: + True + False + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + + + 0 + False + False + + + + + + True + True + GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + True + zenity_warning_dialog_title + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 13 + True + False + 0 + + + + True + gtk-dialog-warning + 6 + 0 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + zenity_warning_text + False + True + GTK_JUSTIFY_LEFT + True + False + 0.5 + 0.5 + 7 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + 10 + True + zenity_fileselection_dialog_text + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + True + True + True + GTK_RELIEF_NORMAL + + + + + + True + True + True + GTK_RELIEF_NORMAL + + + + + + True + zenity_question_dialog_text + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 13 + True + False + 0 + + + + True + gtk-dialog-question + 6 + 0 + 0.5 + 0 + 0 + + + 0 + False + True + + + + + + True + zenity_question_text + False + True + GTK_JUSTIFY_LEFT + True + False + 0.5 + 0.5 + 7 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + + + True + zenity_entry_dialog_text + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + zenity_entry_text: + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + + + + 0 + False + False + + + + + + True + True + True + True + 0 + zenity_entry_input + True + * + False + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + zenity_text_dialog + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + 300 + 200 + True + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-close + True + GTK_RELIEF_NORMAL + -7 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 7 + True + False + 0 + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_ETCHED_IN + GTK_CORNER_TOP_LEFT + + + + True + True + False + GTK_JUSTIFY_LEFT + GTK_WRAP_WORD + True + 2 + 2 + 0 + 2 + 2 + 0 + zenity_text_view + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + zenity_progress_dialog + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + False + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 5 + + + + True + zenity_progress text + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.1 + + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + zenity_error_dialog + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + gtk-dialog-error + 6 + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + zenity_error_text + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + + True + dialog1 + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + 300 + 200 + True + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + -6 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 6 + + + + True + zenity_tree_text + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_NONE + GTK_CORNER_TOP_LEFT + + + + True + True + True + False + False + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + + diff --git a/src/zenity.h b/src/zenity.h new file mode 100644 index 00000000..1543436b --- /dev/null +++ b/src/zenity.h @@ -0,0 +1,95 @@ +#ifndef ZENITY_H +#define ZENITY_H + +#include + +G_BEGIN_DECLS + +#ifdef ENABLE_NLS +#include +#define _(String) dgettext(GETTEXT_PACKAGE,String) +#ifdef gettext_noop +#define N_(String) gettext_noop(String) +#else +#define N_(String) (String) +#endif +#else /* NLS is disabled */ +#define _(String) (String) +#define N_(String) (String) +#define textdomain(String) (String) +#define gettext(String) (String) +#define dgettext(Domain,String) (String) +#define dcgettext(Domain,String,Type) (String) +#define bindtextdomain(Domain,Directory) (Domain) +#endif + +typedef struct { + gchar *dialog_title; + gchar *window_icon; +} ZenityData; + +typedef struct { + gchar *dialog_text; + gint day; + gint month; + gint year; +} ZenityCalendarData; + +typedef enum { + ZENITY_MSG_WARNING, + ZENITY_MSG_QUESTION, + ZENITY_MSG_ERROR +} MsgMode; + +typedef struct { + gchar *dialog_text; + MsgMode mode; +} ZenityMsgData; + +typedef struct { + gchar *uri; +} ZenityFileData; + +typedef struct { + gchar *dialog_text; + gchar *entry_text; + gboolean visible; +} ZenityEntryData; + +typedef struct { + gchar *dialog_text; + gchar *entry_text; + gboolean pulsate; + gdouble percentage; +} ZenityProgressData; + +typedef struct { + gchar *uri; +} ZenityTextData; + +typedef struct { + gchar *dialog_text; + gchar *column_one_header; + gchar *column_two_header; + gboolean checkbox; + gboolean radiobox; +} ZenityTreeData; + +int zenity_calendar (ZenityData *data, + ZenityCalendarData *calendar_data); +int zenity_msg (ZenityData *data, + ZenityMsgData *msg_data); +int zenity_fileselection (ZenityData *data, + ZenityFileData *file_data); +int zenity_entry (ZenityData *data, + ZenityEntryData *entry_data); +int zenity_progress (ZenityData *data, + ZenityProgressData *progress_data); +int zenity_text (ZenityData *data, + ZenityTextData *text_data); +int zenity_tree (ZenityData *data, + ZenityTreeData *tree_data); + +G_END_DECLS + +#endif /* ZENITY_H */ -- cgit From 344345d9aa262940fedfb8beed9dc0c9bb163a10 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 15:06:17 +0000 Subject: Add functions to init and free the parsing options. Still not terribly 2003-01-06 Glynn Foster * src/main.c: Add functions to init and free the parsing options. Still not terribly pretty though. * src/tree.c, src/zenity.h: Handle --column argument. * TODO: Update accordingly. --- src/main.c | 71 ++++++++++++++++++++++++----- src/tree.c | 143 ++++++++++++++++++++++++++++++++--------------------------- src/zenity.h | 3 +- 3 files changed, 138 insertions(+), 79 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index cf17d7dd..a1faf681 100644 --- a/src/main.c +++ b/src/main.c @@ -631,29 +631,76 @@ struct poptOption application_options[] = { ZenityParsingOptions *results; -gint -main (gint argc, gchar **argv) { - poptContext ctx; - int nextopt; - ZenityData *general; - ZenityCalendarData *cal_data; - - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); +static void +zenity_init_parsing_options (void) { results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ results->data = g_new0 (ZenityData, 1); results->calendar_data = g_new0 (ZenityCalendarData, 1); results->msg_data = g_new0 (ZenityMsgData, 1); results->file_data = g_new0 (ZenityFileData, 1); results->entry_data = g_new0 (ZenityEntryData, 1); - results->entry_data->visible = TRUE; results->progress_data = g_new0 (ZenityProgressData, 1); results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); + + /* Give some sensible defaults */ + results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; +} + +static void +zenity_free_parsing_options (void) { + + /* General options */ + if (results->data->dialog_title) + g_free (results->data->dialog_title); + if (results->data->window_icon) + g_free (results->data->window_icon); + + /* Dialog options */ + switch (results->mode) { + case MODE_CALENDAR: + g_free (results->calendar_data->dialog_text); + break; + case MODE_ENTRY: + g_free (results->entry_data->dialog_text); + g_free (results->entry_data->entry_text); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + g_free (results->msg_data->dialog_text); + break; + case MODE_FILE: + g_free (results->file_data->uri); + break; + case MODE_TEXTINFO: + g_free (results->text_data->uri); + break; + case MODE_LIST: + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + break; + default: + break; + } +} + +gint +main (gint argc, gchar **argv) { + poptContext ctx; + int nextopt; + ZenityData *general; + ZenityCalendarData *cal_data; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + zenity_init_parsing_options (); /* FIXME: popt doesn't like passing stuff through data * but it doesn't seem to cope with the data that I try @@ -702,6 +749,7 @@ main (gint argc, gchar **argv) { } poptFreeContext(ctx); + zenity_free_parsing_options (); exit (0); } @@ -811,6 +859,7 @@ void zenity_parse_options_callback (poptContext ctx, } break; case OPTION_COLUMN: + results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: results->tree_data->checkbox = TRUE; diff --git a/src/tree.c b/src/tree.c index c5eef5a4..6e8709ce 100644 --- a/src/tree.c +++ b/src/tree.c @@ -31,13 +31,6 @@ static GladeXML *glade_dialog; -enum -{ - NAME_COLUMN, - DESCRIPTION_COLUMN, - N_COLUMNS -}; - void zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data); static void @@ -52,10 +45,10 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g path = gtk_tree_path_new_from_string (path_string); gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, NAME_COLUMN, &value, -1); + gtk_tree_model_get (model, &iter, 0, &value, -1); value = !value; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, NAME_COLUMN, value, -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1); gtk_tree_path_free (path); } @@ -80,23 +73,23 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv) gtk_tree_model_foreach (model, count_rows_foreach, &i); while (i<10) { - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - NAME_COLUMN, "TRUE", - DESCRIPTION_COLUMN, "This is the bar above foobar", - -1); - - if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { - GtkWidget *scrolled_window; - GtkRequisition rectangle; - - gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); - gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - } - i++; + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + 0, "TRUE", + 1, "This is the bar above foobar", -1); + + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + } + + i++; } } @@ -107,6 +100,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) GtkWidget *tree_view; GtkTreeViewColumn *column; GtkListStore *model; + GType *column_types; + GSList *tmp; + gboolean first_column = FALSE; + gint i, column_index, column_n; glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); @@ -127,57 +124,71 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); - if (tree_data->checkbox || tree_data->radiobox) - model = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING); - else - model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING); - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); + column_n = g_slist_length (tree_data->columns); - if (tree_data->checkbox) { - GtkCellRenderer *cell_renderer; + /* Create an empty list store */ + model = g_object_new (GTK_TYPE_LIST_STORE, NULL); - cell_renderer = gtk_cell_renderer_toggle_new (); - g_signal_connect (cell_renderer, "toggled", - G_CALLBACK (zenity_tree_toggled_callback), model); + column_types = g_new (GType, column_n); - column = gtk_tree_view_column_new_with_attributes (NULL, - cell_renderer, - "active", NAME_COLUMN, NULL); + for (i = 0; i < column_n; i++) { + /* Have the limitation that the radioboxes and checkboxes are in the first column */ + if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) + column_types[i] = G_TYPE_BOOLEAN; + else + column_types[i] = G_TYPE_STRING; } - else if (tree_data->radiobox) { - GtkCellRenderer *cell_renderer; - cell_renderer = gtk_cell_renderer_toggle_new (); - g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); - g_signal_connect (cell_renderer, "toggled", - G_CALLBACK (zenity_tree_toggled_callback), model); + gtk_list_store_set_column_types (model, column_n, column_types); - column = gtk_tree_view_column_new_with_attributes (NULL, - cell_renderer, - "active", NAME_COLUMN, NULL); - - } - else { - column = gtk_tree_view_column_new_with_attributes (tree_data->column_one_header, - gtk_cell_renderer_text_new (), - "text", NAME_COLUMN, NULL); - gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN); - } + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + column_index = 0; + + for (tmp = tree_data->columns; tmp; tmp = tmp->next) { + if (first_column == FALSE) { + if (tree_data->checkbox || tree_data->radiobox) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_toggle_new (); + + if (tree_data->radiobox) + g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); + + g_signal_connect (cell_renderer, "toggled", + G_CALLBACK (zenity_tree_toggled_callback), model); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "active", column_index, NULL); + } + + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, NULL); + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + } + + first_column = TRUE; + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, NULL); + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + + } - column = gtk_tree_view_column_new_with_attributes (tree_data->column_two_header, - gtk_cell_renderer_text_new (), - "text", DESCRIPTION_COLUMN, NULL); - gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN); - gtk_tree_view_column_set_resizable (column, TRUE); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + column_index++; + } gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL); + /* zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL); */ gtk_widget_show (dialog); gtk_main (); diff --git a/src/zenity.h b/src/zenity.h index 1543436b..ea04b026 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -69,8 +69,7 @@ typedef struct { typedef struct { gchar *dialog_text; - gchar *column_one_header; - gchar *column_two_header; + GSList *columns; gboolean checkbox; gboolean radiobox; } ZenityTreeData; -- cgit From 00e8b3c09ab644fbcb16d60ec678c44a6c493a03 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 17:00:49 +0000 Subject: Feeling stupid because I can't use glade. Thanks to jrb and jamesh for 2003-01-06 Glynn Foster * src/zenity.glade: Feeling stupid because I can't use glade. Thanks to jrb and jamesh for showing me the light. Update default strings to sensible stuff. --- src/zenity.glade | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 27b3cf1b..e4e1b1f6 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -5,7 +5,7 @@ True - zenity_calendar_dialog_title + Calendar selection GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -75,7 +75,7 @@ True - zenity_calendar_text + Select a date from below False True GTK_JUSTIFY_LEFT @@ -113,6 +113,7 @@ 0.5 0 0 + zenity_calendar @@ -149,7 +150,7 @@ True - zenity_warning_dialog_title + Warning GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -230,7 +231,7 @@ True - zenity_warning_text + Are you sure you want to proceed? False True GTK_JUSTIFY_LEFT @@ -261,7 +262,7 @@ 10 True - zenity_fileselection_dialog_text + Select a file GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -293,7 +294,7 @@ True - zenity_question_dialog_text + Question GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -374,7 +375,7 @@ True - zenity_question_text + Are you sure you want to proceed? False True GTK_JUSTIFY_LEFT @@ -404,7 +405,7 @@ True - zenity_entry_dialog_text + Add a new entry GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -473,8 +474,8 @@ True - zenity_entry_text: - False + _Enter new text: + True True GTK_JUSTIFY_LEFT False @@ -483,6 +484,7 @@ 0.5 0 0 + zenity_entry_input @@ -501,7 +503,7 @@ True True 0 - zenity_entry_input + True * False @@ -628,7 +630,7 @@ True - zenity_progress_dialog + Progress GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -699,7 +701,7 @@ True - zenity_progress text + Running... False True GTK_JUSTIFY_LEFT @@ -751,7 +753,7 @@ True - zenity_error_dialog + Error GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -825,7 +827,7 @@ True - zenity_error_text + You have not done the right thing, clearly. False True GTK_JUSTIFY_LEFT @@ -862,7 +864,7 @@ True - dialog1 + Select items from the list GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -934,7 +936,7 @@ True - zenity_tree_text + Select items from the list below. False True GTK_JUSTIFY_LEFT -- cgit From 342d84b35fbb3cab483c3d81f415633f2cab4e1e Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 17:09:44 +0000 Subject: Life is pleasant. Death is peaceful. It's the transition that's troublesome. --- src/.cvsignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 src/.cvsignore (limited to 'src') diff --git a/src/.cvsignore b/src/.cvsignore new file mode 100644 index 00000000..fb42eb77 --- /dev/null +++ b/src/.cvsignore @@ -0,0 +1,4 @@ +zenity.gladep +zenity +Makefile.in +Makefile -- cgit From 8924d5c401829efc59380fda8823bedca5994bcb Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 21:09:22 +0000 Subject: I love featuritis. Instead of fixing stuff so it actually works, I add 2003-01-06 Glynn Foster * src/main.c, src/msg.c, src/zenity.glade, src/zenity.h: I love featuritis. Instead of fixing stuff so it actually works, I add more stuff. Add support for info dialog. --- src/main.c | 50 +++++++++++++++++++++++++ src/msg.c | 9 +++++ src/zenity.glade | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 3 +- 4 files changed, 172 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index a1faf681..334c20df 100644 --- a/src/main.c +++ b/src/main.c @@ -35,6 +35,7 @@ typedef enum { MODE_QUESTION, MODE_TEXTINFO, MODE_WARNING, + MODE_INFO, MODE_LAST } ZenityDialogMode; @@ -55,6 +56,7 @@ enum { OPTION_CALENDAR = 1, OPTION_ENTRY, OPTION_ERROR, + OPTION_INFO, OPTION_FILE, OPTION_LIST, OPTION_PROGRESS, @@ -71,6 +73,7 @@ enum { OPTION_INPUTTEXT, OPTION_HIDETEXT, OPTION_ERRORTEXT, + OPTION_INFOTEXT, OPTION_FILENAME, OPTION_COLUMN, OPTION_CHECKLIST, @@ -128,6 +131,15 @@ struct poptOption options[] = { N_("Display error dialog"), NULL }, + { + "info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_INFO, + N_("Display info dialog"), + NULL + }, { "file-selection", '\0', @@ -327,6 +339,28 @@ struct poptOption error_options[] = { POPT_TABLEEND }; +struct poptOption info_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INFOTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND +}; + struct poptOption file_selection_options[] = { { NULL, @@ -545,6 +579,15 @@ struct poptOption application_options[] = { N_("Text entry options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + info_options, + 0, + N_("Info options"), + NULL + }, { NULL, '\0', @@ -673,6 +716,7 @@ zenity_free_parsing_options (void) { case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: g_free (results->msg_data->dialog_text); break; case MODE_FILE: @@ -730,6 +774,7 @@ main (gint argc, gchar **argv) { case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: zenity_msg (results->data, results->msg_data); break; case MODE_FILE: @@ -779,6 +824,10 @@ void zenity_parse_options_callback (poptContext ctx, results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; + case OPTION_INFO: + results->mode = MODE_INFO; + results->msg_data->mode = ZENITY_MSG_INFO; + break; case OPTION_FILE: results->mode = MODE_FILE; break; @@ -821,6 +870,7 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: + case MODE_INFO: results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: diff --git a/src/msg.c b/src/msg.c index a8e5c2de..5b2cba96 100644 --- a/src/msg.c +++ b/src/msg.c @@ -52,6 +52,12 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); break; + + case ZENITY_MSG_INFO: + glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + break; default: g_assert_not_reached (); @@ -81,6 +87,9 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) case ZENITY_MSG_ERROR: zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); break; + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); + break; default: break; } diff --git a/src/zenity.glade b/src/zenity.glade index e4e1b1f6..bb9a5192 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -998,4 +998,115 @@ + + True + Information + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_CENTER + False + False + False + True + + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 6 + True + False + 0 + + + + True + False + 0 + + + + True + gtk-dialog-info + 6 + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + You have done the right thing, hurrah. + False + True + GTK_JUSTIFY_LEFT + False + False + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + 0 + True + True + + + + + + diff --git a/src/zenity.h b/src/zenity.h index ea04b026..897857f5 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -38,7 +38,8 @@ typedef struct { typedef enum { ZENITY_MSG_WARNING, ZENITY_MSG_QUESTION, - ZENITY_MSG_ERROR + ZENITY_MSG_ERROR, + ZENITY_MSG_INFO } MsgMode; typedef struct { -- cgit From d88a32f1f5418e97b5840087a21652f68ac938c8 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 6 Jan 2003 21:58:21 +0000 Subject: Finish off commandline parsing for the list dialog. Wow, this is almost 2003-01-06 Glynn Foster * src/main.c, src/tree.c, src/zenity.h: Finish off commandline parsing for the list dialog. Wow, this is almost approaching usable ;) * TODO: Update accordingly --- src/main.c | 2 ++ src/tree.c | 40 +++++++++++++++++++++++++++------------- src/zenity.h | 1 + 3 files changed, 30 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 334c20df..86f4aaa7 100644 --- a/src/main.c +++ b/src/main.c @@ -735,6 +735,7 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { + char **args; poptContext ctx; int nextopt; ZenityData *general; @@ -781,6 +782,7 @@ main (gint argc, gchar **argv) { zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: + results->tree_data->data = poptGetArgs (ctx); zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: diff --git a/src/tree.c b/src/tree.c index 6e8709ce..9308ab71 100644 --- a/src/tree.c +++ b/src/tree.c @@ -63,21 +63,32 @@ count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, g } static void -zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv) +zenity_tree_fill_entries (GtkTreeView *tree_view, gchar **args, gint n_columns, gboolean toggles) { GtkTreeModel *model; GtkTreeIter iter; gint i = 0; model = gtk_tree_view_get_model (tree_view); - gtk_tree_model_foreach (model, count_rows_foreach, &i); + /* gtk_tree_model_foreach (model, count_rows_foreach, &i); */ + + while (args[i] != NULL) { + gint j; - while (i<10) { gtk_list_store_append (GTK_LIST_STORE (model), &iter); - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - 0, "TRUE", - 1, "This is the bar above foobar", -1); + for (j = 0; j < n_columns; j++) { + + if (toggles && j == 0) { + if (strcmp (args[i+j], "TRUE") == 0 || strcmp (args[i+j], "true") == 0) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); + } + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); + } + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { GtkWidget *scrolled_window; GtkRequisition rectangle; @@ -88,8 +99,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv) gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); } + i += n_columns; - i++; } } @@ -103,7 +114,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) GType *column_types; GSList *tmp; gboolean first_column = FALSE; - gint i, column_index, column_n; + gint i, column_index, n_columns; glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); @@ -124,14 +135,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); - column_n = g_slist_length (tree_data->columns); + n_columns = g_slist_length (tree_data->columns); /* Create an empty list store */ model = g_object_new (GTK_TYPE_LIST_STORE, NULL); - column_types = g_new (GType, column_n); + column_types = g_new (GType, n_columns); - for (i = 0; i < column_n; i++) { + for (i = 0; i < n_columns; i++) { /* Have the limitation that the radioboxes and checkboxes are in the first column */ if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) column_types[i] = G_TYPE_BOOLEAN; @@ -139,7 +150,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) column_types[i] = G_TYPE_STRING; } - gtk_list_store_set_column_types (model, column_n, column_types); + gtk_list_store_set_column_types (model, n_columns, column_types); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); @@ -188,7 +199,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); - /* zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL); */ + if (tree_data->radiobox || tree_data->checkbox) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE); + else + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE); gtk_widget_show (dialog); gtk_main (); diff --git a/src/zenity.h b/src/zenity.h index 897857f5..697a17cd 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -73,6 +73,7 @@ typedef struct { GSList *columns; gboolean checkbox; gboolean radiobox; + gchar **data; } ZenityTreeData; int zenity_calendar (ZenityData *data, -- cgit From a8c3006035a068069ed9199400472332db540bb5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 00:01:00 +0000 Subject: Improve error handling... a lot. 2003-01-06 Glynn Foster * src/calendar.c, src/main.c, src/progress.c, src/tree.c, src/zenity.h: Improve error handling... a lot. --- src/calendar.c | 4 +- src/main.c | 170 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/progress.c | 2 +- src/tree.c | 2 +- src/zenity.h | 2 +- 5 files changed, 169 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 4cdf4811..0264ce17 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -55,9 +55,9 @@ int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); - if (cal_data->month != 0 && cal_data->year !=0) + if (cal_data->month > 0 && cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); - if (cal_data->day) + if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); diff --git a/src/main.c b/src/main.c index 86f4aaa7..aad777e4 100644 --- a/src/main.c +++ b/src/main.c @@ -680,6 +680,7 @@ zenity_init_parsing_options (void) { results = g_new0 (ZenityParsingOptions, 1); /* Initialize the various dialog structures */ + results->mode = MODE_LAST; results->data = g_new0 (ZenityData, 1); results->calendar_data = g_new0 (ZenityCalendarData, 1); results->msg_data = g_new0 (ZenityMsgData, 1); @@ -690,6 +691,10 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* Give some sensible defaults */ + results->calendar_data->day = 0; + results->calendar_data->month = 0; + results->calendar_data->year = 0; + results->progress_data->percentage = -1; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; @@ -760,6 +765,11 @@ main (gint argc, gchar **argv) { while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); + exit (1); + } + gtk_init (&argc, &argv); if (argc < 2) @@ -807,7 +817,6 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - gint i = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; } @@ -817,43 +826,91 @@ void zenity_parse_options_callback (poptContext ctx, switch (opt->val & POPT_ARG_MASK) { case OPTION_CALENDAR: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_ENTRY; break; case OPTION_ERROR: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; case OPTION_INFO: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; break; case OPTION_FILE: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_FILE; break; case OPTION_LIST: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_LIST; break; case OPTION_PROGRESS: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; break; case OPTION_TEXTINFO: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; break; case OPTION_TITLE: + if (results->data->dialog_title != NULL) { + g_printerr (_("--title given twice for the same dialog\n")); + exit (1); + } results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: + if (results->data->window_icon != NULL) { + g_printerr (_("--window-icon given twice for the same dialog\n")); + exit (1); + } results->data->window_icon = g_strdup (arg); break; case OPTION_CALENDARTEXT: @@ -864,72 +921,173 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_WARNINGTEXT: switch (results->mode) { case MODE_CALENDAR: + if (results->calendar_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: + if (results->entry_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->entry_data->dialog_text = g_strdup (arg); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: + if (results->msg_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: + if (results->progress_data->dialog_text != NULL) { + g_printerr (_("--text given twice for the same dialog\n")); + exit (1); + } results->progress_data->dialog_text = g_strdup (arg); break; default: - break; + g_printerr (_("--text is not supported for this dialog\n")); + exit (1); } break; case OPTION_DAY: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--day is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->day > 0) { + g_printerr (_("--day given twice for the same dialog\n")); + exit (1); + } results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--month is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->month > 0) { + g_printerr (_("--month given twice for the same dialog\n")); + exit (1); + } results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--year is not supported for this dialog\n")); + exit (1); + } + if (results->calendar_data->year > 0) { + g_printerr (_("--year given twice for the same dialog\n")); + exit (1); + } results->calendar_data->year = atoi (arg); break; case OPTION_INPUTTEXT: + if (results->mode != MODE_ENTRY) { + g_printerr (_("--entry-text is not supported for this dialog\n")); + exit (1); + } + if (results->entry_data->entry_text != NULL) { + g_printerr (_("--entry-text given twice for the same dialog\n")); + exit (1); + } results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: + if (results->mode != MODE_ENTRY) { + g_printerr (_("--hide-text is not supported for this dialog\n")); + exit (1); + } + if (results->entry_data->visible == FALSE) { + g_printerr (_("--hide-text given twice for the same dialog\n")); + exit (1); + } results->entry_data->visible = FALSE; break; case OPTION_FILENAME: case OPTION_TEXTFILE: switch (results->mode) { case MODE_FILE: + if (results->file_data->uri != NULL) { + g_printerr (_("--filename given twice for the same dialog\n")); + exit (1); + } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: + if (results->text_data->uri != NULL) { + g_printerr (_("--filename given twice for the same dialog\n")); + exit (1); + } results->text_data->uri = g_strdup (arg); break; default: - break; + g_printerr (_("--filename is not supported for this dialog\n")); + exit (1); } break; case OPTION_COLUMN: + if (results->mode != MODE_LIST) { + g_printerr (_("--column is not supported for this dialog\n")); + exit (1); + } results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: + if (results->mode != MODE_LIST) { + g_printerr (_("--checkbox is not supported for this dialog\n")); + exit (1); + } + if (results->tree_data->checkbox == TRUE) { + g_printerr (_("--checkbox given twice for the same dialog\n")); + exit (1); + } results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: + if (results->mode != MODE_LIST) { + g_printerr (_("--radiobox is not supported for this dialog\n")); + exit (1); + } + if (results->tree_data->radiobox == TRUE) { + g_printerr (_("--radiobox given twice for the same dialog\n")); + exit (1); + } results->tree_data->radiobox = TRUE; break; case OPTION_PERCENTAGE: + if (results->mode != MODE_PROGRESS) { + g_printerr (_("--percentage is not supported for this dialog\n")); + exit (1); + } + if (results->progress_data->percentage > -1) { + g_printerr (_("--percentage given twice for the same dialog\n")); + exit (1); + } results->progress_data->percentage = atoi (arg); break; case OPTION_ABOUT: - results->mode = MODE_LAST; + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } break; case OPTION_VERSION: - results->mode = MODE_LAST; + if (results->mode != MODE_LAST) { + g_printerr (_("Two or more dialog options specified\n")); + exit (1); + } g_print ("%s\n", VERSION); break; default: - break; + g_warning ("Invalid option %s", arg); + exit (1); } } diff --git a/src/progress.c b/src/progress.c index 21305917..a890059b 100644 --- a/src/progress.c +++ b/src/progress.c @@ -74,7 +74,7 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) giochannel = g_io_channel_unix_new (0); - if (progress_data->pulsate != TRUE) { + if (progress_data->pulsate != TRUE && progress_data->percentage > -1) { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); } else { diff --git a/src/tree.c b/src/tree.c index 9308ab71..01be45cd 100644 --- a/src/tree.c +++ b/src/tree.c @@ -63,7 +63,7 @@ count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, g } static void -zenity_tree_fill_entries (GtkTreeView *tree_view, gchar **args, gint n_columns, gboolean toggles) +zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles) { GtkTreeModel *model; GtkTreeIter iter; diff --git a/src/zenity.h b/src/zenity.h index 697a17cd..e3387608 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -73,7 +73,7 @@ typedef struct { GSList *columns; gboolean checkbox; gboolean radiobox; - gchar **data; + const gchar **data; } ZenityTreeData; int zenity_calendar (ZenityData *data, -- cgit From 952fc14e7b0178d035de38106711953485aa9490 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 00:30:03 +0000 Subject: Fix up the error returns. 2003-01-07 Glynn Foster * src/main.c: Fix up the error returns. * TODO: Update accordingly. --- src/main.c | 176 +++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 114 insertions(+), 62 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index aad777e4..dc341c42 100644 --- a/src/main.c +++ b/src/main.c @@ -712,26 +712,33 @@ zenity_free_parsing_options (void) { /* Dialog options */ switch (results->mode) { case MODE_CALENDAR: - g_free (results->calendar_data->dialog_text); + if (results->calendar_data->dialog_text) + g_free (results->calendar_data->dialog_text); break; case MODE_ENTRY: - g_free (results->entry_data->dialog_text); - g_free (results->entry_data->entry_text); + if (results->entry_data->dialog_text) + g_free (results->entry_data->dialog_text); + if (results->entry_data->entry_text) + g_free (results->entry_data->entry_text); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - g_free (results->msg_data->dialog_text); + if (results->msg_data->dialog_text) + g_free (results->msg_data->dialog_text); break; case MODE_FILE: - g_free (results->file_data->uri); + if (results->file_data->uri) + g_free (results->file_data->uri); break; case MODE_TEXTINFO: - g_free (results->text_data->uri); + if (results->text_data->uri) + g_free (results->text_data->uri); break; case MODE_LIST: - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->columns) + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); break; default: break; @@ -740,11 +747,11 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { - char **args; - poptContext ctx; - int nextopt; ZenityData *general; ZenityCalendarData *cal_data; + poptContext ctx; + char **args; + int nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); @@ -760,49 +767,54 @@ main (gint argc, gchar **argv) { */ ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - poptSetOtherOptionHelp(ctx, "[OPTIONS] ..."); + poptReadDefaultConfig(ctx, TRUE); while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; if (nextopt != -1) { g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); - exit (1); + zenity_free_parsing_options (); + exit (-1); } gtk_init (&argc, &argv); - if (argc < 2) - exit (1); + if (argc < 2) { + zenity_free_parsing_options (); + exit (-1); + } switch (results->mode) { case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); + retval = zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: - zenity_entry (results->data, results->entry_data); + retval = zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - zenity_msg (results->data, results->msg_data); + retval = zenity_msg (results->data, results->msg_data); break; case MODE_FILE: - zenity_fileselection (results->data, results->file_data); + retval = zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: results->tree_data->data = poptGetArgs (ctx); - zenity_tree (results->data, results->tree_data); + retval = zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); + retval = zenity_progress (results->data, results->progress_data); break; case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); + retval = zenity_text (results->data, results->text_data); break; default: - break; + g_assert_not_reached (); + zenity_free_parsing_options (); + exit (-1); } poptFreeContext(ctx); @@ -828,21 +840,24 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_CALENDAR: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_ENTRY; break; case OPTION_ERROR: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; @@ -850,7 +865,8 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_INFO: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; @@ -858,28 +874,32 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_FILE: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_FILE; break; case OPTION_LIST: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_LIST; break; case OPTION_PROGRESS: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; @@ -887,14 +907,16 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TEXTINFO: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; @@ -902,14 +924,16 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TITLE: if (results->data->dialog_title != NULL) { g_printerr (_("--title given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: if (results->data->window_icon != NULL) { g_printerr (_("--window-icon given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->data->window_icon = g_strdup (arg); break; @@ -923,14 +947,16 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_CALENDAR: if (results->calendar_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: if (results->entry_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->dialog_text = g_strdup (arg); break; @@ -940,74 +966,87 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_INFO: if (results->msg_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: if (results->progress_data->dialog_text != NULL) { g_printerr (_("--text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->progress_data->dialog_text = g_strdup (arg); break; default: g_printerr (_("--text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { g_printerr (_("--day is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->day > 0) { g_printerr (_("--day given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: if (results->mode != MODE_CALENDAR) { g_printerr (_("--month is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->month > 0) { g_printerr (_("--month given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: if (results->mode != MODE_CALENDAR) { g_printerr (_("--year is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->calendar_data->year > 0) { g_printerr (_("--year given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->calendar_data->year = atoi (arg); break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--entry-text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->entry_data->entry_text != NULL) { g_printerr (_("--entry-text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--hide-text is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->entry_data->visible == FALSE) { g_printerr (_("--hide-text given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->entry_data->visible = FALSE; break; @@ -1017,77 +1056,90 @@ void zenity_parse_options_callback (poptContext ctx, case MODE_FILE: if (results->file_data->uri != NULL) { g_printerr (_("--filename given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: if (results->text_data->uri != NULL) { g_printerr (_("--filename given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->text_data->uri = g_strdup (arg); break; default: g_printerr (_("--filename is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { g_printerr (_("--column is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: if (results->mode != MODE_LIST) { g_printerr (_("--checkbox is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->tree_data->checkbox == TRUE) { g_printerr (_("--checkbox given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: if (results->mode != MODE_LIST) { g_printerr (_("--radiobox is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->tree_data->radiobox == TRUE) { g_printerr (_("--radiobox given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->tree_data->radiobox = TRUE; break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) { g_printerr (_("--percentage is not supported for this dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } if (results->progress_data->percentage > -1) { g_printerr (_("--percentage given twice for the same dialog\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } results->progress_data->percentage = atoi (arg); break; case OPTION_ABOUT: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } break; case OPTION_VERSION: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); - exit (1); + zenity_free_parsing_options (); + exit (-1); } g_print ("%s\n", VERSION); break; default: g_warning ("Invalid option %s", arg); - exit (1); + zenity_free_parsing_options (); + exit (-1); } } -- cgit From 6a65d75921d352323277f770f357ca3065436133 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Jan 2003 13:22:57 +0000 Subject: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 2003-01-07 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.glade, src/zenity.h: Fix up the response signal handlers. Use returns of 0 for 'Ok' and 'Close', 1 for 'Cancel' and 'Escape' and -1 for 'Uh Oh'. Get stuff printing to stderr. Fix up the error handling that I thought was improved, although still have issues with popt callback getting called numerous times because of more than one instance of the same kind is being used in poptOption. * TODO: Update accordingly. --- src/calendar.c | 44 +++++++++++++++++++++++++++--------------- src/entry.c | 39 +++++++++++++++++++++++-------------- src/fileselection.c | 34 ++++++++++++++++++++------------- src/main.c | 55 +++++++++++++++-------------------------------------- src/msg.c | 33 +++++++++++++++++++------------- src/progress.c | 33 +++++++++++++++++++------------- src/text.c | 32 ++++++++++++++++++------------- src/tree.c | 26 +++++++++++++++---------- src/zenity.glade | 10 ---------- src/zenity.h | 15 ++++++++------- 10 files changed, 173 insertions(+), 148 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 0264ce17..df5d35c1 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -25,23 +25,32 @@ #include "zenity.h" #include "util.h" -void zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data); -int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) +static GtkWidget *calendar; + +static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); + +void +zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { GladeXML *glade_dialog = NULL; GtkWidget *dialog; - GtkWidget *calendar; GtkWidget *text; glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_calendar_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -55,36 +64,41 @@ int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + if (glade_dialog) + g_object_unref (glade_dialog); + if (cal_data->month > 0 && cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year); + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; + guint day, month, year; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + g_printerr ("%02d/%02d/%02d\n", day, month + 1, year); + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + /* Esc dialog */ + zen_data->exit_code = 1; break; } } diff --git a/src/entry.c b/src/entry.c index 3816a502..81fc2c5e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -25,23 +25,31 @@ #include "zenity.h" #include "util.h" -void zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_entry (ZenityData *data, ZenityEntryData *entry_data) +static GtkWidget *entry; + +void +zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { GladeXML *glade_dialog = NULL; GtkWidget *dialog; GtkWidget *text; - GtkWidget *entry; glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_entry_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -57,6 +65,9 @@ int zenity_entry (ZenityData *data, ZenityEntryData *entry_data) entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + if (glade_dialog) + g_object_unref (glade_dialog); + if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); @@ -67,28 +78,28 @@ int zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + /* Esc dialog */ + zen_data->exit_code = 1; break; } } diff --git a/src/fileselection.c b/src/fileselection.c index 52c0021a..74122f87 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -25,21 +25,30 @@ #include "zenity.h" #include "util.h" -void zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_fileselection (ZenityData *data, ZenityFileData *file_data) +void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { GladeXML *glade_dialog; GtkWidget *dialog; glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); + + if (glade_dialog) + g_object_unref (glade_dialog); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_fileselection_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -53,28 +62,27 @@ int zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } diff --git a/src/main.c b/src/main.c index dc341c42..f60eb7f0 100644 --- a/src/main.c +++ b/src/main.c @@ -694,6 +694,7 @@ zenity_init_parsing_options (void) { results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; + results->calendar_data->dialog_text = NULL; results->progress_data->percentage = -1; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; @@ -750,8 +751,8 @@ main (gint argc, gchar **argv) { ZenityData *general; ZenityCalendarData *cal_data; poptContext ctx; - char **args; - int nextopt, retval; + gchar **args; + gint nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); @@ -787,29 +788,29 @@ main (gint argc, gchar **argv) { switch (results->mode) { case MODE_CALENDAR: - retval = zenity_calendar (results->data, results->calendar_data); + zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: - retval = zenity_entry (results->data, results->entry_data); + zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - retval = zenity_msg (results->data, results->msg_data); + zenity_msg (results->data, results->msg_data); break; case MODE_FILE: - retval = zenity_fileselection (results->data, results->file_data); + zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: results->tree_data->data = poptGetArgs (ctx); - retval = zenity_tree (results->data, results->tree_data); + zenity_tree (results->data, results->tree_data); break; case MODE_PROGRESS: - retval = zenity_progress (results->data, results->progress_data); + zenity_progress (results->data, results->progress_data); break; case MODE_TEXTINFO: - retval = zenity_text (results->data, results->text_data); + zenity_text (results->data, results->text_data); break; default: g_assert_not_reached (); @@ -817,9 +818,10 @@ main (gint argc, gchar **argv) { exit (-1); } + retval = results->data->exit_code; poptFreeContext(ctx); zenity_free_parsing_options (); - exit (0); + exit (retval); } static @@ -945,38 +947,18 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_WARNINGTEXT: switch (results->mode) { case MODE_CALENDAR: - if (results->calendar_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->calendar_data->dialog_text = g_strdup (arg); break; case MODE_ENTRY: - if (results->entry_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->entry_data->dialog_text = g_strdup (arg); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - if (results->msg_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->msg_data->dialog_text = g_strdup (arg); break; case MODE_PROGRESS: - if (results->progress_data->dialog_text != NULL) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->progress_data->dialog_text = g_strdup (arg); break; default: @@ -1054,19 +1036,9 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_TEXTFILE: switch (results->mode) { case MODE_FILE: - if (results->file_data->uri != NULL) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->file_data->uri = g_strdup (arg); break; case MODE_TEXTINFO: - if (results->text_data->uri != NULL) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } results->text_data->uri = g_strdup (arg); break; default: @@ -1128,6 +1100,8 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + g_print ("This does nothing at the moment\n"); + exit (0); break; case OPTION_VERSION: if (results->mode != MODE_LAST) { @@ -1136,6 +1110,7 @@ void zenity_parse_options_callback (poptContext ctx, exit (-1); } g_print ("%s\n", VERSION); + exit (0); break; default: g_warning ("Invalid option %s", arg); diff --git a/src/msg.c b/src/msg.c index 5b2cba96..bb7190fc 100644 --- a/src/msg.c +++ b/src/msg.c @@ -25,9 +25,10 @@ #include "zenity.h" #include "util.h" -void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) +void +zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { GladeXML *glade_dialog; GtkWidget *dialog; @@ -64,8 +65,16 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog) + g_object_unref (glade_dialog); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); + + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); @@ -99,28 +108,26 @@ int zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } diff --git a/src/progress.c b/src/progress.c index a890059b..349072a3 100644 --- a/src/progress.c +++ b/src/progress.c @@ -32,7 +32,7 @@ static GladeXML *glade_dialog; static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); -void zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data); gint zenity_progress_timeout (gpointer data) @@ -41,7 +41,8 @@ zenity_progress_timeout (gpointer data) return TRUE; } -int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) +void +zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; GtkWidget *text; @@ -51,12 +52,17 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_progress_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -72,6 +78,9 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + if (glade_dialog) + g_object_unref (glade_dialog); + giochannel = g_io_channel_unix_new (0); if (progress_data->pulsate != TRUE && progress_data->percentage > -1) { @@ -85,11 +94,6 @@ int zenity_progress (ZenityData *data, ZenityProgressData *progress_data) g_io_channel_unref (giochannel); gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } static gboolean @@ -119,21 +123,24 @@ zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, g /* FIXME: Do nothing at the moment */ } -void -zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } diff --git a/src/text.c b/src/text.c index 0d2dbe11..ead35ec2 100644 --- a/src/text.c +++ b/src/text.c @@ -25,9 +25,10 @@ #include "zenity.h" #include "util.h" -void zenity_text_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data); -int zenity_text (ZenityData *data, ZenityTextData *text_data) +void +zenity_text (ZenityData *data, ZenityTextData *text_data) { GladeXML *glade_dialog = NULL; GtkWidget *dialog; @@ -36,13 +37,21 @@ int zenity_text (ZenityData *data, ZenityTextData *text_data) glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); + if (glade_dialog) + g_object_unref (glade_dialog); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_text_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -60,24 +69,21 @@ int zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_widget_show (dialog); gtk_main (); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_text_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_CLOSE: + zen_data->exit_code = 0; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } diff --git a/src/tree.c b/src/tree.c index 01be45cd..401fbe00 100644 --- a/src/tree.c +++ b/src/tree.c @@ -31,7 +31,7 @@ static GladeXML *glade_dialog; -void zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data); +static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data) @@ -104,7 +104,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col } } -int +void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { GtkWidget *dialog; @@ -118,13 +118,18 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); - if (glade_dialog == NULL) - return FALSE; + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_tree_dialog_response), data); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -209,25 +214,26 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (glade_dialog) g_object_unref (glade_dialog); - - return TRUE; } -void -zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data) +static void +zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { - GError *error = NULL; + ZenityData *zen_data = data; - switch (button) { + switch (response) { case GTK_RESPONSE_OK: + zen_data->exit_code = 0; gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; gtk_main_quit (); break; default: + zen_data->exit_code = 1; break; } } diff --git a/src/zenity.glade b/src/zenity.glade index bb9a5192..9e272fa1 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -12,7 +12,6 @@ False False True - @@ -157,7 +156,6 @@ False False True - @@ -269,7 +267,6 @@ False False True - @@ -301,7 +298,6 @@ False False True - @@ -412,7 +408,6 @@ False False True - @@ -543,7 +538,6 @@ True False True - @@ -637,7 +631,6 @@ False False True - @@ -760,7 +753,6 @@ False False True - @@ -873,7 +865,6 @@ True False True - @@ -1007,7 +998,6 @@ False False True - diff --git a/src/zenity.h b/src/zenity.h index e3387608..9df373c5 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -26,6 +26,7 @@ G_BEGIN_DECLS typedef struct { gchar *dialog_title; gchar *window_icon; + gint exit_code; } ZenityData; typedef struct { @@ -76,19 +77,19 @@ typedef struct { const gchar **data; } ZenityTreeData; -int zenity_calendar (ZenityData *data, +void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data); -int zenity_msg (ZenityData *data, +void zenity_msg (ZenityData *data, ZenityMsgData *msg_data); -int zenity_fileselection (ZenityData *data, +void zenity_fileselection (ZenityData *data, ZenityFileData *file_data); -int zenity_entry (ZenityData *data, +void zenity_entry (ZenityData *data, ZenityEntryData *entry_data); -int zenity_progress (ZenityData *data, +void zenity_progress (ZenityData *data, ZenityProgressData *progress_data); -int zenity_text (ZenityData *data, +void zenity_text (ZenityData *data, ZenityTextData *text_data); -int zenity_tree (ZenityData *data, +void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); G_END_DECLS -- cgit From cd4e438bfb3ebfd3cc872e203e343a50acc02a15 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 9 Jan 2003 18:07:04 +0000 Subject: Fix up the date string, although I guess this should be localized. 2003-01-09 Glynn Foster * src/calendar.c: Fix up the date string, although I guess this should be localized. * src/main.c: Add a new --pulsate option, which reads from stdin and pulsates the progress bar until we reach EOF. * src/progress.c: Rewrite to actually work. Don't really need GIOChannels here. * TODO: Updated accordingly. --- src/calendar.c | 2 +- src/main.c | 19 +++++++++++ src/progress.c | 102 +++++++++++++++++++++++++++++++++++++-------------------- 3 files changed, 87 insertions(+), 36 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index df5d35c1..4d521be2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,7 +86,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - g_printerr ("%02d/%02d/%02d\n", day, month + 1, year); + g_printerr ("%02d/%02d/%02d\n", year, month + 1, day); zen_data->exit_code = 0; gtk_main_quit (); break; diff --git a/src/main.c b/src/main.c index f60eb7f0..53cfc992 100644 --- a/src/main.c +++ b/src/main.c @@ -80,6 +80,7 @@ enum { OPTION_RADIOLIST, OPTION_PROGRESSTEXT, OPTION_PERCENTAGE, + OPTION_PULSATE, OPTION_QUESTIONTEXT, OPTION_TEXTFILE, OPTION_WARNINGTEXT, @@ -451,6 +452,15 @@ struct poptOption progress_options[] = { N_("Set initial percentage"), NULL }, + { + "pulsate", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PULSATE, + N_("Pulsate progress bar"), + NULL + }, POPT_TABLEEND }; @@ -696,6 +706,7 @@ zenity_init_parsing_options (void) { results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; results->progress_data->percentage = -1; + results->progress_data->pulsate = FALSE; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; @@ -1094,6 +1105,14 @@ void zenity_parse_options_callback (poptContext ctx, } results->progress_data->percentage = atoi (arg); break; + case OPTION_PULSATE: + if (results->mode != MODE_PROGRESS) { + g_printerr (_("--pulsate is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->progress_data->pulsate = TRUE; + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) { g_printerr (_("Two or more dialog options specified\n")); diff --git a/src/progress.c b/src/progress.c index 349072a3..bf730bcd 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,25 +29,17 @@ static guint timer; static GladeXML *glade_dialog; -static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); -static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data); +gint zenity_progress_timeout (gpointer data); +gint zenity_progress_pulsate_timeout (gpointer data); static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data); -gint -zenity_progress_timeout (gpointer data) -{ - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); - return TRUE; -} - void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; GtkWidget *text; GtkWidget *progress_bar; - GIOChannel *giochannel; guint input; glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); @@ -78,49 +70,89 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); - if (glade_dialog) - g_object_unref (glade_dialog); - - giochannel = g_io_channel_unix_new (0); - - if (progress_data->pulsate != TRUE && progress_data->percentage > -1) { - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); - } - else { - input = g_io_add_watch (giochannel, G_IO_IN | G_IO_HUP, zenity_progress_pulsate_bar, NULL); - timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); - } + if (progress_data->percentage > -1) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), + progress_data->percentage/100.0); - g_io_channel_unref (giochannel); gtk_widget_show (dialog); + if (progress_data->pulsate != TRUE) + timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); + else + timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar); + gtk_main (); } -static gboolean -zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data) +gint +zenity_progress_timeout (gpointer data) { - gchar buf[1024]; + gchar buffer[256]; + float percentage; + + while(gtk_events_pending()) { + gtk_main_iteration(); - if (!feof (stdin)) { + if (timer == 0) + return FALSE; + } + + if (scanf ("%255s", buffer) == EOF) { GtkWidget *button; - gtk_timeout_remove (timer); - g_io_channel_shutdown (giochannel, 0, NULL); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); gtk_widget_set_sensitive (button, TRUE); gtk_widget_grab_focus (button); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); gtk_widget_set_sensitive (button, FALSE); + + if (glade_dialog) + g_object_unref (glade_dialog); + return FALSE; + } else { + percentage = atoi (buffer); + + if (percentage > 100) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); + else + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0); + + return TRUE; } - - fgets (buf, sizeof (buf)-1, stdin); - return TRUE; } -static gboolean -zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data) +gint +zenity_progress_pulsate_timeout (gpointer data) { - /* FIXME: Do nothing at the moment */ + + while(gtk_events_pending()) { + gtk_main_iteration(); + + if (timer == 0) + return FALSE; + } + + if (feof (stdin)) { + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); + + return FALSE; + } else { + GtkWidget *button; + + /* We stop the pulsating and switch the focus on the dialog buttons */ + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); + + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); + + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + gtk_widget_set_sensitive (button, FALSE); + + return TRUE; + } } static void -- cgit From 69636459e1faf1ce41685550cf7aec59acfbac39 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 16:48:45 +0000 Subject: Improve error handling. Make --list actually return something useful, 2003-01-13 Glynn Foster * src/main.c: Improve error handling. * src/tree.c: Make --list actually return something useful, although I still need to actually seperate things out so it's actually decipherable. * TODO: Update accordingly. --- src/main.c | 17 ++++++++++++++++ src/tree.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++------------ 2 files changed, 70 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 53cfc992..03f6d4c6 100644 --- a/src/main.c +++ b/src/main.c @@ -842,6 +842,9 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { + static gboolean parse_option_text = FALSE; + static gboolean parse_option_file = FALSE; + if (reason == POPT_CALLBACK_REASON_POST) { return; } @@ -956,6 +959,12 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: case OPTION_WARNINGTEXT: + if (parse_option_text == TRUE) { + g_printerr (_("--text given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + switch (results->mode) { case MODE_CALENDAR: results->calendar_data->dialog_text = g_strdup (arg); @@ -977,6 +986,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + parse_option_text = TRUE; break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { @@ -1045,6 +1055,12 @@ void zenity_parse_options_callback (poptContext ctx, break; case OPTION_FILENAME: case OPTION_TEXTFILE: + if (parse_option_file == TRUE) { + g_printerr (_("--filename given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + switch (results->mode) { case MODE_FILE: results->file_data->uri = g_strdup (arg); @@ -1057,6 +1073,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + parse_option_file = TRUE; break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { diff --git a/src/tree.c b/src/tree.c index 401fbe00..2b310023 100644 --- a/src/tree.c +++ b/src/tree.c @@ -53,15 +53,6 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g gtk_tree_path_free (path); } -static gboolean -count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) -{ - gint *rows = data; - - (*rows)++; - return FALSE; -} - static void zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles) { @@ -70,7 +61,6 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col gint i = 0; model = gtk_tree_view_get_model (tree_view); - /* gtk_tree_model_foreach (model, count_rows_foreach, &i); */ while (args[i] != NULL) { gint j; @@ -123,6 +113,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } + n_columns = g_slist_length (tree_data->columns); + + if (n_columns == 0) { + g_printerr (_("No column titles specified for --list\n")); + data->exit_code = -1; + return; + } + glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); @@ -140,8 +138,6 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); - n_columns = g_slist_length (tree_data->columns); - /* Create an empty list store */ model = g_object_new (GTK_TYPE_LIST_STORE, NULL); @@ -216,13 +212,58 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) g_object_unref (glade_dialog); } +static void +zenity_tree_dialog_output (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) +{ + GValue value = {0, }; + + gtk_tree_model_get_value (model, iter, 0, &value); + + g_printerr ("%s", g_value_get_string (&value)); + g_value_unset (&value); +} + +static gboolean +zenity_tree_dialog_toggle_output (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +{ + GValue toggle_value = {0, }; + + gtk_tree_model_get_value (model, iter, 0, &toggle_value); + + if (g_value_get_boolean (&toggle_value) == TRUE) { + GValue value = {0, }; + gtk_tree_model_get_value (model, iter, 1, &value); + g_printerr ("%s", g_value_get_string (&value)); + g_value_unset (&value); + } + g_value_unset (&toggle_value); + return FALSE; +} + static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; + GtkWidget *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; switch (response) { case GTK_RESPONSE_OK: + tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + + if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) { + gtk_tree_model_foreach (model, + (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_output, + NULL); + } + else { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_output, + GTK_TREE_VIEW (tree_view)); + } zen_data->exit_code = 0; gtk_main_quit (); break; -- cgit From 9a77e41fecb3489b069aa7b1bb52ba56f1052819 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 13 Jan 2003 17:35:57 +0000 Subject: Localise output of --calendar dialog by default (using nl_langinfo), and provide a --date-format option to provide a strftime-style format for the returned date. --- src/calendar.c | 18 +++++++++++++----- src/main.c | 21 +++++++++++++++++++++ src/zenity.h | 3 ++- 3 files changed, 36 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 4d521be2..29768caa 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -22,6 +22,7 @@ */ #include +#include #include "zenity.h" #include "util.h" @@ -49,7 +50,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); + G_CALLBACK (zenity_calendar_dialog_response), cal_data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -80,13 +81,20 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - guint day, month, year; - + ZenityCalendarData *cal_data = data; + ZenityData *zen_data; + gint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - g_printerr ("%02d/%02d/%02d\n", year, month + 1, day); + date = g_date_new_dmy (year, month+1, day); + g_date_strftime (time_string, 127, + cal_data->date_format, date); + g_printerr ("%s\n",time_string); + g_date_free ( date ); zen_data->exit_code = 0; gtk_main_quit (); break; diff --git a/src/main.c b/src/main.c index 03f6d4c6..5b023112 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "config.h" #include "zenity.h" #include +#include typedef enum { MODE_CALENDAR, @@ -54,6 +55,7 @@ typedef struct { enum { OPTION_CALENDAR = 1, + OPTION_DATEFORMAT, OPTION_ENTRY, OPTION_ERROR, OPTION_INFO, @@ -275,6 +277,14 @@ struct poptOption calendar_options[] = { N_("Set the calendar year"), NULL }, + { "date-format", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_DATEFORMAT, + N_("Set the format for the returned date"), + NULL + }, POPT_TABLEEND }; @@ -701,6 +711,7 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* Give some sensible defaults */ + results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; @@ -726,6 +737,8 @@ zenity_free_parsing_options (void) { case MODE_CALENDAR: if (results->calendar_data->dialog_text) g_free (results->calendar_data->dialog_text); + if (results->calendar_data->date_format) + g_free (results->calendar_data->date_format); break; case MODE_ENTRY: if (results->entry_data->dialog_text) @@ -1027,6 +1040,14 @@ void zenity_parse_options_callback (poptContext ctx, } results->calendar_data->year = atoi (arg); break; + case OPTION_DATEFORMAT: + if (results->mode != MODE_CALENDAR) { + g_printerr (_("--date-format is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->calendar_data->date_format = g_strdup (arg); + break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { g_printerr (_("--entry-text is not supported for this dialog\n")); diff --git a/src/zenity.h b/src/zenity.h index 9df373c5..a3def00f 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -6,7 +6,7 @@ G_BEGIN_DECLS #ifdef ENABLE_NLS -#include +#include #define _(String) dgettext(GETTEXT_PACKAGE,String) #ifdef gettext_noop #define N_(String) gettext_noop(String) @@ -34,6 +34,7 @@ typedef struct { gint day; gint month; gint year; + gchar *date_format; } ZenityCalendarData; typedef enum { -- cgit From 1e0ff80be4b1fe6f2e6def15bfc02b2d09312061 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 18:16:50 +0000 Subject: Re-structure the code to pass in the ZenityData structure into the 2003-01-13 Glynn Foster * src/calendar.c: Re-structure the code to pass in the ZenityData structure into the response_callback instead. * src/main.c: Fix the screwups in the commandline parser due to popt being teh suck. * src/msg.c: Don't unref the GladeXML before you use it. * THANKS: New file. --- src/calendar.c | 19 ++++++++++++------- src/main.c | 31 +++++++++++++++++++++++++------ src/msg.c | 6 +++--- 3 files changed, 40 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 29768caa..65c2bf90 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -28,6 +28,7 @@ static GtkWidget *calendar; +static ZenityCalendarData *zen_cal_data; static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); @@ -38,6 +39,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) GtkWidget *dialog; GtkWidget *text; + zen_cal_data = cal_data; + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); if (glade_dialog == NULL) { @@ -50,7 +53,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), cal_data); + G_CALLBACK (zenity_calendar_dialog_response), data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -81,20 +84,22 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityCalendarData *cal_data = data; ZenityData *zen_data; gint day, month, year; gchar time_string[128]; GDate *date = NULL; - + + zen_data = data; + switch (response) { case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month+1, day); + date = g_date_new_dmy (year, month + 1, day); g_date_strftime (time_string, 127, - cal_data->date_format, date); - g_printerr ("%s\n",time_string); - g_date_free ( date ); + zen_cal_data->date_format, date); + g_printerr ("%s\n", time_string); + if (date != NULL) + g_date_free (date); zen_data->exit_code = 0; gtk_main_quit (); break; diff --git a/src/main.c b/src/main.c index 5b023112..3e58bd49 100644 --- a/src/main.c +++ b/src/main.c @@ -855,8 +855,9 @@ void zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - static gboolean parse_option_text = FALSE; - static gboolean parse_option_file = FALSE; + static gboolean parse_option_dateformat = FALSE; + static gint parse_option_text = 0; + static gint parse_option_file = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; @@ -972,7 +973,13 @@ void zenity_parse_options_callback (poptContext ctx, case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: case OPTION_WARNINGTEXT: - if (parse_option_text == TRUE) { + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_text > 6) { g_printerr (_("--text given twice for the same dialog\n")); zenity_free_parsing_options (); exit (-1); @@ -999,7 +1006,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - parse_option_text = TRUE; + parse_option_text++; break; case OPTION_DAY: if (results->mode != MODE_CALENDAR) { @@ -1046,7 +1053,13 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } + if (parse_option_dateformat == TRUE) { + g_printerr (_("--date-format given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } results->calendar_data->date_format = g_strdup (arg); + parse_option_dateformat = TRUE; break; case OPTION_INPUTTEXT: if (results->mode != MODE_ENTRY) { @@ -1076,7 +1089,13 @@ void zenity_parse_options_callback (poptContext ctx, break; case OPTION_FILENAME: case OPTION_TEXTFILE: - if (parse_option_file == TRUE) { + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) { g_printerr (_("--filename given twice for the same dialog\n")); zenity_free_parsing_options (); exit (-1); @@ -1094,7 +1113,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - parse_option_file = TRUE; + parse_option_file++; break; case OPTION_COLUMN: if (results->mode != MODE_LIST) { diff --git a/src/msg.c b/src/msg.c index bb7190fc..cc1f0924 100644 --- a/src/msg.c +++ b/src/msg.c @@ -65,9 +65,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (glade_dialog) - g_object_unref (glade_dialog); - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_msg_dialog_response), data); @@ -77,6 +74,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) } glade_xml_signal_autoconnect (glade_dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); -- cgit From 275dafc66e27aa179d09886f17635bda857038e0 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Jan 2003 18:32:26 +0000 Subject: Whitespace hacking. 2003-01-13 Glynn Foster * zenity.h: Whitespace hacking. --- src/zenity.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/zenity.h b/src/zenity.h index a3def00f..bedec33a 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -31,9 +31,9 @@ typedef struct { typedef struct { gchar *dialog_text; - gint day; - gint month; - gint year; + gint day; + gint month; + gint year; gchar *date_format; } ZenityCalendarData; @@ -46,7 +46,7 @@ typedef enum { typedef struct { gchar *dialog_text; - MsgMode mode; + MsgMode mode; } ZenityMsgData; typedef struct { @@ -83,15 +83,15 @@ void zenity_calendar (ZenityData *data, void zenity_msg (ZenityData *data, ZenityMsgData *msg_data); void zenity_fileselection (ZenityData *data, - ZenityFileData *file_data); + ZenityFileData *file_data); void zenity_entry (ZenityData *data, ZenityEntryData *entry_data); void zenity_progress (ZenityData *data, ZenityProgressData *progress_data); void zenity_text (ZenityData *data, - ZenityTextData *text_data); + ZenityTextData *text_data); void zenity_tree (ZenityData *data, - ZenityTreeData *tree_data); + ZenityTreeData *tree_data); G_END_DECLS -- cgit From f00eb34c0604dcf68457ab09278295f647c622b8 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 01:52:23 +0000 Subject: Add support to separate the selected rows output with a character with '/' 2003-01-14 Glynn Foster * src/tree.c, src/zenity.h, src/main.c: Add support to separate the selected rows output with a character with '/' used by default. --- src/main.c | 28 ++++++++++++++++++++++++++++ src/tree.c | 45 +++++++++++++++++++++++++++++++++++++-------- src/zenity.h | 1 + 3 files changed, 66 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 3e58bd49..26232327 100644 --- a/src/main.c +++ b/src/main.c @@ -78,6 +78,7 @@ enum { OPTION_INFOTEXT, OPTION_FILENAME, OPTION_COLUMN, + OPTION_SEPERATOR, OPTION_CHECKLIST, OPTION_RADIOLIST, OPTION_PROGRESSTEXT, @@ -431,6 +432,15 @@ struct poptOption list_options[] = { N_("Use radio buttons for first column"), NULL }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character"), + NULL + }, POPT_TABLEEND }; @@ -716,6 +726,7 @@ zenity_init_parsing_options (void) { results->calendar_data->month = 0; results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; + results->tree_data->separator = g_strdup ("/"); results->progress_data->percentage = -1; results->progress_data->pulsate = FALSE; results->entry_data->visible = TRUE; @@ -764,6 +775,8 @@ zenity_free_parsing_options (void) { case MODE_LIST: if (results->tree_data->columns) g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->separator) + g_free (results->tree_data->separator); break; default: break; @@ -856,6 +869,7 @@ void zenity_parse_options_callback (poptContext ctx, void *data) { static gboolean parse_option_dateformat = FALSE; + static gboolean parse_option_separator = FALSE; static gint parse_option_text = 0; static gint parse_option_file = 0; @@ -1149,6 +1163,20 @@ void zenity_parse_options_callback (poptContext ctx, } results->tree_data->radiobox = TRUE; break; + case OPTION_SEPERATOR: + if (results->mode != MODE_LIST) { + g_printerr (_("--separator is not supported for this dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + if (parse_option_separator == TRUE) { + g_printerr (_("--separator given twice for the same dialog\n")); + zenity_free_parsing_options (); + exit (-1); + } + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) { g_printerr (_("--percentage is not supported for this dialog\n")); diff --git a/src/tree.c b/src/tree.c index 2b310023..29b38c66 100644 --- a/src/tree.c +++ b/src/tree.c @@ -30,6 +30,8 @@ #define MAX_ELEMENTS_BEFORE_SCROLLING 8 static GladeXML *glade_dialog; +static GSList *selected; +static gchar *separator; static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); @@ -70,7 +72,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col for (j = 0; j < n_columns; j++) { if (toggles && j == 0) { - if (strcmp (args[i+j], "TRUE") == 0 || strcmp (args[i+j], "true") == 0) + if (strcmp (args[i+j], "TRUE") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); else gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); @@ -112,7 +114,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) data->exit_code = -1; return; } - + + separator = g_strdup (tree_data->separator); + n_columns = g_slist_length (tree_data->columns); if (n_columns == 0) { @@ -213,18 +217,18 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) } static void -zenity_tree_dialog_output (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) +zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue value = {0, }; gtk_tree_model_get_value (model, iter, 0, &value); - g_printerr ("%s", g_value_get_string (&value)); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); g_value_unset (&value); } static gboolean -zenity_tree_dialog_toggle_output (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { GValue toggle_value = {0, }; @@ -233,13 +237,37 @@ zenity_tree_dialog_toggle_output (GtkTreeModel *model, GtkTreePath *path, GtkTre if (g_value_get_boolean (&toggle_value) == TRUE) { GValue value = {0, }; gtk_tree_model_get_value (model, iter, 1, &value); - g_printerr ("%s", g_value_get_string (&value)); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); g_value_unset (&value); } g_value_unset (&toggle_value); return FALSE; } +static void +zenity_tree_dialog_output (void) +{ + GSList *tmp; + + for (tmp = selected; tmp; tmp = tmp->next) { + if (tmp->next != NULL) { + /* FIXME: There must be a nicer way to do this. This is just arse */ + if (strstr (separator, "\\n") != NULL) + g_printerr ("%s\n", tmp->data); + else if (strstr (separator, "\\t") != NULL) + g_printerr ("%s\t", tmp->data); + else + g_printerr ("%s%s", tmp->data, separator); + } + else + g_printerr ("%s\n", tmp->data); + } + + g_free (separator); + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; +} + static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -255,15 +283,16 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) { gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_output, + (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, NULL); } else { selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_tree_dialog_output, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, GTK_TREE_VIEW (tree_view)); } + zenity_tree_dialog_output (); zen_data->exit_code = 0; gtk_main_quit (); break; diff --git a/src/zenity.h b/src/zenity.h index bedec33a..94311383 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -75,6 +75,7 @@ typedef struct { GSList *columns; gboolean checkbox; gboolean radiobox; + gchar *separator; const gchar **data; } ZenityTreeData; -- cgit From 15538e120d8d184962d406fee5d7bd6600d2463d Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 03:16:47 +0000 Subject: Add an about box. Still need to add an icon, and implement the callbacks 2003-01-14 Glynn Foster * src/Makefile.am, src/about.c, src/main.c, src/zenity.glade: Add an about box. Still need to add an icon, and implement the callbacks for Help and Credits. Extra hassle for not linking against libgnomeui. Sigh. --- src/Makefile.am | 1 + src/about.c | 104 +++++++++++++++++++++++++++++++++++ src/main.c | 7 ++- src/zenity.glade | 165 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 275 insertions(+), 2 deletions(-) create mode 100644 src/about.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 11e0816c..b96eeee2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,6 +10,7 @@ zenity_SOURCES = \ text.c \ progress.c \ tree.c \ + about.c \ util.h \ util.c diff --git a/src/about.c b/src/about.c new file mode 100644 index 00000000..43b023c6 --- /dev/null +++ b/src/about.c @@ -0,0 +1,104 @@ +/* + * about.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include "config.h" +#include "zenity.h" +#include "util.h" + +#define GTK_RESPONSE_CREDITS 1 + +static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); + +void +zenity_about (ZenityData *data) +{ + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *label; + gchar *text; + + glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); + + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_about_dialog_response), data); + + /* FIXME: Set an appropriate window icon for the dialog + * zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("")); + */ + + label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); + text = g_strdup_printf ("Zenity %s", VERSION); + gtk_label_set_markup (GTK_LABEL (label), text); + g_free (text); + + label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); + gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); + + label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); + text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); + gtk_label_set_markup (GTK_LABEL (label), text); + g_free (text); + + if (glade_dialog) + g_object_unref (glade_dialog); + + gtk_widget_show (dialog); + gtk_main (); +} + +static void +zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_HELP: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CREDITS: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } +} diff --git a/src/main.c b/src/main.c index 26232327..bcd3208d 100644 --- a/src/main.c +++ b/src/main.c @@ -37,6 +37,7 @@ typedef enum { MODE_TEXTINFO, MODE_WARNING, MODE_INFO, + MODE_ABOUT, MODE_LAST } ZenityDialogMode; @@ -849,6 +850,9 @@ main (gint argc, gchar **argv) { case MODE_TEXTINFO: zenity_text (results->data, results->text_data); break; + case MODE_ABOUT: + zenity_about (results->data); + break; default: g_assert_not_reached (); zenity_free_parsing_options (); @@ -1204,8 +1208,7 @@ void zenity_parse_options_callback (poptContext ctx, zenity_free_parsing_options (); exit (-1); } - g_print ("This does nothing at the moment\n"); - exit (0); + results->mode = MODE_ABOUT; break; case OPTION_VERSION: if (results->mode != MODE_LAST) { diff --git a/src/zenity.glade b/src/zenity.glade index 9e272fa1..880ec5b7 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1099,4 +1099,169 @@ + + True + About Zenity + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + True + False + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-help + True + GTK_RELIEF_NORMAL + -11 + + + + + + True + True + True + _Credits + True + GTK_RELIEF_NORMAL + 0 + + + + + + True + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 7 + True + False + 8 + + + + True + 0.5 + 0.5 + 0 + 0 + + + 0 + True + True + + + + + + True + True + zenity_about_version + False + True + GTK_JUSTIFY_CENTER + False + True + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + zenity_about_description + False + True + GTK_JUSTIFY_CENTER + True + True + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + + True + True + zenity_about_copyright + False + True + GTK_JUSTIFY_CENTER + False + True + 0.5 + 0.5 + 0 + 0 + + + 0 + False + False + + + + + 0 + True + True + + + + + + -- cgit From 97656d7e299eb2f2063278711eddfff0d2db9392 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 15:35:24 +0000 Subject: Update to add new gconf requirement. 2003-01-14 Glynn Foster * configure.in: Update to add new gconf requirement. * src/zenity.h, src/about.c: Hurray for a new about box, although it lacks an icon. I wonder if people would actually like to see this as part of the dialog options. Can't think of any reason to do so at the moment though. Large chunks copied from libgnomeui/gnome-about.[ch] * src/util.h, src/util.c: Add new helper functions because I don't want to touch gnome_program with a bargepole. Copied from libgnome/gnome-url.[ch] * po/POTFILES.in: Add missing files. I think we have everything now. * TODO: Update accordingly. --- src/about.c | 160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/util.c | 107 ++++++++++++++++++++++++++++++++++++++- src/util.h | 2 + src/zenity.h | 1 + 4 files changed, 260 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 43b023c6..3818c2c1 100644 --- a/src/about.c +++ b/src/about.c @@ -2,6 +2,8 @@ * about.c * * Copyright (C) 2002 Sun Microsystems, Inc. + * Copyright (C) 2001 CodeFactory AB + * Copyright (C) 2001, 2002 Anders Carlsson * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,22 +21,33 @@ * Boston, MA 02111-1307, USA. * * Authors: Glynn Foster + * Anders Carlsson */ -#include #include "config.h" #include "zenity.h" #include "util.h" +#include + +#define GTK_RESPONSE_CREDITS 0 -#define GTK_RESPONSE_CREDITS 1 +static GtkWidget *dialog; +static GtkWidget *cred_dialog; static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); +static const gchar *author_credits[] = { + "Glynn Foster ", + "Mike Newman ", + NULL +}; + +gchar *translator_credits; + void zenity_about (ZenityData *data) { GladeXML *glade_dialog = NULL; - GtkWidget *dialog; GtkWidget *label; gchar *text; @@ -43,8 +56,11 @@ zenity_about (ZenityData *data) if (glade_dialog == NULL) { data->exit_code = -1; return; - } - + } + + translator_credits = _("translator_credits"); + + glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); @@ -76,10 +92,138 @@ zenity_about (ZenityData *data) gtk_main (); } +static GtkWidget * +zenity_about_create_label (void) +{ + GtkWidget *label; + + label = gtk_label_new (""); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); + gtk_misc_set_padding (GTK_MISC (label), 8, 8); + + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + + return label; +} + +static void +zenity_about_update_author_label (GtkWidget *label) +{ + GString *string; + gchar *tmp; + gint i = 0; + + gtk_widget_show (label); + + string = g_string_new (""); + + for (i = 0; author_credits[i] != NULL; i++) { + tmp = g_markup_escape_text (author_credits[i], -1); + g_string_append (string, tmp); + + if (author_credits[i+1] != NULL) + g_string_append (string, "\n"); + + g_free (tmp); + } + gtk_label_set_markup (GTK_LABEL (label), string->str); + g_string_free (string, TRUE); +} + +static void +zenity_about_update_translator_label (GtkWidget *label) +{ + GString *string; + gchar *tmp; + + if (strcmp (translator_credits, "translator_credits") == 0) { + gtk_widget_hide (label); + return; + } else { + gtk_widget_show (label); + } + + string = g_string_new (""); + + tmp = g_markup_escape_text (translator_credits, -1); + g_string_append (string, tmp); + g_free (tmp); + + gtk_label_set_markup (GTK_LABEL (label), string->str); + g_string_free (string, TRUE); +} + +static void +zenity_about_dialog_credits_response (GtkWidget *widget, int response, gpointer data) +{ + gtk_widget_destroy (widget); + widget = NULL; +} + +static void +zenity_about_display_credits_dialog (void) +{ + GtkWidget *credits_dialog; + GtkWidget *label, *notebook, *sw; + + if (cred_dialog != NULL) { + gtk_window_present (GTK_WINDOW (cred_dialog)); + return; + } + + credits_dialog = gtk_dialog_new_with_buttons (_("Credits"), + GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + + g_signal_connect (G_OBJECT (credits_dialog), "response", + G_CALLBACK (gtk_widget_destroy), credits_dialog); + g_signal_connect (G_OBJECT (credits_dialog), "destroy", + G_CALLBACK (gtk_widget_destroyed), &cred_dialog); + + cred_dialog = credits_dialog; + + gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260); + gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK); + + notebook = gtk_notebook_new (); + gtk_container_set_border_width (GTK_CONTAINER (notebook), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0); + + if (author_credits != NULL) { + label = zenity_about_create_label (); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, + gtk_label_new (_("Written by"))); + zenity_about_update_author_label (label); + } + + if (translator_credits != NULL) { + label = zenity_about_create_label (); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, + gtk_label_new (_("Translated by"))); + zenity_about_update_translator_label (label); + } + + gtk_widget_show_all (credits_dialog); +} + static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; + GError *error = NULL; switch (response) { case GTK_RESPONSE_OK: @@ -88,13 +232,11 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_HELP: - zen_data->exit_code = 1; - gtk_main_quit (); + zenity_util_show_help ("ghelp:///", NULL); break; case GTK_RESPONSE_CREDITS: - zen_data->exit_code = 1; - gtk_main_quit (); + zenity_about_display_credits_dialog (); break; default: /* Esc dialog */ diff --git a/src/util.c b/src/util.c index b9116acb..dbc30d8f 100644 --- a/src/util.c +++ b/src/util.c @@ -2,6 +2,8 @@ * util.c * * Copyright (C) 2002 Sun Microsystems, Inc. + * (C) 1999, 2000 Red Hat Inc. + * (C) 1998 James Henstridge * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -19,13 +21,18 @@ * Boston, MA 02111-1307, USA. * * Authors: Glynn Foster - * Havoc Pennington + * Havoc Pennington + * James Henstridge */ #include #include #include "config.h" #include "util.h" +#include + +#define URL_HANDLER_DIR "/desktop/gnome/url-handlers/" +#define DEFAULT_HANDLER_PATH "/desktop/gnome/url-handlers/unknown/command" GladeXML* zenity_util_load_glade_file (const gchar *widget_root) @@ -156,3 +163,101 @@ zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); g_object_unref (pixbuf); } + +/* This is copied from libgnome/gnome-url.c since we try and avoid using + * the evils of gnome_program_init (), which messes up the commandline + */ + +gboolean +zenity_util_show_help (const gchar *url, GError **error) +{ + GConfClient *client; + gint i; + gchar *pos, *template; + int argc; + char **argv; + gboolean ret; + + g_return_val_if_fail (url != NULL, FALSE); + + pos = strchr (url, ':'); + + client = gconf_client_get_default (); + + if (pos != NULL) { + gchar *protocol, *path; + + g_return_val_if_fail (pos >= url, FALSE); + + protocol = g_new (gchar, pos - url + 1); + strncpy (protocol, url, pos - url); + protocol[pos - url] = '\0'; + g_ascii_strdown (protocol, -1); + + path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL); + template = gconf_client_get_string (client, path, NULL); + + if (template == NULL) { + gchar* template_temp; + + template_temp = gconf_client_get_string (client, + DEFAULT_HANDLER_PATH, + NULL); + + /* Retry to get the right url handler */ + template = gconf_client_get_string (client, path, NULL); + + if (template == NULL) + template = template_temp; + else + g_free (template_temp); + + } + + g_free (path); + g_free (protocol); + + } else { + /* no ':' ? this shouldn't happen. Use default handler */ + template = gconf_client_get_string (client, + DEFAULT_HANDLER_PATH, + NULL); + } + + g_object_unref (G_OBJECT (client)); + + if (!g_shell_parse_argv (template, + &argc, + &argv, + error)) { + g_free (template); + return FALSE; + } + + g_free (template); + + for (i = 0; i < argc; i++) { + char *arg; + + if (strcmp (argv[i], "%s") != 0) + continue; + + arg = argv[i]; + argv[i] = g_strdup (url); + g_free (arg); + } + + /* This can return some errors */ + ret = g_spawn_async (NULL /* working directory */, + argv, + NULL, + G_SPAWN_SEARCH_PATH /* flags */, + NULL /* child_setup */, + NULL /* data */, + NULL /* child_pid */, + error); + + g_strfreev (argv); + + return ret; +} diff --git a/src/util.h b/src/util.h index 3f9d8e1d..99c20cb3 100644 --- a/src/util.h +++ b/src/util.h @@ -21,6 +21,8 @@ void zenity_util_set_window_icon (GtkWidget *widget, void zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id); +gboolean zenity_util_show_help (const gchar *url, + GError **error); G_END_DECLS #endif /* UTIL_H */ diff --git a/src/zenity.h b/src/zenity.h index 94311383..813fbdd9 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -93,6 +93,7 @@ void zenity_text (ZenityData *data, ZenityTextData *text_data); void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); +void zenity_about (ZenityData *data); G_END_DECLS -- cgit From 5123cda5cd32333d9e5c1b4e5e769273c667ea71 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 14 Jan 2003 23:40:47 +0000 Subject: Updates to make distcheck. Wow, this is scarey, a 1.0 release is on the 2003-01-14 Glynn Foster * Makefile.am, src/Makefile.am: Updates to make distcheck. Wow, this is scarey, a 1.0 release is on the horizon. Applications like this shouldn't reach 1.0. --- src/Makefile.am | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b96eeee2..3e0c2f3b 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,3 +27,6 @@ gladedir = $(datadir)/zenity glade_DATA = \ zenity.glade + +EXTRA_DIST = \ + $(glade_DATA) -- cgit From 0e338ba3e0fa03b28664448af0cea686c5e6c26d Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 17 Jan 2003 07:46:11 +0000 Subject: Fix a segfault in the --list if no data is supplied to populate the tree. --- src/tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 29b38c66..c19b1804 100644 --- a/src/tree.c +++ b/src/tree.c @@ -124,7 +124,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) data->exit_code = -1; return; } - + + if (tree_data->data == NULL) { + g_printerr (_("No contents specified for --list\n")); + data->exit_code = -1; + return; + } + glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); -- cgit From f182d9f7fce8e9a57c03eb71f4467894394d0104 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 13:35:13 +0000 Subject: Some new window icons. 2003-01-18 Glynn Foster * data/Makefile.am, data/zenity-calendar.png, data/zenity-entry.png, data/zenity-progress.png, data/zenity-text.png: Some new window icons. * src/text.c: Fix crash where the GladeXML ref was getting unref'd before we wanted to use it. * src/main.c: Fix up commandline parsing a little, although we should really add the parsing options for gtk+. * src/zenity.glade: Give some saner defaults. * THANKS, src/about.c: Update for all the people I stole icons and code from. * TODO: Update accordingly. --- src/about.c | 6 ++++++ src/main.c | 7 ++++--- src/text.c | 9 +++++---- src/zenity.glade | 4 ++-- 4 files changed, 17 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 3818c2c1..c121cdc5 100644 --- a/src/about.c +++ b/src/about.c @@ -37,8 +37,14 @@ static GtkWidget *cred_dialog; static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); static const gchar *author_credits[] = { + "Jonathan Blanford ", + "Anders Carlsson ", "Glynn Foster ", + "James Henstridge ", "Mike Newman ", + "Havoc Pennington ", + "Kristian Rietveld ", + "Jakub Steiner ", NULL }; diff --git a/src/main.c b/src/main.c index bcd3208d..58bb13e7 100644 --- a/src/main.c +++ b/src/main.c @@ -812,6 +812,9 @@ main (gint argc, gchar **argv) { /*nothing*/; if (nextopt != -1) { + /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ + * commandline options + */ g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); @@ -1220,8 +1223,6 @@ void zenity_parse_options_callback (poptContext ctx, exit (0); break; default: - g_warning ("Invalid option %s", arg); - zenity_free_parsing_options (); - exit (-1); + break; } } diff --git a/src/text.c b/src/text.c index ead35ec2..fe9747cb 100644 --- a/src/text.c +++ b/src/text.c @@ -46,9 +46,6 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); - if (glade_dialog) - g_object_unref (glade_dialog); - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_text_dialog_response), data); @@ -58,7 +55,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else - ; + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); @@ -68,6 +65,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer); gtk_widget_show (dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); + gtk_main (); } diff --git a/src/zenity.glade b/src/zenity.glade index 880ec5b7..3ea0bab4 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -529,7 +529,7 @@ True - zenity_text_dialog + Text View GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False @@ -601,7 +601,7 @@ 2 2 0 - zenity_text_view + -- cgit From 10e683c2e7fa6b71ce7baaa15185477d544d885f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 14:54:44 +0000 Subject: Hooray! Zenity now has an about window icon. It's very zen too. 2003-01-18 Glynn Foster * data/Makefile.am, data/zenity.png, src/about.c: Hooray! Zenity now has an about window icon. It's very zen too. --- src/about.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index c121cdc5..d260f608 100644 --- a/src/about.c +++ b/src/about.c @@ -54,7 +54,9 @@ void zenity_about (ZenityData *data) { GladeXML *glade_dialog = NULL; + GdkPixbuf *pixbuf; GtkWidget *label; + GtkWidget *image; gchar *text; glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); @@ -74,9 +76,16 @@ zenity_about (ZenityData *data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); - /* FIXME: Set an appropriate window icon for the dialog - * zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("")); - */ + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png")); + + image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); + + pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); + + if (pixbuf != NULL) { + gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); + g_object_unref (pixbuf); + } label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); text = g_strdup_printf ("Zenity %s", VERSION); -- cgit From 18760d406d64f71f7ca6fec5a7a01978418fa8f5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:02:14 +0000 Subject: Only some examples and some screenshots and we're mostly done for a first 2003-01-18 Glynn Foster * help/C/zenity.xml: Only some examples and some screenshots and we're mostly done for a first draft. * src/calendar.c: Don't set the text if it's NULL. * src/main.c: Swap the order of the commandline dialogs so that we're alphabetical. * src/zenity.glade: Add some default strings. --- src/calendar.c | 4 +++- src/main.c | 24 ++++++++++++------------ src/zenity.glade | 2 +- 3 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 65c2bf90..68956e76 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -64,7 +64,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + + if (cal_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); diff --git a/src/main.c b/src/main.c index 58bb13e7..0e762473 100644 --- a/src/main.c +++ b/src/main.c @@ -137,21 +137,21 @@ struct poptOption options[] = { NULL }, { - "info", + "file-selection", '\0', POPT_ARG_NONE, NULL, - OPTION_INFO, - N_("Display info dialog"), + OPTION_FILE, + N_("Display file selection dialog"), NULL }, { - "file-selection", + "info", '\0', POPT_ARG_NONE, NULL, - OPTION_FILE, - N_("Display file selection dialog"), + OPTION_INFO, + N_("Display info dialog"), NULL }, { @@ -614,27 +614,27 @@ struct poptOption application_options[] = { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - info_options, + error_options, 0, - N_("Info options"), + N_("Error options"), NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - error_options, + file_selection_options, 0, - N_("Error options"), + N_("File selection options"), NULL }, { NULL, '\0', POPT_ARG_INCLUDE_TABLE, - file_selection_options, + info_options, 0, - N_("File selection options"), + N_("Info options"), NULL }, { diff --git a/src/zenity.glade b/src/zenity.glade index 3ea0bab4..f22c1018 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -74,7 +74,7 @@ True - Select a date from below + Select a date from below. False True GTK_JUSTIFY_LEFT -- cgit From c41421c043ec92da0936ca8005f3e7841abd19cd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 18 Jan 2003 18:30:52 +0000 Subject: Add some screenshots for the help documentation. 2003-01-18 Glynn Foster * help/C/figures/zenity-calendar-screenshot.png, help/C/figures/zenity-entry-screenshot.png, help/C/figures/zenity-error-screenshot.png, help/C/figures/zenity-fileselection-screenshot.png, help/C/figures/zenity-information-screenshot.png, help/C/figures/zenity-list-screenshot.png, help/C/figures/zenity-progress-screenshot.png, help/C/figures/zenity-question-screenshot.png, help/C/figures/zenity-text-screenshot.png, help/C/figures/zenity-warning-screenshot.png: Add some screenshots for the help documentation. * src/entry.c, src/msg.c: Don't set the text if it's NULL. --- src/entry.c | 2 +- src/msg.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 81fc2c5e..3578788e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -56,7 +56,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else - /* FIXME: Come up with a nice default window icon */; + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); diff --git a/src/msg.c b/src/msg.c index cc1f0924..5c73af0b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -103,8 +103,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } - - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + + if (msg_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); gtk_widget_show (dialog); gtk_main (); -- cgit From 1e1dfef56ec71f732941398529cb1d8c79190c41 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sun, 19 Jan 2003 12:13:08 +0000 Subject: Add --editable option to --text-info, and return edited textbuffer contents on dialog close. --- src/main.c | 24 ++++++++++++++++++++++++ src/text.c | 14 +++++++++++++- src/zenity.h | 2 ++ 3 files changed, 39 insertions(+), 1 deletion(-) (limited to 'src') 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 { -- cgit From 3a90fe71679d726ffe39ad2a7ee9104485d53005 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 19 Jan 2003 12:48:57 +0000 Subject: Attempt to make things work after 2 bottles of wine last night. Harmless 2003-01-19 Glynn Foster * src/about.c: Attempt to make things work after 2 bottles of wine last night. Harmless changes though, so I'll commit them for posterity. * src/main.c: Add a new helper function for the error reporting that makes the translators life easier. Thanks to Ole for spotting this. * src/text.c, src/zenity.h: Lame white spacing hacking. * xmldocs.make: Put the docs in $(datadir)/help - not quite sure yet if yelp is going to like this or not. --- src/about.c | 5 +- src/main.c | 366 +++++++++++++++++++++++++---------------------------------- src/text.c | 2 +- src/zenity.h | 2 +- 4 files changed, 160 insertions(+), 215 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index d260f608..fcc9352b 100644 --- a/src/about.c +++ b/src/about.c @@ -36,6 +36,7 @@ static GtkWidget *cred_dialog; static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); +/* Sync with the people in the THANKS file */ static const gchar *author_credits[] = { "Jonathan Blanford ", "Anders Carlsson ", @@ -239,6 +240,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; GError *error = NULL; + gchar *help_string; switch (response) { case GTK_RESPONSE_OK: @@ -247,7 +249,8 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_HELP: - zenity_util_show_help ("ghelp:///", NULL); + help_string = g_strconcat ("ghelp://", ZENITY_DATADIR, "help/zenity", NULL); + zenity_util_show_help (help_string, NULL); break; case GTK_RESPONSE_CREDITS: diff --git a/src/main.c b/src/main.c index a8e1e0e4..c2155f15 100644 --- a/src/main.c +++ b/src/main.c @@ -41,6 +41,13 @@ typedef enum { MODE_LAST } ZenityDialogMode; +typedef enum { + ERROR_DUPLICATE, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST +} ZenityError; + typedef struct { ZenityDialogMode mode; ZenityData *data; @@ -879,12 +886,33 @@ main (gint argc, gchar **argv) { exit (retval); } -static -void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data) +static void +zenity_error (gchar *string, ZenityError error) +{ + switch (error) { + case ERROR_DUPLICATE: + g_printerr (_("%s given twice for the same dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_("%s is not supported for this dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_("Two or more dialog options specified\n")); + zenity_free_parsing_options (); + exit (-1); + default: + return; + } +} + +static void +zenity_parse_options_callback (poptContext ctx, + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data) { static gboolean parse_option_dateformat = FALSE; static gboolean parse_option_separator = FALSE; @@ -900,103 +928,79 @@ void zenity_parse_options_callback (poptContext ctx, switch (opt->val & POPT_ARG_MASK) { case OPTION_CALENDAR: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_CALENDAR; break; case OPTION_ENTRY: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ENTRY; break; case OPTION_ERROR: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ERROR; results->msg_data->mode = ZENITY_MSG_ERROR; break; case OPTION_INFO: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_INFO; results->msg_data->mode = ZENITY_MSG_INFO; break; case OPTION_FILE: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_FILE; break; case OPTION_LIST: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_LIST; break; case OPTION_PROGRESS: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_PROGRESS; break; case OPTION_QUESTION: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_QUESTION; results->msg_data->mode = ZENITY_MSG_QUESTION; break; case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_TEXTINFO; break; case OPTION_WARNING: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_WARNING; results->msg_data->mode = ZENITY_MSG_WARNING; break; case OPTION_TITLE: - if (results->data->dialog_title != NULL) { - g_printerr (_("--title given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->data->dialog_title != NULL) + zenity_error ("--title", ERROR_DUPLICATE); + results->data->dialog_title = g_strdup (arg); break; case OPTION_ICON: - if (results->data->window_icon != NULL) { - g_printerr (_("--window-icon given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->data->window_icon != NULL) + zenity_error ("--window-icon", ERROR_DUPLICATE); + results->data->window_icon = g_strdup (arg); break; case OPTION_CALENDARTEXT: @@ -1011,11 +1015,8 @@ void zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 6) { - g_printerr (_("--text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (parse_option_text > 6) + zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { case MODE_CALENDAR: @@ -1034,102 +1035,72 @@ void zenity_parse_options_callback (poptContext ctx, results->progress_data->dialog_text = g_strdup (arg); break; default: - g_printerr (_("--text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); + zenity_error ("--text", ERROR_SUPPORT); } parse_option_text++; break; case OPTION_DAY: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--day is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->day > 0) { - g_printerr (_("--day given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--day", ERROR_SUPPORT); + + if (results->calendar_data->day > 0) + zenity_error ("--day", ERROR_DUPLICATE); + results->calendar_data->day = atoi (arg); break; case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--month is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->month > 0) { - g_printerr (_("--month given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--month", ERROR_SUPPORT); + + if (results->calendar_data->month > 0) + zenity_error ("--day", ERROR_DUPLICATE); + results->calendar_data->month = atoi (arg); break; case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--year is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->calendar_data->year > 0) { - g_printerr (_("--year given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--year", ERROR_SUPPORT); + + if (results->calendar_data->year > 0) + zenity_error ("--year", ERROR_DUPLICATE); + results->calendar_data->year = atoi (arg); break; case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) { - g_printerr (_("--date-format is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (parse_option_dateformat == TRUE) { - g_printerr (_("--date-format given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_CALENDAR) + zenity_error ("--date-format", ERROR_SUPPORT); + + if (parse_option_dateformat == TRUE) + zenity_error ("--date-format", ERROR_DUPLICATE); + results->calendar_data->date_format = g_strdup (arg); parse_option_dateformat = TRUE; break; case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) { - g_printerr (_("--entry-text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->entry_data->entry_text != NULL) { - g_printerr (_("--entry-text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_ENTRY) + zenity_error ("--entry-text", ERROR_SUPPORT); + + if (results->entry_data->entry_text != NULL) + zenity_error ("--entry-text", ERROR_DUPLICATE); + results->entry_data->entry_text = g_strdup (arg); break; case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) { - g_printerr (_("--hide-text is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->entry_data->visible == FALSE) { - g_printerr (_("--hide-text given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_ENTRY) + zenity_error ("--hide-text", ERROR_SUPPORT); + + if (results->entry_data->visible == FALSE) + zenity_error ("--hide-text", ERROR_DUPLICATE); + 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); - } + if (results->mode != MODE_TEXTINFO) + zenity_error ("--editable", ERROR_SUPPORT); + + if (results->text_data->editable == TRUE) + zenity_error ("--editable", ERROR_DUPLICATE); + results->text_data->editable = TRUE; break; case OPTION_FILENAME: @@ -1140,11 +1111,8 @@ void zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_file > 2) { - g_printerr (_("--filename given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (parse_option_file > 2) + zenity_error ("--filename", ERROR_DUPLICATE); switch (results->mode) { case MODE_FILE: @@ -1154,95 +1122,69 @@ void zenity_parse_options_callback (poptContext ctx, results->text_data->uri = g_strdup (arg); break; default: - g_printerr (_("--filename is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); + zenity_error ("--filename", ERROR_SUPPORT); } parse_option_file++; break; case OPTION_COLUMN: - if (results->mode != MODE_LIST) { - g_printerr (_("--column is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--column", ERROR_SUPPORT); + results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); break; case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) { - g_printerr (_("--checkbox is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->tree_data->checkbox == TRUE) { - g_printerr (_("--checkbox given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--checkbox", ERROR_SUPPORT); + + if (results->tree_data->checkbox == TRUE) + zenity_error ("--checkbox", ERROR_DUPLICATE); + results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) { - g_printerr (_("--radiobox is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->tree_data->radiobox == TRUE) { - g_printerr (_("--radiobox given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--radiobox", ERROR_SUPPORT); + + if (results->tree_data->radiobox == TRUE) + zenity_error ("--radiobox", ERROR_DUPLICATE); + results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) { - g_printerr (_("--separator is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (parse_option_separator == TRUE) { - g_printerr (_("--separator given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LIST) + zenity_error ("--separator", ERROR_SUPPORT); + + if (parse_option_separator == TRUE) + zenity_error ("--separator", ERROR_DUPLICATE); + results->tree_data->separator = g_strdup (arg); parse_option_separator = TRUE; break; case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) { - g_printerr (_("--percentage is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } - if (results->progress_data->percentage > -1) { - g_printerr (_("--percentage given twice for the same dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_PROGRESS) + zenity_error ("--percentage", ERROR_SUPPORT); + + if (results->progress_data->percentage > -1) + zenity_error ("--percentage", ERROR_DUPLICATE); + results->progress_data->percentage = atoi (arg); break; case OPTION_PULSATE: - if (results->mode != MODE_PROGRESS) { - g_printerr (_("--pulsate is not supported for this dialog\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_PROGRESS) + zenity_error ("--pulsate", ERROR_SUPPORT); + results->progress_data->pulsate = TRUE; break; case OPTION_ABOUT: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_ABOUT; break; case OPTION_VERSION: - if (results->mode != MODE_LAST) { - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - } + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + g_print ("%s\n", VERSION); exit (0); break; diff --git a/src/text.c b/src/text.c index 02b2f109..7601fd98 100644 --- a/src/text.c +++ b/src/text.c @@ -86,7 +86,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_CLOSE: if (zen_text_data->editable) { - GtkTextIter start,end; + 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)); diff --git a/src/zenity.h b/src/zenity.h index 18da11ec..de833f0b 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -68,7 +68,7 @@ typedef struct { typedef struct { gchar *uri; - gboolean editable; + gboolean editable; GtkTextBuffer *buffer; } ZenityTextData; -- cgit From a161b30233263a248e9028de5e15a77a39f980d3 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 20 Jan 2003 10:03:13 +0000 Subject: Remove some strings for translation that should be done. 2003-01-20 Glynn Foster * src/zenity.glade: Remove some strings for translation that should be done. --- src/zenity.glade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index f22c1018..3141c855 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1192,7 +1192,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1214,7 +1214,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1236,7 +1236,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 818872f171108b910344b3d352c6f7d38e80fd97 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 21 Jan 2003 08:00:27 +0000 Subject: Fixed a bug I introduced! Ensure that an editable --text-info dialog gets a buffer associated with it, so we can get the output even when we don't start out with a --filename. --- src/text.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index 7601fd98..4efa4bf4 100644 --- a/src/text.c +++ b/src/text.c @@ -64,8 +64,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) text_buffer = gtk_text_buffer_new (NULL); 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_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; -- cgit From 0629d7f2275840814c732d8764935bc1fd014fe2 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 21 Jan 2003 08:05:38 +0000 Subject: Sigh - half a job done as usual :) --- src/text.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/text.c b/src/text.c index 4efa4bf4..b51f93b1 100644 --- a/src/text.c +++ b/src/text.c @@ -66,6 +66,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view"); 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->uri) { + zenity_util_fill_file_buffer (text_buffer, text_data->uri); + } + if (text_data->editable) { zen_text_data->buffer = text_buffer; } -- cgit From 525e0dbe64d049602becadb3e6571fdce7f8687b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 22 Jan 2003 02:03:09 +0000 Subject: Print out warning when we have no arguments to the commandline. 2003-01-22 Glynn Foster * src/main.c: Print out warning when we have no arguments to the commandline. * TODO: Add another item --- src/main.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index c2155f15..43502141 100644 --- a/src/main.c +++ b/src/main.c @@ -833,7 +833,8 @@ main (gint argc, gchar **argv) { /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ * commandline options */ - g_printerr (_("%s in an invalid option for this dialog\n"), poptBadOption (ctx, 0)); + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); } @@ -841,6 +842,7 @@ main (gint argc, gchar **argv) { gtk_init (&argc, &argv); if (argc < 2) { + g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); zenity_free_parsing_options (); exit (-1); } -- cgit From 89255c3b352855d728ae3adc20b0cdd90fe582dd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 24 Jan 2003 16:16:40 +0000 Subject: Provide correct help URL. 2003-01-24 Glynn Foster * src/about.c: Provide correct help URL. * src/util.h, src/util.c: Add functions from libgnome/gnome-i18n so that we can correctly find the apropriate help file. * xmldocs.make: Install help into $(datadir)/help/$(lang)/ * THANKS: Update from the code I stole from libgnome --- src/about.c | 6 +- src/util.c | 332 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/util.h | 3 +- 3 files changed, 333 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index fcc9352b..9bca0cc3 100644 --- a/src/about.c +++ b/src/about.c @@ -30,6 +30,7 @@ #include #define GTK_RESPONSE_CREDITS 0 +#define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" static GtkWidget *dialog; static GtkWidget *cred_dialog; @@ -46,6 +47,7 @@ static const gchar *author_credits[] = { "Havoc Pennington ", "Kristian Rietveld ", "Jakub Steiner ", + "Tom Tromey " NULL }; @@ -240,7 +242,6 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; GError *error = NULL; - gchar *help_string; switch (response) { case GTK_RESPONSE_OK: @@ -249,8 +250,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_HELP: - help_string = g_strconcat ("ghelp://", ZENITY_DATADIR, "help/zenity", NULL); - zenity_util_show_help (help_string, NULL); + zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL); break; case GTK_RESPONSE_CREDITS: diff --git a/src/util.c b/src/util.c index dbc30d8f..bbb6d777 100644 --- a/src/util.c +++ b/src/util.c @@ -4,6 +4,7 @@ * Copyright (C) 2002 Sun Microsystems, Inc. * (C) 1999, 2000 Red Hat Inc. * (C) 1998 James Henstridge + * (C) 1995-2002 Free Software Foundation * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,12 +24,15 @@ * Authors: Glynn Foster * Havoc Pennington * James Henstridge + * Tom Tromey */ #include +#include #include #include "config.h" #include "util.h" +#include "zenity.h" #include #define URL_HANDLER_DIR "/desktop/gnome/url-handlers/" @@ -164,12 +168,329 @@ zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id g_object_unref (pixbuf); } +/* This is copied from libgnome/gnome-i18n.c since we try and avoid using + * the evils of gnome_program_init (), which messes up the commandline + */ + +static GHashTable *alias_table = NULL; + +/*read an alias file for the locales*/ +static void +zenity_read_aliases (char *file) +{ + FILE *fp; + char buf[256]; + + if (!alias_table) + alias_table = g_hash_table_new (g_str_hash, g_str_equal); + + fp = fopen (file,"r"); + + if (!fp) + return; + + while (fgets (buf,256,fp)) { + gchar *p; + g_strstrip (buf); + + if (buf[0]=='#' || buf[0]=='\0') + continue; + + p = (gchar *) strtok (buf, "\t "); + + if (!p) + continue; + + p = (gchar *) strtok (NULL, "\t "); + + if(!p) + continue; + + if (!g_hash_table_lookup (alias_table, buf)) + g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p)); + } + + fclose (fp); +} + +/*return the un-aliased language as a newly allocated string*/ +static char * +zenity_unalias_lang (char *lang) +{ + char *p; + int i; + + if (!alias_table) { + zenity_read_aliases ("/usr/share/locale/locale.alias"); + zenity_read_aliases ("/usr/local/share/locale/locale.alias"); + zenity_read_aliases ("/usr/lib/X11/locale/locale.alias"); + zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias"); + } + + i = 0; + while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) { + lang = p; + + if (i++ == 30) { + static gboolean said_before = FALSE; + + if (!said_before) + g_warning (_("Too many alias levels for a locale may indicate a loop")); + + said_before = TRUE; + return lang; + } + } + return lang; +} + +/* Mask for components of locale spec. The ordering here is from + * least significant to most significant + */ +enum +{ + COMPONENT_CODESET = 1 << 0, + COMPONENT_TERRITORY = 1 << 1, + COMPONENT_MODIFIER = 1 << 2 +}; + +/* Break an X/Open style locale specification into components + */ +static guint +zenity_explode_locale (const gchar *locale, + gchar **language, + gchar **territory, + gchar **codeset, + gchar **modifier) +{ + const gchar *uscore_pos; + const gchar *at_pos; + const gchar *dot_pos; + guint mask = 0; + + uscore_pos = (const gchar *) strchr (locale, '_'); + dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.'); + at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@'); + + if (at_pos) { + mask |= COMPONENT_MODIFIER; + *modifier = g_strdup (at_pos); + } else + at_pos = locale + strlen (locale); + + if (dot_pos) { + mask |= COMPONENT_CODESET; + *codeset = g_new (gchar, 1 + at_pos - dot_pos); + strncpy (*codeset, dot_pos, at_pos - dot_pos); + (*codeset) [at_pos - dot_pos] = '\0'; + } else + dot_pos = at_pos; + + if (uscore_pos) { + mask |= COMPONENT_TERRITORY; + *territory = g_new (gchar, 1 + dot_pos - uscore_pos); + strncpy (*territory, uscore_pos, dot_pos - uscore_pos); + (*territory)[dot_pos - uscore_pos] = '\0'; + } else + uscore_pos = dot_pos; + + *language = g_new (gchar, 1 + uscore_pos - locale); + strncpy (*language, locale, uscore_pos - locale); + (*language) [uscore_pos - locale] = '\0'; + + return mask; +} + +static GList * +zenity_compute_locale_variants (const gchar *locale) +{ + GList *retval = NULL; + gchar *language; + gchar *territory; + gchar *codeset; + gchar *modifier; + guint mask; + guint i; + + + g_return_val_if_fail (locale != NULL, NULL); + + mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier); + + /* Iterate through all possible combinations, from least attractive + * to most attractive. + */ + + for (i = 0; i <= mask; i++) + if ((i & ~mask) == 0) { + gchar *val = g_strconcat (language, + (i & COMPONENT_TERRITORY) ? territory : "", + (i & COMPONENT_CODESET) ? codeset : "", + (i & COMPONENT_MODIFIER) ? modifier : "", NULL); + retval = g_list_prepend (retval, val); + } + + g_free (language); + + if (mask & COMPONENT_CODESET) + g_free (codeset); + if (mask & COMPONENT_TERRITORY) + g_free (territory); + if (mask & COMPONENT_MODIFIER) + g_free (modifier); + + return retval; +} + +static const gchar * +zenity_guess_category_value (const gchar *categoryname) +{ + const gchar *retval; + + /* The highest priority value is the `LANGUAGE' environment + * variable. This is a GNU extension. + */ + + retval = g_getenv ("LANGUAGE"); + + if (retval != NULL && retval[0] != '\0') + return retval; + + /* `LANGUAGE' is not set. So we have to proceed with the POSIX + * methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some + * systems this can be done by the `setlocale' function itself. + */ + + /* Setting of LC_ALL overwrites all other. */ + + retval = g_getenv ("LC_ALL"); + + if (retval != NULL && retval[0] != '\0') + return retval; + + /* Next comes the name of the desired category. */ + retval = g_getenv (categoryname); + + if (retval != NULL && retval[0] != '\0') + return retval; + + /* Last possibility is the LANG environment variable. */ + retval = g_getenv ("LANG"); + if (retval != NULL && retval[0] != '\0') + return retval; + + return NULL; +} + + +static GHashTable *category_table= NULL; + +static const GList * +zenity_i18n_get_language_list (const gchar *category_name) +{ + GList *list; + + if (!category_name) + category_name= "LC_ALL"; + + if (category_table) { + list= g_hash_table_lookup (category_table, (const gpointer) category_name); + } else { + category_table= g_hash_table_new (g_str_hash, g_str_equal); + list= NULL; + } + + if (!list) { + gint c_locale_defined= FALSE; + const gchar *category_value; + gchar *category_memory, *orig_category_memory; + + category_value = zenity_guess_category_value (category_name); + + if (! category_value) + category_value = "C"; + + orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1); + + while (category_value[0] != '\0') { + while (category_value[0] != '\0' && category_value[0] == ':') + ++category_value; + + if (category_value[0] != '\0') { + char *cp= category_memory; + + while (category_value[0] != '\0' && category_value[0] != ':') + *category_memory++= *category_value++; + + category_memory[0]= '\0'; + category_memory++; + + cp = zenity_unalias_lang (cp); + + if (strcmp (cp, "C") == 0) + c_locale_defined= TRUE; + + list= g_list_concat (list, zenity_compute_locale_variants (cp)); + } + } + + g_free (orig_category_memory); + + if (!c_locale_defined) + list= g_list_append (list, "C"); + + g_hash_table_insert (category_table, (gpointer) category_name, list); + } + + return list; +} + +/* This is copied from libgnome/gnome-help.c since we try and avoid using + * the evils of gnome_program_init (), which messes up the commandline + */ + +static char * +zenity_locate_help_file (const char *path, const char *doc_name) +{ + int i; + char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL }; + const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES"); + + for (;lang_list != NULL; lang_list = lang_list->next) { + const char *lang = lang_list->data; + + /* This has to be a valid language AND a language with + * no encoding postfix. The language will come up without + * encoding next + */ + + if (lang == NULL || (gchar *) strchr (lang, '.') != NULL) + continue; + + for (i = 0; exts[i] != NULL; i++) { + char *name; + char *full; + + name = g_strconcat (doc_name, exts[i], NULL); + full = g_build_filename (path, lang, name, NULL); + + if (g_file_test (full, G_FILE_TEST_EXISTS)) + return full; + + g_free (full); + + } + } + + return NULL; +} + /* This is copied from libgnome/gnome-url.c since we try and avoid using * the evils of gnome_program_init (), which messes up the commandline */ gboolean -zenity_util_show_help (const gchar *url, GError **error) +zenity_util_show_help (const gchar *path, const gchar *document, GError **error) { GConfClient *client; gint i; @@ -177,10 +498,13 @@ zenity_util_show_help (const gchar *url, GError **error) int argc; char **argv; gboolean ret; + char *url; - g_return_val_if_fail (url != NULL, FALSE); - - pos = strchr (url, ':'); + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (document != NULL, FALSE); + + url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL); + pos = (gchar *) strchr (url, ':'); client = gconf_client_get_default (); diff --git a/src/util.h b/src/util.h index 99c20cb3..a9a7ded4 100644 --- a/src/util.h +++ b/src/util.h @@ -21,7 +21,8 @@ void zenity_util_set_window_icon (GtkWidget *widget, void zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id); -gboolean zenity_util_show_help (const gchar *url, +gboolean zenity_util_show_help (const gchar *path, + const gchar *document, GError **error); G_END_DECLS -- cgit From 2d0e828c5d28510058175917543be38900857343 Mon Sep 17 00:00:00 2001 From: John Fleck Date: Sat, 25 Jan 2003 02:12:07 +0000 Subject: adding comma Glynn left out that kept it from compiling 2003-01-24 John Fleck * src/about.c: adding comma Glynn left out that kept it from compiling --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 9bca0cc3..76f39ac0 100644 --- a/src/about.c +++ b/src/about.c @@ -47,7 +47,7 @@ static const gchar *author_credits[] = { "Havoc Pennington ", "Kristian Rietveld ", "Jakub Steiner ", - "Tom Tromey " + "Tom Tromey ", NULL }; -- cgit From 2c9e227432083a7fbca9538a990de7bc55402934 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 26 Jan 2003 20:25:44 +0000 Subject: Update 2003-01-26 Glynn Foster * THANKS, src/about.c: Update --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 76f39ac0..67e9e97a 100644 --- a/src/about.c +++ b/src/about.c @@ -42,6 +42,7 @@ static const gchar *author_credits[] = { "Jonathan Blanford ", "Anders Carlsson ", "Glynn Foster ", + "John Fleck ", "James Henstridge ", "Mike Newman ", "Havoc Pennington ", -- cgit From 22625f8b16e1dc38be50cc2e869780b74e7f6891 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 28 Jan 2003 14:58:30 +0000 Subject: Don't display the translators tab unless there is stuff to show. 2003-01-28 Glynn Foster * src/about.c: Don't display the translators tab unless there is stuff to show. * src/entry.c: Add sanity NULL checking. * src/tree.c, src/zenity.h: Add support for a new --editable option. * src/main.c: Add support for new --editable option for the List dialog. Merge in the list of Gtk+ options into the popt table - ripped this from libbonoboui, thanks to James for pointing this out. * src/zenity.glade: Make the translatable strings less arse. * TODO: Update accordingly. --- src/about.c | 3 +- src/entry.c | 7 ++- src/main.c | 189 ++++++++++++++++++++++++++++++++++++++++++++++++++----- src/tree.c | 102 +++++++++++++++++++++++++----- src/zenity.glade | 4 +- src/zenity.h | 1 + 6 files changed, 272 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 67e9e97a..5e7003fb 100644 --- a/src/about.c +++ b/src/about.c @@ -72,7 +72,6 @@ zenity_about (ZenityData *data) translator_credits = _("translator_credits"); - glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); @@ -222,7 +221,7 @@ zenity_about_display_credits_dialog (void) zenity_about_update_author_label (label); } - if (translator_credits != NULL) { + if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) { label = zenity_about_create_label (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), diff --git a/src/entry.c b/src/entry.c index 3578788e..893fbf62 100644 --- a/src/entry.c +++ b/src/entry.c @@ -84,11 +84,16 @@ static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; + const gchar *text; switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = 0; - g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + gtk_main_quit (); break; diff --git a/src/main.c b/src/main.c index 43502141..13399236 100644 --- a/src/main.c +++ b/src/main.c @@ -88,6 +88,7 @@ enum { OPTION_FILENAME, OPTION_COLUMN, OPTION_SEPERATOR, + OPTION_LISTEDIT, OPTION_CHECKLIST, OPTION_RADIOLIST, OPTION_PROGRESSTEXT, @@ -450,6 +451,15 @@ struct poptOption list_options[] = { N_("Set output separator character"), NULL }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LISTEDIT, + N_("Allow changes to text"), + NULL + }, POPT_TABLEEND }; @@ -559,6 +569,134 @@ struct poptOption warning_options[] = { POPT_TABLEEND }; +struct poptOption gtk_options[] = { + { + "gdk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to set"), + N_("FLAGS") + }, + { + "gdk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to unset"), + N_("FLAGS") + }, + /* X11 only */ + { + "display", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("X display to use"), + N_("DISPLAY") + }, +#ifdef HAVE_GTK_MULTIHEAD + /* X11 & multi-head only */ + { + "screen", + '\0', + POPT_ARG_INT, + NULL, + 0, + N_("X screen to use"), + N_("SCREEN") + }, +#endif + /* X11 only */ + { + "sync", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make X calls synchronous"), + NULL + }, + { + "name", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program name as used by the window manager"), + N_("NAME") + }, + { + "class", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program class as used by the window manager"), + N_("CLASS") + }, + /* X11 only */ + { + "gxid-host", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("HOST") + }, + /* X11 only */ + { + "gxid-port", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("PORT") + }, + { + "gtk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to set"), + N_("FLAGS") + }, + { + "gtk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to unset"), + N_("FLAGS") + }, + { + "g-fatal-warnings", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make all warnings fatal"), + NULL + }, + { + "gtk-module", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Load an additional Gtk module"), + N_("MODULE") + }, + POPT_TABLEEND +}; + struct poptOption miscellaneous_options[] = { { NULL, @@ -699,6 +837,15 @@ struct poptOption application_options[] = { N_("Warning options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + gtk_options, + 0, + N_("GTK+ options"), + NULL + }, { NULL, '\0', @@ -751,6 +898,7 @@ zenity_init_parsing_options (void) { results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; + results->tree_data->editable = FALSE; } static void @@ -825,21 +973,17 @@ main (gint argc, gchar **argv) { ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - poptReadDefaultConfig(ctx, TRUE); + poptReadDefaultConfig(ctx, TRUE); while((nextopt = poptGetNextOpt(ctx)) > 0) /*nothing*/; - if (nextopt != -1) { - /* FIXME : We should probably handle --display, or at least maybe load some of the gtk+ - * commandline options - */ - g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } - - gtk_init (&argc, &argv); + zenity_free_parsing_options (); + exit (-1); + } + gtk_init (&argc, &argv); if (argc < 2) { g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); @@ -920,6 +1064,7 @@ zenity_parse_options_callback (poptContext ctx, static gboolean parse_option_separator = FALSE; static gint parse_option_text = 0; static gint parse_option_file = 0; + static gint parse_option_editable = 0; if (reason == POPT_CALLBACK_REASON_POST) { return; @@ -1096,14 +1241,28 @@ zenity_parse_options_callback (poptContext ctx, results->entry_data->visible = FALSE; break; + case OPTION_LISTEDIT: case OPTION_TEXTEDIT: - if (results->mode != MODE_TEXTINFO) - zenity_error ("--editable", ERROR_SUPPORT); - if (results->text_data->editable == TRUE) + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) zenity_error ("--editable", ERROR_DUPLICATE); - results->text_data->editable = TRUE; + switch (results->mode) { + case MODE_TEXTINFO: + results->text_data->editable = TRUE; + break; + case MODE_LIST: + results->tree_data->editable = TRUE; + break; + default: + zenity_error ("--editable", ERROR_SUPPORT); + } + parse_option_editable++; break; case OPTION_FILENAME: case OPTION_TEXTFILE: diff --git a/src/tree.c b/src/tree.c index c19b1804..e5573fff 100644 --- a/src/tree.c +++ b/src/tree.c @@ -24,6 +24,7 @@ */ #include +#include #include "zenity.h" #include "util.h" @@ -56,7 +57,7 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g } static void -zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles) +zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles, gboolean editable) { GtkTreeModel *model; GtkTreeIter iter; @@ -80,7 +81,10 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col else gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); } - + + if (editable) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { GtkWidget *scrolled_window; GtkRequisition rectangle; @@ -96,6 +100,26 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_col } } +static void +zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer data) +{ + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; + + model = GTK_TREE_MODEL (data); + path = gtk_tree_path_new_from_string (path_string); + + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, + column, new_text, -1); + + gtk_tree_path_free (path); +} + void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { @@ -151,7 +175,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) /* Create an empty list store */ model = g_object_new (GTK_TYPE_LIST_STORE, NULL); - column_types = g_new (GType, n_columns); + if (tree_data->editable) + column_types = g_new (GType, n_columns + 1); + else + column_types = g_new (GType, n_columns); for (i = 0; i < n_columns; i++) { /* Have the limitation that the radioboxes and checkboxes are in the first column */ @@ -161,10 +188,19 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) column_types[i] = G_TYPE_STRING; } - gtk_list_store_set_column_types (model, n_columns, column_types); + if (tree_data->editable) + column_types[n_columns] = G_TYPE_BOOLEAN; + + if (tree_data->editable) + gtk_list_store_set_column_types (model, n_columns + 1, column_types); + else + gtk_list_store_set_column_types (model, n_columns, column_types); gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_MULTIPLE); + column_index = 0; for (tmp = tree_data->columns; tmp; tmp = tmp->next) { @@ -186,9 +222,28 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) } else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, NULL); + if (tree_data->editable == TRUE) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), "column", + (gint *) column_index); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", column_index, + "editable", n_columns, + NULL); + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, NULL); + } + gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); } @@ -196,9 +251,28 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) first_column = TRUE; } else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, NULL); + if (tree_data->editable == TRUE) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), "column", + (gint *) column_index); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", column_index, + "editable", n_columns, + NULL); + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, NULL); + } + gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); @@ -211,9 +285,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); if (tree_data->radiobox || tree_data->checkbox) - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE); + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); else - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE); + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); gtk_widget_show (dialog); gtk_main (); @@ -258,9 +332,9 @@ zenity_tree_dialog_output (void) for (tmp = selected; tmp; tmp = tmp->next) { if (tmp->next != NULL) { /* FIXME: There must be a nicer way to do this. This is just arse */ - if (strstr (separator, "\\n") != NULL) + if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) g_printerr ("%s\n", tmp->data); - else if (strstr (separator, "\\t") != NULL) + else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) g_printerr ("%s\t", tmp->data); else g_printerr ("%s%s", tmp->data, separator); diff --git a/src/zenity.glade b/src/zenity.glade index 3141c855..46eda5af 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -819,7 +819,7 @@ True - You have not done the right thing, clearly. + An error has occurred. False True GTK_JUSTIFY_LEFT @@ -1064,7 +1064,7 @@ True - You have done the right thing, hurrah. + All updates are complete. False True GTK_JUSTIFY_LEFT diff --git a/src/zenity.h b/src/zenity.h index de833f0b..28944164 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -78,6 +78,7 @@ typedef struct { gboolean checkbox; gboolean radiobox; gchar *separator; + gboolean editable; const gchar **data; } ZenityTreeData; -- cgit From 574404b13e1b301bd7abff84c027226503cc4df9 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 29 Jan 2003 02:05:44 +0000 Subject: Update 2003-01-29 Glynn Foster * README: Update * configure.in: Remove some bogus configure checks that we almost certainly don't need. * src/about.c, data/Makefile.am, data/*.png: Add new pixbuf for about dialog. * TODO: Update accordingly --- src/about.c | 219 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 5e7003fb..1e736551 100644 --- a/src/about.c +++ b/src/about.c @@ -27,10 +27,16 @@ #include "config.h" #include "zenity.h" #include "util.h" +#include +#include #include #define GTK_RESPONSE_CREDITS 0 #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" +#define ZENITY_CLOTHES_PATH ZENITY_DATADIR "/clothes/" + +#define ZENITY_CANVAS_X 580.0 +#define ZENITY_CANVAS_Y 400.0 static GtkWidget *dialog; static GtkWidget *cred_dialog; @@ -54,6 +60,214 @@ static const gchar *author_credits[] = { gchar *translator_credits; +static gint +zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) +{ + static double x, y; + double new_x, new_y; + GdkCursor *fleur; + static int dragging; + double item_x, item_y; + + /* set item_[xy] to the event x,y position in the parent's item-relative coordinates */ + item_x = event->button.x; + item_y = event->button.y; + gnome_canvas_item_w2i (item->parent, &item_x, &item_y); + + switch (event->type) { + case GDK_BUTTON_PRESS: + switch (event->button.button) { + case 1: + if (event->button.state & GDK_SHIFT_MASK) + gtk_object_destroy (GTK_OBJECT (item)); + else { + x = item_x; + y = item_y; + + fleur = gdk_cursor_new (GDK_FLEUR); +#if 0 + gnome_canvas_item_grab (item, + GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, + fleur, + event->button.time); +#endif + gdk_cursor_unref (fleur); + dragging = TRUE; + } + break; + + case 2: + if (event->button.state & GDK_SHIFT_MASK) + gnome_canvas_item_lower_to_bottom (item); + else + gnome_canvas_item_lower (item, 1); + break; + + case 3: + if (event->button.state & GDK_SHIFT_MASK) + gnome_canvas_item_raise_to_top (item); + else + gnome_canvas_item_raise (item, 1); + break; + + default: + break; + } + + break; + + case GDK_MOTION_NOTIFY: + if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { + new_x = item_x; + new_y = item_y; + + gnome_canvas_item_move (item, new_x - x, new_y - y); + x = new_x; + y = new_y; + } + break; + + case GDK_BUTTON_RELEASE: + gnome_canvas_item_ungrab (item, event->button.time); + dragging = FALSE; + break; + + default: + break; + } + + return FALSE; +} + +typedef struct +{ + const gchar *filename; + gdouble x, y; +} MonkClothes; + +static MonkClothes monk_clothes[] = { + {"gnome-tshirt.png", 10.0, 10.0} +}; + +static void +zenity_create_clothes (GtkWidget *canvas_board) +{ + GdkPixbuf *pixbuf; + GnomeCanvasItem *canvas_item; + gchar *pixbuf_path; + gint i; + + for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) { + pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); + pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL); + + canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), + gnome_canvas_pixbuf_get_type (), + "x", monk_clothes[i].x, + "y", monk_clothes[i].y, + "pixbuf", pixbuf, + "anchor", GTK_ANCHOR_NW, + NULL); + g_signal_connect (G_OBJECT (canvas_item), "event", + G_CALLBACK (zenity_move_clothes_event), NULL); + } +} + +static GtkWidget * +zenity_create_monk (void) +{ + GtkWidget *canvas_board; + GnomeCanvasItem *canvas_item; + GnomeCanvasGroup *root; + GdkPixbuf *pixbuf; + GdkColor color = { 0, 0xffff, 0xffff, 0xffff }; + + canvas_board = gnome_canvas_new (); + + gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0, + ZENITY_CANVAS_X, ZENITY_CANVAS_Y); + + gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y); + + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)), + &color, FALSE, TRUE); + + gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color); + + pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL); + + canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), + gnome_canvas_pixbuf_get_type (), + "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 20.0, + "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 10.0, + "pixbuf", pixbuf, + "anchor", GTK_ANCHOR_NW, + NULL); + + zenity_create_clothes (canvas_board); + + return canvas_board; +} + +static GtkWidget * +zenity_create_boutique (void) +{ + GtkWidget *window; + GtkWidget *canvas; + + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + + /* FIXME: We need to connect to the close event + * for the window + */ + + canvas = zenity_create_monk (); + gtk_container_add (GTK_CONTAINER (window), canvas); + + return window; +} + +static gboolean +zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) +{ + static gint string_count; + + if (string_count >= 3) + return FALSE; + + switch (event->keyval) { + case GDK_N: + case GDK_n: + if (string_count == 2) { + GtkWidget *window; + window = zenity_create_boutique (); + gtk_widget_show_all (window); + string_count++; + } else { + string_count = 0; + } + break; + case GDK_Z: + case GDK_z: + if (string_count == 0) + string_count++; + else + string_count = 0; + break; + case GDK_E: + case GDK_e: + if (string_count == 1) + string_count++; + else + string_count = 0; + break; + default: + string_count = 0; + } + + return FALSE; +} + void zenity_about (ZenityData *data) { @@ -78,6 +292,8 @@ zenity_about (ZenityData *data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "key_press_event", + G_CALLBACK (zenity_zen_wisdom), glade_dialog); zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png")); @@ -91,14 +307,17 @@ zenity_about (ZenityData *data) } label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); text = g_strdup_printf ("Zenity %s", VERSION); gtk_label_set_markup (GTK_LABEL (label), text); g_free (text); label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); gtk_label_set_markup (GTK_LABEL (label), text); g_free (text); -- cgit From feef0396836668db950026ce637ce805900dc1d7 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 29 Jan 2003 02:20:02 +0000 Subject: Don't do a g_assert_not_reached () if we don't have any dialog types. 2003-01-29 Glynn Foster * src/main.c: Don't do a g_assert_not_reached () if we don't have any dialog types. --- src/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 13399236..233aba53 100644 --- a/src/main.c +++ b/src/main.c @@ -1020,6 +1020,10 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_LAST: + g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); + zenity_free_parsing_options (); + exit (-1); default: g_assert_not_reached (); zenity_free_parsing_options (); -- cgit From 8f85e68421d1d16c32aad96151dab2ac52108949 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 1 Feb 2003 11:43:32 +0000 Subject: Okay, I'm a glory hunter. Seperate out the about dialog entries a little. 2003-02-01 Glynn Foster * src/about.c: Okay, I'm a glory hunter. Seperate out the about dialog entries a little. * THANKS: Update. --- src/about.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 1e736551..fa2ad27c 100644 --- a/src/about.c +++ b/src/about.c @@ -45,9 +45,12 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpoin /* Sync with the people in the THANKS file */ static const gchar *author_credits[] = { - "Jonathan Blanford ", - "Anders Carlsson ", + "Author -", "Glynn Foster ", + "", + "Thanks to -", + "Jonathan Blanford ", + "Anders Carlsson ", "John Fleck ", "James Henstridge ", "Mike Newman ", @@ -217,10 +220,7 @@ zenity_create_boutique (void) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - /* FIXME: We need to connect to the close event - * for the window - */ - + zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png")); canvas = zenity_create_monk (); gtk_container_add (GTK_CONTAINER (window), canvas); -- cgit From 9e7cbd647f75de9b974f4038be5f6135343cc44a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 1 Feb 2003 12:13:25 +0000 Subject: Add new. Update coordinates. 2003-02-01 Glynn Foster * data/Makefile.am, data/sunglasses.png: Add new. * src/about.c: Update coordinates. --- src/about.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index fa2ad27c..f3e8b9bc 100644 --- a/src/about.c +++ b/src/about.c @@ -35,8 +35,8 @@ #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" #define ZENITY_CLOTHES_PATH ZENITY_DATADIR "/clothes/" -#define ZENITY_CANVAS_X 580.0 -#define ZENITY_CANVAS_Y 400.0 +#define ZENITY_CANVAS_X 400.0 +#define ZENITY_CANVAS_Y 280.0 static GtkWidget *dialog; static GtkWidget *cred_dialog; @@ -149,7 +149,8 @@ typedef struct } MonkClothes; static MonkClothes monk_clothes[] = { - {"gnome-tshirt.png", 10.0, 10.0} + {"gnome-tshirt.png", 30.0, ZENITY_CANVAS_Y - 150.0}, + {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 } }; static void @@ -201,8 +202,8 @@ zenity_create_monk (void) canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), gnome_canvas_pixbuf_get_type (), - "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 20.0, - "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 10.0, + "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0, + "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0, "pixbuf", pixbuf, "anchor", GTK_ANCHOR_NW, NULL); -- cgit From 452c3426fba4c48781e7963da0ea5656664805f3 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 1 Feb 2003 20:07:25 +0000 Subject: Fix Jonathan's name - I suck. 2003-02-01 Glynn Foster * NEWS, THANKS, src/about.c: Fix Jonathan's name - I suck. --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index f3e8b9bc..9ca799cf 100644 --- a/src/about.c +++ b/src/about.c @@ -49,7 +49,7 @@ static const gchar *author_credits[] = { "Glynn Foster ", "", "Thanks to -", - "Jonathan Blanford ", + "Jonathan Blandford ", "Anders Carlsson ", "John Fleck ", "James Henstridge ", -- cgit From 00e48cb2b53e1e932ef47a17fcc278395f375981 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 3 Feb 2003 01:56:42 +0000 Subject: Add spec file, thanks to Mihai T. Lazarescu. 2003-02-03 Glynn Foster * Makefile.am, configure.in, zenity.spec.in: Add spec file, thanks to Mihai T. Lazarescu. * THANKS, src/about.c: Update. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 9ca799cf..2fe9d3d1 100644 --- a/src/about.c +++ b/src/about.c @@ -53,6 +53,7 @@ static const gchar *author_credits[] = { "Anders Carlsson ", "John Fleck ", "James Henstridge ", + "Mihai T. Lazarescu ", "Mike Newman ", "Havoc Pennington ", "Kristian Rietveld ", -- cgit From 8402c27e771e8c1e6a3b32720edaaa2a6767d455 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 3 Feb 2003 03:16:32 +0000 Subject: Um, you don't really want to know. 2003-02-03 Glynn Foster * data/Makefile.am, data/hawaii-shirt.png, data/surfboard.png, src/about.c: Um, you don't really want to know. --- src/about.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 2fe9d3d1..fcddc68b 100644 --- a/src/about.c +++ b/src/about.c @@ -150,8 +150,10 @@ typedef struct } MonkClothes; static MonkClothes monk_clothes[] = { - {"gnome-tshirt.png", 30.0, ZENITY_CANVAS_Y - 150.0}, - {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 } + {"gnome-tshirt.png", 30.0, 20.0}, + {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 }, + {"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0}, + {"hawaii-shirt.png", ZENITY_CANVAS_X - 50.0, 20.0} }; static void -- cgit From ec7cb56de2307068f36220029a778a93fde88b87 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 3 Feb 2003 22:58:14 +0000 Subject: Raise on mouse click 2003-02-03 Glynn Foster * src/about.c: Raise on mouse click --- src/about.c | 44 +++++--------------------------------------- 1 file changed, 5 insertions(+), 39 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index fcddc68b..0d7f63b7 100644 --- a/src/about.c +++ b/src/about.c @@ -69,7 +69,6 @@ zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data { static double x, y; double new_x, new_y; - GdkCursor *fleur; static int dragging; double item_x, item_y; @@ -80,44 +79,11 @@ zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data switch (event->type) { case GDK_BUTTON_PRESS: - switch (event->button.button) { - case 1: - if (event->button.state & GDK_SHIFT_MASK) - gtk_object_destroy (GTK_OBJECT (item)); - else { - x = item_x; - y = item_y; - - fleur = gdk_cursor_new (GDK_FLEUR); -#if 0 - gnome_canvas_item_grab (item, - GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, - fleur, - event->button.time); -#endif - gdk_cursor_unref (fleur); - dragging = TRUE; - } - break; - - case 2: - if (event->button.state & GDK_SHIFT_MASK) - gnome_canvas_item_lower_to_bottom (item); - else - gnome_canvas_item_lower (item, 1); - break; - - case 3: - if (event->button.state & GDK_SHIFT_MASK) - gnome_canvas_item_raise_to_top (item); - else - gnome_canvas_item_raise (item, 1); - break; - - default: - break; - } - + x = item_x; + y = item_y; + gnome_canvas_item_ungrab (item, event->button.time); + gnome_canvas_item_raise_to_top (item); + dragging = TRUE; break; case GDK_MOTION_NOTIFY: -- cgit From e5149948ec5878d63ffeeeb603bf975a9716f4f1 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 5 Feb 2003 10:37:08 +0000 Subject: Add Ross. 2003-02-05 Glynn Foster * THANKS, src/about.c: Add Ross. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 0d7f63b7..cf0f1196 100644 --- a/src/about.c +++ b/src/about.c @@ -50,6 +50,7 @@ static const gchar *author_credits[] = { "", "Thanks to -", "Jonathan Blandford ", + "Ross Burton ", "Anders Carlsson ", "John Fleck ", "James Henstridge ", -- cgit From 49f89795349a47ae4e061666d84a715bf24f5373 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 10 Mar 2003 17:11:18 +0000 Subject: Mass indentation cleanup. Make sure the glade dialogs aren't initially 2003-03-10 Glynn Foster * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/util.c, src/util.h, src/zenity.glade, src/zenity.h: Mass indentation cleanup. Make sure the glade dialogs aren't initially visible because this avoids a visibility jump. Apparently == TRUE is bad mojo. Fix up. --- src/about.c | 614 ++++++++-------- src/calendar.c | 126 ++-- src/entry.c | 113 +-- src/fileselection.c | 81 +-- src/main.c | 1922 +++++++++++++++++++++++++-------------------------- src/msg.c | 185 ++--- src/progress.c | 194 +++--- src/text.c | 113 +-- src/tree.c | 549 +++++++-------- src/util.c | 697 +++++++++---------- src/util.h | 32 +- src/zenity.glade | 17 +- src/zenity.h | 92 +-- 13 files changed, 2361 insertions(+), 2374 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index cf0f1196..2adcf642 100644 --- a/src/about.c +++ b/src/about.c @@ -45,410 +45,416 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpoin /* Sync with the people in the THANKS file */ static const gchar *author_credits[] = { - "Author -", - "Glynn Foster ", - "", - "Thanks to -", - "Jonathan Blandford ", - "Ross Burton ", - "Anders Carlsson ", - "John Fleck ", - "James Henstridge ", - "Mihai T. Lazarescu ", - "Mike Newman ", - "Havoc Pennington ", - "Kristian Rietveld ", - "Jakub Steiner ", - "Tom Tromey ", - NULL + "Author -", + "Glynn Foster ", + "", + "Thanks to -", + "Jonathan Blandford ", + "Ross Burton ", + "Anders Carlsson ", + "John Fleck ", + "James Henstridge ", + "Mihai T. Lazarescu ", + "Mike Newman ", + "Havoc Pennington ", + "Kristian Rietveld ", + "Jakub Steiner ", + "Tom Tromey ", + NULL }; gchar *translator_credits; static gint -zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data) +zenity_move_clothes_event (GnomeCanvasItem *item, + GdkEvent *event, + gpointer data) { - static double x, y; - double new_x, new_y; - static int dragging; - double item_x, item_y; - - /* set item_[xy] to the event x,y position in the parent's item-relative coordinates */ - item_x = event->button.x; - item_y = event->button.y; - gnome_canvas_item_w2i (item->parent, &item_x, &item_y); - - switch (event->type) { - case GDK_BUTTON_PRESS: - x = item_x; - y = item_y; - gnome_canvas_item_ungrab (item, event->button.time); - gnome_canvas_item_raise_to_top (item); - dragging = TRUE; - break; - - case GDK_MOTION_NOTIFY: - if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { - new_x = item_x; - new_y = item_y; - - gnome_canvas_item_move (item, new_x - x, new_y - y); - x = new_x; - y = new_y; - } - break; - - case GDK_BUTTON_RELEASE: - gnome_canvas_item_ungrab (item, event->button.time); - dragging = FALSE; - break; - - default: - break; - } - - return FALSE; + static double x, y; + double new_x, new_y; + static int dragging; + double item_x, item_y; + + /* set item_[xy] to the event x,y position in the parent's + * item-relative coordinates + */ + + item_x = event->button.x; + item_y = event->button.y; + gnome_canvas_item_w2i (item->parent, &item_x, &item_y); + + switch (event->type) { + case GDK_BUTTON_PRESS: + x = item_x; + y = item_y; + gnome_canvas_item_ungrab (item, event->button.time); + gnome_canvas_item_raise_to_top (item); + dragging = TRUE; + break; + + case GDK_MOTION_NOTIFY: + if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) { + new_x = item_x; + new_y = item_y; + + gnome_canvas_item_move (item, new_x - x, new_y - y); + x = new_x; + y = new_y; + } + break; + + case GDK_BUTTON_RELEASE: + gnome_canvas_item_ungrab (item, event->button.time); + dragging = FALSE; + break; + + default: + break; + } + + return FALSE; } typedef struct { - const gchar *filename; - gdouble x, y; + const gchar *filename; + gdouble x, y; } MonkClothes; static MonkClothes monk_clothes[] = { - {"gnome-tshirt.png", 30.0, 20.0}, - {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 }, - {"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0}, - {"hawaii-shirt.png", ZENITY_CANVAS_X - 50.0, 20.0} + {"gnome-tshirt.png", 30.0, 20.0}, + {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 }, + {"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0}, + {"hawaii-shirt.png", ZENITY_CANVAS_X - 50.0, 20.0} }; static void zenity_create_clothes (GtkWidget *canvas_board) { - GdkPixbuf *pixbuf; - GnomeCanvasItem *canvas_item; - gchar *pixbuf_path; - gint i; - - for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) { - pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); - pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL); - - canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), - gnome_canvas_pixbuf_get_type (), - "x", monk_clothes[i].x, - "y", monk_clothes[i].y, - "pixbuf", pixbuf, - "anchor", GTK_ANCHOR_NW, - NULL); - g_signal_connect (G_OBJECT (canvas_item), "event", - G_CALLBACK (zenity_move_clothes_event), NULL); - } + GdkPixbuf *pixbuf; + GnomeCanvasItem *canvas_item; + gchar *pixbuf_path; + gint i; + + for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) { + pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); + pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL); + + canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), + gnome_canvas_pixbuf_get_type (), + "x", monk_clothes[i].x, + "y", monk_clothes[i].y, + "pixbuf", pixbuf, + "anchor", GTK_ANCHOR_NW, + NULL); + g_signal_connect (G_OBJECT (canvas_item), "event", + G_CALLBACK (zenity_move_clothes_event), NULL); + } } static GtkWidget * zenity_create_monk (void) { - GtkWidget *canvas_board; - GnomeCanvasItem *canvas_item; - GnomeCanvasGroup *root; - GdkPixbuf *pixbuf; - GdkColor color = { 0, 0xffff, 0xffff, 0xffff }; + GtkWidget *canvas_board; + GnomeCanvasItem *canvas_item; + GnomeCanvasGroup *root; + GdkPixbuf *pixbuf; + GdkColor color = { 0, 0xffff, 0xffff, 0xffff }; - canvas_board = gnome_canvas_new (); + canvas_board = gnome_canvas_new (); - gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0, - ZENITY_CANVAS_X, ZENITY_CANVAS_Y); + gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0, + ZENITY_CANVAS_X, ZENITY_CANVAS_Y); - gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y); + gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y); - gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)), - &color, FALSE, TRUE); + gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)), + &color, FALSE, TRUE); - gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color); + gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color); - pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL); + pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL); - canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), - gnome_canvas_pixbuf_get_type (), - "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0, - "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0, - "pixbuf", pixbuf, - "anchor", GTK_ANCHOR_NW, - NULL); + canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), + gnome_canvas_pixbuf_get_type (), + "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0, + "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0, + "pixbuf", pixbuf, + "anchor", GTK_ANCHOR_NW, + NULL); - zenity_create_clothes (canvas_board); + zenity_create_clothes (canvas_board); - return canvas_board; + return canvas_board; } static GtkWidget * zenity_create_boutique (void) { - GtkWidget *window; - GtkWidget *canvas; + GtkWidget *window; + GtkWidget *canvas; - window = gtk_window_new (GTK_WINDOW_TOPLEVEL); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png")); - canvas = zenity_create_monk (); - gtk_container_add (GTK_CONTAINER (window), canvas); + zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png")); + canvas = zenity_create_monk (); + gtk_container_add (GTK_CONTAINER (window), canvas); - return window; + return window; } static gboolean zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) { - static gint string_count; - - if (string_count >= 3) - return FALSE; - - switch (event->keyval) { - case GDK_N: - case GDK_n: - if (string_count == 2) { - GtkWidget *window; - window = zenity_create_boutique (); - gtk_widget_show_all (window); - string_count++; - } else { - string_count = 0; - } - break; - case GDK_Z: - case GDK_z: - if (string_count == 0) - string_count++; - else - string_count = 0; - break; - case GDK_E: - case GDK_e: - if (string_count == 1) - string_count++; - else - string_count = 0; - break; - default: - string_count = 0; - } - - return FALSE; + static gint string_count; + + if (string_count >= 3) + return FALSE; + + switch (event->keyval) { + case GDK_N: + case GDK_n: + if (string_count == 2) { + GtkWidget *window; + window = zenity_create_boutique (); + gtk_widget_show_all (window); + string_count++; + } else { + string_count = 0; + } + break; + case GDK_Z: + case GDK_z: + if (string_count == 0) + string_count++; + else + string_count = 0; + break; + case GDK_E: + case GDK_e: + if (string_count == 1) + string_count++; + else + string_count = 0; + break; + default: + string_count = 0; + } + + return FALSE; } void zenity_about (ZenityData *data) { - GladeXML *glade_dialog = NULL; - GdkPixbuf *pixbuf; - GtkWidget *label; - GtkWidget *image; - gchar *text; + GladeXML *glade_dialog = NULL; + GdkPixbuf *pixbuf; + GtkWidget *label; + GtkWidget *image; + gchar *text; - glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - translator_credits = _("translator_credits"); + translator_credits = _("translator_credits"); - glade_xml_signal_autoconnect (glade_dialog); + glade_xml_signal_autoconnect (glade_dialog); - dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_about_dialog_response), data); - g_signal_connect (G_OBJECT (dialog), "key_press_event", - G_CALLBACK (zenity_zen_wisdom), glade_dialog); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_about_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "key_press_event", + G_CALLBACK (zenity_zen_wisdom), glade_dialog); - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png")); + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png")); - image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); + image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); - pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); + pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - if (pixbuf != NULL) { - gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); - g_object_unref (pixbuf); - } - - label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("Zenity %s", VERSION); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - if (glade_dialog) - g_object_unref (glade_dialog); - - gtk_widget_show (dialog); - gtk_main (); + if (pixbuf != NULL) { + gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); + g_object_unref (pixbuf); + } + + label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); + text = g_strdup_printf ("Zenity %s", VERSION); + gtk_label_set_markup (GTK_LABEL (label), text); + g_free (text); + + label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); + gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); + + label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); + gtk_label_set_selectable (GTK_LABEL (label), FALSE); + text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); + gtk_label_set_markup (GTK_LABEL (label), text); + g_free (text); + + if (glade_dialog) + g_object_unref (glade_dialog); + + gtk_widget_show (dialog); + gtk_main (); } static GtkWidget * zenity_about_create_label (void) { - GtkWidget *label; + GtkWidget *label; - label = gtk_label_new (""); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - gtk_misc_set_padding (GTK_MISC (label), 8, 8); + label = gtk_label_new (""); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); + gtk_misc_set_padding (GTK_MISC (label), 8, 8); - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); + gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - return label; + return label; } static void zenity_about_update_author_label (GtkWidget *label) { - GString *string; - gchar *tmp; - gint i = 0; + GString *string; + gchar *tmp; + gint i = 0; - gtk_widget_show (label); + gtk_widget_show (label); - string = g_string_new (""); + string = g_string_new (""); - for (i = 0; author_credits[i] != NULL; i++) { - tmp = g_markup_escape_text (author_credits[i], -1); - g_string_append (string, tmp); + for (i = 0; author_credits[i] != NULL; i++) { + tmp = g_markup_escape_text (author_credits[i], -1); + g_string_append (string, tmp); - if (author_credits[i+1] != NULL) - g_string_append (string, "\n"); + if (author_credits[i+1] != NULL) + g_string_append (string, "\n"); - g_free (tmp); - } - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); + g_free (tmp); + } + gtk_label_set_markup (GTK_LABEL (label), string->str); + g_string_free (string, TRUE); } static void zenity_about_update_translator_label (GtkWidget *label) { - GString *string; - gchar *tmp; + GString *string; + gchar *tmp; - if (strcmp (translator_credits, "translator_credits") == 0) { - gtk_widget_hide (label); - return; - } else { - gtk_widget_show (label); - } + if (strcmp (translator_credits, "translator_credits") == 0) { + gtk_widget_hide (label); + return; + } else { + gtk_widget_show (label); + } - string = g_string_new (""); + string = g_string_new (""); - tmp = g_markup_escape_text (translator_credits, -1); - g_string_append (string, tmp); - g_free (tmp); + tmp = g_markup_escape_text (translator_credits, -1); + g_string_append (string, tmp); + g_free (tmp); - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); + gtk_label_set_markup (GTK_LABEL (label), string->str); + g_string_free (string, TRUE); } static void zenity_about_dialog_credits_response (GtkWidget *widget, int response, gpointer data) { - gtk_widget_destroy (widget); - widget = NULL; + gtk_widget_destroy (widget); + widget = NULL; } static void zenity_about_display_credits_dialog (void) { - GtkWidget *credits_dialog; - GtkWidget *label, *notebook, *sw; - - if (cred_dialog != NULL) { - gtk_window_present (GTK_WINDOW (cred_dialog)); - return; - } - - credits_dialog = gtk_dialog_new_with_buttons (_("Credits"), - GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - g_signal_connect (G_OBJECT (credits_dialog), "response", - G_CALLBACK (gtk_widget_destroy), credits_dialog); - g_signal_connect (G_OBJECT (credits_dialog), "destroy", - G_CALLBACK (gtk_widget_destroyed), &cred_dialog); - - cred_dialog = credits_dialog; - - gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260); - gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK); - - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0); - - if (author_credits != NULL) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Written by"))); - zenity_about_update_author_label (label); - } - - if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Translated by"))); - zenity_about_update_translator_label (label); - } - - gtk_widget_show_all (credits_dialog); + GtkWidget *credits_dialog; + GtkWidget *label, *notebook, *sw; + + if (cred_dialog != NULL) { + gtk_window_present (GTK_WINDOW (cred_dialog)); + return; + } + + credits_dialog = gtk_dialog_new_with_buttons (_("Credits"), + GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + + g_signal_connect (G_OBJECT (credits_dialog), "response", + G_CALLBACK (gtk_widget_destroy), credits_dialog); + g_signal_connect (G_OBJECT (credits_dialog), "destroy", + G_CALLBACK (gtk_widget_destroyed), &cred_dialog); + + cred_dialog = credits_dialog; + + gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260); + gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK); + + notebook = gtk_notebook_new (); + gtk_container_set_border_width (GTK_CONTAINER (notebook), 8); + gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0); + + if (author_credits != NULL) { + label = zenity_about_create_label (); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, + gtk_label_new (_("Written by"))); + zenity_about_update_author_label (label); + } + + if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) { + label = zenity_about_create_label (); + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); + gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); + gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, + gtk_label_new (_("Translated by"))); + zenity_about_update_translator_label (label); + } + + gtk_widget_show_all (credits_dialog); } static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - GError *error = NULL; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_HELP: - zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL); - break; - - case GTK_RESPONSE_CREDITS: - zenity_about_display_credits_dialog (); - break; - default: - /* Esc dialog */ - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + GError *error = NULL; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_HELP: + zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL); + break; + + case GTK_RESPONSE_CREDITS: + zenity_about_display_credits_dialog (); + break; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/calendar.c b/src/calendar.c index 68956e76..fc1c014d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -35,85 +35,87 @@ static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gp void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { - GladeXML *glade_dialog = NULL; - GtkWidget *dialog; - GtkWidget *text; + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text; - zen_cal_data = cal_data; + zen_cal_data = cal_data; - glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); + glade_xml_signal_autoconnect (glade_dialog); - dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_calendar_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); - if (cal_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + if (cal_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); - calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - if (cal_data->month > 0 && cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); - if (cal_data->day > 0) - gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + if (cal_data->month > 0 && cal_data->year > 0) + gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); + if (cal_data->day > 0) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - gtk_widget_show (dialog); - gtk_main (); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data; - gint day, month, year; - gchar time_string[128]; - GDate *date = NULL; - - zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, - zen_cal_data->date_format, date); - g_printerr ("%s\n", time_string); - if (date != NULL) - g_date_free (date); - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - /* Esc dialog */ - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data; + gint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, + zen_cal_data->date_format, date); + g_printerr ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); + + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/entry.c b/src/entry.c index 893fbf62..0ccd4c0e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -32,79 +32,80 @@ static GtkWidget *entry; void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { - GladeXML *glade_dialog = NULL; - GtkWidget *dialog; - GtkWidget *text; + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text; - glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); - - dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_entry_dialog_response), data); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_entry_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); - if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); - entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - if (entry_data->entry_text) - gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - if (entry_data->visible == FALSE) - g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + if (!entry_data->visible) + g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - const gchar *text; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - if (text != NULL) - g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); - - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - /* Esc dialog */ - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + const gchar *text; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/fileselection.c b/src/fileselection.c index 74122f87..6655f925 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -29,60 +29,61 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int respons void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GladeXML *glade_dialog; - GtkWidget *dialog; + GladeXML *glade_dialog; + GtkWidget *dialog; - glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); - - dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_fileselection_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); - if (file_data->uri) - gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->uri) + gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); - gtk_main_quit (); - break; + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); + gtk_main_quit (); + break; - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; - default: - zen_data->exit_code = 1; - break; - } + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/main.c b/src/main.c index 233aba53..3985dfd3 100644 --- a/src/main.c +++ b/src/main.c @@ -27,844 +27,844 @@ #include typedef enum { - MODE_CALENDAR, - MODE_ENTRY, - MODE_ERROR, - MODE_FILE, - MODE_LIST, - MODE_PROGRESS, - MODE_QUESTION, - MODE_TEXTINFO, - MODE_WARNING, - MODE_INFO, - MODE_ABOUT, - MODE_LAST + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_INFO, + MODE_ABOUT, + MODE_LAST } ZenityDialogMode; typedef enum { - ERROR_DUPLICATE, - ERROR_SUPPORT, - ERROR_DIALOG, - ERROR_LAST + ERROR_DUPLICATE, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST } ZenityError; typedef struct { - ZenityDialogMode mode; - ZenityData *data; - - ZenityCalendarData *calendar_data; - ZenityMsgData *msg_data; - ZenityFileData *file_data; - ZenityEntryData *entry_data; - ZenityProgressData *progress_data; - ZenityTextData *text_data; - ZenityTreeData *tree_data; + ZenityDialogMode mode; + ZenityData *data; + + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; } ZenityParsingOptions; enum { - OPTION_CALENDAR = 1, - OPTION_DATEFORMAT, - OPTION_ENTRY, - OPTION_ERROR, - OPTION_INFO, - OPTION_FILE, - OPTION_LIST, - OPTION_PROGRESS, - OPTION_QUESTION, - OPTION_TEXTINFO, - OPTION_TEXTEDIT, - OPTION_WARNING, - OPTION_TITLE, - OPTION_ICON, - OPTION_CALENDARTEXT, - OPTION_DAY, - OPTION_MONTH, - OPTION_YEAR, - OPTION_ENTRYTEXT, - OPTION_INPUTTEXT, - OPTION_HIDETEXT, - OPTION_ERRORTEXT, - OPTION_INFOTEXT, - OPTION_FILENAME, - OPTION_COLUMN, - OPTION_SEPERATOR, - OPTION_LISTEDIT, - OPTION_CHECKLIST, - OPTION_RADIOLIST, - OPTION_PROGRESSTEXT, - OPTION_PERCENTAGE, - OPTION_PULSATE, - OPTION_QUESTIONTEXT, - OPTION_TEXTFILE, - OPTION_WARNINGTEXT, - OPTION_ABOUT, - OPTION_VERSION, - OPTION_LAST, + OPTION_CALENDAR = 1, + OPTION_DATEFORMAT, + OPTION_ENTRY, + OPTION_ERROR, + OPTION_INFO, + OPTION_FILE, + OPTION_LIST, + OPTION_PROGRESS, + OPTION_QUESTION, + OPTION_TEXTINFO, + OPTION_TEXTEDIT, + OPTION_WARNING, + OPTION_TITLE, + OPTION_ICON, + OPTION_CALENDARTEXT, + OPTION_DAY, + OPTION_MONTH, + OPTION_YEAR, + OPTION_ENTRYTEXT, + OPTION_INPUTTEXT, + OPTION_HIDETEXT, + OPTION_ERRORTEXT, + OPTION_INFOTEXT, + OPTION_FILENAME, + OPTION_COLUMN, + OPTION_SEPERATOR, + OPTION_LISTEDIT, + OPTION_CHECKLIST, + OPTION_RADIOLIST, + OPTION_PROGRESSTEXT, + OPTION_PERCENTAGE, + OPTION_PULSATE, + OPTION_QUESTIONTEXT, + OPTION_TEXTFILE, + OPTION_WARNINGTEXT, + OPTION_ABOUT, + OPTION_VERSION, + OPTION_LAST, }; static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); struct poptOption options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "calendar", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CALENDAR, - N_("Display calendar dialog"), - NULL - }, - { - "entry", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ENTRY, - N_("Display text entry dialog"), - NULL - }, - { - "error", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ERROR, - N_("Display error dialog"), - NULL - }, - { - "file-selection", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_FILE, - N_("Display file selection dialog"), - NULL - }, - { - "info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_INFO, - N_("Display info dialog"), - NULL - }, - { - "list", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LIST, - N_("Display list dialog"), - NULL - }, - { - "progress", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PROGRESS, - N_("Display progress indication dialog"), - NULL - }, - { - "question", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_QUESTION, - N_("Display question dialog"), - NULL - }, - { - "text-info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTINFO, - N_("Display text information dialog"), - NULL - }, - { - "warning", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_WARNING, - N_("Display warning dialog"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "calendar", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CALENDAR, + N_("Display calendar dialog"), + NULL + }, + { + "entry", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ENTRY, + N_("Display text entry dialog"), + NULL + }, + { + "error", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ERROR, + N_("Display error dialog"), + NULL + }, + { + "file-selection", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_FILE, + N_("Display file selection dialog"), + NULL + }, + { + "info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_INFO, + N_("Display info dialog"), + NULL + }, + { + "list", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LIST, + N_("Display list dialog"), + NULL + }, + { + "progress", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PROGRESS, + N_("Display progress indication dialog"), + NULL + }, + { + "question", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_QUESTION, + N_("Display question dialog"), + NULL + }, + { + "text-info", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTINFO, + N_("Display text information dialog"), + NULL + }, + { + "warning", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_WARNING, + N_("Display warning dialog"), + NULL + }, + POPT_TABLEEND }; struct poptOption general_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "title", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TITLE, - N_("Set the dialog title"), - N_("TITLE") - }, - { - "window-icon", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ICON, - N_("Set the window icon"), - N_("ICONPATH") - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "title", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TITLE, + N_("Set the dialog title"), + N_("TITLE") + }, + { + "window-icon", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ICON, + N_("Set the window icon"), + N_("ICONPATH") + }, + POPT_TABLEEND }; struct poptOption calendar_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_CALENDARTEXT, - N_("Set the dialog text"), - NULL - }, - { - "day", - '\0', - POPT_ARG_INT, - NULL, - OPTION_DAY, - N_("Set the calendar day"), - NULL - }, - { - "month", - '\0', - POPT_ARG_INT, - NULL, - OPTION_MONTH, - N_("Set the calendar month"), - NULL - }, - { - "year", - '\0', - POPT_ARG_INT, - NULL, - OPTION_YEAR, - N_("Set the calendar year"), - NULL - }, - { "date-format", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_DATEFORMAT, - N_("Set the format for the returned date"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_CALENDARTEXT, + N_("Set the dialog text"), + NULL + }, + { + "day", + '\0', + POPT_ARG_INT, + NULL, + OPTION_DAY, + N_("Set the calendar day"), + NULL + }, + { + "month", + '\0', + POPT_ARG_INT, + NULL, + OPTION_MONTH, + N_("Set the calendar month"), + NULL + }, + { + "year", + '\0', + POPT_ARG_INT, + NULL, + OPTION_YEAR, + N_("Set the calendar year"), + NULL + }, + { "date-format", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_DATEFORMAT, + N_("Set the format for the returned date"), + NULL + }, + POPT_TABLEEND }; struct poptOption entry_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ENTRYTEXT, - N_("Set the dialog text"), - NULL - }, - { - "entry-text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INPUTTEXT, - N_("Set the entry text"), - NULL - }, - { - "hide-text", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_HIDETEXT, - N_("Hide the entry text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ENTRYTEXT, + N_("Set the dialog text"), + NULL + }, + { + "entry-text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INPUTTEXT, + N_("Set the entry text"), + NULL + }, + { + "hide-text", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_HIDETEXT, + N_("Hide the entry text"), + NULL + }, + POPT_TABLEEND }; struct poptOption error_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ERRORTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_ERRORTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption info_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INFOTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_INFOTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption file_selection_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_FILENAME, - N_("Set the filename"), - N_("FILENAME") - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_FILENAME, + N_("Set the filename"), + N_("FILENAME") + }, + POPT_TABLEEND }; struct poptOption list_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_COLUMN, - N_("Set the column header"), - NULL - }, - { - "checklist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CHECKLIST, - N_("Use check boxes for first column"), - NULL - }, - { - "radiolist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_RADIOLIST, - N_("Use radio buttons for first column"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character"), - NULL - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LISTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_COLUMN, + N_("Set the column header"), + NULL + }, + { + "checklist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_CHECKLIST, + N_("Use check boxes for first column"), + NULL + }, + { + "radiolist", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_RADIOLIST, + N_("Use radio buttons for first column"), + NULL + }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character"), + NULL + }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_LISTEDIT, + N_("Allow changes to text"), + NULL + }, + POPT_TABLEEND }; struct poptOption progress_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PROGRESSTEXT, - N_("Set the dialog text"), - NULL - }, - { - "percentage", - '\0', - POPT_ARG_INT, - NULL, - OPTION_PERCENTAGE, - N_("Set initial percentage"), - NULL - }, - { - "pulsate", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PULSATE, - N_("Pulsate progress bar"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PROGRESSTEXT, + N_("Set the dialog text"), + NULL + }, + { + "percentage", + '\0', + POPT_ARG_INT, + NULL, + OPTION_PERCENTAGE, + N_("Set initial percentage"), + NULL + }, + { + "pulsate", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_PULSATE, + N_("Pulsate progress bar"), + NULL + }, + POPT_TABLEEND }; - + struct poptOption question_options[] = { - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_QUESTIONTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_QUESTIONTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption text_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TEXTFILE, - N_("Open file"), - N_("FILENAME") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "filename", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_TEXTFILE, + N_("Open file"), + N_("FILENAME") + }, + { + "editable", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_TEXTEDIT, + N_("Allow changes to text"), + NULL + }, + POPT_TABLEEND }; struct poptOption warning_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_WARNINGTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_WARNINGTEXT, + N_("Set the dialog text"), + NULL + }, + POPT_TABLEEND }; struct poptOption gtk_options[] = { - { - "gdk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to set"), - N_("FLAGS") - }, - { - "gdk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to unset"), - N_("FLAGS") - }, - /* X11 only */ - { - "display", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("X display to use"), - N_("DISPLAY") - }, + { + "gdk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to set"), + N_("FLAGS") + }, + { + "gdk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gdk debugging flags to unset"), + N_("FLAGS") + }, + /* X11 only */ + { + "display", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("X display to use"), + N_("DISPLAY") + }, #ifdef HAVE_GTK_MULTIHEAD - /* X11 & multi-head only */ - { - "screen", - '\0', - POPT_ARG_INT, - NULL, - 0, - N_("X screen to use"), - N_("SCREEN") - }, + /* X11 & multi-head only */ + { + "screen", + '\0', + POPT_ARG_INT, + NULL, + 0, + N_("X screen to use"), + N_("SCREEN") + }, #endif - /* X11 only */ - { - "sync", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make X calls synchronous"), - NULL - }, - { - "name", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program name as used by the window manager"), - N_("NAME") - }, - { - "class", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program class as used by the window manager"), - N_("CLASS") - }, - /* X11 only */ - { - "gxid-host", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("HOST") - }, - /* X11 only */ - { - "gxid-port", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("PORT") - }, - { - "gtk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to set"), - N_("FLAGS") - }, - { - "gtk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to unset"), - N_("FLAGS") - }, - { - "g-fatal-warnings", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make all warnings fatal"), - NULL - }, - { - "gtk-module", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Load an additional Gtk module"), - N_("MODULE") - }, - POPT_TABLEEND + /* X11 only */ + { + "sync", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make X calls synchronous"), + NULL + }, + { + "name", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program name as used by the window manager"), + N_("NAME") + }, + { + "class", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Program class as used by the window manager"), + N_("CLASS") + }, + /* X11 only */ + { + "gxid-host", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("HOST") + }, + /* X11 only */ + { + "gxid-port", + '\0', + POPT_ARG_STRING, + NULL, + 0, + NULL, + N_("PORT") + }, + { + "gtk-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to set"), + N_("FLAGS") + }, + { + "gtk-no-debug", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Gtk+ debugging flags to unset"), + N_("FLAGS") + }, + { + "g-fatal-warnings", + '\0', + POPT_ARG_NONE, + NULL, + 0, + N_("Make all warnings fatal"), + NULL + }, + { + "gtk-module", + '\0', + POPT_ARG_STRING, + NULL, + 0, + N_("Load an additional Gtk module"), + N_("MODULE") + }, + POPT_TABLEEND }; struct poptOption miscellaneous_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "about", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ABOUT, - N_("About zenity"), - NULL - }, - { - "version", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_VERSION, - N_("Print version"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "about", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_ABOUT, + N_("About zenity"), + NULL + }, + { + "version", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_VERSION, + N_("Print version"), + NULL + }, + POPT_TABLEEND }; struct poptOption application_options[] = { - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - options, - 0, - N_("Dialog options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - general_options, - 0, - N_("General options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - calendar_options, - 0, - N_("Calendar options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - entry_options, - 0, - N_("Text entry options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - error_options, - 0, - N_("Error options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - file_selection_options, - 0, - N_("File selection options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - info_options, - 0, - N_("Info options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - list_options, - 0, - N_("List options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - progress_options, - 0, - N_("Progress options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - question_options, - 0, - N_("Question options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - text_options, - 0, - N_("Text options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - warning_options, - 0, - N_("Warning options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - gtk_options, - 0, - N_("GTK+ options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - miscellaneous_options, - 0, - N_("Miscellaneous options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - poptHelpOptions, - 0, - N_("Help options"), - NULL - }, - POPT_TABLEEND + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + options, + 0, + N_("Dialog options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + general_options, + 0, + N_("General options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + calendar_options, + 0, + N_("Calendar options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + entry_options, + 0, + N_("Text entry options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + error_options, + 0, + N_("Error options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + file_selection_options, + 0, + N_("File selection options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + info_options, + 0, + N_("Info options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + list_options, + 0, + N_("List options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + progress_options, + 0, + N_("Progress options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + question_options, + 0, + N_("Question options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + text_options, + 0, + N_("Text options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + warning_options, + 0, + N_("Warning options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + gtk_options, + 0, + N_("GTK+ options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + miscellaneous_options, + 0, + N_("Miscellaneous options"), + NULL + }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + poptHelpOptions, + 0, + N_("Help options"), + NULL + }, + POPT_TABLEEND }; ZenityParsingOptions *results; @@ -872,189 +872,189 @@ ZenityParsingOptions *results; static void zenity_init_parsing_options (void) { - results = g_new0 (ZenityParsingOptions, 1); - - /* Initialize the various dialog structures */ - results->mode = MODE_LAST; - results->data = g_new0 (ZenityData, 1); - results->calendar_data = g_new0 (ZenityCalendarData, 1); - results->msg_data = g_new0 (ZenityMsgData, 1); - results->file_data = g_new0 (ZenityFileData, 1); - results->entry_data = g_new0 (ZenityEntryData, 1); - results->progress_data = g_new0 (ZenityProgressData, 1); - results->text_data = g_new0 (ZenityTextData, 1); - results->tree_data = g_new0 (ZenityTreeData, 1); - - /* Give some sensible defaults */ - results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); - results->calendar_data->day = 0; - 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; - results->entry_data->visible = TRUE; - results->tree_data->checkbox = FALSE; - results->tree_data->radiobox = FALSE; - results->tree_data->editable = FALSE; + results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ + results->mode = MODE_LAST; + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); + + /* Give some sensible defaults */ + results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); + results->calendar_data->day = 0; + 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; + results->entry_data->visible = TRUE; + results->tree_data->checkbox = FALSE; + results->tree_data->radiobox = FALSE; + results->tree_data->editable = FALSE; } static void zenity_free_parsing_options (void) { - /* General options */ - if (results->data->dialog_title) - g_free (results->data->dialog_title); - if (results->data->window_icon) - g_free (results->data->window_icon); - - /* Dialog options */ - switch (results->mode) { - case MODE_CALENDAR: - if (results->calendar_data->dialog_text) - g_free (results->calendar_data->dialog_text); - if (results->calendar_data->date_format) - g_free (results->calendar_data->date_format); - break; - case MODE_ENTRY: - if (results->entry_data->dialog_text) - g_free (results->entry_data->dialog_text); - if (results->entry_data->entry_text) - g_free (results->entry_data->entry_text); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - if (results->msg_data->dialog_text) - g_free (results->msg_data->dialog_text); - break; - case MODE_FILE: - if (results->file_data->uri) - g_free (results->file_data->uri); - break; - case MODE_TEXTINFO: - if (results->text_data->uri) - g_free (results->text_data->uri); - break; - case MODE_LIST: - if (results->tree_data->columns) - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); - if (results->tree_data->separator) - g_free (results->tree_data->separator); - break; - default: - break; - } + /* General options */ + if (results->data->dialog_title) + g_free (results->data->dialog_title); + if (results->data->window_icon) + g_free (results->data->window_icon); + + /* Dialog options */ + switch (results->mode) { + case MODE_CALENDAR: + if (results->calendar_data->dialog_text) + g_free (results->calendar_data->dialog_text); + if (results->calendar_data->date_format) + g_free (results->calendar_data->date_format); + break; + case MODE_ENTRY: + if (results->entry_data->dialog_text) + g_free (results->entry_data->dialog_text); + if (results->entry_data->entry_text) + g_free (results->entry_data->entry_text); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + if (results->msg_data->dialog_text) + g_free (results->msg_data->dialog_text); + break; + case MODE_FILE: + if (results->file_data->uri) + g_free (results->file_data->uri); + break; + case MODE_TEXTINFO: + if (results->text_data->uri) + g_free (results->text_data->uri); + break; + case MODE_LIST: + if (results->tree_data->columns) + g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); + if (results->tree_data->separator) + g_free (results->tree_data->separator); + break; + default: + break; + } } gint main (gint argc, gchar **argv) { - ZenityData *general; - ZenityCalendarData *cal_data; - poptContext ctx; - gchar **args; - gint nextopt, retval; - - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); - - zenity_init_parsing_options (); - - /* FIXME: popt doesn't like passing stuff through data - * but it doesn't seem to cope with the data that I try - * to pass in, not quite sure why though. If someone knows - * what I'm doing wrong, we could probably put this back: - * options[0].descrip = (void*) results; - */ - - ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - - poptReadDefaultConfig(ctx, TRUE); - while((nextopt = poptGetNextOpt(ctx)) > 0) - /*nothing*/; - - if (nextopt != -1) { - g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), - poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } - gtk_init (&argc, &argv); - - if (argc < 2) { - g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - zenity_free_parsing_options (); - exit (-1); - } - - switch (results->mode) { - case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); - break; - case MODE_ENTRY: - zenity_entry (results->data, results->entry_data); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - zenity_msg (results->data, results->msg_data); - break; - case MODE_FILE: - zenity_fileselection (results->data, results->file_data); - break; - case MODE_LIST: - results->tree_data->data = poptGetArgs (ctx); - zenity_tree (results->data, results->tree_data); - break; - case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); - break; - case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); - break; - case MODE_ABOUT: - zenity_about (results->data); - break; - case MODE_LAST: - g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_free_parsing_options (); - exit (-1); - default: - g_assert_not_reached (); - zenity_free_parsing_options (); - exit (-1); - } - - retval = results->data->exit_code; - poptFreeContext(ctx); - zenity_free_parsing_options (); - exit (retval); + ZenityData *general; + ZenityCalendarData *cal_data; + poptContext ctx; + gchar **args; + gint nextopt, retval; + + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); + textdomain(GETTEXT_PACKAGE); + + zenity_init_parsing_options (); + + /* FIXME: popt doesn't like passing stuff through data + * but it doesn't seem to cope with the data that I try + * to pass in, not quite sure why though. If someone knows + * what I'm doing wrong, we could probably put this back: + * options[0].descrip = (void*) results; + */ + + ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); + + poptReadDefaultConfig(ctx, TRUE); + while((nextopt = poptGetNextOpt(ctx)) > 0) + /*nothing*/; + + if (nextopt != -1) { + g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + poptBadOption (ctx, 0)); + zenity_free_parsing_options (); + exit (-1); + } + gtk_init (&argc, &argv); + + if (argc < 2) { + g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); + zenity_free_parsing_options (); + exit (-1); + } + + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + zenity_msg (results->data, results->msg_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + results->tree_data->data = poptGetArgs (ctx); + zenity_tree (results->data, results->tree_data); + break; + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + case MODE_ABOUT: + zenity_about (results->data); + break; + case MODE_LAST: + g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); + zenity_free_parsing_options (); + exit (-1); + default: + g_assert_not_reached (); + zenity_free_parsing_options (); + exit (-1); + } + + retval = results->data->exit_code; + poptFreeContext(ctx); + zenity_free_parsing_options (); + exit (retval); } static void zenity_error (gchar *string, ZenityError error) { - switch (error) { - case ERROR_DUPLICATE: - g_printerr (_("%s given twice for the same dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_SUPPORT: - g_printerr (_("%s is not supported for this dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_DIALOG: - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - default: - return; - } + switch (error) { + case ERROR_DUPLICATE: + g_printerr (_("%s given twice for the same dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_("%s is not supported for this dialog\n"), string); + zenity_free_parsing_options (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_("Two or more dialog options specified\n")); + zenity_free_parsing_options (); + exit (-1); + default: + return; + } } static void @@ -1064,13 +1064,13 @@ zenity_parse_options_callback (poptContext ctx, const char *arg, void *data) { - static gboolean parse_option_dateformat = FALSE; - static gboolean parse_option_separator = FALSE; - static gint parse_option_text = 0; - static gint parse_option_file = 0; - static gint parse_option_editable = 0; + static gboolean parse_option_dateformat = FALSE; + static gboolean parse_option_separator = FALSE; + static gint parse_option_text = 0; + static gint parse_option_file = 0; + static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) { + if (reason == POPT_CALLBACK_REASON_POST) { return; } else if (reason != POPT_CALLBACK_REASON_OPTION) @@ -1221,7 +1221,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_CALENDAR) zenity_error ("--date-format", ERROR_SUPPORT); - if (parse_option_dateformat == TRUE) + if (parse_option_dateformat) zenity_error ("--date-format", ERROR_DUPLICATE); results->calendar_data->date_format = g_strdup (arg); @@ -1240,7 +1240,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_ENTRY) zenity_error ("--hide-text", ERROR_SUPPORT); - if (results->entry_data->visible == FALSE) + if (!results->entry_data->visible) zenity_error ("--hide-text", ERROR_DUPLICATE); results->entry_data->visible = FALSE; @@ -1301,7 +1301,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--checkbox", ERROR_SUPPORT); - if (results->tree_data->checkbox == TRUE) + if (results->tree_data->checkbox) zenity_error ("--checkbox", ERROR_DUPLICATE); results->tree_data->checkbox = TRUE; @@ -1310,7 +1310,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--radiobox", ERROR_SUPPORT); - if (results->tree_data->radiobox == TRUE) + if (results->tree_data->radiobox) zenity_error ("--radiobox", ERROR_DUPLICATE); results->tree_data->radiobox = TRUE; @@ -1319,7 +1319,7 @@ zenity_parse_options_callback (poptContext ctx, if (results->mode != MODE_LIST) zenity_error ("--separator", ERROR_SUPPORT); - if (parse_option_separator == TRUE) + if (parse_option_separator) zenity_error ("--separator", ERROR_DUPLICATE); results->tree_data->separator = g_strdup (arg); diff --git a/src/msg.c b/src/msg.c index 5c73af0b..feac59dc 100644 --- a/src/msg.c +++ b/src/msg.c @@ -30,105 +30,108 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointe void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { - GladeXML *glade_dialog; - GtkWidget *dialog; - GtkWidget *text; - - switch (msg_data->mode) { - - case ZENITY_MSG_WARNING: - glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); - break; - - case ZENITY_MSG_QUESTION: - glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); - break; - - case ZENITY_MSG_ERROR: - glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); - break; - - case ZENITY_MSG_INFO: - glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); - break; + GladeXML *glade_dialog; + GtkWidget *dialog; + GtkWidget *text; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + break; + + case ZENITY_MSG_QUESTION: + glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + break; + + case ZENITY_MSG_ERROR: + glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + break; + + case ZENITY_MSG_INFO: + glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); + dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); + text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + break; - default: - g_assert_not_reached (); - break; - } - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } - - glade_xml_signal_autoconnect (glade_dialog); - - if (glade_dialog) - g_object_unref (glade_dialog); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + default: + g_assert_not_reached (); + break; + } - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else { - GdkPixbuf *pixbuf = NULL; - switch (msg_data->mode) { + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); - break; - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); - break; - case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); - break; - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); - break; - default: - break; - } - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } + + glade_xml_signal_autoconnect (glade_dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + GdkPixbuf *pixbuf = NULL; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); + break; + + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); + break; + + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); + break; + + default: + break; + } + } - if (msg_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + if (msg_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); } static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + zen_data->exit_code = 1; + break; + } } diff --git a/src/progress.c b/src/progress.c index bf730bcd..41153bc4 100644 --- a/src/progress.c +++ b/src/progress.c @@ -37,142 +37,142 @@ static void zenity_progress_dialog_response (GtkWidget *widget, int response, gp void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { - GtkWidget *dialog; - GtkWidget *text; - GtkWidget *progress_bar; - guint input; + GtkWidget *dialog; + GtkWidget *text; + GtkWidget *progress_bar; + guint input; - glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); + glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); - - dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_progress_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_progress_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else { - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); - } + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else { + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); + } - text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); - gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); + text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); - if (progress_data->percentage > -1) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), - progress_data->percentage/100.0); + if (progress_data->percentage > -1) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), + progress_data->percentage/100.0); - gtk_widget_show (dialog); - if (progress_data->pulsate != TRUE) - timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); - else - timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar); + gtk_widget_show (dialog); + if (!progress_data->pulsate) + timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); + else + timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar); - gtk_main (); + gtk_main (); } gint zenity_progress_timeout (gpointer data) { - gchar buffer[256]; - float percentage; - - while(gtk_events_pending()) { - gtk_main_iteration(); + gchar buffer[256]; + float percentage; - if (timer == 0) - return FALSE; - } + while(gtk_events_pending()) { + gtk_main_iteration(); - if (scanf ("%255s", buffer) == EOF) { - GtkWidget *button; + if (timer == 0) + return FALSE; + } - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); - gtk_widget_set_sensitive (button, TRUE); - gtk_widget_grab_focus (button); + if (scanf ("%255s", buffer) == EOF) { + GtkWidget *button; - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); - gtk_widget_set_sensitive (button, FALSE); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); - if (glade_dialog) - g_object_unref (glade_dialog); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + gtk_widget_set_sensitive (button, FALSE); + + if (glade_dialog) + g_object_unref (glade_dialog); - return FALSE; - } else { - percentage = atoi (buffer); + return FALSE; + } else { + percentage = atoi (buffer); - if (percentage > 100) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); - else - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0); + if (percentage > 100) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); + else + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0); - return TRUE; - } + return TRUE; + } } gint zenity_progress_pulsate_timeout (gpointer data) { - while(gtk_events_pending()) { - gtk_main_iteration(); - - if (timer == 0) - return FALSE; - } - - if (feof (stdin)) { - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); + while(gtk_events_pending()) { + gtk_main_iteration(); - return FALSE; - } else { - GtkWidget *button; + if (timer == 0) + return FALSE; + } - /* We stop the pulsating and switch the focus on the dialog buttons */ + if (feof (stdin)) { + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); + return FALSE; + } else { + GtkWidget *button; - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); + /* We stop the pulsating and switch the focus on the dialog buttons */ + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); - gtk_widget_set_sensitive (button, TRUE); - gtk_widget_grab_focus (button); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); - gtk_widget_set_sensitive (button, FALSE); + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + gtk_widget_set_sensitive (button, FALSE); - return TRUE; - } + return TRUE; + } } static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/text.c b/src/text.c index b51f93b1..8727986c 100644 --- a/src/text.c +++ b/src/text.c @@ -32,74 +32,75 @@ static void zenity_text_dialog_response (GtkWidget *widget, int response, gpoint void zenity_text (ZenityData *data, ZenityTextData *text_data) { - GladeXML *glade_dialog = NULL; - GtkWidget *dialog; - 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) { - data->exit_code = -1; - return; - } - - glade_xml_signal_autoconnect (glade_dialog); + GladeXML *glade_dialog = NULL; + GtkWidget *dialog; + GtkWidget *text_view; + GtkTextBuffer *text_buffer; - dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); + zen_text_data = text_data; + glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); + + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } + + glade_xml_signal_autoconnect (glade_dialog); + + dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_text_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_text_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); + text_buffer = gtk_text_buffer_new (NULL); + text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view"); + 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); - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); + if (text_data->uri) + zenity_util_fill_file_buffer (text_buffer, text_data->uri); - text_buffer = gtk_text_buffer_new (NULL); - text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view"); - 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->uri) { - zenity_util_fill_file_buffer (text_buffer, text_data->uri); - } + if (text_data->editable) + zen_text_data->buffer = text_buffer; - if (text_data->editable) { - zen_text_data->buffer = text_buffer; - } - gtk_widget_show (dialog); + gtk_widget_show (dialog); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); - gtk_main (); + gtk_main (); } static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = 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; - - default: - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = 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; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/tree.c b/src/tree.c index e5573fff..ee529ce0 100644 --- a/src/tree.c +++ b/src/tree.c @@ -39,351 +39,352 @@ static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpoint static void zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data) { - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path; - gboolean value; + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + gboolean value; - model = GTK_TREE_MODEL (data); - path = gtk_tree_path_new_from_string (path_string); + model = GTK_TREE_MODEL (data); + path = gtk_tree_path_new_from_string (path_string); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 0, &value, -1); + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, 0, &value, -1); - value = !value; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1); + value = !value; + gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1); - gtk_tree_path_free (path); + gtk_tree_path_free (path); } static void -zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles, gboolean editable) +zenity_tree_fill_entries (GtkTreeView *tree_view, + const gchar **args, + gint n_columns, + gboolean toggles, + gboolean editable) { - GtkTreeModel *model; - GtkTreeIter iter; - gint i = 0; + GtkTreeModel *model; + GtkTreeIter iter; + gint i = 0; - model = gtk_tree_view_get_model (tree_view); + model = gtk_tree_view_get_model (tree_view); - while (args[i] != NULL) { - gint j; + while (args[i] != NULL) { + gint j; - gtk_list_store_append (GTK_LIST_STORE (model), &iter); + gtk_list_store_append (GTK_LIST_STORE (model), &iter); - for (j = 0; j < n_columns; j++) { + for (j = 0; j < n_columns; j++) { - if (toggles && j == 0) { - if (strcmp (args[i+j], "TRUE") == 0) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); - else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); - } - else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); - } - - if (editable) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); - - if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { - GtkWidget *scrolled_window; - GtkRequisition rectangle; - - gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); - gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); - } - i += n_columns; - - } + if (toggles && j == 0) { + if (strcmp (args[i+j], "TRUE") == 0) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); + } + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); + } + + if (editable) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + } + i += n_columns; + + } } static void -zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer data) +zenity_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, + const gchar *new_text, + gpointer data) { - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gint column; + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; - model = GTK_TREE_MODEL (data); - path = gtk_tree_path_new_from_string (path_string); + model = GTK_TREE_MODEL (data); + path = gtk_tree_path_new_from_string (path_string); - column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); - gtk_tree_model_get_iter (model, &iter, path); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, - column, new_text, -1); + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + gtk_tree_model_get_iter (model, &iter, path); + + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1); - gtk_tree_path_free (path); + gtk_tree_path_free (path); } void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { - GtkWidget *dialog; - GtkWidget *tree_view; - GtkTreeViewColumn *column; - GtkListStore *model; - GType *column_types; - GSList *tmp; - gboolean first_column = FALSE; - gint i, column_index, n_columns; - - glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); - - if (glade_dialog == NULL) { - data->exit_code = -1; - return; - } + GtkWidget *dialog; + GtkWidget *tree_view; + GtkTreeViewColumn *column; + GtkListStore *model; + GType *column_types; + GSList *tmp; + gboolean first_column = FALSE; + gint i, column_index, n_columns; + + glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); + + if (glade_dialog == NULL) { + data->exit_code = -1; + return; + } - separator = g_strdup (tree_data->separator); + separator = g_strdup (tree_data->separator); - n_columns = g_slist_length (tree_data->columns); + n_columns = g_slist_length (tree_data->columns); - if (n_columns == 0) { - g_printerr (_("No column titles specified for --list\n")); - data->exit_code = -1; - return; - } + if (n_columns == 0) { + g_printerr (_("No column titles specified for --list\n")); + data->exit_code = -1; + return; + } - if (tree_data->data == NULL) { - g_printerr (_("No contents specified for --list\n")); - data->exit_code = -1; - return; - } + if (tree_data->data == NULL) { + g_printerr (_("No contents specified for --list\n")); + data->exit_code = -1; + return; + } - glade_xml_signal_autoconnect (glade_dialog); + glade_xml_signal_autoconnect (glade_dialog); - dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_tree_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_tree_dialog_response), data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); + if (data->window_icon) + zenity_util_set_window_icon (dialog, data->window_icon); + else + zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); - /* Create an empty list store */ - model = g_object_new (GTK_TYPE_LIST_STORE, NULL); + /* Create an empty list store */ + model = g_object_new (GTK_TYPE_LIST_STORE, NULL); - if (tree_data->editable) - column_types = g_new (GType, n_columns + 1); - else - column_types = g_new (GType, n_columns); + if (tree_data->editable) + column_types = g_new (GType, n_columns + 1); + else + column_types = g_new (GType, n_columns); - for (i = 0; i < n_columns; i++) { - /* Have the limitation that the radioboxes and checkboxes are in the first column */ - if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) - column_types[i] = G_TYPE_BOOLEAN; - else - column_types[i] = G_TYPE_STRING; - } + for (i = 0; i < n_columns; i++) { + /* Have the limitation that the radioboxes and checkboxes are in the first column */ + if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) + column_types[i] = G_TYPE_BOOLEAN; + else + column_types[i] = G_TYPE_STRING; + } - if (tree_data->editable) - column_types[n_columns] = G_TYPE_BOOLEAN; + if (tree_data->editable) + column_types[n_columns] = G_TYPE_BOOLEAN; - if (tree_data->editable) - gtk_list_store_set_column_types (model, n_columns + 1, column_types); - else - gtk_list_store_set_column_types (model, n_columns, column_types); + if (tree_data->editable) + gtk_list_store_set_column_types (model, n_columns + 1, column_types); + else + gtk_list_store_set_column_types (model, n_columns, column_types); - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_MULTIPLE); + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_MULTIPLE); - column_index = 0; + column_index = 0; - for (tmp = tree_data->columns; tmp; tmp = tmp->next) { - if (first_column == FALSE) { - if (tree_data->checkbox || tree_data->radiobox) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_toggle_new (); + for (tmp = tree_data->columns; tmp; tmp = tmp->next) { + if (!first_column) { + if (tree_data->checkbox || tree_data->radiobox) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_toggle_new (); - if (tree_data->radiobox) - g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); - - g_signal_connect (cell_renderer, "toggled", - G_CALLBACK (zenity_tree_toggled_callback), model); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "active", column_index, NULL); - } - - else { - if (tree_data->editable == TRUE) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_text_new (); - g_signal_connect (G_OBJECT (cell_renderer), "edited", - G_CALLBACK (zenity_cell_edited_callback), - gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", - (gint *) column_index); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "text", column_index, - "editable", n_columns, - NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, NULL); - } - - gtk_tree_view_column_set_sort_column_id (column, column_index); - gtk_tree_view_column_set_resizable (column, TRUE); - } - - first_column = TRUE; - } - else { - if (tree_data->editable == TRUE) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_text_new (); - g_signal_connect (G_OBJECT (cell_renderer), "edited", - G_CALLBACK (zenity_cell_edited_callback), - gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", - (gint *) column_index); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "text", column_index, - "editable", n_columns, - NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, NULL); - } - - gtk_tree_view_column_set_sort_column_id (column, column_index); - gtk_tree_view_column_set_resizable (column, TRUE); + if (tree_data->radiobox) + g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); + + g_signal_connect (cell_renderer, "toggled", + G_CALLBACK (zenity_tree_toggled_callback), model); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "active", column_index, NULL); + } + else { + if (tree_data->editable) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", column_index, + "editable", n_columns, + NULL); + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, + NULL); + } + + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + } - } + first_column = TRUE; + } + else { + if (tree_data->editable) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", column_index, + "editable", n_columns, + NULL); + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, NULL); + } + + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + } - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); - column_index++; - } + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + column_index++; + } - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); + gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); - if (tree_data->radiobox || tree_data->checkbox) - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); - else - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); + if (tree_data->radiobox || tree_data->checkbox) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); + else + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); - gtk_widget_show (dialog); - gtk_main (); + gtk_widget_show (dialog); + gtk_main (); - if (glade_dialog) - g_object_unref (glade_dialog); + if (glade_dialog) + g_object_unref (glade_dialog); } static void zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) { - GValue value = {0, }; + GValue value = {0, }; - gtk_tree_model_get_value (model, iter, 0, &value); + gtk_tree_model_get_value (model, iter, 0, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); } static gboolean zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { - GValue toggle_value = {0, }; - - gtk_tree_model_get_value (model, iter, 0, &toggle_value); - - if (g_value_get_boolean (&toggle_value) == TRUE) { - GValue value = {0, }; - gtk_tree_model_get_value (model, iter, 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); - } - g_value_unset (&toggle_value); - return FALSE; + GValue toggle_value = {0, }; + + gtk_tree_model_get_value (model, iter, 0, &toggle_value); + + if (g_value_get_boolean (&toggle_value)) { + GValue value = {0, }; + gtk_tree_model_get_value (model, iter, 1, &value); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } + g_value_unset (&toggle_value); + return FALSE; } static void zenity_tree_dialog_output (void) { - GSList *tmp; - - for (tmp = selected; tmp; tmp = tmp->next) { - if (tmp->next != NULL) { - /* FIXME: There must be a nicer way to do this. This is just arse */ - if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) - g_printerr ("%s\n", tmp->data); - else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) - g_printerr ("%s\t", tmp->data); - else - g_printerr ("%s%s", tmp->data, separator); - } - else - g_printerr ("%s\n", tmp->data); - } - - g_free (separator); - g_slist_foreach (selected, (GFunc) g_free, NULL); - selected = NULL; + GSList *tmp; + + for (tmp = selected; tmp; tmp = tmp->next) { + if (tmp->next != NULL) { + /* FIXME: There must be a nicer way to do this. This is just arse */ + if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) + g_printerr ("%s\n", tmp->data); + else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) + g_printerr ("%s\t", tmp->data); + else + g_printerr ("%s%s", tmp->data, separator); + } + else + g_printerr ("%s\n", tmp->data); + } + + g_free (separator); + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; } static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - GtkWidget *tree_view; - GtkTreeSelection *selection; - GtkTreeModel *model; - - switch (response) { - case GTK_RESPONSE_OK: - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - - if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) { - gtk_tree_model_foreach (model, - (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, - NULL); - } - else { - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, - GTK_TREE_VIEW (tree_view)); - } - zenity_tree_dialog_output (); - zen_data->exit_code = 0; - gtk_main_quit (); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; - gtk_main_quit (); - break; - - default: - zen_data->exit_code = 1; - break; - } + ZenityData *zen_data = data; + GtkWidget *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; + + switch (response) { + case GTK_RESPONSE_OK: + tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + + if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) + gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, NULL); + else { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, + GTK_TREE_VIEW (tree_view)); + } + zenity_tree_dialog_output (); + zen_data->exit_code = 0; + gtk_main_quit (); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = 1; + gtk_main_quit (); + break; + + default: + /* Esc dialog */ + zen_data->exit_code = 1; + break; + } } diff --git a/src/util.c b/src/util.c index bbb6d777..907b04c5 100644 --- a/src/util.c +++ b/src/util.c @@ -41,131 +41,131 @@ GladeXML* zenity_util_load_glade_file (const gchar *widget_root) { - GladeXML *xml = NULL; + GladeXML *xml = NULL; - if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, - G_FILE_TEST_EXISTS)) { - /* Try current dir, for debugging */ - xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE); - } + if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { + /* Try current dir, for debugging */ + xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE); + } - if (xml == NULL) - xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE); + if (xml == NULL) + xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE); - if (xml == NULL) { - g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH); - return NULL; - } + if (xml == NULL) { + g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH); + return NULL; + } - return xml; + return xml; } gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) { - GtkTextIter iter, end; - FILE* f; - gchar buf[2048]; - gint remaining = 0; + GtkTextIter iter, end; + FILE *f; + gchar buf[2048]; + gint remaining = 0; - if (filename == NULL) - return FALSE; + if (filename == NULL) + return FALSE; - f = fopen (filename, "r"); + f = fopen (filename, "r"); - if (f == NULL) { - g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno)); - return FALSE; - } + if (f == NULL) { + g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno)); + return FALSE; + } - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); + gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - while (!feof (f)) { - gint count; - const char *leftover; - int to_read = 2047 - remaining; + while (!feof (f)) { + gint count; + const char *leftover; + int to_read = 2047 - remaining; - count = fread (buf + remaining, 1, to_read, f); - buf[count + remaining] = '\0'; + count = fread (buf + remaining, 1, to_read, f); + buf[count + remaining] = '\0'; - g_utf8_validate (buf, count + remaining, &leftover); + g_utf8_validate (buf, count + remaining, &leftover); - g_assert (g_utf8_validate (buf, leftover - buf, NULL)); - gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); + g_assert (g_utf8_validate (buf, leftover - buf, NULL)); + gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); - remaining = (buf + remaining + count) - leftover; - g_memmove (buf, leftover, remaining); + remaining = (buf + remaining + count) - leftover; + g_memmove (buf, leftover, remaining); - if (remaining > 6 || count < to_read) - break; - } + if (remaining > 6 || count < to_read) + break; + } - if (remaining) { - g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename); - return FALSE; - } + if (remaining) { + g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename); + return FALSE; + } - /* We had a newline in the buffer to begin with. (The buffer always contains - * a newline, so we delete to the end of the buffer to clean up. - */ - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_delete (buffer, &iter, &end); + /* We had a newline in the buffer to begin with. (The buffer always contains + * a newline, so we delete to the end of the buffer to clean up. + */ + + gtk_text_buffer_get_end_iter (buffer, &end); + gtk_text_buffer_delete (buffer, &iter, &end); - gtk_text_buffer_set_modified (buffer, FALSE); + gtk_text_buffer_set_modified (buffer, FALSE); - return TRUE; + return TRUE; } static GList * zenity_util_list_from_char_array (const char **s) { - GList *list = NULL; - gint i; + GList *list = NULL; + gint i; - for (i = 0; s[i]; i++) { - GdkPixbuf *pixbuf; + for (i = 0; s[i]; i++) { + GdkPixbuf *pixbuf; - pixbuf = gdk_pixbuf_new_from_file (s[i], NULL); - if (pixbuf) - list = g_list_prepend (list, pixbuf); - } + pixbuf = gdk_pixbuf_new_from_file (s[i], NULL); + if (pixbuf) + list = g_list_prepend (list, pixbuf); + } - return list; + return list; } static void zenity_util_free_list (GList *list) { - g_list_foreach (list, (GFunc) g_object_unref, NULL); - g_list_free (list); + g_list_foreach (list, (GFunc) g_object_unref, NULL); + g_list_free (list); } void zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename) { - const gchar *filenames[2] = { NULL}; - GList *list; + const gchar *filenames[2] = { NULL}; + GList *list; - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WINDOW (widget)); + g_return_if_fail (widget != NULL); + g_return_if_fail (GTK_IS_WINDOW (widget)); - if (filename == NULL) - return; + if (filename == NULL) + return; - filenames[0] = filename; - list = zenity_util_list_from_char_array (filenames); - gtk_window_set_icon_list (GTK_WINDOW (widget), list); - zenity_util_free_list (list); + filenames[0] = filename; + list = zenity_util_list_from_char_array (filenames); + gtk_window_set_icon_list (GTK_WINDOW (widget), list); + zenity_util_free_list (list); } void zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id) { - GdkPixbuf *pixbuf; + GdkPixbuf *pixbuf; - pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL); - gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); - g_object_unref (pixbuf); + pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL); + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); } /* This is copied from libgnome/gnome-i18n.c since we try and avoid using @@ -178,70 +178,70 @@ static GHashTable *alias_table = NULL; static void zenity_read_aliases (char *file) { - FILE *fp; - char buf[256]; + FILE *fp; + char buf[256]; - if (!alias_table) - alias_table = g_hash_table_new (g_str_hash, g_str_equal); + if (!alias_table) + alias_table = g_hash_table_new (g_str_hash, g_str_equal); - fp = fopen (file,"r"); + fp = fopen (file,"r"); - if (!fp) - return; + if (!fp) + return; - while (fgets (buf,256,fp)) { - gchar *p; - g_strstrip (buf); + while (fgets (buf,256,fp)) { + gchar *p; + g_strstrip (buf); - if (buf[0]=='#' || buf[0]=='\0') - continue; + if (buf[0]=='#' || buf[0]=='\0') + continue; - p = (gchar *) strtok (buf, "\t "); + p = (gchar *) strtok (buf, "\t "); - if (!p) - continue; + if (!p) + continue; - p = (gchar *) strtok (NULL, "\t "); + p = (gchar *) strtok (NULL, "\t "); - if(!p) - continue; + if(!p) + continue; - if (!g_hash_table_lookup (alias_table, buf)) - g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p)); - } + if (!g_hash_table_lookup (alias_table, buf)) + g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p)); + } - fclose (fp); + fclose (fp); } /*return the un-aliased language as a newly allocated string*/ static char * zenity_unalias_lang (char *lang) { - char *p; - int i; - - if (!alias_table) { - zenity_read_aliases ("/usr/share/locale/locale.alias"); - zenity_read_aliases ("/usr/local/share/locale/locale.alias"); - zenity_read_aliases ("/usr/lib/X11/locale/locale.alias"); - zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias"); - } + char *p; + int i; + + if (!alias_table) { + zenity_read_aliases ("/usr/share/locale/locale.alias"); + zenity_read_aliases ("/usr/local/share/locale/locale.alias"); + zenity_read_aliases ("/usr/lib/X11/locale/locale.alias"); + zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias"); + } - i = 0; - while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) { - lang = p; + i = 0; + while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) { + lang = p; - if (i++ == 30) { - static gboolean said_before = FALSE; + if (i++ == 30) { + static gboolean said_before = FALSE; - if (!said_before) - g_warning (_("Too many alias levels for a locale may indicate a loop")); + if (!said_before) + g_warning (_("Too many alias levels for a locale may indicate a loop")); - said_before = TRUE; - return lang; - } - } - return lang; + said_before = TRUE; + return lang; + } + } + return lang; } /* Mask for components of locale spec. The ordering here is from @@ -249,137 +249,139 @@ zenity_unalias_lang (char *lang) */ enum { - COMPONENT_CODESET = 1 << 0, - COMPONENT_TERRITORY = 1 << 1, - COMPONENT_MODIFIER = 1 << 2 + COMPONENT_CODESET = 1 << 0, + COMPONENT_TERRITORY = 1 << 1, + COMPONENT_MODIFIER = 1 << 2 }; /* Break an X/Open style locale specification into components */ static guint zenity_explode_locale (const gchar *locale, - gchar **language, - gchar **territory, - gchar **codeset, - gchar **modifier) + gchar **language, + gchar **territory, + gchar **codeset, + gchar **modifier) { - const gchar *uscore_pos; - const gchar *at_pos; - const gchar *dot_pos; - guint mask = 0; - - uscore_pos = (const gchar *) strchr (locale, '_'); - dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.'); - at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@'); - - if (at_pos) { - mask |= COMPONENT_MODIFIER; - *modifier = g_strdup (at_pos); - } else - at_pos = locale + strlen (locale); - - if (dot_pos) { - mask |= COMPONENT_CODESET; - *codeset = g_new (gchar, 1 + at_pos - dot_pos); - strncpy (*codeset, dot_pos, at_pos - dot_pos); - (*codeset) [at_pos - dot_pos] = '\0'; - } else - dot_pos = at_pos; - - if (uscore_pos) { - mask |= COMPONENT_TERRITORY; - *territory = g_new (gchar, 1 + dot_pos - uscore_pos); - strncpy (*territory, uscore_pos, dot_pos - uscore_pos); - (*territory)[dot_pos - uscore_pos] = '\0'; - } else - uscore_pos = dot_pos; - - *language = g_new (gchar, 1 + uscore_pos - locale); - strncpy (*language, locale, uscore_pos - locale); - (*language) [uscore_pos - locale] = '\0'; - - return mask; + const gchar *uscore_pos; + const gchar *at_pos; + const gchar *dot_pos; + guint mask = 0; + + uscore_pos = (const gchar *) strchr (locale, '_'); + dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.'); + at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@'); + + if (at_pos) { + mask |= COMPONENT_MODIFIER; + *modifier = g_strdup (at_pos); + } + else + at_pos = locale + strlen (locale); + + if (dot_pos) { + mask |= COMPONENT_CODESET; + *codeset = g_new (gchar, 1 + at_pos - dot_pos); + strncpy (*codeset, dot_pos, at_pos - dot_pos); + (*codeset) [at_pos - dot_pos] = '\0'; + } + else + dot_pos = at_pos; + + if (uscore_pos) { + mask |= COMPONENT_TERRITORY; + *territory = g_new (gchar, 1 + dot_pos - uscore_pos); + strncpy (*territory, uscore_pos, dot_pos - uscore_pos); + (*territory)[dot_pos - uscore_pos] = '\0'; + } + else + uscore_pos = dot_pos; + + *language = g_new (gchar, 1 + uscore_pos - locale); + strncpy (*language, locale, uscore_pos - locale); + (*language) [uscore_pos - locale] = '\0'; + + return mask; } static GList * zenity_compute_locale_variants (const gchar *locale) { - GList *retval = NULL; - gchar *language; - gchar *territory; - gchar *codeset; - gchar *modifier; - guint mask; - guint i; + GList *retval = NULL; + gchar *language; + gchar *territory; + gchar *codeset; + gchar *modifier; + guint mask; + guint i; - g_return_val_if_fail (locale != NULL, NULL); + g_return_val_if_fail (locale != NULL, NULL); - mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier); + mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier); - /* Iterate through all possible combinations, from least attractive - * to most attractive. - */ + /* Iterate through all possible combinations, from least attractive + * to most attractive. + */ - for (i = 0; i <= mask; i++) - if ((i & ~mask) == 0) { - gchar *val = g_strconcat (language, - (i & COMPONENT_TERRITORY) ? territory : "", - (i & COMPONENT_CODESET) ? codeset : "", - (i & COMPONENT_MODIFIER) ? modifier : "", NULL); - retval = g_list_prepend (retval, val); - } - - g_free (language); + for (i = 0; i <= mask; i++) + if ((i & ~mask) == 0) { + gchar *val = g_strconcat (language, (i & COMPONENT_TERRITORY) ? territory : "", + (i & COMPONENT_CODESET) ? codeset : "", + (i & COMPONENT_MODIFIER) ? modifier : "", NULL); + retval = g_list_prepend (retval, val); + } + + g_free (language); - if (mask & COMPONENT_CODESET) - g_free (codeset); - if (mask & COMPONENT_TERRITORY) - g_free (territory); - if (mask & COMPONENT_MODIFIER) - g_free (modifier); - - return retval; + if (mask & COMPONENT_CODESET) + g_free (codeset); + if (mask & COMPONENT_TERRITORY) + g_free (territory); + if (mask & COMPONENT_MODIFIER) + g_free (modifier); + + return retval; } static const gchar * zenity_guess_category_value (const gchar *categoryname) { - const gchar *retval; + const gchar *retval; - /* The highest priority value is the `LANGUAGE' environment - * variable. This is a GNU extension. - */ + /* The highest priority value is the `LANGUAGE' environment + * variable. This is a GNU extension. + */ - retval = g_getenv ("LANGUAGE"); + retval = g_getenv ("LANGUAGE"); - if (retval != NULL && retval[0] != '\0') - return retval; + if (retval != NULL && retval[0] != '\0') + return retval; - /* `LANGUAGE' is not set. So we have to proceed with the POSIX - * methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some - * systems this can be done by the `setlocale' function itself. - */ + /* `LANGUAGE' is not set. So we have to proceed with the POSIX + * methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some + * systems this can be done by the `setlocale' function itself. + */ - /* Setting of LC_ALL overwrites all other. */ + /* Setting of LC_ALL overwrites all other. */ - retval = g_getenv ("LC_ALL"); + retval = g_getenv ("LC_ALL"); - if (retval != NULL && retval[0] != '\0') - return retval; + if (retval != NULL && retval[0] != '\0') + return retval; - /* Next comes the name of the desired category. */ - retval = g_getenv (categoryname); + /* Next comes the name of the desired category. */ + retval = g_getenv (categoryname); - if (retval != NULL && retval[0] != '\0') - return retval; + if (retval != NULL && retval[0] != '\0') + return retval; - /* Last possibility is the LANG environment variable. */ - retval = g_getenv ("LANG"); - if (retval != NULL && retval[0] != '\0') - return retval; + /* Last possibility is the LANG environment variable. */ + retval = g_getenv ("LANG"); + if (retval != NULL && retval[0] != '\0') + return retval; - return NULL; + return NULL; } @@ -388,61 +390,61 @@ static GHashTable *category_table= NULL; static const GList * zenity_i18n_get_language_list (const gchar *category_name) { - GList *list; + GList *list; - if (!category_name) - category_name= "LC_ALL"; + if (!category_name) + category_name= "LC_ALL"; - if (category_table) { - list= g_hash_table_lookup (category_table, (const gpointer) category_name); - } else { - category_table= g_hash_table_new (g_str_hash, g_str_equal); - list= NULL; - } - - if (!list) { - gint c_locale_defined= FALSE; - const gchar *category_value; - gchar *category_memory, *orig_category_memory; + if (category_table) { + list= g_hash_table_lookup (category_table, (const gpointer) category_name); + } else { + category_table= g_hash_table_new (g_str_hash, g_str_equal); + list= NULL; + } + + if (!list) { + gint c_locale_defined= FALSE; + const gchar *category_value; + gchar *category_memory, *orig_category_memory; - category_value = zenity_guess_category_value (category_name); + category_value = zenity_guess_category_value (category_name); - if (! category_value) - category_value = "C"; + if (! category_value) + category_value = "C"; - orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1); + orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1); - while (category_value[0] != '\0') { - while (category_value[0] != '\0' && category_value[0] == ':') - ++category_value; + while (category_value[0] != '\0') { + while (category_value[0] != '\0' && category_value[0] == ':') + ++category_value; - if (category_value[0] != '\0') { - char *cp= category_memory; + if (category_value[0] != '\0') { + char *cp= category_memory; - while (category_value[0] != '\0' && category_value[0] != ':') - *category_memory++= *category_value++; + while (category_value[0] != '\0' && category_value[0] != ':') + *category_memory++= *category_value++; - category_memory[0]= '\0'; - category_memory++; + category_memory[0]= '\0'; + category_memory++; - cp = zenity_unalias_lang (cp); + cp = zenity_unalias_lang (cp); - if (strcmp (cp, "C") == 0) - c_locale_defined= TRUE; + if (strcmp (cp, "C") == 0) + c_locale_defined= TRUE; - list= g_list_concat (list, zenity_compute_locale_variants (cp)); - } - } + list= g_list_concat (list, zenity_compute_locale_variants (cp)); + } + } - g_free (orig_category_memory); + g_free (orig_category_memory); - if (!c_locale_defined) - list= g_list_append (list, "C"); + if (!c_locale_defined) + list= g_list_append (list, "C"); - g_hash_table_insert (category_table, (gpointer) category_name, list); - } + g_hash_table_insert (category_table, (gpointer) category_name, list); + } - return list; + return list; } /* This is copied from libgnome/gnome-help.c since we try and avoid using @@ -452,37 +454,37 @@ zenity_i18n_get_language_list (const gchar *category_name) static char * zenity_locate_help_file (const char *path, const char *doc_name) { - int i; - char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL }; - const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES"); + int i; + char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL }; + const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES"); - for (;lang_list != NULL; lang_list = lang_list->next) { - const char *lang = lang_list->data; + for (;lang_list != NULL; lang_list = lang_list->next) { + const char *lang = lang_list->data; - /* This has to be a valid language AND a language with - * no encoding postfix. The language will come up without - * encoding next - */ + /* This has to be a valid language AND a language with + * no encoding postfix. The language will come up without + * encoding next + */ - if (lang == NULL || (gchar *) strchr (lang, '.') != NULL) - continue; + if (lang == NULL || (gchar *) strchr (lang, '.') != NULL) + continue; - for (i = 0; exts[i] != NULL; i++) { - char *name; - char *full; + for (i = 0; exts[i] != NULL; i++) { + char *name; + char *full; - name = g_strconcat (doc_name, exts[i], NULL); - full = g_build_filename (path, lang, name, NULL); + name = g_strconcat (doc_name, exts[i], NULL); + full = g_build_filename (path, lang, name, NULL); - if (g_file_test (full, G_FILE_TEST_EXISTS)) - return full; + if (g_file_test (full, G_FILE_TEST_EXISTS)) + return full; - g_free (full); + g_free (full); - } - } + } + } - return NULL; + return NULL; } /* This is copied from libgnome/gnome-url.c since we try and avoid using @@ -492,96 +494,81 @@ zenity_locate_help_file (const char *path, const char *doc_name) gboolean zenity_util_show_help (const gchar *path, const gchar *document, GError **error) { - GConfClient *client; - gint i; - gchar *pos, *template; - int argc; - char **argv; - gboolean ret; - char *url; + GConfClient *client; + gint i; + gchar *pos, *template; + int argc; + char **argv; + gboolean ret; + char *url; - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (document != NULL, FALSE); + g_return_val_if_fail (path != NULL, FALSE); + g_return_val_if_fail (document != NULL, FALSE); - url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL); - pos = (gchar *) strchr (url, ':'); + url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL); + pos = (gchar *) strchr (url, ':'); - client = gconf_client_get_default (); + client = gconf_client_get_default (); - if (pos != NULL) { - gchar *protocol, *path; - - g_return_val_if_fail (pos >= url, FALSE); + if (pos != NULL) { + gchar *protocol, *path; - protocol = g_new (gchar, pos - url + 1); - strncpy (protocol, url, pos - url); - protocol[pos - url] = '\0'; - g_ascii_strdown (protocol, -1); + g_return_val_if_fail (pos >= url, FALSE); - path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL); - template = gconf_client_get_string (client, path, NULL); + protocol = g_new (gchar, pos - url + 1); + strncpy (protocol, url, pos - url); + protocol[pos - url] = '\0'; + g_ascii_strdown (protocol, -1); + + path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL); + template = gconf_client_get_string (client, path, NULL); - if (template == NULL) { - gchar* template_temp; + if (template == NULL) { + gchar* template_temp; - template_temp = gconf_client_get_string (client, - DEFAULT_HANDLER_PATH, - NULL); + template_temp = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL); - /* Retry to get the right url handler */ - template = gconf_client_get_string (client, path, NULL); + /* Retry to get the right url handler */ + template = gconf_client_get_string (client, path, NULL); - if (template == NULL) - template = template_temp; - else - g_free (template_temp); + if (template == NULL) + template = template_temp; + else + g_free (template_temp); - } + } - g_free (path); - g_free (protocol); - - } else { - /* no ':' ? this shouldn't happen. Use default handler */ - template = gconf_client_get_string (client, - DEFAULT_HANDLER_PATH, - NULL); - } - - g_object_unref (G_OBJECT (client)); - - if (!g_shell_parse_argv (template, - &argc, - &argv, - error)) { - g_free (template); - return FALSE; - } - - g_free (template); - - for (i = 0; i < argc; i++) { - char *arg; - - if (strcmp (argv[i], "%s") != 0) - continue; - - arg = argv[i]; - argv[i] = g_strdup (url); - g_free (arg); - } + g_free (path); + g_free (protocol); + + } else { + /* no ':' ? this shouldn't happen. Use default handler */ + template = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL); + } + + g_object_unref (G_OBJECT (client)); + + if (!g_shell_parse_argv (template, &argc, &argv, error)) { + g_free (template); + return FALSE; + } + + g_free (template); + + for (i = 0; i < argc; i++) { + char *arg; + + if (strcmp (argv[i], "%s") != 0) + continue; + + arg = argv[i]; + argv[i] = g_strdup (url); + g_free (arg); + } - /* This can return some errors */ - ret = g_spawn_async (NULL /* working directory */, - argv, - NULL, - G_SPAWN_SEARCH_PATH /* flags */, - NULL /* child_setup */, - NULL /* data */, - NULL /* child_pid */, - error); - - g_strfreev (argv); - - return ret; + /* This can return some errors */ + ret = g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error); + g_strfreev (argv); + + return ret; } diff --git a/src/util.h b/src/util.h index a9a7ded4..7a817abf 100644 --- a/src/util.h +++ b/src/util.h @@ -6,24 +6,20 @@ G_BEGIN_DECLS -#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" -#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" -#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL)) - -GladeXML* zenity_util_load_glade_file (const gchar *widget_root); - -gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, - const gchar *filename); - -void zenity_util_set_window_icon (GtkWidget *widget, - const gchar *filename); - -void zenity_util_set_window_icon_from_stock (GtkWidget *widget, - const gchar *stock_id); - -gboolean zenity_util_show_help (const gchar *path, - const gchar *document, - GError **error); +#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" +#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" +#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL)) + +GladeXML* zenity_util_load_glade_file (const gchar *widget_root); +gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, + const gchar *filename); +void zenity_util_set_window_icon (GtkWidget *widget, + const gchar *filename); +void zenity_util_set_window_icon_from_stock (GtkWidget *widget, + const gchar *stock_id); +gboolean zenity_util_show_help (const gchar *path, + const gchar *document, + GError **error); G_END_DECLS #endif /* UTIL_H */ diff --git a/src/zenity.glade b/src/zenity.glade index 46eda5af..8a4999cd 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -4,7 +4,6 @@ - True Calendar selection GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -148,7 +147,6 @@ - True Warning GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -259,7 +257,6 @@ 10 - True Select a file GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -290,7 +287,6 @@ - True Question GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -400,7 +396,6 @@ - True Add a new entry GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -528,7 +523,6 @@ - True Text View GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -623,7 +617,6 @@ - True Progress GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -745,7 +738,6 @@ - True Error GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -855,7 +847,6 @@ - True Select items from the list GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -990,7 +981,6 @@ - True Information GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -1100,7 +1090,6 @@ - True About Zenity GTK_WINDOW_TOPLEVEL GTK_WIN_POS_NONE @@ -1192,7 +1181,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1214,7 +1203,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1236,7 +1225,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER diff --git a/src/zenity.h b/src/zenity.h index 28944164..16dcab77 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -24,78 +24,78 @@ G_BEGIN_DECLS #endif typedef struct { - gchar *dialog_title; - gchar *window_icon; - gint exit_code; + gchar *dialog_title; + gchar *window_icon; + gint exit_code; } ZenityData; typedef struct { - gchar *dialog_text; - gint day; - gint month; - gint year; - gchar *date_format; + gchar *dialog_text; + gint day; + gint month; + gint year; + gchar *date_format; } ZenityCalendarData; typedef enum { - ZENITY_MSG_WARNING, - ZENITY_MSG_QUESTION, - ZENITY_MSG_ERROR, - ZENITY_MSG_INFO + ZENITY_MSG_WARNING, + ZENITY_MSG_QUESTION, + ZENITY_MSG_ERROR, + ZENITY_MSG_INFO } MsgMode; typedef struct { - gchar *dialog_text; - MsgMode mode; + gchar *dialog_text; + MsgMode mode; } ZenityMsgData; typedef struct { - gchar *uri; + gchar *uri; } ZenityFileData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean visible; + gchar *dialog_text; + gchar *entry_text; + gboolean visible; } ZenityEntryData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean pulsate; - gdouble percentage; + gchar *dialog_text; + gchar *entry_text; + gboolean pulsate; + gdouble percentage; } ZenityProgressData; typedef struct { - gchar *uri; - gboolean editable; - GtkTextBuffer *buffer; + gchar *uri; + gboolean editable; + GtkTextBuffer *buffer; } ZenityTextData; typedef struct { - gchar *dialog_text; - GSList *columns; - gboolean checkbox; - gboolean radiobox; - gchar *separator; - gboolean editable; - const gchar **data; + gchar *dialog_text; + GSList *columns; + gboolean checkbox; + gboolean radiobox; + gchar *separator; + gboolean editable; + const gchar **data; } ZenityTreeData; -void zenity_calendar (ZenityData *data, - ZenityCalendarData *calendar_data); -void zenity_msg (ZenityData *data, - ZenityMsgData *msg_data); -void zenity_fileselection (ZenityData *data, - ZenityFileData *file_data); -void zenity_entry (ZenityData *data, - ZenityEntryData *entry_data); -void zenity_progress (ZenityData *data, - ZenityProgressData *progress_data); -void zenity_text (ZenityData *data, - ZenityTextData *text_data); -void zenity_tree (ZenityData *data, - ZenityTreeData *tree_data); +void zenity_calendar (ZenityData *data, + ZenityCalendarData *calendar_data); +void zenity_msg (ZenityData *data, + ZenityMsgData *msg_data); +void zenity_fileselection (ZenityData *data, + ZenityFileData *file_data); +void zenity_entry (ZenityData *data, + ZenityEntryData *entry_data); +void zenity_progress (ZenityData *data, + ZenityProgressData *progress_data); +void zenity_text (ZenityData *data, + ZenityTextData *text_data); +void zenity_tree (ZenityData *data, + ZenityTreeData *tree_data); void zenity_about (ZenityData *data); G_END_DECLS -- cgit From 965c2a91497fcf96c88c0029b18a6a1e9f5d46bd Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:42:41 +0000 Subject: Finish off the indentation cleanup. Add new '--width' and '--height' 2003-04-13 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/zenity.h: Finish off the indentation cleanup. Add new '--width' and '--height' options to the general options. Fix up the radio list view, so that we can now act like a radio button group. * TODO: Update --- src/calendar.c | 2 + src/entry.c | 4 +- src/fileselection.c | 2 + src/main.c | 589 ++++++++++++++++++++++++++++------------------------ src/msg.c | 2 + src/progress.c | 5 +- src/text.c | 1 + src/tree.c | 27 ++- src/zenity.h | 2 + 9 files changed, 352 insertions(+), 282 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index fc1c014d..1316d518 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -63,6 +63,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); if (cal_data->dialog_text) diff --git a/src/entry.c b/src/entry.c index 0ccd4c0e..a46fd613 100644 --- a/src/entry.c +++ b/src/entry.c @@ -58,7 +58,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_set_window_icon (dialog, data->window_icon); else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - + + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); if (entry_data->dialog_text) diff --git a/src/fileselection.c b/src/fileselection.c index 6655f925..ec46f0c1 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -57,6 +57,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (file_data->uri) gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); diff --git a/src/main.c b/src/main.c index 3985dfd3..7393aa9f 100644 --- a/src/main.c +++ b/src/main.c @@ -76,6 +76,8 @@ enum { OPTION_WARNING, OPTION_TITLE, OPTION_ICON, + OPTION_WIDTH, + OPTION_HEIGHT, OPTION_CALENDARTEXT, OPTION_DAY, OPTION_MONTH, @@ -86,6 +88,7 @@ enum { OPTION_ERRORTEXT, OPTION_INFOTEXT, OPTION_FILENAME, + OPTION_TEXTFILENAME, OPTION_COLUMN, OPTION_SEPERATOR, OPTION_LISTEDIT, @@ -95,7 +98,6 @@ enum { OPTION_PERCENTAGE, OPTION_PULSATE, OPTION_QUESTIONTEXT, - OPTION_TEXTFILE, OPTION_WARNINGTEXT, OPTION_ABOUT, OPTION_VERSION, @@ -239,6 +241,24 @@ struct poptOption general_options[] = { N_("Set the window icon"), N_("ICONPATH") }, + { + "width", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_WIDTH, + N_("Set the width"), + N_("WIDTH") + }, + { + "height", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_HEIGHT, + N_("Set the height"), + N_("HEIGHT") + }, POPT_TABLEEND }; @@ -531,7 +551,7 @@ struct poptOption text_options[] = { '\0', POPT_ARG_STRING, NULL, - OPTION_TEXTFILE, + OPTION_TEXTFILENAME, N_("Open file"), N_("FILENAME") }, @@ -886,6 +906,8 @@ zenity_init_parsing_options (void) { results->tree_data = g_new0 (ZenityTreeData, 1); /* Give some sensible defaults */ + results->data->width = -1; + results->data->height = -1; results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); results->calendar_data->day = 0; results->calendar_data->month = 0; @@ -979,7 +1001,7 @@ main (gint argc, gchar **argv) { if (nextopt != -1) { g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), - poptBadOption (ctx, 0)); + poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); } @@ -1070,290 +1092,303 @@ zenity_parse_options_callback (poptContext ctx, static gint parse_option_file = 0; static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) { - return; - } - else if (reason != POPT_CALLBACK_REASON_OPTION) - return; - - switch (opt->val & POPT_ARG_MASK) { - - case OPTION_CALENDAR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_CALENDAR; - break; - case OPTION_ENTRY: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ENTRY; - break; - case OPTION_ERROR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ERROR; - results->msg_data->mode = ZENITY_MSG_ERROR; - break; - case OPTION_INFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_INFO; - results->msg_data->mode = ZENITY_MSG_INFO; - break; - case OPTION_FILE: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_FILE; - break; - case OPTION_LIST: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_LIST; - break; - case OPTION_PROGRESS: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_PROGRESS; - break; - case OPTION_QUESTION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_QUESTION; - results->msg_data->mode = ZENITY_MSG_QUESTION; - break; - case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_TEXTINFO; - break; - case OPTION_WARNING: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_WARNING; - results->msg_data->mode = ZENITY_MSG_WARNING; - break; - case OPTION_TITLE: - if (results->data->dialog_title != NULL) - zenity_error ("--title", ERROR_DUPLICATE); - - results->data->dialog_title = g_strdup (arg); - break; - case OPTION_ICON: - if (results->data->window_icon != NULL) - zenity_error ("--window-icon", ERROR_DUPLICATE); - - results->data->window_icon = g_strdup (arg); - break; - case OPTION_CALENDARTEXT: - case OPTION_ENTRYTEXT: - case OPTION_ERRORTEXT: - case OPTION_QUESTIONTEXT: - case OPTION_PROGRESSTEXT: - case OPTION_WARNINGTEXT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_text > 6) - zenity_error ("--text", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (arg); - break; - case MODE_ENTRY: - results->entry_data->dialog_text = g_strdup (arg); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - results->msg_data->dialog_text = g_strdup (arg); - break; - case MODE_PROGRESS: - results->progress_data->dialog_text = g_strdup (arg); - break; - default: - zenity_error ("--text", ERROR_SUPPORT); - } - parse_option_text++; - break; - case OPTION_DAY: - if (results->mode != MODE_CALENDAR) - zenity_error ("--day", ERROR_SUPPORT); + if (reason == POPT_CALLBACK_REASON_POST) + return; + else if (reason != POPT_CALLBACK_REASON_OPTION) + return; - if (results->calendar_data->day > 0) - zenity_error ("--day", ERROR_DUPLICATE); + switch (opt->val & POPT_ARG_MASK) { - results->calendar_data->day = atoi (arg); - break; - case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) - zenity_error ("--month", ERROR_SUPPORT); + case OPTION_CALENDAR: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->calendar_data->month > 0) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->month = atoi (arg); - break; - case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) - zenity_error ("--year", ERROR_SUPPORT); - - if (results->calendar_data->year > 0) - zenity_error ("--year", ERROR_DUPLICATE); - - results->calendar_data->year = atoi (arg); - break; - case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) - zenity_error ("--date-format", ERROR_SUPPORT); - - if (parse_option_dateformat) - zenity_error ("--date-format", ERROR_DUPLICATE); - - results->calendar_data->date_format = g_strdup (arg); - parse_option_dateformat = TRUE; - break; - case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--entry-text", ERROR_SUPPORT); - - if (results->entry_data->entry_text != NULL) - zenity_error ("--entry-text", ERROR_DUPLICATE); - - results->entry_data->entry_text = g_strdup (arg); - break; - case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--hide-text", ERROR_SUPPORT); - - if (!results->entry_data->visible) - zenity_error ("--hide-text", ERROR_DUPLICATE); - - results->entry_data->visible = FALSE; - break; - case OPTION_LISTEDIT: - case OPTION_TEXTEDIT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_file > 2) - zenity_error ("--editable", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_TEXTINFO: - results->text_data->editable = TRUE; - break; - case MODE_LIST: - results->tree_data->editable = TRUE; - break; - default: - zenity_error ("--editable", ERROR_SUPPORT); - } - parse_option_editable++; - break; - case OPTION_FILENAME: - case OPTION_TEXTFILE: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ + results->mode = MODE_CALENDAR; + break; + case OPTION_ENTRY: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (parse_option_file > 2) - zenity_error ("--filename", ERROR_DUPLICATE); + results->mode = MODE_ENTRY; + break; + case OPTION_ERROR: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - switch (results->mode) { - case MODE_FILE: - results->file_data->uri = g_strdup (arg); - break; - case MODE_TEXTINFO: - results->text_data->uri = g_strdup (arg); - break; - default: - zenity_error ("--filename", ERROR_SUPPORT); - } - parse_option_file++; - break; - case OPTION_COLUMN: - if (results->mode != MODE_LIST) - zenity_error ("--column", ERROR_SUPPORT); + results->mode = MODE_ERROR; + results->msg_data->mode = ZENITY_MSG_ERROR; + break; + case OPTION_INFO: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); - break; - case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) - zenity_error ("--checkbox", ERROR_SUPPORT); + results->mode = MODE_INFO; + results->msg_data->mode = ZENITY_MSG_INFO; + break; + case OPTION_FILE: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->tree_data->checkbox) - zenity_error ("--checkbox", ERROR_DUPLICATE); + results->mode = MODE_FILE; + break; + case OPTION_LIST: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->tree_data->checkbox = TRUE; - break; - case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) - zenity_error ("--radiobox", ERROR_SUPPORT); + results->mode = MODE_LIST; + break; + case OPTION_PROGRESS: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->tree_data->radiobox) - zenity_error ("--radiobox", ERROR_DUPLICATE); - - results->tree_data->radiobox = TRUE; - break; - case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) - zenity_error ("--separator", ERROR_SUPPORT); - - if (parse_option_separator) - zenity_error ("--separator", ERROR_DUPLICATE); - - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; - break; - case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--percentage", ERROR_SUPPORT); + results->mode = MODE_PROGRESS; + break; + case OPTION_QUESTION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - if (results->progress_data->percentage > -1) - zenity_error ("--percentage", ERROR_DUPLICATE); - - results->progress_data->percentage = atoi (arg); - break; - case OPTION_PULSATE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--pulsate", ERROR_SUPPORT); - - results->progress_data->pulsate = TRUE; - break; - case OPTION_ABOUT: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_QUESTION; + results->msg_data->mode = ZENITY_MSG_QUESTION; + break; + case OPTION_TEXTINFO: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - results->mode = MODE_ABOUT; - break; - case OPTION_VERSION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + results->mode = MODE_TEXTINFO; + break; + case OPTION_WARNING: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); - g_print ("%s\n", VERSION); - exit (0); - break; - default: - break; - } + results->mode = MODE_WARNING; + results->msg_data->mode = ZENITY_MSG_WARNING; + break; + case OPTION_TITLE: + if (results->data->dialog_title != NULL) + zenity_error ("--title", ERROR_DUPLICATE); + + results->data->dialog_title = g_strdup (arg); + break; + case OPTION_ICON: + if (results->data->window_icon != NULL) + zenity_error ("--window-icon", ERROR_DUPLICATE); + + results->data->window_icon = g_strdup (arg); + break; + case OPTION_WIDTH: + if (results->data->width != -1) + zenity_error ("--width", ERROR_DUPLICATE); + + results->data->width = atoi (arg); + break; + case OPTION_HEIGHT: + if (results->data->height != -1) + zenity_error ("--height", ERROR_DUPLICATE); + + results->data->height = atoi (arg); + break; + case OPTION_CALENDARTEXT: + case OPTION_ENTRYTEXT: + case OPTION_ERRORTEXT: + case OPTION_QUESTIONTEXT: + case OPTION_PROGRESSTEXT: + case OPTION_WARNINGTEXT: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_text > 6) + zenity_error ("--text", ERROR_DUPLICATE); + + switch (results->mode) { + case MODE_CALENDAR: + results->calendar_data->dialog_text = g_strdup (arg); + break; + case MODE_ENTRY: + results->entry_data->dialog_text = g_strdup (arg); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + results->msg_data->dialog_text = g_strdup (arg); + break; + case MODE_PROGRESS: + results->progress_data->dialog_text = g_strdup (arg); + break; + default: + zenity_error ("--text", ERROR_SUPPORT); + } + parse_option_text++; + break; + case OPTION_DAY: + if (results->mode != MODE_CALENDAR) + zenity_error ("--day", ERROR_SUPPORT); + + if (results->calendar_data->day > 0) + zenity_error ("--day", ERROR_DUPLICATE); + + results->calendar_data->day = atoi (arg); + break; + case OPTION_MONTH: + if (results->mode != MODE_CALENDAR) + zenity_error ("--month", ERROR_SUPPORT); + + if (results->calendar_data->month > 0) + zenity_error ("--day", ERROR_DUPLICATE); + + results->calendar_data->month = atoi (arg); + break; + case OPTION_YEAR: + if (results->mode != MODE_CALENDAR) + zenity_error ("--year", ERROR_SUPPORT); + + if (results->calendar_data->year > 0) + zenity_error ("--year", ERROR_DUPLICATE); + + results->calendar_data->year = atoi (arg); + break; + case OPTION_DATEFORMAT: + if (results->mode != MODE_CALENDAR) + zenity_error ("--date-format", ERROR_SUPPORT); + + if (parse_option_dateformat) + zenity_error ("--date-format", ERROR_DUPLICATE); + + results->calendar_data->date_format = g_strdup (arg); + parse_option_dateformat = TRUE; + break; + case OPTION_INPUTTEXT: + if (results->mode != MODE_ENTRY) + zenity_error ("--entry-text", ERROR_SUPPORT); + + if (results->entry_data->entry_text != NULL) + zenity_error ("--entry-text", ERROR_DUPLICATE); + + results->entry_data->entry_text = g_strdup (arg); + break; + case OPTION_HIDETEXT: + if (results->mode != MODE_ENTRY) + zenity_error ("--hide-text", ERROR_SUPPORT); + + if (!results->entry_data->visible) + zenity_error ("--hide-text", ERROR_DUPLICATE); + + results->entry_data->visible = FALSE; + break; + case OPTION_LISTEDIT: + case OPTION_TEXTEDIT: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) + zenity_error ("--editable", ERROR_DUPLICATE); + + switch (results->mode) { + case MODE_TEXTINFO: + results->text_data->editable = TRUE; + break; + case MODE_LIST: + results->tree_data->editable = TRUE; + break; + default: + zenity_error ("--editable", ERROR_SUPPORT); + } + parse_option_editable++; + break; + case OPTION_FILENAME: + case OPTION_TEXTFILENAME: + + /* FIXME: This is an ugly hack because of the way the poptOptions are + * ordered above. When you try and use an --option more than once + * parse_options_callback gets called for each option. Suckage + */ + + if (parse_option_file > 2) + zenity_error ("--filename", ERROR_DUPLICATE); + + switch (results->mode) { + case MODE_FILE: + results->file_data->uri = g_strdup (arg); + break; + case MODE_TEXTINFO: + results->text_data->uri = g_strdup (arg); + break; + case MODE_LIST: + results->tree_data->uri = g_strdup (arg); + break; + default: + zenity_error ("--filename", ERROR_SUPPORT); + } + parse_option_file++; + break; + case OPTION_COLUMN: + if (results->mode != MODE_LIST) + zenity_error ("--column", ERROR_SUPPORT); + + results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); + break; + case OPTION_CHECKLIST: + if (results->mode != MODE_LIST) + zenity_error ("--checkbox", ERROR_SUPPORT); + + if (results->tree_data->checkbox) + zenity_error ("--checkbox", ERROR_DUPLICATE); + + results->tree_data->checkbox = TRUE; + break; + case OPTION_RADIOLIST: + if (results->mode != MODE_LIST) + zenity_error ("--radiobox", ERROR_SUPPORT); + if (results->tree_data->radiobox) + zenity_error ("--radiobox", ERROR_DUPLICATE); + + results->tree_data->radiobox = TRUE; + break; + case OPTION_SEPERATOR: + if (results->mode != MODE_LIST) + zenity_error ("--separator", ERROR_SUPPORT); + + if (parse_option_separator) + zenity_error ("--separator", ERROR_DUPLICATE); + + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + case OPTION_PERCENTAGE: + if (results->mode != MODE_PROGRESS) + zenity_error ("--percentage", ERROR_SUPPORT); + + if (results->progress_data->percentage > -1) + zenity_error ("--percentage", ERROR_DUPLICATE); + + results->progress_data->percentage = atoi (arg); + break; + case OPTION_PULSATE: + if (results->mode != MODE_PROGRESS) + zenity_error ("--pulsate", ERROR_SUPPORT); + + results->progress_data->pulsate = TRUE; + break; + case OPTION_ABOUT: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + + results->mode = MODE_ABOUT; + break; + case OPTION_VERSION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + zenity_free_parsing_options (); + g_print ("%s\n", VERSION); + exit (0); + break; + default: + break; + } } diff --git a/src/msg.c b/src/msg.c index feac59dc..85b533e3 100644 --- a/src/msg.c +++ b/src/msg.c @@ -106,6 +106,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } + + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); diff --git a/src/progress.c b/src/progress.c index 41153bc4..d7ae35e3 100644 --- a/src/progress.c +++ b/src/progress.c @@ -61,9 +61,10 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); - else { + else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); - } + + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); diff --git a/src/text.c b/src/text.c index 8727986c..af655e50 100644 --- a/src/text.c +++ b/src/text.c @@ -60,6 +60,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); text_buffer = gtk_text_buffer_new (NULL); diff --git a/src/tree.c b/src/tree.c index ee529ce0..08043787 100644 --- a/src/tree.c +++ b/src/tree.c @@ -36,6 +36,17 @@ static gchar *separator; static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); +static gboolean +zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +{ + GValue toggle_value = {0, }; + + gtk_tree_model_get_value (model, iter, 0, &toggle_value); + + if (g_value_get_boolean (&toggle_value)) + gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1); +} + static void zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data) { @@ -45,8 +56,16 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g gboolean value; model = GTK_TREE_MODEL (data); - path = gtk_tree_path_new_from_string (path_string); + /* Because this is a radio list, we should untoggle the previous toggle so that + * we only have one selection at any given time + */ + + if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) { + gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL); + } + + path = gtk_tree_path_new_from_string (path_string); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, 0, &value, -1); @@ -176,6 +195,8 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); /* Create an empty list store */ @@ -216,8 +237,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) cell_renderer = gtk_cell_renderer_toggle_new (); - if (tree_data->radiobox) + if (tree_data->radiobox) { g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); + g_object_set_data (G_OBJECT (model), "radio", (gint *) 1); + } g_signal_connect (cell_renderer, "toggled", G_CALLBACK (zenity_tree_toggled_callback), model); diff --git a/src/zenity.h b/src/zenity.h index 16dcab77..95f477ca 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -26,6 +26,8 @@ G_BEGIN_DECLS typedef struct { gchar *dialog_title; gchar *window_icon; + gint width; + gint height; gint exit_code; } ZenityData; -- cgit From 9da64526615991b0dc76949d6113d72779242aa5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 13 Apr 2003 15:48:15 +0000 Subject: Ooops - fix build. --- src/main.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 7393aa9f..2f97d1ce 100644 --- a/src/main.c +++ b/src/main.c @@ -1319,9 +1319,6 @@ zenity_parse_options_callback (poptContext ctx, case MODE_TEXTINFO: results->text_data->uri = g_strdup (arg); break; - case MODE_LIST: - results->tree_data->uri = g_strdup (arg); - break; default: zenity_error ("--filename", ERROR_SUPPORT); } -- cgit From 8ff2b32c9eb4b2eb8970a9fa48c4889847c347b1 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 5 May 2003 17:17:02 +0000 Subject: Make the list dialog handle stdin - a little bit buggy still. Update 2003-05-05 Glynn Foster * src/tree.c, src/util.c, src/util.h: Make the list dialog handle stdin - a little bit buggy still. * TODO: Update --- src/tree.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/util.c | 19 +++++++++ src/util.h | 1 + 3 files changed, 148 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 08043787..2481d8b9 100644 --- a/src/tree.c +++ b/src/tree.c @@ -75,6 +75,119 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g gtk_tree_path_free (path); } +static gboolean +zenity_tree_handle_stdin (GIOChannel *channel, + GIOCondition condition, + gpointer data) +{ + static GtkTreeView *tree_view; + GtkTreeModel *model; + GtkTreeIter iter; + static gint column_count = 0; + static gint row_count = 0; + static gint n_columns; + static gboolean editable; + static gboolean toggles; + + tree_view = GTK_TREE_VIEW (data); + n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); + editable = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "editable")); + toggles = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "toggles")); + + model = gtk_tree_view_get_model (tree_view); + + if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + + while (channel->is_readable != TRUE) + ; + do { + gint status; + + do { + status = g_io_channel_read_line_string (channel, string, NULL, &error); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_tree_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + if (column_count == n_columns) { + /* We're starting a new row */ + column_count = 0; + row_count++; + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } + + if (toggles && column_count == 0) { + if (strcmp (string->str, "TRUE") == 0) + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); + else + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); + } + else { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1); + } + + if (editable) { + g_print ("Shouldn't be going here"); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + } + + if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + } + + column_count ++; + + } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + g_string_free (string, TRUE); + } + + if (condition != G_IO_IN) { + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; + } + return TRUE; +} + +static void +zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, + gint n_columns, + gboolean toggles, + gboolean editable) +{ + GIOChannel *channel; + + g_object_set_data (G_OBJECT (tree_view), "n_columns", (gint *) n_columns); + g_object_set_data (G_OBJECT (tree_view), "toggles", (gint *) toggles); + g_object_set_data (G_OBJECT (tree_view), "editable", (gint *) editable); + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_tree_handle_stdin, tree_view); +} + static void zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, @@ -118,8 +231,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); } - i += n_columns; + i += n_columns; } } @@ -174,11 +287,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } + /* if (tree_data->data == NULL) { g_printerr (_("No contents specified for --list\n")); data->exit_code = -1; return; } + */ glade_xml_signal_autoconnect (glade_dialog); @@ -310,10 +425,18 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); - if (tree_data->radiobox || tree_data->checkbox) - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); - else - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); + if (tree_data->radiobox || tree_data->checkbox) { + if (tree_data->data) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); + else + zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, TRUE, tree_data->editable); + } + else { + if (tree_data->data) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); + else + zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); + } gtk_widget_show (dialog); gtk_main (); diff --git a/src/util.c b/src/util.c index 907b04c5..2b3e8dc1 100644 --- a/src/util.c +++ b/src/util.c @@ -59,6 +59,25 @@ zenity_util_load_glade_file (const gchar *widget_root) return xml; } +gchar* +zenity_util_strip_newline (gchar *string) +{ + gsize len; + + g_return_val_if_fail (string != NULL, NULL); + + len = strlen (string); + while (len--) + { + if (string[len] == '\n') + string[len] = '\0'; + else + break; + } + + return string; +} + gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) { diff --git a/src/util.h b/src/util.h index 7a817abf..abfd2aed 100644 --- a/src/util.h +++ b/src/util.h @@ -11,6 +11,7 @@ G_BEGIN_DECLS #define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL)) GladeXML* zenity_util_load_glade_file (const gchar *widget_root); +gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); void zenity_util_set_window_icon (GtkWidget *widget, -- cgit From d5549deab31020185742dbeb41594a6224270240 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 6 May 2003 20:22:16 +0000 Subject: Fix up the stdin list dialog stuff. Updated to actually include the 2003-05-06 Glynn Foster * src/tree.c: Fix up the stdin list dialog stuff. * NEWS: Updated to actually include the updated translations as well. --- src/tree.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 2481d8b9..5b32fd17 100644 --- a/src/tree.c +++ b/src/tree.c @@ -28,7 +28,7 @@ #include "zenity.h" #include "util.h" -#define MAX_ELEMENTS_BEFORE_SCROLLING 8 +#define MAX_ELEMENTS_BEFORE_SCROLLING 5 static GladeXML *glade_dialog; static GSList *selected; @@ -88,6 +88,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, static gint n_columns; static gboolean editable; static gboolean toggles; + static gboolean first_time = FALSE; tree_view = GTK_TREE_VIEW (data); n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -96,6 +97,11 @@ zenity_tree_handle_stdin (GIOChannel *channel, model = gtk_tree_view_get_model (tree_view); + if (!first_time) { + first_time = TRUE; + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } + if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { GString *string; GError *error = NULL; @@ -132,9 +138,9 @@ zenity_tree_handle_stdin (GIOChannel *channel, } if (toggles && column_count == 0) { - if (strcmp (string->str, "TRUE") == 0) + if (strcmp (zenity_util_strip_newline (string->str), "TRUE") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); - else + else gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); } else { @@ -142,7 +148,6 @@ zenity_tree_handle_stdin (GIOChannel *channel, } if (editable) { - g_print ("Shouldn't be going here"); gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); } -- cgit From a08343daf90e9425c85c1138cf6eea90addafb11 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 7 May 2003 01:08:08 +0000 Subject: Update commandline error message, needs updating of translations. Remove 2003-05-06 Glynn Foster * src/main.c: Update commandline error message, needs updating of translations. * src/tree.c: Remove some commented out code. * src/zenity.glade: Updated error and info dialogs to do wrapping. --- src/main.c | 5 +++-- src/tree.c | 10 +--------- src/zenity.glade | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 2f97d1ce..0a2d312b 100644 --- a/src/main.c +++ b/src/main.c @@ -1000,18 +1000,19 @@ main (gint argc, gchar **argv) { /*nothing*/; if (nextopt != -1) { - g_printerr (_("%s in an invalid option for this dialog. See zenity --help for more details\n"), + g_printerr (_("%s in an invalid option. See zenity --help for more details\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); } gtk_init (&argc, &argv); + /* if (argc < 2) { g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); zenity_free_parsing_options (); exit (-1); - } + } */ switch (results->mode) { case MODE_CALENDAR: diff --git a/src/tree.c b/src/tree.c index 5b32fd17..b94f6344 100644 --- a/src/tree.c +++ b/src/tree.c @@ -287,19 +287,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) n_columns = g_slist_length (tree_data->columns); if (n_columns == 0) { - g_printerr (_("No column titles specified for --list\n")); + g_printerr (_("No column titles specified for List dialog.\n")); data->exit_code = -1; return; } - /* - if (tree_data->data == NULL) { - g_printerr (_("No contents specified for --list\n")); - data->exit_code = -1; - return; - } - */ - glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); diff --git a/src/zenity.glade b/src/zenity.glade index 8a4999cd..482f1527 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -815,7 +815,7 @@ False True GTK_JUSTIFY_LEFT - False + True False 0.5 0.5 @@ -1058,7 +1058,7 @@ False True GTK_JUSTIFY_LEFT - False + True False 0.5 0.5 -- cgit From 70ea28f34c25cc21bac51286b7e2c767a2df5807 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 May 2003 18:24:41 +0000 Subject: Make the progress dialog actually work and now uses g_io_channel. Woot! 2003-05-19 Glynn Foster * src/progress.c: Make the progress dialog actually work and now uses g_io_channel. Woot! Need to be able to cancel the dialog, which currently doesn't work too well. * TODO: Update. * help/C/zenity.xml: Update help documentation. --- src/progress.c | 197 +++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 122 insertions(+), 75 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index d7ae35e3..aad133a2 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,11 +29,130 @@ static guint timer; static GladeXML *glade_dialog; +static GIOChannel *channel; + gint zenity_progress_timeout (gpointer data); gint zenity_progress_pulsate_timeout (gpointer data); static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data); +static gboolean +zenity_progress_pulsate_progress_bar (gpointer user_data) +{ + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (user_data)); + return TRUE; +} + +static gboolean +zenity_progress_handle_stdin (GIOChannel *channel, + GIOCondition condition, + gpointer data) +{ + static ZenityProgressData *progress_data; + static GtkWidget *progress_bar; + static GtkWidget *progress_label; + static gint pulsate_timeout = -1; + float percentage = 0.0; + + progress_data = (ZenityProgressData *) data; + progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + progress_label = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + + if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + + if (progress_data->pulsate) { + if (pulsate_timeout == -1) + pulsate_timeout = g_timeout_add (100, zenity_progress_pulsate_progress_bar, progress_bar); + } + + while (channel->is_readable != TRUE) + ; + do { + gint status; + + do { + status = g_io_channel_read_line_string (channel, string, NULL, &error); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_progress_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + if (!g_ascii_strncasecmp (string->str, "#", 1)) { + gchar *match; + + /* We have a comment, so let's try to change the label */ + match = g_strstr_len (string->str, strlen (string->str), "#"); + match++; + gtk_label_set_text (GTK_LABEL (progress_label), g_strchomp (g_strchug (match))); + } else { + + if (!g_ascii_isdigit (*(string->str))) + continue; + + /* Now try to convert the thing to a number */ + percentage = atoi (string->str); + if (percentage > 100) + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); + else + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); + } + + } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + g_string_free (string, TRUE); + } + + if (condition != G_IO_IN) { + /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ + GtkWidget *button; + GtkWidget *progress_bar; + + button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); + + button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + gtk_widget_set_sensitive (button, FALSE); + + progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); + + if (progress_data->pulsate) { + g_source_remove (pulsate_timeout); + pulsate_timeout = -1; + } + + if (glade_dialog) + g_object_unref (glade_dialog); + + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; + } + return TRUE; +} + +static void +zenity_progress_read_info (ZenityProgressData *progress_data) +{ + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_progress_handle_stdin, progress_data); +} + void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { @@ -76,85 +195,11 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) progress_data->percentage/100.0); gtk_widget_show (dialog); - if (!progress_data->pulsate) - timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar); - else - timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar); + zenity_progress_read_info (progress_data); gtk_main (); } -gint -zenity_progress_timeout (gpointer data) -{ - gchar buffer[256]; - float percentage; - - while(gtk_events_pending()) { - gtk_main_iteration(); - - if (timer == 0) - return FALSE; - } - - if (scanf ("%255s", buffer) == EOF) { - GtkWidget *button; - - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); - gtk_widget_set_sensitive (button, TRUE); - gtk_widget_grab_focus (button); - - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); - gtk_widget_set_sensitive (button, FALSE); - - if (glade_dialog) - g_object_unref (glade_dialog); - - return FALSE; - } else { - percentage = atoi (buffer); - - if (percentage > 100) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); - else - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0); - - return TRUE; - } -} - -gint -zenity_progress_pulsate_timeout (gpointer data) -{ - - while(gtk_events_pending()) { - gtk_main_iteration(); - - if (timer == 0) - return FALSE; - } - - if (feof (stdin)) { - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data)); - return FALSE; - } else { - GtkWidget *button; - - /* We stop the pulsating and switch the focus on the dialog buttons */ - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0); - - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); - gtk_widget_set_sensitive (button, TRUE); - gtk_widget_grab_focus (button); - - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); - gtk_widget_set_sensitive (button, FALSE); - - return TRUE; - } -} - static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -167,6 +212,8 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_CANCEL: + /* FIXME: This should kill off the parent process - not entirely sure how to achieve this */ + kill (0); zen_data->exit_code = 1; gtk_main_quit (); break; -- cgit From d8d6d65386b7392aba4a67132e531f85cb9df269 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 May 2003 18:46:03 +0000 Subject: Compatibility wrapper script from Mike Newman . 2003-05-19 Glynn Foster * src/Makefile.am, src/gdialog: Compatibility wrapper script from Mike Newman . Disabled for the present until I have a chance to review the code. --- src/Makefile.am | 2 + src/gdialog | 156 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 158 insertions(+) create mode 100644 src/gdialog (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 3e0c2f3b..b5efbf9f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,6 +20,8 @@ INCLUDES = \ -DGNOMELOCALEDIR=\""$(zenitylocaledir)"\" \ -DZENITY_DATADIR=\""$(datadir)/zenity"\" +EXTRA_DIST = gdialog + zenity_LDADD = \ $(ZENITY_LIBS) diff --git a/src/gdialog b/src/gdialog new file mode 100644 index 00000000..2eb5b0fa --- /dev/null +++ b/src/gdialog @@ -0,0 +1,156 @@ +#!/usr/bin/perl + +# gdialog -> zenity conversion wrapper +# +# by Mike Newman +# +# This is all, of course, horrible - but it should translate +# most commond gdialog types to zenity equivalents. It will drop +# the pointless and unused (even by gdialog!) size arguments +# but hopefully will pass all the others. +# +# For testing purposes, I've used a couple of the nautilus scripts +# available at http://g-scripts.sourceforge.net - what is sometimes +# unclear is what is a gdialog/zenity translation problem, and what is +# a problem with the script + +my $command = "zenity "; # the command line we build up to execute +my $element = ""; # current bit of command line +my $argn = 0; # counter for walking args +my $args = $#ARGV + 1; # total number of command line arguments + +# this just loads the current arg into $element + +sub get_arg () { + $element = $ARGV[$argn]; +} + +# walk the command line + +ARG: while ($argn < $args) { + + get_arg; + + if ($element eq "--title") { + + # --title argument is almost analogous in gdialog and + # zenity - so pass it almost entirely as is + + $argn++; + get_arg; + $command .= "--title=\"$element\" "; + $argn++; + + # keep processing args + + next ARG; + } + + if ($element eq "--msgbox" || $element eq "--infobox") { + + # This bit is common to almost all of the dialogs + # the arg following the dialog type in gdialog is usually + # equivalent to zenity's --text arg. + + $argn++; + get_arg; + $command .= "--info --text=\"$element\" "; + + # this also happens a lot - gdialog accepted size args + # for dialog compatability - which it pretty much ignored + # and we will do the same + + $argn+=2; + last ARG; + } + + if ($element eq "--yesno") { + + # this will silently ignore the gdialog option to set + # the default button in question dialogs - which is + # highly hig-norant anyway! + + $argn++; + get_arg; + $command .= "--question --text=\"$element\" "; + last ARG; + } + + if ($element eq "--inputbox") { + $argn++; + get_arg; + $command .= "--entry --text=\"$element\" "; + + # ignore size elements and maybe there is some + # default text to initialize the entry with? + + $argn+=3; + get_arg; + $command .= "--entry-text=\"$element\" "; + last ARG; + } + + if ($element eq "--textbox") { + $argn++; + get_arg; + $command .= "--text-info "; + + # the arg immediately following the dialog type in + # gdialog is the filename, so pass this to zenity + + $argn++; + get_arg; + $command .= "--filename=\"$element\" "; + last ARG; + } + + if ($element eq "--checklist" || $element eq "--radiolist") { + $list=$element; + $argn++; + get_arg; + + # Conveniently, zenity and gdialog use the same names + # for list types, so pass this to zenity intact along with + # an untitled column for the check or radio buttons + + $command .= "--list $list --column='' --column $element "; + + # Skip to the first 'name' arg of the list content + + $argn += 6; + + # Loop over the remainder of the commandline + # discarding the 'status' and 'tag' args of each item + # and using the 'name' for display in our second column + + while ($argn < $args) { + get_arg; + $command .= "$element "; + $argn += 3; + } + last ARG; + } + + if ($element eq "--gauge") { + $argn++; + get_arg; + $command .= "--progress --text=\"$element\" "; + + # discard the size args as usually, and see if + # a percentage value was supplied to initialize the + # dialog + + $argn += 3; + get_arg; + if ($element) { + $command .= "--percentage=$element "; + } + last ARG; + } + + $argn++; +} + +# execute the constructed zenity command line + +system($command); -- cgit From 0664c941978b167c44441758de7ee383fca6251b Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 20 May 2003 23:48:12 +0000 Subject: Update to gdialog wrapper script --- src/gdialog | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 2eb5b0fa..14e7bed2 100644 --- a/src/gdialog +++ b/src/gdialog @@ -112,25 +112,59 @@ ARG: while ($argn < $args) { # Conveniently, zenity and gdialog use the same names # for list types, so pass this to zenity intact along with # an untitled column for the check or radio buttons + # and the 'text' arg as a second column header $command .= "--list $list --column='' --column $element "; - # Skip to the first 'name' arg of the list content + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] [status] ... - $argn += 6; + $argn += 5; # Loop over the remainder of the commandline # discarding the 'status' and 'tag' args of each item - # and using the 'name' for display in our second column + # and using the 'item' for display in our second column + # also pass a NULL argument since zenity can't set the status + # of a row like gdialog can while ($argn < $args) { get_arg; - $command .= "$element "; + $command .= "NULL $element "; $argn += 3; } last ARG; } + if ($element eq "--menu") { + $list=$element; + $argn++; + get_arg; + + # a gdialog --menu is just a one column zenity --list + # Use the 'text' arg as a second column header + # FIXME: or should it be the dialog text? + + $command .= "--list --column $element "; + + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] ... + + $argn += 5; + + # Loop over the remainder of the commandline + # discarding the 'tag' args of each item + # and using the 'item' for display in our second column + + while ($argn < $args) { + get_arg; + $command .= "$element "; + $argn += 2; + } + last ARG; + } + if ($element eq "--gauge") { $argn++; get_arg; -- cgit From c4bdad5128b2bbf1cb93e36697027aa15e348742 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 23 May 2003 16:18:26 +0000 Subject: More work on wrapper - fix --textbox to actually load the file --- src/gdialog | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 14e7bed2..63e0e1d4 100644 --- a/src/gdialog +++ b/src/gdialog @@ -91,8 +91,6 @@ ARG: while ($argn < $args) { } if ($element eq "--textbox") { - $argn++; - get_arg; $command .= "--text-info "; # the arg immediately following the dialog type in -- cgit From 1930a4a763d2136ea41fbdb6daa4249853b950d2 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 23 May 2003 16:57:16 +0000 Subject: Hmm, forgot some other bits - support --separate-output, ensure list rows are returned. --- src/gdialog | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 63e0e1d4..649d3f3c 100644 --- a/src/gdialog +++ b/src/gdialog @@ -18,6 +18,7 @@ my $command = "zenity "; # the command line we build up to execute my $element = ""; # current bit of command line my $argn = 0; # counter for walking args my $args = $#ARGV + 1; # total number of command line arguments +my $separator = 0; # set if --separate-output is in use # this just loads the current arg into $element @@ -31,6 +32,10 @@ ARG: while ($argn < $args) { get_arg; + + # Section 1 : Args which gdialog expects BEFORE box options + # --clear, --backtitle have no obvious effect - ignored + if ($element eq "--title") { # --title argument is almost analogous in gdialog and @@ -39,12 +44,23 @@ ARG: while ($argn < $args) { $argn++; get_arg; $command .= "--title=\"$element\" "; - $argn++; # keep processing args - + $argn++; + next ARG; + } + + if ($element eq "--separate-output") { + + # set the flag to pring list output line by line + $separator = 1; + + # keep processing args + $argn++; next ARG; } + + # Section 2 : Box Options and subsequent args if ($element eq "--msgbox" || $element eq "--infobox") { @@ -113,7 +129,12 @@ ARG: while ($argn < $args) { # and the 'text' arg as a second column header $command .= "--list $list --column='' --column $element "; - + + # should output be line by line? + if ($separator) { + $command .= " --separator='\n' "; + } + # Skip to the first 'item' arg of the list content # bypassing height, width and list-height # from here args run [tag] [item] [status] ... @@ -184,5 +205,5 @@ ARG: while ($argn < $args) { } # execute the constructed zenity command line - +$command .= " 2>&1"; system($command); -- cgit From 1acd9cfed892c8a277199912d099f7c5ff7a94ca Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 24 May 2003 01:36:24 +0000 Subject: Patch from Dagmar d'Surreal to correct help docs 2003-05-24 Glynn Foster * help/C/zenity.xml: Patch from Dagmar d'Surreal to correct help docs and script examples for the change from --dialog-title to --title. * THANKS, src/about.c: Add Dagmar. * src/progress.c: For now, just send a SIGHUP to the parent process - not entirely sure if this is the best thing to do right now. --- src/about.c | 1 + src/progress.c | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 2adcf642..182a8165 100644 --- a/src/about.c +++ b/src/about.c @@ -59,6 +59,7 @@ static const gchar *author_credits[] = { "Havoc Pennington ", "Kristian Rietveld ", "Jakub Steiner ", + "Daniel d'Surreal ", "Tom Tromey ", NULL }; diff --git a/src/progress.c b/src/progress.c index aad133a2..f7444c42 100644 --- a/src/progress.c +++ b/src/progress.c @@ -212,8 +212,11 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_CANCEL: - /* FIXME: This should kill off the parent process - not entirely sure how to achieve this */ - kill (0); + /* FIXME: This should kill off the parent process nicely and return an error code + * I'm pretty sure there is a nice way to do this, but I'm clueless about this + * stuff. Should be using SIGHUP instead of 1 though. + */ + kill (getpid (), 1); zen_data->exit_code = 1; gtk_main_quit (); break; -- cgit From 25d20adbd11319e7224ada5970c1a1b1ba6557df Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 24 May 2003 09:15:50 +0000 Subject: Fix typo in gdialog wrapper. Sensitize OK button in progress when 100% reached. --- src/gdialog | 12 ++++++------ src/progress.c | 8 ++++++-- 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 649d3f3c..20322c77 100644 --- a/src/gdialog +++ b/src/gdialog @@ -33,8 +33,8 @@ ARG: while ($argn < $args) { get_arg; - # Section 1 : Args which gdialog expects BEFORE box options - # --clear, --backtitle have no obvious effect - ignored +# Section 1 : Args which gdialog expects BEFORE box options +# --clear, --backtitle have no obvious effect - ignored if ($element eq "--title") { @@ -60,7 +60,7 @@ ARG: while ($argn < $args) { next ARG; } - # Section 2 : Box Options and subsequent args +# Section 2 : Box Options and subsequent args if ($element eq "--msgbox" || $element eq "--infobox") { @@ -144,8 +144,8 @@ ARG: while ($argn < $args) { # Loop over the remainder of the commandline # discarding the 'status' and 'tag' args of each item # and using the 'item' for display in our second column - # also pass a NULL argument since zenity can't set the status - # of a row like gdialog can + # also pass a fake NULL argument since zenity can't set + # the status of a row like gdialog can while ($argn < $args) { get_arg; @@ -162,7 +162,7 @@ ARG: while ($argn < $args) { # a gdialog --menu is just a one column zenity --list # Use the 'text' arg as a second column header - # FIXME: or should it be the dialog text? + # FIXME: or should it be the dialog text, or both? $command .= "--list --column $element "; diff --git a/src/progress.c b/src/progress.c index f7444c42..aa06e7d4 100644 --- a/src/progress.c +++ b/src/progress.c @@ -105,9 +105,13 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* Now try to convert the thing to a number */ percentage = atoi (string->str); - if (percentage > 100) + if (percentage >= 100) { + GtkWidget *button; + button = glade_xml_get_widget( glade_dialog,"zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - else + gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); + gtk_widget_grab_focus(GTK_WIDGET (button)); + } else gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); } -- cgit From a7673b42d20f5cbacd61b4dd85408e54aafd135d Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 17:56:51 +0000 Subject: Fix an indentation weirdness in calendar.c Take notice of width and height in gdialog wrapper for textbox, because the original gdialog also did. --- src/calendar.c | 3 +-- src/gdialog | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 1316d518..460ab8d5 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -99,8 +99,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_OK: gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, - zen_cal_data->date_format, date); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); g_printerr ("%s\n", time_string); if (date != NULL) diff --git a/src/gdialog b/src/gdialog index 20322c77..02ac6a91 100644 --- a/src/gdialog +++ b/src/gdialog @@ -28,6 +28,8 @@ sub get_arg () { # walk the command line +print $args; + ARG: while ($argn < $args) { get_arg; @@ -115,6 +117,18 @@ ARG: while ($argn < $args) { $argn++; get_arg; $command .= "--filename=\"$element\" "; + + # width and height matter for this one, so get them + # and apply the same multipliers as used in gdialog + + $argn++; + get_arg; + $element = $element * 8; + $command .= "--width=\"$element\" "; + $argn++; + get_arg; + $element = $element * 7; + $command .= "--height=\"$element\" "; last ARG; } -- cgit From 15c5b0f48ee2114b5a9f4ad25da258fc34065320 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 18:00:56 +0000 Subject: Oops - committed with debugging instrumentation which would confuse scripts! --- src/gdialog | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 02ac6a91..488ee5a0 100644 --- a/src/gdialog +++ b/src/gdialog @@ -5,14 +5,14 @@ # by Mike Newman # # This is all, of course, horrible - but it should translate -# most commond gdialog types to zenity equivalents. It will drop +# most commond gdialog types to zenity equivalents. It will mostly drop # the pointless and unused (even by gdialog!) size arguments -# but hopefully will pass all the others. +# but hopefully will translate all the others. # # For testing purposes, I've used a couple of the nautilus scripts # available at http://g-scripts.sourceforge.net - what is sometimes # unclear is what is a gdialog/zenity translation problem, and what is -# a problem with the script +# a problem with the original script my $command = "zenity "; # the command line we build up to execute my $element = ""; # current bit of command line @@ -28,8 +28,6 @@ sub get_arg () { # walk the command line -print $args; - ARG: while ($argn < $args) { get_arg; -- cgit From 34f3758977b56e72dc07b509d1ed4e215794eee9 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 18:05:18 +0000 Subject: Not my day. Fix order of height and width args of textbox in gdialog wrapper. --- src/gdialog | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gdialog b/src/gdialog index 488ee5a0..092ab13b 100644 --- a/src/gdialog +++ b/src/gdialog @@ -119,14 +119,14 @@ ARG: while ($argn < $args) { # width and height matter for this one, so get them # and apply the same multipliers as used in gdialog - $argn++; - get_arg; - $element = $element * 8; - $command .= "--width=\"$element\" "; $argn++; get_arg; $element = $element * 7; $command .= "--height=\"$element\" "; + $argn++; + get_arg; + $element = $element * 8; + $command .= "--width=\"$element\" "; last ARG; } -- cgit From 9e131f64cb3b67c8ad1a11de2297cc3297baa7fa Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 21:57:46 +0000 Subject: Enable the gdialog compatibility wrapper script. --- src/Makefile.am | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b5efbf9f..b09aacd7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,5 +1,7 @@ bin_PROGRAMS = zenity +bin_SCRIPTS = gdialog + zenity_SOURCES = \ main.c \ zenity.h \ @@ -20,8 +22,6 @@ INCLUDES = \ -DGNOMELOCALEDIR=\""$(zenitylocaledir)"\" \ -DZENITY_DATADIR=\""$(datadir)/zenity"\" -EXTRA_DIST = gdialog - zenity_LDADD = \ $(ZENITY_LIBS) @@ -30,5 +30,10 @@ gladedir = $(datadir)/zenity glade_DATA = \ zenity.glade +DISTCLEANFILES= \ + gdialog + EXTRA_DIST = \ - $(glade_DATA) + $(glade_DATA) \ + gdialog \ + gdialog.in -- cgit From beaff4a661f5d1329e1afd4b5e3f980ee703035a Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 27 May 2003 22:00:43 +0000 Subject: Enable the gdialog wrapper script. --- src/gdialog | 221 --------------------------------------------------------- src/gdialog.in | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 221 insertions(+), 221 deletions(-) delete mode 100644 src/gdialog create mode 100755 src/gdialog.in (limited to 'src') diff --git a/src/gdialog b/src/gdialog deleted file mode 100644 index 092ab13b..00000000 --- a/src/gdialog +++ /dev/null @@ -1,221 +0,0 @@ -#!/usr/bin/perl - -# gdialog -> zenity conversion wrapper -# -# by Mike Newman -# -# This is all, of course, horrible - but it should translate -# most commond gdialog types to zenity equivalents. It will mostly drop -# the pointless and unused (even by gdialog!) size arguments -# but hopefully will translate all the others. -# -# For testing purposes, I've used a couple of the nautilus scripts -# available at http://g-scripts.sourceforge.net - what is sometimes -# unclear is what is a gdialog/zenity translation problem, and what is -# a problem with the original script - -my $command = "zenity "; # the command line we build up to execute -my $element = ""; # current bit of command line -my $argn = 0; # counter for walking args -my $args = $#ARGV + 1; # total number of command line arguments -my $separator = 0; # set if --separate-output is in use - -# this just loads the current arg into $element - -sub get_arg () { - $element = $ARGV[$argn]; -} - -# walk the command line - -ARG: while ($argn < $args) { - - get_arg; - - -# Section 1 : Args which gdialog expects BEFORE box options -# --clear, --backtitle have no obvious effect - ignored - - if ($element eq "--title") { - - # --title argument is almost analogous in gdialog and - # zenity - so pass it almost entirely as is - - $argn++; - get_arg; - $command .= "--title=\"$element\" "; - - # keep processing args - $argn++; - next ARG; - } - - if ($element eq "--separate-output") { - - # set the flag to pring list output line by line - $separator = 1; - - # keep processing args - $argn++; - next ARG; - } - -# Section 2 : Box Options and subsequent args - - if ($element eq "--msgbox" || $element eq "--infobox") { - - # This bit is common to almost all of the dialogs - # the arg following the dialog type in gdialog is usually - # equivalent to zenity's --text arg. - - $argn++; - get_arg; - $command .= "--info --text=\"$element\" "; - - # this also happens a lot - gdialog accepted size args - # for dialog compatability - which it pretty much ignored - # and we will do the same - - $argn+=2; - last ARG; - } - - if ($element eq "--yesno") { - - # this will silently ignore the gdialog option to set - # the default button in question dialogs - which is - # highly hig-norant anyway! - - $argn++; - get_arg; - $command .= "--question --text=\"$element\" "; - last ARG; - } - - if ($element eq "--inputbox") { - $argn++; - get_arg; - $command .= "--entry --text=\"$element\" "; - - # ignore size elements and maybe there is some - # default text to initialize the entry with? - - $argn+=3; - get_arg; - $command .= "--entry-text=\"$element\" "; - last ARG; - } - - if ($element eq "--textbox") { - $command .= "--text-info "; - - # the arg immediately following the dialog type in - # gdialog is the filename, so pass this to zenity - - $argn++; - get_arg; - $command .= "--filename=\"$element\" "; - - # width and height matter for this one, so get them - # and apply the same multipliers as used in gdialog - - $argn++; - get_arg; - $element = $element * 7; - $command .= "--height=\"$element\" "; - $argn++; - get_arg; - $element = $element * 8; - $command .= "--width=\"$element\" "; - last ARG; - } - - if ($element eq "--checklist" || $element eq "--radiolist") { - $list=$element; - $argn++; - get_arg; - - # Conveniently, zenity and gdialog use the same names - # for list types, so pass this to zenity intact along with - # an untitled column for the check or radio buttons - # and the 'text' arg as a second column header - - $command .= "--list $list --column='' --column $element "; - - # should output be line by line? - if ($separator) { - $command .= " --separator='\n' "; - } - - # Skip to the first 'item' arg of the list content - # bypassing height, width and list-height - # from here args run [tag] [item] [status] ... - - $argn += 5; - - # Loop over the remainder of the commandline - # discarding the 'status' and 'tag' args of each item - # and using the 'item' for display in our second column - # also pass a fake NULL argument since zenity can't set - # the status of a row like gdialog can - - while ($argn < $args) { - get_arg; - $command .= "NULL $element "; - $argn += 3; - } - last ARG; - } - - if ($element eq "--menu") { - $list=$element; - $argn++; - get_arg; - - # a gdialog --menu is just a one column zenity --list - # Use the 'text' arg as a second column header - # FIXME: or should it be the dialog text, or both? - - $command .= "--list --column $element "; - - # Skip to the first 'item' arg of the list content - # bypassing height, width and list-height - # from here args run [tag] [item] ... - - $argn += 5; - - # Loop over the remainder of the commandline - # discarding the 'tag' args of each item - # and using the 'item' for display in our second column - - while ($argn < $args) { - get_arg; - $command .= "$element "; - $argn += 2; - } - last ARG; - } - - if ($element eq "--gauge") { - $argn++; - get_arg; - $command .= "--progress --text=\"$element\" "; - - # discard the size args as usually, and see if - # a percentage value was supplied to initialize the - # dialog - - $argn += 3; - get_arg; - if ($element) { - $command .= "--percentage=$element "; - } - last ARG; - } - - $argn++; -} - -# execute the constructed zenity command line -$command .= " 2>&1"; -system($command); diff --git a/src/gdialog.in b/src/gdialog.in new file mode 100755 index 00000000..1b6f63c3 --- /dev/null +++ b/src/gdialog.in @@ -0,0 +1,221 @@ +#!@PERL@ + +# gdialog -> zenity conversion wrapper +# +# by Mike Newman +# +# This is all, of course, horrible - but it should translate +# most commond gdialog types to zenity equivalents. It will mostly drop +# the pointless and unused (even by gdialog!) size arguments +# but hopefully will translate all the others. +# +# For testing purposes, I've used a couple of the nautilus scripts +# available at http://g-scripts.sourceforge.net - what is sometimes +# unclear is what is a gdialog/zenity translation problem, and what is +# a problem with the original script + +my $command = "zenity "; # the command line we build up to execute +my $element = ""; # current bit of command line +my $argn = 0; # counter for walking args +my $args = $#ARGV + 1; # total number of command line arguments +my $separator = 0; # set if --separate-output is in use + +# this just loads the current arg into $element + +sub get_arg () { + $element = $ARGV[$argn]; +} + +# walk the command line + +ARG: while ($argn < $args) { + + get_arg; + + +# Section 1 : Args which gdialog expects BEFORE box options +# --clear, --backtitle have no obvious effect - ignored + + if ($element eq "--title") { + + # --title argument is almost analogous in gdialog and + # zenity - so pass it almost entirely as is + + $argn++; + get_arg; + $command .= "--title=\"$element\" "; + + # keep processing args + $argn++; + next ARG; + } + + if ($element eq "--separate-output") { + + # set the flag to pring list output line by line + $separator = 1; + + # keep processing args + $argn++; + next ARG; + } + +# Section 2 : Box Options and subsequent args + + if ($element eq "--msgbox" || $element eq "--infobox") { + + # This bit is common to almost all of the dialogs + # the arg following the dialog type in gdialog is usually + # equivalent to zenity's --text arg. + + $argn++; + get_arg; + $command .= "--info --text=\"$element\" "; + + # this also happens a lot - gdialog accepted size args + # for dialog compatability - which it pretty much ignored + # and we will do the same + + $argn+=2; + last ARG; + } + + if ($element eq "--yesno") { + + # this will silently ignore the gdialog option to set + # the default button in question dialogs - which is + # highly hig-norant anyway! + + $argn++; + get_arg; + $command .= "--question --text=\"$element\" "; + last ARG; + } + + if ($element eq "--inputbox") { + $argn++; + get_arg; + $command .= "--entry --text=\"$element\" "; + + # ignore size elements and maybe there is some + # default text to initialize the entry with? + + $argn+=3; + get_arg; + $command .= "--entry-text=\"$element\" "; + last ARG; + } + + if ($element eq "--textbox") { + $command .= "--text-info "; + + # the arg immediately following the dialog type in + # gdialog is the filename, so pass this to zenity + + $argn++; + get_arg; + $command .= "--filename=\"$element\" "; + + # width and height matter for this one, so get them + # and apply the same multipliers as used in gdialog + + $argn++; + get_arg; + $element = $element * 7; + $command .= "--height=\"$element\" "; + $argn++; + get_arg; + $element = $element * 8; + $command .= "--width=\"$element\" "; + last ARG; + } + + if ($element eq "--checklist" || $element eq "--radiolist") { + $list=$element; + $argn++; + get_arg; + + # Conveniently, zenity and gdialog use the same names + # for list types, so pass this to zenity intact along with + # an untitled column for the check or radio buttons + # and the 'text' arg as a second column header + + $command .= "--list $list --column='' --column $element "; + + # should output be line by line? + if ($separator) { + $command .= " --separator='\n' "; + } + + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] [status] ... + + $argn += 5; + + # Loop over the remainder of the commandline + # discarding the 'status' and 'tag' args of each item + # and using the 'item' for display in our second column + # also pass a fake NULL argument since zenity can't set + # the status of a row like gdialog can + + while ($argn < $args) { + get_arg; + $command .= "NULL $element "; + $argn += 3; + } + last ARG; + } + + if ($element eq "--menu") { + $list=$element; + $argn++; + get_arg; + + # a gdialog --menu is just a one column zenity --list + # Use the 'text' arg as a second column header + # FIXME: or should it be the dialog text, or both? + + $command .= "--list --column $element "; + + # Skip to the first 'item' arg of the list content + # bypassing height, width and list-height + # from here args run [tag] [item] ... + + $argn += 5; + + # Loop over the remainder of the commandline + # discarding the 'tag' args of each item + # and using the 'item' for display in our second column + + while ($argn < $args) { + get_arg; + $command .= "$element "; + $argn += 2; + } + last ARG; + } + + if ($element eq "--gauge") { + $argn++; + get_arg; + $command .= "--progress --text=\"$element\" "; + + # discard the size args as usually, and see if + # a percentage value was supplied to initialize the + # dialog + + $argn += 3; + get_arg; + if ($element) { + $command .= "--percentage=$element "; + } + last ARG; + } + + $argn++; +} + +# execute the constructed zenity command line +$command .= " 2>&1"; +system($command); -- cgit From f091d10d08727e360172c4dbcca1762cbf9f6f7d Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 27 May 2003 22:28:44 +0000 Subject: Make the progress dialog resize. Lamely fixes #113706. 2003-05-27 Glynn Foster * src/zenity.glade: Make the progress dialog resize. Lamely fixes #113706. --- src/zenity.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 482f1527..c1dad426 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -621,7 +621,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True -- cgit From b12b1a4faf7477427a4dcd0b7a8e3245696f1587 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 3 Jun 2003 17:28:20 +0000 Subject: add a --help option to the gdialog wrapper script --- src/gdialog.in | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index 1b6f63c3..a27c0e9a 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -32,6 +32,16 @@ ARG: while ($argn < $args) { get_arg; +# Informational stuff + + if ($element eq "--help" || $element eq "--about") { + print ( "gdialog is a compatibility wrapper around zenity, " . + "provided to hopefully\nallow older scripts to run. " . + "If you are reading this message, you should\n" . + "probably be using zenity directly\n\n" . + "type: 'zenity --help' or 'man zenity' for more information\n"); + exit (1); + } # Section 1 : Args which gdialog expects BEFORE box options # --clear, --backtitle have no obvious effect - ignored -- cgit From 626d95b752159fdcec1e7c08271f3eaca1113ab7 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 3 Jun 2003 21:52:16 +0000 Subject: Add --auto-close option to progress dialog. Closes dialog when 100% has been reached. Also update docs for new option. Fixes #114125. --- src/main.c | 17 +++++++++++++++++ src/progress.c | 10 +++++++--- src/zenity.h | 1 + 3 files changed, 25 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 0a2d312b..9f990712 100644 --- a/src/main.c +++ b/src/main.c @@ -97,6 +97,7 @@ enum { OPTION_PROGRESSTEXT, OPTION_PERCENTAGE, OPTION_PULSATE, + OPTION_AUTOCLOSE, OPTION_QUESTIONTEXT, OPTION_WARNINGTEXT, OPTION_ABOUT, @@ -520,6 +521,15 @@ struct poptOption progress_options[] = { N_("Pulsate progress bar"), NULL }, + { + "auto-close", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_AUTOCLOSE, + N_("Dismiss the dialog when 100% has been reached"), + NULL + }, POPT_TABLEEND }; @@ -917,6 +927,7 @@ zenity_init_parsing_options (void) { results->tree_data->separator = g_strdup ("/"); results->progress_data->percentage = -1; results->progress_data->pulsate = FALSE; + results->progress_data->autoclose = FALSE; results->entry_data->visible = TRUE; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; @@ -1373,6 +1384,12 @@ zenity_parse_options_callback (poptContext ctx, results->progress_data->pulsate = TRUE; break; + case OPTION_AUTOCLOSE: + if (results->mode != MODE_PROGRESS) + zenity_error ("--auto-close", ERROR_SUPPORT); + + results->progress_data->autoclose = TRUE; + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); diff --git a/src/progress.c b/src/progress.c index aa06e7d4..dc0d74b3 100644 --- a/src/progress.c +++ b/src/progress.c @@ -28,7 +28,7 @@ static guint timer; static GladeXML *glade_dialog; - +static ZenityData *zen_data; static GIOChannel *channel; gint zenity_progress_timeout (gpointer data); @@ -111,6 +111,11 @@ zenity_progress_handle_stdin (GIOChannel *channel, gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); + if (progress_data->autoclose) { + zen_data->exit_code = 0; + gtk_main_quit(); + + } } else gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); } @@ -165,6 +170,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) GtkWidget *progress_bar; guint input; + zen_data = data; glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); if (glade_dialog == NULL) { @@ -207,8 +213,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; - switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = 0; diff --git a/src/zenity.h b/src/zenity.h index 95f477ca..e96f5285 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -65,6 +65,7 @@ typedef struct { gchar *dialog_text; gchar *entry_text; gboolean pulsate; + gboolean autoclose; gdouble percentage; } ZenityProgressData; -- cgit From 52b1f1c71e85be522b30d8f3c0d65a8ce1e8a1d9 Mon Sep 17 00:00:00 2001 From: Jordi Mallach Date: Wed, 4 Jun 2003 10:46:02 +0000 Subject: Add a "no-c-format" xgettext header to unbreak po files in the new 2003-06-04 Jordi Mallach * src/main.c: Add a "no-c-format" xgettext header to unbreak po files in the new auto-close string. --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 9f990712..2792d539 100644 --- a/src/main.c +++ b/src/main.c @@ -527,6 +527,7 @@ struct poptOption progress_options[] = { POPT_ARG_NONE, NULL, OPTION_AUTOCLOSE, + /* xgettext: no-c-format */ N_("Dismiss the dialog when 100% has been reached"), NULL }, -- cgit From 65cb873430d7bfcdf0452c76bf07f2ebbb4a21af Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 4 Jun 2003 12:53:46 +0000 Subject: Fix up some build warnings as reported by Ross Burton and his amazing gcc 2003-06-04 Glynn Foster * src/about.c, src/main.c, src/msg.c, src/progress.c, src/tree.c, src/util.c: Fix up some build warnings as reported by Ross Burton and his amazing gcc 3.3 techno machine. --- src/about.c | 15 ++++----------- src/main.c | 15 +++++++-------- src/msg.c | 5 +++-- src/progress.c | 5 ++++- src/tree.c | 9 +++++---- src/util.c | 1 + 6 files changed, 24 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 182a8165..ddc3325f 100644 --- a/src/about.c +++ b/src/about.c @@ -27,8 +27,9 @@ #include "config.h" #include "zenity.h" #include "util.h" +#include #include -#include +#include #include #define GTK_RESPONSE_CREDITS 0 @@ -142,7 +143,7 @@ zenity_create_clothes (GtkWidget *canvas_board) pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL); canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), - gnome_canvas_pixbuf_get_type (), + GNOME_TYPE_CANVAS_PIXBUF, "x", monk_clothes[i].x, "y", monk_clothes[i].y, "pixbuf", pixbuf, @@ -158,7 +159,6 @@ zenity_create_monk (void) { GtkWidget *canvas_board; GnomeCanvasItem *canvas_item; - GnomeCanvasGroup *root; GdkPixbuf *pixbuf; GdkColor color = { 0, 0xffff, 0xffff, 0xffff }; @@ -177,7 +177,7 @@ zenity_create_monk (void) pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL); canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root), - gnome_canvas_pixbuf_get_type (), + GNOME_TYPE_CANVAS_PIXBUF, "x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0, "y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0, "pixbuf", pixbuf, @@ -368,13 +368,6 @@ zenity_about_update_translator_label (GtkWidget *label) g_string_free (string, TRUE); } -static void -zenity_about_dialog_credits_response (GtkWidget *widget, int response, gpointer data) -{ - gtk_widget_destroy (widget); - widget = NULL; -} - static void zenity_about_display_credits_dialog (void) { diff --git a/src/main.c b/src/main.c index 2792d539..23c4721b 100644 --- a/src/main.c +++ b/src/main.c @@ -23,6 +23,7 @@ #include "config.h" #include "zenity.h" +#include #include #include @@ -986,10 +987,7 @@ zenity_free_parsing_options (void) { gint main (gint argc, gchar **argv) { - ZenityData *general; - ZenityCalendarData *cal_data; poptContext ctx; - gchar **args; gint nextopt, retval; bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); @@ -1020,11 +1018,12 @@ main (gint argc, gchar **argv) { gtk_init (&argc, &argv); /* - if (argc < 2) { - g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - zenity_free_parsing_options (); - exit (-1); - } */ + * if (argc < 2) { + * g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); + * zenity_free_parsing_options (); + * exit (-1); + * } + */ switch (results->mode) { case MODE_CALENDAR: diff --git a/src/msg.c b/src/msg.c index 85b533e3..22f50187 100644 --- a/src/msg.c +++ b/src/msg.c @@ -60,6 +60,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; default: + glade_dialog = NULL; + dialog = NULL; + text = NULL; g_assert_not_reached (); break; } @@ -83,8 +86,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else { - GdkPixbuf *pixbuf = NULL; - switch (msg_data->mode) { case ZENITY_MSG_WARNING: zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); diff --git a/src/progress.c b/src/progress.c index dc0d74b3..0fa80882 100644 --- a/src/progress.c +++ b/src/progress.c @@ -22,6 +22,10 @@ */ #include +#include +#include +#include +#include #include #include "zenity.h" #include "util.h" @@ -168,7 +172,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) GtkWidget *dialog; GtkWidget *text; GtkWidget *progress_bar; - guint input; zen_data = data; glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); diff --git a/src/tree.c b/src/tree.c index b94f6344..f3e63779 100644 --- a/src/tree.c +++ b/src/tree.c @@ -45,6 +45,7 @@ zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter if (g_value_get_boolean (&toggle_value)) gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1); + return FALSE; } static void @@ -479,14 +480,14 @@ zenity_tree_dialog_output (void) if (tmp->next != NULL) { /* FIXME: There must be a nicer way to do this. This is just arse */ if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) - g_printerr ("%s\n", tmp->data); + g_printerr ("%s\n", (gchar *) tmp->data); else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) - g_printerr ("%s\t", tmp->data); + g_printerr ("%s\t", (gchar *) tmp->data); else - g_printerr ("%s%s", tmp->data, separator); + g_printerr ("%s%s", (gchar *) tmp->data, separator); } else - g_printerr ("%s\n", tmp->data); + g_printerr ("%s\n", (gchar *) tmp->data); } g_free (separator); diff --git a/src/util.c b/src/util.c index 2b3e8dc1..7c8805a1 100644 --- a/src/util.c +++ b/src/util.c @@ -30,6 +30,7 @@ #include #include #include +#include #include "config.h" #include "util.h" #include "zenity.h" -- cgit From 3aab6a19a521c0374ef4c83fd7877154ea8636b5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 7 Jun 2003 13:10:58 +0000 Subject: Untranslate silly strings pointed out by Kjartan Maraas. 2003-06-07 Glynn Foster * src/zenity.glade: Untranslate silly strings pointed out by Kjartan Maraas. --- src/zenity.glade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index c1dad426..c83eff02 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1181,7 +1181,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1203,7 +1203,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1225,7 +1225,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 5bade6fe6a14cce50508ee5d510a4560ebe3e421 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 7 Jun 2003 14:41:56 +0000 Subject: Support user-defined return values via env vars, like dialog did. --- src/about.c | 6 ++--- src/calendar.c | 8 +++---- src/entry.c | 8 +++---- src/fileselection.c | 9 ++++---- src/msg.c | 6 ++--- src/progress.c | 10 ++++----- src/text.c | 6 ++--- src/tree.c | 10 ++++----- src/util.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/util.h | 3 +++ src/zenity.h | 8 +++++++ 11 files changed, 107 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index ddc3325f..e00cbce7 100644 --- a/src/about.c +++ b/src/about.c @@ -257,7 +257,7 @@ zenity_about (ZenityData *data) glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -434,7 +434,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; @@ -448,7 +448,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/calendar.c b/src/calendar.c index 460ab8d5..e2d94ffd 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -44,7 +44,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -105,18 +105,18 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) if (date != NULL) g_date_free (date); - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/entry.c b/src/entry.c index a46fd613..d3b6656e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -39,7 +39,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -91,7 +91,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) @@ -101,13 +101,13 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/fileselection.c b/src/fileselection.c index ec46f0c1..69fc6583 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -35,7 +35,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -73,19 +73,20 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code + (ZENITY_OK); g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/msg.c b/src/msg.c index 22f50187..2b4083b5 100644 --- a/src/msg.c +++ b/src/msg.c @@ -71,7 +71,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) G_CALLBACK (zenity_msg_dialog_response), data); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -124,12 +124,12 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; diff --git a/src/progress.c b/src/progress.c index 0fa80882..e07039be 100644 --- a/src/progress.c +++ b/src/progress.c @@ -116,7 +116,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); if (progress_data->autoclose) { - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit(); } @@ -177,7 +177,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -218,7 +218,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; @@ -228,13 +228,13 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) * stuff. Should be using SIGHUP instead of 1 though. */ kill (getpid (), 1); - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/text.c b/src/text.c index af655e50..0afe2694 100644 --- a/src/text.c +++ b/src/text.c @@ -41,7 +41,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -95,13 +95,13 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) 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 = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/tree.c b/src/tree.c index f3e63779..903ef704 100644 --- a/src/tree.c +++ b/src/tree.c @@ -279,7 +279,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); if (glade_dialog == NULL) { - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -289,7 +289,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (n_columns == 0) { g_printerr (_("No column titles specified for List dialog.\n")); - data->exit_code = -1; + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -517,18 +517,18 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) GTK_TREE_VIEW (tree_view)); } zenity_tree_dialog_output (); - zen_data->exit_code = 0; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; default: /* Esc dialog */ - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } diff --git a/src/util.c b/src/util.c index 7c8805a1..5091f2ab 100644 --- a/src/util.c +++ b/src/util.c @@ -39,6 +39,12 @@ #define URL_HANDLER_DIR "/desktop/gnome/url-handlers/" #define DEFAULT_HANDLER_PATH "/desktop/gnome/url-handlers/unknown/command" +#define ZENITY_OK_DEFAULT 0 +#define ZENITY_CANCEL_DEFAULT 1 +#define ZENITY_ESC_DEFAULT 1 +#define ZENITY_ERROR_DEFAULT -1 +#define ZENITY_EXTRA_DEFAULT 127 + GladeXML* zenity_util_load_glade_file (const gchar *widget_root) { @@ -592,3 +598,61 @@ zenity_util_show_help (const gchar *path, const gchar *document, GError **error) return ret; } + +gint +zenity_util_return_exit_code ( ZenityExitCode value ) +{ + + const gchar *env_var = NULL; + gint retval; + + switch (value) { + + case ZENITY_OK: + env_var = g_getenv("ZENITY_OK"); + if (! env_var) + env_var = g_getenv("DIALOG_OK"); + if (! env_var) + retval = ZENITY_OK_DEFAULT; + break; + + case ZENITY_CANCEL: + env_var = g_getenv("ZENITY_CANCEL"); + if (! env_var) + env_var = g_getenv("DIALOG_CANCEL"); + if (! env_var) + retval = ZENITY_CANCEL_DEFAULT; + break; + + case ZENITY_ESC: + env_var = g_getenv("ZENITY_ESC"); + if (! env_var) + env_var = g_getenv("DIALOG_ESC"); + if (! env_var) + retval = ZENITY_ESC_DEFAULT; + break; + + case ZENITY_EXTRA: + env_var = g_getenv("ZENITY_EXTRA"); + if (! env_var) + env_var = g_getenv("DIALOG_EXTRA"); + if (! env_var) + retval = ZENITY_EXTRA_DEFAULT; + break; + + case ZENITY_ERROR: + env_var = g_getenv("ZENITY_ERROR"); + if (! env_var) + env_var = g_getenv("DIALOG_ERROR"); + if (! env_var) + retval = ZENITY_ERROR_DEFAULT; + break; + + default: + retval = 1; + } + + if (env_var) + retval = atoi (env_var); + return retval; +} diff --git a/src/util.h b/src/util.h index abfd2aed..0b518a1e 100644 --- a/src/util.h +++ b/src/util.h @@ -3,6 +3,7 @@ #include #include +#include "zenity.h" G_BEGIN_DECLS @@ -21,6 +22,8 @@ void zenity_util_set_window_icon_from_stock (GtkWidget *widge gboolean zenity_util_show_help (const gchar *path, const gchar *document, GError **error); +gint zenity_util_return_exit_code (ZenityExitCode value); + G_END_DECLS #endif /* UTIL_H */ diff --git a/src/zenity.h b/src/zenity.h index e96f5285..97ecee17 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -31,6 +31,14 @@ typedef struct { gint exit_code; } ZenityData; +typedef enum { + ZENITY_OK, + ZENITY_CANCEL, + ZENITY_ESC, + ZENITY_ERROR, + ZENITY_EXTRA +} ZenityExitCode; + typedef struct { gchar *dialog_text; gint day; -- cgit From 0e4c879656dcb3a0f4ffbcc65e30b6120f65c05e Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 9 Jun 2003 18:57:01 +0000 Subject: Allow multiple file selections. --- src/fileselection.c | 36 +++++++++++++++++++++++++++++----- src/main.c | 56 ++++++++++++++++++++++++++++++++++++++++++----------- src/zenity.h | 2 ++ 3 files changed, 78 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 69fc6583..4e87d043 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -25,6 +25,8 @@ #include "zenity.h" #include "util.h" +ZenityData *zen_data; + static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) @@ -32,6 +34,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GladeXML *glade_dialog; GtkWidget *dialog; + zen_data = data; + glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); if (glade_dialog == NULL) { @@ -47,7 +51,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) g_object_unref (glade_dialog); g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), data); + G_CALLBACK (zenity_fileselection_dialog_response), file_data); if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -62,6 +66,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri) gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->multi) + gtk_file_selection_set_select_multiple (GTK_FILE_SELECTION (dialog), TRUE); + gtk_widget_show (dialog); gtk_main (); } @@ -69,13 +76,32 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - ZenityData *zen_data = data; + ZenityFileData *file_data = data; + gchar **selections; + gchar *separator = g_strdup(file_data->separator); + int i; switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code - (ZENITY_OK); - g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget))); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); + for (i=0;selections[i] != NULL; i++) { + g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); + if (selections[i+1] != NULL) { + /* FIXME: This is a blatant copy of Gman's arse in tree.c */ + if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) + g_printerr ("\n"); + else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) + g_printerr ("\t"); + else + g_printerr ("%s",separator); + } else { + g_printerr ("\n"); + } + } + g_strfreev(selections); + g_free(separator); + gtk_main_quit (); break; diff --git a/src/main.c b/src/main.c index 23c4721b..32c98a14 100644 --- a/src/main.c +++ b/src/main.c @@ -89,6 +89,7 @@ enum { OPTION_ERRORTEXT, OPTION_INFOTEXT, OPTION_FILENAME, + OPTION_MULTIFILE, OPTION_TEXTFILENAME, OPTION_COLUMN, OPTION_SEPERATOR, @@ -424,6 +425,24 @@ struct poptOption file_selection_options[] = { N_("Set the filename"), N_("FILENAME") }, + { + "multiple", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_MULTIFILE, + N_("Allow multiple files to be selected"), + NULL + }, + { + "separator", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_SEPERATOR, + N_("Set output separator character."), + N_("SEPARATOR") + }, POPT_TABLEEND }; @@ -471,7 +490,7 @@ struct poptOption list_options[] = { NULL, OPTION_SEPERATOR, N_("Set output separator character"), - NULL + N_("SEPARATOR") }, { "editable", @@ -925,8 +944,10 @@ zenity_init_parsing_options (void) { results->calendar_data->month = 0; results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; + results->file_data->multi = FALSE; + results->file_data->separator = g_strdup ("|"); 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->pulsate = FALSE; results->progress_data->autoclose = FALSE; @@ -969,6 +990,7 @@ zenity_free_parsing_options (void) { case MODE_FILE: if (results->file_data->uri) g_free (results->file_data->uri); + g_free (results->file_data->separator); break; case MODE_TEXTINFO: if (results->text_data->uri) @@ -1336,6 +1358,12 @@ zenity_parse_options_callback (poptContext ctx, } parse_option_file++; break; + case OPTION_MULTIFILE: + if (results->mode != MODE_FILE) + zenity_error ("--multiple", ERROR_SUPPORT); + + results->file_data->multi = TRUE; + break; case OPTION_COLUMN: if (results->mode != MODE_LIST) zenity_error ("--column", ERROR_SUPPORT); @@ -1360,15 +1388,21 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (results->mode != MODE_LIST) - zenity_error ("--separator", ERROR_SUPPORT); - - if (parse_option_separator) - zenity_error ("--separator", ERROR_DUPLICATE); - - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; - break; + if (parse_option_separator) + zenity_error ("--separator", ERROR_DUPLICATE); + switch (results->mode) { + case MODE_LIST: + results->tree_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + case MODE_FILE: + results->file_data->separator = g_strdup (arg); + parse_option_separator = TRUE; + break; + default: + zenity_error ("--separator", ERROR_SUPPORT); + } + break; case OPTION_PERCENTAGE: if (results->mode != MODE_PROGRESS) zenity_error ("--percentage", ERROR_SUPPORT); diff --git a/src/zenity.h b/src/zenity.h index 97ecee17..b04ff5bb 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -61,6 +61,8 @@ typedef struct { typedef struct { gchar *uri; + gboolean multi; + gchar *separator; } ZenityFileData; typedef struct { -- cgit From 98772744e904127cda466f1b5be3969ae5fbdcc2 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 9 Jun 2003 21:35:39 +0000 Subject: Committing patch to fall back to dialog if DISPLAY not set from Kevin C. Krinke --- src/gdialog.in | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index a27c0e9a..48699d8c 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -20,6 +20,83 @@ my $argn = 0; # counter for walking args my $args = $#ARGV + 1; # total number of command line arguments my $separator = 0; # set if --separate-output is in use + +# Additon by: Kevin C. Krinke (kck) +# +# gdialog itself supports both the X-Windows interface as well as a console +# interface. Here's a fix to use regular dialog when appropriate. +# This should probably be a more advanced test of some sort, but I don't know +# of any other easy way of detecting and X-Windows environment. If someone does +# know better, please let me know. So for now this works: "no DISPLAY; no X". + +unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) { + + # reset the command string + + $command = ""; + + # examine all the available/default paths + + my $PATHS = ($ENV{'PATH'}||'/bin:/usr/bin:/usr/local/bin:/opt/bin'); + + BIN: foreach my $PATH (split(/\:/,$PATHS)) { + + if (-x $PATH."/gdialog.real") { + + # Some GNU/Linux distributions divert binaries when + # other packages are installed. If this exists, chances + # are it's the real gdialog and not the Zenity wrapper. + # gdialog has full support for the Console medium and + # as such is the preference over using the "regular" + # dialog interface. + + $command = $PATH."/gdialog.real "; + last BIN; + + } elsif (-x $PATH."/dialog") { + + # change the command and skip ahead! + + $command = $PATH."/dialog "; + last BIN; + + } + + + } + + unless ($command) { + + # we didn't find the dialog binary, exit(254) with a message + # to STDERR. + + print STDERR "missing DISPLAY and a console dialog could". + " not be found.\n"; + + # exit code 254 is used because 255, 1, 2, 3 are used by Zenity + # and cDialog. This error, is a very _bad_ error so it's semi- + # non-standard at 254. + + exit(254); + + } + + # all is well if we've made it this far + + # so join the arguments double-quoting things so that proper shell + # notation is saved. + + $command .= '"'.join('" "',@ARGV).'"'; + + # and fork the process + + exec($command); + +} + +# Got DISPLAY, has X continue as normal... +# End Addtition by: KCK + # this just loads the current arg into $element sub get_arg () { -- cgit From cfe29d9ad04761e7a97964af5e8f20fca7d22cfc Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Tue, 10 Jun 2003 21:30:22 +0000 Subject: Allow /t and /n in dialog text. Some code cleanup. --- src/fileselection.c | 12 ++---------- src/main.c | 22 +++++++++++----------- src/tree.c | 6 ------ 3 files changed, 13 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 4e87d043..d392b0d0 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -87,18 +87,10 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); for (i=0;selections[i] != NULL; i++) { g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); - if (selections[i+1] != NULL) { - /* FIXME: This is a blatant copy of Gman's arse in tree.c */ - if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) - g_printerr ("\n"); - else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) - g_printerr ("\t"); - else + if (selections[i+1] != NULL) g_printerr ("%s",separator); - } else { - g_printerr ("\n"); - } } + g_printerr("\n"); g_strfreev(selections); g_free(separator); diff --git a/src/main.c b/src/main.c index 32c98a14..5a111efa 100644 --- a/src/main.c +++ b/src/main.c @@ -1125,7 +1125,7 @@ zenity_parse_options_callback (poptContext ctx, static gint parse_option_text = 0; static gint parse_option_file = 0; static gint parse_option_editable = 0; - + if (reason == POPT_CALLBACK_REASON_POST) return; else if (reason != POPT_CALLBACK_REASON_OPTION) @@ -1235,22 +1235,22 @@ zenity_parse_options_callback (poptContext ctx, if (parse_option_text > 6) zenity_error ("--text", ERROR_DUPLICATE); - + switch (results->mode) { case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (arg); + results->calendar_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_ENTRY: - results->entry_data->dialog_text = g_strdup (arg); + results->entry_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - results->msg_data->dialog_text = g_strdup (arg); + results->msg_data->dialog_text = g_strdup (g_strcompress (arg)); break; case MODE_PROGRESS: - results->progress_data->dialog_text = g_strdup (arg); + results->progress_data->dialog_text = g_strdup (g_strcompress (arg)); break; default: zenity_error ("--text", ERROR_SUPPORT); @@ -1388,16 +1388,16 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->radiobox = TRUE; break; case OPTION_SEPERATOR: - if (parse_option_separator) + if (parse_option_separator > 2) zenity_error ("--separator", ERROR_DUPLICATE); switch (results->mode) { case MODE_LIST: - results->tree_data->separator = g_strdup (arg); - parse_option_separator = TRUE; + results->tree_data->separator = g_strdup (g_strcompress (arg)); + parse_option_separator++; break; case MODE_FILE: - results->file_data->separator = g_strdup (arg); - parse_option_separator = TRUE; + results->file_data->separator = g_strdup (g_strcompress (arg)); + parse_option_separator++; break; default: zenity_error ("--separator", ERROR_SUPPORT); diff --git a/src/tree.c b/src/tree.c index 903ef704..80562d86 100644 --- a/src/tree.c +++ b/src/tree.c @@ -478,12 +478,6 @@ zenity_tree_dialog_output (void) for (tmp = selected; tmp; tmp = tmp->next) { if (tmp->next != NULL) { - /* FIXME: There must be a nicer way to do this. This is just arse */ - if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL) - g_printerr ("%s\n", (gchar *) tmp->data); - else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL) - g_printerr ("%s\t", (gchar *) tmp->data); - else g_printerr ("%s%s", (gchar *) tmp->data, separator); } else -- cgit From 9050357a9b482a4fceb8826425c4ee613921fb2e Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 13 Jun 2003 21:53:06 +0000 Subject: Fixed my old and bouncy email address --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index e00cbce7..22a0a41c 100644 --- a/src/about.c +++ b/src/about.c @@ -56,7 +56,7 @@ static const gchar *author_credits[] = { "John Fleck ", "James Henstridge ", "Mihai T. Lazarescu ", - "Mike Newman ", + "Mike Newman ", "Havoc Pennington ", "Kristian Rietveld ", "Jakub Steiner ", -- cgit From af594b60e97a43d8c60027971ed91029df5a7e67 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 13 Jun 2003 22:01:48 +0000 Subject: *** empty log message *** --- src/progress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index e07039be..c7ab5cf1 100644 --- a/src/progress.c +++ b/src/progress.c @@ -101,7 +101,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* We have a comment, so let's try to change the label */ match = g_strstr_len (string->str, strlen (string->str), "#"); match++; - gtk_label_set_text (GTK_LABEL (progress_label), g_strchomp (g_strchug (match))); + gtk_label_set_text (GTK_LABEL (progress_label), g_strcompress(g_strchomp (g_strchug (match)))); } else { if (!g_ascii_isdigit (*(string->str))) -- cgit From 86a829f7c8ba7d02412932ecee5619ae82936d63 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sat, 21 Jun 2003 15:33:39 +0000 Subject: Added en_GB translation and fixed a typo. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 5a111efa..99954ab4 100644 --- a/src/main.c +++ b/src/main.c @@ -1032,7 +1032,7 @@ main (gint argc, gchar **argv) { /*nothing*/; if (nextopt != -1) { - g_printerr (_("%s in an invalid option. See zenity --help for more details\n"), + g_printerr (_("%s is an invalid option. See 'zenity --help' for more details\n"), poptBadOption (ctx, 0)); zenity_free_parsing_options (); exit (-1); -- cgit From 425724a8d1c5624bd6db189267466b7aeaaa3e61 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Sun, 29 Jun 2003 16:21:12 +0000 Subject: gdialog wrapper return values fixed --- src/gdialog.in | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index 48699d8c..004571ba 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -305,4 +305,10 @@ ARG: while ($argn < $args) { # execute the constructed zenity command line $command .= " 2>&1"; -system($command); + +# perl doc: The return value of system() is the exit status of the +#program as returned by the wait() call. To get the actual exit value +# divide by 256. + +exit(system($command)/256); + -- cgit From 652c90596e2c4fff6b7b748afcb01df6e21d22d9 Mon Sep 17 00:00:00 2001 From: "Kevin C. Krinke" Date: Sun, 13 Jul 2003 23:03:18 +0000 Subject: user input data output to STDOUT via g_print instead of outputting to 2003-07-11 Kevin C. Krinke * src/calendar.c, src/entry.c, src/fileselection.c, src/text.c, src/tree.c: user input data output to STDOUT via g_print instead of outputting to STDERR via g_printerr. This makes it possible to destinguish user input data from GTK+ warnings / errors. * THANKS, src/about.c: I figure this is my second patch submission so I belong in the credits... --- src/about.c | 1 + src/calendar.c | 2 +- src/fileselection.c | 6 +++--- src/text.c | 2 +- src/tree.c | 4 ++-- 5 files changed, 8 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 22a0a41c..bb675819 100644 --- a/src/about.c +++ b/src/about.c @@ -58,6 +58,7 @@ static const gchar *author_credits[] = { "Mihai T. Lazarescu ", "Mike Newman ", "Havoc Pennington ", + "Kevin C. Krinke ", "Kristian Rietveld ", "Jakub Steiner ", "Daniel d'Surreal ", diff --git a/src/calendar.c b/src/calendar.c index e2d94ffd..36b3fe4d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -100,7 +100,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_printerr ("%s\n", time_string); + g_print ("%s\n", time_string); if (date != NULL) g_date_free (date); diff --git a/src/fileselection.c b/src/fileselection.c index d392b0d0..cfc966f3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -86,11 +86,11 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); for (i=0;selections[i] != NULL; i++) { - g_printerr ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); + g_print ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); if (selections[i+1] != NULL) - g_printerr ("%s",separator); + g_print ("%s",separator); } - g_printerr("\n"); + g_print("\n"); g_strfreev(selections); g_free(separator); diff --git a/src/text.c b/src/text.c index 0afe2694..0cf992c0 100644 --- a/src/text.c +++ b/src/text.c @@ -93,7 +93,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) 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)); + g_print (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0)); } zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); diff --git a/src/tree.c b/src/tree.c index 80562d86..73e9565d 100644 --- a/src/tree.c +++ b/src/tree.c @@ -478,10 +478,10 @@ zenity_tree_dialog_output (void) for (tmp = selected; tmp; tmp = tmp->next) { if (tmp->next != NULL) { - g_printerr ("%s%s", (gchar *) tmp->data, separator); + g_print ("%s%s", (gchar *) tmp->data, separator); } else - g_printerr ("%s\n", (gchar *) tmp->data); + g_print ("%s\n", (gchar *) tmp->data); } g_free (separator); -- cgit From 32cb0ef0f56cad183438ad3bdfacfc92829639ee Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Fri, 22 Aug 2003 08:30:15 +0000 Subject: Fixed i18n of help messages. --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 99954ab4..02bc8188 100644 --- a/src/main.c +++ b/src/main.c @@ -1012,6 +1012,7 @@ main (gint argc, gchar **argv) { poptContext ctx; gint nextopt, retval; + setlocale(LC_ALL,""); bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); -- cgit From 0ebb6d692bc5f4bbd2943cc46586e8c7ab3a2e92 Mon Sep 17 00:00:00 2001 From: Mike Newman Date: Mon, 25 Aug 2003 20:11:40 +0000 Subject: s/g_printerr/g_print --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index d3b6656e..0d55f44a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -95,7 +95,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) - g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); gtk_main_quit (); break; -- cgit From ceb065ee3352365c7f86dafbc8c8440495eb3093 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Aug 2003 20:11:40 +0000 Subject: Hook up the 'activate' signal on the entry dialog. Fixes Debian bug 2003-09-11 Glynn Foster * src/entry.c: Hook up the 'activate' signal on the entry dialog. Fixes Debian bug #202332. --- src/entry.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 0d55f44a..69822823 100644 --- a/src/entry.c +++ b/src/entry.c @@ -26,6 +26,7 @@ #include "util.h" static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_entry_response (GtkWidget *widget, gpointer data); static GtkWidget *entry; @@ -68,6 +69,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); + g_signal_connect (G_OBJECT (entry), "activate", + G_CALLBACK (zenity_entry_response), data); + if (glade_dialog) g_object_unref (glade_dialog); @@ -83,6 +87,22 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } +static void +zenity_entry_response (GtkWidget *widget, gpointer data) +{ + ZenityData *zen_data = data; + const gchar *text; + + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); + + gtk_main_quit (); +} + static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -95,7 +115,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) text = gtk_entry_get_text (GTK_ENTRY (entry)); if (text != NULL) - g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry))); + g_print ("%s\n", text); gtk_main_quit (); break; -- cgit From d02a5bcd112cf475f7312d234e02c4c761dd9e1f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 27 Aug 2003 12:10:04 +0000 Subject: Put horizontal scrolling on automatic, otherwise we expand off the edge of 2003-08-27 Glynn Foster * src/tree.c: Put horizontal scrolling on automatic, otherwise we expand off the edge of the screen. --- src/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 73e9565d..aaf513c6 100644 --- a/src/tree.c +++ b/src/tree.c @@ -160,7 +160,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); } column_count ++; @@ -235,7 +235,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); } i += n_columns; -- cgit From 751d9a7bec8467c4fe4e596be51825fc27a5dfea Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 1 Sep 2003 08:27:59 +0000 Subject: Documentation updates from Nicholas Curran. Add Nicholas. 2003-09-01 Glynn Foster * help/C/zenity.xml: Documentation updates from Nicholas Curran. * THANKS, src/about.c: Add Nicholas. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index bb675819..b59e5f1c 100644 --- a/src/about.c +++ b/src/about.c @@ -53,6 +53,7 @@ static const gchar *author_credits[] = { "Jonathan Blandford ", "Ross Burton ", "Anders Carlsson ", + "Nicholas Curran ", "John Fleck ", "James Henstridge ", "Mihai T. Lazarescu ", -- cgit From 82b76239aa0d85d24778e68c5bf0fb51e9d25b0a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 1 Sep 2003 18:44:19 +0000 Subject: Add patch from Buchan Miln to fix the gdialog wrapper. 2003-09-01 Glynn Foster * src/gdialog.in: Add patch from Buchan Miln to fix the gdialog wrapper. --- src/gdialog.in | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index 004571ba..ff47010d 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -259,26 +259,45 @@ ARG: while ($argn < $args) { $argn++; get_arg; - # a gdialog --menu is just a one column zenity --list + # a gdialog --menu is just a two column zenity --list + # Leave the first column blank (not provided) # Use the 'text' arg as a second column header # FIXME: or should it be the dialog text, or both? - $command .= "--list --column $element "; + $command .= "--list --column '' --column \"$element\" "; # Skip to the first 'item' arg of the list content - # bypassing height, width and list-height + # after using height, width and bypassing list-height # from here args run [tag] [item] ... - $argn += 5; + $argn += 1; + + get_arg; + # Height and width in characters to be displayed, so adjust + # cdialog uses 6 height for non-list, zenity uses ~24 pixels + # per list entry (default font), and 103 pixels for non-list + # This appears to be almost exact + $element = $element*24 - 35; + $command .= " --height $element"; + + $argn += 1; + get_arg; + # cdialog uses 6 width for non-list, zenity uses ~7 pixels + # per character (default font), and 22 pixels for non-list + # This is not exact, but close enough + $element = $element*7 - 20; + $command .= " --width $element " ; + + $argn += 2; # Loop over the remainder of the commandline - # discarding the 'tag' args of each item + # keeping 'tag' args of each item (required to return) # and using the 'item' for display in our second column while ($argn < $args) { get_arg; $command .= "$element "; - $argn += 2; + $argn += 1; } last ARG; } -- cgit From f3ea9c41a20b59a74a5d897a8f6b92ce2e07f052 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 4 Sep 2003 10:33:00 +0000 Subject: Update. Update. Patch from Toshi to fix encoding of passed text strings. 2003-09-04 Glynn Foster * THANKS: Update. * src/about.c: Update. * src/main.c: Patch from Toshi to fix encoding of passed text strings. Fixes #121389. --- src/about.c | 2 ++ src/main.c | 16 +++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index b59e5f1c..a42a6e17 100644 --- a/src/about.c +++ b/src/about.c @@ -57,12 +57,14 @@ static const gchar *author_credits[] = { "John Fleck ", "James Henstridge ", "Mihai T. Lazarescu ", + "Buhan Milne ", "Mike Newman ", "Havoc Pennington ", "Kevin C. Krinke ", "Kristian Rietveld ", "Jakub Steiner ", "Daniel d'Surreal ", + "Hidetoshi Tajima ", "Tom Tromey ", NULL }; diff --git a/src/main.c b/src/main.c index 02bc8188..95eee262 100644 --- a/src/main.c +++ b/src/main.c @@ -939,7 +939,9 @@ zenity_init_parsing_options (void) { /* Give some sensible defaults */ results->data->width = -1; results->data->height = -1; - results->calendar_data->date_format = g_strdup (nl_langinfo (D_FMT)); + results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), + -1, + NULL, NULL, NULL); results->calendar_data->day = 0; results->calendar_data->month = 0; results->calendar_data->year = 0; @@ -1239,19 +1241,23 @@ zenity_parse_options_callback (poptContext ctx, switch (results->mode) { case MODE_CALENDAR: - results->calendar_data->dialog_text = g_strdup (g_strcompress (arg)); + results->calendar_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_ENTRY: - results->entry_data->dialog_text = g_strdup (g_strcompress (arg)); + results->entry_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_ERROR: case MODE_QUESTION: case MODE_WARNING: case MODE_INFO: - results->msg_data->dialog_text = g_strdup (g_strcompress (arg)); + results->msg_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; case MODE_PROGRESS: - results->progress_data->dialog_text = g_strdup (g_strcompress (arg)); + results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); break; default: zenity_error ("--text", ERROR_SUPPORT); -- cgit From 1fab4b4e6223acd59189b9a327d9fdee650ead27 Mon Sep 17 00:00:00 2001 From: Damien Carbery Date: Fri, 12 Sep 2003 08:40:48 +0000 Subject: Make zenity compile on solaris. Whoops :) 2003-09-12 Damien Carbery * src/main.c: Make zenity compile on solaris. Whoops :) --- src/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/main.c b/src/main.c index 95eee262..84d01fe1 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "config.h" #include "zenity.h" #include +#include #include #include -- cgit From c14af1c42cd52d7bf826e19265272d37a82c9cca Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 12 Sep 2003 08:48:06 +0000 Subject: Better patch from raf@noduck.net to fix the activate on the entry dialog. 2003-09-12 Glynn Foster * src/entry.c, src/zenity.glade: Better patch from raf@noduck.net to fix the activate on the entry dialog. --- src/entry.c | 20 -------------------- src/zenity.glade | 3 ++- 2 files changed, 2 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 69822823..c2570e0a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -26,7 +26,6 @@ #include "util.h" static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); -static void zenity_entry_response (GtkWidget *widget, gpointer data); static GtkWidget *entry; @@ -69,9 +68,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); - g_signal_connect (G_OBJECT (entry), "activate", - G_CALLBACK (zenity_entry_response), data); - if (glade_dialog) g_object_unref (glade_dialog); @@ -87,22 +83,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } -static void -zenity_entry_response (GtkWidget *widget, gpointer data) -{ - ZenityData *zen_data = data; - const gchar *text; - - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - if (text != NULL) - g_print ("%s\n", text); - - gtk_main_quit (); -} - static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { diff --git a/src/zenity.glade b/src/zenity.glade index c83eff02..dd396322 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -432,6 +432,7 @@ True True + True True gtk-ok True @@ -496,7 +497,7 @@ True * - False + True 0 -- cgit From 2d67087ca0e60c7a8036ad2262af6fec9bd2d738 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 27 Oct 2003 02:48:32 +0000 Subject: Patch from Leonardo Boshell to add the locale.h header. 2003-10-27 Glynn Foster * src/main.c: Patch from Leonardo Boshell to add the locale.h header. --- src/main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 84d01fe1..58fe37ac 100644 --- a/src/main.c +++ b/src/main.c @@ -21,12 +21,16 @@ * Authors: Glynn Foster */ -#include "config.h" +#include + #include "zenity.h" #include #include #include #include +#ifdef HAVE_LOCALE_H +#include +#endif typedef enum { MODE_CALENDAR, @@ -1015,7 +1019,10 @@ main (gint argc, gchar **argv) { poptContext ctx; gint nextopt, retval; +#ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); +#endif + bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); -- cgit From cab79bf73c3c7b09d7c82d7592ba1c53847e4239 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 28 Oct 2003 03:10:30 +0000 Subject: Make the dialogs resizable so that --height/--width works. Reported by 2003-10-28 Glynn Foster * src/zenity.glade: Make the dialogs resizable so that --height/--width works. Reported by Ingo van Lil . --- src/zenity.glade | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index dd396322..ff1b852b 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -2,13 +2,14 @@ + Calendar selection GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -151,7 +152,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -261,7 +262,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -291,7 +292,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -400,7 +401,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -743,7 +744,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -986,7 +987,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True @@ -1182,7 +1183,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1204,7 +1205,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1226,7 +1227,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 5f9fe9f087b076dbe1e19108e7feea8a9b237567 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 28 Oct 2003 23:45:31 +0000 Subject: Unmark translation messages, as reported by Christian. Fixes #125717. 2003-10-29 Glynn Foster * src/zenity.glade: Unmark translation messages, as reported by Christian. Fixes #125717. --- src/zenity.glade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index ff1b852b..c33d797e 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1183,7 +1183,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1205,7 +1205,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1227,7 +1227,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 191ebced874dfb6321832f6e8621f0939ff030a5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 12 Nov 2003 01:03:20 +0000 Subject: Make sure the gdialog wrapper handles spaces. Patch from Peter Åstrand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2003-11-12 Glynn Foster * src/gdialog.in: Make sure the gdialog wrapper handles spaces. Patch from Peter Åstrand --- src/gdialog.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index ff47010d..b2045326 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -227,7 +227,7 @@ ARG: while ($argn < $args) { # an untitled column for the check or radio buttons # and the 'text' arg as a second column header - $command .= "--list $list --column='' --column $element "; + $command .= "--list $list --column='' --column \"$element\" "; # should output be line by line? if ($separator) { @@ -248,7 +248,7 @@ ARG: while ($argn < $args) { while ($argn < $args) { get_arg; - $command .= "NULL $element "; + $command .= "NULL \"$element\" "; $argn += 3; } last ARG; -- cgit From c34e4255ffcb29d0aa39c262d68de3bc18095f57 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 12 Nov 2003 01:14:17 +0000 Subject: Fix radiolist returning the wrong argument. Patch from Peter Åstrand MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2003-11-12 Glynn Foster * src/gdialog.in: Fix radiolist returning the wrong argument. Patch from Peter Åstrand . Fixes #125672. --- src/gdialog.in | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index b2045326..72234d43 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -227,8 +227,8 @@ ARG: while ($argn < $args) { # an untitled column for the check or radio buttons # and the 'text' arg as a second column header - $command .= "--list $list --column='' --column \"$element\" "; - + $command .= "--list $list --column='' --column='' --column \"$element\" "; + # should output be line by line? if ($separator) { $command .= " --separator='\n' "; @@ -238,10 +238,10 @@ ARG: while ($argn < $args) { # bypassing height, width and list-height # from here args run [tag] [item] [status] ... - $argn += 5; + $argn += 4; # Loop over the remainder of the commandline - # discarding the 'status' and 'tag' args of each item + # discarding the 'status' args of each item # and using the 'item' for display in our second column # also pass a fake NULL argument since zenity can't set # the status of a row like gdialog can @@ -249,7 +249,10 @@ ARG: while ($argn < $args) { while ($argn < $args) { get_arg; $command .= "NULL \"$element\" "; - $argn += 3; + $argn += 1; + get_arg; + $command .= "\"$element\" "; + $argn += 2; } last ARG; } -- cgit From 0ca6b6fe82639e270241e0f7997a02724dab6ab8 Mon Sep 17 00:00:00 2001 From: Christian Mönneckes Date: Mon, 1 Dec 2003 23:27:45 +0000 Subject: Fix quote and output bugs in the gdialog wrapper #128149. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2003-12-02 Christian Mönneckes < c-w-m@gmx.de> * src/gdialog.in: Fix quote and output bugs in the gdialog wrapper #128149. --- src/gdialog.in | 73 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/gdialog.in b/src/gdialog.in index 72234d43..2fc46336 100755 --- a/src/gdialog.in +++ b/src/gdialog.in @@ -14,7 +14,7 @@ # unclear is what is a gdialog/zenity translation problem, and what is # a problem with the original script -my $command = "zenity "; # the command line we build up to execute +my @command = ("zenity"); # the command line we build up to execute my $element = ""; # current bit of command line my $argn = 0; # counter for walking args my $args = $#ARGV + 1; # total number of command line arguments @@ -33,7 +33,7 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) { # reset the command string - $command = ""; + @command = (); # examine all the available/default paths @@ -50,14 +50,14 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) { # as such is the preference over using the "regular" # dialog interface. - $command = $PATH."/gdialog.real "; + @command = ($PATH."/gdialog.real"); last BIN; } elsif (-x $PATH."/dialog") { # change the command and skip ahead! - $command = $PATH."/dialog "; + @command = ($PATH."/dialog"); last BIN; } @@ -65,7 +65,7 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) { } - unless ($command) { + unless (@command) { # we didn't find the dialog binary, exit(254) with a message # to STDERR. @@ -86,11 +86,11 @@ unless (defined $ENV{'DISPLAY'} && length($ENV{'DISPLAY'})) { # so join the arguments double-quoting things so that proper shell # notation is saved. - $command .= '"'.join('" "',@ARGV).'"'; + push @command, @ARGV; # and fork the process - exec($command); + exec(@command); } @@ -130,7 +130,7 @@ ARG: while ($argn < $args) { $argn++; get_arg; - $command .= "--title=\"$element\" "; + push @command, "--title=$element"; # keep processing args $argn++; @@ -157,7 +157,7 @@ ARG: while ($argn < $args) { $argn++; get_arg; - $command .= "--info --text=\"$element\" "; + push @command, "--info", "--text=$element"; # this also happens a lot - gdialog accepted size args # for dialog compatability - which it pretty much ignored @@ -175,33 +175,33 @@ ARG: while ($argn < $args) { $argn++; get_arg; - $command .= "--question --text=\"$element\" "; + push @command, "--question", "--text=$element"; last ARG; } if ($element eq "--inputbox") { $argn++; get_arg; - $command .= "--entry --text=\"$element\" "; + push @command, "--entry", "--text=$element"; # ignore size elements and maybe there is some # default text to initialize the entry with? $argn+=3; get_arg; - $command .= "--entry-text=\"$element\" "; + push @command, "--entry-text=$element"; last ARG; } if ($element eq "--textbox") { - $command .= "--text-info "; + push @command, "--text-info"; # the arg immediately following the dialog type in # gdialog is the filename, so pass this to zenity $argn++; get_arg; - $command .= "--filename=\"$element\" "; + push @command, "--filename=$element"; # width and height matter for this one, so get them # and apply the same multipliers as used in gdialog @@ -209,11 +209,11 @@ ARG: while ($argn < $args) { $argn++; get_arg; $element = $element * 7; - $command .= "--height=\"$element\" "; + push @command, "--height=$element"; $argn++; get_arg; $element = $element * 8; - $command .= "--width=\"$element\" "; + push @command, "--width=$element"; last ARG; } @@ -227,11 +227,11 @@ ARG: while ($argn < $args) { # an untitled column for the check or radio buttons # and the 'text' arg as a second column header - $command .= "--list $list --column='' --column='' --column \"$element\" "; + push @command, "--list", $list, "--column=''", "--column=''", "--column", $element; # should output be line by line? if ($separator) { - $command .= " --separator='\n' "; + push @command, "--separator=\n"; } # Skip to the first 'item' arg of the list content @@ -248,10 +248,10 @@ ARG: while ($argn < $args) { while ($argn < $args) { get_arg; - $command .= "NULL \"$element\" "; + push @command, "NULL", $element; $argn += 1; get_arg; - $command .= "\"$element\" "; + push @command, $element; $argn += 2; } last ARG; @@ -267,7 +267,7 @@ ARG: while ($argn < $args) { # Use the 'text' arg as a second column header # FIXME: or should it be the dialog text, or both? - $command .= "--list --column '' --column \"$element\" "; + push @command, "--list", "--column", "", "--column", $element; # Skip to the first 'item' arg of the list content # after using height, width and bypassing list-height @@ -281,7 +281,7 @@ ARG: while ($argn < $args) { # per list entry (default font), and 103 pixels for non-list # This appears to be almost exact $element = $element*24 - 35; - $command .= " --height $element"; + push @command, "--height", $element; $argn += 1; get_arg; @@ -289,7 +289,7 @@ ARG: while ($argn < $args) { # per character (default font), and 22 pixels for non-list # This is not exact, but close enough $element = $element*7 - 20; - $command .= " --width $element " ; + push @command, "--width", $element; $argn += 2; @@ -299,7 +299,7 @@ ARG: while ($argn < $args) { while ($argn < $args) { get_arg; - $command .= "$element "; + push @command, $element; $argn += 1; } last ARG; @@ -308,7 +308,7 @@ ARG: while ($argn < $args) { if ($element eq "--gauge") { $argn++; get_arg; - $command .= "--progress --text=\"$element\" "; + push @command, "--progress", "--text=$element"; # discard the size args as usually, and see if # a percentage value was supplied to initialize the @@ -317,7 +317,7 @@ ARG: while ($argn < $args) { $argn += 3; get_arg; if ($element) { - $command .= "--percentage=$element "; + push @command, "--percentage=$element"; } last ARG; } @@ -325,12 +325,29 @@ ARG: while ($argn < $args) { $argn++; } +# save STDOUT and STDERR +open(ORG_STDOUT, ">&STDOUT"); +open(ORG_STDERR, ">&STDERR"); + +# redirect STDERR to /dev/null (GTK messages ie: +# (zenity:637): Gtk-WARNING **: Unable to locate theme engine in module_path: "mist",) +open(STDERR, ">/dev/null"); + +# redirect STDOUT to STDERR (gdialog direct output to STDERR by default) +open(STDOUT, ">&ORG_STDERR"); + # execute the constructed zenity command line -$command .= " 2>&1"; # perl doc: The return value of system() is the exit status of the #program as returned by the wait() call. To get the actual exit value # divide by 256. -exit(system($command)/256); +my $return = system(@command)/256; + +# restore STDOUT and STDERR +open(STDOUT, ">&ORG_STDOUT"); +open(STDERR, ">&ORG_STDERR"); +close(ORG_STDOUT); +close(ORG_STDERR); +exit $return; -- cgit From 104a45c0f772ec07866c717861d8cbf1128b1e58 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 31 Dec 2003 01:52:25 +0000 Subject: Release 2.5.1, a ridiculous bump so that we sync with the GNOME desktop 2003-12-30 Glynn Foster * configure.in: Release 2.5.1, a ridiculous bump so that we sync with the GNOME desktop releases. 2003-12-30 Jan Arne Petersen * src/fileselection.c: (zenity_fileselection), (zenity_fileselection_dialog_response): Replace GtkFileSelection with GtkFileChooser. --- src/fileselection.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index cfc966f3..955226d1 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -31,24 +31,17 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int respons void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GladeXML *glade_dialog; GtkWidget *dialog; + gchar *dir; + gchar *basename; zen_data = data; - glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog"); - - if (glade_dialog == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - glade_xml_signal_autoconnect (glade_dialog); - - dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog"); - - if (glade_dialog) - g_object_unref (glade_dialog); + dialog = gtk_file_chooser_dialog_new (NULL, NULL, + GTK_FILE_CHOOSER_ACTION_OPEN, + GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, + GTK_STOCK_OK, GTK_RESPONSE_OK, + NULL); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); @@ -63,11 +56,19 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (file_data->uri) - gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri); + if (file_data->uri) { + dir = g_path_get_dirname (file_data->uri); + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { + basename = g_path_get_basename (file_data->uri); + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + g_free (basename); + } + g_free (dir); + } if (file_data->multi) - gtk_file_selection_set_select_multiple (GTK_FILE_SELECTION (dialog), TRUE); + gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); gtk_widget_show (dialog); gtk_main (); @@ -77,21 +78,22 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityFileData *file_data = data; - gchar **selections; + GSList *selections, *iter; gchar *separator = g_strdup(file_data->separator); int i; switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - selections = gtk_file_selection_get_selections (GTK_FILE_SELECTION (widget)); - for (i=0;selections[i] != NULL; i++) { - g_print ("%s", g_filename_to_utf8 ((gchar*)selections[i], -1, NULL, NULL, NULL)); - if (selections[i+1] != NULL) + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections;iter != NULL; iter = iter->next) { + g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) g_print ("%s",separator); } g_print("\n"); - g_strfreev(selections); + g_slist_free(selections); g_free(separator); gtk_main_quit (); -- cgit From 2a297420c2ebd72089f74a59f3bc93b0313510ec Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 26 Jan 2004 03:50:50 +0000 Subject: Handle stdin. Fixes #132517. 2004-01-26 Glynn Foster * src/text.c: Handle stdin. Fixes #132517. --- src/text.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) (limited to 'src') diff --git a/src/text.c b/src/text.c index 0cf992c0..c4a49f8b 100644 --- a/src/text.c +++ b/src/text.c @@ -29,6 +29,79 @@ static ZenityTextData *zen_text_data; static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data); +static gboolean +zenity_text_handle_stdin (GIOChannel *channel, + GIOCondition condition, + gpointer data) +{ + static GtkTextBuffer *buffer; + gchar buf[1024]; + + static GtkTextIter iter, end; + static gboolean first_time = FALSE; + gchar *str; + gsize len; + + buffer = GTK_TEXT_BUFFER (data); + + if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + GError *error = NULL; + + while (channel->is_readable != TRUE) + ; + do { + gint status; + + do { + status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_text_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + if (len > 0) { + GtkTextIter end; + gchar *utftext; + gsize localelen; + gsize utflen; + + gtk_text_buffer_get_end_iter (buffer, &end); + utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); + gtk_text_buffer_insert (buffer, &end, utftext, utflen); + g_free (utftext); + } + + } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + } + + if (condition != G_IO_IN) { + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; + } + return TRUE; +} + +static void +zenity_text_fill_entries_from_stdin (GtkTextBuffer *text_buffer) +{ + GIOChannel *channel; + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_buffer); +} + void zenity_text (ZenityData *data, ZenityTextData *text_data) { @@ -70,6 +143,8 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->uri) zenity_util_fill_file_buffer (text_buffer, text_data->uri); + else + zenity_text_fill_entries_from_stdin (GTK_TEXT_BUFFER (text_buffer)); if (text_data->editable) zen_text_data->buffer = text_buffer; -- cgit From f9013fb09f1e5fc0c3979d3d09b29f7f0c9fb301 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 29 Feb 2004 07:34:28 +0000 Subject: Remove all the stupid duplicated code to do the help stuff, and instead do 2004-02-29 Glynn Foster * src/about.c, src/util.c, src/util.h: Remove all the stupid duplicated code to do the help stuff, and instead do a simple call for 'yelp ghelp:zenity'. -418, +23. Eeek. Fixes #135607. --- src/about.c | 2 +- src/util.c | 407 ++---------------------------------------------------------- src/util.h | 4 +- 3 files changed, 9 insertions(+), 404 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index a42a6e17..d955b92a 100644 --- a/src/about.c +++ b/src/about.c @@ -443,7 +443,7 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_HELP: - zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL); + zenity_util_show_help (NULL); break; case GTK_RESPONSE_CREDITS: diff --git a/src/util.c b/src/util.c index 5091f2ab..0b616efa 100644 --- a/src/util.c +++ b/src/util.c @@ -194,409 +194,16 @@ zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id g_object_unref (pixbuf); } -/* This is copied from libgnome/gnome-i18n.c since we try and avoid using - * the evils of gnome_program_init (), which messes up the commandline - */ - -static GHashTable *alias_table = NULL; - -/*read an alias file for the locales*/ -static void -zenity_read_aliases (char *file) -{ - FILE *fp; - char buf[256]; - - if (!alias_table) - alias_table = g_hash_table_new (g_str_hash, g_str_equal); - - fp = fopen (file,"r"); - - if (!fp) - return; - - while (fgets (buf,256,fp)) { - gchar *p; - g_strstrip (buf); - - if (buf[0]=='#' || buf[0]=='\0') - continue; - - p = (gchar *) strtok (buf, "\t "); - - if (!p) - continue; - - p = (gchar *) strtok (NULL, "\t "); - - if(!p) - continue; - - if (!g_hash_table_lookup (alias_table, buf)) - g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p)); - } - - fclose (fp); -} - -/*return the un-aliased language as a newly allocated string*/ -static char * -zenity_unalias_lang (char *lang) -{ - char *p; - int i; - - if (!alias_table) { - zenity_read_aliases ("/usr/share/locale/locale.alias"); - zenity_read_aliases ("/usr/local/share/locale/locale.alias"); - zenity_read_aliases ("/usr/lib/X11/locale/locale.alias"); - zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias"); - } - - i = 0; - while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) { - lang = p; - - if (i++ == 30) { - static gboolean said_before = FALSE; - - if (!said_before) - g_warning (_("Too many alias levels for a locale may indicate a loop")); - - said_before = TRUE; - return lang; - } - } - return lang; -} - -/* Mask for components of locale spec. The ordering here is from - * least significant to most significant - */ -enum -{ - COMPONENT_CODESET = 1 << 0, - COMPONENT_TERRITORY = 1 << 1, - COMPONENT_MODIFIER = 1 << 2 -}; - -/* Break an X/Open style locale specification into components - */ -static guint -zenity_explode_locale (const gchar *locale, - gchar **language, - gchar **territory, - gchar **codeset, - gchar **modifier) -{ - const gchar *uscore_pos; - const gchar *at_pos; - const gchar *dot_pos; - guint mask = 0; - - uscore_pos = (const gchar *) strchr (locale, '_'); - dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.'); - at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@'); - - if (at_pos) { - mask |= COMPONENT_MODIFIER; - *modifier = g_strdup (at_pos); - } - else - at_pos = locale + strlen (locale); - - if (dot_pos) { - mask |= COMPONENT_CODESET; - *codeset = g_new (gchar, 1 + at_pos - dot_pos); - strncpy (*codeset, dot_pos, at_pos - dot_pos); - (*codeset) [at_pos - dot_pos] = '\0'; - } - else - dot_pos = at_pos; - - if (uscore_pos) { - mask |= COMPONENT_TERRITORY; - *territory = g_new (gchar, 1 + dot_pos - uscore_pos); - strncpy (*territory, uscore_pos, dot_pos - uscore_pos); - (*territory)[dot_pos - uscore_pos] = '\0'; - } - else - uscore_pos = dot_pos; - - *language = g_new (gchar, 1 + uscore_pos - locale); - strncpy (*language, locale, uscore_pos - locale); - (*language) [uscore_pos - locale] = '\0'; - - return mask; -} - -static GList * -zenity_compute_locale_variants (const gchar *locale) -{ - GList *retval = NULL; - gchar *language; - gchar *territory; - gchar *codeset; - gchar *modifier; - guint mask; - guint i; - - - g_return_val_if_fail (locale != NULL, NULL); - - mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier); - - /* Iterate through all possible combinations, from least attractive - * to most attractive. - */ - - for (i = 0; i <= mask; i++) - if ((i & ~mask) == 0) { - gchar *val = g_strconcat (language, (i & COMPONENT_TERRITORY) ? territory : "", - (i & COMPONENT_CODESET) ? codeset : "", - (i & COMPONENT_MODIFIER) ? modifier : "", NULL); - retval = g_list_prepend (retval, val); - } - - g_free (language); - - if (mask & COMPONENT_CODESET) - g_free (codeset); - if (mask & COMPONENT_TERRITORY) - g_free (territory); - if (mask & COMPONENT_MODIFIER) - g_free (modifier); - - return retval; -} - -static const gchar * -zenity_guess_category_value (const gchar *categoryname) -{ - const gchar *retval; - - /* The highest priority value is the `LANGUAGE' environment - * variable. This is a GNU extension. - */ - - retval = g_getenv ("LANGUAGE"); - - if (retval != NULL && retval[0] != '\0') - return retval; - - /* `LANGUAGE' is not set. So we have to proceed with the POSIX - * methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some - * systems this can be done by the `setlocale' function itself. - */ - - /* Setting of LC_ALL overwrites all other. */ - - retval = g_getenv ("LC_ALL"); - - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Next comes the name of the desired category. */ - retval = g_getenv (categoryname); - - if (retval != NULL && retval[0] != '\0') - return retval; - - /* Last possibility is the LANG environment variable. */ - retval = g_getenv ("LANG"); - if (retval != NULL && retval[0] != '\0') - return retval; - - return NULL; -} - - -static GHashTable *category_table= NULL; - -static const GList * -zenity_i18n_get_language_list (const gchar *category_name) -{ - GList *list; - - if (!category_name) - category_name= "LC_ALL"; - - if (category_table) { - list= g_hash_table_lookup (category_table, (const gpointer) category_name); - } else { - category_table= g_hash_table_new (g_str_hash, g_str_equal); - list= NULL; - } - - if (!list) { - gint c_locale_defined= FALSE; - const gchar *category_value; - gchar *category_memory, *orig_category_memory; - - category_value = zenity_guess_category_value (category_name); - - if (! category_value) - category_value = "C"; - - orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1); - - while (category_value[0] != '\0') { - while (category_value[0] != '\0' && category_value[0] == ':') - ++category_value; - - if (category_value[0] != '\0') { - char *cp= category_memory; - - while (category_value[0] != '\0' && category_value[0] != ':') - *category_memory++= *category_value++; - - category_memory[0]= '\0'; - category_memory++; - - cp = zenity_unalias_lang (cp); - - if (strcmp (cp, "C") == 0) - c_locale_defined= TRUE; - - list= g_list_concat (list, zenity_compute_locale_variants (cp)); - } - } - - g_free (orig_category_memory); - - if (!c_locale_defined) - list= g_list_append (list, "C"); - - g_hash_table_insert (category_table, (gpointer) category_name, list); - } - - return list; -} - -/* This is copied from libgnome/gnome-help.c since we try and avoid using - * the evils of gnome_program_init (), which messes up the commandline - */ - -static char * -zenity_locate_help_file (const char *path, const char *doc_name) -{ - int i; - char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL }; - const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES"); - - for (;lang_list != NULL; lang_list = lang_list->next) { - const char *lang = lang_list->data; - - /* This has to be a valid language AND a language with - * no encoding postfix. The language will come up without - * encoding next - */ - - if (lang == NULL || (gchar *) strchr (lang, '.') != NULL) - continue; - - for (i = 0; exts[i] != NULL; i++) { - char *name; - char *full; - - name = g_strconcat (doc_name, exts[i], NULL); - full = g_build_filename (path, lang, name, NULL); - - if (g_file_test (full, G_FILE_TEST_EXISTS)) - return full; - - g_free (full); - - } - } - - return NULL; -} - -/* This is copied from libgnome/gnome-url.c since we try and avoid using - * the evils of gnome_program_init (), which messes up the commandline - */ - -gboolean -zenity_util_show_help (const gchar *path, const gchar *document, GError **error) +void +zenity_util_show_help (GError **error) { - GConfClient *client; - gint i; - gchar *pos, *template; - int argc; - char **argv; - gboolean ret; - char *url; - - g_return_val_if_fail (path != NULL, FALSE); - g_return_val_if_fail (document != NULL, FALSE); - - url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL); - pos = (gchar *) strchr (url, ':'); - - client = gconf_client_get_default (); - - if (pos != NULL) { - gchar *protocol, *path; - - g_return_val_if_fail (pos >= url, FALSE); - - protocol = g_new (gchar, pos - url + 1); - strncpy (protocol, url, pos - url); - protocol[pos - url] = '\0'; - g_ascii_strdown (protocol, -1); - - path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL); - template = gconf_client_get_string (client, path, NULL); - - if (template == NULL) { - gchar* template_temp; - - template_temp = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL); - - /* Retry to get the right url handler */ - template = gconf_client_get_string (client, path, NULL); - - if (template == NULL) - template = template_temp; - else - g_free (template_temp); + gchar *tmp; + tmp = g_find_program_in_path ("yelp"); - } - - g_free (path); - g_free (protocol); - - } else { - /* no ':' ? this shouldn't happen. Use default handler */ - template = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL); + if (tmp) { + g_free (tmp); + g_spawn_command_line_async ("yelp ghelp:zenity", error); } - - g_object_unref (G_OBJECT (client)); - - if (!g_shell_parse_argv (template, &argc, &argv, error)) { - g_free (template); - return FALSE; - } - - g_free (template); - - for (i = 0; i < argc; i++) { - char *arg; - - if (strcmp (argv[i], "%s") != 0) - continue; - - arg = argv[i]; - argv[i] = g_strdup (url); - g_free (arg); - } - - /* This can return some errors */ - ret = g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error); - g_strfreev (argv); - - return ret; } gint diff --git a/src/util.h b/src/util.h index 0b518a1e..1374818a 100644 --- a/src/util.h +++ b/src/util.h @@ -19,9 +19,7 @@ void zenity_util_set_window_icon (GtkWidget *widge const gchar *filename); void zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id); -gboolean zenity_util_show_help (const gchar *path, - const gchar *document, - GError **error); +void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); G_END_DECLS -- cgit From 0e37613d25b36039f57cbe463c5e34a8017985e8 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 6 Mar 2004 18:50:14 +0000 Subject: Update to add Mike. Update for new release. Add lots of people, probably 2004-03-07 Glynn Foster * AUTHORS: Update to add Mike. * NEWS: Update for new release. * THANKS, src/about.c: Add lots of people, probably get heaps of bug reports complaining their name is spelled wrongly - darn those weird characters. * configure.in: Release 2.5.90 --- src/about.c | 109 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 91 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index d955b92a..24349155 100644 --- a/src/about.c +++ b/src/about.c @@ -46,26 +46,99 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpoin /* Sync with the people in the THANKS file */ static const gchar *author_credits[] = { - "Author -", + "Authors", + "=======", "Glynn Foster ", - "", - "Thanks to -", - "Jonathan Blandford ", - "Ross Burton ", - "Anders Carlsson ", - "Nicholas Curran ", - "John Fleck ", - "James Henstridge ", - "Mihai T. Lazarescu ", - "Buhan Milne ", "Mike Newman ", - "Havoc Pennington ", - "Kevin C. Krinke ", - "Kristian Rietveld ", - "Jakub Steiner ", - "Daniel d'Surreal ", - "Hidetoshi Tajima ", - "Tom Tromey ", + "", + "Patches from the following people", + "=================================", + "Peter Astrand ", + "Jonathan Blandford ", + "Ross Burton ", + "Damien Carbery ", + "Anders Carlsson ", + "Nicholas Curran ", + "John Fleck ", + "James Henstridge ", + "Mihai T. Lazarescu ", + "Tomasz Koczko ", + "Jordi Mallach ", + "Kjartan Maraas ", + "Buhan Milne ", + "Christian Monneckes ", + "Havoc Pennington ", + "Jan Arne Petersen ", + "Kevin C. Krinke ", + "Kristian Rietveld ", + "Christian Rose ", + "Jakub Steiner ", + "Daniel d'Surreal ", + "Hidetoshi Tajima ", + "Tom Tromey ", + "Yann ", + "", + "And all the translators that rock my world", + "==========================================", + "Vincent van Adrighem ", + "Taneem Ahmed ", + "Takeshi Aihana ", + "Amanpreet Singh Alam ", + "Sanlig Badral ", + "Aygimantas Beruka ", + "Alberto Fernandez Benito ", + "Stefano Canepa ", + "Young-Ho Cha ", + "Abel Cheung ", + "Zbigniew Chyla ", + "Fatih Demir ", + "Laurent Dhima ", + "Paul Duffy ", + "Francisco Javier Fernandez ", + "Artur Flinta ", + "Alessio Frusciante ", + "Evandro Fernandes Giovanini ", + "Pablo Gonzalo del Campo ", + "Dhurba Gnawali ", + "Sammi Gunnarsson ", + "Dafydd Harries ", + "Wang Jian ", + "Guntupalli Karunakar ", + "Tomas Kuliavas ", + "Priit Laes ", + "Iaki Larraaga ", + "Ole Laursen ", + "Toivo Leedjrv ", + "Duarte Loreto ", + "Johanna Makkonen ", + "Jordi Mallach ", + "Kjartan Maraas ", + "Jordi Mas ", + "Kamagasako Masatoshi ", + "Dmitry G. Mastrukov ", + "Arafat Medini ", + "Christophe Merlet ", + "Mike Newman ", + "Alexandre Folle de Menezes ", + "Christian Neumair ", + "Metin Omirov ", + "Kostas Papadimas ", + "Sami Pesonen ", + "Roozbeh Pournader ", + "Jarkko Ranta ", + "Christian Rose ", + "Changwoo Ryu ", + "Pablo Saratxaga ", + "Robert Sedak ", + "Paisa Seeluangsawat ", + "Danilo Segan ", + "Aasmund Skjaveland ", + "Yuriy Syrota ", + "Marcel Telka ", + "Andras Timar ", + "Miloslav Trmac ", + "Daniel Yacob ", + "Funda Wang ", NULL }; -- cgit From 8edcd96f02f861c282afb8f5c35e679a23362431 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sat, 6 Mar 2004 18:52:08 +0000 Subject: Remove some unused code. 2004-03-07 Glynn Foster * src/util.c: Remove some unused code. --- src/util.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 0b616efa..c2b8e798 100644 --- a/src/util.c +++ b/src/util.c @@ -36,9 +36,6 @@ #include "zenity.h" #include -#define URL_HANDLER_DIR "/desktop/gnome/url-handlers/" -#define DEFAULT_HANDLER_PATH "/desktop/gnome/url-handlers/unknown/command" - #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 #define ZENITY_ESC_DEFAULT 1 -- cgit From b43bbda2e247e72782cf116003d308d21346935f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 19 Mar 2004 02:28:30 +0000 Subject: Patch from Darren Adams to make sure the new 2004-03-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, src/progress.c, src/text.c, src/tree.c: Patch from Darren Adams to make sure the new file chooser resizes nicely. Sanitize the default setting of the other widgets. * configure.in, src/util.c: Lose gconf dependancy since we don't currently use it, although arguably we should to detect which help browser we're supposed to run :/ * THANKS, src/about.c: Add Darren to the list. --- src/about.c | 1 + src/calendar.c | 3 ++- src/entry.c | 3 ++- src/fileselection.c | 3 +-- src/msg.c | 5 +++-- src/progress.c | 3 ++- src/text.c | 6 +++++- src/tree.c | 3 ++- src/util.c | 1 - 9 files changed, 18 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 24349155..46dcd255 100644 --- a/src/about.c +++ b/src/about.c @@ -53,6 +53,7 @@ static const gchar *author_credits[] = { "", "Patches from the following people", "=================================", + "Darren Adams ", "Peter Astrand ", "Jonathan Blandford ", "Ross Burton ", diff --git a/src/calendar.c b/src/calendar.c index 36b3fe4d..f5cbb33c 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -63,7 +63,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); diff --git a/src/entry.c b/src/entry.c index c2570e0a..bf1811bd 100644 --- a/src/entry.c +++ b/src/entry.c @@ -59,7 +59,8 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); diff --git a/src/fileselection.c b/src/fileselection.c index 955226d1..6a9b018c 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -54,8 +54,6 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); @@ -107,6 +105,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + gtk_main_quit (); break; } } diff --git a/src/msg.c b/src/msg.c index 2b4083b5..bd1450e0 100644 --- a/src/msg.c +++ b/src/msg.c @@ -107,8 +107,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } } - - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); diff --git a/src/progress.c b/src/progress.c index c7ab5cf1..68c653d7 100644 --- a/src/progress.c +++ b/src/progress.c @@ -196,7 +196,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); diff --git a/src/text.c b/src/text.c index c4a49f8b..fb119b05 100644 --- a/src/text.c +++ b/src/text.c @@ -133,7 +133,6 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); text_buffer = gtk_text_buffer_new (NULL); @@ -149,6 +148,11 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->editable) zen_text_data->buffer = text_buffer; + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + else + gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); + gtk_widget_show (dialog); if (glade_dialog) diff --git a/src/tree.c b/src/tree.c index aaf513c6..03404b04 100644 --- a/src/tree.c +++ b/src/tree.c @@ -308,7 +308,8 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) else zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); diff --git a/src/util.c b/src/util.c index c2b8e798..c521f173 100644 --- a/src/util.c +++ b/src/util.c @@ -34,7 +34,6 @@ #include "config.h" #include "util.h" #include "zenity.h" -#include #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 -- cgit From 1e5f3993ee520c12bdafd9c5587fab0ba393a85c Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 22 Mar 2004 10:53:47 +0000 Subject: Update. Release 2.6.0 2004-03-23 Glynn Foster * NEWS, THANKS, src/about.c: Update. * configure.in: Release 2.6.0 --- src/about.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 46dcd255..b29047fb 100644 --- a/src/about.c +++ b/src/about.c @@ -134,12 +134,14 @@ static const gchar *author_credits[] = { "Paisa Seeluangsawat ", "Danilo Segan ", "Aasmund Skjaveland ", - "Yuriy Syrota ", + "Yuriy Syrota ", "Marcel Telka ", "Andras Timar ", "Miloslav Trmac ", + "Mugurel Tudor ", "Daniel Yacob ", - "Funda Wang ", + "Funda Wang ", + "Alexander Winston ", NULL }; -- cgit From 62785ed80fb0b86847b4eaa3f4cf596f4c109324 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 26 Apr 2004 04:41:25 +0000 Subject: Add from the 2 Sebastian's, and make email addresses more spam proof. 2004-04-26 Glynn Foster * THANKS, src/about.c: Add from the 2 Sebastian's, and make email addresses more spam proof. * src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c, * src/progress.c, src/text.c, src/tree.c, src/util.c, * src/util.h: Patch from Sebastian Kapfer to make all zenity dialogs transients of the parent xterm. Fixes #136226. * src/zenity.glade: Patch from Sebastian Heinlein to improve things HIG wise. Fixes #140745. --- src/about.c | 180 ++++++++++++++++++++++++++-------------------------- src/calendar.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/msg.c | 2 +- src/progress.c | 4 +- src/text.c | 2 +- src/tree.c | 2 +- src/util.c | 93 +++++++++++++++++++++++++++ src/util.h | 1 + src/zenity.glade | 152 ++++++++++++++++++++++++++++++++++---------- 11 files changed, 310 insertions(+), 132 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index b29047fb..5053371a 100644 --- a/src/about.c +++ b/src/about.c @@ -48,100 +48,102 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpoin static const gchar *author_credits[] = { "Authors", "=======", - "Glynn Foster ", - "Mike Newman ", + "Glynn Foster ", + "Mike Newman ", "", "Patches from the following people", "=================================", - "Darren Adams ", - "Peter Astrand ", - "Jonathan Blandford ", - "Ross Burton ", - "Damien Carbery ", - "Anders Carlsson ", - "Nicholas Curran ", - "John Fleck ", - "James Henstridge ", - "Mihai T. Lazarescu ", - "Tomasz Koczko ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Buhan Milne ", - "Christian Monneckes ", - "Havoc Pennington ", - "Jan Arne Petersen ", - "Kevin C. Krinke ", - "Kristian Rietveld ", - "Christian Rose ", - "Jakub Steiner ", - "Daniel d'Surreal ", - "Hidetoshi Tajima ", - "Tom Tromey ", - "Yann ", + "Darren Adams " + "Peter Astrand ", + "Jonathan Blandford ", + "Ross Burton ", + "Damien Carbery ", + "Anders Carlsson ", + "Nicholas Curran ", + "John Fleck ", + "Sebastian Heinlein ", + "James Henstridge ", + "Mihai T Lazarescu ", + "Sebastian Kapfer ", + "Tomasz Koczko ", + "Jordi Mallach ", + "Kjartan Maraas ", + "Buhan Milne ", + "Christian Monneckes ", + "Havoc Pennington ", + "Jan Arne Petersen ", + "Kevin C Krinke ", + "Kristian Rietveld ", + "Christian Rose ", + "Jakub Steiner ", + "Daniel d'Surreal ", + "Hidetoshi Tajima ", + "Tom Tromey ", + "Yann ", "", "And all the translators that rock my world", "==========================================", - "Vincent van Adrighem ", - "Taneem Ahmed ", - "Takeshi Aihana ", - "Amanpreet Singh Alam ", - "Sanlig Badral ", - "Aygimantas Beruka ", - "Alberto Fernandez Benito ", - "Stefano Canepa ", - "Young-Ho Cha ", - "Abel Cheung ", - "Zbigniew Chyla ", - "Fatih Demir ", - "Laurent Dhima ", - "Paul Duffy ", - "Francisco Javier Fernandez ", - "Artur Flinta ", - "Alessio Frusciante ", - "Evandro Fernandes Giovanini ", - "Pablo Gonzalo del Campo ", - "Dhurba Gnawali ", - "Sammi Gunnarsson ", - "Dafydd Harries ", - "Wang Jian ", - "Guntupalli Karunakar ", - "Tomas Kuliavas ", - "Priit Laes ", - "Iaki Larraaga ", - "Ole Laursen ", - "Toivo Leedjrv ", - "Duarte Loreto ", - "Johanna Makkonen ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Jordi Mas ", - "Kamagasako Masatoshi ", - "Dmitry G. Mastrukov ", - "Arafat Medini ", - "Christophe Merlet ", - "Mike Newman ", - "Alexandre Folle de Menezes ", - "Christian Neumair ", - "Metin Omirov ", - "Kostas Papadimas ", - "Sami Pesonen ", - "Roozbeh Pournader ", - "Jarkko Ranta ", - "Christian Rose ", - "Changwoo Ryu ", - "Pablo Saratxaga ", - "Robert Sedak ", - "Paisa Seeluangsawat ", - "Danilo Segan ", - "Aasmund Skjaveland ", - "Yuriy Syrota ", - "Marcel Telka ", - "Andras Timar ", - "Miloslav Trmac ", - "Mugurel Tudor ", - "Daniel Yacob ", - "Funda Wang ", - "Alexander Winston ", + "Vincent van Adrighem ", + "Taneem Ahmed ", + "Takeshi Aihana ", + "Amanpreet Singh Alam ", + "Sanlig Badral ", + "Aygimantas Beruka ", + "Alberto Fernandez Benito ", + "Stefano Canepa ", + "Young-Ho Cha ", + "Abel Cheung ", + "Zbigniew Chyla ", + "Fatih Demir ", + "Laurent Dhima ", + "Paul Duffy ", + "Francisco Javier Fernandez ", + "Artur Flinta ", + "Alessio Frusciante ", + "Evandro Fernandes Giovanini ", + "Pablo Gonzalo del Campo ", + "Dhurba Gnawali ", + "Sammi Gunnarsson ", + "Dafydd Harries ", + "Wang Jian ", + "Guntupalli Karunakar ", + "Tomas Kuliavas ", + "Priit Laes ", + "Iaki Larraaga ", + "Ole Laursen ", + "Toivo Leedjrv ", + "Duarte Loreto ", + "Johanna Makkonen ", + "Jordi Mallach ", + "Kjartan Maraas ", + "Jordi Mas ", + "Kamagasako Masatoshi ", + "Dmitry G Mastrukov ", + "Arafat Medini ", + "Christophe Merlet ", + "Mike Newman ", + "Alexandre Folle de Menezes ", + "Christian Neumair ", + "Metin Omirov ", + "Kostas Papadimas ", + "Sami Pesonen ", + "Roozbeh Pournader ", + "Jarkko Ranta ", + "Christian Rose ", + "Changwoo Ryu ", + "Pablo Saratxaga ", + "Robert Sedak ", + "Paisa Seeluangsawat ", + "Danilo Segan ", + "Aasmund Skjaveland ", + "Yuriy Syrota ", + "Marcel Telka ", + "Andras Timar ", + "Miloslav Trmac ", + "Mugurel Tudor ", + "Daniel Yacob ", + "Funda Wang ", + "Alexander Winston ", NULL }; @@ -382,7 +384,7 @@ zenity_about (ZenityData *data) if (glade_dialog) g_object_unref (glade_dialog); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/calendar.c b/src/calendar.c index f5cbb33c..2d297786 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -82,7 +82,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/entry.c b/src/entry.c index bf1811bd..36ff704a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -80,7 +80,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/fileselection.c b/src/fileselection.c index 6a9b018c..a783b34a 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -68,7 +68,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->multi) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/msg.c b/src/msg.c index bd1450e0..7ce78c58 100644 --- a/src/msg.c +++ b/src/msg.c @@ -114,7 +114,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/progress.c b/src/progress.c index 68c653d7..3cc4bd9a 100644 --- a/src/progress.c +++ b/src/progress.c @@ -207,8 +207,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (progress_data->percentage > -1) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); - - gtk_widget_show (dialog); + + zenity_util_show_dialog (dialog); zenity_progress_read_info (progress_data); gtk_main (); diff --git a/src/text.c b/src/text.c index fb119b05..88c08620 100644 --- a/src/text.c +++ b/src/text.c @@ -153,7 +153,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) else gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); if (glade_dialog) g_object_unref (glade_dialog); diff --git a/src/tree.c b/src/tree.c index 03404b04..a1c1bb95 100644 --- a/src/tree.c +++ b/src/tree.c @@ -437,7 +437,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); } - gtk_widget_show (dialog); + zenity_util_show_dialog (dialog); gtk_main (); if (glade_dialog) diff --git a/src/util.c b/src/util.c index c521f173..3364e306 100644 --- a/src/util.c +++ b/src/util.c @@ -31,10 +31,15 @@ #include #include #include +#include #include "config.h" #include "util.h" #include "zenity.h" +#ifdef GDK_WINDOWING_X11 +#include +#endif + #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 #define ZENITY_ESC_DEFAULT 1 @@ -259,3 +264,91 @@ zenity_util_return_exit_code ( ZenityExitCode value ) retval = atoi (env_var); return retval; } + + +#ifdef GDK_WINDOWING_X11 + +static Window +transient_get_xterm () +{ + const char *wid_str = g_getenv ("WINDOWID"); + if (wid_str) { + char *wid_str_end; + Window wid = strtoul (wid_str, &wid_str_end, 10); + if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) + return wid; + } + return None; +} + +static void +transient_x_free (void *ptr) +{ + if (ptr) + XFree (ptr); +} + +static gboolean +transient_is_toplevel (Window wid) +{ + XTextProperty prop; + Display *dpy = GDK_DISPLAY (); + if (!XGetWMName (dpy, wid, &prop)) + return FALSE; + transient_x_free (prop.value); + return !!prop.value; +} + +/* + * GNOME Terminal doesn't give us its toplevel window, but the WM needs a + * toplevel XID for proper stacking. Other terminals work fine without this + * magic. We can't use GDK here since "xterm" is a foreign window. + */ + +static Window +transient_get_xterm_toplevel () +{ + Window xterm = transient_get_xterm (); + Display *dpy = GDK_DISPLAY (); + while (xterm != None && !transient_is_toplevel (xterm)) + { + Window root, parent, *children; + int nchildren; + XQueryTree (dpy, xterm, + &root, &parent, + &children, &nchildren); + transient_x_free (children); + if (parent == root) + xterm = None; + else + xterm = parent; + } + return xterm; +} + +static void +zenity_util_make_transient (GdkWindow *window) +{ + Window xterm = transient_get_xterm_toplevel (); + if (xterm != None) { + GdkWindow *gdkxterm = gdk_window_foreign_new (xterm); + if (gdkxterm) { + gdk_window_set_transient_for (window, gdkxterm); + g_object_unref (G_OBJECT (gdkxterm)); + } + } +} + +#endif /* GDK_WINDOWING_X11 */ + +void +zenity_util_show_dialog (GtkWidget *dialog) +{ + gtk_widget_realize (dialog); +#ifdef GDK_WINDOWING_X11 + g_assert (dialog->window); + zenity_util_make_transient (dialog->window); +#endif + gtk_widget_show (dialog); +} + diff --git a/src/util.h b/src/util.h index 1374818a..69ec9122 100644 --- a/src/util.h +++ b/src/util.h @@ -21,6 +21,7 @@ void zenity_util_set_window_icon_from_stock (GtkWidget *widge const gchar *stock_id); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); +void zenity_util_show_dialog (GtkWidget *widget); G_END_DECLS diff --git a/src/zenity.glade b/src/zenity.glade index c33d797e..e1126b79 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -2,7 +2,6 @@ - Calendar selection @@ -11,6 +10,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -33,6 +37,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -46,6 +51,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -148,20 +154,26 @@ + 6 Warning GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - True + False False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False True False - 0 + 12 @@ -176,6 +188,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -189,6 +202,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -203,10 +217,10 @@ - 13 + 6 True False - 0 + 12 @@ -214,7 +228,7 @@ gtk-dialog-warning 6 0 - 0.5 + 0 0 0 @@ -235,8 +249,8 @@ True False 0.5 - 0.5 - 7 + 0 + 0 0 @@ -264,6 +278,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -274,6 +293,7 @@ True True GTK_RELIEF_NORMAL + True @@ -283,25 +303,32 @@ True True GTK_RELIEF_NORMAL + True + 6 Question GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - True + False False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False True False - 0 + 12 @@ -316,6 +343,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -329,6 +357,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -343,10 +372,10 @@ - 13 + 6 True False - 0 + 12 @@ -354,7 +383,7 @@ gtk-dialog-question 6 0 - 0.5 + 0 0 0 @@ -375,8 +404,8 @@ True False 0.5 - 0.5 - 7 + 0 + 0 0 @@ -403,6 +432,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -425,6 +459,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -438,6 +473,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -525,6 +561,7 @@ + 6 Text View GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -533,14 +570,19 @@ 200 True False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False True False - 0 + 6 @@ -555,6 +597,7 @@ gtk-close True GTK_RELIEF_NORMAL + True -7 @@ -569,7 +612,7 @@ - 7 + 6 True False 0 @@ -588,6 +631,8 @@ True True False + False + True GTK_JUSTIFY_LEFT GTK_WRAP_WORD True @@ -625,6 +670,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -647,6 +697,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -661,6 +712,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -740,20 +792,26 @@ + 6 Error GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - True + False False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False True False - 0 + 12 @@ -768,6 +826,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -789,9 +848,10 @@ + 6 True False - 0 + 12 @@ -799,7 +859,7 @@ gtk-dialog-error 6 0.5 - 0.5 + 0 0 0 @@ -820,7 +880,7 @@ True False 0.5 - 0.5 + 0 0 0 @@ -857,6 +917,11 @@ 200 True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -879,6 +944,7 @@ gtk-cancel True GTK_RELIEF_NORMAL + True -6 @@ -892,6 +958,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -983,20 +1050,26 @@ + 6 Information GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - True + False False - True + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + False True False - 0 + 12 @@ -1011,6 +1084,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -1034,7 +1108,7 @@ True False - 0 + 12 @@ -1042,7 +1116,7 @@ gtk-dialog-info 6 0.5 - 0.5 + 0 0 0 @@ -1063,7 +1137,7 @@ True False 0.5 - 0.5 + 0 0 0 @@ -1098,6 +1172,11 @@ False True False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST True @@ -1120,6 +1199,7 @@ gtk-help True GTK_RELIEF_NORMAL + True -11 @@ -1132,6 +1212,7 @@ _Credits True GTK_RELIEF_NORMAL + True 0 @@ -1145,6 +1226,7 @@ gtk-ok True GTK_RELIEF_NORMAL + True -5 @@ -1183,7 +1265,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1205,7 +1287,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1227,7 +1309,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 5f7b750f3972de1106e593922374a0b75c2dd5ea Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 27 Apr 2004 20:34:56 +0000 Subject: Untranslate 3 strings again. Thanks to Christian for pointing this out. 2004-04-27 Glynn Foster * src/zenity.glade: Untranslate 3 strings again. Thanks to Christian for pointing this out. --- src/zenity.glade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index e1126b79..bb42c2d8 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1265,7 +1265,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1287,7 +1287,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1309,7 +1309,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER -- cgit From 02955ce70f7fa58da88dc8d66e07520afb94f642 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 28 Apr 2004 12:06:02 +0000 Subject: Fix the list dialog not being able to handle --text to change the text. It 2004-04-29 Glynn Foster * src/main.c, src/tree.c: Fix the list dialog not being able to handle --text to change the text. It was also intentional but must have fallen through the gaps. * data/zenity.1: Update * help/C/zenity.xml: Update. --- src/main.c | 20 +++++++++++++++++++- src/tree.c | 6 ++++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 58fe37ac..9b112c62 100644 --- a/src/main.c +++ b/src/main.c @@ -96,6 +96,7 @@ enum { OPTION_FILENAME, OPTION_MULTIFILE, OPTION_TEXTFILENAME, + OPTION_LISTTEXT, OPTION_COLUMN, OPTION_SEPERATOR, OPTION_LISTEDIT, @@ -461,6 +462,15 @@ struct poptOption list_options[] = { NULL, NULL }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_LISTTEXT, + N_("Set the dialog text"), + NULL + }, { "column", '\0', @@ -959,6 +969,7 @@ zenity_init_parsing_options (void) { results->progress_data->pulsate = FALSE; results->progress_data->autoclose = FALSE; results->entry_data->visible = TRUE; + results->tree_data->dialog_text = NULL; results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; @@ -1004,6 +1015,8 @@ zenity_free_parsing_options (void) { g_free (results->text_data->uri); break; case MODE_LIST: + if (results->tree_data->dialog_text) + g_free (results->tree_data->dialog_text); if (results->tree_data->columns) g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); if (results->tree_data->separator) @@ -1237,6 +1250,7 @@ zenity_parse_options_callback (poptContext ctx, case OPTION_ERRORTEXT: case OPTION_QUESTIONTEXT: case OPTION_PROGRESSTEXT: + case OPTION_LISTTEXT: case OPTION_WARNINGTEXT: /* FIXME: This is an ugly hack because of the way the poptOptions are @@ -1244,7 +1258,7 @@ zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 6) + if (parse_option_text > 7) zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { @@ -1267,6 +1281,10 @@ zenity_parse_options_callback (poptContext ctx, results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), -1, NULL, NULL, NULL); break; + case MODE_LIST: + results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); + break; default: zenity_error ("--text", ERROR_SUPPORT); } diff --git a/src/tree.c b/src/tree.c index a1c1bb95..bc1cc1cc 100644 --- a/src/tree.c +++ b/src/tree.c @@ -269,6 +269,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { GtkWidget *dialog; GtkWidget *tree_view; + GtkWidget *text; GtkTreeViewColumn *column; GtkListStore *model; GType *column_types; @@ -303,6 +304,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + text = glade_xml_get_widget (glade_dialog, "zenity_tree_text"); + + if (tree_data->dialog_text) + gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text); + if (data->window_icon) zenity_util_set_window_icon (dialog, data->window_icon); else -- cgit From c30c2f365fc8567cf1614388510c9d0e6b0aa764 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 9 Jun 2004 21:12:55 +0000 Subject: Add Paul. fix tyops in parsing. 2004-06-08 Glynn Foster * THANKS, src/about.c: Add Paul. * src/main.c: fix tyops in parsing. --- src/about.c | 1 + src/main.c | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 5053371a..b6ee1d60 100644 --- a/src/about.c +++ b/src/about.c @@ -56,6 +56,7 @@ static const gchar *author_credits[] = { "Darren Adams " "Peter Astrand ", "Jonathan Blandford ", + "Paul Bolle ", "Ross Burton ", "Damien Carbery ", "Anders Carlsson ", diff --git a/src/main.c b/src/main.c index 9b112c62..2baed7dc 100644 --- a/src/main.c +++ b/src/main.c @@ -1405,18 +1405,18 @@ zenity_parse_options_callback (poptContext ctx, break; case OPTION_CHECKLIST: if (results->mode != MODE_LIST) - zenity_error ("--checkbox", ERROR_SUPPORT); + zenity_error ("--checklist", ERROR_SUPPORT); if (results->tree_data->checkbox) - zenity_error ("--checkbox", ERROR_DUPLICATE); + zenity_error ("--checklist", ERROR_DUPLICATE); results->tree_data->checkbox = TRUE; break; case OPTION_RADIOLIST: if (results->mode != MODE_LIST) - zenity_error ("--radiobox", ERROR_SUPPORT); + zenity_error ("--radiolist", ERROR_SUPPORT); if (results->tree_data->radiobox) - zenity_error ("--radiobox", ERROR_DUPLICATE); + zenity_error ("--radiolist", ERROR_DUPLICATE); results->tree_data->radiobox = TRUE; break; -- cgit From c7ec5229bbf0328687ae1deef58c9fae906b34f2 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 16 Jun 2004 23:45:28 +0000 Subject: Fix parsing errors. Patch from Paull Bolle. Fixes #144501. 2004-06-17 Glynn Foster * src/main.c: Fix parsing errors. Patch from Paull Bolle. Fixes #144501. --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 2baed7dc..9e28a566 100644 --- a/src/main.c +++ b/src/main.c @@ -1353,7 +1353,7 @@ zenity_parse_options_callback (poptContext ctx, * parse_options_callback gets called for each option. Suckage */ - if (parse_option_file > 2) + if (parse_option_editable > 2) zenity_error ("--editable", ERROR_DUPLICATE); switch (results->mode) { -- cgit From 6c68b70ca3bb5ea719c5044a2e5d7959f87b1a06 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 17 Jun 2004 23:38:39 +0000 Subject: Patch from Luke Suchocki to send HUP to parent instead of itself. Fixes 2004-06-18 Glynn Foster * THANKS, src/about.c, src/progress.c: Patch from Luke Suchocki to send HUP to parent instead of itself. Fixes #144542. --- src/about.c | 1 + src/progress.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index b6ee1d60..c9ae1622 100644 --- a/src/about.c +++ b/src/about.c @@ -77,6 +77,7 @@ static const gchar *author_credits[] = { "Kristian Rietveld ", "Christian Rose ", "Jakub Steiner ", + "Luke Suchocki ", "Daniel d'Surreal ", "Hidetoshi Tajima ", "Tom Tromey ", diff --git a/src/progress.c b/src/progress.c index 3cc4bd9a..5804e88a 100644 --- a/src/progress.c +++ b/src/progress.c @@ -228,7 +228,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) * I'm pretty sure there is a nice way to do this, but I'm clueless about this * stuff. Should be using SIGHUP instead of 1 though. */ - kill (getpid (), 1); + kill (getppid (), 1); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); gtk_main_quit (); break; -- cgit From e6290c86ffbb3c29a2bb071744ab7e425327dc27 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 18 Jul 2004 23:37:06 +0000 Subject: Fix up compilation using Forte compiler. Based on patch from Ivan Noris. 2004-07-19 Glynn Foster * configure.in, src/Makefile.am: Fix up compilation using Forte compiler. Based on patch from Ivan Noris. Fixes #143041. --- src/Makefile.am | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index b09aacd7..c5c9fcda 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,8 @@ INCLUDES = \ -DZENITY_DATADIR=\""$(datadir)/zenity"\" zenity_LDADD = \ - $(ZENITY_LIBS) + $(ZENITY_LIBS) \ + $(X_LIBS) gladedir = $(datadir)/zenity -- cgit From 6a17938c959a4418d2c42ef903fa40916defae2f Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 18 Jul 2004 23:40:20 +0000 Subject: Make sure the text can take markup, so that people can create nice HIG 2004-07-19 Glynn Foster * src/msg.c: Make sure the text can take markup, so that people can create nice HIG compliant message dialogs. Patch from Sebastian Heinlein. Fixes #140748. --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 7ce78c58..013fc721 100644 --- a/src/msg.c +++ b/src/msg.c @@ -112,7 +112,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); if (msg_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); zenity_util_show_dialog (dialog); gtk_main (); -- cgit From b986224682b864b25125bf73ae38f47e0fe883b1 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 18 Jul 2004 23:52:07 +0000 Subject: Remove duplicate locale.h include. Patch from Leonardo Boshell. Partly 2004-07-19 Glynn Foster * src/main.c: Remove duplicate locale.h include. Patch from Leonardo Boshell. Partly fixes #137993. --- src/main.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 9e28a566..129dfa5c 100644 --- a/src/main.c +++ b/src/main.c @@ -25,7 +25,6 @@ #include "zenity.h" #include -#include #include #include #ifdef HAVE_LOCALE_H -- cgit From ffaed088561e8c0a085fd2797543aaef65419f0c Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:01:28 +0000 Subject: Add new option for --print-column, based on a patch by Paul Bolle. Fixes 2004-07-19 Glynn Foster * src/main.c, src/tree.c, src/zenity.h, help/C/zenity.xml: Add new option for --print-column, based on a patch by Paul Bolle. Fixes #144496. --- src/main.c | 27 +++++++++++++++++++++---- src/tree.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- src/zenity.h | 1 + 3 files changed, 79 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 129dfa5c..02a67f3f 100644 --- a/src/main.c +++ b/src/main.c @@ -105,6 +105,7 @@ enum { OPTION_PERCENTAGE, OPTION_PULSATE, OPTION_AUTOCLOSE, + OPTION_PRINTCOLUMN, OPTION_QUESTIONTEXT, OPTION_WARNINGTEXT, OPTION_ABOUT, @@ -113,10 +114,10 @@ enum { }; static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); + enum poptCallbackReason reason, + const struct poptOption *opt, + const char *arg, + void *data); struct poptOption options[] = { { @@ -515,6 +516,15 @@ struct poptOption list_options[] = { N_("Allow changes to text"), NULL }, + { + "print-column", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_PRINTCOLUMN, + N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), + NULL + }, POPT_TABLEEND }; @@ -972,6 +982,7 @@ zenity_init_parsing_options (void) { results->tree_data->checkbox = FALSE; results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; + results->tree_data->print_column = NULL; } static void @@ -1020,6 +1031,8 @@ zenity_free_parsing_options (void) { g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); if (results->tree_data->separator) g_free (results->tree_data->separator); + if (results->tree_data->print_column) + g_free (results->tree_data->print_column); break; default: break; @@ -1456,6 +1469,12 @@ zenity_parse_options_callback (poptContext ctx, results->progress_data->autoclose = TRUE; break; + case OPTION_PRINTCOLUMN: + if (results->mode != MODE_LIST) + zenity_error ("--print-column", ERROR_SUPPORT); + + results->tree_data->print_column = g_strdup (arg); + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); diff --git a/src/tree.c b/src/tree.c index bc1cc1cc..e828dfc3 100644 --- a/src/tree.c +++ b/src/tree.c @@ -33,6 +33,8 @@ static GladeXML *glade_dialog; static GSList *selected; static gchar *separator; +static gboolean print_all_columns = FALSE; +static gint print_column_n = 1; static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); @@ -139,7 +141,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, } if (toggles && column_count == 0) { - if (strcmp (zenity_util_strip_newline (string->str), "TRUE") == 0) + if (strcmp (g_strdown (zenity_util_strip_newline (string->str)), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); else gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); @@ -207,6 +209,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, model = gtk_tree_view_get_model (tree_view); + g_object_set_data (G_OBJECT (tree_view), "n_columns", (gint *) n_columns); + while (args[i] != NULL) { gint j; @@ -215,7 +219,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, for (j = 0; j < n_columns; j++) { if (toggles && j == 0) { - if (strcmp (args[i+j], "TRUE") == 0) + if (strcmp (g_strdown ((gchar *) args[i+j]), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); else gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); @@ -288,6 +292,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) n_columns = g_slist_length (tree_data->columns); + if (tree_data->print_column) { + if (strcmp (g_strdown (tree_data->print_column), "all") == 0) + print_all_columns = TRUE; + else + print_column_n = atoi (tree_data->print_column); + } + if (n_columns == 0) { g_printerr (_("No column titles specified for List dialog.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); @@ -454,25 +465,58 @@ static void zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue value = {0, }; + gint n_columns, i; + + n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); - gtk_tree_model_get_value (model, iter, 0, &value); + if (print_all_columns) { + for (i = 0; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } + return; + } + + if (print_column_n > 0 && print_column_n <= n_columns) { + gtk_tree_model_get_value (model, iter, print_column_n - 1, &value); + + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } } static gboolean -zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) +zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue toggle_value = {0, }; + gint n_columns, i; + + n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); gtk_tree_model_get_value (model, iter, 0, &toggle_value); if (g_value_get_boolean (&toggle_value)) { GValue value = {0, }; - gtk_tree_model_get_value (model, iter, 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); + + if (print_all_columns) { + for (i = 1; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); + + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } + g_value_unset (&toggle_value); + return FALSE; + } + + if (print_column_n > 0 && print_column_n <= n_columns) { + gtk_tree_model_get_value (model, iter, print_column_n, &value); + + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } } g_value_unset (&toggle_value); return FALSE; @@ -510,7 +554,8 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) - gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, NULL); + gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, + GTK_TREE_VIEW (tree_view)); else { selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_selection_selected_foreach (selection, diff --git a/src/zenity.h b/src/zenity.h index b04ff5bb..36cf52e2 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -92,6 +92,7 @@ typedef struct { gboolean radiobox; gchar *separator; gboolean editable; + gchar *print_column; const gchar **data; } ZenityTreeData; -- cgit From 4dd6dd672ae0f9620a561f45e53daffb76fe8874 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:01:58 +0000 Subject: Up the gicker. --- src/.cvsignore | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/.cvsignore b/src/.cvsignore index fb42eb77..76bab18f 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -2,3 +2,4 @@ zenity.gladep zenity Makefile.in Makefile +gdialog -- cgit From 63661a6ea0de0250b545d794f645a36ffeb88490 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 19 Jul 2004 01:13:40 +0000 Subject: src/calendar.c, src/entry.c, src/fileselection.c, Cleanup fixes from Paul 2004-07-19 Glynn Foster * src/calendar.c, src/entry.c, src/fileselection.c, * src/msg.c, src/progress.c, src/text.c, src/tree.c: Cleanup fixes from Paul Bolle. --- src/calendar.c | 5 ++--- src/entry.c | 3 +-- src/fileselection.c | 4 +--- src/msg.c | 5 ++--- src/progress.c | 3 +-- src/text.c | 2 +- src/tree.c | 3 +-- 7 files changed, 9 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 2d297786..5936aef2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -107,17 +107,16 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) g_date_free (date); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; - } + } + gtk_main_quit (); } diff --git a/src/entry.c b/src/entry.c index 36ff704a..4d242160 100644 --- a/src/entry.c +++ b/src/entry.c @@ -98,12 +98,10 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) if (text != NULL) g_print ("%s\n", text); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: @@ -111,4 +109,5 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } diff --git a/src/fileselection.c b/src/fileselection.c index a783b34a..995ba03f 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -94,18 +94,16 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer g_slist_free(selections); g_free(separator); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - gtk_main_quit (); break; } + gtk_main_quit (); } diff --git a/src/msg.c b/src/msg.c index 013fc721..27284472 100644 --- a/src/msg.c +++ b/src/msg.c @@ -126,16 +126,15 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: - zen_data->exit_code = 1; + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } diff --git a/src/progress.c b/src/progress.c index 5804e88a..373c5b82 100644 --- a/src/progress.c +++ b/src/progress.c @@ -220,7 +220,6 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: @@ -230,7 +229,6 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) */ kill (getppid (), 1); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: @@ -238,4 +236,5 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } diff --git a/src/text.c b/src/text.c index 88c08620..b70bed0a 100644 --- a/src/text.c +++ b/src/text.c @@ -175,7 +175,6 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) g_print (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0)); } zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; default: @@ -183,4 +182,5 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } diff --git a/src/tree.c b/src/tree.c index e828dfc3..fed58e2a 100644 --- a/src/tree.c +++ b/src/tree.c @@ -564,12 +564,10 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) } zenity_tree_dialog_output (); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - gtk_main_quit (); break; default: @@ -577,4 +575,5 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + gtk_main_quit (); } -- cgit From eff265571321698103893bf71f7bfc7e0c9bf77b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 3 Aug 2004 05:00:49 +0000 Subject: Release 2.7.90 2004-08-03 Glynn Foster * configure.in: Release 2.7.90 --- src/about.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index c9ae1622..dd1e9e92 100644 --- a/src/about.c +++ b/src/about.c @@ -57,6 +57,7 @@ static const gchar *author_credits[] = { "Peter Astrand ", "Jonathan Blandford ", "Paul Bolle ", + "Leonardo Boshell

", "Ross Burton ", "Damien Carbery ", "Anders Carlsson ", @@ -69,8 +70,10 @@ static const gchar *author_credits[] = { "Tomasz Koczko ", "Jordi Mallach ", "Kjartan Maraas ", + "Baptiste Mille-Mathias ", "Buhan Milne ", "Christian Monneckes ", + "Ivan Noris ", "Havoc Pennington ", "Jan Arne Petersen ", "Kevin C Krinke ", @@ -90,15 +93,18 @@ static const gchar *author_credits[] = { "Takeshi Aihana ", "Amanpreet Singh Alam ", "Sanlig Badral ", + "John C Barstow ", "Aygimantas Beruka ", "Alberto Fernandez Benito ", "Stefano Canepa ", "Young-Ho Cha ", "Abel Cheung ", "Zbigniew Chyla ", + "Mohammad Damt ", "Fatih Demir ", "Laurent Dhima ", "Paul Duffy ", + " Laszlo Dvornik ", "Francisco Javier Fernandez ", "Artur Flinta ", "Alessio Frusciante ", @@ -124,19 +130,23 @@ static const gchar *author_credits[] = { "Arafat Medini ", "Christophe Merlet ", "Mike Newman ", + "Ahmad Riza H Nst ", "Alexandre Folle de Menezes ", "Christian Neumair ", "Metin Omirov ", + "Gareth Owen ", "Kostas Papadimas ", "Sami Pesonen ", "Roozbeh Pournader ", "Jarkko Ranta ", + "Rostislav Raykov ", "Christian Rose ", "Changwoo Ryu ", "Pablo Saratxaga ", "Robert Sedak ", "Paisa Seeluangsawat ", "Danilo Segan ", + "Alexander Shopov ", "Aasmund Skjaveland ", "Yuriy Syrota ", "Marcel Telka ", -- cgit From 06d3c86671c9b55702bae72e0b6a326a65c525b7 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 11 Aug 2004 06:14:21 +0000 Subject: Use 'translator-credits' rather than the underscore version which makes 2004-08-11 Glynn Foster * src/about.c: Use 'translator-credits' rather than the underscore version which makes things easier for the translation dudes. --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index dd1e9e92..1ede5929 100644 --- a/src/about.c +++ b/src/about.c @@ -355,7 +355,7 @@ zenity_about (ZenityData *data) return; } - translator_credits = _("translator_credits"); + translator_credits = _("translator-credits"); glade_xml_signal_autoconnect (glade_dialog); -- cgit From b46dd53df6b51ac363eb1cc8b7b51586befd6bdf Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 17 Aug 2004 08:55:10 +0000 Subject: Add translator comment from Christian Rose, and fix up strcmp's for 2004-08-17 Glynn Foster * src/about.c: Add translator comment from Christian Rose, and fix up strcmp's for untranslated translator-credits. --- src/about.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 1ede5929..d9be6d44 100644 --- a/src/about.c +++ b/src/about.c @@ -355,6 +355,14 @@ zenity_about (ZenityData *data) return; } + /* Translators: This is a special message that shouldn't be translated + literally. It is used in the about box to give credits to + the translators. + Thus, you should translate it to your name and email address. + You can also include other translators who have contributed to + this translation; in that case, please write them on separate + lines seperated by newlines (\n). */ + translator_credits = _("translator-credits"); glade_xml_signal_autoconnect (glade_dialog); @@ -445,7 +453,7 @@ zenity_about_update_translator_label (GtkWidget *label) GString *string; gchar *tmp; - if (strcmp (translator_credits, "translator_credits") == 0) { + if (strcmp (translator_credits, "translator-credits") == 0) { gtk_widget_hide (label); return; } else { @@ -504,7 +512,7 @@ zenity_about_display_credits_dialog (void) zenity_about_update_author_label (label); } - if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) { + if (translator_credits != NULL && strcmp (translator_credits, "translator-credits") != 0) { label = zenity_about_create_label (); sw = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), -- cgit From 03f3e5b060977c9566bd66bc8e4eaac14c4ee781 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 04:56:26 +0000 Subject: Update Update. Patch from Lucas Rocha to implement save and directory 2004-09-13 Glynn Foster * THANKS: Update * src/about.c: Update. * src/fileselection.c, src/main.c, src/zenity.h: Patch from Lucas Rocha to implement save and directory selection in the file selection dialog. Fixes #138342. --- src/about.c | 11 ++++++++++- src/fileselection.c | 13 ++++++++++++- src/main.c | 34 ++++++++++++++++++++++++++++++++++ src/zenity.h | 2 ++ 4 files changed, 58 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index d9be6d44..60cb5704 100644 --- a/src/about.c +++ b/src/about.c @@ -70,6 +70,7 @@ static const gchar *author_credits[] = { "Tomasz Koczko ", "Jordi Mallach ", "Kjartan Maraas ", + "Breda McColgan ", "Baptiste Mille-Mathias ", "Buhan Milne ", "Christian Monneckes ", @@ -78,6 +79,7 @@ static const gchar *author_credits[] = { "Jan Arne Petersen ", "Kevin C Krinke ", "Kristian Rietveld ", + "Lucas Rocha ", "Christian Rose ", "Jakub Steiner ", "Luke Suchocki ", @@ -92,6 +94,7 @@ static const gchar *author_credits[] = { "Taneem Ahmed ", "Takeshi Aihana ", "Amanpreet Singh Alam ", + "Metin Amiroff ", "Sanlig Badral ", "John C Barstow ", "Aygimantas Beruka ", @@ -104,7 +107,8 @@ static const gchar *author_credits[] = { "Fatih Demir ", "Laurent Dhima ", "Paul Duffy ", - " Laszlo Dvornik ", + "Laszlo Dvornik ", + "Maxim Dziumanenko ", "Francisco Javier Fernandez ", "Artur Flinta ", "Alessio Frusciante ", @@ -112,7 +116,9 @@ static const gchar *author_credits[] = { "Pablo Gonzalo del Campo ", "Dhurba Gnawali ", "Sammi Gunnarsson ", + "Martin Willemoes Hansen ", "Dafydd Harries ", + "Raphael Higino ", "Wang Jian ", "Guntupalli Karunakar ", "Tomas Kuliavas ", @@ -120,6 +126,7 @@ static const gchar *author_credits[] = { "Iaki Larraaga ", "Ole Laursen ", "Toivo Leedjrv ", + "David Lodge ", "Duarte Loreto ", "Johanna Makkonen ", "Jordi Mallach ", @@ -136,10 +143,12 @@ static const gchar *author_credits[] = { "Metin Omirov ", "Gareth Owen ", "Kostas Papadimas ", + "Ankit Patel ", "Sami Pesonen ", "Roozbeh Pournader ", "Jarkko Ranta ", "Rostislav Raykov ", + "Hendrik Richter ", "Christian Rose ", "Changwoo Ryu ", "Pablo Saratxaga ", diff --git a/src/fileselection.c b/src/fileselection.c index 995ba03f..fdd40fdd 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -34,11 +34,22 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GtkWidget *dialog; gchar *dir; gchar *basename; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; zen_data = data; + if (file_data->directory) { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + else + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + } else { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_SAVE; + } + dialog = gtk_file_chooser_dialog_new (NULL, NULL, - GTK_FILE_CHOOSER_ACTION_OPEN, + action, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); diff --git a/src/main.c b/src/main.c index 02a67f3f..09b1519c 100644 --- a/src/main.c +++ b/src/main.c @@ -94,6 +94,8 @@ enum { OPTION_INFOTEXT, OPTION_FILENAME, OPTION_MULTIFILE, + OPTION_DIR, + OPTION_SAVE, OPTION_TEXTFILENAME, OPTION_LISTTEXT, OPTION_COLUMN, @@ -440,6 +442,24 @@ struct poptOption file_selection_options[] = { N_("Allow multiple files to be selected"), NULL }, + { + "directory", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_DIR, + N_("Activate directory-only selection"), + NULL + }, + { + "save", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_SAVE, + N_("Activate save mode"), + NULL + }, { "separator", '\0', @@ -971,6 +991,8 @@ zenity_init_parsing_options (void) { results->calendar_data->year = 0; results->calendar_data->dialog_text = NULL; results->file_data->multi = FALSE; + results->file_data->directory = FALSE; + results->file_data->save = FALSE; results->file_data->separator = g_strdup ("|"); results->text_data->editable = FALSE; results->tree_data->separator = g_strdup ("|"); @@ -1409,6 +1431,18 @@ zenity_parse_options_callback (poptContext ctx, results->file_data->multi = TRUE; break; + case OPTION_DIR: + if (results->mode != MODE_FILE) + zenity_error ("--directory", ERROR_SUPPORT); + + results->file_data->directory = TRUE; + break; + case OPTION_SAVE: + if (results->mode != MODE_FILE) + zenity_error ("--save", ERROR_SUPPORT); + + results->file_data->save = TRUE; + break; case OPTION_COLUMN: if (results->mode != MODE_LIST) zenity_error ("--column", ERROR_SUPPORT); diff --git a/src/zenity.h b/src/zenity.h index 36cf52e2..d9aff43f 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -62,6 +62,8 @@ typedef struct { typedef struct { gchar *uri; gboolean multi; + gboolean directory; + gboolean save; gchar *separator; } ZenityFileData; -- cgit From 3e05834b4c23a5d5951403719b8594ff3d9fe30b Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 13 Sep 2004 07:51:51 +0000 Subject: Add new notification icon. Update for new files. Restructure code a little 2004-09-13 Glynn Foster * data/Makefile.am, data/zenity-notification.png: Add new notification icon. * src/Makefile.am: Update for new files. * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a little bit for new utility functions for setting window icons. * src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area support. * src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h: Add support for notification area. * data/zenity.1, help/*: Update docs for notification and new file selection changes. --- src/Makefile.am | 3 + src/about.c | 4 +- src/calendar.c | 5 +- src/eggtrayicon.c | 468 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/eggtrayicon.h | 77 +++++++++ src/entry.c | 5 +- src/fileselection.c | 5 +- src/main.c | 67 +++++++- src/msg.c | 36 ++-- src/notification.c | 129 +++++++++++++++ src/progress.c | 5 +- src/text.c | 5 +- src/tree.c | 5 +- src/util.c | 73 ++++---- src/util.h | 10 +- src/zenity.h | 6 + 16 files changed, 814 insertions(+), 89 deletions(-) create mode 100644 src/eggtrayicon.c create mode 100644 src/eggtrayicon.h create mode 100644 src/notification.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index c5c9fcda..310cb560 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -12,6 +12,9 @@ zenity_SOURCES = \ text.c \ progress.c \ tree.c \ + notification.c \ + eggtrayicon.c \ + eggtrayicon.h \ about.c \ util.h \ util.c diff --git a/src/about.c b/src/about.c index 60cb5704..d6fc9083 100644 --- a/src/about.c +++ b/src/about.c @@ -300,7 +300,7 @@ zenity_create_boutique (void) window = gtk_window_new (GTK_WINDOW_TOPLEVEL); - zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png")); + zenity_util_set_window_icon (window, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); canvas = zenity_create_monk (); gtk_container_add (GTK_CONTAINER (window), canvas); @@ -383,7 +383,7 @@ zenity_about (ZenityData *data) g_signal_connect (G_OBJECT (dialog), "key_press_event", G_CALLBACK (zenity_zen_wisdom), glade_dialog); - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png")); + zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); diff --git a/src/calendar.c b/src/calendar.c index 5936aef2..9da633e8 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -58,10 +58,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); diff --git a/src/eggtrayicon.c b/src/eggtrayicon.c new file mode 100644 index 00000000..c4aa3e6e --- /dev/null +++ b/src/eggtrayicon.c @@ -0,0 +1,468 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* eggtrayicon.c + * Copyright (C) 2002 Anders Carlsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#include +#include +#include + +#include "eggtrayicon.h" + +#include +#include + +#ifndef EGG_COMPILATION +#ifndef _ +#define _(x) dgettext (GETTEXT_PACKAGE, x) +#define N_(x) x +#endif +#else +#define _(x) x +#define N_(x) x +#endif + +#define SYSTEM_TRAY_REQUEST_DOCK 0 +#define SYSTEM_TRAY_BEGIN_MESSAGE 1 +#define SYSTEM_TRAY_CANCEL_MESSAGE 2 + +#define SYSTEM_TRAY_ORIENTATION_HORZ 0 +#define SYSTEM_TRAY_ORIENTATION_VERT 1 + +enum { + PROP_0, + PROP_ORIENTATION +}; + +static GtkPlugClass *parent_class = NULL; + +static void egg_tray_icon_init (EggTrayIcon *icon); +static void egg_tray_icon_class_init (EggTrayIconClass *klass); + +static void egg_tray_icon_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec); + +static void egg_tray_icon_realize (GtkWidget *widget); +static void egg_tray_icon_unrealize (GtkWidget *widget); + +static void egg_tray_icon_update_manager_window (EggTrayIcon *icon); + +GType +egg_tray_icon_get_type (void) +{ + static GType our_type = 0; + + if (our_type == 0) + { + static const GTypeInfo our_info = + { + sizeof (EggTrayIconClass), + (GBaseInitFunc) NULL, + (GBaseFinalizeFunc) NULL, + (GClassInitFunc) egg_tray_icon_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof (EggTrayIcon), + 0, /* n_preallocs */ + (GInstanceInitFunc) egg_tray_icon_init + }; + + our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); + } + + return our_type; +} + +static void +egg_tray_icon_init (EggTrayIcon *icon) +{ + icon->stamp = 1; + icon->orientation = GTK_ORIENTATION_HORIZONTAL; + + gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK); +} + +static void +egg_tray_icon_class_init (EggTrayIconClass *klass) +{ + GObjectClass *gobject_class = (GObjectClass *)klass; + GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; + + parent_class = g_type_class_peek_parent (klass); + + gobject_class->get_property = egg_tray_icon_get_property; + + widget_class->realize = egg_tray_icon_realize; + widget_class->unrealize = egg_tray_icon_unrealize; + + g_object_class_install_property (gobject_class, + PROP_ORIENTATION, + g_param_spec_enum ("orientation", + _("Orientation"), + _("The orientation of the tray."), + GTK_TYPE_ORIENTATION, + GTK_ORIENTATION_HORIZONTAL, + G_PARAM_READABLE)); +} + +static void +egg_tray_icon_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EggTrayIcon *icon = EGG_TRAY_ICON (object); + + switch (prop_id) + { + case PROP_ORIENTATION: + g_value_set_enum (value, icon->orientation); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +egg_tray_icon_get_orientation_property (EggTrayIcon *icon) +{ + Display *xdisplay; + Atom type; + int format; + union { + gulong *prop; + guchar *prop_ch; + } prop = { NULL }; + gulong nitems; + gulong bytes_after; + int error, result; + + g_assert (icon->manager_window != None); + + xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); + + gdk_error_trap_push (); + type = None; + result = XGetWindowProperty (xdisplay, + icon->manager_window, + icon->orientation_atom, + 0, G_MAXLONG, FALSE, + XA_CARDINAL, + &type, &format, &nitems, + &bytes_after, &(prop.prop_ch)); + error = gdk_error_trap_pop (); + + if (error || result != Success) + return; + + if (type == XA_CARDINAL) + { + GtkOrientation orientation; + + orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ? + GTK_ORIENTATION_HORIZONTAL : + GTK_ORIENTATION_VERTICAL; + + if (icon->orientation != orientation) + { + icon->orientation = orientation; + + g_object_notify (G_OBJECT (icon), "orientation"); + } + } + + if (prop.prop) + XFree (prop.prop); +} + +static GdkFilterReturn +egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data) +{ + EggTrayIcon *icon = user_data; + XEvent *xev = (XEvent *)xevent; + + if (xev->xany.type == ClientMessage && + xev->xclient.message_type == icon->manager_atom && + xev->xclient.data.l[1] == icon->selection_atom) + { + egg_tray_icon_update_manager_window (icon); + } + else if (xev->xany.window == icon->manager_window) + { + if (xev->xany.type == PropertyNotify && + xev->xproperty.atom == icon->orientation_atom) + { + egg_tray_icon_get_orientation_property (icon); + } + if (xev->xany.type == DestroyNotify) + { + egg_tray_icon_update_manager_window (icon); + } + } + + return GDK_FILTER_CONTINUE; +} + +static void +egg_tray_icon_unrealize (GtkWidget *widget) +{ + EggTrayIcon *icon = EGG_TRAY_ICON (widget); + GdkWindow *root_window; + + if (icon->manager_window != None) + { + GdkWindow *gdkwin; + + gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget), + icon->manager_window); + + gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); + } + + root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); + + gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon); + + if (GTK_WIDGET_CLASS (parent_class)->unrealize) + (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); +} + +static void +egg_tray_icon_send_manager_message (EggTrayIcon *icon, + long message, + Window window, + long data1, + long data2, + long data3) +{ + XClientMessageEvent ev; + Display *display; + + ev.type = ClientMessage; + ev.window = window; + ev.message_type = icon->system_tray_opcode_atom; + ev.format = 32; + ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window); + ev.data.l[1] = message; + ev.data.l[2] = data1; + ev.data.l[3] = data2; + ev.data.l[4] = data3; + + display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); + + gdk_error_trap_push (); + XSendEvent (display, + icon->manager_window, False, NoEventMask, (XEvent *)&ev); + XSync (display, False); + gdk_error_trap_pop (); +} + +static void +egg_tray_icon_send_dock_request (EggTrayIcon *icon) +{ + egg_tray_icon_send_manager_message (icon, + SYSTEM_TRAY_REQUEST_DOCK, + icon->manager_window, + gtk_plug_get_id (GTK_PLUG (icon)), + 0, 0); +} + +static void +egg_tray_icon_update_manager_window (EggTrayIcon *icon) +{ + Display *xdisplay; + + xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); + + if (icon->manager_window != None) + { + GdkWindow *gdkwin; + + gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), + icon->manager_window); + + gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); + } + + XGrabServer (xdisplay); + + icon->manager_window = XGetSelectionOwner (xdisplay, + icon->selection_atom); + + if (icon->manager_window != None) + XSelectInput (xdisplay, + icon->manager_window, StructureNotifyMask|PropertyChangeMask); + + XUngrabServer (xdisplay); + XFlush (xdisplay); + + if (icon->manager_window != None) + { + GdkWindow *gdkwin; + + gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), + icon->manager_window); + + gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); + + /* Send a request that we'd like to dock */ + egg_tray_icon_send_dock_request (icon); + + egg_tray_icon_get_orientation_property (icon); + } +} + +static void +egg_tray_icon_realize (GtkWidget *widget) +{ + EggTrayIcon *icon = EGG_TRAY_ICON (widget); + GdkScreen *screen; + GdkDisplay *display; + Display *xdisplay; + char buffer[256]; + GdkWindow *root_window; + + if (GTK_WIDGET_CLASS (parent_class)->realize) + GTK_WIDGET_CLASS (parent_class)->realize (widget); + + screen = gtk_widget_get_screen (widget); + display = gdk_screen_get_display (screen); + xdisplay = gdk_x11_display_get_xdisplay (display); + + /* Now see if there's a manager window around */ + g_snprintf (buffer, sizeof (buffer), + "_NET_SYSTEM_TRAY_S%d", + gdk_screen_get_number (screen)); + + icon->selection_atom = XInternAtom (xdisplay, buffer, False); + + icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False); + + icon->system_tray_opcode_atom = XInternAtom (xdisplay, + "_NET_SYSTEM_TRAY_OPCODE", + False); + + icon->orientation_atom = XInternAtom (xdisplay, + "_NET_SYSTEM_TRAY_ORIENTATION", + False); + + egg_tray_icon_update_manager_window (icon); + + root_window = gdk_screen_get_root_window (screen); + + /* Add a root window filter so that we get changes on MANAGER */ + gdk_window_add_filter (root_window, + egg_tray_icon_manager_filter, icon); +} + +EggTrayIcon * +egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name) +{ + g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); + + return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL); +} + +EggTrayIcon* +egg_tray_icon_new (const gchar *name) +{ + return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL); +} + +guint +egg_tray_icon_send_message (EggTrayIcon *icon, + gint timeout, + const gchar *message, + gint len) +{ + guint stamp; + + g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0); + g_return_val_if_fail (timeout >= 0, 0); + g_return_val_if_fail (message != NULL, 0); + + if (icon->manager_window == None) + return 0; + + if (len < 0) + len = strlen (message); + + stamp = icon->stamp++; + + /* Get ready to send the message */ + egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE, + (Window)gtk_plug_get_id (GTK_PLUG (icon)), + timeout, len, stamp); + + /* Now to send the actual message */ + gdk_error_trap_push (); + while (len > 0) + { + XClientMessageEvent ev; + Display *xdisplay; + + xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); + + ev.type = ClientMessage; + ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon)); + ev.format = 8; + ev.message_type = XInternAtom (xdisplay, + "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); + if (len > 20) + { + memcpy (&ev.data, message, 20); + len -= 20; + message += 20; + } + else + { + memcpy (&ev.data, message, len); + len = 0; + } + + XSendEvent (xdisplay, + icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev); + XSync (xdisplay, False); + } + gdk_error_trap_pop (); + + return stamp; +} + +void +egg_tray_icon_cancel_message (EggTrayIcon *icon, + guint id) +{ + g_return_if_fail (EGG_IS_TRAY_ICON (icon)); + g_return_if_fail (id > 0); + + egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, + (Window)gtk_plug_get_id (GTK_PLUG (icon)), + id, 0, 0); +} + +GtkOrientation +egg_tray_icon_get_orientation (EggTrayIcon *icon) +{ + g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL); + + return icon->orientation; +} diff --git a/src/eggtrayicon.h b/src/eggtrayicon.h new file mode 100644 index 00000000..007f4c18 --- /dev/null +++ b/src/eggtrayicon.h @@ -0,0 +1,77 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* eggtrayicon.h + * Copyright (C) 2002 Anders Carlsson + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef __EGG_TRAY_ICON_H__ +#define __EGG_TRAY_ICON_H__ + +#include +#include + +G_BEGIN_DECLS + +#define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ()) +#define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon)) +#define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) +#define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON)) +#define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON)) +#define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) + +typedef struct _EggTrayIcon EggTrayIcon; +typedef struct _EggTrayIconClass EggTrayIconClass; + +struct _EggTrayIcon +{ + GtkPlug parent_instance; + + guint stamp; + + Atom selection_atom; + Atom manager_atom; + Atom system_tray_opcode_atom; + Atom orientation_atom; + Window manager_window; + + GtkOrientation orientation; +}; + +struct _EggTrayIconClass +{ + GtkPlugClass parent_class; +}; + +GType egg_tray_icon_get_type (void); + +EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen, + const gchar *name); + +EggTrayIcon *egg_tray_icon_new (const gchar *name); + +guint egg_tray_icon_send_message (EggTrayIcon *icon, + gint timeout, + const char *message, + gint len); +void egg_tray_icon_cancel_message (EggTrayIcon *icon, + guint id); + +GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon); + +G_END_DECLS + +#endif /* __EGG_TRAY_ICON_H__ */ diff --git a/src/entry.c b/src/entry.c index 4d242160..46672f82 100644 --- a/src/entry.c +++ b/src/entry.c @@ -54,10 +54,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); diff --git a/src/fileselection.c b/src/fileselection.c index fdd40fdd..4d50fb76 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -60,10 +60,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); diff --git a/src/main.c b/src/main.c index 09b1519c..4d8c6079 100644 --- a/src/main.c +++ b/src/main.c @@ -42,6 +42,7 @@ typedef enum { MODE_TEXTINFO, MODE_WARNING, MODE_INFO, + MODE_NOTIFICATION, MODE_ABOUT, MODE_LAST } ZenityDialogMode; @@ -64,6 +65,7 @@ typedef struct { ZenityProgressData *progress_data; ZenityTextData *text_data; ZenityTreeData *tree_data; + ZenityNotificationData *notification_data; } ZenityParsingOptions; enum { @@ -79,6 +81,7 @@ enum { OPTION_TEXTINFO, OPTION_TEXTEDIT, OPTION_WARNING, + OPTION_NOTIFICATION, OPTION_TITLE, OPTION_ICON, OPTION_WIDTH, @@ -110,6 +113,8 @@ enum { OPTION_PRINTCOLUMN, OPTION_QUESTIONTEXT, OPTION_WARNINGTEXT, + OPTION_NOTIFICATIONICON, + OPTION_NOTIFICATIONTEXT, OPTION_ABOUT, OPTION_VERSION, OPTION_LAST, @@ -185,6 +190,15 @@ struct poptOption options[] = { N_("Display list dialog"), NULL }, + { + "notification", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_NOTIFICATION, + N_("Display notification"), + NULL + }, { "progress", '\0', @@ -548,6 +562,28 @@ struct poptOption list_options[] = { POPT_TABLEEND }; +struct poptOption notification_options[] = { + { + NULL, + '\0', + POPT_ARG_CALLBACK | POPT_CBFLAG_POST, + zenity_parse_options_callback, + 0, + NULL, + NULL + }, + { + "text", + '\0', + POPT_ARG_STRING, + NULL, + OPTION_NOTIFICATIONTEXT, + N_("Set the notification text"), + NULL + }, + POPT_TABLEEND +}; + struct poptOption progress_options[] = { { NULL, @@ -896,6 +932,15 @@ struct poptOption application_options[] = { N_("List options"), NULL }, + { + NULL, + '\0', + POPT_ARG_INCLUDE_TABLE, + notification_options, + 0, + N_("Notication options"), + NULL + }, { NULL, '\0', @@ -979,6 +1024,7 @@ zenity_init_parsing_options (void) { results->progress_data = g_new0 (ZenityProgressData, 1); results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); + results->notification_data = g_new0 (ZenityNotificationData, 1); /* Give some sensible defaults */ results->data->width = -1; @@ -1056,6 +1102,10 @@ zenity_free_parsing_options (void) { if (results->tree_data->print_column) g_free (results->tree_data->print_column); break; + case MODE_NOTIFICATION: + if (results->notification_data->notification_text) + g_free (results->notification_data->notification_text); + break; default: break; } @@ -1125,6 +1175,9 @@ main (gint argc, gchar **argv) { results->tree_data->data = poptGetArgs (ctx); zenity_tree (results->data, results->tree_data); break; + case MODE_NOTIFICATION: + zenity_notification (results->data, results->notification_data); + break; case MODE_PROGRESS: zenity_progress (results->data, results->progress_data); break; @@ -1229,6 +1282,12 @@ zenity_parse_options_callback (poptContext ctx, results->mode = MODE_LIST; break; + case OPTION_NOTIFICATION: + if (results->mode != MODE_LAST) + zenity_error (NULL, ERROR_DIALOG); + + results->mode = MODE_NOTIFICATION; + break; case OPTION_PROGRESS: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); @@ -1286,13 +1345,13 @@ zenity_parse_options_callback (poptContext ctx, case OPTION_PROGRESSTEXT: case OPTION_LISTTEXT: case OPTION_WARNINGTEXT: - + case OPTION_NOTIFICATIONTEXT: /* FIXME: This is an ugly hack because of the way the poptOptions are * ordered above. When you try and use an --option more than once * parse_options_callback gets called for each option. Suckage */ - if (parse_option_text > 7) + if (parse_option_text > 8) zenity_error ("--text", ERROR_DUPLICATE); switch (results->mode) { @@ -1319,6 +1378,10 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), -1, NULL, NULL, NULL); break; + case MODE_NOTIFICATION: + results->notification_data->notification_text = g_locale_to_utf8 (g_strcompress (arg), + -1, NULL, NULL, NULL); + break; default: zenity_error ("--text", ERROR_SUPPORT); } diff --git a/src/msg.c b/src/msg.c index 27284472..ffb2e531 100644 --- a/src/msg.c +++ b/src/msg.c @@ -83,29 +83,25 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else { - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING); - break; - - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION); - break; + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + break; - case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR); - break; + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); + break; - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO); - break; + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_INFO); + break; - default: - break; - } + default: + break; } if (data->width > -1 || data->height > -1) diff --git a/src/notification.c b/src/notification.c new file mode 100644 index 00000000..42f72c5b --- /dev/null +++ b/src/notification.c @@ -0,0 +1,129 @@ +/* + * notification.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + */ + +#include +#include +#include "zenity.h" +#include "eggtrayicon.h" +#include "util.h" + +EggTrayIcon *tray_icon; + +static gboolean +zenity_notification_icon_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer data) +{ + ZenityData *zen_data; + + zen_data = data; + + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); +} + +static gboolean +zenity_notification_icon_expose_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data) +{ + if (GTK_WIDGET_HAS_FOCUS (widget)) { + gint focus_width, focus_pad; + gint x, y, width, height; + + gtk_widget_style_get (widget, + "focus-line-width", &focus_width, + "focus-padding", &focus_pad, + NULL); + x = widget->allocation.x + focus_pad; + y = widget->allocation.y + focus_pad; + width = widget->allocation.width - 2 * focus_pad; + height = widget->allocation.height - 2 * focus_pad; + + gtk_paint_focus (widget->style, widget->window, + GTK_WIDGET_STATE (widget), + &event->area, widget, "button", + x, y, width, height); + } + + return FALSE; +} + +static gboolean +zenity_notification_icon_destroy_callback (GtkWidget *widget, gpointer data) +{ + ZenityData *zen_data; + + zen_data = data; + gtk_widget_destroy (GTK_WIDGET (tray_icon)); + + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + gtk_main_quit (); +} + +void +zenity_notification (ZenityData *data, ZenityNotificationData *notification_data) +{ + GtkWidget *icon_image; + GtkWidget *icon_event_box; + GtkTooltips *tooltips; + GdkPixbuf *pixbuf = NULL; + + tray_icon = egg_tray_icon_new (_("Zenity notification")); + tooltips = gtk_tooltips_new (); + + if (data->window_icon != NULL) + pixbuf = zenity_util_pixbuf_new_from_file (GTK_WIDGET (tray_icon), data->window_icon); + else + pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity-notification.png"), NULL); + + icon_event_box = gtk_event_box_new (); + + if (pixbuf) { + icon_image = gtk_image_new_from_pixbuf (pixbuf); + gdk_pixbuf_unref (pixbuf); + } else { + g_warning ("Could not load notification icon : %s", ZENITY_IMAGE_FULLPATH ("zenity-notification.png")); + return; + } + + gtk_container_add (GTK_CONTAINER (icon_event_box), icon_image); + + if (notification_data->notification_text) + gtk_tooltips_set_tip (tooltips, icon_event_box, notification_data->notification_text, notification_data->notification_text); + else + gtk_tooltips_set_tip (tooltips, icon_event_box, _("Zenity notification"), _("Zenity notification")); + + gtk_widget_add_events (GTK_WIDGET (tray_icon), GDK_BUTTON_PRESS_MASK | GDK_FOCUS_CHANGE_MASK); + gtk_container_add (GTK_CONTAINER (tray_icon), icon_event_box); + + g_signal_connect (tray_icon, "button_press_event", + G_CALLBACK (zenity_notification_icon_press_callback), data); + + g_signal_connect (tray_icon, "destroy", + G_CALLBACK (zenity_notification_icon_destroy_callback), data); + + g_signal_connect (tray_icon, "expose_event", + G_CALLBACK (zenity_notification_icon_expose_callback), data); + + gtk_widget_show_all (GTK_WIDGET (tray_icon)); + + /* Does nothing at the moment */ + gtk_main (); +} diff --git a/src/progress.c b/src/progress.c index 373c5b82..ed727cae 100644 --- a/src/progress.c +++ b/src/progress.c @@ -191,10 +191,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); diff --git a/src/text.c b/src/text.c index b70bed0a..acd17394 100644 --- a/src/text.c +++ b/src/text.c @@ -128,10 +128,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); diff --git a/src/tree.c b/src/tree.c index fed58e2a..436f632f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -320,10 +320,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (tree_data->dialog_text) gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text); - if (data->window_icon) - zenity_util_set_window_icon (dialog, data->window_icon); - else - zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); diff --git a/src/util.c b/src/util.c index 3364e306..b839d424 100644 --- a/src/util.c +++ b/src/util.c @@ -143,56 +143,53 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) return TRUE; } -static GList * -zenity_util_list_from_char_array (const char **s) +GdkPixbuf * +zenity_util_pixbuf_new_from_file (GtkWidget *widget, gchar *filename) { - GList *list = NULL; - gint i; - - for (i = 0; s[i]; i++) { - GdkPixbuf *pixbuf; - - pixbuf = gdk_pixbuf_new_from_file (s[i], NULL); - if (pixbuf) - list = g_list_prepend (list, pixbuf); - } - - return list; -} - -static void -zenity_util_free_list (GList *list) -{ - g_list_foreach (list, (GFunc) g_object_unref, NULL); - g_list_free (list); + if (!strcmp (g_strdown (filename), "warning")) + return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON, NULL); + if (!strcmp (g_strdown (filename), "info")) + return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON, NULL); + if (!strcmp (g_strdown (filename), "question")) + return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_BUTTON, NULL); + if (!strcmp (g_strdown (filename), "error")) + return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_BUTTON, NULL); + else + return gdk_pixbuf_new_from_file (filename, NULL); } void -zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename) +zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file) { - const gchar *filenames[2] = { NULL}; - GList *list; - - g_return_if_fail (widget != NULL); - g_return_if_fail (GTK_IS_WINDOW (widget)); + GdkPixbuf *pixbuf; - if (filename == NULL) - return; + if (filename != NULL) + pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename); + else + pixbuf = gdk_pixbuf_new_from_file (default_file, NULL); - filenames[0] = filename; - list = zenity_util_list_from_char_array (filenames); - gtk_window_set_icon_list (GTK_WINDOW (widget), list); - zenity_util_free_list (list); + if (pixbuf != NULL) { + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); + } } void -zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id) +zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *filename, const gchar *default_stock_id) { GdkPixbuf *pixbuf; - - pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL); - gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); - g_object_unref (pixbuf); + + if (filename != NULL) { + pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename); + } + else { + pixbuf = gtk_widget_render_icon (widget, default_stock_id, GTK_ICON_SIZE_BUTTON, NULL); + } + + if (pixbuf != NULL) { + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); + } } void diff --git a/src/util.h b/src/util.h index 69ec9122..4e3c2142 100644 --- a/src/util.h +++ b/src/util.h @@ -15,10 +15,14 @@ GladeXML* zenity_util_load_glade_file (const gchar *widge gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); -void zenity_util_set_window_icon (GtkWidget *widget, - const gchar *filename); +void zenity_util_set_window_icon (GtkWidget *widget, + const gchar *filename, + const gchar *default_file); void zenity_util_set_window_icon_from_stock (GtkWidget *widget, - const gchar *stock_id); + const gchar *filename, + const gchar *default_stock_id); +GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, + gchar *filename); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_show_dialog (GtkWidget *widget); diff --git a/src/zenity.h b/src/zenity.h index d9aff43f..3d4eeeac 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -98,6 +98,10 @@ typedef struct { const gchar **data; } ZenityTreeData; +typedef struct { + gchar *notification_text; +} ZenityNotificationData; + void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data); void zenity_msg (ZenityData *data, @@ -112,6 +116,8 @@ void zenity_text (ZenityData *data, ZenityTextData *text_data); void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); +void zenity_notification (ZenityData *data, + ZenityNotificationData *notification_data); void zenity_about (ZenityData *data); G_END_DECLS -- cgit From 963241dd15b3046e97e526b1547fdd3543b18b14 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Thu, 16 Sep 2004 09:28:09 +0000 Subject: add code to listen for commands on stdin when in listen mode. 2004-09-16 James Henstridge * src/notification.c: add code to listen for commands on stdin when in listen mode. * src/main.c: parse the --listen argument for --notification mode. * src/zenity.h (ZenityNotificationData): add a field for the "listen" argument. --- src/main.c | 17 ++++++++ src/notification.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++--- src/zenity.h | 1 + 3 files changed, 134 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 4d8c6079..b4162cd0 100644 --- a/src/main.c +++ b/src/main.c @@ -115,6 +115,7 @@ enum { OPTION_WARNINGTEXT, OPTION_NOTIFICATIONICON, OPTION_NOTIFICATIONTEXT, + OPTION_NOTIFICATIONLISTEN, OPTION_ABOUT, OPTION_VERSION, OPTION_LAST, @@ -581,6 +582,15 @@ struct poptOption notification_options[] = { N_("Set the notification text"), NULL }, + { + "listen", + '\0', + POPT_ARG_NONE, + NULL, + OPTION_NOTIFICATIONLISTEN, + N_("Listen for commands on stdin"), + NULL + }, POPT_TABLEEND }; @@ -1051,6 +1061,7 @@ zenity_init_parsing_options (void) { results->tree_data->radiobox = FALSE; results->tree_data->editable = FALSE; results->tree_data->print_column = NULL; + results->notification_data->listen = FALSE; } static void @@ -1572,6 +1583,12 @@ zenity_parse_options_callback (poptContext ctx, results->tree_data->print_column = g_strdup (arg); break; + case OPTION_NOTIFICATIONLISTEN: + if (results->mode != MODE_NOTIFICATION) + zenity_error ("--listen", ERROR_SUPPORT); + + results->notification_data->listen = TRUE; + break; case OPTION_ABOUT: if (results->mode != MODE_LAST) zenity_error (NULL, ERROR_DIALOG); diff --git a/src/notification.c b/src/notification.c index 42f72c5b..f3b3b1f9 100644 --- a/src/notification.c +++ b/src/notification.c @@ -27,7 +27,11 @@ #include "eggtrayicon.h" #include "util.h" -EggTrayIcon *tray_icon; +static EggTrayIcon *tray_icon; +static GtkWidget *icon_image; +static GtkWidget *icon_event_box; +static GtkTooltips *tooltips; + static gboolean zenity_notification_icon_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer data) @@ -77,12 +81,112 @@ zenity_notification_icon_destroy_callback (GtkWidget *widget, gpointer data) gtk_main_quit (); } +static gboolean +zenity_notification_handle_stdin (GIOChannel *channel, + GIOCondition condition, + gpointer user_data) +{ + ZenityData *zen_data; + + zen_data = (ZenityData *)user_data; + + if ((condition & G_IO_IN) != 0) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + while (channel->is_readable != TRUE) + ; + do { + gint status; + gchar *command, *value, *colon; + + do { + status = g_io_channel_read_line_string (channel, string, NULL, &error); + while (gdk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_notification_handle_stdin () : %s", + error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + zenity_util_strip_newline (string->str); + colon = strchr(string->str, ':'); + if (colon == NULL) { + g_printerr (_("could not parse command from stdin\n")); + continue; + } + /* split off the command and value */ + command = g_strndup (string->str, colon - string->str); + command = g_strstrip (command); + g_strdown (command); + + value = colon + 1; + while (*value && g_ascii_isspace (*value)) value++; + + if (!strcmp (command, "icon")) { + GdkPixbuf *pixbuf; + + pixbuf = zenity_util_pixbuf_new_from_file (GTK_WIDGET (tray_icon), + value); + if (pixbuf != NULL) { + gtk_image_set_from_pixbuf (GTK_IMAGE (icon_image), pixbuf); + gdk_pixbuf_unref (pixbuf); + } else { + g_warning ("Could not load notification icon : %s", value); + } + } else if (!strcmp (command, "message")) { + g_warning ("haven't implemented message support yet"); + } else if (!strcmp (command, "tooltip")) { + gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); + } else if (!strcmp (command, "visible")) { + if (!strcasecmp (value, "false")) { + gtk_widget_hide (GTK_WIDGET (tray_icon)); + } else { + gtk_widget_show (GTK_WIDGET (tray_icon)); + } + } else { + g_warning ("Unknown command '%s'", command); + } + g_free (command); + + } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + g_string_free (string, TRUE); + } + + if ((condition & G_IO_HUP) != 0) { + g_io_channel_shutdown (channel, TRUE, NULL); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); + return FALSE; + } + + return TRUE; +} + +static void +zenity_notification_listen_on_stdin (ZenityData *data) +{ + GIOChannel *channel; + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch (channel, G_IO_IN | G_IO_HUP, + zenity_notification_handle_stdin, data); +} + void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data) { - GtkWidget *icon_image; - GtkWidget *icon_event_box; - GtkTooltips *tooltips; GdkPixbuf *pixbuf = NULL; tray_icon = egg_tray_icon_new (_("Zenity notification")); @@ -113,15 +217,20 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data gtk_widget_add_events (GTK_WIDGET (tray_icon), GDK_BUTTON_PRESS_MASK | GDK_FOCUS_CHANGE_MASK); gtk_container_add (GTK_CONTAINER (tray_icon), icon_event_box); - g_signal_connect (tray_icon, "button_press_event", - G_CALLBACK (zenity_notification_icon_press_callback), data); - g_signal_connect (tray_icon, "destroy", G_CALLBACK (zenity_notification_icon_destroy_callback), data); g_signal_connect (tray_icon, "expose_event", G_CALLBACK (zenity_notification_icon_expose_callback), data); + if (notification_data->listen) { + zenity_notification_listen_on_stdin (data); + } else { + /* if we aren't listening for changes, then close on button_press */ + g_signal_connect (tray_icon, "button_press_event", + G_CALLBACK (zenity_notification_icon_press_callback), data); + } + gtk_widget_show_all (GTK_WIDGET (tray_icon)); /* Does nothing at the moment */ diff --git a/src/zenity.h b/src/zenity.h index 3d4eeeac..1365d170 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -100,6 +100,7 @@ typedef struct { typedef struct { gchar *notification_text; + gboolean listen; } ZenityNotificationData; void zenity_calendar (ZenityData *data, -- cgit From ca975e839996dbe1a85825b7f3472b170505540c Mon Sep 17 00:00:00 2001 From: Kjartan Maraas Date: Fri, 17 Sep 2004 08:57:21 +0000 Subject: Add missing header. Same ANSIfication. Closes bug #152851. 2004-09-17 Kjartan Maraas * src/progress.c: Add missing header. * src/tree.c: Same * src/util.c: (transient_get_xterm), (transient_get_xterm_toplevel): ANSIfication. Closes bug #152851. --- src/progress.c | 1 + src/tree.c | 1 + src/util.c | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index ed727cae..734dd732 100644 --- a/src/progress.c +++ b/src/progress.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include "zenity.h" diff --git a/src/tree.c b/src/tree.c index 436f632f..49c1d782 100644 --- a/src/tree.c +++ b/src/tree.c @@ -25,6 +25,7 @@ #include #include +#include #include "zenity.h" #include "util.h" diff --git a/src/util.c b/src/util.c index b839d424..a09841e8 100644 --- a/src/util.c +++ b/src/util.c @@ -266,7 +266,7 @@ zenity_util_return_exit_code ( ZenityExitCode value ) #ifdef GDK_WINDOWING_X11 static Window -transient_get_xterm () +transient_get_xterm (void) { const char *wid_str = g_getenv ("WINDOWID"); if (wid_str) { @@ -303,7 +303,7 @@ transient_is_toplevel (Window wid) */ static Window -transient_get_xterm_toplevel () +transient_get_xterm_toplevel (void) { Window xterm = transient_get_xterm (); Display *dpy = GDK_DISPLAY (); -- cgit From 17cd55e682d5b78738f03255b2638bb9da937962 Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Thu, 30 Sep 2004 11:25:37 +0000 Subject: function to set a GtkImage to a scaled pixbuf. 2004-09-30 James Henstridge * src/notification.c (set_scaled_pixbuf): function to set a GtkImage to a scaled pixbuf. (zenity_notification_handle_stdin): set the image to a GTK_ICON_SIZE_BUTTON sized image. (zenity_notification): same here. --- src/notification.c | 40 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index f3b3b1f9..a67b7308 100644 --- a/src/notification.c +++ b/src/notification.c @@ -33,6 +33,39 @@ static GtkWidget *icon_event_box; static GtkTooltips *tooltips; +static void +set_scaled_pixbuf (GtkImage *image, GdkPixbuf *pixbuf, GtkIconSize icon_size) +{ + GdkScreen *screen; + GtkSettings *settings; + int width, height, desired_width, desired_height; + GdkPixbuf *new_pixbuf; + + screen = gtk_widget_get_screen (GTK_WIDGET (image)); + settings = gtk_settings_get_for_screen (screen); + if (!gtk_icon_size_lookup_for_settings (settings, icon_size, + &desired_width, &desired_height)) + return; + + width = gdk_pixbuf_get_width (pixbuf); + height = gdk_pixbuf_get_height (pixbuf); + if (height > desired_height || width > desired_width) { + if (width * desired_height / height > desired_width) + desired_height = height * desired_width / width; + else + desired_width = width * desired_height / height; + + new_pixbuf = gdk_pixbuf_scale_simple (pixbuf, + desired_width, + desired_height, + GDK_INTERP_BILINEAR); + gtk_image_set_from_pixbuf (image, new_pixbuf); + g_object_unref (new_pixbuf); + } else { + gtk_image_set_from_pixbuf (image, pixbuf); + } +} + static gboolean zenity_notification_icon_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer data) { @@ -138,7 +171,8 @@ zenity_notification_handle_stdin (GIOChannel *channel, pixbuf = zenity_util_pixbuf_new_from_file (GTK_WIDGET (tray_icon), value); if (pixbuf != NULL) { - gtk_image_set_from_pixbuf (GTK_IMAGE (icon_image), pixbuf); + set_scaled_pixbuf (GTK_IMAGE (icon_image), pixbuf, + GTK_ICON_SIZE_BUTTON); gdk_pixbuf_unref (pixbuf); } else { g_warning ("Could not load notification icon : %s", value); @@ -198,9 +232,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity-notification.png"), NULL); icon_event_box = gtk_event_box_new (); + icon_image = gtk_image_new (); if (pixbuf) { - icon_image = gtk_image_new_from_pixbuf (pixbuf); + set_scaled_pixbuf (GTK_IMAGE (icon_image), pixbuf, + GTK_ICON_SIZE_BUTTON); gdk_pixbuf_unref (pixbuf); } else { g_warning ("Could not load notification icon : %s", ZENITY_IMAGE_FULLPATH ("zenity-notification.png")); -- cgit From 45943a3b437050822cde1daa9080838e34f3275b Mon Sep 17 00:00:00 2001 From: James Henstridge Date: Tue, 5 Oct 2004 03:44:52 +0000 Subject: g_strdown() modifies the filename, so use strcasecmp() for the comparison 2004-10-05 James Henstridge * src/util.c (zenity_util_pixbuf_new_from_file): g_strdown() modifies the filename, so use strcasecmp() for the comparison instead. Since we are comparing against fixed ASCII strings, this should have no UTF-8 issues. --- src/util.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index a09841e8..6e9de2a7 100644 --- a/src/util.c +++ b/src/util.c @@ -146,13 +146,13 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, gchar *filename) { - if (!strcmp (g_strdown (filename), "warning")) + if (!strcasecmp (filename, "warning")) return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcmp (g_strdown (filename), "info")) + if (!strcasecmp (filename, "info")) return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcmp (g_strdown (filename), "question")) + if (!strcasecmp (filename, "question")) return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcmp (g_strdown (filename), "error")) + if (!strcasecmp (filename, "error")) return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_BUTTON, NULL); else return gdk_pixbuf_new_from_file (filename, NULL); -- cgit From 444ede57defebb326749a9ad173081866b0a1e28 Mon Sep 17 00:00:00 2001 From: "Francisco Javier F. Serrador" Date: Sat, 30 Oct 2004 14:13:02 +0000 Subject: Updated Spanish translation. Fixed typo 2004-10-30 Francisco Javier F. Serrador * po/es.po: Updated Spanish translation. * src/main.c: Fixed typo --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index b4162cd0..7d6ea9b7 100644 --- a/src/main.c +++ b/src/main.c @@ -948,7 +948,7 @@ struct poptOption application_options[] = { POPT_ARG_INCLUDE_TABLE, notification_options, 0, - N_("Notication options"), + N_("Notification options"), NULL }, { -- cgit From 04476d04fed7f5cbca232030121acca61d549116 Mon Sep 17 00:00:00 2001 From: Ross Burton Date: Tue, 23 Nov 2004 10:08:50 +0000 Subject: Check the xterm window ID is valid before using it --- src/util.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 6e9de2a7..ff7d18b3 100644 --- a/src/util.c +++ b/src/util.c @@ -272,8 +272,16 @@ transient_get_xterm (void) if (wid_str) { char *wid_str_end; Window wid = strtoul (wid_str, &wid_str_end, 10); - if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) + if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) { + XWindowAttributes attrs; + gdk_error_trap_push (); + XGetWindowAttributes (GDK_DISPLAY(), wid, &attrs); + gdk_flush(); + if (gdk_error_trap_pop () != 0) { + return None; + } return wid; + } } return None; } -- cgit From 530a4c04082242ea4740998ed4f50270c94e823a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 00:17:16 +0000 Subject: Patch from Lucas Rocha to use the GOption API for the 2004-12-07 Glynn Foster Patch from Lucas Rocha to use the GOption API for the zenity parsing options, with some spacing fixes from Glynn. * configure.in: zenity now requires glib-2.0 >= 2.5.3 to build because now it uses GOption. popt requirement removed. * src/Makefile.am: update for new files * src/main.c: use GOption API * src/option.c, src/option.h: New files to implement the new functionality. * src/zenity.h: Fix spacing. 2004-12-07 Glynn Foster * POTFILES.in: Add new files. --- src/Makefile.am | 2 + src/main.c | 1534 +------------------------------------------------------ src/zenity.h | 28 +- 3 files changed, 31 insertions(+), 1533 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 310cb560..6b43b3e1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -4,6 +4,8 @@ bin_SCRIPTS = gdialog zenity_SOURCES = \ main.c \ + option.c \ + option.h \ zenity.h \ calendar.c \ msg.c \ diff --git a/src/main.c b/src/main.c index 7d6ea9b7..10e75b8a 100644 --- a/src/main.c +++ b/src/main.c @@ -24,1108 +24,20 @@ #include #include "zenity.h" +#include "option.h" + #include -#include +#include +#include #include #ifdef HAVE_LOCALE_H #include #endif -typedef enum { - MODE_CALENDAR, - MODE_ENTRY, - MODE_ERROR, - MODE_FILE, - MODE_LIST, - MODE_PROGRESS, - MODE_QUESTION, - MODE_TEXTINFO, - MODE_WARNING, - MODE_INFO, - MODE_NOTIFICATION, - MODE_ABOUT, - MODE_LAST -} ZenityDialogMode; - -typedef enum { - ERROR_DUPLICATE, - ERROR_SUPPORT, - ERROR_DIALOG, - ERROR_LAST -} ZenityError; - -typedef struct { - ZenityDialogMode mode; - ZenityData *data; - - ZenityCalendarData *calendar_data; - ZenityMsgData *msg_data; - ZenityFileData *file_data; - ZenityEntryData *entry_data; - ZenityProgressData *progress_data; - ZenityTextData *text_data; - ZenityTreeData *tree_data; - ZenityNotificationData *notification_data; -} ZenityParsingOptions; - -enum { - OPTION_CALENDAR = 1, - OPTION_DATEFORMAT, - OPTION_ENTRY, - OPTION_ERROR, - OPTION_INFO, - OPTION_FILE, - OPTION_LIST, - OPTION_PROGRESS, - OPTION_QUESTION, - OPTION_TEXTINFO, - OPTION_TEXTEDIT, - OPTION_WARNING, - OPTION_NOTIFICATION, - OPTION_TITLE, - OPTION_ICON, - OPTION_WIDTH, - OPTION_HEIGHT, - OPTION_CALENDARTEXT, - OPTION_DAY, - OPTION_MONTH, - OPTION_YEAR, - OPTION_ENTRYTEXT, - OPTION_INPUTTEXT, - OPTION_HIDETEXT, - OPTION_ERRORTEXT, - OPTION_INFOTEXT, - OPTION_FILENAME, - OPTION_MULTIFILE, - OPTION_DIR, - OPTION_SAVE, - OPTION_TEXTFILENAME, - OPTION_LISTTEXT, - OPTION_COLUMN, - OPTION_SEPERATOR, - OPTION_LISTEDIT, - OPTION_CHECKLIST, - OPTION_RADIOLIST, - OPTION_PROGRESSTEXT, - OPTION_PERCENTAGE, - OPTION_PULSATE, - OPTION_AUTOCLOSE, - OPTION_PRINTCOLUMN, - OPTION_QUESTIONTEXT, - OPTION_WARNINGTEXT, - OPTION_NOTIFICATIONICON, - OPTION_NOTIFICATIONTEXT, - OPTION_NOTIFICATIONLISTEN, - OPTION_ABOUT, - OPTION_VERSION, - OPTION_LAST, -}; - -static void zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data); - -struct poptOption options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "calendar", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CALENDAR, - N_("Display calendar dialog"), - NULL - }, - { - "entry", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ENTRY, - N_("Display text entry dialog"), - NULL - }, - { - "error", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ERROR, - N_("Display error dialog"), - NULL - }, - { - "file-selection", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_FILE, - N_("Display file selection dialog"), - NULL - }, - { - "info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_INFO, - N_("Display info dialog"), - NULL - }, - { - "list", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LIST, - N_("Display list dialog"), - NULL - }, - { - "notification", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_NOTIFICATION, - N_("Display notification"), - NULL - }, - { - "progress", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PROGRESS, - N_("Display progress indication dialog"), - NULL - }, - { - "question", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_QUESTION, - N_("Display question dialog"), - NULL - }, - { - "text-info", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTINFO, - N_("Display text information dialog"), - NULL - }, - { - "warning", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_WARNING, - N_("Display warning dialog"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption general_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "title", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TITLE, - N_("Set the dialog title"), - N_("TITLE") - }, - { - "window-icon", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ICON, - N_("Set the window icon"), - N_("ICONPATH") - }, - { - "width", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_WIDTH, - N_("Set the width"), - N_("WIDTH") - }, - { - "height", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_HEIGHT, - N_("Set the height"), - N_("HEIGHT") - }, - POPT_TABLEEND -}; - -struct poptOption calendar_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_CALENDARTEXT, - N_("Set the dialog text"), - NULL - }, - { - "day", - '\0', - POPT_ARG_INT, - NULL, - OPTION_DAY, - N_("Set the calendar day"), - NULL - }, - { - "month", - '\0', - POPT_ARG_INT, - NULL, - OPTION_MONTH, - N_("Set the calendar month"), - NULL - }, - { - "year", - '\0', - POPT_ARG_INT, - NULL, - OPTION_YEAR, - N_("Set the calendar year"), - NULL - }, - { "date-format", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_DATEFORMAT, - N_("Set the format for the returned date"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption entry_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ENTRYTEXT, - N_("Set the dialog text"), - NULL - }, - { - "entry-text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INPUTTEXT, - N_("Set the entry text"), - NULL - }, - { - "hide-text", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_HIDETEXT, - N_("Hide the entry text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption error_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_ERRORTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption info_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_INFOTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption file_selection_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_FILENAME, - N_("Set the filename"), - N_("FILENAME") - }, - { - "multiple", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_MULTIFILE, - N_("Allow multiple files to be selected"), - NULL - }, - { - "directory", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_DIR, - N_("Activate directory-only selection"), - NULL - }, - { - "save", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_SAVE, - N_("Activate save mode"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character."), - N_("SEPARATOR") - }, - POPT_TABLEEND -}; - -struct poptOption list_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_LISTTEXT, - N_("Set the dialog text"), - NULL - }, - { - "column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_COLUMN, - N_("Set the column header"), - NULL - }, - { - "checklist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_CHECKLIST, - N_("Use check boxes for first column"), - NULL - }, - { - "radiolist", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_RADIOLIST, - N_("Use radio buttons for first column"), - NULL - }, - { - "separator", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_SEPERATOR, - N_("Set output separator character"), - N_("SEPARATOR") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_LISTEDIT, - N_("Allow changes to text"), - NULL - }, - { - "print-column", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PRINTCOLUMN, - N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption notification_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_NOTIFICATIONTEXT, - N_("Set the notification text"), - NULL - }, - { - "listen", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_NOTIFICATIONLISTEN, - N_("Listen for commands on stdin"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption progress_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_PROGRESSTEXT, - N_("Set the dialog text"), - NULL - }, - { - "percentage", - '\0', - POPT_ARG_INT, - NULL, - OPTION_PERCENTAGE, - N_("Set initial percentage"), - NULL - }, - { - "pulsate", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_PULSATE, - N_("Pulsate progress bar"), - NULL - }, - { - "auto-close", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_AUTOCLOSE, - /* xgettext: no-c-format */ - N_("Dismiss the dialog when 100% has been reached"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption question_options[] = { - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_QUESTIONTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption text_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "filename", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_TEXTFILENAME, - N_("Open file"), - N_("FILENAME") - }, - { - "editable", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_TEXTEDIT, - N_("Allow changes to text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption warning_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "text", - '\0', - POPT_ARG_STRING, - NULL, - OPTION_WARNINGTEXT, - N_("Set the dialog text"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption gtk_options[] = { - { - "gdk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to set"), - N_("FLAGS") - }, - { - "gdk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gdk debugging flags to unset"), - N_("FLAGS") - }, - /* X11 only */ - { - "display", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("X display to use"), - N_("DISPLAY") - }, -#ifdef HAVE_GTK_MULTIHEAD - /* X11 & multi-head only */ - { - "screen", - '\0', - POPT_ARG_INT, - NULL, - 0, - N_("X screen to use"), - N_("SCREEN") - }, -#endif - /* X11 only */ - { - "sync", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make X calls synchronous"), - NULL - }, - { - "name", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program name as used by the window manager"), - N_("NAME") - }, - { - "class", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Program class as used by the window manager"), - N_("CLASS") - }, - /* X11 only */ - { - "gxid-host", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("HOST") - }, - /* X11 only */ - { - "gxid-port", - '\0', - POPT_ARG_STRING, - NULL, - 0, - NULL, - N_("PORT") - }, - { - "gtk-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to set"), - N_("FLAGS") - }, - { - "gtk-no-debug", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Gtk+ debugging flags to unset"), - N_("FLAGS") - }, - { - "g-fatal-warnings", - '\0', - POPT_ARG_NONE, - NULL, - 0, - N_("Make all warnings fatal"), - NULL - }, - { - "gtk-module", - '\0', - POPT_ARG_STRING, - NULL, - 0, - N_("Load an additional Gtk module"), - N_("MODULE") - }, - POPT_TABLEEND -}; - -struct poptOption miscellaneous_options[] = { - { - NULL, - '\0', - POPT_ARG_CALLBACK | POPT_CBFLAG_POST, - zenity_parse_options_callback, - 0, - NULL, - NULL - }, - { - "about", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_ABOUT, - N_("About zenity"), - NULL - }, - { - "version", - '\0', - POPT_ARG_NONE, - NULL, - OPTION_VERSION, - N_("Print version"), - NULL - }, - POPT_TABLEEND -}; - -struct poptOption application_options[] = { - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - options, - 0, - N_("Dialog options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - general_options, - 0, - N_("General options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - calendar_options, - 0, - N_("Calendar options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - entry_options, - 0, - N_("Text entry options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - error_options, - 0, - N_("Error options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - file_selection_options, - 0, - N_("File selection options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - info_options, - 0, - N_("Info options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - list_options, - 0, - N_("List options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - notification_options, - 0, - N_("Notification options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - progress_options, - 0, - N_("Progress options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - question_options, - 0, - N_("Question options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - text_options, - 0, - N_("Text options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - warning_options, - 0, - N_("Warning options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - gtk_options, - 0, - N_("GTK+ options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - miscellaneous_options, - 0, - N_("Miscellaneous options"), - NULL - }, - { - NULL, - '\0', - POPT_ARG_INCLUDE_TABLE, - poptHelpOptions, - 0, - N_("Help options"), - NULL - }, - POPT_TABLEEND -}; - -ZenityParsingOptions *results; - -static void -zenity_init_parsing_options (void) { - - results = g_new0 (ZenityParsingOptions, 1); - - /* Initialize the various dialog structures */ - results->mode = MODE_LAST; - results->data = g_new0 (ZenityData, 1); - results->calendar_data = g_new0 (ZenityCalendarData, 1); - results->msg_data = g_new0 (ZenityMsgData, 1); - results->file_data = g_new0 (ZenityFileData, 1); - results->entry_data = g_new0 (ZenityEntryData, 1); - results->progress_data = g_new0 (ZenityProgressData, 1); - results->text_data = g_new0 (ZenityTextData, 1); - results->tree_data = g_new0 (ZenityTreeData, 1); - results->notification_data = g_new0 (ZenityNotificationData, 1); - - /* Give some sensible defaults */ - results->data->width = -1; - results->data->height = -1; - results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), - -1, - NULL, NULL, NULL); - results->calendar_data->day = 0; - results->calendar_data->month = 0; - results->calendar_data->year = 0; - results->calendar_data->dialog_text = NULL; - results->file_data->multi = FALSE; - results->file_data->directory = FALSE; - results->file_data->save = FALSE; - results->file_data->separator = g_strdup ("|"); - results->text_data->editable = FALSE; - results->tree_data->separator = g_strdup ("|"); - results->progress_data->percentage = -1; - results->progress_data->pulsate = FALSE; - results->progress_data->autoclose = FALSE; - results->entry_data->visible = TRUE; - results->tree_data->dialog_text = NULL; - results->tree_data->checkbox = FALSE; - results->tree_data->radiobox = FALSE; - results->tree_data->editable = FALSE; - results->tree_data->print_column = NULL; - results->notification_data->listen = FALSE; -} - -static void -zenity_free_parsing_options (void) { - - /* General options */ - if (results->data->dialog_title) - g_free (results->data->dialog_title); - if (results->data->window_icon) - g_free (results->data->window_icon); - - /* Dialog options */ - switch (results->mode) { - case MODE_CALENDAR: - if (results->calendar_data->dialog_text) - g_free (results->calendar_data->dialog_text); - if (results->calendar_data->date_format) - g_free (results->calendar_data->date_format); - break; - case MODE_ENTRY: - if (results->entry_data->dialog_text) - g_free (results->entry_data->dialog_text); - if (results->entry_data->entry_text) - g_free (results->entry_data->entry_text); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - if (results->msg_data->dialog_text) - g_free (results->msg_data->dialog_text); - break; - case MODE_FILE: - if (results->file_data->uri) - g_free (results->file_data->uri); - g_free (results->file_data->separator); - break; - case MODE_TEXTINFO: - if (results->text_data->uri) - g_free (results->text_data->uri); - break; - case MODE_LIST: - if (results->tree_data->dialog_text) - g_free (results->tree_data->dialog_text); - if (results->tree_data->columns) - g_slist_foreach (results->tree_data->columns, (GFunc) g_free, NULL); - if (results->tree_data->separator) - g_free (results->tree_data->separator); - if (results->tree_data->print_column) - g_free (results->tree_data->print_column); - break; - case MODE_NOTIFICATION: - if (results->notification_data->notification_text) - g_free (results->notification_data->notification_text); - break; - default: - break; - } -} - gint main (gint argc, gchar **argv) { - poptContext ctx; - gint nextopt, retval; + ZenityParsingOptions *results; + gint retval; #ifdef HAVE_LOCALE_H setlocale(LC_ALL,""); @@ -1135,37 +47,10 @@ main (gint argc, gchar **argv) { bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); - zenity_init_parsing_options (); - - /* FIXME: popt doesn't like passing stuff through data - * but it doesn't seem to cope with the data that I try - * to pass in, not quite sure why though. If someone knows - * what I'm doing wrong, we could probably put this back: - * options[0].descrip = (void*) results; - */ + results = zenity_option_parse (argc, argv); - ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0); - - poptReadDefaultConfig(ctx, TRUE); - while((nextopt = poptGetNextOpt(ctx)) > 0) - /*nothing*/; - - if (nextopt != -1) { - g_printerr (_("%s is an invalid option. See 'zenity --help' for more details\n"), - poptBadOption (ctx, 0)); - zenity_free_parsing_options (); - exit (-1); - } gtk_init (&argc, &argv); - /* - * if (argc < 2) { - * g_printerr (_("You must specify more arguments. See zenity --help for more details\n")); - * zenity_free_parsing_options (); - * exit (-1); - * } - */ - switch (results->mode) { case MODE_CALENDAR: zenity_calendar (results->data, results->calendar_data); @@ -1183,7 +68,7 @@ main (gint argc, gchar **argv) { zenity_fileselection (results->data, results->file_data); break; case MODE_LIST: - results->tree_data->data = poptGetArgs (ctx); + results->tree_data->data = (const gchar **) argv + 1; zenity_tree (results->data, results->tree_data); break; case MODE_NOTIFICATION: @@ -1198,411 +83,22 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_VERSION: + g_print ("%s\n", VERSION); + break; case MODE_LAST: g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_free_parsing_options (); + zenity_option_free (); exit (-1); default: g_assert_not_reached (); - zenity_free_parsing_options (); + zenity_option_free (); exit (-1); } retval = results->data->exit_code; - poptFreeContext(ctx); - zenity_free_parsing_options (); - exit (retval); -} - -static void -zenity_error (gchar *string, ZenityError error) -{ - switch (error) { - case ERROR_DUPLICATE: - g_printerr (_("%s given twice for the same dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_SUPPORT: - g_printerr (_("%s is not supported for this dialog\n"), string); - zenity_free_parsing_options (); - exit (-1); - case ERROR_DIALOG: - g_printerr (_("Two or more dialog options specified\n")); - zenity_free_parsing_options (); - exit (-1); - default: - return; - } -} - -static void -zenity_parse_options_callback (poptContext ctx, - enum poptCallbackReason reason, - const struct poptOption *opt, - const char *arg, - void *data) -{ - static gboolean parse_option_dateformat = FALSE; - static gboolean parse_option_separator = FALSE; - static gint parse_option_text = 0; - static gint parse_option_file = 0; - static gint parse_option_editable = 0; - if (reason == POPT_CALLBACK_REASON_POST) - return; - else if (reason != POPT_CALLBACK_REASON_OPTION) - return; - - switch (opt->val & POPT_ARG_MASK) { - - case OPTION_CALENDAR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_CALENDAR; - break; - case OPTION_ENTRY: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ENTRY; - break; - case OPTION_ERROR: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ERROR; - results->msg_data->mode = ZENITY_MSG_ERROR; - break; - case OPTION_INFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_INFO; - results->msg_data->mode = ZENITY_MSG_INFO; - break; - case OPTION_FILE: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_FILE; - break; - case OPTION_LIST: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); + zenity_option_free (); - results->mode = MODE_LIST; - break; - case OPTION_NOTIFICATION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_NOTIFICATION; - break; - case OPTION_PROGRESS: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_PROGRESS; - break; - case OPTION_QUESTION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_QUESTION; - results->msg_data->mode = ZENITY_MSG_QUESTION; - break; - case OPTION_TEXTINFO: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_TEXTINFO; - break; - case OPTION_WARNING: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_WARNING; - results->msg_data->mode = ZENITY_MSG_WARNING; - break; - case OPTION_TITLE: - if (results->data->dialog_title != NULL) - zenity_error ("--title", ERROR_DUPLICATE); - - results->data->dialog_title = g_strdup (arg); - break; - case OPTION_ICON: - if (results->data->window_icon != NULL) - zenity_error ("--window-icon", ERROR_DUPLICATE); - - results->data->window_icon = g_strdup (arg); - break; - case OPTION_WIDTH: - if (results->data->width != -1) - zenity_error ("--width", ERROR_DUPLICATE); - - results->data->width = atoi (arg); - break; - case OPTION_HEIGHT: - if (results->data->height != -1) - zenity_error ("--height", ERROR_DUPLICATE); - - results->data->height = atoi (arg); - break; - case OPTION_CALENDARTEXT: - case OPTION_ENTRYTEXT: - case OPTION_ERRORTEXT: - case OPTION_QUESTIONTEXT: - case OPTION_PROGRESSTEXT: - case OPTION_LISTTEXT: - case OPTION_WARNINGTEXT: - case OPTION_NOTIFICATIONTEXT: - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_text > 8) - zenity_error ("--text", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_CALENDAR: - results->calendar_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_ENTRY: - results->entry_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - results->msg_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_PROGRESS: - results->progress_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_LIST: - results->tree_data->dialog_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - case MODE_NOTIFICATION: - results->notification_data->notification_text = g_locale_to_utf8 (g_strcompress (arg), - -1, NULL, NULL, NULL); - break; - default: - zenity_error ("--text", ERROR_SUPPORT); - } - parse_option_text++; - break; - case OPTION_DAY: - if (results->mode != MODE_CALENDAR) - zenity_error ("--day", ERROR_SUPPORT); - - if (results->calendar_data->day > 0) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->day = atoi (arg); - break; - case OPTION_MONTH: - if (results->mode != MODE_CALENDAR) - zenity_error ("--month", ERROR_SUPPORT); - - if (results->calendar_data->month > 0) - zenity_error ("--day", ERROR_DUPLICATE); - - results->calendar_data->month = atoi (arg); - break; - case OPTION_YEAR: - if (results->mode != MODE_CALENDAR) - zenity_error ("--year", ERROR_SUPPORT); - - if (results->calendar_data->year > 0) - zenity_error ("--year", ERROR_DUPLICATE); - - results->calendar_data->year = atoi (arg); - break; - case OPTION_DATEFORMAT: - if (results->mode != MODE_CALENDAR) - zenity_error ("--date-format", ERROR_SUPPORT); - - if (parse_option_dateformat) - zenity_error ("--date-format", ERROR_DUPLICATE); - - results->calendar_data->date_format = g_strdup (arg); - parse_option_dateformat = TRUE; - break; - case OPTION_INPUTTEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--entry-text", ERROR_SUPPORT); - - if (results->entry_data->entry_text != NULL) - zenity_error ("--entry-text", ERROR_DUPLICATE); - - results->entry_data->entry_text = g_strdup (arg); - break; - case OPTION_HIDETEXT: - if (results->mode != MODE_ENTRY) - zenity_error ("--hide-text", ERROR_SUPPORT); - - if (!results->entry_data->visible) - zenity_error ("--hide-text", ERROR_DUPLICATE); - - results->entry_data->visible = FALSE; - break; - case OPTION_LISTEDIT: - case OPTION_TEXTEDIT: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_editable > 2) - zenity_error ("--editable", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_TEXTINFO: - results->text_data->editable = TRUE; - break; - case MODE_LIST: - results->tree_data->editable = TRUE; - break; - default: - zenity_error ("--editable", ERROR_SUPPORT); - } - parse_option_editable++; - break; - case OPTION_FILENAME: - case OPTION_TEXTFILENAME: - - /* FIXME: This is an ugly hack because of the way the poptOptions are - * ordered above. When you try and use an --option more than once - * parse_options_callback gets called for each option. Suckage - */ - - if (parse_option_file > 2) - zenity_error ("--filename", ERROR_DUPLICATE); - - switch (results->mode) { - case MODE_FILE: - results->file_data->uri = g_strdup (arg); - break; - case MODE_TEXTINFO: - results->text_data->uri = g_strdup (arg); - break; - default: - zenity_error ("--filename", ERROR_SUPPORT); - } - parse_option_file++; - break; - case OPTION_MULTIFILE: - if (results->mode != MODE_FILE) - zenity_error ("--multiple", ERROR_SUPPORT); - - results->file_data->multi = TRUE; - break; - case OPTION_DIR: - if (results->mode != MODE_FILE) - zenity_error ("--directory", ERROR_SUPPORT); - - results->file_data->directory = TRUE; - break; - case OPTION_SAVE: - if (results->mode != MODE_FILE) - zenity_error ("--save", ERROR_SUPPORT); - - results->file_data->save = TRUE; - break; - case OPTION_COLUMN: - if (results->mode != MODE_LIST) - zenity_error ("--column", ERROR_SUPPORT); - - results->tree_data->columns = g_slist_append (results->tree_data->columns, g_strdup (arg)); - break; - case OPTION_CHECKLIST: - if (results->mode != MODE_LIST) - zenity_error ("--checklist", ERROR_SUPPORT); - - if (results->tree_data->checkbox) - zenity_error ("--checklist", ERROR_DUPLICATE); - - results->tree_data->checkbox = TRUE; - break; - case OPTION_RADIOLIST: - if (results->mode != MODE_LIST) - zenity_error ("--radiolist", ERROR_SUPPORT); - if (results->tree_data->radiobox) - zenity_error ("--radiolist", ERROR_DUPLICATE); - - results->tree_data->radiobox = TRUE; - break; - case OPTION_SEPERATOR: - if (parse_option_separator > 2) - zenity_error ("--separator", ERROR_DUPLICATE); - switch (results->mode) { - case MODE_LIST: - results->tree_data->separator = g_strdup (g_strcompress (arg)); - parse_option_separator++; - break; - case MODE_FILE: - results->file_data->separator = g_strdup (g_strcompress (arg)); - parse_option_separator++; - break; - default: - zenity_error ("--separator", ERROR_SUPPORT); - } - break; - case OPTION_PERCENTAGE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--percentage", ERROR_SUPPORT); - - if (results->progress_data->percentage > -1) - zenity_error ("--percentage", ERROR_DUPLICATE); - - results->progress_data->percentage = atoi (arg); - break; - case OPTION_PULSATE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--pulsate", ERROR_SUPPORT); - - results->progress_data->pulsate = TRUE; - break; - case OPTION_AUTOCLOSE: - if (results->mode != MODE_PROGRESS) - zenity_error ("--auto-close", ERROR_SUPPORT); - - results->progress_data->autoclose = TRUE; - break; - case OPTION_PRINTCOLUMN: - if (results->mode != MODE_LIST) - zenity_error ("--print-column", ERROR_SUPPORT); - - results->tree_data->print_column = g_strdup (arg); - break; - case OPTION_NOTIFICATIONLISTEN: - if (results->mode != MODE_NOTIFICATION) - zenity_error ("--listen", ERROR_SUPPORT); - - results->notification_data->listen = TRUE; - break; - case OPTION_ABOUT: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - - results->mode = MODE_ABOUT; - break; - case OPTION_VERSION: - if (results->mode != MODE_LAST) - zenity_error (NULL, ERROR_DIALOG); - zenity_free_parsing_options (); - g_print ("%s\n", VERSION); - exit (0); - break; - default: - break; - } + exit (retval); } diff --git a/src/zenity.h b/src/zenity.h index 1365d170..0e869716 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -55,35 +55,35 @@ typedef enum { } MsgMode; typedef struct { - gchar *dialog_text; + gchar *dialog_text; MsgMode mode; } ZenityMsgData; typedef struct { - gchar *uri; + gchar *uri; gboolean multi; gboolean directory; gboolean save; - gchar *separator; + gchar *separator; } ZenityFileData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean visible; + gchar *dialog_text; + gchar *entry_text; + gboolean visible; } ZenityEntryData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean pulsate; - gboolean autoclose; - gdouble percentage; + gchar *dialog_text; + gchar *entry_text; + gboolean pulsate; + gboolean autoclose; + gdouble percentage; } ZenityProgressData; typedef struct { gchar *uri; - gboolean editable; + gboolean editable; GtkTextBuffer *buffer; } ZenityTextData; @@ -99,8 +99,8 @@ typedef struct { } ZenityTreeData; typedef struct { - gchar *notification_text; - gboolean listen; + gchar *notification_text; + gboolean listen; } ZenityNotificationData; void zenity_calendar (ZenityData *data, -- cgit From f57c93017bdfbb8612004cd05c606ea4684ea907 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 00:55:26 +0000 Subject: Patch from Lucas Rocha to use the GOption API for the 2004-12-07 Glynn Foster Patch from Lucas Rocha to use the GOption API for the zenity parsing options, with some spacing fixes from Glynn. * configure.in: zenity now requires glib-2.0 >= 2.5.3 to build because now it uses GOption. popt requirement removed. * src/Makefile.am: update for new files * src/main.c: use GOption API * src/option.c, src/option.h: New files to implement the new functionality. * src/zenity.h: Fix spacing. --- src/option.c | 1364 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/option.h | 81 ++++ 2 files changed, 1445 insertions(+) create mode 100644 src/option.c create mode 100644 src/option.h (limited to 'src') diff --git a/src/option.c b/src/option.c new file mode 100644 index 00000000..b230633b --- /dev/null +++ b/src/option.c @@ -0,0 +1,1364 @@ +/* + * option.h + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + * Lucas Rocha + */ + +#include "option.h" + +/* General Options */ +gchar *zenity_general_dialog_title; +gchar *zenity_general_window_icon; +int zenity_general_width; +int zenity_general_height; +gchar *zenity_general_dialog_text; +gchar *zenity_general_separator; +gboolean zenity_general_editable; +gchar *zenity_general_uri; + +/* Calendar Dialog Options */ +gboolean zenity_calendar_active; +int zenity_calendar_day; +int zenity_calendar_month; +int zenity_calendar_year; +gchar *zenity_calendar_date_format; + +/* Entry Dialog Options */ +gboolean zenity_entry_active; +gchar *zenity_entry_entry_text; +gboolean zenity_entry_visible; + +/* Error Dialog Options */ +gboolean zenity_error_active; + +/* Info Dialog Options */ +gboolean zenity_info_active; + +/* File Selection Dialog Options */ +gboolean zenity_file_active; +gboolean zenity_file_multiple; +gboolean zenity_file_directory; +gboolean zenity_file_save; + +/* List Dialog Options */ +gboolean zenity_list_active; +gchar **zenity_list_columns; +gboolean zenity_list_checklist; +gboolean zenity_list_radiolist; +gchar *zenity_list_print_column; + +/* Notification Dialog Options */ +gboolean zenity_notification_active; +gboolean zenity_notification_listen; + +/* Progress Dialog Options */ +gboolean zenity_progress_active; +int zenity_progress_percentage; +gboolean zenity_progress_pulsate; +gboolean zenity_progress_auto_close; + +/* Question Dialog Options */ +gboolean zenity_question_active; + +/* Text Dialog Options */ +gboolean zenity_text_active; + +/* Warning Dialog Options */ +gboolean zenity_warning_active; + +/* Miscelaneus Options */ +gboolean zenity_misc_about; +gboolean zenity_misc_version; + +GOptionEntry general_options[] = { + { + "title", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_title, + N_("Set the dialog title"), + N_("TITLE") + }, + { + "window-icon", + '\0', + 0, + G_OPTION_ARG_FILENAME, + &zenity_general_window_icon, + N_("Set the window icon"), + N_("ICONPATH") + }, + { + "width", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_width, + N_("Set the width"), + N_("WIDTH") + }, + { + "height", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_height, + N_("Set the height"), + N_("HEIGHT") + }, + { + NULL + } +}; + +GOptionEntry calendar_options[] = { + { + "calendar", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_calendar_active, + N_("Display calendar dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + "day", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_day, + N_("Set the calendar day"), + NULL + }, + { + "month", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_month, + N_("Set the calendar month"), + NULL + }, + { + "year", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_year, + N_("Set the calendar year"), + NULL + }, + { "date-format", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_calendar_date_format, + N_("Set the format for the returned date"), + NULL + }, + { + NULL + } +}; + +GOptionEntry entry_options[] = { + { + "entry", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_entry_active, + N_("Display text entry dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + "entry-text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_entry_entry_text, + N_("Set the entry text"), + NULL + }, + { + "hide-text", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_entry_visible, + N_("Hide the entry text"), + NULL + }, + { + NULL + } +}; + + +GOptionEntry error_options[] = { + { + "error", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_error_active, + N_("Display error dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + NULL + } +}; + +GOptionEntry info_options[] = { + { + "info", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_info_active, + N_("Display info dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + NULL + } +}; + +GOptionEntry file_selection_options[] = { + { + "file-selection", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_file_active, + N_("Display file selection dialog"), + NULL + }, + { + "filename", + '\0', + 0, + G_OPTION_ARG_FILENAME, + &zenity_general_uri, + N_("Set the filename"), + N_("FILENAME") + }, + { + "multiple", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_multiple, + N_("Allow multiple files to be selected"), + NULL + }, + { + "directory", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_directory, + N_("Activate directory-only selection"), + NULL + }, + { + "save", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_save, + N_("Activate save mode"), + NULL + }, + { + "separator", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_("Set output separator character"), + N_("SEPARATOR") + }, + { + NULL + } +}; + +GOptionEntry list_options[] = { + { + "list", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_list_active, + N_("Display list dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + "column", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_list_columns, + N_("Set the column header"), + NULL + }, + { + "checklist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_checklist, + N_("Use check boxes for first column"), + NULL + }, + { + "radiolist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_radiolist, + N_("Use radio buttons for first column"), + NULL + }, + { + "separator", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_("Set output separator character"), + N_("SEPARATOR") + }, + { + "editable", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_editable, + N_("Allow changes to text"), + NULL + }, + { + "print-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_list_print_column, + N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), + NULL + }, + { + NULL + } +}; + +GOptionEntry notification_options[] = { + { + "notification", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_notification_active, + N_("Display notification"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the notification text"), + NULL + }, + { + "listen", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_notification_listen, + N_("Listen for commands on stdin"), + NULL + }, + { + NULL + } +}; + +GOptionEntry progress_options[] = { + { + "progress", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_progress_active, + N_("Display progress indication dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + "percentage", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_progress_percentage, + N_("Set initial percentage"), + NULL + }, + { + "pulsate", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_pulsate, + N_("Pulsate progress bar"), + NULL + }, + { + "auto-close", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_auto_close, + /* xgettext: no-c-format */ + N_("Dismiss the dialog when 100% has been reached"), + NULL + }, + { + NULL + } +}; + +GOptionEntry question_options[] = { + { + "question", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_question_active, + N_("Display question dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + NULL + } +}; + +GOptionEntry text_options[] = { + { + "text-info", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_text_active, + N_("Display text information dialog"), + NULL + }, + { + "filename", + '\0', + 0, + G_OPTION_ARG_FILENAME, + &zenity_general_uri, + N_("Open file"), + N_("FILENAME") + }, + { + "editable", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_editable, + N_("Allow changes to text"), + NULL + }, + { + NULL + } +}; + +GOptionEntry warning_options[] = { + { + "warning", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_warning_active, + N_("Display warning dialog"), + NULL + }, + { + "text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + NULL + } +}; + +GOptionEntry miscellaneous_options[] = { + { + "about", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_misc_about, + N_("About zenity"), + NULL + }, + { + "version", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_misc_version, + N_("Print version"), + NULL + }, + { + NULL + } +}; + +ZenityParsingOptions *results; +GOptionContext *ctx; + +void +zenity_option_init (void) { + + results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ + results->mode = MODE_LAST; + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); + results->notification_data = g_new0 (ZenityNotificationData, 1); +} + +void +zenity_option_free (void) { + if (zenity_general_dialog_title) + g_free (zenity_general_dialog_title); + if (zenity_general_window_icon) + g_free (zenity_general_window_icon); + if (zenity_general_dialog_text) + g_free (zenity_general_dialog_text); + if (zenity_general_uri) + g_free (zenity_general_uri); + g_free (zenity_general_separator); + + if (zenity_calendar_date_format) + g_free (zenity_calendar_date_format); + + if (zenity_entry_entry_text) + g_free (zenity_entry_entry_text); + + if (zenity_list_columns) + g_strfreev (zenity_list_columns); + if (zenity_list_print_column) + g_free (zenity_list_print_column); + + g_option_context_free (ctx); +} + +void +zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) +{ + if (is_active == TRUE) { + if (results->mode == MODE_LAST) + results->mode = mode; + else + zenity_option_error (NULL, ERROR_DIALOG); + } +} + +gchar * +zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) +{ + int i; + + for (i = 1; entries[i].long_name != NULL; i++) { + if (entries[i].arg_data == arg_data) + return (gchar *) entries[i].long_name; + } +} + +/* Error callback */ +void zenity_option_error_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_error (NULL, ERROR_SYNTAX); +} + +/* Pre parse callbacks set the default option values */ + +gboolean +zenity_general_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_general_dialog_title = NULL; + zenity_general_window_icon = NULL; + zenity_general_width = -1; + zenity_general_height = -1; + zenity_general_dialog_text = NULL; + zenity_general_separator = g_strdup ("|"); + zenity_general_editable = FALSE; + zenity_general_uri = NULL; + + return TRUE; +} + +gboolean +zenity_calendar_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_calendar_active = FALSE; + zenity_calendar_date_format = NULL; + zenity_calendar_day = 0; + zenity_calendar_month = 0; + zenity_calendar_year = 0; + + return TRUE; +} + +gboolean +zenity_entry_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_entry_active = FALSE; + zenity_entry_entry_text = NULL; + zenity_entry_visible = FALSE; + + return TRUE; +} + +gboolean +zenity_error_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_error_active = FALSE; + + return TRUE; +} + +gboolean +zenity_info_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_info_active = FALSE; + + return TRUE; +} + +gboolean +zenity_file_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_file_active = FALSE; + zenity_file_multiple = FALSE; + zenity_file_directory = FALSE; + zenity_file_save = FALSE; + + return TRUE; +} + +gboolean +zenity_list_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_list_active = FALSE; + zenity_list_columns = NULL; + zenity_list_checklist = FALSE; + zenity_list_radiolist = FALSE; + zenity_list_print_column = NULL; + + return TRUE; +} + +gboolean +zenity_notification_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_notification_active = FALSE; + zenity_notification_listen = FALSE; + + return TRUE; +} + +gboolean +zenity_progress_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_progress_active = FALSE; + zenity_progress_percentage = 0; + zenity_progress_pulsate = FALSE; + zenity_progress_auto_close = FALSE; + + return TRUE; +} + +gboolean +zenity_question_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_question_active = FALSE; + + return TRUE; +} + +gboolean +zenity_text_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_text_active = FALSE; + + return TRUE; +} + +gboolean +zenity_warning_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_warning_active = FALSE; + + return TRUE; +} + +gboolean +zenity_misc_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_misc_about = FALSE; + zenity_misc_version = FALSE; + + return TRUE; +} + +/* Post parse callbacks assign the option values to + parsing result and makes some post condition tests */ + +gboolean +zenity_general_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + results->data->dialog_title = zenity_general_dialog_title; + results->data->window_icon = zenity_general_window_icon; + results->data->width = zenity_general_width; + results->data->height = zenity_general_height; + + return TRUE; +} + +gboolean +zenity_calendar_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + int i; + + zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR); + + if (results->mode == MODE_CALENDAR) { + results->calendar_data->dialog_text = zenity_general_dialog_text; + results->calendar_data->day = zenity_calendar_day; + results->calendar_data->month = zenity_calendar_month; + results->calendar_data->year = zenity_calendar_year; + if (zenity_calendar_date_format) + results->calendar_data->date_format = zenity_calendar_date_format; + else + results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); + } else { + if (zenity_calendar_day) + zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_day), + ERROR_SUPPORT); + + if (zenity_calendar_month) + zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_month), + ERROR_SUPPORT); + + if (zenity_calendar_year) + zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_year), + ERROR_SUPPORT); + + if (zenity_calendar_date_format) + zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_date_format), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_entry_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY); + + if (results->mode == MODE_ENTRY) { + results->entry_data->dialog_text = zenity_general_dialog_text; + results->entry_data->entry_text = zenity_entry_entry_text; + results->entry_data->visible = !zenity_entry_visible; + } else { + if (zenity_entry_entry_text) + zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_entry_text), + ERROR_SUPPORT); + + if (zenity_entry_visible) + zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_visible), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_error_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_error_active, MODE_ERROR); + + if (results->mode == MODE_ERROR) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->mode = ZENITY_MSG_ERROR; + } + + return TRUE; +} + +gboolean +zenity_info_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_info_active, MODE_INFO); + + if (results->mode == MODE_INFO) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->mode = ZENITY_MSG_INFO; + } + + return TRUE; +} + +gboolean +zenity_file_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_file_active, MODE_FILE); + + if (results->mode == MODE_FILE) { + results->file_data->uri = zenity_general_uri; + results->file_data->multi = zenity_file_multiple; + results->file_data->directory = zenity_file_directory; + results->file_data->save = zenity_file_save; + results->file_data->separator = zenity_general_separator; + } else { + if (zenity_file_multiple) + zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_multiple), + ERROR_SUPPORT); + + if (zenity_file_directory) + zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory), + ERROR_SUPPORT); + + if (zenity_file_save) + zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_save), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_list_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + int i = 0; + gchar *column; + + zenity_option_set_dialog_mode (zenity_list_active, MODE_LIST); + + if (results->mode == MODE_LIST) { + results->tree_data->dialog_text = zenity_general_dialog_text; + + if (zenity_list_columns) { + column = zenity_list_columns[0]; + while (column != NULL) { + results->tree_data->columns = g_slist_append (results->tree_data->columns, column); + column = zenity_list_columns[++i]; + } + } + + results->tree_data->checkbox = zenity_list_checklist; + results->tree_data->radiobox = zenity_list_radiolist; + results->tree_data->editable = zenity_general_editable; + results->tree_data->print_column = zenity_list_print_column; + results->tree_data->separator = zenity_general_separator; + } else { + if (zenity_list_columns) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_columns), + ERROR_SUPPORT); + + if (zenity_list_checklist) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_checklist), + ERROR_SUPPORT); + + if (zenity_list_radiolist) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_radiolist), + ERROR_SUPPORT); + + if (zenity_list_print_column) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_notification_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_notification_active, MODE_NOTIFICATION); + + if (results->mode == MODE_NOTIFICATION) { + results->notification_data->notification_text = zenity_general_dialog_text; + results->notification_data->listen = zenity_notification_listen; + } else { + if (zenity_notification_listen) + zenity_option_error (zenity_option_get_name (notification_options, &zenity_notification_listen), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_progress_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS); + + if (results->mode == MODE_PROGRESS) { + results->progress_data->dialog_text = zenity_general_dialog_text; + results->progress_data->pulsate = zenity_progress_pulsate; + results->progress_data->autoclose = zenity_progress_auto_close; + results->progress_data->percentage = zenity_progress_percentage; + } else { + if (zenity_progress_pulsate) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_pulsate), + ERROR_SUPPORT); + + if (zenity_progress_percentage) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_percentage), + ERROR_SUPPORT); + + if (zenity_progress_auto_close) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close), + ERROR_SUPPORT); + } + + return TRUE; +} + +gboolean +zenity_question_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION); + + + if (results->mode == MODE_QUESTION) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->mode = ZENITY_MSG_QUESTION; + } + + return TRUE; +} + +gboolean +zenity_text_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_text_active, MODE_TEXTINFO); + + if (results->mode == MODE_TEXTINFO) { + results->text_data->uri = zenity_general_uri; + results->text_data->editable = zenity_general_editable; + } + + return TRUE; +} + +gboolean +zenity_warning_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_warning_active, MODE_WARNING); + + if (results->mode == MODE_WARNING) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->mode = ZENITY_MSG_WARNING; + } + + return TRUE; +} + +gboolean +zenity_misc_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_misc_about, MODE_ABOUT); + zenity_option_set_dialog_mode (zenity_misc_version, MODE_VERSION); + + return TRUE; +} + +GOptionContext * +zenity_create_context (void) +{ + GOptionContext *tmp_ctx; + GOptionGroup *a_group; + + tmp_ctx = g_option_context_new(NULL); + + /* Adds general option entries */ + a_group = g_option_group_new("general", + N_("General options"), + N_("Show general options"), NULL, 0); + g_option_group_add_entries(a_group, general_options); + g_option_group_set_parse_hooks (a_group, + zenity_general_pre_callback, zenity_general_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds calendar option entries */ + a_group = g_option_group_new("calendar", + N_("Calendar options"), + N_("Show calendar options"), NULL, 0); + g_option_group_add_entries(a_group, calendar_options); + g_option_group_set_parse_hooks (a_group, + zenity_calendar_pre_callback, zenity_calendar_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds entry option entries */ + a_group = g_option_group_new("entry", + N_("Text entry options"), + N_("Show text entry options"), NULL, 0); + g_option_group_add_entries(a_group, entry_options); + g_option_group_set_parse_hooks (a_group, + zenity_entry_pre_callback, zenity_entry_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds error option entries */ + a_group = g_option_group_new("error", + N_("Error options"), + N_("Show error options"), NULL, 0); + g_option_group_add_entries(a_group, error_options); + g_option_group_set_parse_hooks (a_group, + zenity_error_pre_callback, zenity_error_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds info option entries */ + a_group = g_option_group_new("info", + N_("Info options"), + N_("Show info options"), NULL, 0); + g_option_group_add_entries(a_group, info_options); + g_option_group_set_parse_hooks (a_group, + zenity_info_pre_callback, zenity_info_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds file selection option entries */ + a_group = g_option_group_new("file-selection", + N_("File selection options"), + N_("Show file selection options"), NULL, 0); + g_option_group_add_entries(a_group, file_selection_options); + g_option_group_set_parse_hooks (a_group, + zenity_file_pre_callback, zenity_file_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds list option entries */ + a_group = g_option_group_new("list", + N_("List options"), + N_("Show list options"), NULL, 0); + g_option_group_add_entries(a_group, list_options); + g_option_group_set_parse_hooks (a_group, + zenity_list_pre_callback, zenity_list_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds notification option entries */ + a_group = g_option_group_new("notification", + N_("Notication options"), + N_("Show notification options"), NULL, 0); + g_option_group_add_entries(a_group, notification_options); + g_option_group_set_parse_hooks (a_group, + zenity_notification_pre_callback, zenity_notification_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds progress option entries */ + a_group = g_option_group_new("progress", + N_("Progress options"), + N_("Show progress options"), NULL, 0); + g_option_group_add_entries(a_group, progress_options); + g_option_group_set_parse_hooks (a_group, + zenity_progress_pre_callback, zenity_progress_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds question option entries */ + a_group = g_option_group_new("question", + N_("Question options"), + N_("Show question options"), NULL, 0); + g_option_group_add_entries(a_group, question_options); + g_option_group_set_parse_hooks (a_group, + zenity_question_pre_callback, zenity_question_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds warning option entries */ + a_group = g_option_group_new("warning", + N_("Warning options"), + N_("Show warning options"), NULL, 0); + g_option_group_add_entries(a_group, warning_options); + g_option_group_set_parse_hooks (a_group, + zenity_warning_pre_callback, zenity_warning_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds text option entries */ + a_group = g_option_group_new("text", + N_("Text options"), + N_("Show text options"), NULL, 0); + g_option_group_add_entries(a_group, text_options); + g_option_group_set_parse_hooks (a_group, + zenity_text_pre_callback, zenity_text_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds misc option entries */ + a_group = g_option_group_new("misc", + N_("Miscellaneous options"), + N_("Show miscellaneous options"), NULL, 0); + g_option_group_add_entries(a_group, miscellaneous_options); + g_option_group_set_parse_hooks (a_group, + zenity_misc_pre_callback, zenity_misc_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_context_add_group(tmp_ctx, a_group); + + /* Adds gtk option entries */ + a_group = gtk_get_option_group(TRUE); + g_option_context_add_group(tmp_ctx, a_group); + + /* Enable help options */ + g_option_context_set_help_enabled (tmp_ctx, TRUE); + g_option_context_set_ignore_unknown_options (tmp_ctx, FALSE); + + return tmp_ctx; +} + +void +zenity_option_error (gchar *string, ZenityError error) +{ + switch (error) { + case ERROR_SYNTAX: + g_printerr (_("Syntax error\n")); + zenity_option_free (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_("--%s is not supported for this dialog\n"), string); + zenity_option_free (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_("Two or more dialog options specified\n")); + zenity_option_free (); + exit (-1); + default: + return; + } +} + +ZenityParsingOptions * +zenity_option_parse (gint argc, gchar **argv) +{ + GError *error = NULL; + + zenity_option_init (); + + ctx = zenity_create_context (); + + g_option_context_parse (ctx, &argc, &argv, &error); + + /* Some option pointer a shared among more than one group and don't + have their post condition tested. This test is done here. */ + + if (zenity_general_dialog_text) + if (results->mode == MODE_ABOUT || results->mode == MODE_VERSION) + zenity_option_error (zenity_option_get_name (calendar_options, &zenity_general_dialog_text), ERROR_SUPPORT); + + if (strcmp (zenity_general_separator, "|") != 0) + if (results->mode != MODE_LIST && results->mode != MODE_FILE) + zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT); + + if (zenity_general_editable) + if (results->mode != MODE_TEXTINFO && results->mode != MODE_LIST) + zenity_option_error (zenity_option_get_name (list_options, &zenity_general_editable), ERROR_SUPPORT); + + if (zenity_general_uri) + if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) + zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); + + return results; +} diff --git a/src/option.h b/src/option.h new file mode 100644 index 00000000..63b28243 --- /dev/null +++ b/src/option.h @@ -0,0 +1,81 @@ +/* + * option.h + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Authors: Glynn Foster + * Lucas Rocha + */ + +#ifndef OPTION_H +#define OPTION_H + +#include "zenity.h" +#include +#include +#ifdef HAVE_LOCALE_H +#include +#endif + +typedef enum { + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_INFO, + MODE_NOTIFICATION, + MODE_ABOUT, + MODE_VERSION, + MODE_LAST +} ZenityDialogMode; + +typedef enum { + ERROR_SYNTAX, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST +} ZenityError; + +typedef struct { + ZenityDialogMode mode; + ZenityData *data; + + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; + ZenityNotificationData *notification_data; +} ZenityParsingOptions; + +void zenity_option_error (gchar *string, + ZenityError error); + +ZenityParsingOptions * zenity_option_parse (gint argc, + gchar **argv); + +void zenity_option_free (void); + +#endif /* OPTION_H */ -- cgit From 6798192ed825aaeefd296fc1769cbadf5c20e29e Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 01:19:45 +0000 Subject: Fix spacing issue. 2004-12-07 Glynn Foster * src/option.c: Fix spacing issue. --- src/option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index b230633b..7337f488 100644 --- a/src/option.c +++ b/src/option.c @@ -176,7 +176,8 @@ GOptionEntry calendar_options[] = { N_("Set the calendar year"), NULL }, - { "date-format", + { + "date-format", '\0', 0, G_OPTION_ARG_STRING, -- cgit From 69e094a4570bae10dab378e8c024c76fc7d0250a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Tue, 7 Dec 2004 01:26:00 +0000 Subject: Fix for #137993. There is a chance that we'll have to revert this fix, 2004-12-07 Glynn Foster * src/main.c: Fix for #137993. There is a chance that we'll have to revert this fix, given the comments in /etc/X11/gdm/Xsession: # Note that this should only go to zenity dialogs which always # expect utf8 gettextfunc () { if [ "x$gdmtranslate" != "x" ] ; then "$gdmtranslate" --utf8 "$1" else echo "$1" fi } So I guess we may be over a barrel with our original guarantee. Let's just change this in 2.9.x and see if anyone notices or cares enough. Patch from Leonardo Boshell . --- src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 10e75b8a..b79afc06 100644 --- a/src/main.c +++ b/src/main.c @@ -44,11 +44,11 @@ main (gint argc, gchar **argv) { #endif bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); results = zenity_option_parse (argc, argv); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); gtk_init (&argc, &argv); switch (results->mode) { -- cgit From a626476abbeafed0c70ed42e51037df3907d415c Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 19 Dec 2004 21:27:25 +0000 Subject: Fix #161539, and try and hide the parent widget, rather than the tray 2004-12-20 Glynn Foster * src/notification.c: Fix #161539, and try and hide the parent widget, rather than the tray icon, since it saves space. --- src/notification.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index a67b7308..4dcc63d7 100644 --- a/src/notification.c +++ b/src/notification.c @@ -183,9 +183,12 @@ zenity_notification_handle_stdin (GIOChannel *channel, gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); } else if (!strcmp (command, "visible")) { if (!strcasecmp (value, "false")) { - gtk_widget_hide (GTK_WIDGET (tray_icon)); + /* We need to get the parent, because just hiding the tray_icon + * doesn't save on space. See #161539 for details + */ + gtk_widget_hide (gtk_widget_get_parent (GTK_WIDGET (tray_icon))); } else { - gtk_widget_show (GTK_WIDGET (tray_icon)); + gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET (tray_icon))); } } else { g_warning ("Unknown command '%s'", command); -- cgit From c52435f74846b59e9a475f864d18838cfcde01f4 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 20 Dec 2004 22:25:29 +0000 Subject: Fix tyop for #161774, as reported by Christian. 2004-12-21 Glynn Foster * src/option.c: Fix tyop for #161774, as reported by Christian. --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 7337f488..0b892973 100644 --- a/src/option.c +++ b/src/option.c @@ -1241,7 +1241,7 @@ zenity_create_context (void) /* Adds notification option entries */ a_group = g_option_group_new("notification", - N_("Notication options"), + N_("Notification options"), N_("Show notification options"), NULL, 0); g_option_group_add_entries(a_group, notification_options); g_option_group_set_parse_hooks (a_group, -- cgit From 4643fbc3e75d5789500198938395de4def9a3ec0 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Fri, 7 Jan 2005 01:55:11 +0000 Subject: Pre-load the year, because gtk_calendar* is dumb and you need to select 2005-01-07 Glynn Foster * src/option.c: Pre-load the year, because gtk_calendar* is dumb and you need to select the year to change the month. Fixes #162297. --- src/option.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 0b892973..f6fe4b26 100644 --- a/src/option.c +++ b/src/option.c @@ -23,6 +23,7 @@ */ #include "option.h" +#include /* General Options */ gchar *zenity_general_dialog_title; @@ -713,11 +714,17 @@ zenity_calendar_pre_callback (GOptionContext *context, gpointer data, GError **error) { + struct tm *t; + time_t current_time; + + time (¤t_time); + t = localtime (¤t_time); + zenity_calendar_active = FALSE; zenity_calendar_date_format = NULL; zenity_calendar_day = 0; zenity_calendar_month = 0; - zenity_calendar_year = 0; + zenity_calendar_year = t->tm_year + 1900; return TRUE; } -- cgit From 516f9944095b4308a055eaca9a9220cfeb66b669 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 9 Jan 2005 20:04:30 +0000 Subject: Really fix #162297, and preload the current dates if they aren't already 2005-01-07 Glynn Foster * src/option.c, src/calendar.c: Really fix #162297, and preload the current dates if they aren't already set. --- src/calendar.c | 2 +- src/option.c | 32 ++++++++++++++++++++------------ 2 files changed, 21 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 9da633e8..8bffed8e 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -73,7 +73,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (glade_dialog) g_object_unref (glade_dialog); - if (cal_data->month > 0 && cal_data->year > 0) + if (cal_data->month > 0 || cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); diff --git a/src/option.c b/src/option.c index f6fe4b26..65b5373c 100644 --- a/src/option.c +++ b/src/option.c @@ -714,17 +714,11 @@ zenity_calendar_pre_callback (GOptionContext *context, gpointer data, GError **error) { - struct tm *t; - time_t current_time; - - time (¤t_time); - t = localtime (¤t_time); - zenity_calendar_active = FALSE; zenity_calendar_date_format = NULL; - zenity_calendar_day = 0; - zenity_calendar_month = 0; - zenity_calendar_year = t->tm_year + 1900; + zenity_calendar_day = -1; + zenity_calendar_month = -1; + zenity_calendar_year = -1; return TRUE; } @@ -892,6 +886,19 @@ zenity_calendar_post_callback (GOptionContext *context, zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR); if (results->mode == MODE_CALENDAR) { + struct tm *t; + time_t current_time; + + time (¤t_time); + t = localtime (¤t_time); + + if (zenity_calendar_day < 0) + zenity_calendar_day = t->tm_mday; + if (zenity_calendar_month < 0) + zenity_calendar_month = t->tm_mon + 1; + if (zenity_calendar_year < 0) + zenity_calendar_year = t->tm_year + 1900; + results->calendar_data->dialog_text = zenity_general_dialog_text; results->calendar_data->day = zenity_calendar_day; results->calendar_data->month = zenity_calendar_month; @@ -900,16 +907,17 @@ zenity_calendar_post_callback (GOptionContext *context, results->calendar_data->date_format = zenity_calendar_date_format; else results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); + } else { - if (zenity_calendar_day) + if (zenity_calendar_day > -1) zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_day), ERROR_SUPPORT); - if (zenity_calendar_month) + if (zenity_calendar_month > -1) zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_month), ERROR_SUPPORT); - if (zenity_calendar_year) + if (zenity_calendar_year > -1) zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_year), ERROR_SUPPORT); -- cgit From 01872ab746227b3d38faa8f746c504af0defc39a Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 9 Jan 2005 20:13:18 +0000 Subject: Correct error message for notification icon. Fixes #163462. 2005-01-07 Glynn Foster * src/notification.c: Correct error message for notification icon. Fixes #163462. --- src/notification.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 4dcc63d7..63b15116 100644 --- a/src/notification.c +++ b/src/notification.c @@ -242,7 +242,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data GTK_ICON_SIZE_BUTTON); gdk_pixbuf_unref (pixbuf); } else { - g_warning ("Could not load notification icon : %s", ZENITY_IMAGE_FULLPATH ("zenity-notification.png")); + if (data->window_icon != NULL) { + g_warning ("Could not load notification icon : %s", data->window_icon); + } + else + g_warning ("Could not load notification icon : %s", ZENITY_IMAGE_FULLPATH ("zenity-notification.png")); return; } -- cgit From bc282cfa65502ea8d8a84553162f5690b8bf328c Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 17 Jan 2005 01:33:23 +0000 Subject: Patch from Ed Catmur to fix the list dialog on stdin. Fixes #164152. 2005-01-17 Glynn Foster * src/tree.c: Patch from Ed Catmur to fix the list dialog on stdin. Fixes #164152. * src/about.c, THANKS: Update. --- src/about.c | 1 + src/tree.c | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index d6fc9083..d64d6777 100644 --- a/src/about.c +++ b/src/about.c @@ -61,6 +61,7 @@ static const gchar *author_credits[] = { "Ross Burton ", "Damien Carbery ", "Anders Carlsson ", + "Ed Catmur ", "Nicholas Curran ", "John Fleck ", "Sebastian Heinlein ", diff --git a/src/tree.c b/src/tree.c index 49c1d782..63fe4aee 100644 --- a/src/tree.c +++ b/src/tree.c @@ -440,13 +440,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); if (tree_data->radiobox || tree_data->checkbox) { - if (tree_data->data) + if (tree_data->data && *tree_data->data) zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); else zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, TRUE, tree_data->editable); } else { - if (tree_data->data) + if (tree_data->data && *tree_data->data) zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); else zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); -- cgit From a4777781d1b7c0294048e78dbc758de238b386c2 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 31 Jan 2005 22:17:38 +0000 Subject: Patch from Chris Lahey for #165456. Updated. 2005-02-01 Glynn Foster * src/notification.c, src/option.c: Patch from Chris Lahey for #165456. * src/about.c, THANKS: Updated. --- src/about.c | 3 ++- src/notification.c | 3 ++- src/option.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index d64d6777..afcdec13 100644 --- a/src/about.c +++ b/src/about.c @@ -66,7 +66,8 @@ static const gchar *author_credits[] = { "John Fleck ", "Sebastian Heinlein ", "James Henstridge ", - "Mihai T Lazarescu ", + "Chris Lahey ", + "Mihai T Lazarescu ", "Sebastian Kapfer ", "Tomasz Koczko ", "Jordi Mallach ", diff --git a/src/notification.c b/src/notification.c index 63b15116..0a723854 100644 --- a/src/notification.c +++ b/src/notification.c @@ -75,6 +75,7 @@ zenity_notification_icon_press_callback (GtkWidget *widget, GdkEventButton *even zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); + return TRUE; } static gboolean @@ -102,7 +103,7 @@ zenity_notification_icon_expose_callback (GtkWidget *widget, GdkEventExpose *eve return FALSE; } -static gboolean +static void zenity_notification_icon_destroy_callback (GtkWidget *widget, gpointer data) { ZenityData *zen_data; diff --git a/src/option.c b/src/option.c index 65b5373c..cfc95e95 100644 --- a/src/option.c +++ b/src/option.c @@ -676,7 +676,8 @@ zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) for (i = 1; entries[i].long_name != NULL; i++) { if (entries[i].arg_data == arg_data) return (gchar *) entries[i].long_name; - } + } + return NULL; } /* Error callback */ -- cgit From 717b814028ea3ade38710d32b561af46615358b9 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Sun, 6 Feb 2005 23:13:16 +0000 Subject: Update docs to add the new goption help stuff. Update to be in line with 2005-02-07 Glynn Foster * help/C/zenity.xml: Update docs to add the new goption help stuff. * src/option.c: Update to be in line with the documentation descriptions. --- src/option.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index cfc95e95..603ce04b 100644 --- a/src/option.c +++ b/src/option.c @@ -1257,8 +1257,8 @@ zenity_create_context (void) /* Adds notification option entries */ a_group = g_option_group_new("notification", - N_("Notification options"), - N_("Show notification options"), NULL, 0); + N_("Notification icon options"), + N_("Show notification icon options"), NULL, 0); g_option_group_add_entries(a_group, notification_options); g_option_group_set_parse_hooks (a_group, zenity_notification_pre_callback, zenity_notification_post_callback); @@ -1296,9 +1296,9 @@ zenity_create_context (void) g_option_context_add_group(tmp_ctx, a_group); /* Adds text option entries */ - a_group = g_option_group_new("text", - N_("Text options"), - N_("Show text options"), NULL, 0); + a_group = g_option_group_new("text-info", + N_("Text information options"), + N_("Show text information options"), NULL, 0); g_option_group_add_entries(a_group, text_options); g_option_group_set_parse_hooks (a_group, zenity_text_pre_callback, zenity_text_post_callback); -- cgit From 6bac2fb94750123b9cbadc337d1434daf80c9889 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 7 Feb 2005 01:56:02 +0000 Subject: If auto-close, close the dialog when the input stream finds an EOF. 2005-02-07 Glynn Foster * src/progress.c: If auto-close, close the dialog when the input stream finds an EOF. --- src/progress.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 734dd732..dfe9cef1 100644 --- a/src/progress.c +++ b/src/progress.c @@ -152,6 +152,11 @@ zenity_progress_handle_stdin (GIOChannel *channel, if (glade_dialog) g_object_unref (glade_dialog); + if (progress_data->autoclose) { + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit(); + } + g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } -- cgit From a197b56c07a7ae337901ffe3f3d404fe840480f7 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 16 Feb 2005 10:28:11 +0000 Subject: Fix bug #167577, that leaks a seperator. Patch from Paolo Borelli 2005-02-16 Glynn Foster * src/fileselection.c, THANKS, src/about.c: Fix bug #167577, that leaks a seperator. Patch from Paolo Borelli --- src/about.c | 1 + src/fileselection.c | 5 +---- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index afcdec13..a849f864 100644 --- a/src/about.c +++ b/src/about.c @@ -57,6 +57,7 @@ static const gchar *author_credits[] = { "Peter Astrand ", "Jonathan Blandford ", "Paul Bolle ", + "Paolo Borelli ", "Leonardo Boshell

", "Ross Burton ", "Damien Carbery ", diff --git a/src/fileselection.c b/src/fileselection.c index 4d50fb76..69304374 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -85,7 +85,6 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer { ZenityFileData *file_data = data; GSList *selections, *iter; - gchar *separator = g_strdup(file_data->separator); int i; switch (response) { @@ -96,12 +95,10 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); g_free (iter->data); if (iter->next != NULL) - g_print ("%s",separator); + g_print ("%s",file_data->separator); } g_print("\n"); g_slist_free(selections); - g_free(separator); - break; case GTK_RESPONSE_CANCEL: -- cgit From d4d23da5a74c11c1db0ff86862f25b6964479a96 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 16 Feb 2005 10:32:15 +0000 Subject: Fix leak in ZENITY_IMAGE_FULLPATH. Fixes #167518, hopefully. 2005-02-16 Glynn Foster * src/util.h: Fix leak in ZENITY_IMAGE_FULLPATH. Fixes #167518, hopefully. --- src/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/util.h b/src/util.h index 4e3c2142..cbf96ab1 100644 --- a/src/util.h +++ b/src/util.h @@ -9,7 +9,7 @@ G_BEGIN_DECLS #define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" #define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" -#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL)) +#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename) GladeXML* zenity_util_load_glade_file (const gchar *widget_root); gchar * zenity_util_strip_newline (gchar *string); -- cgit From 6e6eeaf79c01b6cc755b57dac7e7ff2d36038316 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 20 Apr 2005 01:59:42 +0000 Subject: Bug fix for #149290, based on contributions from Timo Aaltonen, Lucas 2005-04-20 Glynn Foster * src/msg.c, src/option.c, src/zenity.h: Bug fix for #149290, based on contributions from Timo Aaltonen, Lucas Rocha, and Carlos Parra. * THANKS: Update. --- src/msg.c | 3 +++ src/option.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 1 + 3 files changed, 50 insertions(+) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index ffb2e531..2449c007 100644 --- a/src/msg.c +++ b/src/msg.c @@ -110,6 +110,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); + if (msg_data->no_wrap) + gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/option.c b/src/option.c index 603ce04b..08359120 100644 --- a/src/option.c +++ b/src/option.c @@ -34,6 +34,7 @@ gchar *zenity_general_dialog_text; gchar *zenity_general_separator; gboolean zenity_general_editable; gchar *zenity_general_uri; +gboolean zenity_general_dialog_no_wrap; /* Calendar Dialog Options */ gboolean zenity_calendar_active; @@ -253,6 +254,15 @@ GOptionEntry error_options[] = { N_("Set the dialog text"), NULL }, + { + "no-wrap", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_("Do not enable text wrapping"), + NULL + }, { NULL } @@ -277,6 +287,15 @@ GOptionEntry info_options[] = { N_("Set the dialog text"), NULL }, + { + "no-wrap", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_("Do not enable text wrapping"), + NULL + }, { NULL } @@ -524,6 +543,15 @@ GOptionEntry question_options[] = { N_("Set the dialog text"), NULL }, + { + "no-wrap", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_("Do not enable text wrapping"), + NULL + }, { NULL } @@ -581,6 +609,15 @@ GOptionEntry warning_options[] = { N_("Set the dialog text"), NULL }, + { + "no-wrap", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_("Do not enable text wrapping"), + NULL + }, { NULL } @@ -705,6 +742,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_separator = g_strdup ("|"); zenity_general_editable = FALSE; zenity_general_uri = NULL; + zenity_general_dialog_no_wrap = FALSE; return TRUE; } @@ -966,6 +1004,7 @@ zenity_error_post_callback (GOptionContext *context, if (results->mode == MODE_ERROR) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_ERROR; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; } return TRUE; @@ -982,6 +1021,7 @@ zenity_info_post_callback (GOptionContext *context, if (results->mode == MODE_INFO) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_INFO; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; } return TRUE; @@ -1128,6 +1168,7 @@ zenity_question_post_callback (GOptionContext *context, if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_QUESTION; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; } return TRUE; @@ -1160,6 +1201,7 @@ zenity_warning_post_callback (GOptionContext *context, if (results->mode == MODE_WARNING) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_WARNING; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; } return TRUE; @@ -1377,5 +1419,9 @@ zenity_option_parse (gint argc, gchar **argv) if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); + if (zenity_general_dialog_no_wrap) + if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) + zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); + return results; } diff --git a/src/zenity.h b/src/zenity.h index 0e869716..0f821a4a 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -57,6 +57,7 @@ typedef enum { typedef struct { gchar *dialog_text; MsgMode mode; + gboolean no_wrap; } ZenityMsgData; typedef struct { -- cgit From 403c8104aefc11954398106ab4fa39f9a79233c6 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Wed, 20 Apr 2005 03:00:57 +0000 Subject: Clean up the code a little bit. 2005-04-20 Glynn Foster * src/entry.c, src/option.c, src/zenity.h: Clean up the code a little bit. --- src/entry.c | 5 +++-- src/option.c | 14 +++++++------- src/zenity.h | 2 +- 3 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 46672f82..2d92f2d4 100644 --- a/src/entry.c +++ b/src/entry.c @@ -72,12 +72,13 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - if (!entry_data->visible) - g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL); + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); zenity_util_show_dialog (dialog); + gtk_main (); } diff --git a/src/option.c b/src/option.c index 08359120..44fd74a5 100644 --- a/src/option.c +++ b/src/option.c @@ -46,7 +46,7 @@ gchar *zenity_calendar_date_format; /* Entry Dialog Options */ gboolean zenity_entry_active; gchar *zenity_entry_entry_text; -gboolean zenity_entry_visible; +gboolean zenity_entry_hide_text; /* Error Dialog Options */ gboolean zenity_error_active; @@ -225,7 +225,7 @@ GOptionEntry entry_options[] = { '\0', 0, G_OPTION_ARG_NONE, - &zenity_entry_visible, + &zenity_entry_hide_text, N_("Hide the entry text"), NULL }, @@ -770,7 +770,7 @@ zenity_entry_pre_callback (GOptionContext *context, { zenity_entry_active = FALSE; zenity_entry_entry_text = NULL; - zenity_entry_visible = FALSE; + zenity_entry_hide_text = FALSE; return TRUE; } @@ -979,14 +979,14 @@ zenity_entry_post_callback (GOptionContext *context, if (results->mode == MODE_ENTRY) { results->entry_data->dialog_text = zenity_general_dialog_text; results->entry_data->entry_text = zenity_entry_entry_text; - results->entry_data->visible = !zenity_entry_visible; + results->entry_data->hide_text= zenity_entry_hide_text; } else { if (zenity_entry_entry_text) zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_entry_text), ERROR_SUPPORT); - if (zenity_entry_visible) - zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_visible), + if (zenity_entry_hide_text) + zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_hide_text), ERROR_SUPPORT); } @@ -1373,7 +1373,7 @@ zenity_option_error (gchar *string, ZenityError error) { switch (error) { case ERROR_SYNTAX: - g_printerr (_("Syntax error\n")); + g_printerr (_("This option is not available. Please see --help for all possible usages.\n")); zenity_option_free (); exit (-1); case ERROR_SUPPORT: diff --git a/src/zenity.h b/src/zenity.h index 0f821a4a..7ab47cb4 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -71,7 +71,7 @@ typedef struct { typedef struct { gchar *dialog_text; gchar *entry_text; - gboolean visible; + gboolean hide_text; } ZenityEntryData; typedef struct { -- cgit From 6d386ddda5e4552aeda28b104242626ff05b10c5 Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Thu, 21 Apr 2005 00:56:05 +0000 Subject: Fix for #171838, from Carlos Parra. 2005-04-20 Glynn Foster * src/fileselection.c: Fix for #171838, from Carlos Parra. --- src/fileselection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 69304374..4e51eec2 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -64,7 +64,10 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + + if (g_path_is_absolute (file_data->uri) == TRUE) + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { basename = g_path_get_basename (file_data->uri); gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); -- cgit From 6abd93050f533752e47b75158e95431575c652ac Mon Sep 17 00:00:00 2001 From: Glynn Foster Date: Mon, 25 Apr 2005 03:20:45 +0000 Subject: COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c, 2005-04-25 Glynn Foster * COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, * src/entry.c, src/fileselection.c, src/main.c, src/msg.c, * src/notification.c, src/option.c, src/progress.c, * src/text.c, src/tree.c, src/util.c: Update the FSF address to point to 51 Franklin Street, Fifth Floor as per forwarded mail from Alvaro Lopez Ortega. --- src/about.c | 4 ++-- src/calendar.c | 4 ++-- src/eggtrayicon.c | 4 ++-- src/entry.c | 4 ++-- src/fileselection.c | 4 ++-- src/main.c | 4 ++-- src/msg.c | 4 ++-- src/notification.c | 4 ++-- src/option.c | 4 ++-- src/progress.c | 4 ++-- src/text.c | 4 ++-- src/tree.c | 4 ++-- src/util.c | 4 ++-- 13 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index a849f864..49fdc75f 100644 --- a/src/about.c +++ b/src/about.c @@ -17,8 +17,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster * Anders Carlsson diff --git a/src/calendar.c b/src/calendar.c index 8bffed8e..248f3b8d 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/eggtrayicon.c b/src/eggtrayicon.c index c4aa3e6e..1e6d5bdd 100644 --- a/src/eggtrayicon.c +++ b/src/eggtrayicon.c @@ -14,8 +14,8 @@ * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. */ #include diff --git a/src/entry.c b/src/entry.c index 2d92f2d4..db5b3fe8 100644 --- a/src/entry.c +++ b/src/entry.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/fileselection.c b/src/fileselection.c index 4e51eec2..b2144a15 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/main.c b/src/main.c index b79afc06..09330d55 100644 --- a/src/main.c +++ b/src/main.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/msg.c b/src/msg.c index 2449c007..0c46c362 100644 --- a/src/msg.c +++ b/src/msg.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/notification.c b/src/notification.c index 0a723854..8aa0d917 100644 --- a/src/notification.c +++ b/src/notification.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/option.c b/src/option.c index 44fd74a5..33a185f5 100644 --- a/src/option.c +++ b/src/option.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster * Lucas Rocha diff --git a/src/progress.c b/src/progress.c index dfe9cef1..8d7b1dbe 100644 --- a/src/progress.c +++ b/src/progress.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/text.c b/src/text.c index acd17394..9923cce9 100644 --- a/src/text.c +++ b/src/text.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster */ diff --git a/src/tree.c b/src/tree.c index 63fe4aee..b50a755b 100644 --- a/src/tree.c +++ b/src/tree.c @@ -15,8 +15,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster * Jonathan Blanford diff --git a/src/util.c b/src/util.c index ff7d18b3..9861e411 100644 --- a/src/util.c +++ b/src/util.c @@ -18,8 +18,8 @@ * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. * * Authors: Glynn Foster * Havoc Pennington -- cgit From 14c0bf10c84cf576135c9fdb1e549351ebf5e27c Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Fri, 17 Jun 2005 03:18:41 +0000 Subject: Don't use the parent widget for hiding tray icon --- src/notification.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 8aa0d917..509d2f8e 100644 --- a/src/notification.c +++ b/src/notification.c @@ -184,12 +184,9 @@ zenity_notification_handle_stdin (GIOChannel *channel, gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); } else if (!strcmp (command, "visible")) { if (!strcasecmp (value, "false")) { - /* We need to get the parent, because just hiding the tray_icon - * doesn't save on space. See #161539 for details - */ - gtk_widget_hide (gtk_widget_get_parent (GTK_WIDGET (tray_icon))); + gtk_widget_hide (GTK_WIDGET (tray_icon)); } else { - gtk_widget_show (gtk_widget_get_parent (GTK_WIDGET (tray_icon))); + gtk_widget_show (GTK_WIDGET (tray_icon)); } } else { g_warning ("Unknown command '%s'", command); -- cgit From 9c792cb86a8d0422a07a716a3b024f25d9bca1bb Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Mon, 27 Jun 2005 03:13:37 +0000 Subject: Changed list dialog Selection behavior --- src/option.c | 26 ++++++++++++++++++-------- src/tree.c | 13 +++++++++++-- src/zenity.h | 1 + 3 files changed, 30 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 33a185f5..a1674883 100644 --- a/src/option.c +++ b/src/option.c @@ -32,6 +32,7 @@ int zenity_general_width; int zenity_general_height; gchar *zenity_general_dialog_text; gchar *zenity_general_separator; +gboolean zenity_general_multiple; gboolean zenity_general_editable; gchar *zenity_general_uri; gboolean zenity_general_dialog_no_wrap; @@ -56,7 +57,6 @@ gboolean zenity_info_active; /* File Selection Dialog Options */ gboolean zenity_file_active; -gboolean zenity_file_multiple; gboolean zenity_file_directory; gboolean zenity_file_save; @@ -325,7 +325,7 @@ GOptionEntry file_selection_options[] = { '\0', 0, G_OPTION_ARG_NONE, - &zenity_file_multiple, + &zenity_general_multiple, N_("Allow multiple files to be selected"), NULL }, @@ -416,6 +416,15 @@ GOptionEntry list_options[] = { N_("Set output separator character"), N_("SEPARATOR") }, + { + "multiple", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_general_multiple, + N_("Allow multiple rows to be selected"), + NULL + }, { "editable", '\0', @@ -740,6 +749,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_height = -1; zenity_general_dialog_text = NULL; zenity_general_separator = g_strdup ("|"); + zenity_general_multiple = FALSE; zenity_general_editable = FALSE; zenity_general_uri = NULL; zenity_general_dialog_no_wrap = FALSE; @@ -804,7 +814,6 @@ zenity_file_pre_callback (GOptionContext *context, GError **error) { zenity_file_active = FALSE; - zenity_file_multiple = FALSE; zenity_file_directory = FALSE; zenity_file_save = FALSE; @@ -1037,15 +1046,11 @@ zenity_file_post_callback (GOptionContext *context, if (results->mode == MODE_FILE) { results->file_data->uri = zenity_general_uri; - results->file_data->multi = zenity_file_multiple; + results->file_data->multi = zenity_general_multiple; results->file_data->directory = zenity_file_directory; results->file_data->save = zenity_file_save; results->file_data->separator = zenity_general_separator; } else { - if (zenity_file_multiple) - zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_multiple), - ERROR_SUPPORT); - if (zenity_file_directory) zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory), ERROR_SUPPORT); @@ -1082,6 +1087,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->checkbox = zenity_list_checklist; results->tree_data->radiobox = zenity_list_radiolist; + results->tree_data->multi = zenity_general_multiple; results->tree_data->editable = zenity_general_editable; results->tree_data->print_column = zenity_list_print_column; results->tree_data->separator = zenity_general_separator; @@ -1411,6 +1417,10 @@ zenity_option_parse (gint argc, gchar **argv) if (results->mode != MODE_LIST && results->mode != MODE_FILE) zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT); + if (zenity_general_multiple) + if (results->mode != MODE_FILE && results->mode != MODE_LIST) + zenity_option_error (zenity_option_get_name (list_options, &zenity_general_multiple), ERROR_SUPPORT); + if (zenity_general_editable) if (results->mode != MODE_TEXTINFO && results->mode != MODE_LIST) zenity_option_error (zenity_option_get_name (list_options, &zenity_general_editable), ERROR_SUPPORT); diff --git a/src/tree.c b/src/tree.c index b50a755b..e60e262f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -354,8 +354,17 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_MULTIPLE); + if (!(tree_data->radiobox || tree_data->checkbox)) { + if (tree_data->multi) + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_MULTIPLE); + else + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_SINGLE); + } + else + gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_NONE); column_index = 0; diff --git a/src/zenity.h b/src/zenity.h index 7ab47cb4..0e1dba1b 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -94,6 +94,7 @@ typedef struct { gboolean checkbox; gboolean radiobox; gchar *separator; + gboolean multi; gboolean editable; gchar *print_column; const gchar **data; -- cgit From 5d584ca8ef032cecaf05fcc4ceca0db24e70ff16 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Mon, 27 Jun 2005 04:27:15 +0000 Subject: Double-clicking on list dialog --- src/about.c | 1 + src/tree.c | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 49fdc75f..b4d8bcb9 100644 --- a/src/about.c +++ b/src/about.c @@ -90,6 +90,7 @@ static const gchar *author_credits[] = { "Hidetoshi Tajima ", "Tom Tromey ", "Yann ", + "Norman Rasmussen ", "", "And all the translators that rock my world", "==========================================", diff --git a/src/tree.c b/src/tree.c index e60e262f..46b68c23 100644 --- a/src/tree.c +++ b/src/tree.c @@ -38,6 +38,8 @@ static gboolean print_all_columns = FALSE; static gint print_column_n = 1; static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, + GtkTreeViewColumn *tree_col, gpointer data); static gboolean zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) @@ -328,6 +330,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + if (!(tree_data->radiobox || tree_data->checkbox)) + g_signal_connect (G_OBJECT (tree_view), "row-activated", + G_CALLBACK (zenity_tree_row_activated), data); + /* Create an empty list store */ model = g_object_new (GTK_TYPE_LIST_STORE, NULL); @@ -584,3 +590,23 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) } gtk_main_quit (); } + +static void +zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, + GtkTreeViewColumn *tree_col, gpointer data) +{ + ZenityData *zen_data = data; + GtkTreeSelection *selection; + GtkTreeModel *model; + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, + GTK_TREE_VIEW (tree_view)); + + zenity_tree_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); +} -- cgit From cc3fc2be3ea3f322ca53b13b82dc9e73a44e58b2 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Tue, 28 Jun 2005 04:43:10 +0000 Subject: Error handling when trying to use checklist and radiolist in the same List dialog --- src/tree.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 46b68c23..0e213d5f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -308,6 +308,12 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } + if (tree_data->checkbox && tree_data->radiobox) { + g_printerr (_("You should use only one List dialog type.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); -- cgit From c9be8d057942521381c3e3a7d76c374d02b88dbf Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Tue, 28 Jun 2005 11:11:50 +0000 Subject: New --print-column syntax. Now it's possible to pass a comma-separated list of column indexes. --- src/tree.c | 60 ++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 0e213d5f..1a0d35d1 100644 --- a/src/tree.c +++ b/src/tree.c @@ -30,12 +30,13 @@ #include "util.h" #define MAX_ELEMENTS_BEFORE_SCROLLING 5 +#define PRINT_HIDE_COLUMN_SEPARATOR "," static GladeXML *glade_dialog; static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; -static gint print_column_n = 1; +static char **print_columns = NULL; static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, @@ -146,11 +147,11 @@ zenity_tree_handle_stdin (GIOChannel *channel, if (toggles && column_count == 0) { if (strcmp (g_strdown (zenity_util_strip_newline (string->str)), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); - else + else gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); } else { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1); } if (editable) { @@ -220,15 +221,15 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, gtk_list_store_append (GTK_LIST_STORE (model), &iter); for (j = 0; j < n_columns; j++) { - + if (toggles && j == 0) { if (strcmp (g_strdown ((gchar *) args[i+j]), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); - else + else gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); } else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); } if (editable) @@ -299,7 +300,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (strcmp (g_strdown (tree_data->print_column), "all") == 0) print_all_columns = TRUE; else - print_column_n = atoi (tree_data->print_column); + print_columns = g_strsplit (tree_data->print_column, + PRINT_HIDE_COLUMN_SEPARATOR, 0); + } + else { + print_columns = (char **) g_new (char**, 2); + print_columns[0] = g_strdup ("1"); + print_columns[1] = NULL; } if (n_columns == 0) { @@ -327,7 +334,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) text = glade_xml_get_widget (glade_dialog, "zenity_tree_text"); if (tree_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text); + gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text); zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); @@ -386,13 +393,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) GtkCellRenderer *cell_renderer; cell_renderer = gtk_cell_renderer_toggle_new (); - + if (tree_data->radiobox) { g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); g_object_set_data (G_OBJECT (model), "radio", (gint *) 1); } - g_signal_connect (cell_renderer, "toggled", + g_signal_connect (cell_renderer, "toggled", G_CALLBACK (zenity_tree_toggled_callback), model); column = gtk_tree_view_column_new_with_attributes (tmp->data, @@ -425,7 +432,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); } - + first_column = TRUE; } else { @@ -453,7 +460,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); } - + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); column_index++; } @@ -484,7 +491,7 @@ static void zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue value = {0, }; - gint n_columns, i; + gint n_columns, print_column, i; n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -498,11 +505,15 @@ zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, Gtk return; } - if (print_column_n > 0 && print_column_n <= n_columns) { - gtk_tree_model_get_value (model, iter, print_column_n - 1, &value); + for (i = 0; print_columns[i] != NULL; i++) { + print_column = atoi (print_columns[i]); + + if (print_column > 0 && print_column <= n_columns) { + gtk_tree_model_get_value (model, iter, print_column - 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } } } @@ -510,7 +521,7 @@ static gboolean zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue toggle_value = {0, }; - gint n_columns, i; + gint n_columns, print_column, i; n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -530,11 +541,15 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, return FALSE; } - if (print_column_n > 0 && print_column_n <= n_columns) { - gtk_tree_model_get_value (model, iter, print_column_n, &value); + for (i = 0; print_columns[i] != NULL; i++) { + print_column = atoi (print_columns[i]); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); + if (print_column > 0 && print_column <= n_columns) { + gtk_tree_model_get_value (model, iter, print_column, &value); + + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); + } } } g_value_unset (&toggle_value); @@ -554,6 +569,7 @@ zenity_tree_dialog_output (void) g_print ("%s\n", (gchar *) tmp->data); } + g_strfreev (print_columns); g_free (separator); g_slist_foreach (selected, (GFunc) g_free, NULL); selected = NULL; -- cgit From da0a2585b3dce693eb1961fdc64ffcb3840a1bba Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Thu, 30 Jun 2005 23:43:23 +0000 Subject: Data structure improvements on List dialogs. --- src/tree.c | 72 ++++++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 47 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 1a0d35d1..ea2ba9e4 100644 --- a/src/tree.c +++ b/src/tree.c @@ -36,8 +36,9 @@ static GladeXML *glade_dialog; static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; -static char **print_columns = NULL; +static gint *print_columns = NULL; +static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *tree_col, gpointer data); @@ -299,14 +300,13 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (tree_data->print_column) { if (strcmp (g_strdown (tree_data->print_column), "all") == 0) print_all_columns = TRUE; - else - print_columns = g_strsplit (tree_data->print_column, - PRINT_HIDE_COLUMN_SEPARATOR, 0); + else + print_columns = zenity_tree_extract_column_indexes (tree_data->print_column, n_columns); } else { - print_columns = (char **) g_new (char**, 2); - print_columns[0] = g_strdup ("1"); - print_columns[1] = NULL; + print_columns = g_new (gint, 2); + print_columns[0] = 1; + print_columns[1] = 0; } if (n_columns == 0) { @@ -491,7 +491,7 @@ static void zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue value = {0, }; - gint n_columns, print_column, i; + gint n_columns, i; n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -505,15 +505,11 @@ zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, Gtk return; } - for (i = 0; print_columns[i] != NULL; i++) { - print_column = atoi (print_columns[i]); - - if (print_column > 0 && print_column <= n_columns) { - gtk_tree_model_get_value (model, iter, print_column - 1, &value); + for (i = 0; print_columns[i] != 0; i++) { + gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); - } + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); } } @@ -541,18 +537,16 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, return FALSE; } - for (i = 0; print_columns[i] != NULL; i++) { - print_column = atoi (print_columns[i]); + for (i = 0; print_columns[i] != 0; i++) { + gtk_tree_model_get_value (model, iter, print_columns[i], &value); - if (print_column > 0 && print_column <= n_columns) { - gtk_tree_model_get_value (model, iter, print_column, &value); - - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); - g_value_unset (&value); - } + selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + g_value_unset (&value); } } + g_value_unset (&toggle_value); + return FALSE; } @@ -569,7 +563,7 @@ zenity_tree_dialog_output (void) g_print ("%s\n", (gchar *) tmp->data); } - g_strfreev (print_columns); + g_free (print_columns); g_free (separator); g_slist_foreach (selected, (GFunc) g_free, NULL); selected = NULL; @@ -632,3 +626,31 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); } + +static gint * +zenity_tree_extract_column_indexes (char *indexes, int n_columns) +{ + char **tmp; + gint *result; + gint i, j, index; + + tmp = g_strsplit (indexes, + PRINT_HIDE_COLUMN_SEPARATOR, 0); + + result = g_new (gint, 1); + + for (j = i = 0; tmp[i] != NULL; i++) { + index = atoi (tmp[i]); + + if (index > 0 && index <= n_columns) { + result[j] = index; + j++; + g_renew (gint, result, j + 1); + } + } + result[j] = 0; + + g_strfreev (tmp); + + return result; +} -- cgit From 8ba040f33b37ef92976b75be79a1a342bceb91f9 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Fri, 1 Jul 2005 21:28:36 +0000 Subject: New --hide-column option. --- src/option.c | 18 ++++++++++++++++++ src/tree.c | 40 ++++++++++++++++++++++++++++++++-------- src/zenity.h | 1 + 3 files changed, 51 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index a1674883..b4d35bca 100644 --- a/src/option.c +++ b/src/option.c @@ -66,6 +66,7 @@ gchar **zenity_list_columns; gboolean zenity_list_checklist; gboolean zenity_list_radiolist; gchar *zenity_list_print_column; +gchar *zenity_list_hide_column; /* Notification Dialog Options */ gboolean zenity_notification_active; @@ -443,6 +444,15 @@ GOptionEntry list_options[] = { N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), NULL }, + { + "hide-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_list_hide_column, + N_("Hide a specific column"), + NULL + }, { NULL } @@ -699,6 +709,8 @@ zenity_option_free (void) { g_strfreev (zenity_list_columns); if (zenity_list_print_column) g_free (zenity_list_print_column); + if (zenity_list_hide_column) + g_free (zenity_list_hide_column); g_option_context_free (ctx); } @@ -831,6 +843,7 @@ zenity_list_pre_callback (GOptionContext *context, zenity_list_checklist = FALSE; zenity_list_radiolist = FALSE; zenity_list_print_column = NULL; + zenity_list_hide_column = NULL; return TRUE; } @@ -1090,6 +1103,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->multi = zenity_general_multiple; results->tree_data->editable = zenity_general_editable; results->tree_data->print_column = zenity_list_print_column; + results->tree_data->hide_column = zenity_list_hide_column; results->tree_data->separator = zenity_general_separator; } else { if (zenity_list_columns) @@ -1107,6 +1121,10 @@ zenity_list_post_callback (GOptionContext *context, if (zenity_list_print_column) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column), ERROR_SUPPORT); + + if (zenity_list_hide_column) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column), + ERROR_SUPPORT); } return TRUE; diff --git a/src/tree.c b/src/tree.c index ea2ba9e4..57e81285 100644 --- a/src/tree.c +++ b/src/tree.c @@ -37,8 +37,10 @@ static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; static gint *print_columns = NULL; +static gint *hide_columns = NULL; static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); +static gboolean zenity_tree_column_is_hidden (gint column_index); static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *tree_col, gpointer data); @@ -309,6 +311,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) print_columns[1] = 0; } + if (tree_data->hide_column) + hide_columns = zenity_tree_extract_column_indexes (tree_data->hide_column, n_columns); + if (n_columns == 0) { g_printerr (_("No column titles specified for List dialog.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); @@ -421,18 +426,20 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) "text", column_index, "editable", n_columns, NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, - NULL); - } + } + else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", column_index, + NULL); + } gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); } - + if (zenity_tree_column_is_hidden (1)) + gtk_tree_view_column_set_visible (column, FALSE); + first_column = TRUE; } else { @@ -459,6 +466,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_column_set_sort_column_id (column, column_index); gtk_tree_view_column_set_resizable (column, TRUE); + + if (zenity_tree_column_is_hidden (column_index + 1)) + gtk_tree_view_column_set_visible (column, FALSE); } gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); @@ -564,6 +574,7 @@ zenity_tree_dialog_output (void) } g_free (print_columns); + g_free (hide_columns); g_free (separator); g_slist_foreach (selected, (GFunc) g_free, NULL); selected = NULL; @@ -627,6 +638,19 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, gtk_main_quit (); } +static gboolean +zenity_tree_column_is_hidden (gint column_index) +{ + gint i; + + if (hide_columns != NULL) + for (i = 0; hide_columns[i] != 0; i++) + if (hide_columns[i] == column_index) + return TRUE; + + return FALSE; +} + static gint * zenity_tree_extract_column_indexes (char *indexes, int n_columns) { diff --git a/src/zenity.h b/src/zenity.h index 0e1dba1b..b224abd9 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -97,6 +97,7 @@ typedef struct { gboolean multi; gboolean editable; gchar *print_column; + gchar *hide_column; const gchar **data; } ZenityTreeData; -- cgit From c23ba6a523c812e4e31aa2556f7b67250e3dc92b Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Mon, 4 Jul 2005 17:30:29 +0000 Subject: Translation contributors update. --- src/about.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index b4d8bcb9..14022bdd 100644 --- a/src/about.c +++ b/src/about.c @@ -169,6 +169,17 @@ static const gchar *author_credits[] = { "Daniel Yacob ", "Funda Wang ", "Alexander Winston ", + "Theppitak Karoonboonyanan ", + "Martin Willemoes Hansen ", + "Ignacio Casal Quinteiro ", + "Pawan Chitrakar ", + "Rajesh Ranjan ", + "Vladimir Petkov ", + "Abduxukur Abdurixit ", + "Adi Attar ", + "Steve Murphy ", + "Josep Puigdemont ", + "Adam Weinberger ", NULL }; -- cgit From 4c328078b6ff16a0ba648f53c3bee7a68fe4dbc5 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Wed, 6 Jul 2005 20:13:11 +0000 Subject: Include cleanups (config.h) --- src/calendar.c | 2 ++ src/entry.c | 2 ++ src/fileselection.c | 3 +++ src/msg.c | 2 ++ src/notification.c | 3 +++ src/option.c | 4 ++++ src/progress.c | 2 ++ src/text.c | 2 ++ src/tree.c | 2 ++ src/util.c | 2 ++ 10 files changed, 24 insertions(+) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 248f3b8d..7e9eb9ca 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include #include "zenity.h" diff --git a/src/entry.c b/src/entry.c index db5b3fe8..e8c25857 100644 --- a/src/entry.c +++ b/src/entry.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include "zenity.h" #include "util.h" diff --git a/src/fileselection.c b/src/fileselection.c index b2144a15..95178ec7 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -21,7 +21,10 @@ * Authors: Glynn Foster */ +#include "config.h" + #include +#include #include "zenity.h" #include "util.h" diff --git a/src/msg.c b/src/msg.c index 0c46c362..b400f0bd 100644 --- a/src/msg.c +++ b/src/msg.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include "zenity.h" #include "util.h" diff --git a/src/notification.c b/src/notification.c index 509d2f8e..26600cb3 100644 --- a/src/notification.c +++ b/src/notification.c @@ -21,8 +21,11 @@ * Authors: Glynn Foster */ +#include + #include #include +#include #include "zenity.h" #include "eggtrayicon.h" #include "util.h" diff --git a/src/option.c b/src/option.c index b4d35bca..69c83dda 100644 --- a/src/option.c +++ b/src/option.c @@ -22,8 +22,12 @@ * Lucas Rocha */ +#include "config.h" + #include "option.h" #include +#include +#include /* General Options */ gchar *zenity_general_dialog_title; diff --git a/src/progress.c b/src/progress.c index 8d7b1dbe..d92d2e2d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include #include diff --git a/src/text.c b/src/text.c index 9923cce9..151e000e 100644 --- a/src/text.c +++ b/src/text.c @@ -21,6 +21,8 @@ * Authors: Glynn Foster */ +#include "config.h" + #include #include "zenity.h" #include "util.h" diff --git a/src/tree.c b/src/tree.c index 57e81285..72a9b392 100644 --- a/src/tree.c +++ b/src/tree.c @@ -23,6 +23,8 @@ * Kristian Rietveld */ +#include "config.h" + #include #include #include diff --git a/src/util.c b/src/util.c index 9861e411..f503526e 100644 --- a/src/util.c +++ b/src/util.c @@ -27,6 +27,8 @@ * Tom Tromey */ +#include "config.h" + #include #include #include -- cgit From 0bc80a781d2b250fbde3ad6e66457efc66f79979 Mon Sep 17 00:00:00 2001 From: Lucas Almeida Rocha Date: Wed, 6 Jul 2005 20:22:58 +0000 Subject: Changelog fixes, THANKS update. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 14022bdd..5209f76c 100644 --- a/src/about.c +++ b/src/about.c @@ -91,6 +91,7 @@ static const gchar *author_credits[] = { "Tom Tromey ", "Yann ", "Norman Rasmussen ", + "Benoît Dejean ", "", "And all the translators that rock my world", "==========================================", -- cgit From d6f1d76768fe99c0f67545a9b6da98411733ffca Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 8 Jul 2005 13:39:27 +0000 Subject: marks static many functions and global variables. Contribution from MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-08 Lucas Rocha * src/about.c, src/option.c, src/fileselection.c: marks static many functions and global variables. Contribution from Benoît Dejean. --- src/about.c | 6 +- src/fileselection.c | 2 +- src/option.c | 179 ++++++++++++++++++++++++++-------------------------- 3 files changed, 94 insertions(+), 93 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 5209f76c..1b9d921b 100644 --- a/src/about.c +++ b/src/about.c @@ -45,7 +45,7 @@ static GtkWidget *cred_dialog; static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); /* Sync with the people in the THANKS file */ -static const gchar *author_credits[] = { +static const gchar *const author_credits[] = { "Authors", "=======", "Glynn Foster ", @@ -184,7 +184,7 @@ static const gchar *author_credits[] = { NULL }; -gchar *translator_credits; +static gchar *translator_credits; static gint zenity_move_clothes_event (GnomeCanvasItem *item, @@ -242,7 +242,7 @@ typedef struct gdouble x, y; } MonkClothes; -static MonkClothes monk_clothes[] = { +static const MonkClothes monk_clothes[] = { {"gnome-tshirt.png", 30.0, 20.0}, {"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 }, {"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0}, diff --git a/src/fileselection.c b/src/fileselection.c index 95178ec7..91c0a0f3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -28,7 +28,7 @@ #include "zenity.h" #include "util.h" -ZenityData *zen_data; +static ZenityData *zen_data; static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); diff --git a/src/option.c b/src/option.c index 69c83dda..1d47be81 100644 --- a/src/option.c +++ b/src/option.c @@ -30,72 +30,72 @@ #include /* General Options */ -gchar *zenity_general_dialog_title; -gchar *zenity_general_window_icon; -int zenity_general_width; -int zenity_general_height; -gchar *zenity_general_dialog_text; -gchar *zenity_general_separator; -gboolean zenity_general_multiple; -gboolean zenity_general_editable; -gchar *zenity_general_uri; -gboolean zenity_general_dialog_no_wrap; +static gchar *zenity_general_dialog_title; +static gchar *zenity_general_window_icon; +static int zenity_general_width; +static int zenity_general_height; +static gchar *zenity_general_dialog_text; +static gchar *zenity_general_separator; +static gboolean zenity_general_multiple; +static gboolean zenity_general_editable; +static gchar *zenity_general_uri; +static gboolean zenity_general_dialog_no_wrap; /* Calendar Dialog Options */ -gboolean zenity_calendar_active; -int zenity_calendar_day; -int zenity_calendar_month; -int zenity_calendar_year; -gchar *zenity_calendar_date_format; +static gboolean zenity_calendar_active; +static int zenity_calendar_day; +static int zenity_calendar_month; +static int zenity_calendar_year; +static gchar *zenity_calendar_date_format; /* Entry Dialog Options */ -gboolean zenity_entry_active; -gchar *zenity_entry_entry_text; -gboolean zenity_entry_hide_text; +static gboolean zenity_entry_active; +static gchar *zenity_entry_entry_text; +static gboolean zenity_entry_hide_text; /* Error Dialog Options */ -gboolean zenity_error_active; +static gboolean zenity_error_active; /* Info Dialog Options */ -gboolean zenity_info_active; +static gboolean zenity_info_active; /* File Selection Dialog Options */ -gboolean zenity_file_active; -gboolean zenity_file_directory; -gboolean zenity_file_save; +static gboolean zenity_file_active; +static gboolean zenity_file_directory; +static gboolean zenity_file_save; /* List Dialog Options */ -gboolean zenity_list_active; -gchar **zenity_list_columns; -gboolean zenity_list_checklist; -gboolean zenity_list_radiolist; -gchar *zenity_list_print_column; -gchar *zenity_list_hide_column; +static gboolean zenity_list_active; +static gchar **zenity_list_columns; +static gboolean zenity_list_checklist; +static gboolean zenity_list_radiolist; +static gchar *zenity_list_print_column; +static gchar *zenity_list_hide_column; /* Notification Dialog Options */ -gboolean zenity_notification_active; -gboolean zenity_notification_listen; +static gboolean zenity_notification_active; +static gboolean zenity_notification_listen; /* Progress Dialog Options */ -gboolean zenity_progress_active; -int zenity_progress_percentage; -gboolean zenity_progress_pulsate; -gboolean zenity_progress_auto_close; +static gboolean zenity_progress_active; +static int zenity_progress_percentage; +static gboolean zenity_progress_pulsate; +static gboolean zenity_progress_auto_close; /* Question Dialog Options */ -gboolean zenity_question_active; +static gboolean zenity_question_active; /* Text Dialog Options */ -gboolean zenity_text_active; +static gboolean zenity_text_active; /* Warning Dialog Options */ -gboolean zenity_warning_active; +static gboolean zenity_warning_active; /* Miscelaneus Options */ -gboolean zenity_misc_about; -gboolean zenity_misc_version; +static gboolean zenity_misc_about; +static gboolean zenity_misc_version; -GOptionEntry general_options[] = { +static GOptionEntry general_options[] = { { "title", '\0', @@ -137,7 +137,7 @@ GOptionEntry general_options[] = { } }; -GOptionEntry calendar_options[] = { +static GOptionEntry calendar_options[] = { { "calendar", '\0', @@ -197,7 +197,7 @@ GOptionEntry calendar_options[] = { } }; -GOptionEntry entry_options[] = { +static GOptionEntry entry_options[] = { { "entry", '\0', @@ -240,7 +240,7 @@ GOptionEntry entry_options[] = { }; -GOptionEntry error_options[] = { +static GOptionEntry error_options[] = { { "error", '\0', @@ -273,7 +273,7 @@ GOptionEntry error_options[] = { } }; -GOptionEntry info_options[] = { +static GOptionEntry info_options[] = { { "info", '\0', @@ -306,7 +306,7 @@ GOptionEntry info_options[] = { } }; -GOptionEntry file_selection_options[] = { +static GOptionEntry file_selection_options[] = { { "file-selection", '\0', @@ -366,7 +366,7 @@ GOptionEntry file_selection_options[] = { } }; -GOptionEntry list_options[] = { +static GOptionEntry list_options[] = { { "list", '\0', @@ -462,7 +462,7 @@ GOptionEntry list_options[] = { } }; -GOptionEntry notification_options[] = { +static GOptionEntry notification_options[] = { { "notification", '\0', @@ -495,7 +495,7 @@ GOptionEntry notification_options[] = { } }; -GOptionEntry progress_options[] = { +static GOptionEntry progress_options[] = { { "progress", '\0', @@ -547,7 +547,7 @@ GOptionEntry progress_options[] = { } }; -GOptionEntry question_options[] = { +static GOptionEntry question_options[] = { { "question", '\0', @@ -580,7 +580,7 @@ GOptionEntry question_options[] = { } }; -GOptionEntry text_options[] = { +static GOptionEntry text_options[] = { { "text-info", '\0', @@ -613,7 +613,7 @@ GOptionEntry text_options[] = { } }; -GOptionEntry warning_options[] = { +static GOptionEntry warning_options[] = { { "warning", '\0', @@ -646,7 +646,7 @@ GOptionEntry warning_options[] = { } }; -GOptionEntry miscellaneous_options[] = { +static GOptionEntry miscellaneous_options[] = { { "about", '\0', @@ -670,10 +670,10 @@ GOptionEntry miscellaneous_options[] = { } }; -ZenityParsingOptions *results; -GOptionContext *ctx; +static ZenityParsingOptions *results; +static GOptionContext *ctx; -void +static void zenity_option_init (void) { results = g_new0 (ZenityParsingOptions, 1); @@ -719,7 +719,7 @@ zenity_option_free (void) { g_option_context_free (ctx); } -void +static void zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) { if (is_active == TRUE) { @@ -730,7 +730,7 @@ zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) } } -gchar * +static gchar * zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) { int i; @@ -743,17 +743,18 @@ zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) } /* Error callback */ -void zenity_option_error_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) +static void +zenity_option_error_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) { zenity_option_error (NULL, ERROR_SYNTAX); } /* Pre parse callbacks set the default option values */ -gboolean +static gboolean zenity_general_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -773,7 +774,7 @@ zenity_general_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_calendar_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -788,7 +789,7 @@ zenity_calendar_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_entry_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -801,7 +802,7 @@ zenity_entry_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_error_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -812,7 +813,7 @@ zenity_error_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_info_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -823,7 +824,7 @@ zenity_info_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_file_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -836,7 +837,7 @@ zenity_file_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_list_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -852,7 +853,7 @@ zenity_list_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -864,7 +865,7 @@ zenity_notification_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_progress_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -878,7 +879,7 @@ zenity_progress_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_question_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -889,7 +890,7 @@ zenity_question_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_text_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -900,7 +901,7 @@ zenity_text_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_warning_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -911,7 +912,7 @@ zenity_warning_pre_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -926,7 +927,7 @@ zenity_misc_pre_callback (GOptionContext *context, /* Post parse callbacks assign the option values to parsing result and makes some post condition tests */ -gboolean +static gboolean zenity_general_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -940,7 +941,7 @@ zenity_general_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_calendar_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -994,7 +995,7 @@ zenity_calendar_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_entry_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1019,7 +1020,7 @@ zenity_entry_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_error_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1036,7 +1037,7 @@ zenity_error_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_info_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1053,7 +1054,7 @@ zenity_info_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_file_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1080,7 +1081,7 @@ zenity_file_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_list_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1134,7 +1135,7 @@ zenity_list_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_notification_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1154,7 +1155,7 @@ zenity_notification_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_progress_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1184,7 +1185,7 @@ zenity_progress_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_question_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1202,7 +1203,7 @@ zenity_question_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_text_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1218,7 +1219,7 @@ zenity_text_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_warning_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1235,7 +1236,7 @@ zenity_warning_post_callback (GOptionContext *context, return TRUE; } -gboolean +static gboolean zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group, gpointer data, @@ -1247,7 +1248,7 @@ zenity_misc_post_callback (GOptionContext *context, return TRUE; } -GOptionContext * +static GOptionContext * zenity_create_context (void) { GOptionContext *tmp_ctx; -- cgit From 21f7bc6a54636c749cf5514e091feb68cc88907b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 8 Jul 2005 23:21:34 +0000 Subject: general code cleanups. Contribution from Benoît Dejean. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2005-07-08 Lucas Rocha * src/about.c, src/calendar.c, src/fileselection.c, src/option.c, src/progress.c, src/text.c, src/tree.c, src/util.c: general code cleanups. Contribution from Benoît Dejean. --- src/about.c | 3 +-- src/calendar.c | 2 +- src/fileselection.c | 1 - src/option.c | 2 -- src/progress.c | 1 - src/text.c | 3 --- src/tree.c | 2 +- src/util.c | 2 +- 8 files changed, 4 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 1b9d921b..6522e3c8 100644 --- a/src/about.c +++ b/src/about.c @@ -255,7 +255,7 @@ zenity_create_clothes (GtkWidget *canvas_board) GdkPixbuf *pixbuf; GnomeCanvasItem *canvas_item; gchar *pixbuf_path; - gint i; + size_t i; for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) { pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL); @@ -557,7 +557,6 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - GError *error = NULL; switch (response) { case GTK_RESPONSE_OK: diff --git a/src/calendar.c b/src/calendar.c index 7e9eb9ca..f876c038 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -89,7 +89,7 @@ static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data; - gint day, month, year; + guint day, month, year; gchar time_string[128]; GDate *date = NULL; diff --git a/src/fileselection.c b/src/fileselection.c index 91c0a0f3..53859229 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -91,7 +91,6 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer { ZenityFileData *file_data = data; GSList *selections, *iter; - int i; switch (response) { case GTK_RESPONSE_OK: diff --git a/src/option.c b/src/option.c index 1d47be81..362751f2 100644 --- a/src/option.c +++ b/src/option.c @@ -947,8 +947,6 @@ zenity_calendar_post_callback (GOptionContext *context, gpointer data, GError **error) { - int i; - zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR); if (results->mode == MODE_CALENDAR) { diff --git a/src/progress.c b/src/progress.c index d92d2e2d..34779c12 100644 --- a/src/progress.c +++ b/src/progress.c @@ -33,7 +33,6 @@ #include "zenity.h" #include "util.h" -static guint timer; static GladeXML *glade_dialog; static ZenityData *zen_data; static GIOChannel *channel; diff --git a/src/text.c b/src/text.c index 151e000e..f3b331d4 100644 --- a/src/text.c +++ b/src/text.c @@ -39,9 +39,6 @@ zenity_text_handle_stdin (GIOChannel *channel, static GtkTextBuffer *buffer; gchar buf[1024]; - static GtkTextIter iter, end; - static gboolean first_time = FALSE; - gchar *str; gsize len; buffer = GTK_TEXT_BUFFER (data); diff --git a/src/tree.c b/src/tree.c index 72a9b392..d6621c32 100644 --- a/src/tree.c +++ b/src/tree.c @@ -529,7 +529,7 @@ static gboolean zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view) { GValue toggle_value = {0, }; - gint n_columns, print_column, i; + gint n_columns, i; n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); diff --git a/src/util.c b/src/util.c index f503526e..4fc7f8d4 100644 --- a/src/util.c +++ b/src/util.c @@ -320,7 +320,7 @@ transient_get_xterm_toplevel (void) while (xterm != None && !transient_is_toplevel (xterm)) { Window root, parent, *children; - int nchildren; + unsigned nchildren; XQueryTree (dpy, xterm, &root, &parent, &children, &nchildren); -- cgit From 68ab19d2c4567a6855fa3ca5f0c71ddc323cd32e Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 12 Jul 2005 13:46:50 +0000 Subject: activate option help translations in GOption. 2005-07-12 Lucas Rocha * src/option.c: activate option help translations in GOption. --- src/option.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 362751f2..574fd91d 100644 --- a/src/option.c +++ b/src/option.c @@ -1262,6 +1262,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_general_pre_callback, zenity_general_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds calendar option entries */ @@ -1272,6 +1273,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_calendar_pre_callback, zenity_calendar_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds entry option entries */ @@ -1282,6 +1284,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_entry_pre_callback, zenity_entry_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds error option entries */ @@ -1292,6 +1295,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_error_pre_callback, zenity_error_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds info option entries */ @@ -1302,6 +1306,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_info_pre_callback, zenity_info_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds file selection option entries */ @@ -1312,6 +1317,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_file_pre_callback, zenity_file_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds list option entries */ @@ -1322,6 +1328,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_list_pre_callback, zenity_list_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds notification option entries */ @@ -1332,6 +1339,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_notification_pre_callback, zenity_notification_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds progress option entries */ @@ -1342,6 +1350,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_progress_pre_callback, zenity_progress_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds question option entries */ @@ -1352,6 +1361,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_question_pre_callback, zenity_question_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds warning option entries */ @@ -1362,6 +1372,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_warning_pre_callback, zenity_warning_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds text option entries */ @@ -1372,6 +1383,7 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_text_pre_callback, zenity_text_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds misc option entries */ @@ -1382,10 +1394,12 @@ zenity_create_context (void) g_option_group_set_parse_hooks (a_group, zenity_misc_pre_callback, zenity_misc_post_callback); g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Adds gtk option entries */ a_group = gtk_get_option_group(TRUE); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); /* Enable help options */ -- cgit From beffc3f8a93dbd5d809690322043e074005a250b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 13 Jul 2005 03:28:15 +0000 Subject: dependency on glib >= 2.7.3 Add G_OPTION_FLAG_NOALIAS flag on options that 2005-07-12 Lucas Rocha * configure.in: dependency on glib >= 2.7.3 * src/option.c: Add G_OPTION_FLAG_NOALIAS flag on options that are present in more than on group. --- src/option.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 574fd91d..c8640f3f 100644 --- a/src/option.c +++ b/src/option.c @@ -150,7 +150,7 @@ static GOptionEntry calendar_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -210,7 +210,7 @@ static GOptionEntry entry_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -220,7 +220,7 @@ static GOptionEntry entry_options[] = { "entry-text", '\0', 0, - G_OPTION_ARG_STRING, + G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS, &zenity_entry_entry_text, N_("Set the entry text"), NULL @@ -253,7 +253,7 @@ static GOptionEntry error_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -262,7 +262,7 @@ static GOptionEntry error_options[] = { { "no-wrap", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_wrap, N_("Do not enable text wrapping"), @@ -286,7 +286,7 @@ static GOptionEntry info_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -295,7 +295,7 @@ static GOptionEntry info_options[] = { { "no-wrap", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_wrap, N_("Do not enable text wrapping"), @@ -319,7 +319,7 @@ static GOptionEntry file_selection_options[] = { { "filename", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_FILENAME, &zenity_general_uri, N_("Set the filename"), @@ -328,7 +328,7 @@ static GOptionEntry file_selection_options[] = { { "multiple", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_multiple, N_("Allow multiple files to be selected"), @@ -355,7 +355,7 @@ static GOptionEntry file_selection_options[] = { { "separator", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_separator, N_("Set output separator character"), @@ -379,7 +379,7 @@ static GOptionEntry list_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -424,7 +424,7 @@ static GOptionEntry list_options[] = { { "multiple", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_multiple, N_("Allow multiple rows to be selected"), @@ -433,7 +433,7 @@ static GOptionEntry list_options[] = { { "editable", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_editable, N_("Allow changes to text"), @@ -475,7 +475,7 @@ static GOptionEntry notification_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the notification text"), @@ -508,7 +508,7 @@ static GOptionEntry progress_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -560,7 +560,7 @@ static GOptionEntry question_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -569,7 +569,7 @@ static GOptionEntry question_options[] = { { "no-wrap", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_wrap, N_("Do not enable text wrapping"), @@ -593,7 +593,7 @@ static GOptionEntry text_options[] = { { "filename", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_FILENAME, &zenity_general_uri, N_("Open file"), @@ -602,7 +602,7 @@ static GOptionEntry text_options[] = { { "editable", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_editable, N_("Allow changes to text"), @@ -626,7 +626,7 @@ static GOptionEntry warning_options[] = { { "text", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), @@ -635,7 +635,7 @@ static GOptionEntry warning_options[] = { { "no-wrap", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_wrap, N_("Do not enable text wrapping"), -- cgit From 4b5cdda3c868bc7a20f52efd60e2db6575363c1b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 13 Jul 2005 04:04:09 +0000 Subject: Release 2.11.1 Add note about feature frozen-ness. Update. 2005-07-13 Lucas Rocha * configure.in: Release 2.11.1 * HACKING: Add note about feature frozen-ness. * NEWS, THANKS, src/about.c: Update. --- src/about.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 6522e3c8..c2c9e634 100644 --- a/src/about.c +++ b/src/about.c @@ -181,6 +181,9 @@ static const gchar *const author_credits[] = { "Steve Murphy ", "Josep Puigdemont ", "Adam Weinberger ", + "Ivar Smolin ", + "Jens Seidel ", + "Benoît Dejean ", NULL }; -- cgit From 47a2e0479af9694840d2c3d352213bdb13d78b9a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 26 Jul 2005 03:12:09 +0000 Subject: Release 2.11.90 Update. 2005-07-25 Lucas Rocha * configure.in: Release 2.11.90 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index c2c9e634..5bb772df 100644 --- a/src/about.c +++ b/src/about.c @@ -184,6 +184,9 @@ static const gchar *const author_credits[] = { "Ivar Smolin ", "Jens Seidel ", "Benoît Dejean ", + "Yair Hershkovitz ", + "Clytie Siddall ", + "Ilkka Tuohela ", NULL }; -- cgit From 0bc57119fbc42ce8cbf7a6fbf40954c897e8b9d3 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 7 Aug 2005 19:45:50 +0000 Subject: Release 2.11.91 Update. 2005-08-07 Lucas Rocha * configure.in: Release 2.11.91 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 5bb772df..b649bf54 100644 --- a/src/about.c +++ b/src/about.c @@ -187,6 +187,7 @@ static const gchar *const author_credits[] = { "Yair Hershkovitz ", "Clytie Siddall ", "Ilkka Tuohela ", + "Chao-Hsiung Liao ", NULL }; -- cgit From 417bfb638949dfb17995bd948a05ab2bd911b881 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 23 Aug 2005 15:16:57 +0000 Subject: Release 2.11.92 Update. 2005-08-23 Lucas Rocha * configure.in: Release 2.11.92 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index b649bf54..f37d8efd 100644 --- a/src/about.c +++ b/src/about.c @@ -188,6 +188,8 @@ static const gchar *const author_credits[] = { "Clytie Siddall ", "Ilkka Tuohela ", "Chao-Hsiung Liao ", + "Žygimantas BeruÄka ", + "Gabor Kelemen ", NULL }; -- cgit From 7f091245f70b6d6fac4c79288109e31aa62eb8aa Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 6 Sep 2005 03:44:07 +0000 Subject: Release 2.12.0 Update. 2005-09-06 Lucas Rocha * configure.in: Release 2.12.0 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index f37d8efd..965ce9bc 100644 --- a/src/about.c +++ b/src/about.c @@ -190,6 +190,9 @@ static const gchar *const author_credits[] = { "Chao-Hsiung Liao ", "Žygimantas BeruÄka ", "Gabor Kelemen ", + "Telsa Gwynne ", + "Slobodan D. Sredojevic ", + "Baris Cicek ", NULL }; -- cgit From 0086a9363f9c94f19d6d5ad2424680fcac0e7a7a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 24 Sep 2005 15:04:02 +0000 Subject: fixed bug #317033. 2005-09-24 Lucas Rocha * src/option.c: fixed bug #317033. --- src/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index c8640f3f..19089305 100644 --- a/src/option.c +++ b/src/option.c @@ -211,7 +211,7 @@ static GOptionEntry entry_options[] = { "text", '\0', G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, + G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS, &zenity_general_dialog_text, N_("Set the dialog text"), NULL @@ -220,7 +220,7 @@ static GOptionEntry entry_options[] = { "entry-text", '\0', 0, - G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, &zenity_entry_entry_text, N_("Set the entry text"), NULL -- cgit From 7f2aedec5aa6a489b89c347f998c62d49fc0fa7b Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 18 Oct 2005 13:56:35 +0000 Subject: by default, focus is on tree view in list dialogs. Fixes #317263. Patch 2005-10-18 Lucas Rocha * src/zenity.glade: by default, focus is on tree view in list dialogs. Fixes #317263. Patch from Aleksey Kliger --- src/zenity.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index bb42c2d8..22049ba9 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -954,7 +954,6 @@ True True True - True gtk-ok True GTK_RELIEF_NORMAL @@ -1018,6 +1017,7 @@ True True + True True False False -- cgit From 5483bdb680420014ebcfc3b916fb30fbe04de581 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 24 Oct 2005 12:51:36 +0000 Subject: Release 2.13.1 Update. 2005-10-24 Lucas Rocha * configure.in: Release 2.13.1 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 965ce9bc..b24cb5d9 100644 --- a/src/about.c +++ b/src/about.c @@ -193,6 +193,7 @@ static const gchar *const author_credits[] = { "Telsa Gwynne ", "Slobodan D. Sredojevic ", "Baris Cicek ", + "Runa Bhattacharjee ", NULL }; -- cgit From c8b9b79813c426837092ccda149bb3f2ca9c58be Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 Nov 2005 04:25:58 +0000 Subject: make it possible to add new lines in the in the msg dialog (Fixes bug 2005-11-13 Lucas Rocha * src/msg.c: make it possible to add new lines in the in the msg dialog (Fixes bug #320787). --- src/msg.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index b400f0bd..973062ee 100644 --- a/src/msg.c +++ b/src/msg.c @@ -109,9 +109,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (msg_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), msg_data->dialog_text); - + if (msg_data->dialog_text) + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- cgit From 6a7b36229c87a9c477c56cbea789ddfb5f6758c8 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 Nov 2005 05:05:33 +0000 Subject: Release 2.13.2 Update. 2005-11-13 Lucas Rocha * configure.in: Release 2.13.2 * NEWS, THANKS, src/about.c: Update. --- src/about.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index b24cb5d9..07578236 100644 --- a/src/about.c +++ b/src/about.c @@ -194,6 +194,7 @@ static const gchar *const author_credits[] = { "Slobodan D. Sredojevic ", "Baris Cicek ", "Runa Bhattacharjee ", + "Erdal Ronahi ", NULL }; -- cgit From 5547de9384430dfccb9c3c8a68badfa120760b4a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 15 Nov 2005 04:14:35 +0000 Subject: make it possible to add new lines and markup in the dialog text. 2005-11-15 Lucas Rocha * src/calendar.c, src/progress.c, src/tree.c: make it possible to add new lines and markup in the dialog text. --- src/calendar.c | 2 +- src/progress.c | 4 +++- src/tree.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index f876c038..fd0eb7b5 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -68,7 +68,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); if (cal_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text); + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); diff --git a/src/progress.c b/src/progress.c index 34779c12..68f34ac4 100644 --- a/src/progress.c +++ b/src/progress.c @@ -204,7 +204,9 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); - gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text); + + if (progress_data->dialog_text) + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); diff --git a/src/tree.c b/src/tree.c index d6621c32..b3bb977c 100644 --- a/src/tree.c +++ b/src/tree.c @@ -341,7 +341,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) text = glade_xml_get_widget (glade_dialog, "zenity_tree_text"); if (tree_data->dialog_text) - gtk_label_set_text (GTK_LABEL (text), tree_data->dialog_text); + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text)); zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); -- cgit From 285cb79bafd2616f2d2dd7eb2ae82527942ef4cc Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 13 Dec 2005 04:18:58 +0000 Subject: new scale dialog for selecting a value from a range (Fixes #322399). 2005-12-13 Lucas Rocha * data/Makefile.am, data/zenity-scale.png, src/Makefile.am, src/main.c, src/option.c, src/option.h, src/scale.c, src/zenity.glade, src/zenity.h: new scale dialog for selecting a value from a range (Fixes #322399). --- src/Makefile.am | 1 + src/main.c | 3 + src/option.c | 125 ++++++++++++++++++++++++++++++++ src/option.h | 2 + src/scale.c | 122 +++++++++++++++++++++++++++++++ src/zenity.glade | 213 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/zenity.h | 9 +++ 7 files changed, 468 insertions(+), 7 deletions(-) create mode 100644 src/scale.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 6b43b3e1..e3c62d53 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,6 +9,7 @@ zenity_SOURCES = \ zenity.h \ calendar.c \ msg.c \ + scale.c \ fileselection.c \ entry.c \ text.c \ diff --git a/src/main.c b/src/main.c index 09330d55..7077af8a 100644 --- a/src/main.c +++ b/src/main.c @@ -64,6 +64,9 @@ main (gint argc, gchar **argv) { case MODE_INFO: zenity_msg (results->data, results->msg_data); break; + case MODE_SCALE: + zenity_scale (results->data, results->scale_data); + break; case MODE_FILE: zenity_fileselection (results->data, results->file_data); break; diff --git a/src/option.c b/src/option.c index 19089305..f3f26b3a 100644 --- a/src/option.c +++ b/src/option.c @@ -91,6 +91,14 @@ static gboolean zenity_text_active; /* Warning Dialog Options */ static gboolean zenity_warning_active; +/* Scale Dialog Options */ +static gboolean zenity_scale_active; +static gint zenity_scale_value; +static gint zenity_scale_min_value; +static gint zenity_scale_max_value; +static gint zenity_scale_step; +static gboolean zenity_scale_print_partial; + /* Miscelaneus Options */ static gboolean zenity_misc_about; static gboolean zenity_misc_version; @@ -646,6 +654,75 @@ static GOptionEntry warning_options[] = { } }; +static GOptionEntry scale_options[] = { + { + "scale", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_scale_active, + N_("Display scale dialog"), + NULL + }, + { + "text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + NULL + }, + { + "value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_value, + N_("Set initial value"), + NULL + }, + { + "min-value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_min_value, + N_("Set minimum value"), + NULL + }, + { + "max-value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_max_value, + N_("Set maximum value"), + NULL + }, + { + "step", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_step, + N_("Set step size"), + NULL + }, + { + "print-partial", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_scale_print_partial, + N_("Print partial values"), + NULL + }, + { + NULL + } +}; + static GOptionEntry miscellaneous_options[] = { { "about", @@ -683,6 +760,7 @@ zenity_option_init (void) { results->data = g_new0 (ZenityData, 1); results->calendar_data = g_new0 (ZenityCalendarData, 1); results->msg_data = g_new0 (ZenityMsgData, 1); + results->scale_data = g_new0 (ZenityScaleData, 1); results->file_data = g_new0 (ZenityFileData, 1); results->entry_data = g_new0 (ZenityEntryData, 1); results->progress_data = g_new0 (ZenityProgressData, 1); @@ -912,6 +990,22 @@ zenity_warning_pre_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_scale_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_scale_active = FALSE; + zenity_scale_value = 0; + zenity_scale_min_value = 0; + zenity_scale_max_value = 100; + zenity_scale_step = 1; + zenity_scale_print_partial = FALSE; + + return TRUE; +} + static gboolean zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, @@ -1234,6 +1328,26 @@ zenity_warning_post_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_scale_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_scale_active, MODE_SCALE); + + if (results->mode == MODE_SCALE) { + results->scale_data->dialog_text = zenity_general_dialog_text; + results->scale_data->value = zenity_scale_value; + results->scale_data->min_value = zenity_scale_min_value; + results->scale_data->max_value = zenity_scale_max_value; + results->scale_data->step = zenity_scale_step; + results->scale_data->print_partial = zenity_scale_print_partial; + } + + return TRUE; +} + static gboolean zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group, @@ -1375,6 +1489,17 @@ zenity_create_context (void) g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); + /* Adds scale option entries */ + a_group = g_option_group_new("scale", + N_("Scale options"), + N_("Show scale options"), NULL, 0); + g_option_group_add_entries(a_group, scale_options); + g_option_group_set_parse_hooks (a_group, + zenity_scale_pre_callback, zenity_scale_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group(tmp_ctx, a_group); + /* Adds text option entries */ a_group = g_option_group_new("text-info", N_("Text information options"), diff --git a/src/option.h b/src/option.h index 63b28243..cce0553d 100644 --- a/src/option.h +++ b/src/option.h @@ -42,6 +42,7 @@ typedef enum { MODE_QUESTION, MODE_TEXTINFO, MODE_WARNING, + MODE_SCALE, MODE_INFO, MODE_NOTIFICATION, MODE_ABOUT, @@ -62,6 +63,7 @@ typedef struct { ZenityCalendarData *calendar_data; ZenityMsgData *msg_data; + ZenityScaleData *scale_data; ZenityFileData *file_data; ZenityEntryData *entry_data; ZenityProgressData *progress_data; diff --git a/src/scale.c b/src/scale.c new file mode 100644 index 00000000..228995e6 --- /dev/null +++ b/src/scale.c @@ -0,0 +1,122 @@ +/* + * scale.c + * + * Copyright (C) 2002 Sun Microsystems, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Lucas Rocha + */ + +#include "config.h" + +#include +#include "zenity.h" +#include "util.h" + +static GtkWidget *scale; + +static void zenity_scale_value_changed (GtkWidget *widget, gpointer data); +static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data); + +void +zenity_scale (ZenityData *data, ZenityScaleData *scale_data) +{ + GladeXML *glade_dialog; + GtkWidget *dialog; + GtkWidget *text; + + glade_dialog = zenity_util_load_glade_file ("zenity_scale_dialog"); + dialog = glade_xml_get_widget (glade_dialog, "zenity_scale_dialog"); + scale = glade_xml_get_widget (glade_dialog, "zenity_scale_hscale"); + text = glade_xml_get_widget (glade_dialog, "zenity_scale_text"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_scale_dialog_response), data); + + if (glade_dialog == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + if (scale_data->min_value >= scale_data->max_value) { + g_printerr (_("Maximum value must be greater than minimum value.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + if (scale_data->value < scale_data->min_value || + scale_data->value > scale_data->max_value) { + g_printerr (_("Value out of range.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + glade_xml_signal_autoconnect (glade_dialog); + + if (glade_dialog) + g_object_unref (glade_dialog); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-scale.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (scale_data->dialog_text) + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text)); + + gtk_range_set_value (GTK_RANGE (scale), scale_data->value); + gtk_range_set_range (GTK_RANGE (scale), scale_data->min_value, scale_data->max_value); + gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0); + + if (scale_data->print_partial) + g_signal_connect (G_OBJECT (scale), "value-changed", + G_CALLBACK (zenity_scale_value_changed), data); + + zenity_util_show_dialog (dialog); + gtk_main (); +} + +static void +zenity_scale_value_changed (GtkWidget *widget, gpointer data) +{ + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (widget))); +} + +static void +zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); +} diff --git a/src/zenity.glade b/src/zenity.glade index 22049ba9..66dc3cce 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -15,6 +15,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -90,6 +92,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -119,6 +125,10 @@ 0 0 zenity_calendar + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -166,6 +176,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -252,6 +264,10 @@ 0 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -283,6 +299,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -321,6 +339,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -407,6 +427,10 @@ 0 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -437,6 +461,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -513,6 +539,10 @@ 0 0 zenity_entry_input + PANGO_ELLIPSIZE_NONE + -1 + False + 0 @@ -533,7 +563,7 @@ 0 True - * + * True @@ -575,6 +605,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -675,6 +707,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -751,6 +785,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -764,8 +802,9 @@ True GTK_PROGRESS_LEFT_TO_RIGHT 0 - 0.1 + 0.10000000149 + PANGO_ELLIPSIZE_NONE 0 @@ -804,6 +843,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -883,6 +924,10 @@ 0 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -914,7 +959,7 @@ GTK_WIN_POS_CENTER False 300 - 200 + 196 True False True @@ -922,6 +967,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -996,6 +1043,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1017,11 +1068,14 @@ True True - True + True True False False True + False + False + False @@ -1062,6 +1116,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False False @@ -1140,6 +1196,10 @@ 0 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1177,6 +1237,8 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST + True + False True @@ -1265,7 +1327,7 @@ True True - zenity_about_version + zenity_about_version False True GTK_JUSTIFY_CENTER @@ -1275,6 +1337,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1287,7 +1353,7 @@ True True - zenity_about_description + zenity_about_description False True GTK_JUSTIFY_CENTER @@ -1297,6 +1363,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1309,7 +1379,7 @@ True True - zenity_about_copyright + zenity_about_copyright False True GTK_JUSTIFY_CENTER @@ -1319,6 +1389,10 @@ 0.5 0 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 0 @@ -1337,4 +1411,129 @@ + + True + Adjust the scale value + GTK_WINDOW_TOPLEVEL + GTK_WIN_POS_NONE + False + 300 + 100 + True + False + True + False + False + GDK_WINDOW_TYPE_HINT_DIALOG + GDK_GRAVITY_NORTH_WEST + True + False + True + + + + + True + False + 0 + + + + True + GTK_BUTTONBOX_END + + + + True + True + True + gtk-cancel + True + GTK_RELIEF_NORMAL + True + -6 + + + + + + True + True + True + gtk-ok + True + GTK_RELIEF_NORMAL + True + -5 + + + + + 0 + False + True + GTK_PACK_END + + + + + + 3 + True + False + 0 + + + + True + Adjust the scale value. + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 4 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + + + + + True + True + True + GTK_POS_RIGHT + 0 + GTK_UPDATE_DELAYED + False + 0 0 100 1 1 0 + + + 0 + True + True + + + + + 0 + True + True + + + + + + diff --git a/src/zenity.h b/src/zenity.h index b224abd9..6b8cd294 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -60,6 +60,15 @@ typedef struct { gboolean no_wrap; } ZenityMsgData; +typedef struct { + gchar *dialog_text; + gint value; + gint min_value; + gint max_value; + gint step; + gboolean print_partial; +} ZenityScaleData; + typedef struct { gchar *uri; gboolean multi; -- cgit From b657c347e82335715fc2540380d2282cabff2586 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 13 Dec 2005 15:12:38 +0000 Subject: make the hscale discontinuous. 2005-12-13 Lucas Rocha * src/zenity.glade: make the hscale discontinuous. --- src/zenity.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 66dc3cce..622502b2 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1515,7 +1515,7 @@ True GTK_POS_RIGHT 0 - GTK_UPDATE_DELAYED + GTK_UPDATE_DISCONTINUOUS False 0 0 100 1 1 0 -- cgit From 4ac6730868c97e7cc800cee8eba6721a23181678 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 15 Dec 2005 05:40:15 +0000 Subject: add --hide-value to scale dialog. 2005-12-15 Lucas Rocha * src/option.c, src/scale.c, src/zenity.h: add --hide-value to scale dialog. --- src/option.c | 12 ++++++++++++ src/scale.c | 3 +++ src/zenity.h | 1 + 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index f3f26b3a..2268ef7e 100644 --- a/src/option.c +++ b/src/option.c @@ -98,6 +98,7 @@ static gint zenity_scale_min_value; static gint zenity_scale_max_value; static gint zenity_scale_step; static gboolean zenity_scale_print_partial; +static gboolean zenity_scale_hide_value; /* Miscelaneus Options */ static gboolean zenity_misc_about; @@ -718,6 +719,15 @@ static GOptionEntry scale_options[] = { N_("Print partial values"), NULL }, + { + "hide-value", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_scale_hide_value, + N_("Hide value"), + NULL + }, { NULL } @@ -1002,6 +1012,7 @@ zenity_scale_pre_callback (GOptionContext *context, zenity_scale_max_value = 100; zenity_scale_step = 1; zenity_scale_print_partial = FALSE; + zenity_scale_hide_value = FALSE; return TRUE; } @@ -1343,6 +1354,7 @@ zenity_scale_post_callback (GOptionContext *context, results->scale_data->max_value = zenity_scale_max_value; results->scale_data->step = zenity_scale_step; results->scale_data->print_partial = zenity_scale_print_partial; + results->scale_data->hide_value = zenity_scale_hide_value; } return TRUE; diff --git a/src/scale.c b/src/scale.c index 228995e6..cacb083a 100644 --- a/src/scale.c +++ b/src/scale.c @@ -89,6 +89,9 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) g_signal_connect (G_OBJECT (scale), "value-changed", G_CALLBACK (zenity_scale_value_changed), data); + if (scale_data->hide_value) + gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); + zenity_util_show_dialog (dialog); gtk_main (); } diff --git a/src/zenity.h b/src/zenity.h index 6b8cd294..6fb2b4c2 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -67,6 +67,7 @@ typedef struct { gint max_value; gint step; gboolean print_partial; + gboolean hide_value; } ZenityScaleData; typedef struct { -- cgit From 906b3397b29050dc0e129d4f9b59b2b3db1027be Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 17 Dec 2005 02:22:51 +0000 Subject: make all dialogs HIG compliant by fixing spaces and removing separator 2005-12-16 Lucas Rocha * src/zenity.glade: make all dialogs HIG compliant by fixing spaces and removing separator (Fixes bug #324211). Patch by Christian Persch . --- src/zenity.glade | 328 +++++++++++++++++++++++++------------------------------ 1 file changed, 147 insertions(+), 181 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 622502b2..50959f96 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -4,6 +4,7 @@ + 5 Calendar selection GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -17,14 +18,14 @@ GDK_GRAVITY_NORTH_WEST True False - True + False True False - 0 + 2 @@ -68,16 +69,16 @@ - 6 + 5 True False - 0 + 6 True False - 4 + 6 @@ -105,7 +106,7 @@ - 12 + 0 True True @@ -164,7 +165,7 @@ - 6 + 5 Warning GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -185,7 +186,7 @@ True False - 12 + 14 @@ -229,7 +230,7 @@ - 6 + 5 True False 12 @@ -327,7 +328,7 @@ - 6 + 5 Question GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -348,7 +349,7 @@ True False - 12 + 14 @@ -392,7 +393,7 @@ - 6 + 5 True False 12 @@ -450,6 +451,7 @@ + 5 Add a new entry GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -463,14 +465,14 @@ GDK_GRAVITY_NORTH_WEST True False - True + False True False - 0 + 2 @@ -523,7 +525,7 @@ True False - 0 + 6 @@ -575,7 +577,7 @@ 0 - True + False True @@ -591,7 +593,7 @@ - 6 + 5 Text View GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -614,7 +616,7 @@ True False - 6 + 2 @@ -644,7 +646,7 @@ - 6 + 5 True False 0 @@ -696,6 +698,7 @@ + 5 Progress GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -709,14 +712,14 @@ GDK_GRAVITY_NORTH_WEST True False - True + False True False - 0 + 2 @@ -760,63 +763,50 @@ - - 6 + + 5 True False - 0 + 6 - + True - False - 5 - - - - True - Running... - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - + Running... + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - - - True - GTK_PROGRESS_LEFT_TO_RIGHT - 0 - 0.10000000149 - - PANGO_ELLIPSIZE_NONE - - - 0 - False - False - - + + + True + GTK_PROGRESS_LEFT_TO_RIGHT + 0 + 0.10000000149 + + PANGO_ELLIPSIZE_NONE 0 - True - True + False + False @@ -831,7 +821,7 @@ - 6 + 5 Error GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -852,7 +842,7 @@ True False - 12 + 14 @@ -889,7 +879,7 @@ - 6 + 5 True False 12 @@ -954,6 +944,7 @@ + 5 Select items from the list GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -969,7 +960,7 @@ GDK_GRAVITY_NORTH_WEST True False - True + False @@ -1018,72 +1009,59 @@ - - 6 + + 5 True False - 0 + 6 - + True - False - 6 + Select items from the list below. + False + True + GTK_JUSTIFY_LEFT + False + False + 0 + 0.5 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + - - - True - Select items from the list below. - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - + + + True + True + GTK_POLICY_AUTOMATIC + GTK_POLICY_AUTOMATIC + GTK_SHADOW_IN + GTK_CORNER_TOP_LEFT - + True True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_NONE - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - False - False - True - False - False - False - - + True + True + False + False + True + False + False + False - - 0 - True - True - @@ -1104,7 +1082,7 @@ - 6 + 5 Information GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER @@ -1125,7 +1103,7 @@ True False - 12 + 14 @@ -1154,59 +1132,21 @@ - - 6 + + 5 True False - 0 + 12 - + True - False - 12 - - - - True - gtk-dialog-info - 6 - 0.5 - 0 - 0 - 0 - - - 0 - True - True - - - - - - True - All updates are complete. - False - True - GTK_JUSTIFY_LEFT - True - False - 0.5 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - + gtk-dialog-info + 6 + 0.5 + 0 + 0 + 0 0 @@ -1214,6 +1154,31 @@ True + + + + True + All updates are complete. + False + True + GTK_JUSTIFY_LEFT + True + False + 0.5 + 0 + 0 + 0 + PANGO_ELLIPSIZE_NONE + -1 + False + 0 + + + 0 + False + False + + 0 @@ -1412,6 +1377,7 @@ + 5 True Adjust the scale value GTK_WINDOW_TOPLEVEL @@ -1428,7 +1394,7 @@ GDK_GRAVITY_NORTH_WEST True False - True + False @@ -1478,10 +1444,10 @@ - 3 + 5 True False - 0 + 6 -- cgit From 7486a38445e16fc17505c5f3e6afd7f8f8e87aeb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 18 Dec 2005 03:19:40 +0000 Subject: use GtkAboutDialog instead of custom dialog (Fixes bug #309405). remove 2005-12-18 Lucas Rocha * src/about.c: use GtkAboutDialog instead of custom dialog (Fixes bug #309405). * src/zenity.glade: remove zenity_about_dialog. * configure.in: zenity now depends on GTK+ >= 2.6.x because now it uses GtkAboutDialog. --- src/about.c | 379 +++++++------------------------------------------------ src/zenity.glade | 186 --------------------------- 2 files changed, 47 insertions(+), 518 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 07578236..2fe95aa7 100644 --- a/src/about.c +++ b/src/about.c @@ -30,7 +30,6 @@ #include #include #include -#include #define GTK_RESPONSE_CREDITS 0 #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" @@ -40,165 +39,27 @@ #define ZENITY_CANVAS_Y 280.0 static GtkWidget *dialog; -static GtkWidget *cred_dialog; +static void zenity_about_display_help (GtkWidget *widget, gpointer data); static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); /* Sync with the people in the THANKS file */ -static const gchar *const author_credits[] = { - "Authors", - "=======", +static const gchar *const authors[] = { "Glynn Foster ", + "Lucas Rocha ", "Mike Newman ", - "", - "Patches from the following people", - "=================================", - "Darren Adams " - "Peter Astrand ", - "Jonathan Blandford ", - "Paul Bolle ", - "Paolo Borelli ", - "Leonardo Boshell

", - "Ross Burton ", - "Damien Carbery ", - "Anders Carlsson ", - "Ed Catmur ", - "Nicholas Curran ", - "John Fleck ", - "Sebastian Heinlein ", - "James Henstridge ", - "Chris Lahey ", - "Mihai T Lazarescu ", - "Sebastian Kapfer ", - "Tomasz Koczko ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Breda McColgan ", - "Baptiste Mille-Mathias ", - "Buhan Milne ", - "Christian Monneckes ", - "Ivan Noris ", - "Havoc Pennington ", - "Jan Arne Petersen ", - "Kevin C Krinke ", - "Kristian Rietveld ", - "Lucas Rocha ", - "Christian Rose ", - "Jakub Steiner ", - "Luke Suchocki ", - "Daniel d'Surreal ", - "Hidetoshi Tajima ", - "Tom Tromey ", - "Yann ", - "Norman Rasmussen ", - "Benoît Dejean ", - "", - "And all the translators that rock my world", - "==========================================", - "Vincent van Adrighem ", - "Taneem Ahmed ", - "Takeshi Aihana ", - "Amanpreet Singh Alam ", - "Metin Amiroff ", - "Sanlig Badral ", - "John C Barstow ", - "Aygimantas Beruka ", - "Alberto Fernandez Benito ", - "Stefano Canepa ", - "Young-Ho Cha ", - "Abel Cheung ", - "Zbigniew Chyla ", - "Mohammad Damt ", - "Fatih Demir ", - "Laurent Dhima ", - "Paul Duffy ", - "Laszlo Dvornik ", - "Maxim Dziumanenko ", - "Francisco Javier Fernandez ", - "Artur Flinta ", - "Alessio Frusciante ", - "Evandro Fernandes Giovanini ", - "Pablo Gonzalo del Campo ", - "Dhurba Gnawali ", - "Sammi Gunnarsson ", - "Martin Willemoes Hansen ", - "Dafydd Harries ", - "Raphael Higino ", - "Wang Jian ", - "Guntupalli Karunakar ", - "Tomas Kuliavas ", - "Priit Laes ", - "Iaki Larraaga ", - "Ole Laursen ", - "Toivo Leedjrv ", - "David Lodge ", - "Duarte Loreto ", - "Johanna Makkonen ", - "Jordi Mallach ", - "Kjartan Maraas ", - "Jordi Mas ", - "Kamagasako Masatoshi ", - "Dmitry G Mastrukov ", - "Arafat Medini ", - "Christophe Merlet ", - "Mike Newman ", - "Ahmad Riza H Nst ", - "Alexandre Folle de Menezes ", - "Christian Neumair ", - "Metin Omirov ", - "Gareth Owen ", - "Kostas Papadimas ", - "Ankit Patel ", - "Sami Pesonen ", - "Roozbeh Pournader ", - "Jarkko Ranta ", - "Rostislav Raykov ", - "Hendrik Richter ", - "Christian Rose ", - "Changwoo Ryu ", - "Pablo Saratxaga ", - "Robert Sedak ", - "Paisa Seeluangsawat ", - "Danilo Segan ", - "Alexander Shopov ", - "Aasmund Skjaveland ", - "Yuriy Syrota ", - "Marcel Telka ", - "Andras Timar ", - "Miloslav Trmac ", - "Mugurel Tudor ", - "Daniel Yacob ", - "Funda Wang ", - "Alexander Winston ", - "Theppitak Karoonboonyanan ", - "Martin Willemoes Hansen ", - "Ignacio Casal Quinteiro ", - "Pawan Chitrakar ", - "Rajesh Ranjan ", - "Vladimir Petkov ", - "Abduxukur Abdurixit ", - "Adi Attar ", - "Steve Murphy ", - "Josep Puigdemont ", - "Adam Weinberger ", - "Ivar Smolin ", - "Jens Seidel ", - "Benoît Dejean ", - "Yair Hershkovitz ", - "Clytie Siddall ", - "Ilkka Tuohela ", - "Chao-Hsiung Liao ", - "Žygimantas BeruÄka ", - "Gabor Kelemen ", - "Telsa Gwynne ", - "Slobodan D. Sredojevic ", - "Baris Cicek ", - "Runa Bhattacharjee ", - "Erdal Ronahi ", NULL }; -static gchar *translator_credits; +static const char *documenters[] = { + "Glynn Foster ", + "Lucas Rocha ", + "Java Desktop System Documentation Team", + "GNOME Documentation Project", + NULL +}; + +static gchar *translators; static gint zenity_move_clothes_event (GnomeCanvasItem *item, @@ -381,214 +242,68 @@ zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) void zenity_about (ZenityData *data) { - GladeXML *glade_dialog = NULL; - GdkPixbuf *pixbuf; - GtkWidget *label; - GtkWidget *image; - gchar *text; + GdkPixbuf *logo; + GtkWidget *help_button; - glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog"); + translators = _("translator-credits"); + logo = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - if (glade_dialog == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - /* Translators: This is a special message that shouldn't be translated - literally. It is used in the about box to give credits to - the translators. - Thus, you should translate it to your name and email address. - You can also include other translators who have contributed to - this translation; in that case, please write them on separate - lines seperated by newlines (\n). */ + dialog = gtk_about_dialog_new (); - translator_credits = _("translator-credits"); + g_object_set (G_OBJECT (dialog), + "name", "Zenity", + "version", VERSION, + "copyright", "Copyright \xc2\xa9 2003 Sun Microsystems", + "comments", _("Display dialog boxes from shell scripts"), + "authors", authors, + "documenters", documenters, + "translator-credits", translators, + "logo", logo, + NULL); - glade_xml_signal_autoconnect (glade_dialog); + zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog"); + help_button = gtk_button_new_from_stock (GTK_STOCK_HELP); + + g_signal_connect (G_OBJECT (help_button), "clicked", + G_CALLBACK (zenity_about_display_help), data); + + gtk_widget_show (help_button); + + gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->action_area), + help_button, FALSE, TRUE, 0); + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), + help_button, TRUE); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); g_signal_connect (G_OBJECT (dialog), "key_press_event", - G_CALLBACK (zenity_zen_wisdom), glade_dialog); - - zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - - image = glade_xml_get_widget (glade_dialog, "zenity_about_image"); - - pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - - if (pixbuf != NULL) { - gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf); - g_object_unref (pixbuf); - } - - label = glade_xml_get_widget (glade_dialog, "zenity_about_version"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("Zenity %s", VERSION); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_description"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts")); - - label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright"); - gtk_label_set_selectable (GTK_LABEL (label), FALSE); - text = g_strdup_printf ("%s", _("(C) 2003 Sun Microsystems")); - gtk_label_set_markup (GTK_LABEL (label), text); - g_free (text); - - if (glade_dialog) - g_object_unref (glade_dialog); + G_CALLBACK (zenity_zen_wisdom), NULL); zenity_util_show_dialog (dialog); gtk_main (); } -static GtkWidget * -zenity_about_create_label (void) -{ - GtkWidget *label; - - label = gtk_label_new (""); - gtk_label_set_selectable (GTK_LABEL (label), TRUE); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0); - gtk_misc_set_padding (GTK_MISC (label), 8, 8); - - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - - return label; -} - -static void -zenity_about_update_author_label (GtkWidget *label) -{ - GString *string; - gchar *tmp; - gint i = 0; - - gtk_widget_show (label); - - string = g_string_new (""); - - for (i = 0; author_credits[i] != NULL; i++) { - tmp = g_markup_escape_text (author_credits[i], -1); - g_string_append (string, tmp); - - if (author_credits[i+1] != NULL) - g_string_append (string, "\n"); - - g_free (tmp); - } - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); -} - -static void -zenity_about_update_translator_label (GtkWidget *label) -{ - GString *string; - gchar *tmp; - - if (strcmp (translator_credits, "translator-credits") == 0) { - gtk_widget_hide (label); - return; - } else { - gtk_widget_show (label); - } - - string = g_string_new (""); - - tmp = g_markup_escape_text (translator_credits, -1); - g_string_append (string, tmp); - g_free (tmp); - - gtk_label_set_markup (GTK_LABEL (label), string->str); - g_string_free (string, TRUE); -} - -static void -zenity_about_display_credits_dialog (void) -{ - GtkWidget *credits_dialog; - GtkWidget *label, *notebook, *sw; - - if (cred_dialog != NULL) { - gtk_window_present (GTK_WINDOW (cred_dialog)); - return; - } - - credits_dialog = gtk_dialog_new_with_buttons (_("Credits"), - GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); - - g_signal_connect (G_OBJECT (credits_dialog), "response", - G_CALLBACK (gtk_widget_destroy), credits_dialog); - g_signal_connect (G_OBJECT (credits_dialog), "destroy", - G_CALLBACK (gtk_widget_destroyed), &cred_dialog); - - cred_dialog = credits_dialog; - - gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260); - gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK); - - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 8); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0); - - if (author_credits != NULL) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Written by"))); - zenity_about_update_author_label (label); - } - - if (translator_credits != NULL && strcmp (translator_credits, "translator-credits") != 0) { - label = zenity_about_create_label (); - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw, - gtk_label_new (_("Translated by"))); - zenity_about_update_translator_label (label); - } - - gtk_widget_show_all (credits_dialog); -} - static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; switch (response) { - case GTK_RESPONSE_OK: + case GTK_RESPONSE_CLOSE: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); break; - case GTK_RESPONSE_HELP: - zenity_util_show_help (NULL); - break; - - case GTK_RESPONSE_CREDITS: - zenity_about_display_credits_dialog (); - break; - default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } } + +static void +zenity_about_display_help (GtkWidget *widget, gpointer data) +{ + zenity_util_show_help (NULL); +} diff --git a/src/zenity.glade b/src/zenity.glade index 50959f96..f19fde34 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1190,192 +1190,6 @@ - - About Zenity - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - True - False - True - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-help - True - GTK_RELIEF_NORMAL - True - -11 - - - - - - True - True - True - _Credits - True - GTK_RELIEF_NORMAL - True - 0 - - - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 7 - True - False - 8 - - - - True - 0.5 - 0.5 - 0 - 0 - - - 0 - True - True - - - - - - True - True - zenity_about_version - False - True - GTK_JUSTIFY_CENTER - False - True - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - True - zenity_about_description - False - True - GTK_JUSTIFY_CENTER - True - True - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - True - zenity_about_copyright - False - True - GTK_JUSTIFY_CENTER - False - True - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - 5 True -- cgit From 17989a09c1212985c7124c9d9198a99bfa654834 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 7 Mar 2006 19:04:04 +0000 Subject: add G_OPTION_FLAG_NOALIAS to separator option for list dialog. Patch from 2006-03-07 Lucas Rocha * src/option.c: add G_OPTION_FLAG_NOALIAS to separator option for list dialog. Patch from Glynn Foster . --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 2268ef7e..dcc1da04 100644 --- a/src/option.c +++ b/src/option.c @@ -424,7 +424,7 @@ static GOptionEntry list_options[] = { { "separator", '\0', - 0, + G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_separator, N_("Set output separator character"), -- cgit From e919741e641a82d7eb99dd5f0463c7006024c474 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 23 Mar 2006 03:43:23 +0000 Subject: Implement the "message" command on notification icon with libnotify 2006-03-22 Lucas Rocha Implement the "message" command on notification icon with libnotify bubbles. Patch from Davyd Madeley . * configure.in: add libnotify checking. * src/notification.c (zenity_notification_handle_stdin, zenity_notification): initialize libnotify and implement "message" command. --- src/notification.c | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 26600cb3..6d5f8dd7 100644 --- a/src/notification.c +++ b/src/notification.c @@ -26,6 +26,11 @@ #include #include #include + +#ifdef HAVE_LIBNOTIFY +#include +#endif + #include "zenity.h" #include "eggtrayicon.h" #include "util.h" @@ -182,7 +187,33 @@ zenity_notification_handle_stdin (GIOChannel *channel, g_warning ("Could not load notification icon : %s", value); } } else if (!strcmp (command, "message")) { - g_warning ("haven't implemented message support yet"); +#ifdef HAVE_LIBNOTIFY + /* display a notification bubble */ + if (notify_is_initted ()) { + GError *error = NULL; + NotifyNotification *n; + GdkPixbuf *icon; + + n = notify_notification_new (g_strcompress (value), NULL, NULL, + GTK_WIDGET (tray_icon)); + + icon = gtk_image_get_pixbuf (GTK_IMAGE (icon_image)); + + notify_notification_set_icon_from_pixbuf (n, icon); + + notify_notification_show (n, &error); + if (error) { + g_warning (error->message); + g_error_free (error); + } + + g_object_unref (G_OBJECT (n)); + } else { +#else + { /* this brace is for balance */ +#endif + g_warning ("Notification framework not available"); + } } else if (!strcmp (command, "tooltip")) { gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); } else if (!strcmp (command, "visible")) { @@ -275,6 +306,12 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data G_CALLBACK (zenity_notification_icon_press_callback), data); } +#ifdef HAVE_LIBNOTIFY + /* create the notification widget */ + if (!notify_is_initted ()) + notify_init (_("Zenity notification")); +#endif + gtk_widget_show_all (GTK_WIDGET (tray_icon)); /* Does nothing at the moment */ -- cgit From 6645316bc935dfc2b4f8a1cad95a98f90cd710c1 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 23 Mar 2006 20:08:17 +0000 Subject: add --confirm-overwrite to file selection dialog to pop a confirmation 2006-03-23 Lucas Rocha * src/fileselection.c, zenity.h, option.c: add --confirm-overwrite to file selection dialog to pop a confirmation dialog when selecting an existing filename. --- src/fileselection.c | 3 +++ src/option.c | 12 ++++++++++++ src/zenity.h | 1 + 3 files changed, 16 insertions(+) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 53859229..3f355bab 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -57,6 +57,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); + gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), + file_data->confirm_overwrite); + g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); diff --git a/src/option.c b/src/option.c index dcc1da04..7917c91e 100644 --- a/src/option.c +++ b/src/option.c @@ -63,6 +63,7 @@ static gboolean zenity_info_active; static gboolean zenity_file_active; static gboolean zenity_file_directory; static gboolean zenity_file_save; +static gboolean zenity_file_confirm_overwrite; /* List Dialog Options */ static gboolean zenity_list_active; @@ -370,6 +371,15 @@ static GOptionEntry file_selection_options[] = { N_("Set output separator character"), N_("SEPARATOR") }, + { + "confirm-overwrite", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_confirm_overwrite, + N_("Confirm file selection if filename already exists"), + NULL + }, { NULL } @@ -921,6 +931,7 @@ zenity_file_pre_callback (GOptionContext *context, zenity_file_active = FALSE; zenity_file_directory = FALSE; zenity_file_save = FALSE; + zenity_file_confirm_overwrite = FALSE; return TRUE; } @@ -1170,6 +1181,7 @@ zenity_file_post_callback (GOptionContext *context, results->file_data->multi = zenity_general_multiple; results->file_data->directory = zenity_file_directory; results->file_data->save = zenity_file_save; + results->file_data->confirm_overwrite = zenity_file_confirm_overwrite; results->file_data->separator = zenity_general_separator; } else { if (zenity_file_directory) diff --git a/src/zenity.h b/src/zenity.h index 6fb2b4c2..05e628f4 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -75,6 +75,7 @@ typedef struct { gboolean multi; gboolean directory; gboolean save; + gboolean confirm_overwrite; gchar *separator; } ZenityFileData; -- cgit From a8363ee2199e82d547a3f90f119069c90448a0d7 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 31 Mar 2006 04:20:47 +0000 Subject: quit zenity on dialog response (Fixes bug #336505). 2006-03-31 Lucas Rocha * src/about.c (zenity_about_dialog_response): quit zenity on dialog response (Fixes bug #336505). --- src/about.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 2fe95aa7..9586d537 100644 --- a/src/about.c +++ b/src/about.c @@ -292,7 +292,6 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_CLOSE: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); break; default: @@ -300,6 +299,8 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + + gtk_main_quit (); } static void -- cgit From e97b6eeaebedf82788f7218e1b63d4e6c7478e92 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 17 Apr 2006 04:11:15 +0000 Subject: don't ignore return value from g_renew() (Fixes bug #338038). Patch from 2006-04-16 Lucas Rocha * src/tree.c (zenity_tree_extract_column_indexes): don't ignore return value from g_renew() (Fixes bug #338038). Patch from Behdad Esfahbod . --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index b3bb977c..0273e551 100644 --- a/src/tree.c +++ b/src/tree.c @@ -671,7 +671,7 @@ zenity_tree_extract_column_indexes (char *indexes, int n_columns) if (index > 0 && index <= n_columns) { result[j] = index; j++; - g_renew (gint, result, j + 1); + result = g_renew (gint, result, j + 1); } } result[j] = 0; -- cgit From 59b5bad79402b81b130e3b4242a74611d1c3be63 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 10 May 2006 03:37:14 +0000 Subject: move to automake 1.9 and several cleanups (Fixes bug #341056). Patch from 2006-05-10 Lucas Rocha * .cvsignore, Makefile.am, autogen.sh, configure.in, data/Makefile.am, po/.cvsignore, src/Makefile.am: move to automake 1.9 and several cleanups (Fixes bug #341056). Patch from Christian Persch . --- src/Makefile.am | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index e3c62d53..192dc3b5 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,21 +15,31 @@ zenity_SOURCES = \ text.c \ progress.c \ tree.c \ - notification.c \ - eggtrayicon.c \ eggtrayicon.h \ + eggtrayicon.c \ + notification.c \ about.c \ util.h \ util.c -INCLUDES = \ - $(ZENITY_CFLAGS) \ +zenity_CPPFLAGS = \ -I$(includedir) \ - -DGNOMELOCALEDIR=\""$(zenitylocaledir)"\" \ - -DZENITY_DATADIR=\""$(datadir)/zenity"\" + -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ + -DZENITY_DATADIR=\""$(pkgdatadir)"\" \ + $(AM_CPPFLAGS) + +zenity_CFLAGS = \ + $(ZENITY_CFLAGS) \ + $(LIBNOTIFY_CFLAGS) \ + $(WARN_CFLAGS) \ + $(AM_CFLAGS) + +zenity_LDFLAGS = \ + $(AM_LDFLAGS) zenity_LDADD = \ $(ZENITY_LIBS) \ + $(LIBNOTIFY_LIBS) \ $(X_LIBS) gladedir = $(datadir)/zenity -- cgit From 07618f9daa007f7cabfee3b25845e9088330abcd Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 11 May 2006 01:31:35 +0000 Subject: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from 2006-05-10 Lucas Rocha * src/entry.c (zenity_entry_fill_entries, zenity_entry), src/main.c, src/option.c, src/zenity.glade, src/zenity.h: add optional dropdown menu to entry dialog (Fixed bug #311038). Patch from Diego Escalante Urrelo . --- src/entry.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++---------- src/main.c | 1 + src/option.c | 2 +- src/zenity.glade | 21 +----------------- src/zenity.h | 1 + 5 files changed, 58 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index e8c25857..4b0f588a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -30,6 +30,18 @@ static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); static GtkWidget *entry; +static gint n_entries = 0; + +static void +zenity_entry_fill_entries (GSList **entries, const gchar **args) +{ + gint i = 0; + + while (args[i] != NULL) { + *entries = g_slist_append (*entries, (gchar *) args[i]); + i++; + } +} void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) @@ -37,7 +49,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) GladeXML *glade_dialog = NULL; GtkWidget *dialog; GtkWidget *text; - + GSList *entries = NULL; + GSList *tmp; + GtkWidget *vbox; + glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); if (glade_dialog == NULL) { @@ -48,7 +63,6 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) glade_xml_signal_autoconnect (glade_dialog); dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_entry_dialog_response), data); @@ -65,17 +79,41 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + + vbox = glade_xml_get_widget (glade_dialog, "vbox4"); + + zenity_entry_fill_entries(&entries, entry_data->data); + + n_entries = g_slist_length (entries); + + if (n_entries > 1) { + entry = gtk_combo_box_entry_new_text (); + + for (tmp = entries; tmp; tmp = tmp->next) { + gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data); + } + + if (entry_data->entry_text) { + gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); + gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); + } + } else { + entry = gtk_entry_new(); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input"); - - if (glade_dialog) - g_object_unref (glade_dialog); + } - if (entry_data->entry_text) - gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + gtk_widget_show (entry); - if (entry_data->hide_text) - g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); + gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + + if (glade_dialog) + g_object_unref (glade_dialog); gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); @@ -93,7 +131,12 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - text = gtk_entry_get_text (GTK_ENTRY (entry)); + if (n_entries > 1) { + text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)); + } + else { + text = gtk_entry_get_text (GTK_ENTRY (entry)); + } if (text != NULL) g_print ("%s\n", text); diff --git a/src/main.c b/src/main.c index 7077af8a..7e83fd89 100644 --- a/src/main.c +++ b/src/main.c @@ -56,6 +56,7 @@ main (gint argc, gchar **argv) { zenity_calendar (results->data, results->calendar_data); break; case MODE_ENTRY: + results->entry_data->data = (const gchar **) argv + 1; zenity_entry (results->data, results->entry_data); break; case MODE_ERROR: diff --git a/src/option.c b/src/option.c index 7917c91e..2be45500 100644 --- a/src/option.c +++ b/src/option.c @@ -1116,7 +1116,7 @@ zenity_entry_post_callback (GOptionContext *context, GError **error) { zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY); - + if (results->mode == MODE_ENTRY) { results->entry_data->dialog_text = zenity_general_dialog_text; results->entry_data->entry_text = zenity_entry_entry_text; diff --git a/src/zenity.glade b/src/zenity.glade index f19fde34..9e018654 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -540,14 +540,10 @@ 0.5 0 0 - zenity_entry_input PANGO_ELLIPSIZE_NONE -1 False 0 - - - 0 @@ -557,22 +553,7 @@ - - True - True - True - True - 0 - - True - * - True - - - 0 - False - False - + diff --git a/src/zenity.h b/src/zenity.h index 05e628f4..c6a1892e 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -83,6 +83,7 @@ typedef struct { gchar *dialog_text; gchar *entry_text; gboolean hide_text; + const gchar **data; } ZenityEntryData; typedef struct { -- cgit From 1bf8562a2e23b5c54d8e9ff0014d317fc3ef6a33 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 19 May 2006 20:00:29 +0000 Subject: about dialog update. 2006-05-19 Lucas Rocha * src/about.c (zenity_about): about dialog update. --- src/about.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/about.c b/src/about.c index 9586d537..c78fe35e 100644 --- a/src/about.c +++ b/src/about.c @@ -61,6 +61,20 @@ static const char *documenters[] = { static gchar *translators; +const char *license[] = { + N_("This program is free software; you can redistribute it and/or modify " + "it under the terms of the GNU General Public License as published by " + "the Free Software Foundation; either version 2 of the License, or " + "(at your option) any later version.\n"), + N_("This program is distributed in the hope that it will be useful, " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " + "GNU General Public License for more details.\n"), + N_("You should have received a copy of the GNU General Public License " + "along with this program; if not, write to the Free Software " + "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") +}; + static gint zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, @@ -244,10 +258,15 @@ zenity_about (ZenityData *data) { GdkPixbuf *logo; GtkWidget *help_button; + char *license_trans; + translators = _("translator-credits"); logo = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); + license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n", + _(license[2]), "\n", NULL); + dialog = gtk_about_dialog_new (); g_object_set (G_OBJECT (dialog), @@ -258,8 +277,13 @@ zenity_about (ZenityData *data) "authors", authors, "documenters", documenters, "translator-credits", translators, + "website", "http://live.gnome.org/Zenity", "logo", logo, + "wrap-license", TRUE, + "license", license_trans, NULL); + + g_free (license_trans); zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); -- cgit From 5968740b29dcbe3f7d3e009bd63a96e0b0d4e949 Mon Sep 17 00:00:00 2001 From: "Francisco Javier F. Serrador" Date: Sat, 10 Jun 2006 20:16:35 +0000 Subject: Replaced old FSF postal address with current one. 2006-06-10 Francisco Javier F. Serrador * src/about.c: Replaced old FSF postal address with current one. --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index c78fe35e..0d92a902 100644 --- a/src/about.c +++ b/src/about.c @@ -72,7 +72,7 @@ const char *license[] = { "GNU General Public License for more details.\n"), N_("You should have received a copy of the GNU General Public License " "along with this program; if not, write to the Free Software " - "Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.") + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.") }; static gint -- cgit From 216ee62fe1c062a9fb87aa3ce2097e0f8d21a06e Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 26 Jul 2006 23:17:04 +0000 Subject: fix small build warnings on 64-bit architectures (Fixes bug #344125). fix 2006-07-26 Lucas Rocha * src/tree.c (zenity_tree_fill_entries_from_stdin, zenity_tree): fix small build warnings on 64-bit architectures (Fixes bug #344125). * src/zenity.h: fix small build warning. --- src/tree.c | 14 +++++++------- src/zenity.h | 2 ++ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 0273e551..1e67f706 100644 --- a/src/tree.c +++ b/src/tree.c @@ -195,9 +195,9 @@ zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, { GIOChannel *channel; - g_object_set_data (G_OBJECT (tree_view), "n_columns", (gint *) n_columns); - g_object_set_data (G_OBJECT (tree_view), "toggles", (gint *) toggles); - g_object_set_data (G_OBJECT (tree_view), "editable", (gint *) editable); + g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); + g_object_set_data (G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles)); + g_object_set_data (G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable)); channel = g_io_channel_unix_new (0); g_io_channel_set_encoding (channel, NULL, NULL); @@ -218,7 +218,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, model = gtk_tree_view_get_model (tree_view); - g_object_set_data (G_OBJECT (tree_view), "n_columns", (gint *) n_columns); + g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); while (args[i] != NULL) { gint j; @@ -403,7 +403,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (tree_data->radiobox) { g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); - g_object_set_data (G_OBJECT (model), "radio", (gint *) 1); + g_object_set_data (G_OBJECT (model), "radio", GINT_TO_POINTER (1)); } g_signal_connect (cell_renderer, "toggled", @@ -421,7 +421,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) g_signal_connect (G_OBJECT (cell_renderer), "edited", G_CALLBACK (zenity_cell_edited_callback), gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index); + g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index)); column = gtk_tree_view_column_new_with_attributes (tmp->data, cell_renderer, @@ -452,7 +452,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) g_signal_connect (G_OBJECT (cell_renderer), "edited", G_CALLBACK (zenity_cell_edited_callback), gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index); + g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index)); column = gtk_tree_view_column_new_with_attributes (tmp->data, cell_renderer, diff --git a/src/zenity.h b/src/zenity.h index c6a1892e..c15f950a 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -134,6 +134,8 @@ void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data); +void zenity_scale (ZenityData *data, + ZenityScaleData *scale_data); void zenity_about (ZenityData *data); G_END_DECLS -- cgit From 80d39c09c1ceecbf854fa9a8632708e2ab6fe878 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 27 Jul 2006 03:29:44 +0000 Subject: entry activation makes dialog return OK (Fixes bug #347340). 2006-07-27 Lucas Rocha * src/entry.c (zenity_entry): entry activation makes dialog return OK (Fixes bug #347340). --- src/entry.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 4b0f588a..390d9b6b 100644 --- a/src/entry.c +++ b/src/entry.c @@ -99,13 +99,14 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) } } else { entry = gtk_entry_new(); + + gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); if (entry_data->entry_text) gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); if (entry_data->hide_text) g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - } gtk_widget_show (entry); -- cgit From e46814b46ac4687de519dfdd0fd8f578cfa17946 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 28 Jul 2006 04:18:58 +0000 Subject: correctly stdin input for text info dialog (Fixes bug #336736). 2006-07-27 Lucas Rocha * src/text.c (zenity_text_handle_stdin): correctly stdin input for text info dialog (Fixes bug #336736). --- src/text.c | 59 ++++++++++++++++++++++++++--------------------------------- 1 file changed, 26 insertions(+), 33 deletions(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index f3b331d4..1a4a3227 100644 --- a/src/text.c +++ b/src/text.c @@ -43,50 +43,43 @@ zenity_text_handle_stdin (GIOChannel *channel, buffer = GTK_TEXT_BUFFER (data); - if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) { GError *error = NULL; + gint status; while (channel->is_readable != TRUE) ; - do { - gint status; - - do { - status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); - - while (gtk_events_pending ()) - gtk_main_iteration (); - } while (status == G_IO_STATUS_AGAIN); + do { + status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_warning ("zenity_text_handle_stdin () : %s", error->message); - g_error_free (error); - error = NULL; - } - continue; - } + while (gtk_events_pending ()) + gtk_main_iteration (); - if (len > 0) { - GtkTextIter end; - gchar *utftext; - gsize localelen; - gsize utflen; + } while (status == G_IO_STATUS_AGAIN); - gtk_text_buffer_get_end_iter (buffer, &end); - utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); - gtk_text_buffer_insert (buffer, &end, utftext, utflen); - g_free (utftext); + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_text_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; } - - } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + return FALSE; + } + + if (len > 0) { + GtkTextIter end; + gchar *utftext; + gsize localelen; + gsize utflen; + + gtk_text_buffer_get_end_iter (buffer, &end); + utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); + gtk_text_buffer_insert (buffer, &end, utftext, utflen); + g_free (utftext); + } } - if (condition != G_IO_IN) { - g_io_channel_shutdown (channel, TRUE, NULL); - return FALSE; - } return TRUE; } -- cgit From d373b3f3ce9e1876f2e267bf240fbb807abd6815 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 28 Jul 2006 21:25:11 +0000 Subject: src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update, 2006-07-27 Lucas Rocha * src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update, -zenity_notification_icon_press_callback, +zenity_notification_icon_size_changed_cb, -zenity_notification_icon_expose_callback, -zenity_notification_icon_destroy_callback, +zenity_notification_icon_activate_cb, zenity_notification_handle_stdin, zenity_notification), src/util.[ch] (+zenity_util_stock_from_filename, zenity_util_pixbuf_new_from_file), Makefile.am, configure.in: Migration to gtk_status_icon (Fixes bug #341451). Patch from Christian Persch . * src/eggtrayicon.[ch]: removed. --- src/Makefile.am | 20 ++- src/eggtrayicon.c | 468 ----------------------------------------------------- src/eggtrayicon.h | 77 --------- src/notification.c | 287 +++++++++++++++----------------- src/util.c | 36 +++-- src/util.h | 3 +- 6 files changed, 163 insertions(+), 728 deletions(-) delete mode 100644 src/eggtrayicon.c delete mode 100644 src/eggtrayicon.h (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 192dc3b5..e70a51b2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -3,24 +3,22 @@ bin_PROGRAMS = zenity bin_SCRIPTS = gdialog zenity_SOURCES = \ + about.c \ + calendar.c \ + entry.c \ + fileselection.c \ main.c \ + msg.c \ + notification.c \ option.c \ option.h \ - zenity.h \ - calendar.c \ - msg.c \ + progress.c \ scale.c \ - fileselection.c \ - entry.c \ text.c \ - progress.c \ tree.c \ - eggtrayicon.h \ - eggtrayicon.c \ - notification.c \ - about.c \ + util.c \ util.h \ - util.c + zenity.h zenity_CPPFLAGS = \ -I$(includedir) \ diff --git a/src/eggtrayicon.c b/src/eggtrayicon.c deleted file mode 100644 index 1e6d5bdd..00000000 --- a/src/eggtrayicon.c +++ /dev/null @@ -1,468 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eggtrayicon.c - * Copyright (C) 2002 Anders Carlsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - */ - -#include -#include -#include - -#include "eggtrayicon.h" - -#include -#include - -#ifndef EGG_COMPILATION -#ifndef _ -#define _(x) dgettext (GETTEXT_PACKAGE, x) -#define N_(x) x -#endif -#else -#define _(x) x -#define N_(x) x -#endif - -#define SYSTEM_TRAY_REQUEST_DOCK 0 -#define SYSTEM_TRAY_BEGIN_MESSAGE 1 -#define SYSTEM_TRAY_CANCEL_MESSAGE 2 - -#define SYSTEM_TRAY_ORIENTATION_HORZ 0 -#define SYSTEM_TRAY_ORIENTATION_VERT 1 - -enum { - PROP_0, - PROP_ORIENTATION -}; - -static GtkPlugClass *parent_class = NULL; - -static void egg_tray_icon_init (EggTrayIcon *icon); -static void egg_tray_icon_class_init (EggTrayIconClass *klass); - -static void egg_tray_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); - -static void egg_tray_icon_realize (GtkWidget *widget); -static void egg_tray_icon_unrealize (GtkWidget *widget); - -static void egg_tray_icon_update_manager_window (EggTrayIcon *icon); - -GType -egg_tray_icon_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - { - static const GTypeInfo our_info = - { - sizeof (EggTrayIconClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) egg_tray_icon_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (EggTrayIcon), - 0, /* n_preallocs */ - (GInstanceInitFunc) egg_tray_icon_init - }; - - our_type = g_type_register_static (GTK_TYPE_PLUG, "EggTrayIcon", &our_info, 0); - } - - return our_type; -} - -static void -egg_tray_icon_init (EggTrayIcon *icon) -{ - icon->stamp = 1; - icon->orientation = GTK_ORIENTATION_HORIZONTAL; - - gtk_widget_add_events (GTK_WIDGET (icon), GDK_PROPERTY_CHANGE_MASK); -} - -static void -egg_tray_icon_class_init (EggTrayIconClass *klass) -{ - GObjectClass *gobject_class = (GObjectClass *)klass; - GtkWidgetClass *widget_class = (GtkWidgetClass *)klass; - - parent_class = g_type_class_peek_parent (klass); - - gobject_class->get_property = egg_tray_icon_get_property; - - widget_class->realize = egg_tray_icon_realize; - widget_class->unrealize = egg_tray_icon_unrealize; - - g_object_class_install_property (gobject_class, - PROP_ORIENTATION, - g_param_spec_enum ("orientation", - _("Orientation"), - _("The orientation of the tray."), - GTK_TYPE_ORIENTATION, - GTK_ORIENTATION_HORIZONTAL, - G_PARAM_READABLE)); -} - -static void -egg_tray_icon_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (object); - - switch (prop_id) - { - case PROP_ORIENTATION: - g_value_set_enum (value, icon->orientation); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -egg_tray_icon_get_orientation_property (EggTrayIcon *icon) -{ - Display *xdisplay; - Atom type; - int format; - union { - gulong *prop; - guchar *prop_ch; - } prop = { NULL }; - gulong nitems; - gulong bytes_after; - int error, result; - - g_assert (icon->manager_window != None); - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - gdk_error_trap_push (); - type = None; - result = XGetWindowProperty (xdisplay, - icon->manager_window, - icon->orientation_atom, - 0, G_MAXLONG, FALSE, - XA_CARDINAL, - &type, &format, &nitems, - &bytes_after, &(prop.prop_ch)); - error = gdk_error_trap_pop (); - - if (error || result != Success) - return; - - if (type == XA_CARDINAL) - { - GtkOrientation orientation; - - orientation = (prop.prop [0] == SYSTEM_TRAY_ORIENTATION_HORZ) ? - GTK_ORIENTATION_HORIZONTAL : - GTK_ORIENTATION_VERTICAL; - - if (icon->orientation != orientation) - { - icon->orientation = orientation; - - g_object_notify (G_OBJECT (icon), "orientation"); - } - } - - if (prop.prop) - XFree (prop.prop); -} - -static GdkFilterReturn -egg_tray_icon_manager_filter (GdkXEvent *xevent, GdkEvent *event, gpointer user_data) -{ - EggTrayIcon *icon = user_data; - XEvent *xev = (XEvent *)xevent; - - if (xev->xany.type == ClientMessage && - xev->xclient.message_type == icon->manager_atom && - xev->xclient.data.l[1] == icon->selection_atom) - { - egg_tray_icon_update_manager_window (icon); - } - else if (xev->xany.window == icon->manager_window) - { - if (xev->xany.type == PropertyNotify && - xev->xproperty.atom == icon->orientation_atom) - { - egg_tray_icon_get_orientation_property (icon); - } - if (xev->xany.type == DestroyNotify) - { - egg_tray_icon_update_manager_window (icon); - } - } - - return GDK_FILTER_CONTINUE; -} - -static void -egg_tray_icon_unrealize (GtkWidget *widget) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (widget); - GdkWindow *root_window; - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (widget), - icon->manager_window); - - gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); - } - - root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget)); - - gdk_window_remove_filter (root_window, egg_tray_icon_manager_filter, icon); - - if (GTK_WIDGET_CLASS (parent_class)->unrealize) - (* GTK_WIDGET_CLASS (parent_class)->unrealize) (widget); -} - -static void -egg_tray_icon_send_manager_message (EggTrayIcon *icon, - long message, - Window window, - long data1, - long data2, - long data3) -{ - XClientMessageEvent ev; - Display *display; - - ev.type = ClientMessage; - ev.window = window; - ev.message_type = icon->system_tray_opcode_atom; - ev.format = 32; - ev.data.l[0] = gdk_x11_get_server_time (GTK_WIDGET (icon)->window); - ev.data.l[1] = message; - ev.data.l[2] = data1; - ev.data.l[3] = data2; - ev.data.l[4] = data3; - - display = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - gdk_error_trap_push (); - XSendEvent (display, - icon->manager_window, False, NoEventMask, (XEvent *)&ev); - XSync (display, False); - gdk_error_trap_pop (); -} - -static void -egg_tray_icon_send_dock_request (EggTrayIcon *icon) -{ - egg_tray_icon_send_manager_message (icon, - SYSTEM_TRAY_REQUEST_DOCK, - icon->manager_window, - gtk_plug_get_id (GTK_PLUG (icon)), - 0, 0); -} - -static void -egg_tray_icon_update_manager_window (EggTrayIcon *icon) -{ - Display *xdisplay; - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), - icon->manager_window); - - gdk_window_remove_filter (gdkwin, egg_tray_icon_manager_filter, icon); - } - - XGrabServer (xdisplay); - - icon->manager_window = XGetSelectionOwner (xdisplay, - icon->selection_atom); - - if (icon->manager_window != None) - XSelectInput (xdisplay, - icon->manager_window, StructureNotifyMask|PropertyChangeMask); - - XUngrabServer (xdisplay); - XFlush (xdisplay); - - if (icon->manager_window != None) - { - GdkWindow *gdkwin; - - gdkwin = gdk_window_lookup_for_display (gtk_widget_get_display (GTK_WIDGET (icon)), - icon->manager_window); - - gdk_window_add_filter (gdkwin, egg_tray_icon_manager_filter, icon); - - /* Send a request that we'd like to dock */ - egg_tray_icon_send_dock_request (icon); - - egg_tray_icon_get_orientation_property (icon); - } -} - -static void -egg_tray_icon_realize (GtkWidget *widget) -{ - EggTrayIcon *icon = EGG_TRAY_ICON (widget); - GdkScreen *screen; - GdkDisplay *display; - Display *xdisplay; - char buffer[256]; - GdkWindow *root_window; - - if (GTK_WIDGET_CLASS (parent_class)->realize) - GTK_WIDGET_CLASS (parent_class)->realize (widget); - - screen = gtk_widget_get_screen (widget); - display = gdk_screen_get_display (screen); - xdisplay = gdk_x11_display_get_xdisplay (display); - - /* Now see if there's a manager window around */ - g_snprintf (buffer, sizeof (buffer), - "_NET_SYSTEM_TRAY_S%d", - gdk_screen_get_number (screen)); - - icon->selection_atom = XInternAtom (xdisplay, buffer, False); - - icon->manager_atom = XInternAtom (xdisplay, "MANAGER", False); - - icon->system_tray_opcode_atom = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_OPCODE", - False); - - icon->orientation_atom = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_ORIENTATION", - False); - - egg_tray_icon_update_manager_window (icon); - - root_window = gdk_screen_get_root_window (screen); - - /* Add a root window filter so that we get changes on MANAGER */ - gdk_window_add_filter (root_window, - egg_tray_icon_manager_filter, icon); -} - -EggTrayIcon * -egg_tray_icon_new_for_screen (GdkScreen *screen, const char *name) -{ - g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); - - return g_object_new (EGG_TYPE_TRAY_ICON, "screen", screen, "title", name, NULL); -} - -EggTrayIcon* -egg_tray_icon_new (const gchar *name) -{ - return g_object_new (EGG_TYPE_TRAY_ICON, "title", name, NULL); -} - -guint -egg_tray_icon_send_message (EggTrayIcon *icon, - gint timeout, - const gchar *message, - gint len) -{ - guint stamp; - - g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), 0); - g_return_val_if_fail (timeout >= 0, 0); - g_return_val_if_fail (message != NULL, 0); - - if (icon->manager_window == None) - return 0; - - if (len < 0) - len = strlen (message); - - stamp = icon->stamp++; - - /* Get ready to send the message */ - egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_BEGIN_MESSAGE, - (Window)gtk_plug_get_id (GTK_PLUG (icon)), - timeout, len, stamp); - - /* Now to send the actual message */ - gdk_error_trap_push (); - while (len > 0) - { - XClientMessageEvent ev; - Display *xdisplay; - - xdisplay = GDK_DISPLAY_XDISPLAY (gtk_widget_get_display (GTK_WIDGET (icon))); - - ev.type = ClientMessage; - ev.window = (Window)gtk_plug_get_id (GTK_PLUG (icon)); - ev.format = 8; - ev.message_type = XInternAtom (xdisplay, - "_NET_SYSTEM_TRAY_MESSAGE_DATA", False); - if (len > 20) - { - memcpy (&ev.data, message, 20); - len -= 20; - message += 20; - } - else - { - memcpy (&ev.data, message, len); - len = 0; - } - - XSendEvent (xdisplay, - icon->manager_window, False, StructureNotifyMask, (XEvent *)&ev); - XSync (xdisplay, False); - } - gdk_error_trap_pop (); - - return stamp; -} - -void -egg_tray_icon_cancel_message (EggTrayIcon *icon, - guint id) -{ - g_return_if_fail (EGG_IS_TRAY_ICON (icon)); - g_return_if_fail (id > 0); - - egg_tray_icon_send_manager_message (icon, SYSTEM_TRAY_CANCEL_MESSAGE, - (Window)gtk_plug_get_id (GTK_PLUG (icon)), - id, 0, 0); -} - -GtkOrientation -egg_tray_icon_get_orientation (EggTrayIcon *icon) -{ - g_return_val_if_fail (EGG_IS_TRAY_ICON (icon), GTK_ORIENTATION_HORIZONTAL); - - return icon->orientation; -} diff --git a/src/eggtrayicon.h b/src/eggtrayicon.h deleted file mode 100644 index 007f4c18..00000000 --- a/src/eggtrayicon.h +++ /dev/null @@ -1,77 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ -/* eggtrayicon.h - * Copyright (C) 2002 Anders Carlsson - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef __EGG_TRAY_ICON_H__ -#define __EGG_TRAY_ICON_H__ - -#include -#include - -G_BEGIN_DECLS - -#define EGG_TYPE_TRAY_ICON (egg_tray_icon_get_type ()) -#define EGG_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EGG_TYPE_TRAY_ICON, EggTrayIcon)) -#define EGG_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) -#define EGG_IS_TRAY_ICON(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EGG_TYPE_TRAY_ICON)) -#define EGG_IS_TRAY_ICON_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EGG_TYPE_TRAY_ICON)) -#define EGG_TRAY_ICON_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), EGG_TYPE_TRAY_ICON, EggTrayIconClass)) - -typedef struct _EggTrayIcon EggTrayIcon; -typedef struct _EggTrayIconClass EggTrayIconClass; - -struct _EggTrayIcon -{ - GtkPlug parent_instance; - - guint stamp; - - Atom selection_atom; - Atom manager_atom; - Atom system_tray_opcode_atom; - Atom orientation_atom; - Window manager_window; - - GtkOrientation orientation; -}; - -struct _EggTrayIconClass -{ - GtkPlugClass parent_class; -}; - -GType egg_tray_icon_get_type (void); - -EggTrayIcon *egg_tray_icon_new_for_screen (GdkScreen *screen, - const gchar *name); - -EggTrayIcon *egg_tray_icon_new (const gchar *name); - -guint egg_tray_icon_send_message (EggTrayIcon *icon, - gint timeout, - const char *message, - gint len); -void egg_tray_icon_cancel_message (EggTrayIcon *icon, - guint id); - -GtkOrientation egg_tray_icon_get_orientation (EggTrayIcon *icon); - -G_END_DECLS - -#endif /* __EGG_TRAY_ICON_H__ */ diff --git a/src/notification.c b/src/notification.c index 6d5f8dd7..222fbc8a 100644 --- a/src/notification.c +++ b/src/notification.c @@ -2,6 +2,7 @@ * notification.c * * Copyright (C) 2002 Sun Microsystems, Inc. + * Copyright (C) 2006 Christian Persch * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -23,6 +24,7 @@ #include +#include #include #include #include @@ -32,101 +34,71 @@ #endif #include "zenity.h" -#include "eggtrayicon.h" #include "util.h" -static EggTrayIcon *tray_icon; -static GtkWidget *icon_image; -static GtkWidget *icon_event_box; -static GtkTooltips *tooltips; - +static GtkStatusIcon *status_icon; +static gchar *icon_file; +static const gchar *icon_stock; +static gint icon_size; static void -set_scaled_pixbuf (GtkImage *image, GdkPixbuf *pixbuf, GtkIconSize icon_size) +zenity_notification_icon_update (void) { - GdkScreen *screen; - GtkSettings *settings; - int width, height, desired_width, desired_height; - GdkPixbuf *new_pixbuf; - - screen = gtk_widget_get_screen (GTK_WIDGET (image)); - settings = gtk_settings_get_for_screen (screen); - if (!gtk_icon_size_lookup_for_settings (settings, icon_size, - &desired_width, &desired_height)) - return; - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - if (height > desired_height || width > desired_width) { - if (width * desired_height / height > desired_width) - desired_height = height * desired_width / width; - else - desired_width = width * desired_height / height; - - new_pixbuf = gdk_pixbuf_scale_simple (pixbuf, - desired_width, - desired_height, - GDK_INTERP_BILINEAR); - gtk_image_set_from_pixbuf (image, new_pixbuf); - g_object_unref (new_pixbuf); - } else { - gtk_image_set_from_pixbuf (image, pixbuf); + GdkPixbuf *pixbuf; + GError *error = NULL; + + pixbuf = gdk_pixbuf_new_from_file_at_scale (icon_file, icon_size, icon_size, TRUE, &error); + if (error) { + g_warning ("Could not load notification icon '%s': %s", + icon_file, error->message); + g_clear_error (&error); + } + if (!pixbuf) { + pixbuf = gdk_pixbuf_new_from_file_at_scale (ZENITY_IMAGE_FULLPATH ("zenity-notification.png"), + icon_size, icon_size, TRUE, NULL); + } + + gtk_status_icon_set_from_pixbuf (status_icon, pixbuf); + + if (pixbuf) { + g_object_unref (pixbuf); } } static gboolean -zenity_notification_icon_press_callback (GtkWidget *widget, GdkEventButton *event, gpointer data) +zenity_notification_icon_size_changed_cb (GtkStatusIcon *icon, + gint size, + gpointer user_data) { - ZenityData *zen_data; + icon_size = size; - zen_data = data; + /* If we're displaying not a stock icon but a custom pixbuf, + * we need to update the icon for the new size. + */ + if (!icon_stock) { + zenity_notification_icon_update (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); - return TRUE; -} + return TRUE; + } -static gboolean -zenity_notification_icon_expose_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data) -{ - if (GTK_WIDGET_HAS_FOCUS (widget)) { - gint focus_width, focus_pad; - gint x, y, width, height; - - gtk_widget_style_get (widget, - "focus-line-width", &focus_width, - "focus-padding", &focus_pad, - NULL); - x = widget->allocation.x + focus_pad; - y = widget->allocation.y + focus_pad; - width = widget->allocation.width - 2 * focus_pad; - height = widget->allocation.height - 2 * focus_pad; - - gtk_paint_focus (widget->style, widget->window, - GTK_WIDGET_STATE (widget), - &event->area, widget, "button", - x, y, width, height); - } - - return FALSE; + return FALSE; } -static void -zenity_notification_icon_destroy_callback (GtkWidget *widget, gpointer data) +static gboolean +zenity_notification_icon_activate_cb (GtkWidget *widget, + ZenityData *data) { - ZenityData *zen_data; + data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - zen_data = data; - gtk_widget_destroy (GTK_WIDGET (tray_icon)); - - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); gtk_main_quit (); + + return TRUE; } static gboolean -zenity_notification_handle_stdin (GIOChannel *channel, +zenity_notification_handle_stdin (GIOChannel *channel, GIOCondition condition, - gpointer user_data) + gpointer user_data) { ZenityData *zen_data; @@ -137,7 +109,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, GError *error = NULL; string = g_string_new (NULL); - while (channel->is_readable != TRUE) + while (channel->is_readable == FALSE) ; do { gint status; @@ -167,60 +139,72 @@ zenity_notification_handle_stdin (GIOChannel *channel, continue; } /* split off the command and value */ - command = g_strndup (string->str, colon - string->str); - command = g_strstrip (command); - g_strdown (command); + command = g_strstrip (g_strndup (string->str, colon - string->str)); value = colon + 1; while (*value && g_ascii_isspace (*value)) value++; - if (!strcmp (command, "icon")) { - GdkPixbuf *pixbuf; - - pixbuf = zenity_util_pixbuf_new_from_file (GTK_WIDGET (tray_icon), - value); - if (pixbuf != NULL) { - set_scaled_pixbuf (GTK_IMAGE (icon_image), pixbuf, - GTK_ICON_SIZE_BUTTON); - gdk_pixbuf_unref (pixbuf); - } else { - g_warning ("Could not load notification icon : %s", value); - } - } else if (!strcmp (command, "message")) { -#ifdef HAVE_LIBNOTIFY - /* display a notification bubble */ - if (notify_is_initted ()) { - GError *error = NULL; - NotifyNotification *n; - GdkPixbuf *icon; - - n = notify_notification_new (g_strcompress (value), NULL, NULL, - GTK_WIDGET (tray_icon)); + if (!g_ascii_strcasecmp (command, "icon")) { + icon_stock = zenity_util_stock_from_filename (value); - icon = gtk_image_get_pixbuf (GTK_IMAGE (icon_image)); + g_free (icon_file); + icon_file = g_strdup (value); - notify_notification_set_icon_from_pixbuf (n, icon); - - notify_notification_show (n, &error); + if (icon_stock) { + gtk_status_icon_set_from_stock (status_icon, icon_stock); + } else if (gtk_status_icon_get_visible (status_icon) && + gtk_status_icon_is_embedded (status_icon)) { + zenity_notification_icon_update (); + } + } else if (!g_ascii_strcasecmp (command, "message")) { +#ifdef HAVE_LIBNOTIFY + /* display a notification bubble */ + if (!g_utf8_validate (value, -1, NULL)) { + g_warning ("Invalid UTF-8 in input!"); + } else if (notify_is_initted ()) { + GError *error = NULL; + NotifyNotification *notif; + const gchar *icon = NULL; + gchar *freeme = NULL; + gchar *message; + + message = g_strcompress (value); + + if (icon_stock) { + icon = icon_stock; + } else if (icon_file) { + icon = freeme = g_filename_to_uri (icon_file, NULL, NULL); + } + + notif = notify_notification_new_with_status_icon (message, NULL /* summary */, + icon, status_icon); + g_free (message); + g_free (freeme); + + notify_notification_show (notif, &error); if (error) { - g_warning (error->message); + g_warning ("Error showing notification: %s", error->message); g_error_free (error); } - g_object_unref (G_OBJECT (n)); + g_object_unref (notif); } else { #else { /* this brace is for balance */ #endif g_warning ("Notification framework not available"); } - } else if (!strcmp (command, "tooltip")) { - gtk_tooltips_set_tip (tooltips, icon_event_box, value, value); - } else if (!strcmp (command, "visible")) { - if (!strcasecmp (value, "false")) { - gtk_widget_hide (GTK_WIDGET (tray_icon)); - } else { - gtk_widget_show (GTK_WIDGET (tray_icon)); + } else if (!g_ascii_strcasecmp (command, "tooltip")) { + if (g_utf8_validate (value, -1, NULL)) { + gtk_status_icon_set_tooltip (status_icon, value); + } else { + g_warning ("Invalid UTF-8 in input!"); + } + } else if (!g_ascii_strcasecmp (command, "visible")) { + if (!g_ascii_strcasecmp (value, "false")) { + gtk_status_icon_set_visible (status_icon, FALSE); + } else { + gtk_status_icon_set_visible (status_icon, TRUE); } } else { g_warning ("Unknown command '%s'", command); @@ -256,64 +240,47 @@ zenity_notification_listen_on_stdin (ZenityData *data) void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data) { - GdkPixbuf *pixbuf = NULL; + status_icon = gtk_status_icon_new (); + g_signal_connect (status_icon, "size-changed", + G_CALLBACK (zenity_notification_icon_size_changed_cb), data); - tray_icon = egg_tray_icon_new (_("Zenity notification")); - tooltips = gtk_tooltips_new (); - - if (data->window_icon != NULL) - pixbuf = zenity_util_pixbuf_new_from_file (GTK_WIDGET (tray_icon), data->window_icon); - else - pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity-notification.png"), NULL); - - icon_event_box = gtk_event_box_new (); - icon_image = gtk_image_new (); - - if (pixbuf) { - set_scaled_pixbuf (GTK_IMAGE (icon_image), pixbuf, - GTK_ICON_SIZE_BUTTON); - gdk_pixbuf_unref (pixbuf); + if (notification_data->notification_text) { + gtk_status_icon_set_tooltip (status_icon, notification_data->notification_text); } else { - if (data->window_icon != NULL) { - g_warning ("Could not load notification icon : %s", data->window_icon); - } - else - g_warning ("Could not load notification icon : %s", ZENITY_IMAGE_FULLPATH ("zenity-notification.png")); - return; + gtk_status_icon_set_tooltip (status_icon, _("Zenity notification")); } - gtk_container_add (GTK_CONTAINER (icon_event_box), icon_image); - - if (notification_data->notification_text) - gtk_tooltips_set_tip (tooltips, icon_event_box, notification_data->notification_text, notification_data->notification_text); - else - gtk_tooltips_set_tip (tooltips, icon_event_box, _("Zenity notification"), _("Zenity notification")); - - gtk_widget_add_events (GTK_WIDGET (tray_icon), GDK_BUTTON_PRESS_MASK | GDK_FOCUS_CHANGE_MASK); - gtk_container_add (GTK_CONTAINER (tray_icon), icon_event_box); + icon_file = g_strdup (data->window_icon); + icon_stock = zenity_util_stock_from_filename (data->window_icon); - g_signal_connect (tray_icon, "destroy", - G_CALLBACK (zenity_notification_icon_destroy_callback), data); - - g_signal_connect (tray_icon, "expose_event", - G_CALLBACK (zenity_notification_icon_expose_callback), data); + /* Only set the stock icon here; if we're going to display a + * custom pixbuf we wait for the size-changed signal to load + * it at the right size. + */ + if (icon_stock) { + gtk_status_icon_set_from_stock (status_icon, icon_stock); + } +#ifdef HAVE_LIBNOTIFY + /* create the notification widget */ + if (!notify_is_initted ()) { + notify_init (_("Zenity notification")); + } +#endif + if (notification_data->listen) { zenity_notification_listen_on_stdin (data); } else { - /* if we aren't listening for changes, then close on button_press */ - g_signal_connect (tray_icon, "button_press_event", - G_CALLBACK (zenity_notification_icon_press_callback), data); + /* if we aren't listening for changes, then close on activate (left-click) */ + g_signal_connect (status_icon, "activate", + G_CALLBACK (zenity_notification_icon_activate_cb), data); } -#ifdef HAVE_LIBNOTIFY - /* create the notification widget */ - if (!notify_is_initted ()) - notify_init (_("Zenity notification")); -#endif - - gtk_widget_show_all (GTK_WIDGET (tray_icon)); - - /* Does nothing at the moment */ + /* Show icon and wait */ + gtk_status_icon_set_visible (status_icon, TRUE); gtk_main (); + + /* Cleanup */ + g_object_unref (status_icon); + g_free (icon_file); } diff --git a/src/util.c b/src/util.c index 4fc7f8d4..41c7c556 100644 --- a/src/util.c +++ b/src/util.c @@ -145,19 +145,33 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) return TRUE; } +const gchar * +zenity_util_stock_from_filename (const gchar *filename) +{ + if (!filename || !filename[0]) + return GTK_STOCK_DIALOG_WARNING; /* default */ + + if (!g_ascii_strcasecmp (filename, "warning")) + return GTK_STOCK_DIALOG_WARNING; + if (!g_ascii_strcasecmp (filename, "info")) + return GTK_STOCK_DIALOG_INFO; + if (!g_ascii_strcasecmp (filename, "question")) + return GTK_STOCK_DIALOG_QUESTION; + if (!g_ascii_strcasecmp (filename, "error")) + return GTK_STOCK_DIALOG_ERROR; + return NULL; +} + GdkPixbuf * -zenity_util_pixbuf_new_from_file (GtkWidget *widget, gchar *filename) +zenity_util_pixbuf_new_from_file (GtkWidget *widget, const gchar *filename) { - if (!strcasecmp (filename, "warning")) - return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcasecmp (filename, "info")) - return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcasecmp (filename, "question")) - return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_BUTTON, NULL); - if (!strcasecmp (filename, "error")) - return gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_BUTTON, NULL); - else - return gdk_pixbuf_new_from_file (filename, NULL); + const gchar *stock; + + stock = zenity_util_stock_from_filename (filename); + if (stock) + return gtk_widget_render_icon (widget, stock, GTK_ICON_SIZE_BUTTON, NULL); + + return gdk_pixbuf_new_from_file (filename, NULL); } void diff --git a/src/util.h b/src/util.h index cbf96ab1..7535275b 100644 --- a/src/util.h +++ b/src/util.h @@ -15,6 +15,7 @@ GladeXML* zenity_util_load_glade_file (const gchar *widge gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); +const gchar * zenity_util_stock_from_filename (const gchar *filename); void zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file); @@ -22,7 +23,7 @@ void zenity_util_set_window_icon_from_stock (GtkWidget *widge const gchar *filename, const gchar *default_stock_id); GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, - gchar *filename); + const gchar *filename); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_show_dialog (GtkWidget *widget); -- cgit From 94e6ab1132d0510edb6a733593de7f031d259101 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 9 Aug 2006 00:55:59 +0000 Subject: Release 2.15.91 Update. 2006-07-28 Lucas Rocha * configure.in: Release 2.15.91 * NEWS: Update. --- src/notification.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 222fbc8a..745d8a35 100644 --- a/src/notification.c +++ b/src/notification.c @@ -182,6 +182,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, g_free (freeme); notify_notification_show (notif, &error); + if (error) { g_warning ("Error showing notification: %s", error->message); g_error_free (error); -- cgit From 4d9c0448f583c97fdac316c6773951f987357dbc Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 2 Dec 2006 10:41:21 +0000 Subject: don't show cancel button on warning dialog (Fixes bug #324100). Patch from 2006-12-02 Lucas Rocha * src/zenity.glade: don't show cancel button on warning dialog (Fixes bug #324100). Patch from Claudio Saavedra --- src/zenity.glade | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 9e018654..3cd6aa30 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -193,19 +193,6 @@ True GTK_BUTTONBOX_END - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - True -- cgit From 09c4a49800992d979845e3c7a05122b5aa1ceaed Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 2 Dec 2006 10:54:45 +0000 Subject: add "auto-kill" option to progress dialog. Now the user can choose whether 2006-12-02 Lucas Rocha * src/zenity.h, src/progress.c, src/option.c: add "auto-kill" option to progress dialog. Now the user can choose whether to kill parent process or not (Fixes bug #310824). Patch from Diego Escalante Urrelo . --- src/option.c | 17 +++++++++++++++++ src/progress.c | 21 +++++++++++++++------ src/zenity.h | 1 + 3 files changed, 33 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 2be45500..79c327a2 100644 --- a/src/option.c +++ b/src/option.c @@ -82,6 +82,7 @@ static gboolean zenity_progress_active; static int zenity_progress_percentage; static gboolean zenity_progress_pulsate; static gboolean zenity_progress_auto_close; +static gboolean zenity_progress_auto_kill; /* Question Dialog Options */ static gboolean zenity_question_active; @@ -561,6 +562,16 @@ static GOptionEntry progress_options[] = { N_("Dismiss the dialog when 100% has been reached"), NULL }, + { + "auto-kill", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_auto_kill, + /* xgettext: no-c-format */ + N_("Kill parent process if cancel button is pressed"), + NULL + }, { NULL } @@ -974,6 +985,7 @@ zenity_progress_pre_callback (GOptionContext *context, zenity_progress_percentage = 0; zenity_progress_pulsate = FALSE; zenity_progress_auto_close = FALSE; + zenity_progress_auto_kill = FALSE; return TRUE; } @@ -1282,6 +1294,7 @@ zenity_progress_post_callback (GOptionContext *context, results->progress_data->dialog_text = zenity_general_dialog_text; results->progress_data->pulsate = zenity_progress_pulsate; results->progress_data->autoclose = zenity_progress_auto_close; + results->progress_data->autokill = zenity_progress_auto_kill; results->progress_data->percentage = zenity_progress_percentage; } else { if (zenity_progress_pulsate) @@ -1295,6 +1308,10 @@ zenity_progress_post_callback (GOptionContext *context, if (zenity_progress_auto_close) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close), ERROR_SUPPORT); + + if (zenity_progress_auto_kill) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_kill), + ERROR_SUPPORT); } return TRUE; diff --git a/src/progress.c b/src/progress.c index 68f34ac4..d14969b2 100644 --- a/src/progress.c +++ b/src/progress.c @@ -37,6 +37,8 @@ static GladeXML *glade_dialog; static ZenityData *zen_data; static GIOChannel *channel; +static gboolean autokill; + gint zenity_progress_timeout (gpointer data); gint zenity_progress_pulsate_timeout (gpointer data); @@ -214,6 +216,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); + autokill = progress_data->autokill; + zenity_util_show_dialog (dialog); zenity_progress_read_info (progress_data); @@ -229,14 +233,19 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) break; case GTK_RESPONSE_CANCEL: - /* FIXME: This should kill off the parent process nicely and return an error code - * I'm pretty sure there is a nice way to do this, but I'm clueless about this - * stuff. Should be using SIGHUP instead of 1 though. - */ - kill (getppid (), 1); + /* We do not want to kill the parent process, in order to give the user + the ability to choose the action to be taken. See bug #310824. + -- Monday 27, March 2006 + But we want to give people the option to choose this behavior. + */ + if (autokill) { + kill (getppid (), 1); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + } zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; - + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/zenity.h b/src/zenity.h index c15f950a..330d317d 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -91,6 +91,7 @@ typedef struct { gchar *entry_text; gboolean pulsate; gboolean autoclose; + gboolean autokill; gdouble percentage; } ZenityProgressData; -- cgit From 784eada1b4defd0aa4bbcfd4431a012b8855fad5 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 3 Dec 2006 16:48:39 +0000 Subject: merged identic i18n strings (Fixes bug #334361). 2006-12-03 Lucas Rocha * src/zenity.glade: merged identic i18n strings (Fixes bug #334361). --- src/zenity.glade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 3cd6aa30..123536cc 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -1234,7 +1234,7 @@ True - Adjust the scale value. + Adjust the scale value False True GTK_JUSTIFY_LEFT -- cgit From 72e55948250d955b9abdeba2fb34fe0d4ef69898 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 4 Dec 2006 20:22:54 +0000 Subject: make dialog text selectable on message dialogs (error, warning, info, and 2006-12-04 Lucas Rocha * src/zenity.glade: make dialog text selectable on message dialogs (error, warning, info, and question) (Fixes bug #352910). Patch from Greg Hudson . --- src/zenity.glade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 123536cc..c496dcc7 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -247,7 +247,7 @@ True GTK_JUSTIFY_LEFT True - False + True 0.5 0 0 @@ -410,7 +410,7 @@ True GTK_JUSTIFY_LEFT True - False + True 0.5 0 0 @@ -877,7 +877,7 @@ True GTK_JUSTIFY_LEFT True - False + True 0.5 0 0 @@ -1131,7 +1131,7 @@ True GTK_JUSTIFY_LEFT True - False + True 0.5 0 0 -- cgit From 7a58e9e4c77f835ec51b87e618bcfab1b4ad0764 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 4 Dec 2006 20:35:48 +0000 Subject: complete list dialog options with respective arguments (Fixes bug 2006-12-04 Lucas Rocha * src/option.c: complete list dialog options with respective arguments (Fixes bug #353320). Patch from Glynn Foster . --- src/option.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 79c327a2..5fe5dbce 100644 --- a/src/option.c +++ b/src/option.c @@ -165,7 +165,7 @@ static GOptionEntry calendar_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "day", @@ -174,7 +174,7 @@ static GOptionEntry calendar_options[] = { G_OPTION_ARG_INT, &zenity_calendar_day, N_("Set the calendar day"), - NULL + N_("DAY") }, { "month", @@ -183,7 +183,7 @@ static GOptionEntry calendar_options[] = { G_OPTION_ARG_INT, &zenity_calendar_month, N_("Set the calendar month"), - NULL + N_("MONTH") }, { "year", @@ -192,7 +192,7 @@ static GOptionEntry calendar_options[] = { G_OPTION_ARG_INT, &zenity_calendar_year, N_("Set the calendar year"), - NULL + N_("YEAR") }, { "date-format", @@ -201,7 +201,7 @@ static GOptionEntry calendar_options[] = { G_OPTION_ARG_STRING, &zenity_calendar_date_format, N_("Set the format for the returned date"), - NULL + N_("PATTERN") }, { NULL @@ -225,7 +225,7 @@ static GOptionEntry entry_options[] = { G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "entry-text", @@ -234,7 +234,7 @@ static GOptionEntry entry_options[] = { G_OPTION_ARG_STRING, &zenity_entry_entry_text, N_("Set the entry text"), - NULL + N_("TEXT") }, { "hide-text", @@ -243,7 +243,7 @@ static GOptionEntry entry_options[] = { G_OPTION_ARG_NONE, &zenity_entry_hide_text, N_("Hide the entry text"), - NULL + N_("TEXT") }, { NULL @@ -268,7 +268,7 @@ static GOptionEntry error_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "no-wrap", @@ -301,7 +301,7 @@ static GOptionEntry info_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "no-wrap", @@ -403,7 +403,7 @@ static GOptionEntry list_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "column", @@ -412,7 +412,7 @@ static GOptionEntry list_options[] = { G_OPTION_ARG_STRING_ARRAY, &zenity_list_columns, N_("Set the column header"), - NULL + N_("COLUMN") }, { "checklist", @@ -466,7 +466,7 @@ static GOptionEntry list_options[] = { G_OPTION_ARG_STRING, &zenity_list_print_column, N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), - NULL + N_("NUMBER") }, { "hide-column", @@ -475,7 +475,7 @@ static GOptionEntry list_options[] = { G_OPTION_ARG_STRING, &zenity_list_hide_column, N_("Hide a specific column"), - NULL + N_("NUMBER") }, { NULL @@ -499,7 +499,7 @@ static GOptionEntry notification_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the notification text"), - NULL + N_("TEXT") }, { "listen", @@ -532,7 +532,7 @@ static GOptionEntry progress_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "percentage", @@ -541,7 +541,7 @@ static GOptionEntry progress_options[] = { G_OPTION_ARG_INT, &zenity_progress_percentage, N_("Set initial percentage"), - NULL + N_("PERCENTAGE") }, { "pulsate", @@ -594,7 +594,7 @@ static GOptionEntry question_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "no-wrap", @@ -660,7 +660,7 @@ static GOptionEntry warning_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "no-wrap", @@ -693,7 +693,7 @@ static GOptionEntry scale_options[] = { G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), - NULL + N_("TEXT") }, { "value", @@ -702,7 +702,7 @@ static GOptionEntry scale_options[] = { G_OPTION_ARG_INT, &zenity_scale_value, N_("Set initial value"), - NULL + N_("VALUE") }, { "min-value", @@ -711,7 +711,7 @@ static GOptionEntry scale_options[] = { G_OPTION_ARG_INT, &zenity_scale_min_value, N_("Set minimum value"), - NULL + N_("VALUE") }, { "max-value", @@ -720,7 +720,7 @@ static GOptionEntry scale_options[] = { G_OPTION_ARG_INT, &zenity_scale_max_value, N_("Set maximum value"), - NULL + N_("VALUE") }, { "step", @@ -729,7 +729,7 @@ static GOptionEntry scale_options[] = { G_OPTION_ARG_INT, &zenity_scale_step, N_("Set step size"), - NULL + N_("VALUE") }, { "print-partial", -- cgit From adee9db56646cc297fd226db983d40f3ba0d4793 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 May 2007 21:26:08 +0000 Subject: general cleanups for build warnings (Fixes bug #416196). Patch from 2007-05-14 Lucas Rocha * src/progress.c (zenity_progress_handle_stdin), src/option.c (zenity_create_context), src/about.c, src/notification.c (zenity_notification_handle_stdin): general cleanups for build warnings (Fixes bug #416196). Patch from Kjartan Maraas . svn path=/trunk/; revision=1208 --- src/about.c | 2 +- src/notification.c | 2 +- src/option.c | 30 +++++++++++++++--------------- src/progress.c | 2 -- 4 files changed, 17 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 0d92a902..434b7bb9 100644 --- a/src/about.c +++ b/src/about.c @@ -61,7 +61,7 @@ static const char *documenters[] = { static gchar *translators; -const char *license[] = { +static const char *license[] = { N_("This program is free software; you can redistribute it and/or modify " "it under the terms of the GNU General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " diff --git a/src/notification.c b/src/notification.c index 745d8a35..35747be4 100644 --- a/src/notification.c +++ b/src/notification.c @@ -162,11 +162,11 @@ zenity_notification_handle_stdin (GIOChannel *channel, if (!g_utf8_validate (value, -1, NULL)) { g_warning ("Invalid UTF-8 in input!"); } else if (notify_is_initted ()) { - GError *error = NULL; NotifyNotification *notif; const gchar *icon = NULL; gchar *freeme = NULL; gchar *message; + error = NULL; message = g_strcompress (value); diff --git a/src/option.c b/src/option.c index 5fe5dbce..25a74402 100644 --- a/src/option.c +++ b/src/option.c @@ -222,7 +222,7 @@ static GOptionEntry entry_options[] = { "text", '\0', G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING | G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, &zenity_general_dialog_text, N_("Set the dialog text"), N_("TEXT") @@ -1412,7 +1412,7 @@ zenity_create_context (void) /* Adds general option entries */ a_group = g_option_group_new("general", N_("General options"), - N_("Show general options"), NULL, 0); + N_("Show general options"), NULL, NULL); g_option_group_add_entries(a_group, general_options); g_option_group_set_parse_hooks (a_group, zenity_general_pre_callback, zenity_general_post_callback); @@ -1423,7 +1423,7 @@ zenity_create_context (void) /* Adds calendar option entries */ a_group = g_option_group_new("calendar", N_("Calendar options"), - N_("Show calendar options"), NULL, 0); + N_("Show calendar options"), NULL, NULL); g_option_group_add_entries(a_group, calendar_options); g_option_group_set_parse_hooks (a_group, zenity_calendar_pre_callback, zenity_calendar_post_callback); @@ -1434,7 +1434,7 @@ zenity_create_context (void) /* Adds entry option entries */ a_group = g_option_group_new("entry", N_("Text entry options"), - N_("Show text entry options"), NULL, 0); + N_("Show text entry options"), NULL, NULL); g_option_group_add_entries(a_group, entry_options); g_option_group_set_parse_hooks (a_group, zenity_entry_pre_callback, zenity_entry_post_callback); @@ -1445,7 +1445,7 @@ zenity_create_context (void) /* Adds error option entries */ a_group = g_option_group_new("error", N_("Error options"), - N_("Show error options"), NULL, 0); + N_("Show error options"), NULL, NULL); g_option_group_add_entries(a_group, error_options); g_option_group_set_parse_hooks (a_group, zenity_error_pre_callback, zenity_error_post_callback); @@ -1456,7 +1456,7 @@ zenity_create_context (void) /* Adds info option entries */ a_group = g_option_group_new("info", N_("Info options"), - N_("Show info options"), NULL, 0); + N_("Show info options"), NULL, NULL); g_option_group_add_entries(a_group, info_options); g_option_group_set_parse_hooks (a_group, zenity_info_pre_callback, zenity_info_post_callback); @@ -1467,7 +1467,7 @@ zenity_create_context (void) /* Adds file selection option entries */ a_group = g_option_group_new("file-selection", N_("File selection options"), - N_("Show file selection options"), NULL, 0); + N_("Show file selection options"), NULL, NULL); g_option_group_add_entries(a_group, file_selection_options); g_option_group_set_parse_hooks (a_group, zenity_file_pre_callback, zenity_file_post_callback); @@ -1478,7 +1478,7 @@ zenity_create_context (void) /* Adds list option entries */ a_group = g_option_group_new("list", N_("List options"), - N_("Show list options"), NULL, 0); + N_("Show list options"), NULL, NULL); g_option_group_add_entries(a_group, list_options); g_option_group_set_parse_hooks (a_group, zenity_list_pre_callback, zenity_list_post_callback); @@ -1489,7 +1489,7 @@ zenity_create_context (void) /* Adds notification option entries */ a_group = g_option_group_new("notification", N_("Notification icon options"), - N_("Show notification icon options"), NULL, 0); + N_("Show notification icon options"), NULL, NULL); g_option_group_add_entries(a_group, notification_options); g_option_group_set_parse_hooks (a_group, zenity_notification_pre_callback, zenity_notification_post_callback); @@ -1500,7 +1500,7 @@ zenity_create_context (void) /* Adds progress option entries */ a_group = g_option_group_new("progress", N_("Progress options"), - N_("Show progress options"), NULL, 0); + N_("Show progress options"), NULL, NULL); g_option_group_add_entries(a_group, progress_options); g_option_group_set_parse_hooks (a_group, zenity_progress_pre_callback, zenity_progress_post_callback); @@ -1511,7 +1511,7 @@ zenity_create_context (void) /* Adds question option entries */ a_group = g_option_group_new("question", N_("Question options"), - N_("Show question options"), NULL, 0); + N_("Show question options"), NULL, NULL); g_option_group_add_entries(a_group, question_options); g_option_group_set_parse_hooks (a_group, zenity_question_pre_callback, zenity_question_post_callback); @@ -1522,7 +1522,7 @@ zenity_create_context (void) /* Adds warning option entries */ a_group = g_option_group_new("warning", N_("Warning options"), - N_("Show warning options"), NULL, 0); + N_("Show warning options"), NULL, NULL); g_option_group_add_entries(a_group, warning_options); g_option_group_set_parse_hooks (a_group, zenity_warning_pre_callback, zenity_warning_post_callback); @@ -1533,7 +1533,7 @@ zenity_create_context (void) /* Adds scale option entries */ a_group = g_option_group_new("scale", N_("Scale options"), - N_("Show scale options"), NULL, 0); + N_("Show scale options"), NULL, NULL); g_option_group_add_entries(a_group, scale_options); g_option_group_set_parse_hooks (a_group, zenity_scale_pre_callback, zenity_scale_post_callback); @@ -1544,7 +1544,7 @@ zenity_create_context (void) /* Adds text option entries */ a_group = g_option_group_new("text-info", N_("Text information options"), - N_("Show text information options"), NULL, 0); + N_("Show text information options"), NULL, NULL); g_option_group_add_entries(a_group, text_options); g_option_group_set_parse_hooks (a_group, zenity_text_pre_callback, zenity_text_post_callback); @@ -1555,7 +1555,7 @@ zenity_create_context (void) /* Adds misc option entries */ a_group = g_option_group_new("misc", N_("Miscellaneous options"), - N_("Show miscellaneous options"), NULL, 0); + N_("Show miscellaneous options"), NULL, NULL); g_option_group_add_entries(a_group, miscellaneous_options); g_option_group_set_parse_hooks (a_group, zenity_misc_pre_callback, zenity_misc_post_callback); diff --git a/src/progress.c b/src/progress.c index d14969b2..b8ac1fc8 100644 --- a/src/progress.c +++ b/src/progress.c @@ -135,7 +135,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, if (condition != G_IO_IN) { /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ GtkWidget *button; - GtkWidget *progress_bar; button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); gtk_widget_set_sensitive (button, TRUE); @@ -144,7 +143,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); gtk_widget_set_sensitive (button, FALSE); - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); if (progress_data->pulsate) { -- cgit From f297dd91bd4e6a81d0b14562fccd615f2045bc48 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 May 2007 21:38:47 +0000 Subject: double-click on day results in dialog response (Fixes bug #395152). Patch 2007-05-15 Lucas Rocha * src/calendar.c (zenity_calendar, zenity_calendar_double_click): double-click on day results in dialog response (Fixes bug #395152). Patch from Tom Tromey . svn path=/trunk/; revision=1209 --- src/calendar.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index fd0eb7b5..9c50c5ab 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -33,6 +33,7 @@ static GtkWidget *calendar; static ZenityCalendarData *zen_cal_data; static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) @@ -80,6 +81,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (cal_data->day > 0) gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + g_signal_connect (calendar, "day-selected-double-click", + G_CALLBACK (zenity_calendar_double_click), data); + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); zenity_util_show_dialog (dialog); gtk_main (); @@ -119,3 +123,9 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) } gtk_main_quit (); } + +static void +zenity_calendar_double_click (GtkCalendar *cal, gpointer data) +{ + zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); +} -- cgit From a705262d816a7f2d9bdd5405f6c077b690219cef Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 May 2007 22:07:13 +0000 Subject: fix index handling for --print-column (Fixes bug #420396). 2007-05-15 Lucas Rocha * src/tree.c (zenity_tree_dialog_toggle_get_selected): fix index handling for --print-column (Fixes bug #420396). svn path=/trunk/; revision=1211 --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 1e67f706..09346e0a 100644 --- a/src/tree.c +++ b/src/tree.c @@ -550,7 +550,7 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, } for (i = 0; print_columns[i] != 0; i++) { - gtk_tree_model_get_value (model, iter, print_columns[i], &value); + gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); g_value_unset (&value); -- cgit From b9cbcc8d0ba9ed63920ba0b7bbe1bc3fa553aeb5 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 14 May 2007 22:13:59 +0000 Subject: fix seg fault when outputing files with special printf format strings MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2007-05-15 Lucas Rocha * src/text.c (zenity_text_dialog_response): fix seg fault when outputing files with special printf format strings (Fixes bug #405006). Patch from Mariano Suárez-Alvarez. svn path=/trunk/; revision=1212 --- src/text.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index 1a4a3227..b7816826 100644 --- a/src/text.c +++ b/src/text.c @@ -159,9 +159,12 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_CLOSE: if (zen_text_data->editable) { GtkTextIter start, end; + gchar *text; gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); - g_print (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0)); + text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); + g_print ("%s", text); + g_free (text); } zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); break; -- cgit From b73e72bcfea040aaf4ea681068676de3ee013ac8 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 27 May 2007 20:09:27 +0000 Subject: initialize GTK+ before parsing command line options to better handle 2007-05-27 Lucas Rocha * src/main.c: initialize GTK+ before parsing command line options to better handle errors on display setting (Fixes bug #410055). svn path=/trunk/; revision=1217 --- src/main.c | 6 +++--- src/notification.c | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 7e83fd89..1c37de2c 100644 --- a/src/main.c +++ b/src/main.c @@ -44,13 +44,13 @@ main (gint argc, gchar **argv) { #endif bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); textdomain(GETTEXT_PACKAGE); - results = zenity_option_parse (argc, argv); - - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); gtk_init (&argc, &argv); + results = zenity_option_parse (argc, argv); + switch (results->mode) { case MODE_CALENDAR: zenity_calendar (results->data, results->calendar_data); diff --git a/src/notification.c b/src/notification.c index 35747be4..b5cdd406 100644 --- a/src/notification.c +++ b/src/notification.c @@ -48,6 +48,7 @@ zenity_notification_icon_update (void) GError *error = NULL; pixbuf = gdk_pixbuf_new_from_file_at_scale (icon_file, icon_size, icon_size, TRUE, &error); + if (error) { g_warning ("Could not load notification icon '%s': %s", icon_file, error->message); -- cgit From 5868adac7501134a8cb9d2ace1ae12622368a910 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 27 May 2007 20:35:32 +0000 Subject: correctly handle UTF-8 input text in the text info dialog (Fixes bug 2007-05-27 Lucas Rocha * src/text.c: correctly handle UTF-8 input text in the text info dialog (Fixes bug #407275). svn path=/trunk/; revision=1220 --- src/text.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index b7816826..a8da744a 100644 --- a/src/text.c +++ b/src/text.c @@ -74,9 +74,14 @@ zenity_text_handle_stdin (GIOChannel *channel, gsize utflen; gtk_text_buffer_get_end_iter (buffer, &end); - utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); - gtk_text_buffer_insert (buffer, &end, utftext, utflen); - g_free (utftext); + + if (!g_utf8_validate (buf, len, NULL)) { + utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); + gtk_text_buffer_insert (buffer, &end, utftext, utflen); + g_free (utftext); + } else { + gtk_text_buffer_insert (buffer, &end, buf, len); + } } } -- cgit From b2459f3b6e480ba8568084f4ed50d1634239b0ea Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 27 May 2007 21:20:39 +0000 Subject: fix broken handling of input from pipes in list dialog (Fixes bug 2007-05-27 Lucas Rocha * src/tree.c: fix broken handling of input from pipes in list dialog (Fixes bug #343684). svn path=/trunk/; revision=1221 --- src/tree.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 09346e0a..dafb2eb5 100644 --- a/src/tree.c +++ b/src/tree.c @@ -94,13 +94,13 @@ zenity_tree_handle_stdin (GIOChannel *channel, { static GtkTreeView *tree_view; GtkTreeModel *model; - GtkTreeIter iter; + static GtkTreeIter iter; static gint column_count = 0; static gint row_count = 0; static gint n_columns; static gboolean editable; static gboolean toggles; - static gboolean first_time = FALSE; + static gboolean first_time = TRUE; tree_view = GTK_TREE_VIEW (data); n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -109,8 +109,8 @@ zenity_tree_handle_stdin (GIOChannel *channel, model = gtk_tree_view_get_model (tree_view); - if (!first_time) { - first_time = TRUE; + if (first_time) { + first_time = FALSE; gtk_list_store_append (GTK_LIST_STORE (model), &iter); } @@ -159,22 +159,22 @@ zenity_tree_handle_stdin (GIOChannel *channel, gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1); } - if (editable) { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); - } + if (editable) { + gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + } - if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) { - GtkWidget *scrolled_window; - GtkRequisition rectangle; + if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; - gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); - gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - } + gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); + } - column_count ++; + column_count++; } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); g_string_free (string, TRUE); -- cgit From ae3e8d1496fcfc3bf2ca65e475455bbf4c935e50 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 13 Aug 2007 20:16:37 +0000 Subject: fix critical warning when using checkbox and radiobox in list dialog 2007-08-13 Lucas Rocha * src/tree.c: fix critical warning when using checkbox and radiobox in list dialog (Fixes bug #453713). svn path=/trunk/; revision=1230 --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index dafb2eb5..254ac0e7 100644 --- a/src/tree.c +++ b/src/tree.c @@ -309,7 +309,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) } else { print_columns = g_new (gint, 2); - print_columns[0] = 1; + print_columns[0] = (tree_data->radiobox || tree_data->checkbox ? 2 : 1); print_columns[1] = 0; } -- cgit From 8b16d4d4122e6337517ec16b9ca22dd27df0dafb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 13 Aug 2007 20:36:29 +0000 Subject: added timeout option to all dialogs (Fixes bug #160654). Based on patch 2007-08-13 Lucas Rocha * src/*.c: added timeout option to all dialogs (Fixes bug #160654). Based on patch from Muthiah Annamalai . svn path=/trunk/; revision=1231 --- src/calendar.c | 5 +++++ src/entry.c | 4 ++++ src/fileselection.c | 5 +++++ src/msg.c | 5 +++++ src/notification.c | 5 +++++ src/option.c | 13 ++++++++++++- src/progress.c | 4 ++++ src/scale.c | 5 +++++ src/text.c | 4 ++++ src/tree.c | 5 +++++ src/util.c | 9 +++++++++ src/util.h | 4 +++- src/zenity.h | 4 +++- 13 files changed, 69 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 9c50c5ab..e05950cb 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,6 +86,11 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); zenity_util_show_dialog (dialog); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/entry.c b/src/entry.c index 390d9b6b..dcd09854 100644 --- a/src/entry.c +++ b/src/entry.c @@ -120,6 +120,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/fileselection.c b/src/fileselection.c index 3f355bab..c91c816a 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -86,6 +86,11 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); zenity_util_show_dialog (dialog); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/msg.c b/src/msg.c index 973062ee..cbe6e3af 100644 --- a/src/msg.c +++ b/src/msg.c @@ -116,6 +116,11 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); zenity_util_show_dialog (dialog); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/notification.c b/src/notification.c index b5cdd406..b2ab18fe 100644 --- a/src/notification.c +++ b/src/notification.c @@ -280,6 +280,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data /* Show icon and wait */ gtk_status_icon_set_visible (status_icon, TRUE); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); /* Cleanup */ diff --git a/src/option.c b/src/option.c index 25a74402..cbb50816 100644 --- a/src/option.c +++ b/src/option.c @@ -40,6 +40,7 @@ static gboolean zenity_general_multiple; static gboolean zenity_general_editable; static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; +static guint zenity_general_timeout_delay; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -143,6 +144,15 @@ static GOptionEntry general_options[] = { N_("Set the height"), N_("HEIGHT") }, + { + "timeout", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_timeout_delay, + N_("Set dialog timeout in seconds"), + NULL + }, { NULL } @@ -879,6 +889,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_editable = FALSE; zenity_general_uri = NULL; zenity_general_dialog_no_wrap = FALSE; + zenity_general_timeout_delay = -1; return TRUE; } @@ -1065,7 +1076,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->window_icon = zenity_general_window_icon; results->data->width = zenity_general_width; results->data->height = zenity_general_height; - + results->data->timeout_delay=zenity_general_timeout_delay; return TRUE; } diff --git a/src/progress.c b/src/progress.c index b8ac1fc8..ffd87072 100644 --- a/src/progress.c +++ b/src/progress.c @@ -219,6 +219,10 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) zenity_util_show_dialog (dialog); zenity_progress_read_info (progress_data); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/scale.c b/src/scale.c index cacb083a..91b0ef5f 100644 --- a/src/scale.c +++ b/src/scale.c @@ -93,6 +93,11 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); zenity_util_show_dialog (dialog); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/text.c b/src/text.c index a8da744a..bdd8e0c8 100644 --- a/src/text.c +++ b/src/text.c @@ -152,6 +152,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (glade_dialog) g_object_unref (glade_dialog); + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); } diff --git a/src/tree.c b/src/tree.c index 254ac0e7..6dd3f645 100644 --- a/src/tree.c +++ b/src/tree.c @@ -493,6 +493,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) } zenity_util_show_dialog (dialog); + + if(data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + gtk_main (); if (glade_dialog) diff --git a/src/util.c b/src/util.c index 41c7c556..267332cd 100644 --- a/src/util.c +++ b/src/util.c @@ -350,6 +350,7 @@ transient_get_xterm_toplevel (void) static void zenity_util_make_transient (GdkWindow *window) { +#if 0 Window xterm = transient_get_xterm_toplevel (); if (xterm != None) { GdkWindow *gdkxterm = gdk_window_foreign_new (xterm); @@ -358,6 +359,7 @@ zenity_util_make_transient (GdkWindow *window) g_object_unref (G_OBJECT (gdkxterm)); } } +#endif } #endif /* GDK_WINDOWING_X11 */ @@ -373,3 +375,10 @@ zenity_util_show_dialog (GtkWidget *dialog) gtk_widget_show (dialog); } +gboolean +zenity_util_timeout_handle (void) +{ + gtk_main_quit(); + exit(ZENITY_TIMEOUT); + return FALSE; +} diff --git a/src/util.h b/src/util.h index 7535275b..4815da2a 100644 --- a/src/util.h +++ b/src/util.h @@ -27,7 +27,9 @@ GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_show_dialog (GtkWidget *widget); - + +gboolean zenity_util_timeout_handle (void); + G_END_DECLS #endif /* UTIL_H */ diff --git a/src/zenity.h b/src/zenity.h index 330d317d..ac6c4f8e 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -29,6 +29,7 @@ typedef struct { gint width; gint height; gint exit_code; + guint timeout_delay; } ZenityData; typedef enum { @@ -36,7 +37,8 @@ typedef enum { ZENITY_CANCEL, ZENITY_ESC, ZENITY_ERROR, - ZENITY_EXTRA + ZENITY_EXTRA, + ZENITY_TIMEOUT } ZenityExitCode; typedef struct { -- cgit From 67baada43072de56c7a9f0c88fd29d1056cf31a3 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 17 Mar 2008 19:16:31 +0000 Subject: added comment on a string in order clarify its meaning for translators 2007-03-17 Lucas Rocha * src/option.c: added comment on a string in order clarify its meaning for translators (Fixes bug #520847). svn path=/trunk/; revision=1335 --- src/option.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index cbb50816..68d655f7 100644 --- a/src/option.c +++ b/src/option.c @@ -476,6 +476,7 @@ static GOptionEntry list_options[] = { G_OPTION_ARG_STRING, &zenity_list_print_column, N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), + /* Column index number to print out on a list dialog */ N_("NUMBER") }, { -- cgit From 82358456e04897a96749e0a43f1cf4b518571d27 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 17 Mar 2008 19:23:03 +0000 Subject: set value range before setting value in order to correctly set initial 2007-03-17 Lucas Rocha * src/scale.c (zenity_scale): set value range before setting value in order to correctly set initial state (Fixes bug #521574). svn path=/trunk/; revision=1337 --- src/scale.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/scale.c b/src/scale.c index 91b0ef5f..d69bd8a8 100644 --- a/src/scale.c +++ b/src/scale.c @@ -81,8 +81,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (scale_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text)); - gtk_range_set_value (GTK_RANGE (scale), scale_data->value); gtk_range_set_range (GTK_RANGE (scale), scale_data->min_value, scale_data->max_value); + gtk_range_set_value (GTK_RANGE (scale), scale_data->value); gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0); if (scale_data->print_partial) -- cgit From 69390b9e435e71acd9c965ce3b9c1a73b77dc16f Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 17 Mar 2008 19:28:49 +0000 Subject: added arg_description for --timeout option (Fixes bug #516876). Patch from 2008-03-17 Lucas Rocha * src/option.c: added arg_description for --timeout option (Fixes bug #516876). Patch from Luca Ferretti . svn path=/trunk/; revision=1341 --- src/option.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 68d655f7..babe4e9c 100644 --- a/src/option.c +++ b/src/option.c @@ -151,7 +151,8 @@ static GOptionEntry general_options[] = { G_OPTION_ARG_INT, &zenity_general_timeout_delay, N_("Set dialog timeout in seconds"), - NULL + /* Timeout for closing the dialog */ + N_("TIMEOUT") }, { NULL -- cgit From 2141cb9184c20be91e469b2bd4e4bb22e57faba3 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 29 Mar 2008 22:13:50 +0000 Subject: Allow question dialogs to use custom button label text (Fixes bug 2008-03-30 Lucas Rocha Allow question dialogs to use custom button label text (Fixes bug #335763). Patch from Cosimo Cecchi and Thomas Thurman . * src/msg.c (zenity_msg_construct_question_dialog), (zenity_msg): dynamically add dialog buttons with provided labels. * src/option.c (zenity_option_free): free input labels. (zenity_question_post_callback): set button labels provided by the respective command line options. * src/zenity.glade: remove pre-defined dialog button from question dialog. * src/zenity.h: added ok_label and cancel_label to ZenityMsgData. svn path=/trunk/; revision=1346 --- src/msg.c | 24 ++++++++++++++++++++++++ src/option.c | 29 ++++++++++++++++++++++++++++- src/zenity.glade | 33 +++++---------------------------- src/zenity.h | 2 ++ 4 files changed, 59 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index cbe6e3af..90e51642 100644 --- a/src/msg.c +++ b/src/msg.c @@ -29,6 +29,29 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); +static void +zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data) +{ + GtkWidget *cancel_button, *ok_button; + + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); + + gtk_widget_grab_focus (ok_button); + + if (msg_data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), g_strdup (msg_data->cancel_label)); + gtk_button_set_image (GTK_BUTTON (cancel_button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + + if (msg_data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), g_strdup (msg_data->ok_label)); + gtk_button_set_image (GTK_BUTTON (ok_button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } +} + void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { @@ -92,6 +115,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) case ZENITY_MSG_QUESTION: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + zenity_msg_construct_question_dialog (dialog, msg_data); break; case ZENITY_MSG_ERROR: diff --git a/src/option.c b/src/option.c index babe4e9c..b56d5f09 100644 --- a/src/option.c +++ b/src/option.c @@ -87,6 +87,8 @@ static gboolean zenity_progress_auto_kill; /* Question Dialog Options */ static gboolean zenity_question_active; +static gchar *zenity_question_ok_button; +static gchar *zenity_question_cancel_button; /* Text Dialog Options */ static gboolean zenity_text_active; @@ -608,6 +610,24 @@ static GOptionEntry question_options[] = { N_("Set the dialog text"), N_("TEXT") }, + { + "ok-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_question_ok_button, + N_("Sets the label of the Ok button"), + N_("TEXT") + }, + { + "cancel-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_question_cancel_button, + N_("Sets the label of the Cancel button"), + N_("TEXT") + }, { "no-wrap", '\0', @@ -837,6 +857,11 @@ zenity_option_free (void) { if (zenity_list_hide_column) g_free (zenity_list_hide_column); + if (zenity_question_ok_button) + g_free (zenity_question_ok_button); + if (zenity_question_cancel_button) + g_free (zenity_question_cancel_button); + g_option_context_free (ctx); } @@ -1342,7 +1367,9 @@ zenity_question_post_callback (GOptionContext *context, if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_QUESTION; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->ok_label = zenity_question_ok_button; + results->msg_data->cancel_label = zenity_question_cancel_button; } return TRUE; diff --git a/src/zenity.glade b/src/zenity.glade index c496dcc7..ffda0e8b 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -242,6 +242,7 @@ True + True Are you sure you want to proceed? False True @@ -339,36 +340,9 @@ 14 - + True GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - 0 @@ -405,6 +379,7 @@ True + True Are you sure you want to proceed? False True @@ -872,6 +847,7 @@ True + True An error has occurred. False True @@ -1126,6 +1102,7 @@ True + True All updates are complete. False True diff --git a/src/zenity.h b/src/zenity.h index ac6c4f8e..8865cd9b 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -60,6 +60,8 @@ typedef struct { gchar *dialog_text; MsgMode mode; gboolean no_wrap; + gchar *ok_label; + gchar *cancel_label; } ZenityMsgData; typedef struct { -- cgit From eeb43bf65b8fd1f41b30e69fd898526ba02d9f78 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 7 Apr 2008 19:06:21 +0000 Subject: fix memory leak on custom labels (Fixes bug #526627). Patch by 2008-03-30 Lucas Rocha * src/msg.c (zenity_msg_construct_question_dialog): fix memory leak on custom labels (Fixes bug #526627). Patch by kraai@ftbfs.org. svn path=/trunk/; revision=1348 --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 90e51642..03642686 100644 --- a/src/msg.c +++ b/src/msg.c @@ -40,13 +40,13 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_widget_grab_focus (ok_button); if (msg_data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), g_strdup (msg_data->cancel_label)); + gtk_button_set_label (GTK_BUTTON (cancel_button), msg_data->cancel_label); gtk_button_set_image (GTK_BUTTON (cancel_button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (msg_data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), g_strdup (msg_data->ok_label)); + gtk_button_set_label (GTK_BUTTON (ok_button), msg_data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } -- cgit From a740e32652506eb82fd2a20623dd996ed3bd1ae7 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 10 Apr 2008 09:57:14 +0000 Subject: use g_value_dup_string when applicable (Fixes bug #527258). Patch from 2008-04-10 Lucas Rocha * src/tree.c (zenity_tree_dialog_get_selected, zenity_tree_dialog_toggle_get_selected): use g_value_dup_string when applicable (Fixes bug #527258). Patch from kraai@ftbfs.org. svn path=/trunk/; revision=1352 --- src/tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 6dd3f645..65e9c471 100644 --- a/src/tree.c +++ b/src/tree.c @@ -516,7 +516,7 @@ zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, Gtk for (i = 0; i < n_columns; i++) { gtk_tree_model_get_value (model, iter, i, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + selected = g_slist_append (selected, g_value_dup_string (&value)); g_value_unset (&value); } return; @@ -525,7 +525,7 @@ zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, Gtk for (i = 0; print_columns[i] != 0; i++) { gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + selected = g_slist_append (selected, g_value_dup_string (&value)); g_value_unset (&value); } } @@ -547,7 +547,7 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, for (i = 1; i < n_columns; i++) { gtk_tree_model_get_value (model, iter, i, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + selected = g_slist_append (selected, g_value_dup_string (&value)); g_value_unset (&value); } g_value_unset (&toggle_value); @@ -557,7 +557,7 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, for (i = 0; print_columns[i] != 0; i++) { gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); - selected = g_slist_append (selected, g_strdup (g_value_get_string (&value))); + selected = g_slist_append (selected, g_value_dup_string (&value)); g_value_unset (&value); } } -- cgit From 8cda6025f0a11278c8d2f01482ad1656a2b5e5b1 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 21 Apr 2008 20:47:38 +0000 Subject: Add support for file filter in file selection dialog through the new 2008-04-21 Lucas Rocha Add support for file filter in file selection dialog through the new --file-filter command line option (Fixes bug #409843). * src/option.c, src/zenity.h: added supporting variable and new GOptionEntry entry for the new command line option. * src/fileselection.c (zenity_fileselection): add file filters based on command line input. svn path=/trunk/; revision=1362 --- src/fileselection.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/option.c | 24 ++++++++++++++++++++---- src/zenity.h | 1 + 3 files changed, 67 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index c91c816a..46d1941d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -85,6 +85,52 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->multi) gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); + if (file_data->filter) { + /* Filter format: Executables | *.exe *.bat *.com */ + gint filter_i; + + for (filter_i = 0; file_data->filter [filter_i]; filter_i++) { + GtkFileFilter *filter = gtk_file_filter_new(); + gchar *filter_str = file_data->filter [filter_i]; + gchar **pattern, **patterns; + gchar *name = NULL; + gint i; + + /* Set name */ + for (i = 0; filter_str[i] != '\0'; i++) + if (filter_str[i] == '|') + break; + + if (filter_str[i] == '|') { + name = g_strndup (filter_str, i); + g_strstrip (name); + } + + if (name) { + gtk_file_filter_set_name (filter, name); + + /* Point i to the right position for split */ + for (++i; filter_str[i] == ' '; i++); + } else { + gtk_file_filter_set_name (filter, filter_str); + i = 0; + } + + /* Get patterns */ + patterns = g_strsplit_set (filter_str + i, " ", -1); + + for (pattern = patterns; *pattern; pattern++) + gtk_file_filter_add_pattern (filter, *pattern); + + if (name) + g_free (name); + + g_strfreev (patterns); + + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + } + } + zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { diff --git a/src/option.c b/src/option.c index b56d5f09..9cbf490c 100644 --- a/src/option.c +++ b/src/option.c @@ -61,10 +61,11 @@ static gboolean zenity_error_active; static gboolean zenity_info_active; /* File Selection Dialog Options */ -static gboolean zenity_file_active; -static gboolean zenity_file_directory; -static gboolean zenity_file_save; -static gboolean zenity_file_confirm_overwrite; +static gboolean zenity_file_active; +static gboolean zenity_file_directory; +static gboolean zenity_file_save; +static gboolean zenity_file_confirm_overwrite; +static GtkFileFilter *zenity_file_filter; /* List Dialog Options */ static gboolean zenity_list_active; @@ -394,6 +395,15 @@ static GOptionEntry file_selection_options[] = { N_("Confirm file selection if filename already exists"), NULL }, + { + "file-filter", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_file_filter, + N_("Sets a filename filter"), + N_("NAME | PATTERN1 PATTERN2 ..."), + }, { NULL } @@ -981,6 +991,7 @@ zenity_file_pre_callback (GOptionContext *context, zenity_file_directory = FALSE; zenity_file_save = FALSE; zenity_file_confirm_overwrite = FALSE; + zenity_file_filter = NULL; return TRUE; } @@ -1233,6 +1244,7 @@ zenity_file_post_callback (GOptionContext *context, results->file_data->save = zenity_file_save; results->file_data->confirm_overwrite = zenity_file_confirm_overwrite; results->file_data->separator = zenity_general_separator; + results->file_data->filter = zenity_file_filter; } else { if (zenity_file_directory) zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory), @@ -1241,6 +1253,10 @@ zenity_file_post_callback (GOptionContext *context, if (zenity_file_save) zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_save), ERROR_SUPPORT); + + if (zenity_file_filter) + zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_filter), + ERROR_SUPPORT); } return TRUE; diff --git a/src/zenity.h b/src/zenity.h index 8865cd9b..511ee84d 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -81,6 +81,7 @@ typedef struct { gboolean save; gboolean confirm_overwrite; gchar *separator; + gchar **filter; } ZenityFileData; typedef struct { -- cgit From 954fd84362fdbbf602479d049393fffc57c0f9b1 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 21 Apr 2008 22:14:32 +0000 Subject: release 2.23.1 2008-04-21 Lucas Rocha * NEWS: release 2.23.1 svn path=/trunk/; revision=1364 --- src/util.c | 2 -- src/zenity.glade | 22 +++++++++++----------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 267332cd..cf34579d 100644 --- a/src/util.c +++ b/src/util.c @@ -350,7 +350,6 @@ transient_get_xterm_toplevel (void) static void zenity_util_make_transient (GdkWindow *window) { -#if 0 Window xterm = transient_get_xterm_toplevel (); if (xterm != None) { GdkWindow *gdkxterm = gdk_window_foreign_new (xterm); @@ -359,7 +358,6 @@ zenity_util_make_transient (GdkWindow *window) g_object_unref (G_OBJECT (gdkxterm)); } } -#endif } #endif /* GDK_WINDOWING_X11 */ diff --git a/src/zenity.glade b/src/zenity.glade index ffda0e8b..7095b974 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -16,7 +16,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -177,7 +177,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -288,7 +288,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False True @@ -328,7 +328,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -425,7 +425,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -550,7 +550,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -653,7 +653,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -776,7 +776,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -902,7 +902,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -1038,7 +1038,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False @@ -1151,7 +1151,7 @@ False GDK_WINDOW_TYPE_HINT_DIALOG GDK_GRAVITY_NORTH_WEST - True + False False False -- cgit From 92eda5b9ce67831c136cf2403ca24e6030b1c9eb Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 31 May 2008 13:52:18 +0000 Subject: set all dialogs in glade file as resizable in order to have them 2008-05-31 Lucas Rocha * src/zenity.glade: set all dialogs in glade file as resizable in order to have them respecting the --width and --height command-line options (Fixes bug #529452). svn path=/trunk/; revision=1380 --- src/zenity.glade | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 7095b974..9e013843 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -170,7 +170,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True False @@ -321,7 +321,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True False @@ -769,7 +769,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True False @@ -1031,7 +1031,7 @@ GTK_WINDOW_TOPLEVEL GTK_WIN_POS_CENTER False - False + True False True False -- cgit From ec484005101b3720feb95c8d76a65bcd6b0472c2 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:08:01 +0000 Subject: correctly handle --filename option on file selection mode (Fixes bug 2009-01-09 Lucas Rocha * src/fileselection.c (zenity_fileselection): correctly handle --filename option on file selection mode (Fixes bug #564552). Patch from Gilles Detillieux. svn path=/trunk/; revision=1461 --- src/fileselection.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 46d1941d..4cfa0514 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -76,7 +76,10 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) if (file_data->uri[strlen (file_data->uri) - 1] != '/') { basename = g_path_get_basename (file_data->uri); - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + if (file_data->save) + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); + else + (void) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_data->uri); g_free (basename); } g_free (dir); -- cgit From bd9e29d33ac1ed929ee09ccdffaf59d4db428fe9 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:10:30 +0000 Subject: GNOME Goal: Clean up GLib and GTK+ includes (Fixes bug #563855). Patch 2009-01-09 Lucas Rocha * src/main.c: * src/option.h: GNOME Goal: Clean up GLib and GTK+ includes (Fixes bug #563855). Patch from Pedro Fragoso . svn path=/trunk/; revision=1462 --- src/main.c | 2 +- src/option.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index 1c37de2c..4f87e6df 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ #include "option.h" #include -#include +#include #include #include #ifdef HAVE_LOCALE_H diff --git a/src/option.h b/src/option.h index cce0553d..2b7a703b 100644 --- a/src/option.h +++ b/src/option.h @@ -26,7 +26,7 @@ #define OPTION_H #include "zenity.h" -#include +#include #include #ifdef HAVE_LOCALE_H #include -- cgit From ba29edd13497fac1414d9dacd9f1ad147ac716ad Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:14:01 +0000 Subject: GNOME Goal: Remove deprecated GLib symbols (Fixes bug #560452). Patch from 2009-01-09 Lucas Rocha * src/tree.c: GNOME Goal: Remove deprecated GLib symbols (Fixes bug #560452). Patch from Frederic Peters . svn path=/trunk/; revision=1463 --- src/tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 65e9c471..3237cded 100644 --- a/src/tree.c +++ b/src/tree.c @@ -150,7 +150,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, } if (toggles && column_count == 0) { - if (strcmp (g_strdown (zenity_util_strip_newline (string->str)), "true") == 0) + if (strcmp (g_ascii_strdown (zenity_util_strip_newline (string->str), -1), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); else gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); @@ -228,7 +228,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, for (j = 0; j < n_columns; j++) { if (toggles && j == 0) { - if (strcmp (g_strdown ((gchar *) args[i+j]), "true") == 0) + if (strcmp (g_ascii_strdown ((gchar *) args[i+j], -1), "true") == 0) gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); else gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); @@ -302,7 +302,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) n_columns = g_slist_length (tree_data->columns); if (tree_data->print_column) { - if (strcmp (g_strdown (tree_data->print_column), "all") == 0) + if (strcmp (g_ascii_strdown (tree_data->print_column, -1), "all") == 0) print_all_columns = TRUE; else print_columns = zenity_tree_extract_column_indexes (tree_data->print_column, n_columns); -- cgit From c6da35807bee14b9a7e813e6bbcf757472cbf9e0 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Fri, 9 Jan 2009 00:17:40 +0000 Subject: translator comment for file-filter option string (Fixes bug #547202). 2009-01-09 Lucas Rocha * src/option.c: translator comment for file-filter option string (Fixes bug #547202). Patch from Frederic Peters . svn path=/trunk/; revision=1464 --- src/option.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 9cbf490c..c7a8b35e 100644 --- a/src/option.c +++ b/src/option.c @@ -402,6 +402,7 @@ static GOptionEntry file_selection_options[] = { G_OPTION_ARG_STRING_ARRAY, &zenity_file_filter, N_("Sets a filename filter"), + /* Help for file-filter argument (name and patterns for file selection) */ N_("NAME | PATTERN1 PATTERN2 ..."), }, { -- cgit From 9df2eda37fba550d5d13f8597454d25d1955fde7 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 8 Mar 2009 22:01:00 +0000 Subject: remove deprecated/obsoleted dialog definition (fixes bug #571869). Patch 2009-03-08 Lucas Rocha * src/zenity.glade: remove deprecated/obsoleted dialog definition (fixes bug #571869). Patch from Felix Riemann . svn path=/trunk/; revision=1487 --- src/zenity.glade | 40 ---------------------------------------- 1 file changed, 40 deletions(-) (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade index 9e013843..c23d09b5 100644 --- a/src/zenity.glade +++ b/src/zenity.glade @@ -275,46 +275,6 @@ - - 10 - Select a file - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - True - - - - - True - True - True - True - GTK_RELIEF_NORMAL - True - - - - - - True - True - True - GTK_RELIEF_NORMAL - True - - - - 5 Question -- cgit From 6dd1d4b5e674014d1eeaad82d5b057e6537fc346 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 8 Mar 2009 22:04:02 +0000 Subject: replace deprecated GTK+ calls (fixes bug #571869). Patch from Felix 2009-03-08 Lucas Rocha * configure.in, src/notification.c: replace deprecated GTK+ calls (fixes bug #571869). Patch from Felix Riemann . svn path=/trunk/; revision=1488 --- src/notification.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index b2ab18fe..6c8f7463 100644 --- a/src/notification.c +++ b/src/notification.c @@ -198,7 +198,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, } } else if (!g_ascii_strcasecmp (command, "tooltip")) { if (g_utf8_validate (value, -1, NULL)) { - gtk_status_icon_set_tooltip (status_icon, value); + gtk_status_icon_set_tooltip_text (status_icon, value); } else { g_warning ("Invalid UTF-8 in input!"); } @@ -247,9 +247,9 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data G_CALLBACK (zenity_notification_icon_size_changed_cb), data); if (notification_data->notification_text) { - gtk_status_icon_set_tooltip (status_icon, notification_data->notification_text); + gtk_status_icon_set_tooltip_text (status_icon, notification_data->notification_text); } else { - gtk_status_icon_set_tooltip (status_icon, _("Zenity notification")); + gtk_status_icon_set_tooltip_text (status_icon, _("Zenity notification")); } icon_file = g_strdup (data->window_icon); -- cgit From 278a669eaf7f2621fa547d5028911912e68408b0 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 8 Mar 2009 22:34:50 +0000 Subject: disable monk easter egg in order to remove gnome-canvas dependency (Fixes 2009-03-08 Lucas Rocha * configure.in, src/about.c: disable monk easter egg in order to remove gnome-canvas dependency (Fixes #571741). svn path=/trunk/; revision=1489 --- src/about.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 434b7bb9..b8f1fc06 100644 --- a/src/about.c +++ b/src/about.c @@ -29,7 +29,6 @@ #include "util.h" #include #include -#include #define GTK_RESPONSE_CREDITS 0 #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" @@ -75,6 +74,7 @@ static const char *license[] = { "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.") }; +#if 0 static gint zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, @@ -252,6 +252,7 @@ zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) return FALSE; } +#endif void zenity_about (ZenityData *data) @@ -301,8 +302,11 @@ zenity_about (ZenityData *data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); + +#if 0 g_signal_connect (G_OBJECT (dialog), "key_press_event", G_CALLBACK (zenity_zen_wisdom), NULL); +#endif zenity_util_show_dialog (dialog); gtk_main (); -- cgit From 3f33966167cf2216f813c091d47461c451837602 Mon Sep 17 00:00:00 2001 From: Felix Riemann Date: Mon, 20 Jul 2009 10:23:32 +0200 Subject: Bug 578393 – convert from libglade to GtkBuilder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Makefile.am | 8 +- src/calendar.c | 23 +- src/entry.c | 24 +- src/fileselection.c | 1 - src/msg.c | 48 +- src/notification.c | 1 - src/progress.c | 41 +- src/scale.c | 29 +- src/text.c | 19 +- src/tree.c | 34 +- src/util.c | 60 +- src/util.h | 8 +- src/zenity.ui | 1854 +++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 2016 insertions(+), 134 deletions(-) create mode 100644 src/zenity.ui (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index e70a51b2..30f7ccd3 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -40,15 +40,15 @@ zenity_LDADD = \ $(LIBNOTIFY_LIBS) \ $(X_LIBS) -gladedir = $(datadir)/zenity +uidir = $(datadir)/zenity -glade_DATA = \ - zenity.glade +ui_DATA = \ + zenity.ui DISTCLEANFILES= \ gdialog EXTRA_DIST = \ - $(glade_DATA) \ + $(ui_DATA) \ gdialog \ gdialog.in diff --git a/src/calendar.c b/src/calendar.c index e05950cb..8ad53ea6 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" @@ -38,22 +37,23 @@ static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); void zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; zen_cal_data = cal_data; - glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog"); + builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_calendar_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_calendar_dialog_response), data); @@ -66,16 +66,13 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text"); + text = gtk_builder_get_object (builder, "zenity_calendar_text"); if (cal_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); - calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar"); + calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); - if (glade_dialog) - g_object_unref (glade_dialog); - if (cal_data->month > 0 || cal_data->year > 0) gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); if (cal_data->day > 0) @@ -91,6 +88,8 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/entry.c b/src/entry.c index dcd09854..9c02095d 100644 --- a/src/entry.c +++ b/src/entry.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -46,23 +45,23 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args) void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder = NULL; GtkWidget *dialog; - GtkWidget *text; + GObject *text; GSList *entries = NULL; GSList *tmp; - GtkWidget *vbox; + GObject *vbox; - glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog"); + builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_entry_dialog_response), data); @@ -75,12 +74,12 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_entry_text"); + text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); - vbox = glade_xml_get_widget (glade_dialog, "vbox4"); + vbox = gtk_builder_get_object (builder, "vbox4"); zenity_entry_fill_entries(&entries, entry_data->data); @@ -113,11 +112,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - if (glade_dialog) - g_object_unref (glade_dialog); - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + g_object_unref (builder); + zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { diff --git a/src/fileselection.c b/src/fileselection.c index 4cfa0514..dd4ab0d3 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include #include "zenity.h" #include "util.h" diff --git a/src/msg.c b/src/msg.c index 03642686..cf0e47d0 100644 --- a/src/msg.c +++ b/src/msg.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -55,56 +54,53 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { - GladeXML *glade_dialog; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; switch (msg_data->mode) { case ZENITY_MSG_WARNING: - glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_warning_text"); + builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); + text = gtk_builder_get_object (builder, "zenity_warning_text"); break; case ZENITY_MSG_QUESTION: - glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_question_text"); + builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); + text = gtk_builder_get_object (builder, "zenity_question_text"); break; case ZENITY_MSG_ERROR: - glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_error_text"); + builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); + text = gtk_builder_get_object (builder, "zenity_error_text"); break; case ZENITY_MSG_INFO: - glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog"); - dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog"); - text = glade_xml_get_widget (glade_dialog, "zenity_info_text"); + builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); + text = gtk_builder_get_object (builder, "zenity_info_text"); break; default: - glade_dialog = NULL; + builder = NULL; dialog = NULL; text = NULL; g_assert_not_reached (); break; } - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - - glade_xml_signal_autoconnect (glade_dialog); - - if (glade_dialog) - g_object_unref (glade_dialog); + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_msg_dialog_response), data); + + gtk_builder_connect_signals (builder, NULL); + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -145,6 +141,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/notification.c b/src/notification.c index 6c8f7463..1d80fa15 100644 --- a/src/notification.c +++ b/src/notification.c @@ -25,7 +25,6 @@ #include #include -#include #include #include diff --git a/src/progress.c b/src/progress.c index ffd87072..a17a36ae 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,11 +29,10 @@ #include #include #include -#include #include "zenity.h" #include "util.h" -static GladeXML *glade_dialog; +static GtkBuilder *builder; static ZenityData *zen_data; static GIOChannel *channel; @@ -57,14 +56,14 @@ zenity_progress_handle_stdin (GIOChannel *channel, gpointer data) { static ZenityProgressData *progress_data; - static GtkWidget *progress_bar; - static GtkWidget *progress_label; + static GObject *progress_bar; + static GObject *progress_label; static gint pulsate_timeout = -1; float percentage = 0.0; progress_data = (ZenityProgressData *) data; - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); - progress_label = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + progress_label = gtk_builder_get_object (builder, "zenity_progress_text"); if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { GString *string; @@ -114,8 +113,8 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* Now try to convert the thing to a number */ percentage = atoi (string->str); if (percentage >= 100) { - GtkWidget *button; - button = glade_xml_get_widget( glade_dialog,"zenity_progress_ok_button"); + GObject *button; + button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); @@ -136,11 +135,13 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ GtkWidget *button; - button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button"); + button = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_ok_button")); gtk_widget_set_sensitive (button, TRUE); gtk_widget_grab_focus (button); - button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button"); + button = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_cancel_button")); gtk_widget_set_sensitive (button, FALSE); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); @@ -150,8 +151,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, pulsate_timeout = -1; } - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); if (progress_data->autoclose) { zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); @@ -177,20 +177,21 @@ void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; - GtkWidget *text; - GtkWidget *progress_bar; + GObject *text; + GObject *progress_bar; zen_data = data; - glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog"); + builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_progress_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_progress_dialog_response), data); @@ -203,12 +204,12 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - text = glade_xml_get_widget (glade_dialog, "zenity_progress_text"); + text = gtk_builder_get_object (builder, "zenity_progress_text"); if (progress_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); - progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar"); + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); if (progress_data->percentage > -1) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), diff --git a/src/scale.c b/src/scale.c index d69bd8a8..86787742 100644 --- a/src/scale.c +++ b/src/scale.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -35,23 +34,24 @@ static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpoin void zenity_scale (ZenityData *data, ZenityScaleData *scale_data) { - GladeXML *glade_dialog; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text; + GObject *text; - glade_dialog = zenity_util_load_glade_file ("zenity_scale_dialog"); - dialog = glade_xml_get_widget (glade_dialog, "zenity_scale_dialog"); - scale = glade_xml_get_widget (glade_dialog, "zenity_scale_hscale"); - text = glade_xml_get_widget (glade_dialog, "zenity_scale_text"); + builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_scale_dialog_response), data); - - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog")); + scale = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale")); + text = gtk_builder_get_object (builder, "zenity_scale_text"); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_scale_dialog_response), data); + if (scale_data->min_value >= scale_data->max_value) { g_printerr (_("Maximum value must be greater than minimum value.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); @@ -65,11 +65,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - if (glade_dialog) - g_object_unref (glade_dialog); - if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -98,6 +95,8 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); } + g_object_unref (builder); + gtk_main (); } diff --git a/src/text.c b/src/text.c index bdd8e0c8..25bd7688 100644 --- a/src/text.c +++ b/src/text.c @@ -23,7 +23,6 @@ #include "config.h" -#include #include "zenity.h" #include "util.h" @@ -102,22 +101,23 @@ zenity_text_fill_entries_from_stdin (GtkTextBuffer *text_buffer) void zenity_text (ZenityData *data, ZenityTextData *text_data) { - GladeXML *glade_dialog = NULL; + GtkBuilder *builder; GtkWidget *dialog; - GtkWidget *text_view; + GObject *text_view; GtkTextBuffer *text_buffer; zen_text_data = text_data; - glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog"); + builder = zenity_util_load_ui_file ("zenity_text_dialog", + "textbuffer1", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_text_dialog_response), data); @@ -130,7 +130,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); text_buffer = gtk_text_buffer_new (NULL); - text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view"); + text_view = gtk_builder_get_object (builder, "zenity_text_view"); 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); @@ -149,8 +149,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) zenity_util_show_dialog (dialog); - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); if(data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); diff --git a/src/tree.c b/src/tree.c index 3237cded..da2cf474 100644 --- a/src/tree.c +++ b/src/tree.c @@ -25,7 +25,6 @@ #include "config.h" -#include #include #include #include "zenity.h" @@ -34,7 +33,7 @@ #define MAX_ELEMENTS_BEFORE_SCROLLING 5 #define PRINT_HIDE_COLUMN_SEPARATOR "," -static GladeXML *glade_dialog; +static GtkBuilder *builder; static GSList *selected; static gchar *separator; static gboolean print_all_columns = FALSE; @@ -168,7 +167,8 @@ zenity_tree_handle_stdin (GIOChannel *channel, GtkRequisition rectangle; gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -245,7 +245,8 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, GtkRequisition rectangle; gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); - scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window"); + scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, + "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); @@ -281,8 +282,8 @@ void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { GtkWidget *dialog; - GtkWidget *tree_view; - GtkWidget *text; + GObject *tree_view; + GObject *text; GtkTreeViewColumn *column; GtkListStore *model; GType *column_types; @@ -290,9 +291,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gboolean first_column = FALSE; gint i, column_index, n_columns; - glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog"); + builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL); - if (glade_dialog == NULL) { + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } @@ -328,9 +329,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } - glade_xml_signal_autoconnect (glade_dialog); + gtk_builder_connect_signals (builder, NULL); - dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_tree_dialog_response), data); @@ -338,7 +339,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - text = glade_xml_get_widget (glade_dialog, "zenity_tree_text"); + text = gtk_builder_get_object (builder, "zenity_tree_text"); if (tree_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text)); @@ -348,10 +349,10 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); if (!(tree_data->radiobox || tree_data->checkbox)) - g_signal_connect (G_OBJECT (tree_view), "row-activated", + g_signal_connect (tree_view, "row-activated", G_CALLBACK (zenity_tree_row_activated), data); /* Create an empty list store */ @@ -500,8 +501,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_main (); - if (glade_dialog) - g_object_unref (glade_dialog); + g_object_unref (builder); } static void @@ -591,13 +591,13 @@ static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - GtkWidget *tree_view; + GObject *tree_view; GtkTreeSelection *selection; GtkTreeModel *model; switch (response) { case GTK_RESPONSE_OK: - tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view"); + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) diff --git a/src/util.c b/src/util.c index cf34579d..036e2b54 100644 --- a/src/util.c +++ b/src/util.c @@ -34,6 +34,7 @@ #include #include #include +#include #include "config.h" #include "util.h" #include "zenity.h" @@ -48,27 +49,62 @@ #define ZENITY_ERROR_DEFAULT -1 #define ZENITY_EXTRA_DEFAULT 127 -GladeXML* -zenity_util_load_glade_file (const gchar *widget_root) +GtkBuilder* +zenity_util_load_ui_file (const gchar *root_widget, ...) { - GladeXML *xml = NULL; + va_list args; + gchar *arg = NULL; + GPtrArray *ptrarray; + GtkBuilder *builder = gtk_builder_new (); + GError *error = NULL; + gchar **objects; + guint result = 0; - if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); + + /* We have at least the root_widget and a NULL */ + ptrarray = g_ptr_array_sized_new (2); + + g_ptr_array_add (ptrarray, g_strdup (root_widget)); + + va_start (args, root_widget); + + arg = va_arg (args, gchar*); + + while (arg) { + g_ptr_array_add (ptrarray, g_strdup (arg)); + arg = va_arg (args, gchar*); + } + va_end (args); + + /* Enforce terminating NULL */ + g_ptr_array_add (ptrarray, NULL); + objects = (gchar**) g_ptr_array_free (ptrarray, FALSE); + + if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { /* Try current dir, for debugging */ - xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE); + result = gtk_builder_add_objects_from_file (builder, + ZENITY_UI_FILE_RELATIVEPATH, + objects, NULL); } - - if (xml == NULL) - xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE); - if (xml == NULL) { - g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH); + if (result == 0) + result = gtk_builder_add_objects_from_file (builder, + ZENITY_UI_FILE_FULLPATH, + objects, &error); + + g_strfreev (objects); + + if (result == 0) { + g_warning ("Could not load ui file %s: %s", ZENITY_UI_FILE_FULLPATH, + error->message); + g_error_free (error); + g_object_unref (builder); return NULL; } - return xml; + return builder; } - gchar* zenity_util_strip_newline (gchar *string) { diff --git a/src/util.h b/src/util.h index 4815da2a..2bf154ec 100644 --- a/src/util.h +++ b/src/util.h @@ -2,16 +2,16 @@ #define UTIL_H #include -#include #include "zenity.h" G_BEGIN_DECLS -#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade" -#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade" +#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" +#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui" + #define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename) -GladeXML* zenity_util_load_glade_file (const gchar *widget_root); +GtkBuilder* zenity_util_load_ui_file (const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED; gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); diff --git a/src/zenity.ui b/src/zenity.ui new file mode 100644 index 00000000..48f0501a --- /dev/null +++ b/src/zenity.ui @@ -0,0 +1,1854 @@ + + + + + + 5 + Calendar selection + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 6 + + + True + 0 + Select a date from below. + True + True + + + False + False + 0 + + + + + 0 + + + + + True + 0 + C_alendar: + True + zenity_calendar + + + + + + False + False + 1 + + + + + True + True + + + False + False + 2 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_calendar_cancel_button + zenity_calendar_ok_button + + + + 5 + Warning + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-warning + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_warning_ok_button + + + + 5 + Question + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-question + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + False + end + 0 + + + + + + + 5 + Add a new entry + center + dialog + False + False + + + + True + 2 + + + True + 6 + + + True + 6 + + + True + 0 + _Enter new text: + True + True + + + False + False + 0 + + + + + + + + False + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_entry_cancel_button + zenity_entry_ok_button + + + + 5 + Text View + center + 300 + 200 + dialog + False + False + + + + True + 2 + + + True + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + 2 + 2 + False + word + 2 + 2 + textbuffer1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_text_close_button + + + + 5 + Progress + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 0 + Running... + True + + + False + False + 0 + + + + + True + 0.10000000149 + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + False + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_progress_cancel_button + zenity_progress_ok_button + + + + 5 + Error + center + dialog + False + False + + + + True + 14 + + + True + 6 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-error + 6 + + + 0 + + + + + True + True + 0 + An error has occurred. + True + True + True + + + False + False + 1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_error_ok_button + + + + 5 + Select items from the list + center + 300 + 196 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + Select items from the list below. + True + + + False + False + 0 + + + + + True + True + automatic + automatic + in + + + True + True + True + + + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_tree_cancel_button + zenity_tree_ok_button + + + + 5 + Information + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-info + 6 + + + 0 + + + + + True + True + 0 + All updates are complete. + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_info_ok_button + + + + True + 5 + Adjust the scale value + 300 + 100 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + 4 + Adjust the scale value + True + + + False + False + 0 + + + + + True + True + discontinuous + adjustment1 + 0 + right + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + cancelbutton1 + okbutton1 + + + + 100 + 1 + 1 + + + + + + + + + 5 + Calendar selection + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 6 + + + True + 0 + Select a date from below. + True + True + + + False + False + 0 + + + + + 0 + + + + + True + 0 + C_alendar: + True + zenity_calendar + + + + + + False + False + 1 + + + + + True + True + + + False + False + 2 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_calendar_cancel_button + zenity_calendar_ok_button + + + + 5 + Warning + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-warning + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_warning_ok_button + + + + 5 + Question + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + 0 + gtk-dialog-question + 6 + + + False + 0 + + + + + True + True + 0 + Are you sure you want to proceed? + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + False + end + 0 + + + + + + + 5 + Add a new entry + center + dialog + False + False + + + + True + 2 + + + True + 6 + + + True + 6 + + + True + 0 + _Enter new text: + True + True + + + False + False + 0 + + + + + + + + False + 0 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_entry_cancel_button + zenity_entry_ok_button + + + + 5 + Text View + center + 300 + 200 + dialog + False + False + + + + True + 2 + + + True + 5 + + + True + True + automatic + automatic + etched-in + + + True + True + 2 + 2 + False + word + 2 + 2 + textbuffer1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-close + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_text_close_button + + + + 5 + Progress + center + dialog + False + False + + + + True + 2 + + + True + 5 + 6 + + + True + 0 + Running... + True + + + False + False + 0 + + + + + True + 0.10000000149 + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + False + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_progress_cancel_button + zenity_progress_ok_button + + + + 5 + Error + center + dialog + False + False + + + + True + 14 + + + True + 6 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-error + 6 + + + 0 + + + + + True + True + 0 + An error has occurred. + True + True + True + + + False + False + 1 + + + + + 0 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_error_ok_button + + + + 5 + Select items from the list + center + 300 + 196 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + Select items from the list below. + True + + + False + False + 0 + + + + + True + True + automatic + automatic + in + + + True + True + True + + + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + zenity_tree_cancel_button + zenity_tree_ok_button + + + + 5 + Information + center + dialog + False + False + + + + True + 14 + + + True + 5 + 12 + + + True + 0 + gtk-dialog-info + 6 + + + 0 + + + + + True + True + 0 + All updates are complete. + True + True + True + + + False + False + 1 + + + + + 1 + + + + + True + end + + + gtk-ok + True + True + True + False + True + + + False + False + 0 + + + + + False + end + 0 + + + + + + zenity_info_ok_button + + + + True + 5 + Adjust the scale value + 300 + 100 + dialog + False + False + + + + True + + + True + 5 + 6 + + + True + 0 + 4 + Adjust the scale value + True + + + False + False + 0 + + + + + True + True + discontinuous + adjustment1 + 0 + right + + + 1 + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + cancelbutton1 + okbutton1 + + + + 100 + 1 + 1 + + + -- cgit From 94c9ee1c7fac13090012943e19587e7952414e48 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Mon, 20 Jul 2009 14:16:44 +0200 Subject: Clean some things in the GtkBuilder port (GnomeBug:578393) * Makefile.am * README * configure.in * po/POTFILES.skip * src/zenity.ui --- src/zenity.glade | 1224 ------------------------------------------------------ src/zenity.ui | 955 +----------------------------------------- 2 files changed, 14 insertions(+), 2165 deletions(-) delete mode 100644 src/zenity.glade (limited to 'src') diff --git a/src/zenity.glade b/src/zenity.glade deleted file mode 100644 index c23d09b5..00000000 --- a/src/zenity.glade +++ /dev/null @@ -1,1224 +0,0 @@ - - - - - - - 5 - Calendar selection - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - True - False - 6 - - - - True - Select a date from below. - False - True - GTK_JUSTIFY_LEFT - True - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - True - C_alendar: - True - False - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - zenity_calendar - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - - - - 0 - False - False - - - - - - True - True - GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - 5 - Warning - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 14 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 12 - - - - True - gtk-dialog-warning - 6 - 0 - 0 - 0 - 0 - - - 0 - False - True - - - - - - True - True - Are you sure you want to proceed? - False - True - GTK_JUSTIFY_LEFT - True - True - 0.5 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - 5 - Question - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 14 - - - - True - GTK_BUTTONBOX_END - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 12 - - - - True - gtk-dialog-question - 6 - 0 - 0 - 0 - 0 - - - 0 - False - True - - - - - - True - True - Are you sure you want to proceed? - False - True - GTK_JUSTIFY_LEFT - True - True - 0.5 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - 5 - Add a new entry - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 6 - True - False - 0 - - - - True - False - 6 - - - - True - _Enter new text: - True - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - - - - 0 - False - True - - - - - 0 - True - True - - - - - - - - 5 - Text View - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - 300 - 200 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-close - True - GTK_RELIEF_NORMAL - True - -7 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 0 - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_ETCHED_IN - GTK_CORNER_TOP_LEFT - - - - True - True - False - False - True - GTK_JUSTIFY_LEFT - GTK_WRAP_WORD - True - 2 - 2 - 0 - 2 - 2 - 0 - - - - - - 0 - True - True - - - - - 0 - True - True - - - - - - - - 5 - Progress - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 2 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - False - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - True - Running... - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - GTK_PROGRESS_LEFT_TO_RIGHT - 0 - 0.10000000149 - - PANGO_ELLIPSIZE_NONE - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - 5 - Error - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 14 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 6 - True - False - 0 - - - - 5 - True - False - 12 - - - - True - gtk-dialog-error - 6 - 0.5 - 0 - 0 - 0 - - - 0 - True - True - - - - - - True - True - An error has occurred. - False - True - GTK_JUSTIFY_LEFT - True - True - 0.5 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - 0 - True - True - - - - - - - - 5 - Select items from the list - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - 300 - 196 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - True - Select items from the list below. - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - True - GTK_POLICY_AUTOMATIC - GTK_POLICY_AUTOMATIC - GTK_SHADOW_IN - GTK_CORNER_TOP_LEFT - - - - True - True - True - True - False - False - True - False - False - False - - - - - 0 - True - True - - - - - 0 - True - True - - - - - - - - 5 - Information - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_CENTER - False - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 14 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 12 - - - - True - gtk-dialog-info - 6 - 0.5 - 0 - 0 - 0 - - - 0 - True - True - - - - - - True - True - All updates are complete. - False - True - GTK_JUSTIFY_LEFT - True - True - 0.5 - 0 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - 0 - True - True - - - - - - - - 5 - True - Adjust the scale value - GTK_WINDOW_TOPLEVEL - GTK_WIN_POS_NONE - False - 300 - 100 - True - False - True - False - False - GDK_WINDOW_TYPE_HINT_DIALOG - GDK_GRAVITY_NORTH_WEST - False - False - False - - - - - True - False - 0 - - - - True - GTK_BUTTONBOX_END - - - - True - True - True - gtk-cancel - True - GTK_RELIEF_NORMAL - True - -6 - - - - - - True - True - True - gtk-ok - True - GTK_RELIEF_NORMAL - True - -5 - - - - - 0 - False - True - GTK_PACK_END - - - - - - 5 - True - False - 6 - - - - True - Adjust the scale value - False - True - GTK_JUSTIFY_LEFT - False - False - 0 - 0.5 - 0 - 4 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - False - False - - - - - - True - True - True - GTK_POS_RIGHT - 0 - GTK_UPDATE_DISCONTINUOUS - False - 0 0 100 1 1 0 - - - 0 - True - True - - - - - 0 - True - True - - - - - - - diff --git a/src/zenity.ui b/src/zenity.ui index 48f0501a..db30432d 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,7 +1,7 @@ - - + + 5 Calendar selection @@ -11,934 +11,7 @@ False - - True - 2 - - - True - 5 - 6 - - - True - 6 - - - True - 0 - Select a date from below. - True - True - - - False - False - 0 - - - - - 0 - - - - - True - 0 - C_alendar: - True - zenity_calendar - - - - - - False - False - 1 - - - - - True - True - - - False - False - 2 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - zenity_calendar_cancel_button - zenity_calendar_ok_button - - - - 5 - Warning - center - dialog - False - False - - - - True - 14 - - - True - 5 - 12 - - - True - 0 - 0 - gtk-dialog-warning - 6 - - - False - 0 - - - - - True - True - 0 - Are you sure you want to proceed? - True - True - True - - - False - False - 1 - - - - - 1 - - - - - True - end - - - gtk-ok - True - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - zenity_warning_ok_button - - - - 5 - Question - center - dialog - False - False - - - - True - 14 - - - True - 5 - 12 - - - True - 0 - 0 - gtk-dialog-question - 6 - - - False - 0 - - - - - True - True - 0 - Are you sure you want to proceed? - True - True - True - - - False - False - 1 - - - - - 1 - - - - - True - end - - - False - end - 0 - - - - - - - 5 - Add a new entry - center - dialog - False - False - - - - True - 2 - - - True - 6 - - - True - 6 - - - True - 0 - _Enter new text: - True - True - - - False - False - 0 - - - - - - - - False - 0 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - zenity_entry_cancel_button - zenity_entry_ok_button - - - - 5 - Text View - center - 300 - 200 - dialog - False - False - - - - True - 2 - - - True - 5 - - - True - True - automatic - automatic - etched-in - - - True - True - 2 - 2 - False - word - 2 - 2 - textbuffer1 - - - - - 0 - - - - - 1 - - - - - True - end - - - gtk-close - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - zenity_text_close_button - - - - 5 - Progress - center - dialog - False - False - - - - True - 2 - - - True - 5 - 6 - - - True - 0 - Running... - True - - - False - False - 0 - - - - - True - 0.10000000149 - - - False - False - 1 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - False - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - zenity_progress_cancel_button - zenity_progress_ok_button - - - - 5 - Error - center - dialog - False - False - - - - True - 14 - - - True - 6 - - - True - 5 - 12 - - - True - 0 - gtk-dialog-error - 6 - - - 0 - - - - - True - True - 0 - An error has occurred. - True - True - True - - - False - False - 1 - - - - - 0 - - - - - 1 - - - - - True - end - - - gtk-ok - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - zenity_error_ok_button - - - - 5 - Select items from the list - center - 300 - 196 - dialog - False - False - - - - True - - - True - 5 - 6 - - - True - 0 - Select items from the list below. - True - - - False - False - 0 - - - - - True - True - automatic - automatic - in - - - True - True - True - - - - - 1 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - zenity_tree_cancel_button - zenity_tree_ok_button - - - - 5 - Information - center - dialog - False - False - - - - True - 14 - - - True - 5 - 12 - - - True - 0 - gtk-dialog-info - 6 - - - 0 - - - - - True - True - 0 - All updates are complete. - True - True - True - - - False - False - 1 - - - - - 1 - - - - - True - end - - - gtk-ok - True - True - True - False - True - - - False - False - 0 - - - - - False - end - 0 - - - - - - zenity_info_ok_button - - - - True - 5 - Adjust the scale value - 300 - 100 - dialog - False - False - - - - True - - - True - 5 - 6 - - - True - 0 - 4 - Adjust the scale value - True - - - False - False - 0 - - - - - True - True - discontinuous - adjustment1 - 0 - right - - - 1 - - - - - 1 - - - - - True - end - - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - False - True - - - False - False - 1 - - - - - False - end - 0 - - - - - - cancelbutton1 - okbutton1 - - - - 100 - 1 - 1 - - - - - - - - - 5 - Calendar selection - center - dialog - False - False - - - + True 2 @@ -1003,7 +76,7 @@ - + True end @@ -1060,16 +133,16 @@ False - + True 14 - + True 5 12 - + True 0 0 @@ -1103,7 +176,7 @@ - + True end @@ -1148,12 +221,12 @@ True 14 - + True 5 12 - + True 0 0 @@ -1675,16 +748,16 @@ False - + True 14 - + True 5 12 - + True 0 gtk-dialog-info @@ -1716,7 +789,7 @@ - + True end -- cgit From b87f233061134f8876803d150f1d1196d2d41561 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Thu, 6 Aug 2009 15:42:04 +0100 Subject: Bug 561131 – zenity windows don't appear with the focus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/zenity.ui | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index db30432d..5275a07c 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -7,7 +7,7 @@ Calendar selection center dialog - False + True False @@ -129,7 +129,7 @@ Warning center dialog - False + True False @@ -213,7 +213,7 @@ Question center dialog - False + True False @@ -278,7 +278,7 @@ Add a new entry center dialog - False + True False @@ -377,7 +377,7 @@ 300 200 dialog - False + True False @@ -455,7 +455,7 @@ Progress center dialog - False + True False @@ -551,7 +551,7 @@ Error center dialog - False + True False @@ -643,7 +643,7 @@ 300 196 dialog - False + True False @@ -744,7 +744,7 @@ Information center dialog - False + True False @@ -827,7 +827,7 @@ 300 100 dialog - False + True False -- cgit From 94190df420ee849752f5726979fea65fdb3b313b Mon Sep 17 00:00:00 2001 From: Siegfried-Angel Gevatter Pujals Date: Sat, 8 Aug 2009 01:55:22 +0200 Subject: Bug 567773 – "zenity --entry --text" doesn't interpret line breaks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 9c02095d..43a312d5 100644 --- a/src/entry.c +++ b/src/entry.c @@ -77,7 +77,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) text = gtk_builder_get_object (builder, "zenity_entry_text"); if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text); + gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); vbox = gtk_builder_get_object (builder, "vbox4"); -- cgit From 62a1292d1ea8b611b539ab2cc5dc4dfe479225d8 Mon Sep 17 00:00:00 2001 From: Olivier Blin Date: Thu, 23 Apr 2009 19:55:12 +0200 Subject: Bug 579999 – zenity sets a huge but finite timeout MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Declare timeout delay as signed, so that assigning -1 does not act as setting a huge (but finite) timeout (this has been noticed by resetting the clock) --- src/option.c | 2 +- src/zenity.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index c7a8b35e..93a09a21 100644 --- a/src/option.c +++ b/src/option.c @@ -40,7 +40,7 @@ static gboolean zenity_general_multiple; static gboolean zenity_general_editable; static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; -static guint zenity_general_timeout_delay; +static gint zenity_general_timeout_delay; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; diff --git a/src/zenity.h b/src/zenity.h index 511ee84d..3248ad37 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -29,7 +29,7 @@ typedef struct { gint width; gint height; gint exit_code; - guint timeout_delay; + gint timeout_delay; } ZenityData; typedef enum { -- cgit From 5c6a48f6843bbc133a2c9b48ecc67c7a271474f2 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 10:51:52 +0100 Subject: [progress] Cosmetic fix in code comment --- src/progress.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index a17a36ae..485f4797 100644 --- a/src/progress.c +++ b/src/progress.c @@ -238,8 +238,8 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_CANCEL: /* We do not want to kill the parent process, in order to give the user the ability to choose the action to be taken. See bug #310824. + But we want to give people the option to choose this behavior. -- Monday 27, March 2006 - But we want to give people the option to choose this behavior. */ if (autokill) { kill (getppid (), 1); -- cgit From 25ec1ed3bb17675c2e522e175676f5fa1551c0e7 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 11:21:24 +0100 Subject: [progress] Remove duplicate code when returning --- src/progress.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 485f4797..668f4277 100644 --- a/src/progress.c +++ b/src/progress.c @@ -243,8 +243,6 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) */ if (autokill) { kill (getppid (), 1); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; } zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; -- cgit From 533edc70443741edd36fe7b332ce47c2f2701167 Mon Sep 17 00:00:00 2001 From: "Aurélio A. Heckert" Date: Mon, 10 Aug 2009 00:08:14 +0100 Subject: Bug 573802 - Support notification summary You can now define title and summary on notifications. The first line of the provided text will be considered the title and the following lines are the summary. --- src/notification.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 1d80fa15..674eaec9 100644 --- a/src/notification.c +++ b/src/notification.c @@ -165,10 +165,18 @@ zenity_notification_handle_stdin (GIOChannel *channel, NotifyNotification *notif; const gchar *icon = NULL; gchar *freeme = NULL; - gchar *message; + gchar **message; error = NULL; - message = g_strcompress (value); + /* message[1] (the summary) will be NULL in case there's + * no \n in the string. In which case only the title is + * defined */ + message = g_strsplit (g_strcompress (value), "\n", 2); + + if (*message == NULL) { + g_printerr (_("Could not parse message from stdin\n")); + continue; + } if (icon_stock) { icon = icon_stock; @@ -176,9 +184,12 @@ zenity_notification_handle_stdin (GIOChannel *channel, icon = freeme = g_filename_to_uri (icon_file, NULL, NULL); } - notif = notify_notification_new_with_status_icon (message, NULL /* summary */, - icon, status_icon); - g_free (message); + notif = notify_notification_new_with_status_icon ( + message[0] /* title */, + message[1] /* summary */, + icon, status_icon); + + g_strfreev (message); g_free (freeme); notify_notification_show (notif, &error); -- cgit From 54b171ff82c39fcc178c1366fdee94bb6555dead Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 18:19:33 +0100 Subject: [progress] coding style fixes --- src/progress.c | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 668f4277..9d6e8bb3 100644 --- a/src/progress.c +++ b/src/progress.c @@ -113,17 +113,16 @@ zenity_progress_handle_stdin (GIOChannel *channel, /* Now try to convert the thing to a number */ percentage = atoi (string->str); if (percentage >= 100) { - GObject *button; - button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); + GObject *button; + button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); - gtk_widget_grab_focus(GTK_WIDGET (button)); - if (progress_data->autoclose) { - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit(); - - } - } else + gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); + gtk_widget_grab_focus(GTK_WIDGET (button)); + if (progress_data->autoclose) { + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit(); + } + } else gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); } @@ -136,14 +135,15 @@ zenity_progress_handle_stdin (GIOChannel *channel, GtkWidget *button; button = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_ok_button")); + "zenity_progress_ok_button")); gtk_widget_set_sensitive (button, TRUE); gtk_widget_grab_focus (button); button = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_cancel_button")); + "zenity_progress_cancel_button")); + gtk_widget_set_sensitive (button, FALSE); - + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); if (progress_data->pulsate) { @@ -157,7 +157,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit(); } - + g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } @@ -187,15 +187,15 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; } - + gtk_builder_connect_signals (builder, NULL); - + dialog = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_dialog")); + "zenity_progress_dialog")); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_progress_dialog_response), data); - + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -234,12 +234,12 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); break; - + case GTK_RESPONSE_CANCEL: /* We do not want to kill the parent process, in order to give the user the ability to choose the action to be taken. See bug #310824. - But we want to give people the option to choose this behavior. - -- Monday 27, March 2006 + But we want to give people the option to choose this behavior. + -- Monday 27, March 2006 */ if (autokill) { kill (getppid (), 1); -- cgit From fa0349545d65df0ce1c8b4de2cedc5824c7a5866 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 19:16:49 +0100 Subject: [progress] Factor out function to control pulsate --- src/progress.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 9d6e8bb3..8a6e10fc 100644 --- a/src/progress.c +++ b/src/progress.c @@ -36,6 +36,7 @@ static GtkBuilder *builder; static ZenityData *zen_data; static GIOChannel *channel; +static gint pulsate_timeout = -1; static gboolean autokill; gint zenity_progress_timeout (gpointer data); @@ -50,6 +51,25 @@ zenity_progress_pulsate_progress_bar (gpointer user_data) return TRUE; } +static void +zenity_progress_pulsate_stop () +{ + if (pulsate_timeout > 0) { + g_source_remove (pulsate_timeout); + pulsate_timeout = -1; + } +} + +static void +zenity_progress_pulsate_start (GObject *progress_bar) +{ + if (pulsate_timeout == -1) { + pulsate_timeout = g_timeout_add (100, + zenity_progress_pulsate_progress_bar, + progress_bar); + } +} + static gboolean zenity_progress_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -58,7 +78,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, static ZenityProgressData *progress_data; static GObject *progress_bar; static GObject *progress_label; - static gint pulsate_timeout = -1; float percentage = 0.0; progress_data = (ZenityProgressData *) data; @@ -72,8 +91,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, string = g_string_new (NULL); if (progress_data->pulsate) { - if (pulsate_timeout == -1) - pulsate_timeout = g_timeout_add (100, zenity_progress_pulsate_progress_bar, progress_bar); + zenity_progress_pulsate_start (progress_bar); } while (channel->is_readable != TRUE) @@ -146,10 +164,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - if (progress_data->pulsate) { - g_source_remove (pulsate_timeout); - pulsate_timeout = -1; - } + zenity_progress_pulsate_stop (); g_object_unref (builder); -- cgit From a66e4df5d1c0ebb485d5f3f8a24129366d2ff598 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sat, 8 Aug 2009 18:15:42 +0100 Subject: Bug 556198 – Support toggling pulsate in progressbar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/progress.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 8a6e10fc..a0868eaa 100644 --- a/src/progress.c +++ b/src/progress.c @@ -123,6 +123,33 @@ zenity_progress_handle_stdin (GIOChannel *channel, match = g_strstr_len (string->str, strlen (string->str), "#"); match++; gtk_label_set_text (GTK_LABEL (progress_label), g_strcompress(g_strchomp (g_strchug (match)))); + + } else if (g_str_has_prefix (string->str, "pulsate")) { + gchar *colon, *command, *value; + + zenity_util_strip_newline (string->str); + + colon = strchr(string->str, ':'); + if (colon == NULL) { + continue; + } + + /* split off the command and value */ + command = g_strstrip (g_strndup (string->str, colon - string->str)); + + value = colon + 1; + while (*value && g_ascii_isspace (*value)) value++; + + if (!g_ascii_strcasecmp (value, "false")) { + zenity_progress_pulsate_stop (); + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), + progress_data->percentage / 100.0); + } else { + zenity_progress_pulsate_start (progress_bar); + } + + g_free (command); } else { if (!g_ascii_isdigit (*(string->str))) @@ -134,14 +161,17 @@ zenity_progress_handle_stdin (GIOChannel *channel, GObject *button; button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); + progress_data->percentage = 100; gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); if (progress_data->autoclose) { zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit(); } - } else + } else { gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); + progress_data->percentage = percentage; + } } } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); -- cgit From f0dfc8a82038de334c545a4add70851051dabccc Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 10 Aug 2009 03:22:05 +0100 Subject: [progress] Improve code to update of percentage --- src/progress.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index a0868eaa..bc1c102d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -156,21 +156,24 @@ zenity_progress_handle_stdin (GIOChannel *channel, continue; /* Now try to convert the thing to a number */ - percentage = atoi (string->str); - if (percentage >= 100) { + percentage = CLAMP(atoi (string->str), 0, 100); + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), + percentage / 100.0); + + progress_data->percentage = percentage; + + if (percentage == 100) { GObject *button; + button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - progress_data->percentage = 100; gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); gtk_widget_grab_focus(GTK_WIDGET (button)); + if (progress_data->autoclose) { zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit(); } - } else { - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); - progress_data->percentage = percentage; } } -- cgit From 4bba7c63f81b2d198bbe9fe2988005fed96b72ba Mon Sep 17 00:00:00 2001 From: Matt Keenan Date: Mon, 10 Aug 2009 03:36:13 +0100 Subject: Bug 549404 - --help-entry for hide-text incorrect --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 93a09a21..5742648c 100644 --- a/src/option.c +++ b/src/option.c @@ -257,7 +257,7 @@ static GOptionEntry entry_options[] = { G_OPTION_ARG_NONE, &zenity_entry_hide_text, N_("Hide the entry text"), - N_("TEXT") + NULL }, { NULL -- cgit From bf53ffc6f2d9e6345d04e9a8a88752ac9a071bdf Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 10 Aug 2009 03:40:59 +0100 Subject: [option] Fix type of filters variable --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 5742648c..2367d089 100644 --- a/src/option.c +++ b/src/option.c @@ -65,7 +65,7 @@ static gboolean zenity_file_active; static gboolean zenity_file_directory; static gboolean zenity_file_save; static gboolean zenity_file_confirm_overwrite; -static GtkFileFilter *zenity_file_filter; +static gchar **zenity_file_filter; /* List Dialog Options */ static gboolean zenity_list_active; -- cgit From 82f63f94d5f7204a77d22fea7eb0331ce5d59311 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 10 Aug 2009 03:44:00 +0100 Subject: [option] Free file filter list on exit --- src/option.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 2367d089..1bc2eafc 100644 --- a/src/option.c +++ b/src/option.c @@ -861,6 +861,9 @@ zenity_option_free (void) { if (zenity_entry_entry_text) g_free (zenity_entry_entry_text); + if (zenity_file_filter) + g_strfreev (zenity_file_filter); + if (zenity_list_columns) g_strfreev (zenity_list_columns); if (zenity_list_print_column) -- cgit From 171e59e3eae4ff183d690c460f99eea788b70be8 Mon Sep 17 00:00:00 2001 From: Adrian Carpenter Date: Mon, 10 Aug 2009 03:59:34 +0100 Subject: Bug 551116 - Fix default activation in entry dialog when using the dialog with drop down menu. --- src/entry.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 43a312d5..8826e92b 100644 --- a/src/entry.c +++ b/src/entry.c @@ -42,6 +42,12 @@ zenity_entry_fill_entries (GSList **entries, const gchar **args) } } +static void +zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) +{ + gtk_window_activate_default (GTK_WINDOW (window)); +} + void zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { @@ -96,6 +102,10 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } + + g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", + G_CALLBACK (zenity_entry_combo_activate_default), + GTK_WINDOW (dialog)); } else { entry = gtk_entry_new(); -- cgit From 8e190dbb1f39eae31210f7d4c97a4c5ebb496907 Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Mon, 10 Aug 2009 04:10:53 +0100 Subject: Bug 552971 - Add a hide-header option to list dialog --- src/option.c | 16 ++++++++++++++++ src/tree.c | 3 +++ src/zenity.h | 1 + 3 files changed, 20 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 1bc2eafc..58ea5381 100644 --- a/src/option.c +++ b/src/option.c @@ -74,6 +74,7 @@ static gboolean zenity_list_checklist; static gboolean zenity_list_radiolist; static gchar *zenity_list_print_column; static gchar *zenity_list_hide_column; +static gchar *zenity_list_hide_header; /* Notification Dialog Options */ static gboolean zenity_notification_active; @@ -502,6 +503,15 @@ static GOptionEntry list_options[] = { N_("Hide a specific column"), N_("NUMBER") }, + { + "hide-header", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_list_hide_header, + N_("Hides the column headers"), + NULL + }, { NULL } @@ -1010,6 +1020,7 @@ zenity_list_pre_callback (GOptionContext *context, zenity_list_columns = NULL; zenity_list_checklist = FALSE; zenity_list_radiolist = FALSE; + zenity_list_hide_header = FALSE; zenity_list_print_column = NULL; zenity_list_hide_column = NULL; @@ -1294,6 +1305,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->editable = zenity_general_editable; results->tree_data->print_column = zenity_list_print_column; results->tree_data->hide_column = zenity_list_hide_column; + results->tree_data->hide_header = zenity_list_hide_header; results->tree_data->separator = zenity_general_separator; } else { if (zenity_list_columns) @@ -1315,6 +1327,10 @@ zenity_list_post_callback (GOptionContext *context, if (zenity_list_hide_column) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column), ERROR_SUPPORT); + + if (zenity_list_hide_header) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_header), + ERROR_SUPPORT); } return TRUE; diff --git a/src/tree.c b/src/tree.c index da2cf474..f0fc1873 100644 --- a/src/tree.c +++ b/src/tree.c @@ -480,6 +480,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); + if (tree_data->hide_header) + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); + if (tree_data->radiobox || tree_data->checkbox) { if (tree_data->data && *tree_data->data) zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); diff --git a/src/zenity.h b/src/zenity.h index 3248ad37..fa65b0c0 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -111,6 +111,7 @@ typedef struct { GSList *columns; gboolean checkbox; gboolean radiobox; + gboolean hide_header; gchar *separator; gboolean multi; gboolean editable; -- cgit From c1f2e66288e5fbb5e2b4402139f45cb96735d24a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 10 Aug 2009 04:17:47 +0100 Subject: Bug 572835 – Zenity --question should be yes or no MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index cf0e47d0..fd92289c 100644 --- a/src/msg.c +++ b/src/msg.c @@ -33,8 +33,8 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data { GtkWidget *cancel_button, *ok_button; - cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_OK); + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); gtk_widget_grab_focus (ok_button); -- cgit From cf0f0b1668d4a20f86eb30af290a7a136563f11c Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Wed, 16 Sep 2009 21:30:46 +0100 Subject: [list] allow escaped chars as separator --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index f0fc1873..63287e36 100644 --- a/src/tree.c +++ b/src/tree.c @@ -298,7 +298,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } - separator = g_strdup (tree_data->separator); + separator = g_strcompress (tree_data->separator); n_columns = g_slist_length (tree_data->columns); -- cgit From 97d7fa636e4f5ee20a53b667d9d27303b951a05d Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Sun, 13 Dec 2009 17:45:28 +0000 Subject: Bug 603673 - Show correct license in the about dialog --- src/about.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index b8f1fc06..dc241663 100644 --- a/src/about.c +++ b/src/about.c @@ -62,14 +62,14 @@ static gchar *translators; static const char *license[] = { N_("This program is free software; you can redistribute it and/or modify " - "it under the terms of the GNU General Public License as published by " + "it under the terms of the GNU Lesser General Public License as published by " "the Free Software Foundation; either version 2 of the License, or " "(at your option) any later version.\n"), N_("This program is distributed in the hope that it will be useful, " "but WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " "GNU General Public License for more details.\n"), - N_("You should have received a copy of the GNU General Public License " + N_("You should have received a copy of the GNU Lesser General Public License " "along with this program; if not, write to the Free Software " "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.") }; -- cgit From 3b4f73ce466eb76c746920ba25e9c2f00374017a Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 23 Feb 2010 17:53:38 +0000 Subject: [options] Use correct type in hide_header variable --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 58ea5381..0e3ede5f 100644 --- a/src/option.c +++ b/src/option.c @@ -74,7 +74,7 @@ static gboolean zenity_list_checklist; static gboolean zenity_list_radiolist; static gchar *zenity_list_print_column; static gchar *zenity_list_hide_column; -static gchar *zenity_list_hide_header; +static gboolean zenity_list_hide_header; /* Notification Dialog Options */ static gboolean zenity_notification_active; -- cgit From 078ff023621c57c7287a4978bf944d812481c82c Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Tue, 23 Feb 2010 17:55:00 +0000 Subject: Bug 609224 - GPL mentioning left in about dialog --- src/about.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index dc241663..de85a549 100644 --- a/src/about.c +++ b/src/about.c @@ -68,7 +68,7 @@ static const char *license[] = { N_("This program is distributed in the hope that it will be useful, " "but WITHOUT ANY WARRANTY; without even the implied warranty of " "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " - "GNU General Public License for more details.\n"), + "GNU Lesser General Public License for more details.\n"), N_("You should have received a copy of the GNU Lesser General Public License " "along with this program; if not, write to the Free Software " "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.") -- cgit From 3c17a5a8870422b9a9145ff805d6d3bb872dacea Mon Sep 17 00:00:00 2001 From: Huzaifa Sidhpurwala Date: Tue, 23 Feb 2010 18:07:08 +0000 Subject: Bug 593926 - --progress needs a --nocancel option --- src/option.c | 17 ++++++++++++++++- src/progress.c | 17 +++++++++++++++++ src/zenity.h | 1 + 3 files changed, 34 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 0e3ede5f..bc09009a 100644 --- a/src/option.c +++ b/src/option.c @@ -86,6 +86,7 @@ static int zenity_progress_percentage; static gboolean zenity_progress_pulsate; static gboolean zenity_progress_auto_close; static gboolean zenity_progress_auto_kill; +static gboolean zenity_progress_no_cancel; /* Question Dialog Options */ static gboolean zenity_question_active; @@ -607,6 +608,16 @@ static GOptionEntry progress_options[] = { N_("Kill parent process if cancel button is pressed"), NULL }, + { + "no-cancel", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_no_cancel, + /* xgettext: no-c-format */ + N_("Hide cancel button"), + NULL + }, { NULL } @@ -1050,7 +1061,7 @@ zenity_progress_pre_callback (GOptionContext *context, zenity_progress_pulsate = FALSE; zenity_progress_auto_close = FALSE; zenity_progress_auto_kill = FALSE; - + zenity_progress_no_cancel = FALSE; return TRUE; } @@ -1370,6 +1381,7 @@ zenity_progress_post_callback (GOptionContext *context, results->progress_data->autoclose = zenity_progress_auto_close; results->progress_data->autokill = zenity_progress_auto_kill; results->progress_data->percentage = zenity_progress_percentage; + results->progress_data->no_cancel = zenity_progress_no_cancel; } else { if (zenity_progress_pulsate) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_pulsate), @@ -1386,6 +1398,9 @@ zenity_progress_post_callback (GOptionContext *context, if (zenity_progress_auto_kill) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_kill), ERROR_SUPPORT); + if (zenity_progress_no_cancel) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_no_cancel), + ERROR_SUPPORT); } return TRUE; diff --git a/src/progress.c b/src/progress.c index bc1c102d..40f91821 100644 --- a/src/progress.c +++ b/src/progress.c @@ -38,6 +38,8 @@ static GIOChannel *channel; static gint pulsate_timeout = -1; static gboolean autokill; +static gboolean no_cancel; +static gboolean auto_close; gint zenity_progress_timeout (gpointer data); gint zenity_progress_pulsate_timeout (gpointer data); @@ -227,6 +229,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) GtkWidget *dialog; GObject *text; GObject *progress_bar; + GObject *cancel_button,*ok_button; zen_data = data; builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL); @@ -265,6 +268,20 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) autokill = progress_data->autokill; + auto_close = progress_data->autoclose; + ok_button = gtk_builder_get_object (builder, "zenity_progress_ok_button"); + + no_cancel = progress_data->no_cancel; + cancel_button = gtk_builder_get_object (builder, "zenity_progress_cancel_button"); + + if (no_cancel) { + gtk_widget_hide (GTK_WIDGET(cancel_button)); + gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE); + } + + if (no_cancel && auto_close) + gtk_widget_hide(GTK_WIDGET(ok_button)); + zenity_util_show_dialog (dialog); zenity_progress_read_info (progress_data); diff --git a/src/zenity.h b/src/zenity.h index fa65b0c0..9d7a1532 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -98,6 +98,7 @@ typedef struct { gboolean autoclose; gboolean autokill; gdouble percentage; + gboolean no_cancel; } ZenityProgressData; typedef struct { -- cgit From 4ccc7f6fac79a189e0c0c4896bb2f0f38d38d7c7 Mon Sep 17 00:00:00 2001 From: Berislav Kovacki Date: Tue, 23 Feb 2010 18:24:20 +0000 Subject: Bug 540169 - Zenity should offer color selection dialog --- src/Makefile.am | 1 + src/color.c | 97 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/main.c | 3 ++ src/option.c | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/option.h | 2 ++ src/zenity.h | 7 +++++ 6 files changed, 200 insertions(+) create mode 100644 src/color.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 30f7ccd3..dbd672d0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,6 +16,7 @@ zenity_SOURCES = \ scale.c \ text.c \ tree.c \ + color.c \ util.c \ util.h \ zenity.h diff --git a/src/color.c b/src/color.c new file mode 100644 index 00000000..8f31937f --- /dev/null +++ b/src/color.c @@ -0,0 +1,97 @@ +/* + * color.c + * + * Copyright (C) 2010 Berislav Kovacki + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Berislav Kovacki + */ + +#include "config.h" + +#include +#include "zenity.h" +#include "util.h" + +static ZenityData *zen_data; + +static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data); + +void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) +{ + GtkWidget *dialog; + GtkWidget *colorsel; + GdkColor color; + + zen_data = data; + + dialog = gtk_color_selection_dialog_new (NULL); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_colorselection_dialog_response), + color_data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog)); + + if (color_data->color) { + if (gdk_color_parse (color_data->color, &color)) + gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), + &color); + } + + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), + color_data->show_palette); + + zenity_util_show_dialog (dialog); + + if (data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + + gtk_main(); +} + +static void +zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + GtkWidget *colorsel; + GdkColor color; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); + gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); + g_print ("%s\n", gdk_color_to_string (&color)); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); +} diff --git a/src/main.c b/src/main.c index 4f87e6df..5e079707 100644 --- a/src/main.c +++ b/src/main.c @@ -84,6 +84,9 @@ main (gint argc, gchar **argv) { case MODE_TEXTINFO: zenity_text (results->data, results->text_data); break; + case MODE_COLOR: + zenity_colorselection (results->data, results->color_data); + break; case MODE_ABOUT: zenity_about (results->data); break; diff --git a/src/option.c b/src/option.c index bc09009a..00467452 100644 --- a/src/option.c +++ b/src/option.c @@ -108,6 +108,11 @@ static gint zenity_scale_step; static gboolean zenity_scale_print_partial; static gboolean zenity_scale_hide_value; +/* Color Selection Dialog Options */ +static gboolean zenity_colorsel_active; +static gchar *zenity_colorsel_color; +static gboolean zenity_colorsel_show_palette; + /* Miscelaneus Options */ static gboolean zenity_misc_about; static gboolean zenity_misc_version; @@ -818,6 +823,39 @@ static GOptionEntry scale_options[] = { } }; +static GOptionEntry color_selection_options[] = { + { + "color-selection", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_colorsel_active, + N_("Display color selection dialog"), + NULL + }, + { + "color", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_colorsel_color, + N_("Set the color"), + N_("VALUE") + }, + { + "show-palette", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_colorsel_show_palette, + N_("Show the palette"), + NULL + }, + { + NULL + } +}; + static GOptionEntry miscellaneous_options[] = { { "about", @@ -862,6 +900,7 @@ zenity_option_init (void) { results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); results->notification_data = g_new0 (ZenityNotificationData, 1); + results->color_data = g_new0 (ZenityColorData, 1); } void @@ -897,6 +936,9 @@ zenity_option_free (void) { if (zenity_question_cancel_button) g_free (zenity_question_cancel_button); + if (zenity_colorsel_color) + g_free (zenity_colorsel_color); + g_option_context_free (ctx); } @@ -1115,6 +1157,19 @@ zenity_scale_pre_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_color_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_colorsel_active = FALSE; + zenity_colorsel_color = NULL; + zenity_colorsel_show_palette = FALSE; + + return TRUE; +} + static gboolean zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, @@ -1480,6 +1535,30 @@ zenity_scale_post_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_color_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_colorsel_active, MODE_COLOR); + + if (results->mode == MODE_COLOR) { + results->color_data->color = zenity_colorsel_color; + results->color_data->show_palette = zenity_colorsel_show_palette; + } else { + if (zenity_colorsel_color) + zenity_option_error (zenity_option_get_name(color_selection_options, &zenity_colorsel_color), + ERROR_SUPPORT); + + if (zenity_colorsel_show_palette) + zenity_option_error (zenity_option_get_name(color_selection_options, &zenity_colorsel_show_palette), + ERROR_SUPPORT); + } + + return TRUE; +} + static gboolean zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group, @@ -1643,6 +1722,17 @@ zenity_create_context (void) g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); + /* Adds color selection option entries */ + a_group = g_option_group_new("color-selection", + N_("Color selection options"), + N_("Show color selection options"), NULL, NULL); + g_option_group_add_entries(a_group, color_selection_options); + g_option_group_set_parse_hooks (a_group, + zenity_color_pre_callback, zenity_color_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group(tmp_ctx, a_group); + /* Adds misc option entries */ a_group = g_option_group_new("misc", N_("Miscellaneous options"), diff --git a/src/option.h b/src/option.h index 2b7a703b..f52c3125 100644 --- a/src/option.h +++ b/src/option.h @@ -45,6 +45,7 @@ typedef enum { MODE_SCALE, MODE_INFO, MODE_NOTIFICATION, + MODE_COLOR, MODE_ABOUT, MODE_VERSION, MODE_LAST @@ -70,6 +71,7 @@ typedef struct { ZenityTextData *text_data; ZenityTreeData *tree_data; ZenityNotificationData *notification_data; + ZenityColorData *color_data; } ZenityParsingOptions; void zenity_option_error (gchar *string, diff --git a/src/zenity.h b/src/zenity.h index 9d7a1532..a4cff2b9 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -126,6 +126,11 @@ typedef struct { gboolean listen; } ZenityNotificationData; +typedef struct { + gchar *color; + gboolean show_palette; +} ZenityColorData; + void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data); void zenity_msg (ZenityData *data, @@ -142,6 +147,8 @@ void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data); +void zenity_colorselection (ZenityData *data, + ZenityColorData *notification_data); void zenity_scale (ZenityData *data, ZenityScaleData *scale_data); void zenity_about (ZenityData *data); -- cgit From 29625ff9cc86c183c3c6a3b1ab8ee77722580c54 Mon Sep 17 00:00:00 2001 From: Andre Klapper Date: Wed, 10 Mar 2010 23:51:28 +0100 Subject: Compile with -DGSEAL_ENABLED. Fixes bug 612498. --- src/about.c | 4 ++-- src/util.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index de85a549..67c2474c 100644 --- a/src/about.c +++ b/src/about.c @@ -295,9 +295,9 @@ zenity_about (ZenityData *data) gtk_widget_show (help_button); - gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->action_area), + gtk_box_pack_end (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), help_button, FALSE, TRUE, 0); - gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), + gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), help_button, TRUE); g_signal_connect (G_OBJECT (dialog), "response", diff --git a/src/util.c b/src/util.c index 036e2b54..96bf3152 100644 --- a/src/util.c +++ b/src/util.c @@ -403,8 +403,8 @@ zenity_util_show_dialog (GtkWidget *dialog) { gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 - g_assert (dialog->window); - zenity_util_make_transient (dialog->window); + g_assert (gtk_widget_get_window(dialog)); + zenity_util_make_transient (gtk_widget_get_window(dialog)); #endif gtk_widget_show (dialog); } -- cgit From eb6ed94c9eac1dae8c943041bc278b9b9e0e26b0 Mon Sep 17 00:00:00 2001 From: Michal Pryc Date: Mon, 19 Apr 2010 13:36:52 +0100 Subject: Bug 615527 - zenity hangs if invalid WINDOWID is specified --- src/util.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 96bf3152..8f887f35 100644 --- a/src/util.c +++ b/src/util.c @@ -323,13 +323,14 @@ transient_get_xterm (void) const char *wid_str = g_getenv ("WINDOWID"); if (wid_str) { char *wid_str_end; + int ret; Window wid = strtoul (wid_str, &wid_str_end, 10); if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) { XWindowAttributes attrs; gdk_error_trap_push (); - XGetWindowAttributes (GDK_DISPLAY(), wid, &attrs); + ret = XGetWindowAttributes (GDK_DISPLAY(), wid, &attrs); gdk_flush(); - if (gdk_error_trap_pop () != 0) { + if (gdk_error_trap_pop () != 0 || ret == 0) { return None; } return wid; -- cgit From 1570a2bbf07627cb5f8d9828a95db67b7d00634c Mon Sep 17 00:00:00 2001 From: Philippe Gauthier Date: Fri, 30 Oct 2009 14:51:16 -0400 Subject: Use g_timeout_add_seconds instead g_timeout_add The calls to g_timeout_add are replaced with g_timeout_add_seconds to reduce the number or program wake ups. See the GNOME Goal description: http://live.gnome.org/GnomeGoals/UseTimeoutAddSeconds --- src/calendar.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/msg.c | 2 +- src/notification.c | 2 +- src/progress.c | 2 +- src/scale.c | 2 +- src/text.c | 2 +- src/tree.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 8ad53ea6..9aaee9f2 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -85,7 +85,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); diff --git a/src/entry.c b/src/entry.c index 8826e92b..ca53caf2 100644 --- a/src/entry.c +++ b/src/entry.c @@ -129,7 +129,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); diff --git a/src/fileselection.c b/src/fileselection.c index dd4ab0d3..026bb310 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); diff --git a/src/msg.c b/src/msg.c index fd92289c..1a92875b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); diff --git a/src/notification.c b/src/notification.c index 674eaec9..99a2e36a 100644 --- a/src/notification.c +++ b/src/notification.c @@ -292,7 +292,7 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data gtk_status_icon_set_visible (status_icon, TRUE); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); diff --git a/src/progress.c b/src/progress.c index 40f91821..4f1f55ef 100644 --- a/src/progress.c +++ b/src/progress.c @@ -286,7 +286,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) zenity_progress_read_info (progress_data); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); diff --git a/src/scale.c b/src/scale.c index 86787742..c0d25d12 100644 --- a/src/scale.c +++ b/src/scale.c @@ -92,7 +92,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); diff --git a/src/text.c b/src/text.c index 25bd7688..eb5f989b 100644 --- a/src/text.c +++ b/src/text.c @@ -152,7 +152,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) g_object_unref (builder); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); diff --git a/src/tree.c b/src/tree.c index 63287e36..3861e863 100644 --- a/src/tree.c +++ b/src/tree.c @@ -499,7 +499,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); -- cgit From 10d038022014a8069495bd72ccf9ed47fdf9d14d Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Sat, 10 Jul 2010 16:13:40 -0300 Subject: Add new password dialog --- src/Makefile.am | 1 + src/main.c | 3 + src/option.c | 72 +++++++++++++++++++++++- src/option.h | 2 + src/password.c | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 10 ++++ 6 files changed, 256 insertions(+), 1 deletion(-) create mode 100644 src/password.c (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index dbd672d0..03110fbc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -17,6 +17,7 @@ zenity_SOURCES = \ text.c \ tree.c \ color.c \ + password.c \ util.c \ util.h \ zenity.h diff --git a/src/main.c b/src/main.c index 5e079707..ee8fc3bf 100644 --- a/src/main.c +++ b/src/main.c @@ -87,6 +87,9 @@ main (gint argc, gchar **argv) { case MODE_COLOR: zenity_colorselection (results->data, results->color_data); break; + case MODE_PASSWORD: + zenity_password_dialog (results->data, results->password_data); + break; case MODE_ABOUT: zenity_about (results->data); break; diff --git a/src/option.c b/src/option.c index 00467452..b9694fde 100644 --- a/src/option.c +++ b/src/option.c @@ -113,6 +113,10 @@ static gboolean zenity_colorsel_active; static gchar *zenity_colorsel_color; static gboolean zenity_colorsel_show_palette; +/* Password Dialog Options */ +static gboolean zenity_password_active; +static gboolean zenity_password_show_username; + /* Miscelaneus Options */ static gboolean zenity_misc_about; static gboolean zenity_misc_version; @@ -823,6 +827,30 @@ static GOptionEntry scale_options[] = { } }; +static GOptionEntry password_dialog_options[] = { + { + "password", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_password_active, + N_("Display password dialog"), + NULL + }, + { + "username", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_password_show_username, + N_("Display the username option"), + NULL + }, + { + NULL + } +}; + static GOptionEntry color_selection_options[] = { { "color-selection", @@ -901,6 +929,7 @@ zenity_option_init (void) { results->tree_data = g_new0 (ZenityTreeData, 1); results->notification_data = g_new0 (ZenityNotificationData, 1); results->color_data = g_new0 (ZenityColorData, 1); + results->password_data = g_new0 (ZenityPasswordData, 1); } void @@ -938,7 +967,7 @@ zenity_option_free (void) { if (zenity_colorsel_color) g_free (zenity_colorsel_color); - + g_option_context_free (ctx); } @@ -1170,6 +1199,18 @@ zenity_color_pre_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_password_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_password_active = FALSE; + zenity_password_show_username = FALSE; + + return TRUE; +} + static gboolean zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, @@ -1559,6 +1600,24 @@ zenity_color_post_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_password_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_password_active, MODE_PASSWORD); + if (results->mode == MODE_PASSWORD) { + results->password_data->username = zenity_password_show_username; + } else { + if (zenity_password_show_username) + zenity_option_error (zenity_option_get_name(password_dialog_options, &zenity_password_show_username), + ERROR_SUPPORT); + } + + return TRUE; +} + static gboolean zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group, @@ -1733,6 +1792,17 @@ zenity_create_context (void) g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); + /* Adds password dialog option entries */ + a_group = g_option_group_new("password", + N_("Password dialog options"), + N_("Show password dialog options"), NULL, NULL); + g_option_group_add_entries (a_group, password_dialog_options); + g_option_group_set_parse_hooks (a_group, + zenity_password_pre_callback, zenity_password_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group(tmp_ctx, a_group); + /* Adds misc option entries */ a_group = g_option_group_new("misc", N_("Miscellaneous options"), diff --git a/src/option.h b/src/option.h index f52c3125..076b4c77 100644 --- a/src/option.h +++ b/src/option.h @@ -46,6 +46,7 @@ typedef enum { MODE_INFO, MODE_NOTIFICATION, MODE_COLOR, + MODE_PASSWORD, MODE_ABOUT, MODE_VERSION, MODE_LAST @@ -72,6 +73,7 @@ typedef struct { ZenityTreeData *tree_data; ZenityNotificationData *notification_data; ZenityColorData *color_data; + ZenityPasswordData *password_data; } ZenityParsingOptions; void zenity_option_error (gchar *string, diff --git a/src/password.c b/src/password.c new file mode 100644 index 00000000..96aef7a2 --- /dev/null +++ b/src/password.c @@ -0,0 +1,169 @@ +/* + * password.c + * + * Copyright (C) 2010 Berislav Kovacki + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 121 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Arx Cruz + */ + +#include "config.h" +#include +#include "zenity.h" +#include "util.h" + +static ZenityData *zen_data; + +static void zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data); + +void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data) +{ + GtkWidget *dialog; + GtkWidget *image; + GtkWidget *hbox; + GtkWidget *vbox_labels; + GtkWidget *vbox_entries; + GtkWidget *label; + GtkWidget *align; + + zen_data = data; + + dialog = gtk_dialog_new (); + + gtk_dialog_add_button(GTK_DIALOG(dialog), + GTK_STOCK_CANCEL, + GTK_RESPONSE_CANCEL); + gtk_dialog_add_button(GTK_DIALOG(dialog), + GTK_STOCK_OK, + GTK_RESPONSE_OK); + + image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, + GTK_ICON_SIZE_DIALOG); + gtk_dialog_set_default_response(GTK_DIALOG(dialog), + GTK_RESPONSE_OK); + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(hbox), + image, + FALSE, + FALSE, + 12); + label = gtk_label_new(_("Type your password")); + gtk_box_pack_start(GTK_BOX(hbox), + label, + FALSE, + FALSE, + 12); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + hbox, + FALSE, + TRUE, + 5); + + vbox_labels = gtk_vbox_new(FALSE, 5); + vbox_entries = gtk_vbox_new(FALSE, 5); + + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + hbox, + FALSE, + TRUE, + 5); + + gtk_box_pack_start(GTK_BOX(hbox), + vbox_labels, + FALSE, + TRUE, + 12); + gtk_box_pack_start(GTK_BOX(hbox), + vbox_entries, + TRUE, + TRUE, + 12); + + if(password_data->username) { + align = gtk_alignment_new(0.0, 0.12, 0.0, 0.0); + label = gtk_label_new(_("Username:")); + gtk_container_add(GTK_CONTAINER(align), label); + gtk_box_pack_start(GTK_BOX(vbox_labels), + align, + TRUE, + FALSE, + 12); + password_data->entry_username = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(vbox_entries), + password_data->entry_username, + TRUE, + TRUE, + 12); + } + + align = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); + label = gtk_label_new(_("Password:")); + gtk_container_add(GTK_CONTAINER(align), label); + + gtk_box_pack_start(GTK_BOX(vbox_labels), + align, + TRUE, + FALSE, + 12); + password_data->entry_password = gtk_entry_new(); + gtk_entry_set_visibility(GTK_ENTRY(password_data->entry_password), + FALSE); + gtk_box_pack_start(GTK_BOX(vbox_entries), + password_data->entry_password, + TRUE, + TRUE, + 12); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + g_signal_connect (G_OBJECT (dialog), "response", + G_CALLBACK (zenity_password_dialog_response), + password_data); + gtk_widget_show_all(GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); + zenity_util_show_dialog (dialog); + + if (data->timeout_delay > 0) { + g_timeout_add (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + gtk_main(); +} + +static void +zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + ZenityPasswordData *password_data = (ZenityPasswordData *) data; + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); +} diff --git a/src/zenity.h b/src/zenity.h index a4cff2b9..ecde3db6 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -131,6 +131,13 @@ typedef struct { gboolean show_palette; } ZenityColorData; +typedef struct { + gboolean username; + gchar *password; + GtkWidget *entry_username; + GtkWidget *entry_password; +} ZenityPasswordData; + void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data); void zenity_msg (ZenityData *data, @@ -153,6 +160,9 @@ void zenity_scale (ZenityData *data, ZenityScaleData *scale_data); void zenity_about (ZenityData *data); +void zenity_password_dialog (ZenityData *data, + ZenityPasswordData *password_data); + G_END_DECLS #endif /* ZENITY_H */ -- cgit From 79ea294e0a55190f2e4e3de895e3f9afc78ef4eb Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 12 Jul 2010 11:20:02 -0300 Subject: Just changing the copyright. --- src/password.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 96aef7a2..7aee3068 100644 --- a/src/password.c +++ b/src/password.c @@ -1,7 +1,7 @@ /* * password.c * - * Copyright (C) 2010 Berislav Kovacki + * Copyright (C) 2010 Arx Cruz * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public -- cgit From 7969d942c8c1d6fa4b5536d36080a5331db196d7 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 12 Jul 2010 12:57:47 -0300 Subject: Change GTK_DIALOG(dialog)->vbox to gtk_dialog_get_content_area() in order to compile with GTK 3.0 --- src/password.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 7aee3068..00896eaf 100644 --- a/src/password.c +++ b/src/password.c @@ -67,7 +67,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data FALSE, FALSE, 12); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, TRUE, @@ -77,7 +77,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data vbox_entries = gtk_vbox_new(FALSE, 5); hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), + gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, TRUE, @@ -135,7 +135,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_password_dialog_response), password_data); - gtk_widget_show_all(GTK_WIDGET(GTK_DIALOG(dialog)->vbox)); + gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog)))); zenity_util_show_dialog (dialog); if (data->timeout_delay > 0) { -- cgit From 3ae7f89228297d88bb4fd12c64f5f2f0377201d1 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 21 Jul 2010 20:22:16 -0300 Subject: Change cancel button messages to be capitalized --- src/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index b9694fde..af206a02 100644 --- a/src/option.c +++ b/src/option.c @@ -614,7 +614,7 @@ static GOptionEntry progress_options[] = { G_OPTION_ARG_NONE, &zenity_progress_auto_kill, /* xgettext: no-c-format */ - N_("Kill parent process if cancel button is pressed"), + N_("Kill parent process if Cancel button is pressed"), NULL }, { @@ -624,7 +624,7 @@ static GOptionEntry progress_options[] = { G_OPTION_ARG_NONE, &zenity_progress_no_cancel, /* xgettext: no-c-format */ - N_("Hide cancel button"), + N_("Hide Cancel button"), NULL }, { -- cgit From 00684221706b821ba9b3da09c2ecb73b149ef5a1 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 21 Jul 2010 20:16:21 -0300 Subject: Removing X_LIBS from src/Makefile --- src/Makefile.am | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 03110fbc..95f0790f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -39,8 +39,7 @@ zenity_LDFLAGS = \ zenity_LDADD = \ $(ZENITY_LIBS) \ - $(LIBNOTIFY_LIBS) \ - $(X_LIBS) + $(LIBNOTIFY_LIBS) uidir = $(datadir)/zenity -- cgit From 18ed4622acad91021976435f693fd560098432c5 Mon Sep 17 00:00:00 2001 From: Luis Medinas Date: Wed, 29 Sep 2010 12:26:52 +0100 Subject: Add default activation on entry. Fixes bgo#630884 - Zenity --password dialog doesn't have a default action --- src/password.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/password.c b/src/password.c index 00896eaf..3d9311ab 100644 --- a/src/password.c +++ b/src/password.c @@ -123,6 +123,8 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data password_data->entry_password = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(password_data->entry_password), FALSE); + gtk_entry_set_activates_default (GTK_ENTRY(password_data->entry_password), + TRUE); gtk_box_pack_start(GTK_BOX(vbox_entries), password_data->entry_password, TRUE, -- cgit From bb00f842d0e1504d53c348b9de3c7eadb5251796 Mon Sep 17 00:00:00 2001 From: Luis Medinas Date: Sat, 2 Oct 2010 20:00:04 +0100 Subject: Remove GDK_DISPLAY() usage. Fixes build with GTK+-3.0 Replaced by GDK_DISPLAY_XDISPLAY. --- src/util.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 8f887f35..186a8db4 100644 --- a/src/util.c +++ b/src/util.c @@ -328,7 +328,7 @@ transient_get_xterm (void) if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) { XWindowAttributes attrs; gdk_error_trap_push (); - ret = XGetWindowAttributes (GDK_DISPLAY(), wid, &attrs); + ret = XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wid, &attrs); gdk_flush(); if (gdk_error_trap_pop () != 0 || ret == 0) { return None; @@ -350,7 +350,7 @@ static gboolean transient_is_toplevel (Window wid) { XTextProperty prop; - Display *dpy = GDK_DISPLAY (); + Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); if (!XGetWMName (dpy, wid, &prop)) return FALSE; transient_x_free (prop.value); @@ -367,7 +367,7 @@ static Window transient_get_xterm_toplevel (void) { Window xterm = transient_get_xterm (); - Display *dpy = GDK_DISPLAY (); + Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); while (xterm != None && !transient_is_toplevel (xterm)) { Window root, parent, *children; -- cgit From 620d5505c59b5b5dd092bfa35bdf3e7723f1e7c3 Mon Sep 17 00:00:00 2001 From: William Jon McCann Date: Sat, 9 Oct 2010 04:59:44 -0400 Subject: Require libnotify 0.6.1 https://bugzilla.gnome.org/show_bug.cgi?id=631737 --- src/notification.c | 198 ++++++++++++++++++----------------------------------- 1 file changed, 65 insertions(+), 133 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 99a2e36a..531aed22 100644 --- a/src/notification.c +++ b/src/notification.c @@ -24,75 +24,31 @@ #include +#include +#include #include #include #include - -#ifdef HAVE_LIBNOTIFY #include -#endif #include "zenity.h" #include "util.h" -static GtkStatusIcon *status_icon; -static gchar *icon_file; -static const gchar *icon_stock; -static gint icon_size; +static char *icon_file; static void -zenity_notification_icon_update (void) +on_notification_default_action (NotifyNotification *n, + const char *action, + void *user_data) { - GdkPixbuf *pixbuf; - GError *error = NULL; - - pixbuf = gdk_pixbuf_new_from_file_at_scale (icon_file, icon_size, icon_size, TRUE, &error); - - if (error) { - g_warning ("Could not load notification icon '%s': %s", - icon_file, error->message); - g_clear_error (&error); - } - if (!pixbuf) { - pixbuf = gdk_pixbuf_new_from_file_at_scale (ZENITY_IMAGE_FULLPATH ("zenity-notification.png"), - icon_size, icon_size, TRUE, NULL); - } - - gtk_status_icon_set_from_pixbuf (status_icon, pixbuf); - - if (pixbuf) { - g_object_unref (pixbuf); - } -} - -static gboolean -zenity_notification_icon_size_changed_cb (GtkStatusIcon *icon, - gint size, - gpointer user_data) -{ - icon_size = size; - - /* If we're displaying not a stock icon but a custom pixbuf, - * we need to update the icon for the new size. - */ - if (!icon_stock) { - zenity_notification_icon_update (); - - return TRUE; - } + ZenityData *zen_data; - return FALSE; -} + zen_data = (ZenityData *)user_data; + notify_notification_close (n, NULL); -static gboolean -zenity_notification_icon_activate_cb (GtkWidget *widget, - ZenityData *data) -{ - data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); gtk_main_quit (); - - return TRUE; } static gboolean @@ -145,26 +101,14 @@ zenity_notification_handle_stdin (GIOChannel *channel, while (*value && g_ascii_isspace (*value)) value++; if (!g_ascii_strcasecmp (command, "icon")) { - icon_stock = zenity_util_stock_from_filename (value); - g_free (icon_file); icon_file = g_strdup (value); - - if (icon_stock) { - gtk_status_icon_set_from_stock (status_icon, icon_stock); - } else if (gtk_status_icon_get_visible (status_icon) && - gtk_status_icon_is_embedded (status_icon)) { - zenity_notification_icon_update (); - } } else if (!g_ascii_strcasecmp (command, "message")) { -#ifdef HAVE_LIBNOTIFY /* display a notification bubble */ if (!g_utf8_validate (value, -1, NULL)) { g_warning ("Invalid UTF-8 in input!"); - } else if (notify_is_initted ()) { + } else { NotifyNotification *notif; - const gchar *icon = NULL; - gchar *freeme = NULL; gchar **message; error = NULL; @@ -178,46 +122,37 @@ zenity_notification_handle_stdin (GIOChannel *channel, continue; } - if (icon_stock) { - icon = icon_stock; - } else if (icon_file) { - icon = freeme = g_filename_to_uri (icon_file, NULL, NULL); - } - - notif = notify_notification_new_with_status_icon ( - message[0] /* title */, - message[1] /* summary */, - icon, status_icon); + notif = notify_notification_new (message[0] /* title */, + message[1] /* summary */, + icon_file); g_strfreev (message); - g_free (freeme); - notify_notification_show (notif, &error); - - if (error) { - g_warning ("Error showing notification: %s", error->message); - g_error_free (error); - } + notify_notification_show (notif, &error); + if (error) { + g_warning ("Error showing notification: %s", error->message); + g_error_free (error); + } g_object_unref (notif); - } else { -#else - { /* this brace is for balance */ -#endif - g_warning ("Notification framework not available"); - } + } } else if (!g_ascii_strcasecmp (command, "tooltip")) { - if (g_utf8_validate (value, -1, NULL)) { - gtk_status_icon_set_tooltip_text (status_icon, value); - } else { + if (!g_utf8_validate (value, -1, NULL)) { g_warning ("Invalid UTF-8 in input!"); + } else { + NotifyNotification *notif; + + notif = notify_notification_new (value, + NULL, + icon_file); + notify_notification_show (notif, &error); + if (error) { + g_warning ("Error showing notification: %s", error->message); + g_error_free (error); + } } } else if (!g_ascii_strcasecmp (command, "visible")) { - if (!g_ascii_strcasecmp (value, "false")) { - gtk_status_icon_set_visible (status_icon, FALSE); - } else { - gtk_status_icon_set_visible (status_icon, TRUE); - } + } else { g_warning ("Unknown command '%s'", command); } @@ -249,55 +184,52 @@ zenity_notification_listen_on_stdin (ZenityData *data) zenity_notification_handle_stdin, data); } -void +void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data) { - status_icon = gtk_status_icon_new (); - g_signal_connect (status_icon, "size-changed", - G_CALLBACK (zenity_notification_icon_size_changed_cb), data); + GError *error; + NotifyNotification *notification; - if (notification_data->notification_text) { - gtk_status_icon_set_tooltip_text (status_icon, notification_data->notification_text); - } else { - gtk_status_icon_set_tooltip_text (status_icon, _("Zenity notification")); - } - - icon_file = g_strdup (data->window_icon); - icon_stock = zenity_util_stock_from_filename (data->window_icon); - - /* Only set the stock icon here; if we're going to display a - * custom pixbuf we wait for the size-changed signal to load - * it at the right size. - */ - if (icon_stock) { - gtk_status_icon_set_from_stock (status_icon, icon_stock); - } - -#ifdef HAVE_LIBNOTIFY /* create the notification widget */ if (!notify_is_initted ()) { notify_init (_("Zenity notification")); } -#endif - + if (notification_data->listen) { zenity_notification_listen_on_stdin (data); } else { - /* if we aren't listening for changes, then close on activate (left-click) */ - g_signal_connect (status_icon, "activate", - G_CALLBACK (zenity_notification_icon_activate_cb), data); - } + if (notification_data->notification_text == NULL) { + exit (1); + } + + notification = notify_notification_new (notification_data->notification_text, NULL, data->window_icon); + if (notification == NULL) { + exit (1); + } + + /* if we aren't listening for changes, then close on default action */ + notify_notification_add_action (notification, + "default", + "Do Default Action", + (NotifyActionCallback) on_notification_default_action, + data, + NULL); + + /* Show icon and wait */ + error = NULL; + if (!notify_notification_show (notification, &error)) { + if (error != NULL) { + g_warning ("Error showing notification: %s", error->message); + g_error_free (error); + } + exit (1); + } - /* Show icon and wait */ - gtk_status_icon_set_visible (status_icon, TRUE); + } - if(data->timeout_delay > 0) { + if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); - - /* Cleanup */ - g_object_unref (status_icon); - g_free (icon_file); } -- cgit From 4421de675feeb7d490d16f5410bf6bd514d99154 Mon Sep 17 00:00:00 2001 From: Luis Medinas Date: Thu, 21 Oct 2010 00:41:09 +0100 Subject: Remove deprecated code for GTK+-3.0. --- src/entry.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index ca53caf2..d69d918a 100644 --- a/src/entry.c +++ b/src/entry.c @@ -92,14 +92,14 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) n_entries = g_slist_length (entries); if (n_entries > 1) { - entry = gtk_combo_box_entry_new_text (); + entry = gtk_combo_box_new_with_entry (); for (tmp = entries; tmp; tmp = tmp->next) { - gtk_combo_box_append_text (GTK_COMBO_BOX (entry), tmp->data); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); } if (entry_data->entry_text) { - gtk_combo_box_prepend_text (GTK_COMBO_BOX (entry), entry_data->entry_text); + gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); } @@ -145,7 +145,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); if (n_entries > 1) { - text = gtk_combo_box_get_active_text (GTK_COMBO_BOX (entry)); + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); } else { text = gtk_entry_get_text (GTK_ENTRY (entry)); -- cgit From 079254bb48c28f62d15270028e64308347888a76 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 4 Nov 2010 17:12:52 -0200 Subject: Add libnotify as optional in zenity instalation --- src/main.c | 2 ++ src/notification.c | 2 ++ src/option.c | 15 ++++++++++++++- src/option.h | 4 ++++ src/zenity.h | 5 +++++ 5 files changed, 27 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.c b/src/main.c index ee8fc3bf..05176158 100644 --- a/src/main.c +++ b/src/main.c @@ -75,9 +75,11 @@ main (gint argc, gchar **argv) { results->tree_data->data = (const gchar **) argv + 1; zenity_tree (results->data, results->tree_data); break; +#ifdef HAVE_LIBNOTIFY case MODE_NOTIFICATION: zenity_notification (results->data, results->notification_data); break; +#endif case MODE_PROGRESS: zenity_progress (results->data, results->progress_data); break; diff --git a/src/notification.c b/src/notification.c index 531aed22..6fe44f1d 100644 --- a/src/notification.c +++ b/src/notification.c @@ -34,6 +34,7 @@ #include "zenity.h" #include "util.h" +#ifdef HAVE_LIBNOTIFY static char *icon_file; static void @@ -233,3 +234,4 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data gtk_main (); } +#endif diff --git a/src/option.c b/src/option.c index af206a02..f4813450 100644 --- a/src/option.c +++ b/src/option.c @@ -76,9 +76,11 @@ static gchar *zenity_list_print_column; static gchar *zenity_list_hide_column; static gboolean zenity_list_hide_header; +#ifdef HAVE_LIBNOTIFY /* Notification Dialog Options */ static gboolean zenity_notification_active; static gboolean zenity_notification_listen; +#endif /* Progress Dialog Options */ static gboolean zenity_progress_active; @@ -527,6 +529,7 @@ static GOptionEntry list_options[] = { } }; +#ifdef HAVE_LIBNOTIFY static GOptionEntry notification_options[] = { { "notification", @@ -560,6 +563,8 @@ static GOptionEntry notification_options[] = { } }; +#endif + static GOptionEntry progress_options[] = { { "progress", @@ -927,7 +932,9 @@ zenity_option_init (void) { results->progress_data = g_new0 (ZenityProgressData, 1); results->text_data = g_new0 (ZenityTextData, 1); results->tree_data = g_new0 (ZenityTreeData, 1); +#ifdef HAVE_LIBNOTIFY results->notification_data = g_new0 (ZenityNotificationData, 1); +#endif results->color_data = g_new0 (ZenityColorData, 1); results->password_data = g_new0 (ZenityPasswordData, 1); } @@ -1109,6 +1116,7 @@ zenity_list_pre_callback (GOptionContext *context, return TRUE; } +#ifdef HAVE_LIBNOTIFY static gboolean zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group, @@ -1120,6 +1128,7 @@ zenity_notification_pre_callback (GOptionContext *context, return TRUE; } +#endif static gboolean zenity_progress_pre_callback (GOptionContext *context, @@ -1443,6 +1452,7 @@ zenity_list_post_callback (GOptionContext *context, return TRUE; } +#ifdef HAVE_LIBNOTIFY static gboolean zenity_notification_post_callback (GOptionContext *context, GOptionGroup *group, @@ -1462,6 +1472,7 @@ zenity_notification_post_callback (GOptionContext *context, return TRUE; } +#endif static gboolean zenity_progress_post_callback (GOptionContext *context, @@ -1714,7 +1725,8 @@ zenity_create_context (void) g_option_group_set_error_hook (a_group, zenity_option_error_callback); g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); - + +#ifdef HAVE_LIBNOTIFY /* Adds notification option entries */ a_group = g_option_group_new("notification", N_("Notification icon options"), @@ -1725,6 +1737,7 @@ zenity_create_context (void) g_option_group_set_error_hook (a_group, zenity_option_error_callback); g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); +#endif /* Adds progress option entries */ a_group = g_option_group_new("progress", diff --git a/src/option.h b/src/option.h index 076b4c77..ac550b3d 100644 --- a/src/option.h +++ b/src/option.h @@ -44,7 +44,9 @@ typedef enum { MODE_WARNING, MODE_SCALE, MODE_INFO, +#ifdef HAVE_LIBNOTIFY MODE_NOTIFICATION, +#endif MODE_COLOR, MODE_PASSWORD, MODE_ABOUT, @@ -71,7 +73,9 @@ typedef struct { ZenityProgressData *progress_data; ZenityTextData *text_data; ZenityTreeData *tree_data; +#ifdef HAVE_LIBNOTIFY ZenityNotificationData *notification_data; +#endif ZenityColorData *color_data; ZenityPasswordData *password_data; } ZenityParsingOptions; diff --git a/src/zenity.h b/src/zenity.h index ecde3db6..537f5f0c 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -121,10 +121,12 @@ typedef struct { const gchar **data; } ZenityTreeData; +#ifdef HAVE_LIBNOTIFY typedef struct { gchar *notification_text; gboolean listen; } ZenityNotificationData; +#endif typedef struct { gchar *color; @@ -152,8 +154,11 @@ void zenity_text (ZenityData *data, ZenityTextData *text_data); void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); +#ifdef HAVE_LIBNOTIFY void zenity_notification (ZenityData *data, ZenityNotificationData *notification_data); +#endif + void zenity_colorselection (ZenityData *data, ZenityColorData *notification_data); void zenity_scale (ZenityData *data, -- cgit From 54a8e7079a65d8dd7aea344ece6a8dbc38b3e048 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 18 Nov 2010 14:33:13 -0200 Subject: Fix for bug 412493 --- src/forms.c | 215 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 src/forms.c (limited to 'src') diff --git a/src/forms.c b/src/forms.c new file mode 100644 index 00000000..9ad78deb --- /dev/null +++ b/src/forms.c @@ -0,0 +1,215 @@ +/* + * forms.c + * + * Copyright (C) 2010 Arx Cruz + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 121 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + * + * Authors: Arx Cruz + */ + +#include "config.h" +#include +#include "zenity.h" +#include "util.h" + +static ZenityData *zen_data; + +static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); + +void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) +{ + GtkBuilder *builder = NULL; + GtkWidget *dialog; + GtkWidget *table; + GtkWidget *text; + + GSList *tmp; + + gint number_of_widgets = g_slist_length (forms_data->list); + + zen_data = data; + + builder = zenity_util_load_ui_file("zenity_forms_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals(builder, NULL); + + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog")); + + g_signal_connect (G_OBJECT(dialog), "response", + G_CALLBACK (zenity_forms_dialog_response), forms_data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); + + if (forms_data->dialog_text) + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text)); + + table = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_table")); + + gtk_table_resize (GTK_TABLE (table), number_of_widgets, 2); + + int i = 0; + + for (tmp = forms_data->list; tmp; tmp = tmp->next) { + ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; + GtkWidget *label; + GtkWidget *align; + + label = gtk_label_new(zenity_value->option_value); + + align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); + gtk_container_add (GTK_CONTAINER (align), label); + + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (align), + 0, + 1, + i, + i+1, + GTK_FILL, + GTK_FILL, + 0, + 0); + + switch(zenity_value->type) + { + case ZENITY_FORMS_ENTRY: + zenity_value->forms_widget = gtk_entry_new(); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + break; + case ZENITY_FORMS_PASSWORD: + zenity_value->forms_widget = gtk_entry_new(); + gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget), + FALSE); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + break; + case ZENITY_FORMS_CALENDAR: + zenity_value->forms_widget = gtk_calendar_new(); + gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); + align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); + gtk_container_add (GTK_CONTAINER (align), zenity_value->forms_widget); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (align), + 1, + 2, + i, + i+1, + GTK_FILL, + GTK_FILL, + 0, + 0); + break; + default: + zenity_value->forms_widget = gtk_entry_new(); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + break; + } + + i++; + } + + gtk_widget_show_all (GTK_WIDGET (dialog)); + + g_object_unref (builder); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + } + + gtk_main(); +} + +static void +zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + ZenityFormsData *forms_data = (ZenityFormsData *) data; + GSList *tmp; + guint day, year, month; + GDate *date = NULL; + gchar time_string[128]; + + switch (response) { + case GTK_RESPONSE_OK: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + for (tmp = forms_data->list; tmp; tmp = tmp->next) { + ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; + switch (zenity_value->type) { + case ZENITY_FORMS_PASSWORD: + case ZENITY_FORMS_ENTRY: + g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); + break; + case ZENITY_FORMS_CALENDAR: + gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, forms_data->date_format, date); + g_print ("%s", time_string); + break; + } + if (tmp->next != NULL) + g_print("%s", forms_data->separator); + } + g_print("\n"); + + break; + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); +} -- cgit From 01bf7956d6bba165326c99ea42f498687119b618 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 18 Nov 2010 14:54:36 -0200 Subject: Fix for bug 630885 --- src/password.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 3d9311ab..2de1a76b 100644 --- a/src/password.c +++ b/src/password.c @@ -155,7 +155,10 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); + if (password_data->username) + g_print("%s|%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_username)), gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); + else + g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); break; case GTK_RESPONSE_CANCEL: -- cgit From e9fcf66cd324e0301224caa4f247c5de296d647c Mon Sep 17 00:00:00 2001 From: Cosimo Cecchi Date: Wed, 22 Dec 2010 18:42:55 +0100 Subject: util: fix build with new GTK+ --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 186a8db4..7072c250 100644 --- a/src/util.c +++ b/src/util.c @@ -389,7 +389,7 @@ zenity_util_make_transient (GdkWindow *window) { Window xterm = transient_get_xterm_toplevel (); if (xterm != None) { - GdkWindow *gdkxterm = gdk_window_foreign_new (xterm); + GdkWindow *gdkxterm = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xterm); if (gdkxterm) { gdk_window_set_transient_for (window, gdkxterm); g_object_unref (G_OBJECT (gdkxterm)); -- cgit From ef3a33a142620fee850351d14f4a1c191fc6e273 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Sun, 2 Jan 2011 22:57:42 -0200 Subject: Fix for bug 540560. Patch by Victor Ananjevsky --- src/progress.c | 2 +- src/tree.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index 4f1f55ef..29814d91 100644 --- a/src/progress.c +++ b/src/progress.c @@ -183,7 +183,7 @@ zenity_progress_handle_stdin (GIOChannel *channel, g_string_free (string, TRUE); } - if (condition != G_IO_IN) { + if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) { /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ GtkWidget *button; diff --git a/src/tree.c b/src/tree.c index 3861e863..7b466674 100644 --- a/src/tree.c +++ b/src/tree.c @@ -180,7 +180,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, g_string_free (string, TRUE); } - if (condition != G_IO_IN) { + if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) { g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } -- cgit From e5467650a641694c82d85cc5d34a5ece28fd51f0 Mon Sep 17 00:00:00 2001 From: muzuiget Date: Thu, 19 Aug 2010 05:40:57 +0800 Subject: Add font and no wrap mode support in text dialog --- src/option.c | 24 ++++++++++++++++++++++-- src/text.c | 8 ++++++++ src/zenity.h | 2 ++ 3 files changed, 32 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index f4813450..2d6d8a4c 100644 --- a/src/option.c +++ b/src/option.c @@ -97,6 +97,7 @@ static gchar *zenity_question_cancel_button; /* Text Dialog Options */ static gboolean zenity_text_active; +static gchar *zenity_text_font; /* Warning Dialog Options */ static gboolean zenity_warning_active; @@ -716,6 +717,15 @@ static GOptionEntry text_options[] = { N_("Allow changes to text"), NULL }, + { + "font", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_text_font, + N_("Set the text font"), + N_("TEXT") + }, { NULL } @@ -972,6 +982,9 @@ zenity_option_free (void) { if (zenity_question_cancel_button) g_free (zenity_question_cancel_button); + if (zenity_text_font) + g_free (zenity_text_font); + if (zenity_colorsel_color) g_free (zenity_colorsel_color); @@ -1163,6 +1176,7 @@ zenity_text_pre_callback (GOptionContext *context, GError **error) { zenity_text_active = FALSE; + zenity_text_font = NULL; return TRUE; } @@ -1544,7 +1558,13 @@ zenity_text_post_callback (GOptionContext *context, if (results->mode == MODE_TEXTINFO) { results->text_data->uri = zenity_general_uri; results->text_data->editable = zenity_general_editable; - } + results->text_data->no_wrap = zenity_general_dialog_no_wrap; + results->text_data->font = zenity_text_font; + } else { + if (zenity_text_font) + zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), + ERROR_SUPPORT); + } return TRUE; } @@ -1895,7 +1915,7 @@ zenity_option_parse (gint argc, gchar **argv) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); if (zenity_general_dialog_no_wrap) - if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) + if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); return results; diff --git a/src/text.c b/src/text.c index eb5f989b..cd31c5f9 100644 --- a/src/text.c +++ b/src/text.c @@ -134,6 +134,14 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) 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->no_wrap) + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(text_view), GTK_WRAP_NONE); + + if (text_data->font) { + PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font); + gtk_widget_modify_font(GTK_TEXT_VIEW(text_view), fontDesc); + } + if (text_data->uri) zenity_util_fill_file_buffer (text_buffer, text_data->uri); else diff --git a/src/zenity.h b/src/zenity.h index 537f5f0c..6414140f 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -104,6 +104,8 @@ typedef struct { typedef struct { gchar *uri; gboolean editable; + gboolean no_wrap; + gchar *font; GtkTextBuffer *buffer; } ZenityTextData; -- cgit From 9c32783a1442f95f77a6a997058baa8c720011c8 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 17 Jan 2011 12:20:21 -0200 Subject: Adding missed files and code for --forms option. --- src/Makefile.am | 1 + src/main.c | 3 ++ src/option.c | 152 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/option.h | 2 + src/zenity.h | 23 ++++++++- src/zenity.ui | 102 +++++++++++++++++++++++++++++++++---- 6 files changed, 271 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index 95f0790f..fb61e5c0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -20,6 +20,7 @@ zenity_SOURCES = \ password.c \ util.c \ util.h \ + forms.c \ zenity.h zenity_CPPFLAGS = \ diff --git a/src/main.c b/src/main.c index 05176158..e667ee1a 100644 --- a/src/main.c +++ b/src/main.c @@ -95,6 +95,9 @@ main (gint argc, gchar **argv) { case MODE_ABOUT: zenity_about (results->data); break; + case MODE_FORMS: + zenity_forms_dialog (results->data, results->forms_data); + break; case MODE_VERSION: g_print ("%s\n", VERSION); break; diff --git a/src/option.c b/src/option.c index 2d6d8a4c..cd812091 100644 --- a/src/option.c +++ b/src/option.c @@ -120,10 +120,20 @@ static gboolean zenity_colorsel_show_palette; static gboolean zenity_password_active; static gboolean zenity_password_show_username; +/* Forms Dialog Options */ +static gboolean zenity_forms_active; +static gchar *zenity_forms_date_format; + /* Miscelaneus Options */ static gboolean zenity_misc_about; static gboolean zenity_misc_version; +static gboolean +zenity_forms_callback (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error); + static GOptionEntry general_options[] = { { "title", @@ -842,6 +852,75 @@ static GOptionEntry scale_options[] = { } }; +static GOptionEntry forms_dialog_options[] = { + { + "forms", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_forms_active, + N_("Display forms dialog"), + NULL + }, + { + "add-entry", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new Entry in forms dialog"), + N_("Field name") + }, + { + "add-password", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new Password Entry in forms dialog"), + N_("Field name") + }, + { + "add-calendar", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new Calendar in forms dialog"), + N_("Calendar field name") + }, + { + "text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_("Set the dialog text"), + N_("TEXT") + }, + { + "separator", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_("Set output separator character"), + N_("SEPARATOR") + }, + { + "date-format", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_forms_date_format, + N_("Set the format for the returned date"), + N_("PATTERN") + }, + { + NULL + } +}; + static GOptionEntry password_dialog_options[] = { { "password", @@ -947,6 +1026,7 @@ zenity_option_init (void) { #endif results->color_data = g_new0 (ZenityColorData, 1); results->password_data = g_new0 (ZenityPasswordData, 1); + results->forms_data = g_new0 (ZenityFormsData, 1); } void @@ -964,6 +1044,9 @@ zenity_option_free (void) { if (zenity_calendar_date_format) g_free (zenity_calendar_date_format); + if (zenity_forms_date_format) + g_free (zenity_forms_date_format); + if (zenity_entry_entry_text) g_free (zenity_entry_entry_text); @@ -1014,6 +1097,27 @@ zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) return NULL; } +/* Forms callback */ +static gboolean +zenity_forms_callback (const gchar *option_name, + const gchar *value, + gpointer data, + GError **error) +{ + ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); + forms_value->option_value = g_strdup(value); + if (g_strcmp0(option_name, "--add-entry") == 0) + forms_value->type = ZENITY_FORMS_ENTRY; + else if (g_strcmp0(option_name, "--add-calendar") == 0) + forms_value->type = ZENITY_FORMS_CALENDAR; + else if (g_strcmp0(option_name, "--add-password") == 0) + forms_value->type = ZENITY_FORMS_PASSWORD; + + results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); + + return TRUE; +} + /* Error callback */ static void zenity_option_error_callback (GOptionContext *context, @@ -1234,6 +1338,17 @@ zenity_password_pre_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_forms_pre_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_forms_active = FALSE; + zenity_forms_date_format = NULL; + return TRUE; +} + static gboolean zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, @@ -1631,6 +1746,30 @@ zenity_color_post_callback (GOptionContext *context, return TRUE; } +static gboolean +zenity_forms_post_callback (GOptionContext *context, + GOptionGroup *group, + gpointer data, + GError **error) +{ + zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); + if (results->mode == MODE_FORMS) { + results->forms_data->dialog_text = zenity_general_dialog_text; + results->forms_data->separator = zenity_general_separator; + if (zenity_forms_date_format) + results->forms_data->date_format = zenity_forms_date_format; + else + results->forms_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); + } else { + if (zenity_forms_date_format) + zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_date_format), + ERROR_SUPPORT); + } + + return TRUE; +} + + static gboolean zenity_password_post_callback (GOptionContext *context, GOptionGroup *group, @@ -1836,6 +1975,17 @@ zenity_create_context (void) g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); g_option_context_add_group(tmp_ctx, a_group); + /* Adds forms dialog option entries */ + a_group = g_option_group_new("forms", + N_("Forms dialog options"), + N_("Show forms dialog options"), NULL, NULL); + g_option_group_add_entries (a_group, forms_dialog_options); + g_option_group_set_parse_hooks (a_group, + zenity_forms_pre_callback, zenity_forms_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group(tmp_ctx, a_group); + /* Adds misc option entries */ a_group = g_option_group_new("misc", N_("Miscellaneous options"), @@ -1899,7 +2049,7 @@ zenity_option_parse (gint argc, gchar **argv) zenity_option_error (zenity_option_get_name (calendar_options, &zenity_general_dialog_text), ERROR_SUPPORT); if (strcmp (zenity_general_separator, "|") != 0) - if (results->mode != MODE_LIST && results->mode != MODE_FILE) + if (results->mode != MODE_LIST && results->mode != MODE_FILE && results->mode != MODE_FORMS) zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT); if (zenity_general_multiple) diff --git a/src/option.h b/src/option.h index ac550b3d..ddca9a99 100644 --- a/src/option.h +++ b/src/option.h @@ -49,6 +49,7 @@ typedef enum { #endif MODE_COLOR, MODE_PASSWORD, + MODE_FORMS, MODE_ABOUT, MODE_VERSION, MODE_LAST @@ -78,6 +79,7 @@ typedef struct { #endif ZenityColorData *color_data; ZenityPasswordData *password_data; + ZenityFormsData *forms_data; } ZenityParsingOptions; void zenity_option_error (gchar *string, diff --git a/src/zenity.h b/src/zenity.h index 6414140f..e5c6f4cd 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -135,6 +135,26 @@ typedef struct { gboolean show_palette; } ZenityColorData; +typedef struct { + GSList *list; + GSList *list_widgets; + gchar *dialog_text; + gchar *separator; + gchar *date_format; +} ZenityFormsData; + +typedef enum { + ZENITY_FORMS_ENTRY, + ZENITY_FORMS_PASSWORD, + ZENITY_FORMS_CALENDAR +} ZenityFormsType; + +typedef struct { + gchar *option_value; + ZenityFormsType type; + GtkWidget *forms_widget; +} ZenityFormsValue; + typedef struct { gboolean username; gchar *password; @@ -169,7 +189,8 @@ void zenity_about (ZenityData *data); void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data); - +void zenity_forms_dialog (ZenityData *data, + ZenityFormsData *forms_data); G_END_DECLS #endif /* ZENITY_H */ diff --git a/src/zenity.ui b/src/zenity.ui index 5275a07c..02556109 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -7,7 +7,6 @@ Calendar selection center dialog - True False @@ -129,7 +128,6 @@ Warning center dialog - True False @@ -213,7 +211,6 @@ Question center dialog - True False @@ -278,7 +275,6 @@ Add a new entry center dialog - True False @@ -377,7 +373,6 @@ 300 200 dialog - True False @@ -455,7 +450,6 @@ Progress center dialog - True False @@ -551,7 +545,6 @@ Error center dialog - True False @@ -643,7 +636,6 @@ 300 196 dialog - True False @@ -744,7 +736,6 @@ Information center dialog - True False @@ -827,7 +818,6 @@ 300 100 dialog - True False @@ -924,4 +914,96 @@ 1 + + 5 + normal + False + + + True + 2 + + + True + 0 + + + True + 12 + 12 + 6 + + + True + 2 + 10 + 6 + + + + + + + + + + + + + True + <b>Forms dialog</b> + True + + + + + 1 + + + + + True + end + + + gtk-cancel + True + True + True + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + + + False + False + 1 + + + + + False + end + 0 + + + + + + cancelbutton12 + okbutton12 + + -- cgit From 55df95a2f737ae89bab9fe82c5e2a9e620761f05 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 25 Jan 2011 18:49:01 -0500 Subject: Reset errors after freeing them This was causing segfaults: https://bugzilla.redhat.com/show_bug.cgi?id=670895 --- src/notification.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 6fe44f1d..41d64e24 100644 --- a/src/notification.c +++ b/src/notification.c @@ -133,6 +133,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, if (error) { g_warning ("Error showing notification: %s", error->message); g_error_free (error); + error = NULL; } g_object_unref (notif); @@ -150,6 +151,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, if (error) { g_warning ("Error showing notification: %s", error->message); g_error_free (error); + error = NULL; } } } else if (!g_ascii_strcasecmp (command, "visible")) { -- cgit From f675707d1c8ed3daafdec61c529b5e4ecffa7c33 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Tue, 15 Feb 2011 21:27:24 +0000 Subject: Do not use deprecated separator GtkDialog property --- src/zenity.ui | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 02556109..5573bbde 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -7,7 +7,6 @@ Calendar selection center dialog - False @@ -128,7 +127,6 @@ Warning center dialog - False @@ -211,7 +209,6 @@ Question center dialog - False @@ -275,7 +272,6 @@ Add a new entry center dialog - False @@ -373,7 +369,6 @@ 300 200 dialog - False @@ -450,7 +445,6 @@ Progress center dialog - False @@ -545,7 +539,6 @@ Error center dialog - False @@ -636,7 +629,6 @@ 300 196 dialog - False @@ -736,7 +728,6 @@ Information center dialog - False @@ -818,7 +809,6 @@ 300 100 dialog - False @@ -917,7 +907,6 @@ 5 normal - False True -- cgit From 9744aaab18403e80e2d381326b4dc33132293ae2 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Tue, 15 Feb 2011 21:34:31 +0000 Subject: text.c: Fix compilation warning --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index cd31c5f9..b8bf42eb 100644 --- a/src/text.c +++ b/src/text.c @@ -139,7 +139,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->font) { PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font); - gtk_widget_modify_font(GTK_TEXT_VIEW(text_view), fontDesc); + gtk_widget_modify_font (GTK_WIDGET(text_view), fontDesc); } if (text_data->uri) -- cgit From dc0c483b915c2185399fac3dd4d56466c0026fb0 Mon Sep 17 00:00:00 2001 From: Luca Ferretti Date: Thu, 17 Mar 2011 12:02:20 +0100 Subject: Use proper case in forms dialog option values --- src/option.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index cd812091..5e3032e4 100644 --- a/src/option.c +++ b/src/option.c @@ -869,7 +869,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Entry in forms dialog"), - N_("Field name") + N_("FIELDNAME") }, { "add-password", @@ -878,7 +878,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Password Entry in forms dialog"), - N_("Field name") + N_("FIELDNAME") }, { "add-calendar", @@ -887,7 +887,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Calendar in forms dialog"), - N_("Calendar field name") + N_("CALENDARNAME") }, { "text", -- cgit From 40cae89ace1678b7b4c77276e20ce756b1263648 Mon Sep 17 00:00:00 2001 From: Luca Ferretti Date: Thu, 17 Mar 2011 12:56:28 +0100 Subject: Revert mistakely pushed string change --- src/option.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 5e3032e4..cd812091 100644 --- a/src/option.c +++ b/src/option.c @@ -869,7 +869,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Entry in forms dialog"), - N_("FIELDNAME") + N_("Field name") }, { "add-password", @@ -878,7 +878,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Password Entry in forms dialog"), - N_("FIELDNAME") + N_("Field name") }, { "add-calendar", @@ -887,7 +887,7 @@ static GOptionEntry forms_dialog_options[] = { G_OPTION_ARG_CALLBACK, zenity_forms_callback, N_("Add a new Calendar in forms dialog"), - N_("CALENDARNAME") + N_("Calendar field name") }, { "text", -- cgit From 2fa457ed44afa5f4bbb35e3f3731ac11e64c0b7a Mon Sep 17 00:00:00 2001 From: Nirbheek Chauhan Date: Thu, 2 Jun 2011 22:42:33 +0530 Subject: Fix bug 651723, don't look for libnotify.h if not requested --- src/notification.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 41d64e24..3f4c454e 100644 --- a/src/notification.c +++ b/src/notification.c @@ -29,12 +29,12 @@ #include #include #include +#ifdef HAVE_LIBNOTIFY #include #include "zenity.h" #include "util.h" -#ifdef HAVE_LIBNOTIFY static char *icon_file; static void -- cgit From b39ad33c35bb93c647e7f6f05d1310a0ce6895d5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 16 Jun 2011 11:07:58 -0300 Subject: Bug 651948 - zenity list does not return default value when timeout is over --- src/calendar.c | 2 +- src/color.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/forms.c | 2 +- src/msg.c | 2 +- src/password.c | 2 +- src/progress.c | 2 +- src/scale.c | 2 +- src/text.c | 2 +- src/tree.c | 2 +- src/util.c | 11 +- src/util.h | 2 +- src/zenity.ui | 1066 ++++++++++++++++++++++++++++----------------------- 14 files changed, 615 insertions(+), 486 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 9aaee9f2..60931c49 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -85,7 +85,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } g_object_unref (builder); diff --git a/src/color.c b/src/color.c index 8f31937f..eee68ee7 100644 --- a/src/color.c +++ b/src/color.c @@ -64,7 +64,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, - NULL); + dialog); } gtk_main(); diff --git a/src/entry.c b/src/entry.c index d69d918a..ce6cda50 100644 --- a/src/entry.c +++ b/src/entry.c @@ -129,7 +129,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); diff --git a/src/fileselection.c b/src/fileselection.c index 026bb310..07d85c0d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); diff --git a/src/forms.c b/src/forms.c index 9ad78deb..d6db7787 100644 --- a/src/forms.c +++ b/src/forms.c @@ -164,7 +164,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) g_object_unref (builder); if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main(); diff --git a/src/msg.c b/src/msg.c index 1a92875b..567ee23d 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } g_object_unref (builder); diff --git a/src/password.c b/src/password.c index 2de1a76b..219f5f9c 100644 --- a/src/password.c +++ b/src/password.c @@ -143,7 +143,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, (GSourceFunc) zenity_util_timeout_handle, - NULL); + dialog); } gtk_main(); } diff --git a/src/progress.c b/src/progress.c index 29814d91..2533aa1c 100644 --- a/src/progress.c +++ b/src/progress.c @@ -286,7 +286,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) zenity_progress_read_info (progress_data); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); diff --git a/src/scale.c b/src/scale.c index c0d25d12..d6cc340b 100644 --- a/src/scale.c +++ b/src/scale.c @@ -92,7 +92,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } g_object_unref (builder); diff --git a/src/text.c b/src/text.c index b8bf42eb..147e7066 100644 --- a/src/text.c +++ b/src/text.c @@ -160,7 +160,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) g_object_unref (builder); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); diff --git a/src/tree.c b/src/tree.c index 7b466674..c7477c36 100644 --- a/src/tree.c +++ b/src/tree.c @@ -499,7 +499,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } gtk_main (); diff --git a/src/util.c b/src/util.c index 7072c250..37845a0b 100644 --- a/src/util.c +++ b/src/util.c @@ -411,9 +411,14 @@ zenity_util_show_dialog (GtkWidget *dialog) } gboolean -zenity_util_timeout_handle (void) +zenity_util_timeout_handle (gpointer data) { - gtk_main_quit(); - exit(ZENITY_TIMEOUT); + GtkDialog *dialog = GTK_DIALOG(data); + if(dialog != NULL) + gtk_dialog_response(dialog, GTK_RESPONSE_OK); + else { + gtk_main_quit(); + exit(ZENITY_TIMEOUT); + } return FALSE; } diff --git a/src/util.h b/src/util.h index 2bf154ec..7005441b 100644 --- a/src/util.h +++ b/src/util.h @@ -28,7 +28,7 @@ void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_show_dialog (GtkWidget *widget); -gboolean zenity_util_timeout_handle (void); +gboolean zenity_util_timeout_handle (gpointer data); G_END_DECLS diff --git a/src/zenity.ui b/src/zenity.ui index 5573bbde..3187d0ba 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,29 +1,85 @@ - + - + + 100 + 1 + 1 + + + False 5 Calendar selection center dialog - + - + True + False 2 + + + True + False + end + + + gtk-cancel + True + True + True + False + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + False + False + True + + + False + False + 1 + + + + + False + True + end + 0 + + True + False 5 6 True + False 6 True + False 0 Select a date from below. True @@ -37,12 +93,15 @@ + True + True 0 True + False 0 C_alendar: True @@ -70,20 +129,43 @@ + False + True 1 + + + + zenity_calendar_cancel_button + zenity_calendar_ok_button + + + + False + 5 + Add a new entry + center + dialog + + + + True + False + 2 - + True + False end - + gtk-cancel True True True False + False True @@ -93,13 +175,14 @@ - + gtk-ok True True - True True + True False + False True @@ -111,78 +194,85 @@ False + True end 0 - - - - zenity_calendar_cancel_button - zenity_calendar_ok_button - - - - 5 - Warning - center - dialog - - - - True - 14 - + True - 5 - 12 + False + 6 - + True - 0 - 0 - gtk-dialog-warning - 6 + False + 6 + + + True + False + 0 + _Enter new text: + True + True + + + False + False + 0 + + + + + False + True 0 - - - True - True - 0 - Are you sure you want to proceed? - True - True - True - - - False - False - 1 - - + False + True 1 + + + + zenity_entry_cancel_button + zenity_entry_ok_button + + + + False + 5 + Error + center + dialog + + + + True + False + 14 - + True + False end - + gtk-ok True True - True True False + False True @@ -194,53 +284,109 @@ False + True end 0 + + + True + False + 6 + + + True + False + 5 + 12 + + + True + False + 0 + gtk-dialog-error + 6 + + + True + True + 0 + + + + + True + True + 0 + An error has occurred. + True + True + True + + + False + False + 1 + + + + + True + True + 0 + + + + + False + True + 1 + + - zenity_warning_ok_button + zenity_error_ok_button - + + False 5 - Question - center - dialog - + normal - + True - 14 - - + False + 2 + + True - 5 - 12 + False + end - + + gtk-cancel True - 0 - 0 - gtk-dialog-question - 6 + True + True + False + True False + False 0 - + + gtk-ok True True - 0 - Are you sure you want to proceed? - True - True - True + True + False + True False @@ -249,81 +395,89 @@ - - 1 - - - - - True - end - False + True end 0 - - - - - 5 - Add a new entry - center - dialog - - - - True - 2 - + True - 6 + False + 0 - + True - 6 + False + 12 + 12 + 6 - + True - 0 - _Enter new text: - True - True + False + 2 + 10 + 6 + + + + + + - - False - False - 0 - - - - - - False - 0 - + + + + True + False + <b>Forms dialog</b> + True + + False + True 1 + + + + cancelbutton12 + okbutton12 + + + + False + 5 + Information + center + dialog + + + + True + False + 14 - + True + False end - - gtk-cancel + + gtk-ok True True True False + False True @@ -332,15 +486,43 @@ 0 + + + False + True + end + 0 + + + + + True + False + 5 + 12 + + + True + False + 0 + gtk-dialog-info + 6 + + + True + True + 0 + + - - gtk-ok + True True - True - True - False - True + 0 + All updates are complete. + True + True + True False @@ -351,127 +533,176 @@ False - end - 0 + True + 1 - zenity_entry_cancel_button - zenity_entry_ok_button + zenity_info_ok_button - + + False 5 - Text View + Progress center - 300 - 200 dialog - + - + True + False 2 - - + + True - 5 + False + end - + + gtk-cancel True True - automatic - automatic - etched-in - - - True - True - 2 - 2 - False - word - 2 - 2 - textbuffer1 - - + True + False + False + True + False + False 0 - - - 1 - - - - - True - end - - gtk-close + + gtk-ok True + False True + True True False + False True False False - 0 + 1 False + True end 0 + + + True + False + 5 + 6 + + + True + False + 0 + Running... + True + + + False + False + 0 + + + + + True + False + 0.10000000149 + + + False + False + 1 + + + + + False + True + 1 + + - zenity_text_close_button + zenity_progress_cancel_button + zenity_progress_ok_button - + + False 5 - Progress + Question center dialog - + - + True - 2 + False + 14 + + + True + False + end + + + False + True + end + 0 + + - + True + False 5 - 6 + 12 - + True + False 0 - Running... - True + 0 + gtk-dialog-question + 6 False - False + True 0 - + True - 0.10000000149 + True + 0 + Are you sure you want to proceed? + True + True + True False @@ -481,20 +712,40 @@ + False + True 1 + + + + + True + False + 5 + Adjust the scale value + 300 + 100 + dialog + + + + True + False - + True + False end - + gtk-cancel True True True False + False True @@ -504,14 +755,13 @@ - + gtk-ok True - False True - True True False + False True @@ -523,127 +773,88 @@ False + True end 0 - - - - zenity_progress_cancel_button - zenity_progress_ok_button - - - - 5 - Error - center - dialog - - - - True - 14 - + True - 6 + False + 5 + 6 - + True - 5 - 12 - - - True - 0 - gtk-dialog-error - 6 - - - 0 - - - - - True - True - 0 - An error has occurred. - True - True - True - - - False - False - 1 - - + False + 0 + 4 + Adjust the scale value + True + False + False 0 - - - 1 - - - - - True - end - - gtk-ok + True True - True - False - True + adjustment1 + 0 + right - False - False - 0 + True + True + 1 False - end - 0 + True + 1 - zenity_error_ok_button + cancelbutton1 + okbutton1 - + + False 5 - Select items from the list + Text View center 300 - 196 + 200 dialog - + - + True - - + False + 2 + + True - 5 - 6 + False + end - + + gtk-close True - 0 - Select items from the list below. - True + True + True + False + False + True False @@ -651,33 +862,74 @@ 0 + + + False + True + end + 0 + + + + + True + False + 5 - + True True - automatic - automatic - in + etched-in - + True True - True + 2 + 2 + False + word + 2 + 2 + textbuffer1 - 1 + True + True + 0 + True + True 1 + + + + zenity_text_close_button + + + + False + 5 + Select items from the list + center + 300 + 196 + dialog + + + + True + False - + True + False end @@ -686,6 +938,7 @@ True True False + False True @@ -701,6 +954,7 @@ True True False + False True @@ -712,268 +966,139 @@ False + True end 0 - - - - zenity_tree_cancel_button - zenity_tree_ok_button - - - - 5 - Information - center - dialog - - - - True - 14 - + True + False 5 - 12 - - - True - 0 - gtk-dialog-info - 6 - - - 0 - - + 6 - + True - True - 0 - All updates are complete. + False + 0 + Select items from the list below. True - True - True False False - 1 + 0 - - - 1 - - - - - True - end - - gtk-ok + True True - True - False - True + in + + + True + True + True + + + + + - False - False - 0 + True + True + 1 False - end - 0 + True + 1 - zenity_info_ok_button + zenity_tree_cancel_button + zenity_tree_ok_button - - True + + False 5 - Adjust the scale value - 300 - 100 + Warning + center dialog - + - + True - - - True - 5 - 6 - - - True - 0 - 4 - Adjust the scale value - True - - - False - False - 0 - - - - - True - True - discontinuous - adjustment1 - 0 - right - - - 1 - - - - - 1 - - + False + 14 - + True + False end - - gtk-cancel - True - True - True - False - True - - - False - False - 0 - - - - + gtk-ok True True + True True False + False True False False - 1 + 0 False + True end 0 - - - - cancelbutton1 - okbutton1 - - - - 100 - 1 - 1 - - - - 5 - normal - - - True - 2 - - True - 0 - - - True - 12 - 12 - 6 - - - True - 2 - 10 - 6 - - - - - - - - - - - - - True - <b>Forms dialog</b> - True - - - - - 1 - - - - + True - end + False + 5 + 12 - - gtk-cancel + True - True - True - True + False + 0 + 0 + gtk-dialog-warning + 6 False - False + True 0 - - gtk-ok + True True - True - True + 0 + Are you sure you want to proceed? + True + True + True False @@ -984,15 +1109,14 @@ False - end - 0 + True + 1 - cancelbutton12 - okbutton12 + zenity_warning_ok_button -- cgit From f77a0199af3a3d1362be95ab651186546492e8cd Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 16 Jun 2011 14:45:52 -0300 Subject: Fix the msg forms (question, warning, error) to return 5 when timeout --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 567ee23d..1a92875b 100644 --- a/src/msg.c +++ b/src/msg.c @@ -138,7 +138,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_util_show_dialog (dialog); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } g_object_unref (builder); -- cgit From d60e5eeeb379e5444ad218d7335b17eaa821b182 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 17 Jun 2011 10:47:07 -0300 Subject: Now if you use --timeout option, the return code will be properly handled The default behavior will be done (ie. user click on ok button) The return code will be 5 --- src/calendar.c | 3 +-- src/color.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/forms.c | 2 +- src/msg.c | 2 +- src/password.c | 2 +- src/progress.c | 2 +- src/scale.c | 2 +- src/text.c | 2 +- src/tree.c | 2 +- src/util.c | 19 ++++++++++++++++++- src/util.h | 2 ++ 13 files changed, 31 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 60931c49..32825da9 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -112,8 +112,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) if (date != NULL) g_date_free (date); - - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); break; case GTK_RESPONSE_CANCEL: diff --git a/src/color.c b/src/color.c index eee68ee7..ca8debde 100644 --- a/src/color.c +++ b/src/color.c @@ -78,7 +78,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); g_print ("%s\n", gdk_color_to_string (&color)); diff --git a/src/entry.c b/src/entry.c index ce6cda50..d8111c04 100644 --- a/src/entry.c +++ b/src/entry.c @@ -143,7 +143,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); if (n_entries > 1) { text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); } diff --git a/src/fileselection.c b/src/fileselection.c index 07d85c0d..349ff32d 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -150,7 +150,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); for (iter = selections;iter != NULL; iter = iter->next) { g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); diff --git a/src/forms.c b/src/forms.c index d6db7787..d59a5afb 100644 --- a/src/forms.c +++ b/src/forms.c @@ -181,7 +181,7 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); for (tmp = forms_data->list; tmp; tmp = tmp->next) { ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; switch (zenity_value->type) { diff --git a/src/msg.c b/src/msg.c index 1a92875b..1f060c5a 100644 --- a/src/msg.c +++ b/src/msg.c @@ -153,7 +153,7 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); break; case GTK_RESPONSE_CANCEL: diff --git a/src/password.c b/src/password.c index 219f5f9c..c49b6752 100644 --- a/src/password.c +++ b/src/password.c @@ -154,7 +154,7 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) ZenityPasswordData *password_data = (ZenityPasswordData *) data; switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); if (password_data->username) g_print("%s|%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_username)), gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); else diff --git a/src/progress.c b/src/progress.c index 2533aa1c..6dc93f87 100644 --- a/src/progress.c +++ b/src/progress.c @@ -297,7 +297,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) { switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); break; case GTK_RESPONSE_CANCEL: diff --git a/src/scale.c b/src/scale.c index d6cc340b..87bf55ae 100644 --- a/src/scale.c +++ b/src/scale.c @@ -113,7 +113,7 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_OK: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); break; diff --git a/src/text.c b/src/text.c index 147e7066..98686750 100644 --- a/src/text.c +++ b/src/text.c @@ -187,7 +187,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) default: /* Esc dialog */ - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); break; } gtk_main_quit (); diff --git a/src/tree.c b/src/tree.c index c7477c36..b0ff4c5f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -613,7 +613,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) GTK_TREE_VIEW (tree_view)); } zenity_tree_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); break; case GTK_RESPONSE_CANCEL: diff --git a/src/util.c b/src/util.c index 37845a0b..440c7de9 100644 --- a/src/util.c +++ b/src/util.c @@ -304,7 +304,15 @@ zenity_util_return_exit_code ( ZenityExitCode value ) if (! env_var) retval = ZENITY_ERROR_DEFAULT; break; - + + case ZENITY_TIMEOUT: + env_var = g_getenv("ZENITY_TIMEOUT"); + if (! env_var) + env_var = g_getenv("DIALOG_TIMEOUT"); + if (! env_var) + retval = ZENITY_TIMEOUT; + break; + default: retval = 1; } @@ -314,6 +322,15 @@ zenity_util_return_exit_code ( ZenityExitCode value ) return retval; } +void +zenity_util_exit_code_with_data(ZenityExitCode value, ZenityData *zen_data) +{ + /* We assume it's being called with --timeout option and should return 5) */ + if(zen_data->timeout_delay > 0) + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + else + zen_data->exit_code = zenity_util_return_exit_code (value); +} #ifdef GDK_WINDOWING_X11 diff --git a/src/util.h b/src/util.h index 7005441b..48409c11 100644 --- a/src/util.h +++ b/src/util.h @@ -26,6 +26,8 @@ GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, const gchar *filename); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); +void zenity_util_exit_code_with_data (ZenityExitCode value, + ZenityData *data); void zenity_util_show_dialog (GtkWidget *widget); gboolean zenity_util_timeout_handle (gpointer data); -- cgit From 5872558feef3727e3ff1bb2bf395dfc6bd896f74 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 28 Jun 2011 17:09:04 -0300 Subject: This change add a new functionality to text-info: * Added a cancel button returning 1 if clicked * Renamed the Close button to Ok, still returning 0 if clicked * Added --ok-label=TEXT option to change the Ok button label * Added --cancel-label=TEXT option to change the Cancel button label * Added --checkbox=TEXT option to show an "I Agree and accept the terms" checkbox If --checkbox is enabled, the Ok button will be disabled if the checkbox isn't checked. --- src/option.c | 72 +++++++++++++++++++++++++++++++++++++++++++++-------------- src/text.c | 34 ++++++++++++++++++++++++++-- src/zenity.h | 3 +++ src/zenity.ui | 37 +++++++++++++++++++++++++++--- 4 files changed, 124 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index cd812091..954ba648 100644 --- a/src/option.c +++ b/src/option.c @@ -41,6 +41,8 @@ static gboolean zenity_general_editable; static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; static gint zenity_general_timeout_delay; +static gchar *zenity_general_ok_button; +static gchar *zenity_general_cancel_button; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -92,12 +94,11 @@ static gboolean zenity_progress_no_cancel; /* Question Dialog Options */ static gboolean zenity_question_active; -static gchar *zenity_question_ok_button; -static gchar *zenity_question_cancel_button; /* Text Dialog Options */ static gboolean zenity_text_active; static gchar *zenity_text_font; +static gchar *zenity_text_checkbox; /* Warning Dialog Options */ static gboolean zenity_warning_active; @@ -672,7 +673,7 @@ static GOptionEntry question_options[] = { '\0', G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, - &zenity_question_ok_button, + &zenity_general_ok_button, N_("Sets the label of the Ok button"), N_("TEXT") }, @@ -681,7 +682,7 @@ static GOptionEntry question_options[] = { '\0', G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, - &zenity_question_cancel_button, + &zenity_general_cancel_button, N_("Sets the label of the Cancel button"), N_("TEXT") }, @@ -736,6 +737,33 @@ static GOptionEntry text_options[] = { N_("Set the text font"), N_("TEXT") }, + { + "ok-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_ok_button, + N_("Sets the label of the Ok button"), + N_("TEXT") + }, + { + "cancel-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_cancel_button, + N_("Sets the label of the Cancel button"), + N_("TEXT") + }, + { + "checkbox", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_text_checkbox, + N_("Enable a I read and agree checkbox"), + N_("TEXT") + }, { NULL } @@ -1040,6 +1068,10 @@ zenity_option_free (void) { if (zenity_general_uri) g_free (zenity_general_uri); g_free (zenity_general_separator); + if (zenity_general_ok_button) + g_free (zenity_general_ok_button); + if (zenity_general_cancel_button) + g_free (zenity_general_cancel_button); if (zenity_calendar_date_format) g_free (zenity_calendar_date_format); @@ -1060,13 +1092,10 @@ zenity_option_free (void) { if (zenity_list_hide_column) g_free (zenity_list_hide_column); - if (zenity_question_ok_button) - g_free (zenity_question_ok_button); - if (zenity_question_cancel_button) - g_free (zenity_question_cancel_button); - if (zenity_text_font) g_free (zenity_text_font); + if (zenity_text_checkbox) + g_free (zenity_text_checkbox); if (zenity_colorsel_color) g_free (zenity_colorsel_color); @@ -1145,6 +1174,8 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_multiple = FALSE; zenity_general_editable = FALSE; zenity_general_uri = NULL; + zenity_general_ok_button = NULL; + zenity_general_cancel_button = NULL; zenity_general_dialog_no_wrap = FALSE; zenity_general_timeout_delay = -1; @@ -1281,7 +1312,7 @@ zenity_text_pre_callback (GOptionContext *context, { zenity_text_active = FALSE; zenity_text_font = NULL; - + zenity_text_checkbox = NULL; return TRUE; } @@ -1610,7 +1641,6 @@ zenity_progress_post_callback (GOptionContext *context, GError **error) { zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS); - if (results->mode == MODE_PROGRESS) { results->progress_data->dialog_text = zenity_general_dialog_text; results->progress_data->pulsate = zenity_progress_pulsate; @@ -1649,14 +1679,12 @@ zenity_question_post_callback (GOptionContext *context, GError **error) { zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION); - - if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; - results->msg_data->ok_label = zenity_question_ok_button; - results->msg_data->cancel_label = zenity_question_cancel_button; + results->msg_data->ok_label = zenity_general_ok_button; + results->msg_data->cancel_label = zenity_general_cancel_button; } return TRUE; @@ -1675,12 +1703,14 @@ zenity_text_post_callback (GOptionContext *context, results->text_data->editable = zenity_general_editable; results->text_data->no_wrap = zenity_general_dialog_no_wrap; results->text_data->font = zenity_text_font; + results->text_data->ok_label = zenity_general_ok_button; + results->text_data->cancel_label = zenity_general_cancel_button; + results->text_data->checkbox = zenity_text_checkbox; } else { - if (zenity_text_font) + if (zenity_text_font) zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), ERROR_SUPPORT); } - return TRUE; } @@ -2063,7 +2093,15 @@ zenity_option_parse (gint argc, gchar **argv) if (zenity_general_uri) if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); + + if (zenity_general_ok_button) + if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO) + zenity_option_error (zenity_option_get_name (text_options, &zenity_general_ok_button), ERROR_SUPPORT); + if (zenity_general_cancel_button) + if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO) + zenity_option_error (zenity_option_get_name (text_options, &zenity_general_cancel_button), ERROR_SUPPORT); + if (zenity_general_dialog_no_wrap) if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); diff --git a/src/text.c b/src/text.c index 98686750..fabc860a 100644 --- a/src/text.c +++ b/src/text.c @@ -29,6 +29,7 @@ static ZenityTextData *zen_text_data; static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data); static gboolean zenity_text_handle_stdin (GIOChannel *channel, @@ -103,6 +104,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *ok_button; + GtkWidget *checkbox; + GtkWidget *cancel_button; + GObject *text_view; GtkTextBuffer *text_buffer; @@ -118,7 +123,11 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_builder_connect_signals (builder, NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog")); - + + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_close_button")); + cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_cancel_button")); + checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_checkbox")); + g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_text_dialog_response), data); @@ -150,6 +159,21 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->editable) zen_text_data->buffer = text_buffer; + if (text_data->ok_label) + gtk_button_set_label (GTK_BUTTON(ok_button), text_data->ok_label); + + if (text_data->cancel_label) + gtk_button_set_label (GTK_BUTTON(cancel_button), text_data->cancel_label); + + if (text_data->checkbox) { + gtk_widget_set_visible (GTK_WIDGET(checkbox), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET(ok_button), FALSE); + gtk_button_set_label (GTK_BUTTON(checkbox), text_data->checkbox); + + g_signal_connect (G_OBJECT (checkbox), "toggled", + G_CALLBACK (zenity_text_toggle_button), ok_button); + } + if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); else @@ -166,6 +190,13 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_main (); } +static void +zenity_text_toggle_button (GtkToggleButton *button, gpointer data) +{ + GtkWidget *ok_button = (GtkWidget *)data; + gtk_widget_set_sensitive (GTK_WIDGET(ok_button), gtk_toggle_button_get_active(button)); +} + static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -176,7 +207,6 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) if (zen_text_data->editable) { GtkTextIter start, end; gchar *text; - gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); g_print ("%s", text); diff --git a/src/zenity.h b/src/zenity.h index e5c6f4cd..fd744b67 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -107,6 +107,9 @@ typedef struct { gboolean no_wrap; gchar *font; GtkTextBuffer *buffer; + gchar *ok_label; + gchar *cancel_label; + gchar *checkbox; } ZenityTextData; typedef struct { diff --git a/src/zenity.ui b/src/zenity.ui index 3187d0ba..07aa51a2 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -847,11 +847,10 @@ False end - - gtk-close + + gtk-cancel True True - True False False True @@ -862,6 +861,23 @@ 0 + + + gtk-ok + True + True + True + True + False + True + right + + + False + False + 1 + + False @@ -900,6 +916,20 @@ 0 + + + True + False + False + 0 + True + + + False + False + 1 + + True @@ -910,6 +940,7 @@ + zenity_text_cancel_button zenity_text_close_button -- cgit From d8954d9222654f645ebdcc1752c70be97faaae45 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 6 Jul 2011 14:55:30 -0300 Subject: Patch for bug #621907 This patch add the option --no-markup in the info, warning, error and question dialogs So if the user wants to use & \ ' and other symbols, now he can, and no error will be showed. --- src/msg.c | 5 ++++- src/option.c | 42 ++++++++++++++++++++++++++++++++++++++++-- src/zenity.h | 1 + 3 files changed, 45 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 1f060c5a..b5a1aa01 100644 --- a/src/msg.c +++ b/src/msg.c @@ -131,7 +131,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - + + if (msg_data->no_markup) + gtk_label_set_use_markup (GTK_LABEL (text), FALSE); + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); diff --git a/src/option.c b/src/option.c index 954ba648..079bd02e 100644 --- a/src/option.c +++ b/src/option.c @@ -40,6 +40,7 @@ static gboolean zenity_general_multiple; static gboolean zenity_general_editable; static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; +static gboolean zenity_general_dialog_no_markup; static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; @@ -318,6 +319,14 @@ static GOptionEntry error_options[] = { N_("Do not enable text wrapping"), NULL }, + { + "no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_("Do not enable pango markup") + }, { NULL } @@ -351,6 +360,14 @@ static GOptionEntry info_options[] = { N_("Do not enable text wrapping"), NULL }, + { + "no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_("Do not enable pango markup") + }, { NULL } @@ -695,6 +712,14 @@ static GOptionEntry question_options[] = { N_("Do not enable text wrapping"), NULL }, + { + "no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_("Do not enable pango markup") + }, { NULL } @@ -797,6 +822,14 @@ static GOptionEntry warning_options[] = { N_("Do not enable text wrapping"), NULL }, + { + "no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_("Do not enable pango markup") + }, { NULL } @@ -1177,6 +1210,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_ok_button = NULL; zenity_general_cancel_button = NULL; zenity_general_dialog_no_wrap = FALSE; + zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; return TRUE; @@ -1498,6 +1532,7 @@ zenity_error_post_callback (GOptionContext *context, results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_ERROR; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; } return TRUE; @@ -1514,7 +1549,8 @@ zenity_info_post_callback (GOptionContext *context, if (results->mode == MODE_INFO) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_INFO; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; } return TRUE; @@ -1683,6 +1719,7 @@ zenity_question_post_callback (GOptionContext *context, results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; results->msg_data->ok_label = zenity_general_ok_button; results->msg_data->cancel_label = zenity_general_cancel_button; } @@ -1725,7 +1762,8 @@ zenity_warning_post_callback (GOptionContext *context, if (results->mode == MODE_WARNING) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->mode = ZENITY_MSG_WARNING; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; } return TRUE; diff --git a/src/zenity.h b/src/zenity.h index fd744b67..22ffca71 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -60,6 +60,7 @@ typedef struct { gchar *dialog_text; MsgMode mode; gboolean no_wrap; + gboolean no_markup; gchar *ok_label; gchar *cancel_label; } ZenityMsgData; -- cgit From 3f5c1667926bbd8071be69727d3688ef73b10164 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 6 Jul 2011 15:09:38 -0300 Subject: Forgot change one option in gtk_label --- src/msg.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index b5a1aa01..5df884ff 100644 --- a/src/msg.c +++ b/src/msg.c @@ -129,11 +129,12 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (msg_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - - if (msg_data->no_markup) - gtk_label_set_use_markup (GTK_LABEL (text), FALSE); + if (msg_data->dialog_text) { + if (msg_data->no_markup) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + else + gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + } if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); -- cgit From 9ab8380ff217cf6162ef4be7a473bb7a34b4d104 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 8 Jul 2011 11:57:18 -0300 Subject: Fix for bug #540489 and #501001 both related to 100% use of cpu. --- src/tree.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index b0ff4c5f..cdc1599c 100644 --- a/src/tree.c +++ b/src/tree.c @@ -130,6 +130,9 @@ zenity_tree_handle_stdin (GIOChannel *channel, while (gtk_events_pending ()) gtk_main_iteration (); + // TODO: Find a better way to avoid 100% cpu utilization + g_usleep(10000); + } while (status == G_IO_STATUS_AGAIN); if (status != G_IO_STATUS_NORMAL) { -- cgit From 1d339e29a782de8962379652635c9ee42988d99c Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 19 Jul 2011 14:33:28 -0300 Subject: Enable html support in --text-info option. This fix bug #598655, thanks for the work from Francis Meyvis francis.meyvis at gmail dot com. Two new options in --text-info: * --html - enable HTML support. * --url - load an url If you need to load a local html file, you can use --filename=patch/to/html. Examples: * zenity --text-info --html --filename=file.html * zenity --text-info --html --url=www.gnome.org Zenity will add http:// if isn't declared in --url --- src/Makefile.am | 4 +- src/option.c | 34 +++++++++++++- src/text.c | 138 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 4 ++ src/zenity.ui | 2 +- 5 files changed, 179 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index fb61e5c0..f6e9e981 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -32,6 +32,7 @@ zenity_CPPFLAGS = \ zenity_CFLAGS = \ $(ZENITY_CFLAGS) \ $(LIBNOTIFY_CFLAGS) \ + $(WEBKIT_CFLAGS) \ $(WARN_CFLAGS) \ $(AM_CFLAGS) @@ -40,7 +41,8 @@ zenity_LDFLAGS = \ zenity_LDADD = \ $(ZENITY_LIBS) \ - $(LIBNOTIFY_LIBS) + $(LIBNOTIFY_LIBS) \ + $(WEBKIT_LIBS) uidir = $(datadir)/zenity diff --git a/src/option.c b/src/option.c index 079bd02e..e5f79b9e 100644 --- a/src/option.c +++ b/src/option.c @@ -100,6 +100,10 @@ static gboolean zenity_question_active; static gboolean zenity_text_active; static gchar *zenity_text_font; static gchar *zenity_text_checkbox; +#ifdef HAVE_WEBKITGTK +static gboolean zenity_text_enable_html; +static gchar *zenity_text_url; +#endif /* Warning Dialog Options */ static gboolean zenity_warning_active; @@ -786,9 +790,29 @@ static GOptionEntry text_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_text_checkbox, - N_("Enable a I read and agree checkbox"), + N_("Enable an I read and agree checkbox"), N_("TEXT") }, +#ifdef HAVE_WEBKITGTK + { + "html", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_enable_html, + N_("Enable html support"), + NULL + }, + { + "url", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_text_url, + N_("Sets an url instead of a file. Only works if you use --html option"), + N_("URL") + }, +#endif { NULL } @@ -1347,6 +1371,10 @@ zenity_text_pre_callback (GOptionContext *context, zenity_text_active = FALSE; zenity_text_font = NULL; zenity_text_checkbox = NULL; +#ifdef HAVE_WEBKITGTK + zenity_text_enable_html = FALSE; + zenity_text_url = NULL; +#endif return TRUE; } @@ -1743,6 +1771,10 @@ zenity_text_post_callback (GOptionContext *context, results->text_data->ok_label = zenity_general_ok_button; results->text_data->cancel_label = zenity_general_cancel_button; results->text_data->checkbox = zenity_text_checkbox; +#ifdef HAVE_WEBKITGTK + results->text_data->html = zenity_text_enable_html; + results->text_data->url = zenity_text_url; +#endif } else { if (zenity_text_font) zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), diff --git a/src/text.c b/src/text.c index fabc860a..e786884e 100644 --- a/src/text.c +++ b/src/text.c @@ -26,11 +26,108 @@ #include "zenity.h" #include "util.h" +#ifdef HAVE_WEBKITGTK +#include +#endif + static ZenityTextData *zen_text_data; static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data); static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data); +#ifdef HAVE_WEBKITGTK +static void +zenity_configure_webkit (WebKitWebView *web_view) +{ + WebKitWebSettings *settings; + settings = webkit_web_view_get_settings(web_view); + g_object_set(G_OBJECT(settings), "enable-scripts", FALSE, NULL); + g_object_set(G_OBJECT(settings), "auto-load-images", TRUE, NULL); + g_object_set(G_OBJECT(settings), "auto-resize-window", TRUE, NULL); + g_object_set(G_OBJECT(settings), "auto-shrink-images", TRUE, NULL); + /* + Stick to the defaults + "cursive-font-family" gchar* : Read / Write / Construct + "default-encoding" gchar* : Read / Write / Construct + "default-font-family" gchar* : Read / Write / Construct + "default-font-size" gint : Read / Write / Construct + "default-monospace-font-size" gint : Read / Write / Construct + "editing-behavior" WebKitEditingBehavior : Read / Write / Construct + */ + g_object_set(G_OBJECT(settings), "enable-caret-browsing", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-default-context-menu", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL); + /* unexisting property? g_object_set(G_OBJECT(settings), "enable-dns-prefetching", FALSE, NULL);*/ + g_object_set(G_OBJECT(settings), "enable-dom-paste", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", FALSE, NULL); + /* unexisting property? g_object_set(G_OBJECT(settings), "enable-frame-flattening", FALSE, NULL);*/ + /* unexisting property? g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL);*/ + g_object_set(G_OBJECT(settings), "enable-html5-database", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-html5-local-storage", FALSE, NULL); + /* unexisting property? g_object_set(G_OBJECT(settings), "enable-hyperlink-auditing", FALSE, NULL);*/ + g_object_set(G_OBJECT(settings), "enable-java-applet", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-offline-web-application-cache", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-page-cache", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-private-browsing", TRUE, NULL); + g_object_set(G_OBJECT(settings), "enable-scripts", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-site-specific-quirks", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-spatial-navigation", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-spell-checking", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-xss-auditor", TRUE, NULL); + /* + Stick to defaults + "enforce-96-dpi" gboolean : Read / Write / Construct + "fantasy-font-family" gchar* : Read / Write / Construct + */ + g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", FALSE, NULL); + g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", FALSE, NULL); + g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", FALSE, NULL); + /* + Stick to defaults + "minimum-font-size" gint : Read / Write / Construct + "minimum-logical-font-size" gint : Read / Write / Construct + "monospace-font-family" gchar* : Read / Write / Construct + "print-backgrounds" gboolean : Read / Write / Construct + "resizable-text-areas" gboolean : Read / Write / Construct + "sans-serif-font-family" gchar* : Read / Write / Construct + "serif-font-family" gchar* : Read / Write / Construct + "spell-checking-languages" gchar* : Read / Write / Construct + */ + g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", FALSE, NULL); + g_object_set(G_OBJECT(settings), "user-agent", + "Zenity with WebKit (KHTML, like Gecko) support", NULL); + /* + Stick to defaults + "user-stylesheet-uri" gchar* : Read / Write / Construct + "zoom-step" gfloat : Read / Write / Construct + */ +} + +static gboolean +zenity_text_webview_decision_request (WebKitWebView *webkitwebview, + WebKitWebFrame *frame, + WebKitNetworkRequest *request, + WebKitWebNavigationAction *navigation_action, + WebKitWebPolicyDecision *policy_decision, + gpointer user_data) +{ + webkit_web_policy_decision_ignore (policy_decision); + return TRUE; +} + +static void +zenity_text_webview_load_finished (WebKitWebView *webkitwebview, + WebKitWebFrame *frame, + gpointer user_data) +{ + g_signal_connect (G_OBJECT (webkitwebview), "navigation-policy-decision-requested", + G_CALLBACK (zenity_text_webview_decision_request), NULL); +} + +#endif + static gboolean zenity_text_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -111,6 +208,12 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) GObject *text_view; GtkTextBuffer *text_buffer; +#ifdef HAVE_WEBKITGTK + GtkWidget *web_kit; + GtkWidget *scrolled_window; + GtkTextIter start_iter, end_iter; + gchar *content; +#endif zen_text_data = text_data; builder = zenity_util_load_ui_file ("zenity_text_dialog", "textbuffer1", NULL); @@ -179,6 +282,41 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) else gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); +#ifdef HAVE_WEBKITGTK + if(text_data->html) { + web_kit = webkit_web_view_new(); + scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_scrolled_window")); + + zenity_configure_webkit (WEBKIT_WEB_VIEW (web_kit)); + + if (text_data->url) + { + if (!(g_str_has_prefix (text_data->url, "http://") || g_str_has_prefix (text_data->url, "https://"))) + text_data->url = g_strdup_printf ("http://%s", text_data->url); + + + webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_kit), text_data->url); + } + else + { + gtk_text_buffer_get_start_iter (text_buffer, &start_iter); + gtk_text_buffer_get_end_iter (text_buffer, &end_iter); + content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE); + webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", NULL); + g_free (content); + } + + // We don't want user to click on links and navigate to another page. + // So, when page finish load, we block requests. + + g_signal_connect (G_OBJECT (web_kit), "document-load-finished", + G_CALLBACK (zenity_text_webview_load_finished), NULL); + + gtk_widget_destroy (GTK_WIDGET (text_view)); + gtk_container_add (GTK_CONTAINER(scrolled_window), web_kit); + gtk_widget_show (GTK_WIDGET (web_kit)); + } +#endif zenity_util_show_dialog (dialog); g_object_unref (builder); diff --git a/src/zenity.h b/src/zenity.h index 22ffca71..d9d0a108 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -111,6 +111,10 @@ typedef struct { gchar *ok_label; gchar *cancel_label; gchar *checkbox; +#ifdef HAVE_WEBKITGTK + gboolean html; + gchar *url; +#endif } ZenityTextData; typedef struct { diff --git a/src/zenity.ui b/src/zenity.ui index 07aa51a2..cd955b2a 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -892,7 +892,7 @@ False 5 - + True True etched-in -- cgit From 7a34df3041844918e2a0c5c44cb5601cff4c451a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 10:08:31 -0300 Subject: Bug #592195. This fix made the --list mode return as soon as receive an ok or cancel response avoiding crash. --- src/tree.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index cdc1599c..c15f502e 100644 --- a/src/tree.c +++ b/src/tree.c @@ -39,6 +39,7 @@ static gchar *separator; static gboolean print_all_columns = FALSE; static gint *print_columns = NULL; static gint *hide_columns = NULL; +static GIOChannel *channel; static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); static gboolean zenity_tree_column_is_hidden (gint column_index); @@ -125,7 +126,10 @@ zenity_tree_handle_stdin (GIOChannel *channel, gint status; do { - status = g_io_channel_read_line_string (channel, string, NULL, &error); + if (channel->is_readable == TRUE) + status = g_io_channel_read_line_string (channel, string, NULL, &error); + else + return FALSE; while (gtk_events_pending ()) gtk_main_iteration (); @@ -196,8 +200,6 @@ zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, gboolean toggles, gboolean editable) { - GIOChannel *channel; - g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); g_object_set_data (G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles)); g_object_set_data (G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable)); @@ -628,6 +630,9 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } + if (channel != NULL) + g_io_channel_shutdown (channel, TRUE, NULL); + gtk_main_quit (); } -- cgit From 6768a40e997697d05008aecdb41815e1dbae61c6 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 26 Jul 2011 14:00:28 -0300 Subject: Fix for bug #611297 Now Zenity have --ok-label and --cancel-label in all dialogs. This patch doesn't break old zenity scripts. --- src/calendar.c | 17 ++++++++++++- src/color.c | 17 +++++++++++++ src/entry.c | 15 ++++++++++++ src/forms.c | 17 ++++++++++++- src/msg.c | 26 +++++++++++++++----- src/option.c | 76 ++++++++++++++++++++++------------------------------------ src/password.c | 4 ++-- src/progress.c | 15 ++++++++++++ src/scale.c | 15 ++++++++++++ src/text.c | 20 ++++++++++------ src/tree.c | 15 ++++++++++++ src/zenity.h | 6 ++--- src/zenity.ui | 16 ++++++------- 13 files changed, 183 insertions(+), 76 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 32825da9..c62c1818 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -39,6 +39,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *button; GObject *text; zen_cal_data = cal_data; @@ -84,10 +85,24 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); zenity_util_show_dialog (dialog); - if(data->timeout_delay > 0) { + if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + g_object_unref (builder); gtk_main (); diff --git a/src/color.c b/src/color.c index ca8debde..5e24e3dc 100644 --- a/src/color.c +++ b/src/color.c @@ -35,6 +35,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { GtkWidget *dialog; GtkWidget *colorsel; + GtkWidget *button; GdkColor color; zen_data = data; @@ -56,6 +57,22 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) &color); } + if (data->ok_label) { + g_object_get (G_OBJECT (dialog), "ok-button", &button); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + g_object_unref (G_OBJECT (button)); + } + + if (data->cancel_label) { + g_object_get (G_OBJECT (dialog), "cancel-button", &button); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + g_object_unref (G_OBJECT (button)); + } + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); diff --git a/src/entry.c b/src/entry.c index d8111c04..7163e54c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -53,6 +53,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { GtkBuilder *builder = NULL; GtkWidget *dialog; + GtkWidget *button; GObject *text; GSList *entries = NULL; GSList *tmp; @@ -79,6 +80,20 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } text = gtk_builder_get_object (builder, "zenity_entry_text"); diff --git a/src/forms.c b/src/forms.c index d59a5afb..c2b9f851 100644 --- a/src/forms.c +++ b/src/forms.c @@ -36,6 +36,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) GtkWidget *dialog; GtkWidget *table; GtkWidget *text; + GtkWidget *button; GSList *tmp; @@ -62,7 +63,21 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - + + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); if (forms_data->dialog_text) diff --git a/src/msg.c b/src/msg.c index 5df884ff..667239b1 100644 --- a/src/msg.c +++ b/src/msg.c @@ -29,7 +29,7 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); static void -zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data) +zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { GtkWidget *cancel_button, *ok_button; @@ -38,14 +38,14 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_widget_grab_focus (ok_button); - if (msg_data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), msg_data->cancel_label); + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); gtk_button_set_image (GTK_BUTTON (cancel_button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } - if (msg_data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), msg_data->ok_label); + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } @@ -56,6 +56,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *ok_button; GObject *text; switch (msg_data->mode) { @@ -63,30 +64,35 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); text = gtk_builder_get_object (builder, "zenity_warning_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); break; case ZENITY_MSG_QUESTION: builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); text = gtk_builder_get_object (builder, "zenity_question_text"); + ok_button = NULL; break; case ZENITY_MSG_ERROR: builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); text = gtk_builder_get_object (builder, "zenity_error_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); break; case ZENITY_MSG_INFO: builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); text = gtk_builder_get_object (builder, "zenity_info_text"); + ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); break; default: builder = NULL; dialog = NULL; text = NULL; + ok_button = NULL; g_assert_not_reached (); break; } @@ -104,6 +110,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (ok_button) { + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (ok_button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + } + switch (msg_data->mode) { case ZENITY_MSG_WARNING: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); @@ -111,7 +125,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) case ZENITY_MSG_QUESTION: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); - zenity_msg_construct_question_dialog (dialog, msg_data); + zenity_msg_construct_question_dialog (dialog, msg_data, data); break; case ZENITY_MSG_ERROR: diff --git a/src/option.c b/src/option.c index e5f79b9e..e9d370d0 100644 --- a/src/option.c +++ b/src/option.c @@ -187,6 +187,24 @@ static GOptionEntry general_options[] = { /* Timeout for closing the dialog */ N_("TIMEOUT") }, + { + "ok-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_ok_button, + N_("Sets the label of the Ok button"), + N_("TEXT") + }, + { + "cancel-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_cancel_button, + N_("Sets the label of the Cancel button"), + N_("TEXT") + }, { NULL } @@ -689,24 +707,6 @@ static GOptionEntry question_options[] = { N_("Set the dialog text"), N_("TEXT") }, - { - "ok-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_ok_button, - N_("Sets the label of the Ok button"), - N_("TEXT") - }, - { - "cancel-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_cancel_button, - N_("Sets the label of the Cancel button"), - N_("TEXT") - }, { "no-wrap", '\0', @@ -766,24 +766,6 @@ static GOptionEntry text_options[] = { N_("Set the text font"), N_("TEXT") }, - { - "ok-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_ok_button, - N_("Sets the label of the Ok button"), - N_("TEXT") - }, - { - "cancel-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_cancel_button, - N_("Sets the label of the Cancel button"), - N_("TEXT") - }, { "checkbox", '\0', @@ -1467,7 +1449,9 @@ zenity_general_post_callback (GOptionContext *context, results->data->window_icon = zenity_general_window_icon; results->data->width = zenity_general_width; results->data->height = zenity_general_height; - results->data->timeout_delay=zenity_general_timeout_delay; + results->data->timeout_delay = zenity_general_timeout_delay; + results->data->ok_label = zenity_general_ok_button; + results->data->cancel_label = zenity_general_cancel_button; return TRUE; } @@ -1497,6 +1481,7 @@ zenity_calendar_post_callback (GOptionContext *context, results->calendar_data->day = zenity_calendar_day; results->calendar_data->month = zenity_calendar_month; results->calendar_data->year = zenity_calendar_year; + if (zenity_calendar_date_format) results->calendar_data->date_format = zenity_calendar_date_format; else @@ -1748,8 +1733,6 @@ zenity_question_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ok_label = zenity_general_ok_button; - results->msg_data->cancel_label = zenity_general_cancel_button; } return TRUE; @@ -1768,8 +1751,6 @@ zenity_text_post_callback (GOptionContext *context, results->text_data->editable = zenity_general_editable; results->text_data->no_wrap = zenity_general_dialog_no_wrap; results->text_data->font = zenity_text_font; - results->text_data->ok_label = zenity_general_ok_button; - results->text_data->cancel_label = zenity_general_cancel_button; results->text_data->checkbox = zenity_text_checkbox; #ifdef HAVE_WEBKITGTK results->text_data->html = zenity_text_enable_html; @@ -2163,15 +2144,16 @@ zenity_option_parse (gint argc, gchar **argv) if (zenity_general_uri) if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); - + if (zenity_general_ok_button) - if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO) - zenity_option_error (zenity_option_get_name (text_options, &zenity_general_ok_button), ERROR_SUPPORT); + if(results->mode == MODE_FILE) + zenity_option_error (zenity_option_get_name (general_options, &zenity_general_ok_button), ERROR_SUPPORT); if (zenity_general_cancel_button) - if(results->mode != MODE_QUESTION && results->mode != MODE_TEXTINFO) - zenity_option_error (zenity_option_get_name (text_options, &zenity_general_cancel_button), ERROR_SUPPORT); - + if(results->mode == MODE_FILE || results->mode == MODE_ERROR || results->mode == MODE_WARNING || results->mode == MODE_INFO) + zenity_option_error (zenity_option_get_name (general_options, &zenity_general_cancel_button), ERROR_SUPPORT); + + if (zenity_general_dialog_no_wrap) if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); diff --git a/src/password.c b/src/password.c index c49b6752..b656d8fc 100644 --- a/src/password.c +++ b/src/password.c @@ -45,10 +45,10 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data dialog = gtk_dialog_new (); gtk_dialog_add_button(GTK_DIALOG(dialog), - GTK_STOCK_CANCEL, + data->cancel_label != NULL ? data->cancel_label : GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button(GTK_DIALOG(dialog), - GTK_STOCK_OK, + data->ok_label != NULL ? data->ok_label : GTK_STOCK_OK, GTK_RESPONSE_OK); image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, diff --git a/src/progress.c b/src/progress.c index 6dc93f87..b16e400d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -227,6 +227,7 @@ void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { GtkWidget *dialog; + GtkWidget *button; GObject *text; GObject *progress_bar; GObject *cancel_button,*ok_button; @@ -255,6 +256,20 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + text = gtk_builder_get_object (builder, "zenity_progress_text"); if (progress_data->dialog_text) diff --git a/src/scale.c b/src/scale.c index 87bf55ae..11d95887 100644 --- a/src/scale.c +++ b/src/scale.c @@ -36,6 +36,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) { GtkBuilder *builder; GtkWidget *dialog; + GtkWidget *button; GObject *text; builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL); @@ -75,6 +76,20 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + if (scale_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text)); diff --git a/src/text.c b/src/text.c index e786884e..9c031cb9 100644 --- a/src/text.c +++ b/src/text.c @@ -262,16 +262,22 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->editable) zen_text_data->buffer = text_buffer; - if (text_data->ok_label) - gtk_button_set_label (GTK_BUTTON(ok_button), text_data->ok_label); + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (ok_button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } - if (text_data->cancel_label) - gtk_button_set_label (GTK_BUTTON(cancel_button), text_data->cancel_label); + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (cancel_button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } if (text_data->checkbox) { - gtk_widget_set_visible (GTK_WIDGET(checkbox), TRUE); - gtk_widget_set_sensitive (GTK_WIDGET(ok_button), FALSE); - gtk_button_set_label (GTK_BUTTON(checkbox), text_data->checkbox); + gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE); + gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox); g_signal_connect (G_OBJECT (checkbox), "toggled", G_CALLBACK (zenity_text_toggle_button), ok_button); diff --git a/src/tree.c b/src/tree.c index c15f502e..10d8946b 100644 --- a/src/tree.c +++ b/src/tree.c @@ -287,6 +287,7 @@ void zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { GtkWidget *dialog; + GtkWidget *button; GObject *tree_view; GObject *text; GtkTreeViewColumn *column; @@ -344,6 +345,20 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->ok_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); + } + + if (data->cancel_label) { + button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + gtk_button_set_image (GTK_BUTTON (button), + gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); + } + text = gtk_builder_get_object (builder, "zenity_tree_text"); if (tree_data->dialog_text) diff --git a/src/zenity.h b/src/zenity.h index d9d0a108..4d1e27d3 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -26,6 +26,8 @@ G_BEGIN_DECLS typedef struct { gchar *dialog_title; gchar *window_icon; + gchar *ok_label; + gchar *cancel_label; gint width; gint height; gint exit_code; @@ -61,8 +63,6 @@ typedef struct { MsgMode mode; gboolean no_wrap; gboolean no_markup; - gchar *ok_label; - gchar *cancel_label; } ZenityMsgData; typedef struct { @@ -108,8 +108,6 @@ typedef struct { gboolean no_wrap; gchar *font; GtkTextBuffer *buffer; - gchar *ok_label; - gchar *cancel_label; gchar *checkbox; #ifdef HAVE_WEBKITGTK gboolean html; diff --git a/src/zenity.ui b/src/zenity.ui index cd955b2a..869bdca9 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -365,7 +365,7 @@ False end - + gtk-cancel True True @@ -380,7 +380,7 @@ - + gtk-ok True True @@ -449,8 +449,8 @@ - cancelbutton12 - okbutton12 + zenity_forms_cancel_button + zenity_forms_ok_button @@ -739,7 +739,7 @@ False end - + gtk-cancel True True @@ -755,7 +755,7 @@ - + gtk-ok True True @@ -823,8 +823,8 @@ - cancelbutton1 - okbutton1 + zenity_scale_cancel_button + zenity_scale_ok_button -- cgit From ed825cf92b9d786b9b13361db4a0e696af347a59 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 13 Oct 2011 13:40:40 -0300 Subject: Initial support for list/tree on --forms option Added zenity --add-list and --list-values on --forms option. This is an initial support. Next steps add support to multiple selections and multiple columns --- src/forms.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- src/option.c | 43 +++++++++++++++++++++--- src/zenity.h | 4 ++- src/zenity.ui | 49 ++++++++++++++------------- 4 files changed, 168 insertions(+), 32 deletions(-) (limited to 'src') diff --git a/src/forms.c b/src/forms.c index c2b9f851..56c6f5ab 100644 --- a/src/forms.c +++ b/src/forms.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 121 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * Authors: Arx Cruz + * Authors: Arx Cruz */ #include "config.h" @@ -27,9 +27,84 @@ #include "util.h" static ZenityData *zen_data; - +static GSList *selected; static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) +{ + GValue value = {0, }; + gtk_tree_model_get_value (model, iter, 0, &value); + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); +} + +static void zenity_forms_dialog_output (void) +{ + GSList *tmp; + + for (tmp = selected; tmp; tmp = tmp->next) { + if (tmp->next != NULL) { + g_print ("%s,", (gchar *) tmp->data); + } + else + g_print ("%s", (gchar *) tmp->data); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; +} + +static GtkWidget * +zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, + int list_number, gchar *header) +{ + GtkListStore *list_store; + GtkWidget *tree_view; + GtkWidget *scrolled_window; + GtkCellRenderer *renderer; + + gchar *values; + int i = 0; + + list_store = gtk_list_store_new (1, G_TYPE_STRING); + if (forms_data->list_values) { + values = g_slist_nth_data (forms_data->list_values, list_number); + if (values) { + gchar **row_values = g_strsplit_set (values, "|", -1); + if (row_values) { + GtkTreeIter iter; + gchar *row = row_values[0]; + while (row != NULL) { + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, 0, row, -1); + row = row_values[++i]; + } + g_strfreev (row_values); + } + } + } + tree_view = gtk_tree_view_new (); + renderer = gtk_cell_renderer_text_new (); + gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), + -1, + header, + renderer, + "text", + 0, + NULL); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); + g_object_unref (list_store); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + //gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), + // GTK_WIDGET (tree_view)); + gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view)); + gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); + + return scrolled_window; +} + void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) { GtkBuilder *builder = NULL; @@ -41,6 +116,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) GSList *tmp; gint number_of_widgets = g_slist_length (forms_data->list); + int list_count = 0; zen_data = data; @@ -156,6 +232,22 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) 0, 0); break; + case ZENITY_FORMS_LIST: + zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, + zenity_value->option_value); + gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + list_count++; + break; default: zenity_value->forms_widget = gtk_entry_new(); gtk_table_attach (GTK_TABLE (table), @@ -193,6 +285,7 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) guint day, year, month; GDate *date = NULL; gchar time_string[128]; + GtkTreeSelection *selection; switch (response) { case GTK_RESPONSE_OK: @@ -204,6 +297,13 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) case ZENITY_FORMS_ENTRY: g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); break; + case ZENITY_FORMS_LIST: + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, + GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + zenity_forms_dialog_output (); + break; case ZENITY_FORMS_CALENDAR: gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); diff --git a/src/option.c b/src/option.c index e9d370d0..8cfed08b 100644 --- a/src/option.c +++ b/src/option.c @@ -129,6 +129,7 @@ static gboolean zenity_password_show_username; /* Forms Dialog Options */ static gboolean zenity_forms_active; static gchar *zenity_forms_date_format; +static gchar **zenity_forms_list_values; /* Miscelaneus Options */ static gboolean zenity_misc_about; @@ -956,6 +957,24 @@ static GOptionEntry forms_dialog_options[] = { N_("Add a new Calendar in forms dialog"), N_("Calendar field name") }, + { + "add-list", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new List in forms dialog"), + N_("List field and header name") + }, + { + "list-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_list_values, + N_("List of values for List"), + N_("List of values separated by |") + }, { "text", '\0', @@ -1117,6 +1136,8 @@ zenity_option_free (void) { if (zenity_forms_date_format) g_free (zenity_forms_date_format); + if (zenity_forms_list_values) + g_strfreev (zenity_forms_list_values); if (zenity_entry_entry_text) g_free (zenity_entry_entry_text); @@ -1173,13 +1194,17 @@ zenity_forms_callback (const gchar *option_name, GError **error) { ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); - forms_value->option_value = g_strdup(value); - if (g_strcmp0(option_name, "--add-entry") == 0) + + forms_value->option_value = g_strdup (value); + + if (g_strcmp0 (option_name, "--add-entry") == 0) forms_value->type = ZENITY_FORMS_ENTRY; - else if (g_strcmp0(option_name, "--add-calendar") == 0) + else if (g_strcmp0 (option_name, "--add-calendar") == 0) forms_value->type = ZENITY_FORMS_CALENDAR; - else if (g_strcmp0(option_name, "--add-password") == 0) + else if (g_strcmp0 (option_name, "--add-password") == 0) forms_value->type = ZENITY_FORMS_PASSWORD; + else if (g_strcmp0 (option_name, "--add-list") == 0) + forms_value->type = ZENITY_FORMS_LIST; results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); @@ -1833,10 +1858,20 @@ zenity_forms_post_callback (GOptionContext *context, gpointer data, GError **error) { + gchar *values; + int i = 0; + zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); if (results->mode == MODE_FORMS) { results->forms_data->dialog_text = zenity_general_dialog_text; results->forms_data->separator = zenity_general_separator; + if (zenity_forms_list_values) { + values = zenity_forms_list_values[0]; + while (values != NULL) { + results->forms_data->list_values = g_slist_append (results->forms_data->list_values, values); + values = zenity_forms_list_values[++i]; + } + } if (zenity_forms_date_format) results->forms_data->date_format = zenity_forms_date_format; else diff --git a/src/zenity.h b/src/zenity.h index 4d1e27d3..e6b0afed 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -144,6 +144,7 @@ typedef struct { typedef struct { GSList *list; GSList *list_widgets; + GSList *list_values; gchar *dialog_text; gchar *separator; gchar *date_format; @@ -152,7 +153,8 @@ typedef struct { typedef enum { ZENITY_FORMS_ENTRY, ZENITY_FORMS_PASSWORD, - ZENITY_FORMS_CALENDAR + ZENITY_FORMS_CALENDAR, + ZENITY_FORMS_LIST } ZenityFormsType; typedef struct { diff --git a/src/zenity.ui b/src/zenity.ui index 869bdca9..b39e5b1a 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,6 +1,7 @@ + 100 1 @@ -15,12 +16,12 @@ dialog - + True False 2 - + True False end @@ -149,12 +150,12 @@ dialog - + True False 2 - + True False end @@ -256,12 +257,12 @@ dialog - + True False 14 - + True False end @@ -355,12 +356,12 @@ 5 normal - + True False 2 - + True False end @@ -412,6 +413,7 @@ True False 12 + 12 12 6 @@ -461,12 +463,12 @@ dialog - + True False 14 - + True False end @@ -551,12 +553,12 @@ dialog - + True False 2 - + True False end @@ -656,12 +658,12 @@ dialog - + True False 14 - + True False end @@ -730,11 +732,11 @@ dialog - + True False - + True False end @@ -837,12 +839,12 @@ dialog - + True False 2 - + True False end @@ -954,11 +956,11 @@ dialog - + True False - + True False end @@ -1032,9 +1034,6 @@ True True True - - - @@ -1066,12 +1065,12 @@ dialog - + True False 14 - + True False end -- cgit From de352548229f60940ed9cc09bcedc883d104f311 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 13 Oct 2011 15:21:32 -0300 Subject: Revert "Initial support for list/tree on --forms option Added zenity --add-list and --list-values on --forms option. This is an initial support. Next steps add support to multiple selections and multiple columns" This reverts commit ed825cf92b9d786b9b13361db4a0e696af347a59. --- src/forms.c | 104 ++-------------------------------------------------------- src/option.c | 43 +++--------------------- src/zenity.h | 4 +-- src/zenity.ui | 49 +++++++++++++-------------- 4 files changed, 32 insertions(+), 168 deletions(-) (limited to 'src') diff --git a/src/forms.c b/src/forms.c index 56c6f5ab..c2b9f851 100644 --- a/src/forms.c +++ b/src/forms.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 121 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * Authors: Arx Cruz + * Authors: Arx Cruz */ #include "config.h" @@ -27,83 +27,8 @@ #include "util.h" static ZenityData *zen_data; -static GSList *selected; -static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); - -static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) -{ - GValue value = {0, }; - gtk_tree_model_get_value (model, iter, 0, &value); - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); -} - -static void zenity_forms_dialog_output (void) -{ - GSList *tmp; - - for (tmp = selected; tmp; tmp = tmp->next) { - if (tmp->next != NULL) { - g_print ("%s,", (gchar *) tmp->data); - } - else - g_print ("%s", (gchar *) tmp->data); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - selected = NULL; -} - -static GtkWidget * -zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, - int list_number, gchar *header) -{ - GtkListStore *list_store; - GtkWidget *tree_view; - GtkWidget *scrolled_window; - GtkCellRenderer *renderer; - gchar *values; - int i = 0; - - list_store = gtk_list_store_new (1, G_TYPE_STRING); - if (forms_data->list_values) { - values = g_slist_nth_data (forms_data->list_values, list_number); - if (values) { - gchar **row_values = g_strsplit_set (values, "|", -1); - if (row_values) { - GtkTreeIter iter; - gchar *row = row_values[0]; - while (row != NULL) { - gtk_list_store_append (list_store, &iter); - gtk_list_store_set (list_store, &iter, 0, row, -1); - row = row_values[++i]; - } - g_strfreev (row_values); - } - } - } - tree_view = gtk_tree_view_new (); - renderer = gtk_cell_renderer_text_new (); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tree_view), - -1, - header, - renderer, - "text", - 0, - NULL); - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); - g_object_unref (list_store); - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - //gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), - // GTK_WIDGET (tree_view)); - gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view)); - gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); - - return scrolled_window; -} +static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) { @@ -116,7 +41,6 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) GSList *tmp; gint number_of_widgets = g_slist_length (forms_data->list); - int list_count = 0; zen_data = data; @@ -232,22 +156,6 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) 0, 0); break; - case ZENITY_FORMS_LIST: - zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, - zenity_value->option_value); - gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); - list_count++; - break; default: zenity_value->forms_widget = gtk_entry_new(); gtk_table_attach (GTK_TABLE (table), @@ -285,7 +193,6 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) guint day, year, month; GDate *date = NULL; gchar time_string[128]; - GtkTreeSelection *selection; switch (response) { case GTK_RESPONSE_OK: @@ -297,13 +204,6 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) case ZENITY_FORMS_ENTRY: g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); break; - case ZENITY_FORMS_LIST: - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, - GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - zenity_forms_dialog_output (); - break; case ZENITY_FORMS_CALENDAR: gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); diff --git a/src/option.c b/src/option.c index 8cfed08b..e9d370d0 100644 --- a/src/option.c +++ b/src/option.c @@ -129,7 +129,6 @@ static gboolean zenity_password_show_username; /* Forms Dialog Options */ static gboolean zenity_forms_active; static gchar *zenity_forms_date_format; -static gchar **zenity_forms_list_values; /* Miscelaneus Options */ static gboolean zenity_misc_about; @@ -957,24 +956,6 @@ static GOptionEntry forms_dialog_options[] = { N_("Add a new Calendar in forms dialog"), N_("Calendar field name") }, - { - "add-list", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new List in forms dialog"), - N_("List field and header name") - }, - { - "list-values", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_forms_list_values, - N_("List of values for List"), - N_("List of values separated by |") - }, { "text", '\0', @@ -1136,8 +1117,6 @@ zenity_option_free (void) { if (zenity_forms_date_format) g_free (zenity_forms_date_format); - if (zenity_forms_list_values) - g_strfreev (zenity_forms_list_values); if (zenity_entry_entry_text) g_free (zenity_entry_entry_text); @@ -1194,17 +1173,13 @@ zenity_forms_callback (const gchar *option_name, GError **error) { ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); - - forms_value->option_value = g_strdup (value); - - if (g_strcmp0 (option_name, "--add-entry") == 0) + forms_value->option_value = g_strdup(value); + if (g_strcmp0(option_name, "--add-entry") == 0) forms_value->type = ZENITY_FORMS_ENTRY; - else if (g_strcmp0 (option_name, "--add-calendar") == 0) + else if (g_strcmp0(option_name, "--add-calendar") == 0) forms_value->type = ZENITY_FORMS_CALENDAR; - else if (g_strcmp0 (option_name, "--add-password") == 0) + else if (g_strcmp0(option_name, "--add-password") == 0) forms_value->type = ZENITY_FORMS_PASSWORD; - else if (g_strcmp0 (option_name, "--add-list") == 0) - forms_value->type = ZENITY_FORMS_LIST; results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); @@ -1858,20 +1833,10 @@ zenity_forms_post_callback (GOptionContext *context, gpointer data, GError **error) { - gchar *values; - int i = 0; - zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); if (results->mode == MODE_FORMS) { results->forms_data->dialog_text = zenity_general_dialog_text; results->forms_data->separator = zenity_general_separator; - if (zenity_forms_list_values) { - values = zenity_forms_list_values[0]; - while (values != NULL) { - results->forms_data->list_values = g_slist_append (results->forms_data->list_values, values); - values = zenity_forms_list_values[++i]; - } - } if (zenity_forms_date_format) results->forms_data->date_format = zenity_forms_date_format; else diff --git a/src/zenity.h b/src/zenity.h index e6b0afed..4d1e27d3 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -144,7 +144,6 @@ typedef struct { typedef struct { GSList *list; GSList *list_widgets; - GSList *list_values; gchar *dialog_text; gchar *separator; gchar *date_format; @@ -153,8 +152,7 @@ typedef struct { typedef enum { ZENITY_FORMS_ENTRY, ZENITY_FORMS_PASSWORD, - ZENITY_FORMS_CALENDAR, - ZENITY_FORMS_LIST + ZENITY_FORMS_CALENDAR } ZenityFormsType; typedef struct { diff --git a/src/zenity.ui b/src/zenity.ui index b39e5b1a..869bdca9 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,7 +1,6 @@ - 100 1 @@ -16,12 +15,12 @@ dialog - + True False 2 - + True False end @@ -150,12 +149,12 @@ dialog - + True False 2 - + True False end @@ -257,12 +256,12 @@ dialog - + True False 14 - + True False end @@ -356,12 +355,12 @@ 5 normal - + True False 2 - + True False end @@ -413,7 +412,6 @@ True False 12 - 12 12 6 @@ -463,12 +461,12 @@ dialog - + True False 14 - + True False end @@ -553,12 +551,12 @@ dialog - + True False 2 - + True False end @@ -658,12 +656,12 @@ dialog - + True False 14 - + True False end @@ -732,11 +730,11 @@ dialog - + True False - + True False end @@ -839,12 +837,12 @@ dialog - + True False 2 - + True False end @@ -956,11 +954,11 @@ dialog - + True False - + True False end @@ -1034,6 +1032,9 @@ True True True + + + @@ -1065,12 +1066,12 @@ dialog - + True False 14 - + True False end -- cgit From 82d09a41f2d7f6c13f207d05f2c594f3657fc599 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 21 Dec 2011 10:20:29 -0200 Subject: Added support to lists on zenity --forms --- src/forms.c | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- src/option.c | 104 +++++++++++++++++++++++++++++++++++++++--- src/zenity.h | 7 ++- 3 files changed, 247 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/forms.c b/src/forms.c index c2b9f851..f8f1db53 100644 --- a/src/forms.c +++ b/src/forms.c @@ -18,7 +18,7 @@ * Free Software Foundation, Inc., 121 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. * - * Authors: Arx Cruz + * Authors: Arx Cruz */ #include "config.h" @@ -27,9 +27,124 @@ #include "util.h" static ZenityData *zen_data; - +static GSList *selected; static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) +{ + gint n_columns = 0; + gint i = 0; + + n_columns = gtk_tree_model_get_n_columns (model); + GValue value = {0, }; + for (i = 0; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } +} + +static void zenity_forms_dialog_output (void) +{ + GSList *tmp; + + for (tmp = selected; tmp; tmp = tmp->next) { + if (tmp->next != NULL) { + g_print ("%s,", (gchar *) tmp->data); + } + else + g_print ("%s", (gchar *) tmp->data); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; +} + +static GtkWidget * +zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, + int list_number, gchar *header) +{ + GtkListStore *list_store; + GtkWidget *tree_view; + GtkWidget *scrolled_window; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + GType *column_types = NULL; + gchar *list_values; + gchar *column_values; + + gint i = 0; + /* If no column names available, default is one */ + gint n_columns = 1; + gint column_index = 0; + + tree_view = gtk_tree_view_new (); + + if (forms_data->column_values) { + column_values = g_slist_nth_data (forms_data->column_values, list_number); + if (column_values) { + gchar **values = g_strsplit_set (column_values, "|", -1); + if (values) { + n_columns = g_strv_length (values); + column_types = g_new (GType, n_columns); + for (i = 0; i < n_columns; i++) + column_types[i] = G_TYPE_STRING; + + for (i = 0; i < n_columns; i++) { + gchar *column_name = values[i]; + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes (column_name, + renderer, + "text", column_index, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + column_index++; + } + } + } + } + + list_store = g_object_new (GTK_TYPE_LIST_STORE, NULL); + + gtk_list_store_set_column_types (list_store, n_columns, column_types); + + if (forms_data->list_values) { + list_values = g_slist_nth_data (forms_data->list_values, list_number); + if (list_values) { + gchar **row_values = g_strsplit_set (list_values, "|", -1); + if (row_values) { + GtkTreeIter iter; + gchar *row = row_values[0]; + gint position = -1; + i = 0; + + while (row != NULL) { + if (position >= n_columns || position == -1) { + position = 0; + gtk_list_store_append (list_store, &iter); + } + gtk_list_store_set (list_store, &iter, position, row, -1); + position++; + row = row_values[++i]; + } + g_strfreev (row_values); + } + g_free (list_values); + } + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); + g_object_unref (list_store); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + //gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), + // GTK_WIDGET (tree_view)); + gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view)); + gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100); + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), forms_data->show_header); + + return scrolled_window; +} + void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) { GtkBuilder *builder = NULL; @@ -41,6 +156,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) GSList *tmp; gint number_of_widgets = g_slist_length (forms_data->list); + int list_count = 0; zen_data = data; @@ -156,6 +272,22 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) 0, 0); break; + case ZENITY_FORMS_LIST: + zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, + zenity_value->option_value); + gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + list_count++; + break; default: zenity_value->forms_widget = gtk_entry_new(); gtk_table_attach (GTK_TABLE (table), @@ -193,6 +325,7 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) guint day, year, month; GDate *date = NULL; gchar time_string[128]; + GtkTreeSelection *selection; switch (response) { case GTK_RESPONSE_OK: @@ -204,6 +337,13 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) case ZENITY_FORMS_ENTRY: g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); break; + case ZENITY_FORMS_LIST: + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, + GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + zenity_forms_dialog_output (); + break; case ZENITY_FORMS_CALENDAR: gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); date = g_date_new_dmy (year, month + 1, day); diff --git a/src/option.c b/src/option.c index e9d370d0..7fdb7f1d 100644 --- a/src/option.c +++ b/src/option.c @@ -128,7 +128,11 @@ static gboolean zenity_password_show_username; /* Forms Dialog Options */ static gboolean zenity_forms_active; +static gboolean zenity_forms_show_header; static gchar *zenity_forms_date_format; +//static gchar *zenity_forms_hide_column; +static gchar **zenity_forms_list_values; +static gchar **zenity_forms_column_values; /* Miscelaneus Options */ static gboolean zenity_misc_about; @@ -956,6 +960,52 @@ static GOptionEntry forms_dialog_options[] = { N_("Add a new Calendar in forms dialog"), N_("Calendar field name") }, + { + "add-list", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new List in forms dialog"), + N_("List field and header name") + }, + { + "list-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_list_values, + N_("List of values for List"), + N_("List of values separated by |") + }, + { + "column-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_column_values, + N_("List of values for columns"), + N_("List of values separated by |") + }, + /* TODO: Implement how to hide specifc column + { + "hide-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_forms_hide_column, + N_("Hide a specific column"), + N_("NUMBER") + },*/ + { + "show-header", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_forms_show_header, + N_("Show the columns header"), + NULL + }, { "text", '\0', @@ -1117,7 +1167,12 @@ zenity_option_free (void) { if (zenity_forms_date_format) g_free (zenity_forms_date_format); - + if (zenity_forms_list_values) + g_strfreev (zenity_forms_list_values); + if (zenity_forms_column_values) + g_strfreev (zenity_forms_column_values); +// if (zenity_forms_hide_column) +// g_free (zenity_forms_hide_column); if (zenity_entry_entry_text) g_free (zenity_entry_entry_text); @@ -1173,13 +1228,17 @@ zenity_forms_callback (const gchar *option_name, GError **error) { ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); - forms_value->option_value = g_strdup(value); - if (g_strcmp0(option_name, "--add-entry") == 0) + + forms_value->option_value = g_strdup (value); + + if (g_strcmp0 (option_name, "--add-entry") == 0) forms_value->type = ZENITY_FORMS_ENTRY; - else if (g_strcmp0(option_name, "--add-calendar") == 0) + else if (g_strcmp0 (option_name, "--add-calendar") == 0) forms_value->type = ZENITY_FORMS_CALENDAR; - else if (g_strcmp0(option_name, "--add-password") == 0) + else if (g_strcmp0 (option_name, "--add-password") == 0) forms_value->type = ZENITY_FORMS_PASSWORD; + else if (g_strcmp0 (option_name, "--add-list") == 0) + forms_value->type = ZENITY_FORMS_LIST; results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); @@ -1420,7 +1479,9 @@ zenity_forms_pre_callback (GOptionContext *context, GError **error) { zenity_forms_active = FALSE; + zenity_forms_show_header = FALSE; zenity_forms_date_format = NULL; +// zenity_forms_hide_column = NULL; return TRUE; } @@ -1833,10 +1894,31 @@ zenity_forms_post_callback (GOptionContext *context, gpointer data, GError **error) { + gchar *values; + int i = 0; + zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); if (results->mode == MODE_FORMS) { results->forms_data->dialog_text = zenity_general_dialog_text; results->forms_data->separator = zenity_general_separator; +// results->forms_data->hide_column = zenity_forms_hide_column; + results->forms_data->show_header = zenity_forms_show_header; + + if (zenity_forms_list_values) { + values = zenity_forms_list_values[0]; + while (values != NULL) { + results->forms_data->list_values = g_slist_append (results->forms_data->list_values, values); + values = zenity_forms_list_values[++i]; + } + } + if (zenity_forms_column_values) { + i = 0; + values = zenity_forms_column_values[0]; + while (values != NULL) { + results->forms_data->column_values = g_slist_append (results->forms_data->column_values, values); + values = zenity_forms_list_values[++i]; + } + } if (zenity_forms_date_format) results->forms_data->date_format = zenity_forms_date_format; else @@ -1845,6 +1927,18 @@ zenity_forms_post_callback (GOptionContext *context, if (zenity_forms_date_format) zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_date_format), ERROR_SUPPORT); + if (zenity_forms_list_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_list_values), + ERROR_SUPPORT); +// if (zenity_forms_hide_column) +// zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_hide_column), +// ERROR_SUPPORT); + if (zenity_forms_column_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_column_values), + ERROR_SUPPORT); + if (zenity_forms_show_header) + zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_show_header), + ERROR_SUPPORT); } return TRUE; diff --git a/src/zenity.h b/src/zenity.h index 4d1e27d3..c5414fe7 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -144,15 +144,20 @@ typedef struct { typedef struct { GSList *list; GSList *list_widgets; + GSList *list_values; + GSList *column_values; gchar *dialog_text; gchar *separator; gchar *date_format; +// gchar *hide_column; + gboolean show_header; } ZenityFormsData; typedef enum { ZENITY_FORMS_ENTRY, ZENITY_FORMS_PASSWORD, - ZENITY_FORMS_CALENDAR + ZENITY_FORMS_CALENDAR, + ZENITY_FORMS_LIST } ZenityFormsType; typedef struct { -- cgit From fd165dfe195375f66d5d97b97a2d3ab22c0bb633 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 30 Jan 2012 15:56:23 -0200 Subject: Bug #668935 - the channel was being freed twice. --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 10d8946b..ad4a6d14 100644 --- a/src/tree.c +++ b/src/tree.c @@ -645,7 +645,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } - if (channel != NULL) + if (channel->is_readable == TRUE) g_io_channel_shutdown (channel, TRUE, NULL); gtk_main_quit (); -- cgit From 4a30be17b3adfd7b8383f5c23fae71e31933326b Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 17 Apr 2012 16:50:52 -0300 Subject: Bug #673529 Fix segmentation fault in --list option --- src/tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index ad4a6d14..721817ec 100644 --- a/src/tree.c +++ b/src/tree.c @@ -120,13 +120,13 @@ zenity_tree_handle_stdin (GIOChannel *channel, string = g_string_new (NULL); - while (channel->is_readable != TRUE) + while (g_io_channel_get_flags(channel) != G_IO_FLAG_IS_READABLE) ; do { gint status; do { - if (channel->is_readable == TRUE) + if (g_io_channel_get_flags(channel) == G_IO_FLAG_IS_READABLE) status = g_io_channel_read_line_string (channel, string, NULL, &error); else return FALSE; @@ -645,7 +645,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } - if (channel->is_readable == TRUE) + if (channel != NULL && g_io_channel_get_flags (channel) == G_IO_FLAG_IS_READABLE) g_io_channel_shutdown (channel, TRUE, NULL); gtk_main_quit (); -- cgit From 1e88554c3f18c5b92a8a2724bf36d875eb6bd8f0 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 19 Apr 2012 16:10:21 -0300 Subject: Fix for Bug 567663. Now the --pulsate option works properly --- src/progress.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index b16e400d..d17b3599 100644 --- a/src/progress.c +++ b/src/progress.c @@ -92,10 +92,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, string = g_string_new (NULL); - if (progress_data->pulsate) { - zenity_progress_pulsate_start (progress_bar); - } - while (channel->is_readable != TRUE) ; do { @@ -221,6 +217,14 @@ zenity_progress_read_info (ZenityProgressData *progress_data) g_io_channel_set_encoding (channel, NULL, NULL); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_progress_handle_stdin, progress_data); + /* We need to check the pulsate state here, because, the g_io_add_watch + doesn't call the zenity_progress_handle_stdin function if there's no + input. This fix the Bug 567663 */ + if (progress_data->pulsate) { + GObject *progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + zenity_progress_pulsate_start (progress_bar); + g_object_unref(progress_bar); + } } void -- cgit From cb5f17a2df9fd06520d7078c50b781fc320e47a5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 19 Apr 2012 17:32:59 -0300 Subject: Wrong unref object --- src/progress.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index d17b3599..6763376d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -223,7 +223,6 @@ zenity_progress_read_info (ZenityProgressData *progress_data) if (progress_data->pulsate) { GObject *progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); zenity_progress_pulsate_start (progress_bar); - g_object_unref(progress_bar); } } -- cgit From 127c298ac43cbdf3b965002e7e9115571ca1d90d Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Tue, 8 May 2012 22:14:58 +0200 Subject: mask the result of g_io_channel_get_flags for the wanted flag --- src/tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 721817ec..b347b158 100644 --- a/src/tree.c +++ b/src/tree.c @@ -120,13 +120,13 @@ zenity_tree_handle_stdin (GIOChannel *channel, string = g_string_new (NULL); - while (g_io_channel_get_flags(channel) != G_IO_FLAG_IS_READABLE) + while ((g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) != G_IO_FLAG_IS_READABLE) ; do { gint status; do { - if (g_io_channel_get_flags(channel) == G_IO_FLAG_IS_READABLE) + if (g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) status = g_io_channel_read_line_string (channel, string, NULL, &error); else return FALSE; @@ -645,7 +645,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } - if (channel != NULL && g_io_channel_get_flags (channel) == G_IO_FLAG_IS_READABLE) + if (channel != NULL && g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE) g_io_channel_shutdown (channel, TRUE, NULL); gtk_main_quit (); -- cgit From 4ca4e421c59708dae16b631069d460edb8b134d0 Mon Sep 17 00:00:00 2001 From: Piotr DrÄ…g Date: Wed, 16 May 2012 19:10:16 +0200 Subject: Remove markup from translatable strings Also manually unbreak the string freeze break. --- src/zenity.ui | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 869bdca9..d656ad40 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -82,7 +82,6 @@ False 0 Select a date from below. - True True @@ -215,7 +214,6 @@ False 0 _Enter new text: - True True @@ -320,7 +318,6 @@ True 0 An error has occurred. - True True True @@ -435,8 +432,10 @@ True False - <b>Forms dialog</b> - True + Forms dialog + + + @@ -520,7 +519,6 @@ True 0 All updates are complete. - True True True @@ -614,7 +612,6 @@ False 0 Running... - True False @@ -700,7 +697,6 @@ True 0 Are you sure you want to proceed? - True True True @@ -791,7 +787,6 @@ 0 4 Adjust the scale value - True False @@ -1014,7 +1009,6 @@ False 0 Select items from the list below. - True False @@ -1127,7 +1121,6 @@ True 0 Are you sure you want to proceed? - True True True -- cgit From d845087870a8994dfb0842bf72ca7a5d5138fbef Mon Sep 17 00:00:00 2001 From: Alexandre Rostovtsev Date: Sat, 19 May 2012 20:53:27 -0400 Subject: Do not crash in --forms --add-list without column values Be a bit more user friendly, and instead of crashing, add a default column name if the user forgot to use --column-values with a --forms list. https://bugzilla.gnome.org/show_bug.cgi?id=676406 --- src/option.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 7fdb7f1d..334ec86a 100644 --- a/src/option.c +++ b/src/option.c @@ -1918,7 +1918,9 @@ zenity_forms_post_callback (GOptionContext *context, results->forms_data->column_values = g_slist_append (results->forms_data->column_values, values); values = zenity_forms_list_values[++i]; } - } + } else + results->forms_data->column_values = g_slist_append (NULL, "column"); + if (zenity_forms_date_format) results->forms_data->date_format = zenity_forms_date_format; else -- cgit From c17eff5863009c69196e92520b150643f1f7937d Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 19 Jul 2012 14:22:25 -0300 Subject: Added support to --imagelist on tree. Thanks to Joshua Nathaniel Pritikin now the first column can have an image. --- src/option.c | 16 ++++++++++++++++ src/tree.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++------ src/zenity.h | 1 + 3 files changed, 64 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 334ec86a..ee0e9c28 100644 --- a/src/option.c +++ b/src/option.c @@ -78,6 +78,7 @@ static gboolean zenity_list_radiolist; static gchar *zenity_list_print_column; static gchar *zenity_list_hide_column; static gboolean zenity_list_hide_header; +static gboolean zenity_list_imagelist; #ifdef HAVE_LIBNOTIFY /* Notification Dialog Options */ @@ -524,6 +525,15 @@ static GOptionEntry list_options[] = { N_("Use radio buttons for first column"), NULL }, + { + "imagelist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_imagelist, + N_("Use an image for first column"), + NULL + }, { "separator", '\0', @@ -1356,6 +1366,7 @@ zenity_list_pre_callback (GOptionContext *context, zenity_list_columns = NULL; zenity_list_checklist = FALSE; zenity_list_radiolist = FALSE; + zenity_list_imagelist = FALSE; zenity_list_hide_header = FALSE; zenity_list_print_column = NULL; zenity_list_hide_column = NULL; @@ -1687,6 +1698,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->checkbox = zenity_list_checklist; results->tree_data->radiobox = zenity_list_radiolist; + results->tree_data->imagebox = zenity_list_imagelist; results->tree_data->multi = zenity_general_multiple; results->tree_data->editable = zenity_general_editable; results->tree_data->print_column = zenity_list_print_column; @@ -1706,6 +1718,10 @@ zenity_list_post_callback (GOptionContext *context, zenity_option_error (zenity_option_get_name (list_options, &zenity_list_radiolist), ERROR_SUPPORT); + if (zenity_list_imagelist) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_imagelist), + ERROR_SUPPORT); + if (zenity_list_print_column) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column), ERROR_SUPPORT); diff --git a/src/tree.c b/src/tree.c index b347b158..4234fc1a 100644 --- a/src/tree.c +++ b/src/tree.c @@ -87,6 +87,44 @@ zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, g gtk_tree_path_free (path); } +static void +zenity_load_pixbuf (GtkTreeViewColumn *tree_column, + GtkCellRenderer *cell, + GtkTreeModel *tree_model, + GtkTreeIter *iter, + gpointer data) +{ + static GHashTable *pixbuf_cache = NULL; + GError *error = NULL; + GdkPixbuf *pixbuf; + gchar *str; + + gtk_tree_model_get (tree_model, iter, 0, &str, -1); + + if (!str) + return; + + if (!pixbuf_cache) { + pixbuf_cache = g_hash_table_new (g_str_hash, g_str_equal); + g_assert(pixbuf_cache); + } + + pixbuf = g_hash_table_lookup (pixbuf_cache, str); + + if (!pixbuf) { + pixbuf = gdk_pixbuf_new_from_file (str, &error); + if (!pixbuf) + g_warning ("Failed to load '%s'", str); + + g_hash_table_insert (pixbuf_cache, g_strdup (str), pixbuf); + } + + if (pixbuf) + g_object_set (cell, "pixbuf", pixbuf, NULL); + + g_free (str); +} + static gboolean zenity_tree_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -249,7 +287,7 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, GtkWidget *scrolled_window; GtkRequisition rectangle; - gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), &rectangle, NULL); scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); @@ -329,7 +367,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) return; } - if (tree_data->checkbox && tree_data->radiobox) { + if (tree_data->checkbox + tree_data->radiobox + tree_data->imagebox > 1) { g_printerr (_("You should use only one List dialog type.\n")); data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; @@ -433,6 +471,12 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) column = gtk_tree_view_column_new_with_attributes (tmp->data, cell_renderer, "active", column_index, NULL); + } else if (tree_data->imagebox) { + GtkCellRenderer *cell_renderer = gtk_cell_renderer_pixbuf_new (); + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, NULL); + gtk_tree_view_column_set_cell_data_func (column, cell_renderer, + zenity_load_pixbuf, NULL, NULL); } else { if (tree_data->editable) { @@ -657,10 +701,7 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, { ZenityData *zen_data = data; GtkTreeSelection *selection; - GtkTreeModel *model; - - model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); gtk_tree_selection_selected_foreach (selection, (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, diff --git a/src/zenity.h b/src/zenity.h index c5414fe7..30c497b1 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -121,6 +121,7 @@ typedef struct { gboolean checkbox; gboolean radiobox; gboolean hide_header; + gboolean imagebox; gchar *separator; gboolean multi; gboolean editable; -- cgit From 8777940f499a4a37fdb7c118de50f39cfa62f34b Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 19 Jul 2012 14:44:53 -0300 Subject: Fixing string freeze --- src/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index ee0e9c28..19fbbc72 100644 --- a/src/option.c +++ b/src/option.c @@ -525,7 +525,7 @@ static GOptionEntry list_options[] = { N_("Use radio buttons for first column"), NULL }, - { + /* { "imagelist", '\0', 0, @@ -533,7 +533,7 @@ static GOptionEntry list_options[] = { &zenity_list_imagelist, N_("Use an image for first column"), NULL - }, + },*/ { "separator", '\0', -- cgit From 31eef0cd8acf91aba30b5b94d5544247ebaff6bd Mon Sep 17 00:00:00 2001 From: Piotr DrÄ…g Date: Sat, 21 Jul 2012 01:07:48 +0200 Subject: Revert "Fixing string freeze" This reverts commit 8777940f499a4a37fdb7c118de50f39cfa62f34b. The master branch is not yet affected by the string freeze. --- src/option.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 19fbbc72..ee0e9c28 100644 --- a/src/option.c +++ b/src/option.c @@ -525,7 +525,7 @@ static GOptionEntry list_options[] = { N_("Use radio buttons for first column"), NULL }, - /* { + { "imagelist", '\0', 0, @@ -533,7 +533,7 @@ static GOptionEntry list_options[] = { &zenity_list_imagelist, N_("Use an image for first column"), NULL - },*/ + }, { "separator", '\0', -- cgit From 5dd7442bd5b544a99553b6e595419ed999ae6eab Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Sun, 12 Aug 2012 12:20:07 -0400 Subject: Fix various compiler warnings (two serious) Missing sentinels can cause crashes. The others are just style. --- src/color.c | 4 ++-- src/forms.c | 5 ++--- src/progress.c | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/color.c b/src/color.c index 5e24e3dc..4c9c1517 100644 --- a/src/color.c +++ b/src/color.c @@ -58,7 +58,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) } if (data->ok_label) { - g_object_get (G_OBJECT (dialog), "ok-button", &button); + g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); @@ -66,7 +66,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) } if (data->cancel_label) { - g_object_get (G_OBJECT (dialog), "cancel-button", &button); + g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); diff --git a/src/forms.c b/src/forms.c index f8f1db53..6a5b08f8 100644 --- a/src/forms.c +++ b/src/forms.c @@ -34,9 +34,9 @@ static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath * { gint n_columns = 0; gint i = 0; + GValue value = {0, }; n_columns = gtk_tree_model_get_n_columns (model); - GValue value = {0, }; for (i = 0; i < n_columns; i++) { gtk_tree_model_get_value (model, iter, i, &value); selected = g_slist_append (selected, g_value_dup_string (&value)); @@ -157,6 +157,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) gint number_of_widgets = g_slist_length (forms_data->list); int list_count = 0; + int i = 0; zen_data = data; @@ -203,8 +204,6 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) gtk_table_resize (GTK_TABLE (table), number_of_widgets, 2); - int i = 0; - for (tmp = forms_data->list; tmp; tmp = tmp->next) { ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; GtkWidget *label; diff --git a/src/progress.c b/src/progress.c index 6763376d..3e6f5a2c 100644 --- a/src/progress.c +++ b/src/progress.c @@ -54,7 +54,7 @@ zenity_progress_pulsate_progress_bar (gpointer user_data) } static void -zenity_progress_pulsate_stop () +zenity_progress_pulsate_stop (void) { if (pulsate_timeout > 0) { g_source_remove (pulsate_timeout); -- cgit From e4c5d60ee2f54bf4db3057483214e50ffd140c6c Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Fri, 10 Aug 2012 02:40:15 +0900 Subject: Port to new documentation infrastructure --- src/util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index 440c7de9..1fb8e327 100644 --- a/src/util.c +++ b/src/util.c @@ -252,7 +252,7 @@ zenity_util_show_help (GError **error) if (tmp) { g_free (tmp); - g_spawn_command_line_async ("yelp ghelp:zenity", error); + g_spawn_command_line_async ("yelp help:zenity", error); } } -- cgit From bac509bb12fafb928f9e4009e46cefc63562b4ca Mon Sep 17 00:00:00 2001 From: Frode Austvik Date: Tue, 21 Aug 2012 11:25:51 +0200 Subject: Fix the ComboBoxText construction so the dropmenu works again. This fixes lp#998445 by changing the code to construct a new ComboBoxText instead of a ComboBox, which it was (probably accidentally) changed to do in commit 4421de67. Closes: lp#998445 --- src/entry.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/entry.c b/src/entry.c index 7163e54c..2b92e59f 100644 --- a/src/entry.c +++ b/src/entry.c @@ -107,7 +107,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) n_entries = g_slist_length (entries); if (n_entries > 1) { - entry = gtk_combo_box_new_with_entry (); + entry = gtk_combo_box_text_new_with_entry (); for (tmp = entries; tmp; tmp = tmp->next) { gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); -- cgit From 0628bd3291aad936b6b553366600590cca360bfa Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Tue, 18 Sep 2012 18:33:07 +0200 Subject: util: Add an option to request dialogs being modal As WMs cannot open windows themselves, Mutter uses zenity to open "Force Quit" dialogs for unresponsive windows; as those are strongly tied to the corresponding window, it makes sense to make them modal (in particular when attaching them to their parent). https://bugzilla.gnome.org/show_bug.cgi?id=684322 --- src/calendar.c | 3 +++ src/color.c | 3 +++ src/entry.c | 3 +++ src/fileselection.c | 3 +++ src/msg.c | 3 +++ src/option.c | 12 ++++++++++++ src/password.c | 3 +++ src/progress.c | 3 +++ src/scale.c | 3 +++ src/text.c | 3 +++ src/tree.c | 3 +++ src/zenity.h | 1 + 12 files changed, 43 insertions(+) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index c62c1818..c0f7af13 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -67,6 +67,9 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + text = gtk_builder_get_object (builder, "zenity_calendar_text"); if (cal_data->dialog_text) diff --git a/src/color.c b/src/color.c index 4c9c1517..791d76da 100644 --- a/src/color.c +++ b/src/color.c @@ -73,6 +73,9 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) g_object_unref (G_OBJECT (button)); } + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); diff --git a/src/entry.c b/src/entry.c index 2b92e59f..72f73b5c 100644 --- a/src/entry.c +++ b/src/entry.c @@ -80,6 +80,9 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); diff --git a/src/fileselection.c b/src/fileselection.c index 349ff32d..cf82f028 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -67,6 +67,9 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); diff --git a/src/msg.c b/src/msg.c index 667239b1..505f961c 100644 --- a/src/msg.c +++ b/src/msg.c @@ -142,6 +142,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (msg_data->dialog_text) { if (msg_data->no_markup) diff --git a/src/option.c b/src/option.c index ee0e9c28..ba4691d0 100644 --- a/src/option.c +++ b/src/option.c @@ -44,6 +44,7 @@ static gboolean zenity_general_dialog_no_markup; static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; +static gboolean zenity_general_modal; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -210,6 +211,15 @@ static GOptionEntry general_options[] = { N_("Sets the label of the Cancel button"), N_("TEXT") }, + { + "modal", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_modal, + N_("Set the modal hint"), + NULL + }, { NULL } @@ -1287,6 +1297,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_dialog_no_wrap = FALSE; zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; + zenity_general_modal = FALSE; return TRUE; } @@ -1524,6 +1535,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->timeout_delay = zenity_general_timeout_delay; results->data->ok_label = zenity_general_ok_button; results->data->cancel_label = zenity_general_cancel_button; + results->data->modal = zenity_general_modal; return TRUE; } diff --git a/src/password.c b/src/password.c index b656d8fc..1582f956 100644 --- a/src/password.c +++ b/src/password.c @@ -134,6 +134,9 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_password_dialog_response), password_data); diff --git a/src/progress.c b/src/progress.c index 3e6f5a2c..fca31c82 100644 --- a/src/progress.c +++ b/src/progress.c @@ -259,6 +259,9 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); diff --git a/src/scale.c b/src/scale.c index 11d95887..21f820eb 100644 --- a/src/scale.c +++ b/src/scale.c @@ -75,6 +75,9 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); diff --git a/src/text.c b/src/text.c index 9c031cb9..0163c3c0 100644 --- a/src/text.c +++ b/src/text.c @@ -288,6 +288,9 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) else gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + #ifdef HAVE_WEBKITGTK if(text_data->html) { web_kit = webkit_web_view_new(); diff --git a/src/tree.c b/src/tree.c index 4234fc1a..c1a20d0f 100644 --- a/src/tree.c +++ b/src/tree.c @@ -383,6 +383,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); diff --git a/src/zenity.h b/src/zenity.h index 30c497b1..2eec3aa6 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -32,6 +32,7 @@ typedef struct { gint height; gint exit_code; gint timeout_delay; + gboolean modal; } ZenityData; typedef enum { -- cgit From bbcb2a3783de925b93707b8e76110ec9ebaed552 Mon Sep 17 00:00:00 2001 From: Florian Müllner Date: Tue, 18 Sep 2012 22:51:08 +0200 Subject: msg: Add an option to set a custom dialog icon The predefined dialog icons work well in many cases, but sometimes it makes sense to use a more specific icon, so add an option to specify an icon-name to use instead. https://bugzilla.gnome.org/show_bug.cgi?id=684329 --- src/msg.c | 9 +++++++++ src/option.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/zenity.h | 1 + src/zenity.ui | 8 ++++---- 4 files changed, 55 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 505f961c..229f0cec 100644 --- a/src/msg.c +++ b/src/msg.c @@ -58,12 +58,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) GtkWidget *dialog; GtkWidget *ok_button; GObject *text; + GObject *image; switch (msg_data->mode) { case ZENITY_MSG_WARNING: builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); text = gtk_builder_get_object (builder, "zenity_warning_text"); + image = gtk_builder_get_object (builder, "zenity_warning_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); break; @@ -71,6 +73,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); text = gtk_builder_get_object (builder, "zenity_question_text"); + image = gtk_builder_get_object (builder, "zenity_question_image"); ok_button = NULL; break; @@ -78,6 +81,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); text = gtk_builder_get_object (builder, "zenity_error_text"); + image = gtk_builder_get_object (builder, "zenity_error_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); break; @@ -85,6 +89,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); text = gtk_builder_get_object (builder, "zenity_info_text"); + image = gtk_builder_get_object (builder, "zenity_info_image"); ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); break; @@ -92,6 +97,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) builder = NULL; dialog = NULL; text = NULL; + image = NULL; ok_button = NULL; g_assert_not_reached (); break; @@ -152,6 +158,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) else gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); } + + if (msg_data->dialog_icon) + gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); diff --git a/src/option.c b/src/option.c index ba4691d0..13275d1c 100644 --- a/src/option.c +++ b/src/option.c @@ -35,6 +35,7 @@ static gchar *zenity_general_window_icon; static int zenity_general_width; static int zenity_general_height; static gchar *zenity_general_dialog_text; +static gchar *zenity_general_dialog_icon; static gchar *zenity_general_separator; static gboolean zenity_general_multiple; static gboolean zenity_general_editable; @@ -347,6 +348,15 @@ static GOptionEntry error_options[] = { N_("Set the dialog text"), N_("TEXT") }, + { + "icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_("Set the dialog icon"), + N_("ICON-NAME") + }, { "no-wrap", '\0', @@ -388,6 +398,15 @@ static GOptionEntry info_options[] = { N_("Set the dialog text"), N_("TEXT") }, + { + "icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_("Set the dialog icon"), + N_("ICON-NAME") + }, { "no-wrap", '\0', @@ -731,6 +750,15 @@ static GOptionEntry question_options[] = { N_("Set the dialog text"), N_("TEXT") }, + { + "icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_("Set the dialog icon"), + N_("ICON-NAME") + }, { "no-wrap", '\0', @@ -843,6 +871,15 @@ static GOptionEntry warning_options[] = { N_("Set the dialog text"), N_("TEXT") }, + { + "icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_("Set the dialog icon"), + N_("ICON-NAME") + }, { "no-wrap", '\0', @@ -1627,6 +1664,7 @@ zenity_error_post_callback (GOptionContext *context, if (results->mode == MODE_ERROR) { results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; results->msg_data->mode = ZENITY_MSG_ERROR; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; @@ -1645,6 +1683,7 @@ zenity_info_post_callback (GOptionContext *context, if (results->mode == MODE_INFO) { results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; results->msg_data->mode = ZENITY_MSG_INFO; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; @@ -1819,6 +1858,7 @@ zenity_question_post_callback (GOptionContext *context, zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION); if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; @@ -1863,6 +1903,7 @@ zenity_warning_post_callback (GOptionContext *context, if (results->mode == MODE_WARNING) { results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; results->msg_data->mode = ZENITY_MSG_WARNING; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; diff --git a/src/zenity.h b/src/zenity.h index 2eec3aa6..4c941290 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -61,6 +61,7 @@ typedef enum { typedef struct { gchar *dialog_text; + gchar *dialog_icon; MsgMode mode; gboolean no_wrap; gboolean no_markup; diff --git a/src/zenity.ui b/src/zenity.ui index d656ad40..ee89093a 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -299,7 +299,7 @@ 5 12 - + True False 0 @@ -500,7 +500,7 @@ 5 12 - + True False 0 @@ -677,7 +677,7 @@ 5 12 - + True False 0 @@ -1101,7 +1101,7 @@ 5 12 - + True False 0 -- cgit From 156a99e304247504a486f0911596ab5765ad1add Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 25 Sep 2012 18:49:50 -0400 Subject: Don't break the string freeze I'm out of time waiting for a second string freeze break approval, so the strings will be untranslated for now. --- src/option.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 13275d1c..ae2dc080 100644 --- a/src/option.c +++ b/src/option.c @@ -218,7 +218,7 @@ static GOptionEntry general_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_modal, - N_("Set the modal hint"), + "Set the modal hint", NULL }, { @@ -354,8 +354,8 @@ static GOptionEntry error_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_icon, - N_("Set the dialog icon"), - N_("ICON-NAME") + "Set the dialog icon", + "ICON-NAME" }, { "no-wrap", -- cgit From cabf7b76bc258e3f2bb72db5d59e9956def7c6d8 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Tue, 25 Sep 2012 19:44:46 -0400 Subject: Revert "Don't break the string freeze" This reverts commit 156a99e304247504a486f0911596ab5765ad1add. I got the second string freeze approval after all, so lets add the new strings back. --- src/option.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index ae2dc080..13275d1c 100644 --- a/src/option.c +++ b/src/option.c @@ -218,7 +218,7 @@ static GOptionEntry general_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_modal, - "Set the modal hint", + N_("Set the modal hint"), NULL }, { @@ -354,8 +354,8 @@ static GOptionEntry error_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_dialog_icon, - "Set the dialog icon", - "ICON-NAME" + N_("Set the dialog icon"), + N_("ICON-NAME") }, { "no-wrap", -- cgit From 9beba8872dd01d6c9347717d9ce156c059e85a0d Mon Sep 17 00:00:00 2001 From: Marc Ruiz - radykal - Date: Mon, 12 Nov 2012 21:57:07 +0100 Subject: Replaced string 'could' to start with an Uppercase. BUG ID: 687180 --- src/notification.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 3f4c454e..0a36e09e 100644 --- a/src/notification.c +++ b/src/notification.c @@ -92,7 +92,7 @@ zenity_notification_handle_stdin (GIOChannel *channel, zenity_util_strip_newline (string->str); colon = strchr(string->str, ':'); if (colon == NULL) { - g_printerr (_("could not parse command from stdin\n")); + g_printerr (_("Could not parse command from stdin\n")); continue; } /* split off the command and value */ -- cgit From 74d867c2aa9dde9dc21297c67af9e6432124b054 Mon Sep 17 00:00:00 2001 From: Nuno Araujo Date: Thu, 14 Feb 2013 01:08:56 +0100 Subject: Allow to specify notification's hints Desktop Notifications Specification [1] specifies that hints can be used to provide extra data to a notification server. A new command line option --hint allows to add a hint to the notification to display. This option can be used multiple times, one for each hint to add. --hint option format is name:value. The new 'hints' command allow to specify hints in 'listen' mode. Same format that in the command line option is used. Several hints can be passed by separating them by '\n'. Hints of value type '(iiibiiay)' are not supported. This value type is used to pass a raw data image as a hint value. This new change is useful for implementing the NotificationSource [2] GNOME Goal. A application using zenity and having a desktop file, can now specify that it is a notification emitter and it's notifications can be filtered in the new Notifications GNOME control panel pane. [1] http://people.gnome.org/~mccann/docs/notification-spec/notification-spec-latest.html#hints [2] https://live.gnome.org/GnomeGoals/NotificationSource https://bugzilla.gnome.org/show_bug.cgi?id=693751 --- src/notification.c | 131 +++++++++++++++++++++++++++++++++++++++++++++++++++++ src/option.c | 16 +++++++ src/zenity.h | 1 + 3 files changed, 148 insertions(+) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 0a36e09e..3a552026 100644 --- a/src/notification.c +++ b/src/notification.c @@ -35,7 +35,10 @@ #include "zenity.h" #include "util.h" +#define MAX_HINTS 16 + static char *icon_file; +static GHashTable *notification_hints; static void on_notification_default_action (NotifyNotification *n, @@ -52,6 +55,117 @@ on_notification_default_action (NotifyNotification *n, gtk_main_quit (); } +static GHashTable * +zenity_notification_parse_hints_array (gchar **hints) +{ + GHashTable *result; + gchar** pair; + int i; + + result = g_hash_table_new_full (g_str_hash, + g_str_equal, + g_free, + g_free); + + for(i = 0; i < g_strv_length (hints); i++) { + pair = g_strsplit (hints[i], ":", 2); + g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1])); + g_strfreev (pair); + } + if (g_hash_table_size (result) == 0) { + g_hash_table_unref (result); + return NULL; + } else { + return result; + } +} + +static GHashTable * +zenity_notification_parse_hints (gchar *hints) +{ + GHashTable *result; + gchar** hint_array; + + hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS); + result = zenity_notification_parse_hints_array (hint_array); + g_strfreev (hint_array); + return result; +} + +static void +zenity_notification_set_hint(gpointer key, gpointer value, gpointer user_data) +{ + NotifyNotification *notification; + gchar *hint_name; + GVariant *hint_value; + + gchar *string_value; + gboolean boolean_value; + gint32 int_value; + guchar byte_value; + + hint_name = (gchar *) key; + string_value = (gchar *) value; + notification = (NotifyNotification *) user_data; + + if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0) + || (g_ascii_strcasecmp ("resident", hint_name) == 0) + || (g_ascii_strcasecmp ("suppress-sound", hint_name) == 0) + || (g_ascii_strcasecmp ("transient", hint_name) == 0)) { + /* boolean hints */ + if (g_ascii_strcasecmp ("true", string_value) == 0) { + boolean_value = TRUE; + } else if (g_ascii_strcasecmp ("false", string_value) == 0) { + boolean_value = FALSE; + } else { + g_printerr (_("Invalid value for a boolean typed hint.\nSupported values are 'true' or 'false'.\n")); + return; + } + hint_value = g_variant_new_boolean (boolean_value); + } else if ((g_ascii_strcasecmp ("category", hint_name) == 0) + || (g_ascii_strcasecmp ("desktop-entry", hint_name) == 0) + || (g_ascii_strcasecmp ("image-path", hint_name) == 0) + || (g_ascii_strcasecmp ("image_path", hint_name) == 0) + || (g_ascii_strcasecmp ("sound-file", hint_name) == 0) + || (g_ascii_strcasecmp ("sound-name", hint_name) == 0)) { + /* string hints */ + hint_value = g_variant_new_string (string_value); + } else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0) + || (g_ascii_strcasecmp ("image_data", hint_name) == 0) + || (g_ascii_strcasecmp ("icon-data", hint_name) == 0)) { + /* (iibiiay) */ + g_printerr (_("Unsupported hint. Skipping.\n")); + return; + } else if ((g_ascii_strcasecmp ("x", hint_name) == 0) + || (g_ascii_strcasecmp ("y", hint_name) == 0)) { + /* int hints */ + int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0); + hint_value = g_variant_new_int32 (int_value); + } else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) { + /* byte hints */ + byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0); + hint_value = g_variant_new_byte (byte_value); + } else { + /* unknown hints */ + g_printerr (_("Unknown hint name. Skipping.\n")); + return; + } + + notify_notification_set_hint (notification, + hint_name, + hint_value); +} + +static void +zenity_notification_set_hints (NotifyNotification *notification, GHashTable *hints) +{ + if (hints == NULL) { + return; + } + + g_hash_table_foreach (hints, zenity_notification_set_hint, notification); +} + static gboolean zenity_notification_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -104,6 +218,11 @@ zenity_notification_handle_stdin (GIOChannel *channel, if (!g_ascii_strcasecmp (command, "icon")) { g_free (icon_file); icon_file = g_strdup (value); + } else if (!g_ascii_strcasecmp (command, "hints")) { + if (notification_hints != NULL) { + g_hash_table_unref (notification_hints); + } + notification_hints = zenity_notification_parse_hints (value); } else if (!g_ascii_strcasecmp (command, "message")) { /* display a notification bubble */ if (!g_utf8_validate (value, -1, NULL)) { @@ -129,6 +248,8 @@ zenity_notification_handle_stdin (GIOChannel *channel, g_strfreev (message); + zenity_notification_set_hints (notif, notification_hints); + notify_notification_show (notif, &error); if (error) { g_warning ("Error showing notification: %s", error->message); @@ -147,6 +268,9 @@ zenity_notification_handle_stdin (GIOChannel *channel, notif = notify_notification_new (value, NULL, icon_file); + + zenity_notification_set_hints (notif, notification_hints); + notify_notification_show (notif, &error); if (error) { g_warning ("Error showing notification: %s", error->message); @@ -192,6 +316,7 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data { GError *error; NotifyNotification *notification; + GHashTable *notification_hints; /* create the notification widget */ if (!notify_is_initted ()) { @@ -218,6 +343,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data data, NULL); + /* set the notification hints for the displayed notification */ + notification_hints = zenity_notification_parse_hints_array (notification_data->notification_hints); + zenity_notification_set_hints(notification, notification_hints); + g_hash_table_unref (notification_hints); + /* Show icon and wait */ error = NULL; if (!notify_notification_show (notification, &error)) { @@ -236,4 +366,5 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data gtk_main (); } + #endif diff --git a/src/option.c b/src/option.c index 13275d1c..2ca9f1d7 100644 --- a/src/option.c +++ b/src/option.c @@ -86,6 +86,7 @@ static gboolean zenity_list_imagelist; /* Notification Dialog Options */ static gboolean zenity_notification_active; static gboolean zenity_notification_listen; +static gchar **zenity_notification_hints; #endif /* Progress Dialog Options */ @@ -652,6 +653,15 @@ static GOptionEntry notification_options[] = { N_("Listen for commands on stdin"), NULL }, + { + "hint", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING_ARRAY, + &zenity_notification_hints, + N_("Set the notification hints"), + N_("TEXT") + }, { NULL } @@ -1243,6 +1253,11 @@ zenity_option_free (void) { if (zenity_list_hide_column) g_free (zenity_list_hide_column); +#ifdef HAVE_LIBNOTIFY + if (zenity_notification_hints) + g_strfreev (zenity_notification_hints); +#endif + if (zenity_text_font) g_free (zenity_text_font); if (zenity_text_checkbox) @@ -1801,6 +1816,7 @@ zenity_notification_post_callback (GOptionContext *context, if (results->mode == MODE_NOTIFICATION) { results->notification_data->notification_text = zenity_general_dialog_text; results->notification_data->listen = zenity_notification_listen; + results->notification_data->notification_hints = zenity_notification_hints; } else { if (zenity_notification_listen) zenity_option_error (zenity_option_get_name (notification_options, &zenity_notification_listen), diff --git a/src/zenity.h b/src/zenity.h index 4c941290..7018800f 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -136,6 +136,7 @@ typedef struct { typedef struct { gchar *notification_text; gboolean listen; + gchar **notification_hints; } ZenityNotificationData; #endif -- cgit From 1ac1da63f8de626ce10d350be7b29744a743ec95 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 5 Mar 2013 16:56:24 -0300 Subject: But #674881 - Timeout option overriding normal exit code --- src/calendar.c | 33 ++++++++++++------ src/entry.c | 31 +++++++++++------ src/fileselection.c | 33 ++++++++++++------ src/forms.c | 99 ++++++++++++++++++++++++++++------------------------- src/progress.c | 5 ++- src/scale.c | 5 +++ src/text.c | 27 ++++++++++----- src/tree.c | 37 ++++++++++++-------- src/util.c | 8 ++--- 9 files changed, 169 insertions(+), 109 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index c0f7af13..f2820014 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -110,33 +110,44 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) gtk_main (); } +static void +zenity_calendar_dialog_output (void) +{ + guint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); + g_print ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); +} static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data; - guint day, month, year; - gchar time_string[128]; - GDate *date = NULL; zen_data = data; switch (response) { case GTK_RESPONSE_OK: - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_print ("%s\n", time_string); - - if (date != NULL) - g_date_free (date); - zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/entry.c b/src/entry.c index 72f73b5c..da708e22 100644 --- a/src/entry.c +++ b/src/entry.c @@ -153,31 +153,40 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) gtk_main (); } +static void +zenity_entry_dialog_output (void) +{ + const gchar *text; + if (n_entries > 1) + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); + else + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); + +} + static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - const gchar *text; switch (response) { case GTK_RESPONSE_OK: + zenity_entry_dialog_output (); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - if (n_entries > 1) { - text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); - } - else { - text = gtk_entry_get_text (GTK_ENTRY (entry)); - } - - if (text != NULL) - g_print ("%s\n", text); - break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_entry_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/fileselection.c b/src/fileselection.c index cf82f028..b4b0a65e 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -145,30 +145,41 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) gtk_main (); } +static void +zenity_fileselection_dialog_output (GtkWidget *widget, ZenityFileData *file_data) +{ + GSList *selections, *iter; + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections;iter != NULL; iter = iter->next) { + g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) + g_print ("%s",file_data->separator); + } + g_print("\n"); + g_slist_free(selections); +} + static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityFileData *file_data = data; - GSList *selections, *iter; - + switch (response) { case GTK_RESPONSE_OK: + zenity_fileselection_dialog_output (widget, file_data); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); - for (iter = selections;iter != NULL; iter = iter->next) { - g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); - g_free (iter->data); - if (iter->next != NULL) - g_print ("%s",file_data->separator); - } - g_print("\n"); - g_slist_free(selections); break; case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_fileselection_dialog_output (widget, file_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/forms.c b/src/forms.c index 6a5b08f8..0bac6679 100644 --- a/src/forms.c +++ b/src/forms.c @@ -44,22 +44,6 @@ static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath * } } -static void zenity_forms_dialog_output (void) -{ - GSList *tmp; - - for (tmp = selected; tmp; tmp = tmp->next) { - if (tmp->next != NULL) { - g_print ("%s,", (gchar *) tmp->data); - } - else - g_print ("%s", (gchar *) tmp->data); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - selected = NULL; -} - static GtkWidget * zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, int list_number, gchar *header) @@ -317,49 +301,72 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) } static void -zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) +zenity_forms_dialog_output (ZenityFormsData *forms_data) { - ZenityFormsData *forms_data = (ZenityFormsData *) data; - GSList *tmp; + GSList *tmp, *tmp2; guint day, year, month; GDate *date = NULL; - gchar time_string[128]; + gchar time_string[128]; GtkTreeSelection *selection; + for (tmp = forms_data->list; tmp; tmp = tmp->next) { + ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; + switch (zenity_value->type) { + case ZENITY_FORMS_PASSWORD: + case ZENITY_FORMS_ENTRY: + g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); + break; + case ZENITY_FORMS_LIST: + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, + GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + + for (tmp2 = selected; tmp2; tmp2 = tmp2->next) { + if (tmp->next != NULL) { + g_print ("%s,", (gchar *) tmp2->data); + } + else + g_print ("%s", (gchar *) tmp2->data); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; + + break; + case ZENITY_FORMS_CALENDAR: + gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, forms_data->date_format, date); + g_print ("%s", time_string); + break; + } + if (tmp->next != NULL) + g_print("%s", forms_data->separator); + } + g_print("\n"); +} + +static void +zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) +{ + ZenityFormsData *forms_data = (ZenityFormsData *) data; + switch (response) { case GTK_RESPONSE_OK: + zenity_forms_dialog_output (forms_data); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - for (tmp = forms_data->list; tmp; tmp = tmp->next) { - ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; - switch (zenity_value->type) { - case ZENITY_FORMS_PASSWORD: - case ZENITY_FORMS_ENTRY: - g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); - break; - case ZENITY_FORMS_LIST: - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, - GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - zenity_forms_dialog_output (); - break; - case ZENITY_FORMS_CALENDAR: - gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, forms_data->date_format, date); - g_print ("%s", time_string); - break; - } - if (tmp->next != NULL) - g_print("%s", forms_data->separator); - } - g_print("\n"); - break; + case GTK_RESPONSE_CANCEL: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_forms_dialog_output (forms_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/progress.c b/src/progress.c index fca31c82..c382d74d 100644 --- a/src/progress.c +++ b/src/progress.c @@ -307,7 +307,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) zenity_progress_read_info (progress_data); if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); } gtk_main (); @@ -333,6 +333,9 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data); + break; default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/scale.c b/src/scale.c index 21f820eb..a7f6d718 100644 --- a/src/scale.c +++ b/src/scale.c @@ -139,6 +139,11 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); + break; + default: zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/text.c b/src/text.c index 0163c3c0..05ada53d 100644 --- a/src/text.c +++ b/src/text.c @@ -344,6 +344,19 @@ zenity_text_toggle_button (GtkToggleButton *button, gpointer data) gtk_widget_set_sensitive (GTK_WIDGET(ok_button), gtk_toggle_button_get_active(button)); } +static void +zenity_text_dialog_output (ZenityData *zen_data) +{ + if (zen_text_data->editable) { + GtkTextIter start, end; + gchar *text; + gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); + text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); + g_print ("%s", text); + g_free (text); + } +} + static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) { @@ -351,17 +364,15 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) switch (response) { case GTK_RESPONSE_CLOSE: - if (zen_text_data->editable) { - GtkTextIter start, end; - gchar *text; - gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); - text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); - g_print ("%s", text); - g_free (text); - } + zenity_text_dialog_output (zen_data); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); break; + case ZENITY_TIMEOUT: + zenity_text_dialog_output (zen_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); diff --git a/src/tree.c b/src/tree.c index c1a20d0f..cf902391 100644 --- a/src/tree.c +++ b/src/tree.c @@ -640,6 +640,23 @@ zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, static void zenity_tree_dialog_output (void) { +GObject *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; + + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + + if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) + gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, + GTK_TREE_VIEW (tree_view)); + else { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, + GTK_TREE_VIEW (tree_view)); + } + GSList *tmp; for (tmp = selected; tmp; tmp = tmp->next) { @@ -661,24 +678,9 @@ static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { ZenityData *zen_data = data; - GObject *tree_view; - GtkTreeSelection *selection; - GtkTreeModel *model; switch (response) { case GTK_RESPONSE_OK: - tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - - if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) - gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, - GTK_TREE_VIEW (tree_view)); - else { - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, - GTK_TREE_VIEW (tree_view)); - } zenity_tree_dialog_output (); zenity_util_exit_code_with_data(ZENITY_OK, zen_data); break; @@ -687,6 +689,11 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); break; + case ZENITY_TIMEOUT: + zenity_tree_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + default: /* Esc dialog */ zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); diff --git a/src/util.c b/src/util.c index 1fb8e327..df7317a9 100644 --- a/src/util.c +++ b/src/util.c @@ -312,7 +312,7 @@ zenity_util_return_exit_code ( ZenityExitCode value ) if (! env_var) retval = ZENITY_TIMEOUT; break; - + default: retval = 1; } @@ -325,10 +325,6 @@ zenity_util_return_exit_code ( ZenityExitCode value ) void zenity_util_exit_code_with_data(ZenityExitCode value, ZenityData *zen_data) { - /* We assume it's being called with --timeout option and should return 5) */ - if(zen_data->timeout_delay > 0) - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - else zen_data->exit_code = zenity_util_return_exit_code (value); } @@ -432,7 +428,7 @@ zenity_util_timeout_handle (gpointer data) { GtkDialog *dialog = GTK_DIALOG(data); if(dialog != NULL) - gtk_dialog_response(dialog, GTK_RESPONSE_OK); + gtk_dialog_response(dialog, ZENITY_TIMEOUT); else { gtk_main_quit(); exit(ZENITY_TIMEOUT); -- cgit From 7c234ed9b71d5f009abff509ef2bf576f61a0cbb Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 23 May 2013 16:27:58 -0300 Subject: Bug 698683 - Double clicking an item or hitting enter after selecting an item returns it twice --- src/tree.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index cf902391..031765e4 100644 --- a/src/tree.c +++ b/src/tree.c @@ -710,12 +710,6 @@ zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, GtkTreeViewColumn *tree_col, gpointer data) { ZenityData *zen_data = data; - GtkTreeSelection *selection; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, - GTK_TREE_VIEW (tree_view)); zenity_tree_dialog_output (); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); -- cgit From c89ce9c3812fdc3a2637fd76b42a07385ad50684 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 4 Jun 2013 16:27:48 -0300 Subject: Bug #653468. Fixed by Kurt Miller . Fix the broken auto-close option in progress and list dialogs. --- src/progress.c | 9 ++++----- src/tree.c | 9 ++++----- 2 files changed, 8 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index c382d74d..055699c0 100644 --- a/src/progress.c +++ b/src/progress.c @@ -81,12 +81,13 @@ zenity_progress_handle_stdin (GIOChannel *channel, static GObject *progress_bar; static GObject *progress_label; float percentage = 0.0; + GIOStatus status = G_IO_STATUS_NORMAL; progress_data = (ZenityProgressData *) data; progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); progress_label = gtk_builder_get_object (builder, "zenity_progress_text"); - if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + if ((condition & G_IO_IN) != 0) { GString *string; GError *error = NULL; @@ -95,8 +96,6 @@ zenity_progress_handle_stdin (GIOChannel *channel, while (channel->is_readable != TRUE) ; do { - gint status; - do { status = g_io_channel_read_line_string (channel, string, NULL, &error); @@ -175,11 +174,11 @@ zenity_progress_handle_stdin (GIOChannel *channel, } } - } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF); g_string_free (string, TRUE); } - if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) { + if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ GtkWidget *button; diff --git a/src/tree.c b/src/tree.c index 031765e4..4634ba12 100644 --- a/src/tree.c +++ b/src/tree.c @@ -139,6 +139,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, static gboolean editable; static gboolean toggles; static gboolean first_time = TRUE; + GIOStatus status = G_IO_STATUS_NORMAL; tree_view = GTK_TREE_VIEW (data); n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); @@ -152,7 +153,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, gtk_list_store_append (GTK_LIST_STORE (model), &iter); } - if ((condition == G_IO_IN) || (condition == G_IO_IN + G_IO_HUP)) { + if ((condition & G_IO_IN) == G_IO_IN) { GString *string; GError *error = NULL; @@ -161,8 +162,6 @@ zenity_tree_handle_stdin (GIOChannel *channel, while ((g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) != G_IO_FLAG_IS_READABLE) ; do { - gint status; - do { if (g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) status = g_io_channel_read_line_string (channel, string, NULL, &error); @@ -221,11 +220,11 @@ zenity_tree_handle_stdin (GIOChannel *channel, column_count++; - } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF); g_string_free (string, TRUE); } - if ((condition != G_IO_IN) && (condition != G_IO_IN + G_IO_HUP)) { + if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { g_io_channel_shutdown (channel, TRUE, NULL); return FALSE; } -- cgit From 58245d4d4acd00e256e29159e645fa0c5f117d34 Mon Sep 17 00:00:00 2001 From: Benjamin Berg Date: Fri, 2 Aug 2013 11:17:17 +0200 Subject: Add a runtime check for X11 (bug #705335) If GTK+ is compiled with multiple backends, then it is necessary to do a runtime check for the used backend. --- src/util.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/util.c b/src/util.c index df7317a9..a6f2896f 100644 --- a/src/util.c +++ b/src/util.c @@ -417,8 +417,11 @@ zenity_util_show_dialog (GtkWidget *dialog) { gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 - g_assert (gtk_widget_get_window(dialog)); - zenity_util_make_transient (gtk_widget_get_window(dialog)); + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) + { + g_assert (gtk_widget_get_window(dialog)); + zenity_util_make_transient (gtk_widget_get_window(dialog)); + } #endif gtk_widget_show (dialog); } -- cgit From 009523d5da827392b027ac6da1a50f94314e3a35 Mon Sep 17 00:00:00 2001 From: Weitian Leung Date: Fri, 23 Aug 2013 09:15:07 +0800 Subject: added attach option for transient window --- src/about.c | 2 +- src/calendar.c | 2 +- src/color.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/msg.c | 2 +- src/option.c | 12 ++++++++++++ src/password.c | 2 +- src/progress.c | 2 +- src/scale.c | 2 +- src/text.c | 2 +- src/tree.c | 2 +- src/util.c | 22 ++++++++-------------- src/util.h | 6 +++++- src/zenity.h | 1 + 15 files changed, 37 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 67c2474c..ab82068a 100644 --- a/src/about.c +++ b/src/about.c @@ -308,7 +308,7 @@ zenity_about (ZenityData *data) G_CALLBACK (zenity_zen_wisdom), NULL); #endif - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); gtk_main (); } diff --git a/src/calendar.c b/src/calendar.c index f2820014..e8967974 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -86,7 +86,7 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) G_CALLBACK (zenity_calendar_double_click), data); gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/color.c b/src/color.c index 791d76da..b6a6b121 100644 --- a/src/color.c +++ b/src/color.c @@ -79,7 +79,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), color_data->show_palette); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, diff --git a/src/entry.c b/src/entry.c index da708e22..ca5e3752 100644 --- a/src/entry.c +++ b/src/entry.c @@ -144,7 +144,7 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) g_object_unref (builder); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/fileselection.c b/src/fileselection.c index b4b0a65e..9edbb6ae 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -136,7 +136,7 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) } } - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/msg.c b/src/msg.c index 229f0cec..53f8a5df 100644 --- a/src/msg.c +++ b/src/msg.c @@ -165,7 +165,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); diff --git a/src/option.c b/src/option.c index 2ca9f1d7..7658e8b4 100644 --- a/src/option.c +++ b/src/option.c @@ -46,6 +46,7 @@ static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; static gboolean zenity_general_modal; +static gint zenity_general_attach; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -222,6 +223,15 @@ static GOptionEntry general_options[] = { N_("Set the modal hint"), NULL }, + { + "attach", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_INT, + &zenity_general_attach, + N_("Set the parent window to attach to"), + N_("WINDOW") + }, { NULL } @@ -1350,6 +1360,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; zenity_general_modal = FALSE; + zenity_general_attach = 0; return TRUE; } @@ -1588,6 +1599,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->ok_label = zenity_general_ok_button; results->data->cancel_label = zenity_general_cancel_button; results->data->modal = zenity_general_modal; + results->data->attach = zenity_general_attach; return TRUE; } diff --git a/src/password.c b/src/password.c index 1582f956..915ea3d9 100644 --- a/src/password.c +++ b/src/password.c @@ -141,7 +141,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data G_CALLBACK (zenity_password_dialog_response), password_data); gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog)))); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { g_timeout_add (data->timeout_delay * 1000, diff --git a/src/progress.c b/src/progress.c index 055699c0..cbffe08e 100644 --- a/src/progress.c +++ b/src/progress.c @@ -302,7 +302,7 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (no_cancel && auto_close) gtk_widget_hide(GTK_WIDGET(ok_button)); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); zenity_progress_read_info (progress_data); if(data->timeout_delay > 0) { diff --git a/src/scale.c b/src/scale.c index a7f6d718..adcf67be 100644 --- a/src/scale.c +++ b/src/scale.c @@ -107,7 +107,7 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (scale_data->hide_value) gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/text.c b/src/text.c index 05ada53d..056ad28b 100644 --- a/src/text.c +++ b/src/text.c @@ -326,7 +326,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_widget_show (GTK_WIDGET (web_kit)); } #endif - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); g_object_unref (builder); diff --git a/src/tree.c b/src/tree.c index 4634ba12..a8b324f7 100644 --- a/src/tree.c +++ b/src/tree.c @@ -562,7 +562,7 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); } - zenity_util_show_dialog (dialog); + zenity_util_show_dialog (dialog, data->attach); if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); diff --git a/src/util.c b/src/util.c index a6f2896f..d63aecaf 100644 --- a/src/util.c +++ b/src/util.c @@ -39,10 +39,6 @@ #include "util.h" #include "zenity.h" -#ifdef GDK_WINDOWING_X11 -#include -#endif - #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 #define ZENITY_ESC_DEFAULT 1 @@ -398,29 +394,27 @@ transient_get_xterm_toplevel (void) } static void -zenity_util_make_transient (GdkWindow *window) +zenity_util_make_transient (GdkWindow *window, Window parent) { - Window xterm = transient_get_xterm_toplevel (); - if (xterm != None) { - GdkWindow *gdkxterm = gdk_x11_window_foreign_new_for_display (gdk_display_get_default (), xterm); - if (gdkxterm) { - gdk_window_set_transient_for (window, gdkxterm); - g_object_unref (G_OBJECT (gdkxterm)); - } + Window parent_window = parent; + if (parent_window == 0) + parent_window = transient_get_xterm_toplevel (); + if (parent_window != None) { + XSetTransientForHint (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_WINDOW_XID(window), parent_window); } } #endif /* GDK_WINDOWING_X11 */ void -zenity_util_show_dialog (GtkWidget *dialog) +zenity_util_show_dialog (GtkWidget *dialog, Window parent) { gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { g_assert (gtk_widget_get_window(dialog)); - zenity_util_make_transient (gtk_widget_get_window(dialog)); + zenity_util_make_transient (gtk_widget_get_window(dialog), parent); } #endif gtk_widget_show (dialog); diff --git a/src/util.h b/src/util.h index 48409c11..f9db4bea 100644 --- a/src/util.h +++ b/src/util.h @@ -4,6 +4,10 @@ #include #include "zenity.h" +#ifdef GDK_WINDOWING_X11 +#include +#endif + G_BEGIN_DECLS #define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" @@ -28,7 +32,7 @@ void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data); -void zenity_util_show_dialog (GtkWidget *widget); +void zenity_util_show_dialog (GtkWidget *widget, Window parent); gboolean zenity_util_timeout_handle (gpointer data); diff --git a/src/zenity.h b/src/zenity.h index 7018800f..501109a4 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -33,6 +33,7 @@ typedef struct { gint exit_code; gint timeout_delay; gboolean modal; + gint attach; } ZenityData; typedef enum { -- cgit From 8888114fed6e65da0bf9d4a1642a0b591f14d32f Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 25 Sep 2013 09:34:25 -0300 Subject: Added combobox support on forms dialog --- src/forms.c | 71 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/option.c | 34 +++++++++++++++++++++++++++++ src/zenity.h | 4 +++- 3 files changed, 108 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/forms.c b/src/forms.c index 0bac6679..59c6461f 100644 --- a/src/forms.c +++ b/src/forms.c @@ -44,6 +44,46 @@ static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath * } } +static GtkWidget * +zenity_forms_create_and_fill_combo (ZenityFormsData *forms_data, int combo_number) +{ + GtkListStore *list_store; + GtkWidget *combo_box; + GtkCellRenderer *renderer; + gchar *combo_values; + + list_store = gtk_list_store_new (1, G_TYPE_STRING); + + if (forms_data->combo_values) { + combo_values = g_slist_nth_data (forms_data->combo_values, combo_number); + if (combo_values) { + gchar **row_values = g_strsplit_set (combo_values, "|", -1); + if (row_values) { + gint i = 0; + GtkTreeIter iter; + gchar *row = row_values[i]; + + while (row != NULL) { + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, 0, row, -1); + row = row_values[++i]; + } + g_strfreev (row_values); + } + g_free (combo_values); + } + } + + combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); + g_object_unref (G_OBJECT (list_store)); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL); + + return combo_box; +} + static GtkWidget * zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, int list_number, gchar *header) @@ -141,6 +181,7 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) gint number_of_widgets = g_slist_length (forms_data->list); int list_count = 0; + int combo_count = 0; int i = 0; zen_data = data; @@ -271,6 +312,21 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) 0); list_count++; break; + case ZENITY_FORMS_COMBO: + zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count); + gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); + gtk_table_attach (GTK_TABLE (table), + GTK_WIDGET (zenity_value->forms_widget), + 1, + 2, + i, + i+1, + GTK_EXPAND | GTK_FILL, + GTK_EXPAND | GTK_FILL, + 0, + 0); + combo_count++; + break; default: zenity_value->forms_widget = gtk_entry_new(); gtk_table_attach (GTK_TABLE (table), @@ -307,7 +363,10 @@ zenity_forms_dialog_output (ZenityFormsData *forms_data) guint day, year, month; GDate *date = NULL; gchar time_string[128]; + gchar *combo_value = NULL; GtkTreeSelection *selection; + GtkListStore *list_store; + GtkTreeIter iter; for (tmp = forms_data->list; tmp; tmp = tmp->next) { ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; @@ -340,6 +399,18 @@ zenity_forms_dialog_output (ZenityFormsData *forms_data) g_date_strftime (time_string, 127, forms_data->date_format, date); g_print ("%s", time_string); break; + case ZENITY_FORMS_COMBO: + if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (zenity_value->forms_widget), &iter)) { + list_store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (zenity_value->forms_widget))); + gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, 0, &combo_value, -1); + g_object_unref (G_OBJECT (list_store)); + + g_print ("%s", combo_value); + g_free (combo_value); + } else + g_print (" "); + break; + } if (tmp->next != NULL) g_print("%s", forms_data->separator); diff --git a/src/option.c b/src/option.c index 7658e8b4..d3004fe2 100644 --- a/src/option.c +++ b/src/option.c @@ -138,6 +138,7 @@ static gchar *zenity_forms_date_format; //static gchar *zenity_forms_hide_column; static gchar **zenity_forms_list_values; static gchar **zenity_forms_column_values; +static gchar **zenity_forms_combo_values; /* Miscelaneus Options */ static gboolean zenity_misc_about; @@ -1064,6 +1065,24 @@ static GOptionEntry forms_dialog_options[] = { N_("List of values for columns"), N_("List of values separated by |") }, + { + "add-combo", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_("Add a new combo box in forms dialog"), + N_("Combo box field name") + }, + { + "combo-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_combo_values, + N_("List of values for combo box"), + N_("List of values separated by |") + }, /* TODO: Implement how to hide specifc column { "hide-column", @@ -1246,6 +1265,8 @@ zenity_option_free (void) { g_free (zenity_forms_date_format); if (zenity_forms_list_values) g_strfreev (zenity_forms_list_values); + if (zenity_forms_combo_values) + g_strfreev (zenity_forms_combo_values); if (zenity_forms_column_values) g_strfreev (zenity_forms_column_values); // if (zenity_forms_hide_column) @@ -1321,6 +1342,8 @@ zenity_forms_callback (const gchar *option_name, forms_value->type = ZENITY_FORMS_PASSWORD; else if (g_strcmp0 (option_name, "--add-list") == 0) forms_value->type = ZENITY_FORMS_LIST; + else if (g_strcmp0 (option_name, "--add-combo") == 0) + forms_value->type = ZENITY_FORMS_COMBO; results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); @@ -2018,6 +2041,14 @@ zenity_forms_post_callback (GOptionContext *context, } else results->forms_data->column_values = g_slist_append (NULL, "column"); + if (zenity_forms_combo_values) { + i = 0; + values = zenity_forms_combo_values[0]; + while (values != NULL) { + results->forms_data->combo_values = g_slist_append (results->forms_data->combo_values, values); + values = zenity_forms_combo_values[++i]; + } + } if (zenity_forms_date_format) results->forms_data->date_format = zenity_forms_date_format; else @@ -2035,6 +2066,9 @@ zenity_forms_post_callback (GOptionContext *context, if (zenity_forms_column_values) zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_column_values), ERROR_SUPPORT); + if (zenity_forms_combo_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_combo_values), + ERROR_SUPPORT); if (zenity_forms_show_header) zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_show_header), ERROR_SUPPORT); diff --git a/src/zenity.h b/src/zenity.h index 501109a4..acde39bf 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -151,6 +151,7 @@ typedef struct { GSList *list_widgets; GSList *list_values; GSList *column_values; + GSList *combo_values; gchar *dialog_text; gchar *separator; gchar *date_format; @@ -162,7 +163,8 @@ typedef enum { ZENITY_FORMS_ENTRY, ZENITY_FORMS_PASSWORD, ZENITY_FORMS_CALENDAR, - ZENITY_FORMS_LIST + ZENITY_FORMS_LIST, + ZENITY_FORMS_COMBO } ZenityFormsType; typedef struct { -- cgit From 80bc8ce643979fec201c4ebd5cd6405b6310357f Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 10 Oct 2013 16:52:38 -0300 Subject: But #702535 - List box doesn't expand to fill window --- src/zenity.ui | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index ee89093a..7c0ab1fb 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1021,6 +1021,7 @@ True True in + True True -- cgit From b0fc720fe4584530d1090cd3e9175905e6381c85 Mon Sep 17 00:00:00 2001 From: Berislav Kovacki Date: Sat, 23 Nov 2013 16:44:26 -0200 Subject: Bug #534935 Need hability to specify default answer in --question dialog --- src/msg.c | 2 +- src/option.c | 12 ++++++++++++ src/zenity.h | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 53f8a5df..f4d5e7a9 100644 --- a/src/msg.c +++ b/src/msg.c @@ -36,7 +36,7 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_CANCEL); ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); - gtk_widget_grab_focus (ok_button); + gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button); if (data->cancel_label) { gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); diff --git a/src/option.c b/src/option.c index d3004fe2..46112d04 100644 --- a/src/option.c +++ b/src/option.c @@ -100,6 +100,7 @@ static gboolean zenity_progress_no_cancel; /* Question Dialog Options */ static gboolean zenity_question_active; +static gboolean zenity_question_default_cancel; /* Text Dialog Options */ static gboolean zenity_text_active; @@ -797,6 +798,15 @@ static GOptionEntry question_options[] = { &zenity_general_dialog_no_markup, N_("Do not enable pango markup") }, + { + "default-cancel", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_question_default_cancel, + N_("Give cancel button focus by default"), + NULL + }, { NULL } @@ -1507,6 +1517,7 @@ zenity_question_pre_callback (GOptionContext *context, GError **error) { zenity_question_active = FALSE; + zenity_question_default_cancel = FALSE; return TRUE; } @@ -1913,6 +1924,7 @@ zenity_question_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->default_cancel = zenity_question_default_cancel; } return TRUE; diff --git a/src/zenity.h b/src/zenity.h index acde39bf..52c29df5 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -66,6 +66,7 @@ typedef struct { MsgMode mode; gboolean no_wrap; gboolean no_markup; + gboolean default_cancel; } ZenityMsgData; typedef struct { -- cgit From 4681d74c02e49c2f3af1da5ce9457807dbcf3f9e Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Sat, 23 Nov 2013 20:32:51 -0200 Subject: Bug #600533 zenity --text-info should have an auto scroll option This is a request to add a auto-scroll option. For now it's only works when text-info is getting the text from stdin. Example usage: cat file.txt | zenity --text-info --auto-scroll --- src/option.c | 13 +++++++++++++ src/text.c | 19 ++++++++++++++----- src/zenity.h | 1 + 3 files changed, 28 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 46112d04..fb25f37c 100644 --- a/src/option.c +++ b/src/option.c @@ -106,6 +106,8 @@ static gboolean zenity_question_default_cancel; static gboolean zenity_text_active; static gchar *zenity_text_font; static gchar *zenity_text_checkbox; +static gboolean zenity_text_auto_scroll; + #ifdef HAVE_WEBKITGTK static gboolean zenity_text_enable_html; static gchar *zenity_text_url; @@ -878,6 +880,15 @@ static GOptionEntry text_options[] = { N_("URL") }, #endif + { + "auto-scroll", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_auto_scroll, + N_("Auto scroll the text to the end. Only when text is captured from stdin"), + NULL + }, { NULL } @@ -1531,6 +1542,7 @@ zenity_text_pre_callback (GOptionContext *context, zenity_text_active = FALSE; zenity_text_font = NULL; zenity_text_checkbox = NULL; + zenity_text_auto_scroll = FALSE; #ifdef HAVE_WEBKITGTK zenity_text_enable_html = FALSE; zenity_text_url = NULL; @@ -1944,6 +1956,7 @@ zenity_text_post_callback (GOptionContext *context, results->text_data->no_wrap = zenity_general_dialog_no_wrap; results->text_data->font = zenity_text_font; results->text_data->checkbox = zenity_text_checkbox; + results->text_data->auto_scroll = zenity_text_auto_scroll; #ifdef HAVE_WEBKITGTK results->text_data->html = zenity_text_enable_html; results->text_data->url = zenity_text_url; diff --git a/src/text.c b/src/text.c index 056ad28b..fda60dcd 100644 --- a/src/text.c +++ b/src/text.c @@ -134,11 +134,13 @@ zenity_text_handle_stdin (GIOChannel *channel, gpointer data) { static GtkTextBuffer *buffer; + static GtkTextView *text_view; gchar buf[1024]; gsize len; - buffer = GTK_TEXT_BUFFER (data); + text_view = GTK_TEXT_VIEW (data); + buffer = gtk_text_view_get_buffer (text_view); if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) { GError *error = NULL; @@ -179,6 +181,12 @@ zenity_text_handle_stdin (GIOChannel *channel, } else { gtk_text_buffer_insert (buffer, &end, buf, len); } + if (zen_text_data->auto_scroll) { + GtkTextMark *mark = NULL; + mark = gtk_text_buffer_get_insert (buffer); + if (mark != NULL) + gtk_text_view_scroll_to_mark (text_view, mark, 0.0, FALSE, 0, 0); + } } } @@ -186,14 +194,14 @@ zenity_text_handle_stdin (GIOChannel *channel, } static void -zenity_text_fill_entries_from_stdin (GtkTextBuffer *text_buffer) +zenity_text_fill_entries_from_stdin (GtkTextView *text_view) { GIOChannel *channel; channel = g_io_channel_unix_new (0); g_io_channel_set_encoding (channel, NULL, NULL); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_buffer); + g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view); } void @@ -233,7 +241,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_text_dialog_response), data); - + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -257,7 +265,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->uri) zenity_util_fill_file_buffer (text_buffer, text_data->uri); else - zenity_text_fill_entries_from_stdin (GTK_TEXT_BUFFER (text_buffer)); + zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW(text_view)); if (text_data->editable) zen_text_data->buffer = text_buffer; @@ -326,6 +334,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_widget_show (GTK_WIDGET (web_kit)); } #endif + zenity_util_show_dialog (dialog, data->attach); g_object_unref (builder); diff --git a/src/zenity.h b/src/zenity.h index 52c29df5..6e1b6875 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -110,6 +110,7 @@ typedef struct { gchar *uri; gboolean editable; gboolean no_wrap; + gboolean auto_scroll; gchar *font; GtkTextBuffer *buffer; gchar *checkbox; -- cgit From cdef9c8fa16fd3ab9c4790c328285de15a0dfcd0 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Nov 2013 22:27:10 -0200 Subject: Fixing bug #712616 --- src/password.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 915ea3d9..84cca21e 100644 --- a/src/password.c +++ b/src/password.c @@ -61,7 +61,15 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data FALSE, FALSE, 12); - label = gtk_label_new(_("Type your password")); + + /* Checks if username has been passed as a parameter */ + gchar *title_text = N_("Type your password"); + + if(password_data->username) + title_text = N_("Type your username and password"); + + label = gtk_label_new(title_text); + gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, -- cgit From 3d43541db7b4f2f1ce51356a2394aec125a48a2a Mon Sep 17 00:00:00 2001 From: Daniel Mustieles Date: Thu, 23 Jan 2014 12:55:03 +0100 Subject: Updated FSF's address --- src/option.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src') diff --git a/src/option.h b/src/option.h index ddca9a99..d77c5631 100644 --- a/src/option.h +++ b/src/option.h @@ -14,9 +14,7 @@ * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. + * License along with this library; if not, see . * * Authors: Glynn Foster * Lucas Rocha -- cgit From 797ef3f1bd0dd2dea62d912af1340fbeb248e7bb Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 16 May 2014 18:05:59 -0300 Subject: Remove deprecated methods. This remove deprecated methods in about dialog. Also remove the help button in the about dialog, since wasn't being used (due the deprecated methods) and keep it just make the UI ugly. --- src/about.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index ab82068a..486b6416 100644 --- a/src/about.c +++ b/src/about.c @@ -39,7 +39,6 @@ static GtkWidget *dialog; -static void zenity_about_display_help (GtkWidget *widget, gpointer data); static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); /* Sync with the people in the THANKS file */ @@ -258,7 +257,6 @@ void zenity_about (ZenityData *data) { GdkPixbuf *logo; - GtkWidget *help_button; char *license_trans; @@ -288,18 +286,6 @@ zenity_about (ZenityData *data) zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - help_button = gtk_button_new_from_stock (GTK_STOCK_HELP); - - g_signal_connect (G_OBJECT (help_button), "clicked", - G_CALLBACK (zenity_about_display_help), data); - - gtk_widget_show (help_button); - - gtk_box_pack_end (GTK_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), - help_button, FALSE, TRUE, 0); - gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (gtk_dialog_get_action_area (GTK_DIALOG (dialog))), - help_button, TRUE); - g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_about_dialog_response), data); @@ -330,9 +316,3 @@ zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) gtk_main_quit (); } - -static void -zenity_about_display_help (GtkWidget *widget, gpointer data) -{ - zenity_util_show_help (NULL); -} -- cgit From 5ce972d784e64156dcab50676ceb2a70e184106e Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 20 May 2014 10:35:39 -0300 Subject: Removing some deprecated classes in zenity GtkBuilder file --- src/zenity.ui | 496 ++++++++++++++++++++++++++++++---------------------------- 1 file changed, 254 insertions(+), 242 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 7c0ab1fb..d72cc57a 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,12 +1,231 @@ + - + 100 1 1 + + True + False + 5 + Adjust the scale value + 300 + 100 + dialog + + + + True + False + + + True + False + end + + + gtk-cancel + True + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + False + True + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + 5 + 6 + + + True + False + 0 + 4 + Adjust the scale value + + + False + False + 0 + + + + + True + True + adjustment1 + 0 + right + + + True + True + 1 + + + + + False + True + 1 + + + + + + zenity_scale_cancel_button + zenity_scale_ok_button + + + + False + 5 + Text View + center + 300 + 200 + dialog + + + + True + False + 2 + + + True + False + end + + + gtk-cancel + True + True + False + True + + + False + False + 0 + + + + + gtk-ok + True + True + True + True + True + right + + + False + False + 1 + + + + + False + True + end + 0 + + + + + True + False + 5 + + + True + True + etched-in + + + True + True + 2 + 2 + False + word + 2 + 2 + textbuffer1 + + + + + True + True + 0 + + + + + True + False + 0 + True + + + False + False + 1 + + + + + True + True + 1 + + + + + + zenity_text_cancel_button + zenity_text_close_button + + False 5 @@ -31,7 +250,6 @@ True True False - False True @@ -48,7 +266,6 @@ True True False - False True @@ -164,7 +381,6 @@ True True False - False True @@ -181,7 +397,6 @@ True True False - False True @@ -270,7 +485,6 @@ True True False - False True @@ -304,7 +518,7 @@ False 0 gtk-dialog-error - 6 + 6 True @@ -367,7 +581,6 @@ True True True - False True @@ -382,7 +595,6 @@ True True True - False True @@ -424,6 +636,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -476,7 +718,6 @@ True True False - False True @@ -505,7 +746,7 @@ False 0 gtk-dialog-info - 6 + 6 True @@ -565,7 +806,6 @@ True True False - False True @@ -583,7 +823,6 @@ True True False - False True @@ -683,7 +922,7 @@ 0 0 gtk-dialog-question - 6 + 6 False @@ -716,229 +955,6 @@ - - True - False - 5 - Adjust the scale value - 300 - 100 - dialog - - - - True - False - - - True - False - end - - - gtk-cancel - True - True - True - False - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - False - False - True - - - False - False - 1 - - - - - False - True - end - 0 - - - - - True - False - 5 - 6 - - - True - False - 0 - 4 - Adjust the scale value - - - False - False - 0 - - - - - True - True - adjustment1 - 0 - right - - - True - True - 1 - - - - - False - True - 1 - - - - - - zenity_scale_cancel_button - zenity_scale_ok_button - - - - False - 5 - Text View - center - 300 - 200 - dialog - - - - True - False - 2 - - - True - False - end - - - gtk-cancel - True - True - False - False - True - - - False - False - 0 - - - - - gtk-ok - True - True - True - True - False - True - right - - - False - False - 1 - - - - - False - True - end - 0 - - - - - True - False - 5 - - - True - True - etched-in - - - True - True - 2 - 2 - False - word - 2 - 2 - textbuffer1 - - - - - True - True - 0 - - - - - True - False - False - 0 - True - - - False - False - 1 - - - - - True - True - 1 - - - - - - zenity_text_cancel_button - zenity_text_close_button - - False 5 @@ -964,7 +980,6 @@ True True False - False True @@ -980,7 +995,6 @@ True True False - False True @@ -1021,7 +1035,6 @@ True True in - True True @@ -1078,7 +1091,6 @@ True True False - False True @@ -1108,7 +1120,7 @@ 0 0 gtk-dialog-warning - 6 + 6 False -- cgit From 86f6329fc18ca284c51c9f718fbe216bec903831 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 20 May 2014 10:50:04 -0300 Subject: Fixing deprecated classes in GtkBuilder --- src/zenity.ui | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index d72cc57a..61bea5e5 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -17,11 +17,11 @@ dialog - + True False - + True False end @@ -122,12 +122,12 @@ dialog - + True False 2 - + True False end @@ -234,12 +234,12 @@ dialog - + True False 2 - + True False end @@ -365,12 +365,12 @@ dialog - + True False 2 - + True False end @@ -469,12 +469,12 @@ dialog - + True False 14 - + True False end @@ -566,12 +566,12 @@ 5 normal - + True False 2 - + True False end @@ -702,12 +702,12 @@ dialog - + True False 14 - + True False end @@ -790,12 +790,12 @@ dialog - + True False 2 - + True False end @@ -892,12 +892,12 @@ dialog - + True False 14 - + True False end @@ -965,11 +965,11 @@ dialog - + True False - + True False end @@ -1035,6 +1035,7 @@ True True in + True True @@ -1074,12 +1075,12 @@ dialog - + True False 14 - + True False end -- cgit From ec0c2f3292b3db0fdad7f02ed068a97b66f7a2ea Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 20 May 2014 16:05:32 -0300 Subject: Add the --ellipsize option to info, error, warning and question dialogs This option will help people who need to add huge texts in their dialogs and the window size get's very huge due amount of size that GtkLabel requests --- src/msg.c | 4 ++++ src/option.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- src/zenity.h | 1 + 3 files changed, 48 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index f4d5e7a9..f5d4dc94 100644 --- a/src/msg.c +++ b/src/msg.c @@ -159,6 +159,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); } + if (msg_data->ellipsize) + gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); + if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); @@ -176,6 +179,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } + static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { diff --git a/src/option.c b/src/option.c index fb25f37c..1b2bb5c9 100644 --- a/src/option.c +++ b/src/option.c @@ -47,6 +47,7 @@ static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; static gboolean zenity_general_modal; static gint zenity_general_attach; +static gboolean zenity_general_dialog_ellipsize; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; @@ -389,6 +390,14 @@ static GOptionEntry error_options[] = { &zenity_general_dialog_no_markup, N_("Do not enable pango markup") }, + { + "ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + }, { NULL } @@ -439,6 +448,14 @@ static GOptionEntry info_options[] = { &zenity_general_dialog_no_markup, N_("Do not enable pango markup") }, + { + "ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + }, { NULL } @@ -809,6 +826,14 @@ static GOptionEntry question_options[] = { N_("Give cancel button focus by default"), NULL }, + { + "ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + }, { NULL } @@ -939,6 +964,14 @@ static GOptionEntry warning_options[] = { &zenity_general_dialog_no_markup, N_("Do not enable pango markup") }, + { + "ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + }, { NULL } @@ -1646,6 +1679,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->cancel_label = zenity_general_cancel_button; results->data->modal = zenity_general_modal; results->data->attach = zenity_general_attach; + return TRUE; } @@ -1741,6 +1775,7 @@ zenity_error_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_ERROR; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; } return TRUE; @@ -1760,6 +1795,7 @@ zenity_info_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_INFO; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; } return TRUE; @@ -1936,6 +1972,7 @@ zenity_question_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; results->msg_data->default_cancel = zenity_question_default_cancel; } @@ -1983,6 +2020,7 @@ zenity_warning_post_callback (GOptionContext *context, results->msg_data->mode = ZENITY_MSG_WARNING; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; } return TRUE; @@ -2405,10 +2443,13 @@ zenity_option_parse (gint argc, gchar **argv) if(results->mode == MODE_FILE || results->mode == MODE_ERROR || results->mode == MODE_WARNING || results->mode == MODE_INFO) zenity_option_error (zenity_option_get_name (general_options, &zenity_general_cancel_button), ERROR_SUPPORT); - if (zenity_general_dialog_no_wrap) if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); - + + if (zenity_general_dialog_ellipsize) + if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) + zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_ellipsize), ERROR_SUPPORT); + return results; } diff --git a/src/zenity.h b/src/zenity.h index 6e1b6875..d3606cd4 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -67,6 +67,7 @@ typedef struct { gboolean no_wrap; gboolean no_markup; gboolean default_cancel; + gboolean ellipsize; } ZenityMsgData; typedef struct { -- cgit From c4895ee9a0f3e6ca5aa4113b4bbc3ced0f3d6067 Mon Sep 17 00:00:00 2001 From: Piotr DrÄ…g Date: Tue, 20 May 2014 21:33:52 +0200 Subject: Improve grammar in new translatable strings --- src/option.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 1b2bb5c9..f5c84d54 100644 --- a/src/option.c +++ b/src/option.c @@ -396,7 +396,7 @@ static GOptionEntry error_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_ellipsize, - N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, { NULL @@ -454,7 +454,7 @@ static GOptionEntry info_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_ellipsize, - N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, { NULL @@ -832,7 +832,7 @@ static GOptionEntry question_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_ellipsize, - N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, { NULL @@ -970,7 +970,7 @@ static GOptionEntry warning_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_ellipsize, - N_("Enable ellipsize in dialog text. This fix the high window size with big texts") + N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, { NULL -- cgit From e5eb127e9779b9a58e53b1a7d268b81284ebd241 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 29 May 2014 17:51:46 -0300 Subject: Bug #670496 and #673643 This fix the size of GtkLabel width when you have a big text in the dialog. --- src/msg.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index f5d4dc94..f287f25d 100644 --- a/src/msg.c +++ b/src/msg.c @@ -27,7 +27,7 @@ #include "util.h" static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); - +static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { @@ -161,6 +161,9 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->ellipsize) gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); + else + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); @@ -179,6 +182,11 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } +static void +zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) +{ + gtk_widget_set_size_request (widget, allocation->width, -1); +} static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) -- cgit From 9d03f0d006ad3080d6bbb91bff6ea5e71c7c98a2 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 Aug 2014 14:31:57 +0200 Subject: Bug 733870 - Segmentation fault on zenity --notification This fix a problem when user calls --hint=urgency without specify a :NOTIFY_URGENCY --- src/notification.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 3a552026..d5631573 100644 --- a/src/notification.c +++ b/src/notification.c @@ -139,10 +139,14 @@ zenity_notification_set_hint(gpointer key, gpointer value, gpointer user_data) } else if ((g_ascii_strcasecmp ("x", hint_name) == 0) || (g_ascii_strcasecmp ("y", hint_name) == 0)) { /* int hints */ + if (string_value == NULL) + string_value = ""; int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0); hint_value = g_variant_new_int32 (int_value); } else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) { /* byte hints */ + if (string_value == NULL) + string_value = ""; byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0); hint_value = g_variant_new_byte (byte_value); } else { -- cgit From fc76e0c19be22d47cf6044ca591f0e01010a1a80 Mon Sep 17 00:00:00 2001 From: Emilio Pozuelo Monfort Date: Sat, 27 Feb 2010 15:32:23 +0100 Subject: Don't quit zenity when the input stream is closed When using --listen for a notification, zenity quits when the stream ends. This makes it impossible to read commands from a pipe as in `echo icon:info | zenity --notification --listen'. https://bugzilla.gnome.org/show_bug.cgi?id=525596 --- src/notification.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index d5631573..06ac1dde 100644 --- a/src/notification.c +++ b/src/notification.c @@ -295,8 +295,6 @@ zenity_notification_handle_stdin (GIOChannel *channel, if ((condition & G_IO_HUP) != 0) { g_io_channel_shutdown (channel, TRUE, NULL); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); return FALSE; } -- cgit From 673550b6d326e111867fa78ba4d796045715202e Mon Sep 17 00:00:00 2001 From: Scott Pakin Date: Tue, 5 Aug 2014 15:22:12 -0600 Subject: Added time-remaining support to progress bars Introduced a --time-remaining command-line option that uses the time and percent complete to extrapolate the time remaining until progress reaches 100%. --- src/option.c | 17 +++++++++++++++++ src/progress.c | 37 +++++++++++++++++++++++++++++++++++++ src/zenity.h | 1 + src/zenity.ui | 12 ++++++++++++ 4 files changed, 67 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index f5c84d54..c1e3a77f 100644 --- a/src/option.c +++ b/src/option.c @@ -98,6 +98,7 @@ static gboolean zenity_progress_pulsate; static gboolean zenity_progress_auto_close; static gboolean zenity_progress_auto_kill; static gboolean zenity_progress_no_cancel; +static gboolean zenity_progress_time_remaining; /* Question Dialog Options */ static gboolean zenity_question_active; @@ -767,6 +768,15 @@ static GOptionEntry progress_options[] = { N_("Hide Cancel button"), NULL }, + { + "time-remaining", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_time_remaining, + N_("Estimate when progress will reach 100%"), + NULL + }, { NULL } @@ -1551,6 +1561,7 @@ zenity_progress_pre_callback (GOptionContext *context, zenity_progress_auto_close = FALSE; zenity_progress_auto_kill = FALSE; zenity_progress_no_cancel = FALSE; + zenity_progress_time_remaining = FALSE; return TRUE; } @@ -1935,6 +1946,7 @@ zenity_progress_post_callback (GOptionContext *context, results->progress_data->autokill = zenity_progress_auto_kill; results->progress_data->percentage = zenity_progress_percentage; results->progress_data->no_cancel = zenity_progress_no_cancel; + results->progress_data->time_remaining = zenity_progress_time_remaining; } else { if (zenity_progress_pulsate) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_pulsate), @@ -1951,9 +1963,14 @@ zenity_progress_post_callback (GOptionContext *context, if (zenity_progress_auto_kill) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_kill), ERROR_SUPPORT); + if (zenity_progress_no_cancel) zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_no_cancel), ERROR_SUPPORT); + + if (zenity_progress_time_remaining) + zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_time_remaining), + ERROR_SUPPORT); } return TRUE; diff --git a/src/progress.c b/src/progress.c index cbffe08e..00544873 100644 --- a/src/progress.c +++ b/src/progress.c @@ -29,6 +29,7 @@ #include #include #include +#include #include "zenity.h" #include "util.h" @@ -72,6 +73,39 @@ zenity_progress_pulsate_start (GObject *progress_bar) } } +static void +zenity_progress_update_time_remaining (ZenityProgressData *progress_data) +{ + static GObject *progress_time = NULL; + static time_t start_time = (time_t)(-1); + float percentage = progress_data->percentage; + + if (progress_time == NULL) + progress_time = gtk_builder_get_object (builder, "zenity_progress_time"); + if (start_time == (time_t)(-1) || percentage <= 0.0 || percentage >= 100.0) { + start_time = time(NULL); + gtk_label_set_text (GTK_LABEL (progress_time), ""); + } else { + time_t current_time = time (NULL); + time_t elapsed_time = current_time - start_time; + time_t total_time = (time_t) (100.0*elapsed_time/progress_data->percentage); + time_t remaining_time = total_time - elapsed_time; + gulong hours, minutes, seconds; + gchar *remaining_message; + + seconds = (gulong) (remaining_time%60); + remaining_time /= 60; + minutes = (gulong) (remaining_time%60); + remaining_time /= 60; + hours = (gulong) remaining_time; + + remaining_message = g_strdup_printf (_("Time remaining: %lu:%02lu:%02lu"), + hours, minutes, seconds); + gtk_label_set_text (GTK_LABEL (progress_time), remaining_message); + g_free (remaining_message); + } +} + static gboolean zenity_progress_handle_stdin (GIOChannel *channel, GIOCondition condition, @@ -160,6 +194,9 @@ zenity_progress_handle_stdin (GIOChannel *channel, progress_data->percentage = percentage; + if (progress_data->time_remaining == TRUE) + zenity_progress_update_time_remaining (progress_data); + if (percentage == 100) { GObject *button; diff --git a/src/zenity.h b/src/zenity.h index d3606cd4..4cf7a044 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -105,6 +105,7 @@ typedef struct { gboolean autokill; gdouble percentage; gboolean no_cancel; + gboolean time_remaining; } ZenityProgressData; typedef struct { diff --git a/src/zenity.ui b/src/zenity.ui index 61bea5e5..5b40e9e6 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -870,6 +870,18 @@ 1 + + + True + False + 0 + + + False + False + 2 + + False -- cgit From 8098bb3dd7c6e1742fb0c8ac349ec35333b15a25 Mon Sep 17 00:00:00 2001 From: Kernc Date: Sat, 30 Aug 2014 16:58:15 +0200 Subject: Allow --text-info to load resources from absolute file:// URIs --- src/text.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index fda60dcd..e5ba15e9 100644 --- a/src/text.c +++ b/src/text.c @@ -59,7 +59,7 @@ zenity_configure_webkit (WebKitWebView *web_view) g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL); /* unexisting property? g_object_set(G_OBJECT(settings), "enable-dns-prefetching", FALSE, NULL);*/ g_object_set(G_OBJECT(settings), "enable-dom-paste", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", TRUE, NULL); /* unexisting property? g_object_set(G_OBJECT(settings), "enable-frame-flattening", FALSE, NULL);*/ /* unexisting property? g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL);*/ g_object_set(G_OBJECT(settings), "enable-html5-database", FALSE, NULL); @@ -319,7 +319,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_text_buffer_get_start_iter (text_buffer, &start_iter); gtk_text_buffer_get_end_iter (text_buffer, &end_iter); content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE); - webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", NULL); + webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", "file:///"); g_free (content); } -- cgit From 6ac663ea05f00aa42d2aa620968e26e525487201 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 16:05:31 +0200 Subject: Fixing remain g_timeout_add Finish switch g_timeout_add for g_timeout_add_seconds --- src/color.c | 6 +++--- src/password.c | 6 +++--- src/progress.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/color.c b/src/color.c index b6a6b121..633e3427 100644 --- a/src/color.c +++ b/src/color.c @@ -82,9 +82,9 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, - (GSourceFunc) zenity_util_timeout_handle, - dialog); + g_timeout_add_seconds (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + dialog); } gtk_main(); diff --git a/src/password.c b/src/password.c index 84cca21e..a6dceda2 100644 --- a/src/password.c +++ b/src/password.c @@ -152,9 +152,9 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add (data->timeout_delay * 1000, - (GSourceFunc) zenity_util_timeout_handle, - dialog); + g_timeout_add_seconds (data->timeout_delay * 1000, + (GSourceFunc) zenity_util_timeout_handle, + dialog); } gtk_main(); } diff --git a/src/progress.c b/src/progress.c index 00544873..1963f16e 100644 --- a/src/progress.c +++ b/src/progress.c @@ -67,9 +67,9 @@ static void zenity_progress_pulsate_start (GObject *progress_bar) { if (pulsate_timeout == -1) { - pulsate_timeout = g_timeout_add (100, - zenity_progress_pulsate_progress_bar, - progress_bar); + pulsate_timeout = g_timeout_add_seconds (100, + zenity_progress_pulsate_progress_bar, + progress_bar); } } -- cgit From b44b2fb33dac0618e355f8cd5c46be0b3d13eadc Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 16:32:14 +0200 Subject: Fixing g_timeout_add calls --- src/color.c | 2 +- src/password.c | 2 +- src/progress.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/color.c b/src/color.c index 633e3427..e3b8a428 100644 --- a/src/color.c +++ b/src/color.c @@ -82,7 +82,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay * 1000, + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } diff --git a/src/password.c b/src/password.c index a6dceda2..ff254fde 100644 --- a/src/password.c +++ b/src/password.c @@ -152,7 +152,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data zenity_util_show_dialog (dialog, data->attach); if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay * 1000, + g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } diff --git a/src/progress.c b/src/progress.c index 1963f16e..185da2f2 100644 --- a/src/progress.c +++ b/src/progress.c @@ -67,7 +67,7 @@ static void zenity_progress_pulsate_start (GObject *progress_bar) { if (pulsate_timeout == -1) { - pulsate_timeout = g_timeout_add_seconds (100, + pulsate_timeout = g_timeout_add (100, zenity_progress_pulsate_progress_bar, progress_bar); } -- cgit From 15e2759668a1d17bb1570a890bf294aaa796cbf5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Oct 2014 18:30:35 +0200 Subject: Bug #685051 Adding --mid-search option to --list This will enable users to find a row with a text matching the middle of the row. Consider the following list: Little piggy one Little piggy two Little piggy three As a user I would expect that entering 'th' would focus the last row, because it's the first one that contains 'th' --- src/option.c | 15 +++++++++++++++ src/tree.c | 14 ++++++++++++++ src/zenity.h | 1 + 3 files changed, 30 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index c1e3a77f..e11c1ba9 100644 --- a/src/option.c +++ b/src/option.c @@ -83,6 +83,7 @@ static gchar *zenity_list_print_column; static gchar *zenity_list_hide_column; static gboolean zenity_list_hide_header; static gboolean zenity_list_imagelist; +static gboolean zenity_list_mid_search; #ifdef HAVE_LIBNOTIFY /* Notification Dialog Options */ @@ -651,6 +652,15 @@ static GOptionEntry list_options[] = { N_("Hides the column headers"), NULL }, + { + "mid-search", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_list_mid_search, + N_("Change list default search function searching for text in the middle, not on the beginning"), + NULL + }, { NULL } @@ -1531,6 +1541,7 @@ zenity_list_pre_callback (GOptionContext *context, zenity_list_hide_header = FALSE; zenity_list_print_column = NULL; zenity_list_hide_column = NULL; + zenity_list_mid_search = FALSE; return TRUE; } @@ -1876,6 +1887,7 @@ zenity_list_post_callback (GOptionContext *context, results->tree_data->hide_column = zenity_list_hide_column; results->tree_data->hide_header = zenity_list_hide_header; results->tree_data->separator = zenity_general_separator; + results->tree_data->mid_search = zenity_list_mid_search; } else { if (zenity_list_columns) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_columns), @@ -1904,6 +1916,9 @@ zenity_list_post_callback (GOptionContext *context, if (zenity_list_hide_header) zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_header), ERROR_SUPPORT); + if (zenity_list_mid_search) + zenity_option_error (zenity_option_get_name (list_options, &zenity_list_mid_search), + ERROR_SUPPORT); } return TRUE; diff --git a/src/tree.c b/src/tree.c index a8b324f7..819f9a8e 100644 --- a/src/tree.c +++ b/src/tree.c @@ -298,6 +298,17 @@ zenity_tree_fill_entries (GtkTreeView *tree_view, } } +static gboolean +zenity_mid_search_func (GtkTreeModel *model, gint column, + const gchar *key, GtkTreeIter *iter, + gpointer search_data) +{ + gchar *iter_string = NULL; + gtk_tree_model_get (model, iter, column, &iter_string, -1); + return ! g_strrstr (g_utf8_strdown(iter_string, -1), + g_utf8_strdown(key, -1)) != NULL; +} + static void zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, @@ -564,6 +575,9 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) zenity_util_show_dialog (dialog, data->attach); + if (tree_data->mid_search) + gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree_view), (GtkTreeViewSearchEqualFunc) zenity_mid_search_func, model, NULL); + if(data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } diff --git a/src/zenity.h b/src/zenity.h index 4cf7a044..4b3214dd 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -132,6 +132,7 @@ typedef struct { gchar *separator; gboolean multi; gboolean editable; + gboolean mid_search; gchar *print_column; gchar *hide_column; const gchar **data; -- cgit From fad5a25dcd23a46bf2e25d001b008273cc4ea578 Mon Sep 17 00:00:00 2001 From: Kernc Date: Wed, 22 Oct 2014 00:14:24 +0200 Subject: Allow --text-info to load resources also from relative file:// URIs --- src/text.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index e5ba15e9..cf4aa63e 100644 --- a/src/text.c +++ b/src/text.c @@ -316,10 +316,19 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) } else { + gchar *cwd; + gchar *dirname; + gchar *dirname_uri; + dirname = text_data->uri ? g_path_get_dirname (text_data->uri) : g_strdup ("/"); + cwd = g_get_current_dir (); + dirname_uri = g_strconcat ("file://", cwd, "/", dirname, "/", NULL); + g_free (cwd); + g_free (dirname); gtk_text_buffer_get_start_iter (text_buffer, &start_iter); gtk_text_buffer_get_end_iter (text_buffer, &end_iter); content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE); - webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", "file:///"); + webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", dirname_uri); + g_free (dirname_uri); g_free (content); } -- cgit From 9fdac81d78db26fc10bc7c2370f9f67d723f272a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 22 Oct 2014 11:22:15 +0200 Subject: Bug #734049 - zenity --text-info chokes on some UTF-8 string text-info is now seting the text to UTF-8 properly --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index cf4aa63e..9f1041c3 100644 --- a/src/text.c +++ b/src/text.c @@ -199,7 +199,7 @@ zenity_text_fill_entries_from_stdin (GtkTextView *text_view) GIOChannel *channel; channel = g_io_channel_unix_new (0); - g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_encoding (channel, "UTF-8", NULL); g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view); } -- cgit From 210b073bcd4ee3d6d7a3c743ac407703cff60185 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 22 Oct 2014 15:16:22 +0200 Subject: Better sollution for wrap text This fix is a better sollution for info, error, warning and question dialog. Now the dialog wraps the text properly, and don't allocate a lot of height --- src/msg.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index f287f25d..49137e38 100644 --- a/src/msg.c +++ b/src/msg.c @@ -146,9 +146,17 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } - if (data->width > -1 || data->height > -1) + if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else + if (!msg_data->ellipsize) + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); + + if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -161,13 +169,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (msg_data->ellipsize) gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); - else - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - + if (msg_data->dialog_icon) gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); - + if (msg_data->no_wrap) gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); @@ -185,7 +190,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) { - gtk_widget_set_size_request (widget, allocation->width, -1); + gtk_widget_set_size_request (widget, allocation->width/2, -1); } static void -- cgit From b5460887fb2b37d1f7aa2edc5dc53b86152cfb2a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 22 Oct 2014 15:35:22 +0200 Subject: Bug #700249 - Progress dialog does not wrap --- src/msg.c | 13 ++++++------- src/progress.c | 20 ++++++++++++++++++-- src/zenity.ui | 47 +++++++++++++++++++++++++---------------------- 3 files changed, 49 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 49137e38..4132ae98 100644 --- a/src/msg.c +++ b/src/msg.c @@ -149,13 +149,12 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - if (data->width > -1) - gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); - else - if (!msg_data->ellipsize) - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else + if (!msg_data->ellipsize) + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); diff --git a/src/progress.c b/src/progress.c index 185da2f2..3fd2c2ef 100644 --- a/src/progress.c +++ b/src/progress.c @@ -262,6 +262,12 @@ zenity_progress_read_info (ZenityProgressData *progress_data) } } +static void +zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) +{ + gtk_widget_set_size_request (widget, allocation->width/2, -1); +} + void zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { @@ -281,6 +287,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) gtk_builder_connect_signals (builder, NULL); + text = gtk_builder_get_object (builder, "zenity_progress_text"); + dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_dialog")); @@ -295,6 +303,16 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->width > -1) { + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + } + else { + g_signal_connect_after (G_OBJECT (text), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); + g_signal_connect_after (G_OBJECT (progress_bar), "size-allocate", + G_CALLBACK (zenity_text_size_allocate), data); + } + if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -312,8 +330,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } - text = gtk_builder_get_object (builder, "zenity_progress_text"); - if (progress_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); diff --git a/src/zenity.ui b/src/zenity.ui index 5b40e9e6..32cff725 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,7 +1,7 @@ - - + + 100 1 @@ -21,7 +21,7 @@ True False - + True False end @@ -127,7 +127,7 @@ False 2 - + True False end @@ -239,7 +239,7 @@ False 2 - + True False end @@ -370,7 +370,7 @@ False 2 - + True False end @@ -474,7 +474,7 @@ False 14 - + True False end @@ -518,7 +518,7 @@ False 0 gtk-dialog-error - 6 + 6 True @@ -571,7 +571,7 @@ False 2 - + True False end @@ -666,6 +666,12 @@ + + + + + + @@ -707,7 +713,7 @@ False 14 - + True False end @@ -746,7 +752,7 @@ False 0 gtk-dialog-info - 6 + 6 True @@ -795,7 +801,7 @@ False 2 - + True False end @@ -851,6 +857,7 @@ False 0 Running... + True False @@ -885,7 +892,7 @@ False - True + False 1 @@ -909,7 +916,7 @@ False 14 - + True False end @@ -934,7 +941,7 @@ 0 0 gtk-dialog-question - 6 + 6 False @@ -981,7 +988,7 @@ True False - + True False end @@ -1047,15 +1054,11 @@ True True in - True True True True - - - @@ -1092,7 +1095,7 @@ False 14 - + True False end @@ -1133,7 +1136,7 @@ 0 0 gtk-dialog-warning - 6 + 6 False -- cgit From 5b0553e9ef4fcabebefbc510a088b009af73d4ab Mon Sep 17 00:00:00 2001 From: Kernc Date: Sat, 30 Aug 2014 17:07:52 +0200 Subject: Allow user to interact with --text-info --html WebView This commit changes the default --text-view behavior (when --html is also in effect) so that the clicked links are opened in the default browser (closes #732626). Additionally, a new option is introduced, --prevent-interaction, which disables above behavior. --- src/option.c | 12 ++++++++++++ src/text.c | 8 +++++++- src/zenity.h | 1 + 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index e11c1ba9..eb0a03a3 100644 --- a/src/option.c +++ b/src/option.c @@ -113,6 +113,7 @@ static gboolean zenity_text_auto_scroll; #ifdef HAVE_WEBKITGTK static gboolean zenity_text_enable_html; +static gboolean zenity_text_no_interaction; static gchar *zenity_text_url; #endif @@ -915,6 +916,15 @@ static GOptionEntry text_options[] = { N_("Enable html support"), NULL }, + { + "no-interaction", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_no_interaction, + N_("Do not enable user interaction with the WebView. Only works if you use --html option"), + NULL + }, { "url", '\0', @@ -1600,6 +1610,7 @@ zenity_text_pre_callback (GOptionContext *context, zenity_text_auto_scroll = FALSE; #ifdef HAVE_WEBKITGTK zenity_text_enable_html = FALSE; + zenity_text_no_interaction = FALSE; zenity_text_url = NULL; #endif return TRUE; @@ -2028,6 +2039,7 @@ zenity_text_post_callback (GOptionContext *context, results->text_data->auto_scroll = zenity_text_auto_scroll; #ifdef HAVE_WEBKITGTK results->text_data->html = zenity_text_enable_html; + results->text_data->no_interaction = zenity_text_no_interaction; results->text_data->url = zenity_text_url; #endif } else { diff --git a/src/text.c b/src/text.c index 9f1041c3..8f383b9c 100644 --- a/src/text.c +++ b/src/text.c @@ -23,6 +23,7 @@ #include "config.h" +#include #include "zenity.h" #include "util.h" @@ -114,6 +115,11 @@ zenity_text_webview_decision_request (WebKitWebView *webkitwebview, gpointer user_data) { webkit_web_policy_decision_ignore (policy_decision); + if (!zen_text_data->no_interaction && + webkit_web_navigation_action_get_reason (navigation_action) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { + g_app_info_launch_default_for_uri (webkit_web_navigation_action_get_original_uri(navigation_action), + NULL, NULL); + } return TRUE; } @@ -333,7 +339,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) } // We don't want user to click on links and navigate to another page. - // So, when page finish load, we block requests. + // So, when the page finishes loading, we take handle of the requests. g_signal_connect (G_OBJECT (web_kit), "document-load-finished", G_CALLBACK (zenity_text_webview_load_finished), NULL); diff --git a/src/zenity.h b/src/zenity.h index 4b3214dd..6390b007 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -118,6 +118,7 @@ typedef struct { gchar *checkbox; #ifdef HAVE_WEBKITGTK gboolean html; + gboolean no_interaction; gchar *url; #endif } ZenityTextData; -- cgit From 03a791abee3f604a0c0d918643157585fb55589b Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:17:38 +0000 Subject: src/zenity.ui: Changes when open with Glade 3.18.3 --- src/zenity.ui | 65 ++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 37 insertions(+), 28 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 32cff725..272c3bb2 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,7 +1,7 @@ + - - + 100 1 @@ -17,11 +17,11 @@ dialog - + True False - + True False end @@ -122,12 +122,12 @@ dialog - + True False 2 - + True False end @@ -234,12 +234,12 @@ dialog - + True False 2 - + True False end @@ -365,12 +365,12 @@ dialog - + True False 2 - + True False end @@ -469,12 +469,12 @@ dialog - + True False 14 - + True False end @@ -518,7 +518,7 @@ False 0 gtk-dialog-error - 6 + 6 True @@ -566,12 +566,12 @@ 5 normal - + True False 2 - + True False end @@ -672,6 +672,12 @@ + + + + + + @@ -708,12 +714,12 @@ dialog - + True False 14 - + True False end @@ -752,7 +758,7 @@ False 0 gtk-dialog-info - 6 + 6 True @@ -796,12 +802,12 @@ dialog - + True False 2 - + True False end @@ -911,12 +917,12 @@ dialog - + True False 14 - + True False end @@ -941,7 +947,7 @@ 0 0 gtk-dialog-question - 6 + 6 False @@ -984,11 +990,11 @@ dialog - + True False - + True False end @@ -1059,6 +1065,9 @@ True True True + + + @@ -1090,12 +1099,12 @@ dialog - + True False 14 - + True False end @@ -1136,7 +1145,7 @@ 0 0 gtk-dialog-warning - 6 + 6 False -- cgit From a1fe6eb88e1701319d007a7b1a469d1154bba5ab Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:30:20 +0000 Subject: src/zenity.ui: Do not use deprecated stock buttons --- src/zenity.ui | 57 +++++++++++++++++++++++---------------------------------- 1 file changed, 23 insertions(+), 34 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 272c3bb2..f1edfa19 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -27,12 +27,11 @@ end - gtk-cancel + Cancel True True True False - True False @@ -42,12 +41,11 @@ - gtk-ok + OK True True True False - True False @@ -133,11 +131,10 @@ end - gtk-cancel + Cancel True True False - True False @@ -147,12 +144,11 @@ - gtk-ok + OK True True True True - True right @@ -245,12 +241,11 @@ end - gtk-cancel + Cancel True True True False - True False @@ -260,13 +255,12 @@ - gtk-ok + OK True True True True False - True False @@ -376,12 +370,11 @@ end - gtk-cancel + Cancel True True True False - True False @@ -391,13 +384,12 @@ - gtk-ok + OK True True True True False - True False @@ -480,12 +472,11 @@ end - gtk-ok + OK True True True False - True False @@ -577,11 +568,10 @@ end - gtk-cancel + Cancel True True True - True False @@ -591,11 +581,10 @@ - gtk-ok + OK True True True - True False @@ -678,6 +667,12 @@ + + + + + + @@ -725,12 +720,11 @@ end - gtk-ok + OK True True True False - True False @@ -813,12 +807,11 @@ end - gtk-cancel + Cancel True True True False - True False @@ -828,14 +821,13 @@ - gtk-ok + OK True False True True True False - True False @@ -1000,12 +992,11 @@ end - gtk-cancel + Cancel True True True False - True False @@ -1015,12 +1006,11 @@ - gtk-ok + OK True True True False - True False @@ -1110,13 +1100,12 @@ end - gtk-ok + OK True True True True False - True False -- cgit From d26aa23e1dbc38be7709782d36df487ac59d0541 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:43:49 +0000 Subject: src/zenity.ui: Do not use deprecated stock images --- src/zenity.ui | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index f1edfa19..fed8c23b 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -508,7 +508,7 @@ True False 0 - gtk-dialog-error + dialog-error 6 @@ -751,7 +751,7 @@ True False 0 - gtk-dialog-info + dialog-information 6 @@ -938,7 +938,7 @@ False 0 0 - gtk-dialog-question + dialog-question 6 @@ -1133,7 +1133,7 @@ False 0 0 - gtk-dialog-warning + dialog-warning 6 -- cgit From 6fcbb80fd1b5268fbedcdb985ffa873a2e475840 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 04:57:05 +0000 Subject: Do not use an icon for Cancel/OK buttons GTK+ documentation recommends to not use an icons, but use "_OK"/"_Cancel" labels instead --- src/calendar.c | 4 ---- src/color.c | 4 ---- src/entry.c | 4 ---- src/fileselection.c | 4 ++-- src/forms.c | 4 ---- src/msg.c | 6 ------ src/password.c | 4 ++-- src/progress.c | 4 ---- src/scale.c | 4 ---- src/text.c | 4 ---- src/tree.c | 4 ---- 11 files changed, 4 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index e8967974..0166c500 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -95,15 +95,11 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } g_object_unref (builder); diff --git a/src/color.c b/src/color.c index e3b8a428..6820bbbe 100644 --- a/src/color.c +++ b/src/color.c @@ -60,16 +60,12 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->ok_label) { g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); g_object_unref (G_OBJECT (button)); } if (data->cancel_label) { g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); g_object_unref (G_OBJECT (button)); } diff --git a/src/entry.c b/src/entry.c index ca5e3752..efb2234d 100644 --- a/src/entry.c +++ b/src/entry.c @@ -87,15 +87,11 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } text = gtk_builder_get_object (builder, "zenity_entry_text"); diff --git a/src/fileselection.c b/src/fileselection.c index 9edbb6ae..30495558 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -52,8 +52,8 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) dialog = gtk_file_chooser_dialog_new (NULL, NULL, action, - GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, GTK_RESPONSE_OK, + _("_Cancel"), GTK_RESPONSE_CANCEL, + _("_OK"), GTK_RESPONSE_OK, NULL); gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), diff --git a/src/forms.c b/src/forms.c index 59c6461f..072908e6 100644 --- a/src/forms.c +++ b/src/forms.c @@ -209,15 +209,11 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); diff --git a/src/msg.c b/src/msg.c index 4132ae98..ce25ab3a 100644 --- a/src/msg.c +++ b/src/msg.c @@ -40,14 +40,10 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data if (data->cancel_label) { gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (cancel_button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (ok_button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } } @@ -119,8 +115,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (ok_button) { if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (ok_button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } } diff --git a/src/password.c b/src/password.c index ff254fde..6d85390b 100644 --- a/src/password.c +++ b/src/password.c @@ -45,10 +45,10 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data dialog = gtk_dialog_new (); gtk_dialog_add_button(GTK_DIALOG(dialog), - data->cancel_label != NULL ? data->cancel_label : GTK_STOCK_CANCEL, + data->cancel_label != NULL ? data->cancel_label : _("_Cancel"), GTK_RESPONSE_CANCEL); gtk_dialog_add_button(GTK_DIALOG(dialog), - data->ok_label != NULL ? data->ok_label : GTK_STOCK_OK, + data->ok_label != NULL ? data->ok_label : _("_OK"), GTK_RESPONSE_OK); image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, diff --git a/src/progress.c b/src/progress.c index 3fd2c2ef..dfbdd8a9 100644 --- a/src/progress.c +++ b/src/progress.c @@ -319,15 +319,11 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (progress_data->dialog_text) diff --git a/src/scale.c b/src/scale.c index adcf67be..ea56dd22 100644 --- a/src/scale.c +++ b/src/scale.c @@ -82,15 +82,11 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (scale_data->dialog_text) diff --git a/src/text.c b/src/text.c index 8f383b9c..83aff9b5 100644 --- a/src/text.c +++ b/src/text.c @@ -278,14 +278,10 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (ok_button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (cancel_button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } if (text_data->checkbox) { diff --git a/src/tree.c b/src/tree.c index 819f9a8e..ac61cd87 100644 --- a/src/tree.c +++ b/src/tree.c @@ -399,15 +399,11 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } if (data->cancel_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button")); gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - gtk_button_set_image (GTK_BUTTON (button), - gtk_image_new_from_stock (GTK_STOCK_CANCEL, GTK_ICON_SIZE_BUTTON)); } text = gtk_builder_get_object (builder, "zenity_tree_text"); -- cgit From c1cf0abc21133e4fa79f412f2e7b0d1a4b6954bd Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 05:00:48 +0000 Subject: Do not use stock dialog --- src/password.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 6d85390b..be3bcf43 100644 --- a/src/password.c +++ b/src/password.c @@ -51,8 +51,8 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data data->ok_label != NULL ? data->ok_label : _("_OK"), GTK_RESPONSE_OK); - image = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, - GTK_ICON_SIZE_DIALOG); + image = gtk_image_new_from_icon_name("dialog-password", + GTK_ICON_SIZE_DIALOG); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); hbox = gtk_hbox_new(FALSE, 5); -- cgit From 1a43253ac568bc8ff293746477361a33a4469f88 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 05:17:25 +0000 Subject: Do not use a stock answer for yes/no buttons --- src/msg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index ce25ab3a..73c48981 100644 --- a/src/msg.c +++ b/src/msg.c @@ -33,8 +33,8 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data { GtkWidget *cancel_button, *ok_button; - cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_CANCEL); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Yes"), GTK_RESPONSE_OK); gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button); -- cgit From fba4f05582d6c84030354ba3e1adc228543a3919 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 06:02:41 +0000 Subject: Rework zenity_util_set_window_icon* to not use stock images --- src/msg.c | 8 ++++---- src/util.c | 65 +++++++++++++++++++++++++++++--------------------------------- src/util.h | 8 ++++---- 3 files changed, 38 insertions(+), 43 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 73c48981..6892e733 100644 --- a/src/msg.c +++ b/src/msg.c @@ -120,20 +120,20 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) switch (msg_data->mode) { case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_WARNING); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-warning"); break; case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); zenity_msg_construct_question_dialog (dialog, msg_data, data); break; case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error"); break; case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_INFO); + zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-information"); break; default: diff --git a/src/util.c b/src/util.c index d63aecaf..29ef6daf 100644 --- a/src/util.c +++ b/src/util.c @@ -178,66 +178,61 @@ zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) } const gchar * -zenity_util_stock_from_filename (const gchar *filename) +zenity_util_icon_name_from_filename (const gchar *filename) { if (!filename || !filename[0]) - return GTK_STOCK_DIALOG_WARNING; /* default */ + return "dialog-warning"; /* default */ if (!g_ascii_strcasecmp (filename, "warning")) - return GTK_STOCK_DIALOG_WARNING; + return "dialog-warning"; if (!g_ascii_strcasecmp (filename, "info")) - return GTK_STOCK_DIALOG_INFO; + return "dialog-information"; if (!g_ascii_strcasecmp (filename, "question")) - return GTK_STOCK_DIALOG_QUESTION; + return "dialog-question"; if (!g_ascii_strcasecmp (filename, "error")) - return GTK_STOCK_DIALOG_ERROR; + return "dialog-error"; return NULL; } -GdkPixbuf * -zenity_util_pixbuf_new_from_file (GtkWidget *widget, const gchar *filename) -{ - const gchar *stock; - - stock = zenity_util_stock_from_filename (filename); - if (stock) - return gtk_widget_render_icon (widget, stock, GTK_ICON_SIZE_BUTTON, NULL); - - return gdk_pixbuf_new_from_file (filename, NULL); -} - void -zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file) +zenity_util_set_window_icon_from_file (GtkWidget *widget, const gchar *filename) { GdkPixbuf *pixbuf; + const gchar *icon_name; - if (filename != NULL) - pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename); - else - pixbuf = gdk_pixbuf_new_from_file (default_file, NULL); - - if (pixbuf != NULL) { + icon_name = zenity_util_icon_name_from_filename (filename); + if (icon_name) { + gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name); + } else { + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); g_object_unref (pixbuf); } } -void -zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *filename, const gchar *default_stock_id) +void +zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file) { GdkPixbuf *pixbuf; if (filename != NULL) { - pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename); - } - else { - pixbuf = gtk_widget_render_icon (widget, default_stock_id, GTK_ICON_SIZE_BUTTON, NULL); + zenity_util_set_window_icon_from_file (widget, filename); + } else { + pixbuf = gdk_pixbuf_new_from_file (default_file, NULL); + if (pixbuf != NULL) { + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); + } } +} - if (pixbuf != NULL) { - gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); - g_object_unref (pixbuf); - } +void +zenity_util_set_window_icon_from_icon_name (GtkWidget *widget, const gchar *filename, const gchar *default_icon_name) +{ + if (filename != NULL) + zenity_util_set_window_icon_from_file (widget, filename); + else + gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name); } void diff --git a/src/util.h b/src/util.h index f9db4bea..0fd2fff9 100644 --- a/src/util.h +++ b/src/util.h @@ -19,14 +19,14 @@ GtkBuilder* zenity_util_load_ui_file (const gchar *widge gchar * zenity_util_strip_newline (gchar *string); gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename); -const gchar * zenity_util_stock_from_filename (const gchar *filename); +const gchar * zenity_util_icon_name_from_filename (const gchar *filename); void zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file); -void zenity_util_set_window_icon_from_stock (GtkWidget *widget, +void zenity_util_set_window_icon_from_icon_name(GtkWidget *widget, const gchar *filename, - const gchar *default_stock_id); -GdkPixbuf * zenity_util_pixbuf_new_from_file (GtkWidget *widget, + const gchar *default_icon_name); +void zenity_util_set_window_icon_from_file (GtkWidget *widget, const gchar *filename); void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); -- cgit From e54c5db6aa0374db35abe8ae6e128648e95a35b1 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 06:30:57 +0000 Subject: src/color.c: Port to GtkColorChooserDialog --- src/color.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) (limited to 'src') diff --git a/src/color.c b/src/color.c index 6820bbbe..2a7e0396 100644 --- a/src/color.c +++ b/src/color.c @@ -34,27 +34,21 @@ static void zenity_colorselection_dialog_response (GtkWidget *widget, int respon void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { GtkWidget *dialog; - GtkWidget *colorsel; GtkWidget *button; - GdkColor color; + GdkRGBA color; zen_data = data; - dialog = gtk_color_selection_dialog_new (NULL); + dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_colorselection_dialog_response), color_data); - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (dialog)); - if (color_data->color) { - if (gdk_color_parse (color_data->color, &color)) - gtk_color_selection_set_current_color (GTK_COLOR_SELECTION (colorsel), - &color); + if (gdk_rgba_parse (&color, color_data->color)) { + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); + } } if (data->ok_label) { @@ -72,8 +66,7 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - gtk_color_selection_set_has_palette (GTK_COLOR_SELECTION (colorsel), - color_data->show_palette); + g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); zenity_util_show_dialog (dialog, data->attach); @@ -89,15 +82,13 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) { - GtkWidget *colorsel; - GdkColor color; + GdkRGBA color; switch (response) { case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - colorsel = gtk_color_selection_dialog_get_color_selection (GTK_COLOR_SELECTION_DIALOG (widget)); - gtk_color_selection_get_current_color (GTK_COLOR_SELECTION (colorsel), &color); - g_print ("%s\n", gdk_color_to_string (&color)); + zenity_util_exit_code_with_data(ZENITY_OK, zen_data); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); + g_print ("%s\n", gdk_rgba_to_string (&color)); break; case GTK_RESPONSE_CANCEL: -- cgit From 1cf533964e61202c2e0921e10dc4ee149423bd6c Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 07:15:51 +0000 Subject: src/text.c: gtk_widget_override_font instead gtk_widget_modify_font --- src/text.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index 83aff9b5..634be3da 100644 --- a/src/text.c +++ b/src/text.c @@ -265,7 +265,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->font) { PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font); - gtk_widget_modify_font (GTK_WIDGET(text_view), fontDesc); + gtk_widget_override_font (GTK_WIDGET(text_view), fontDesc); } if (text_data->uri) -- cgit From 1f130a37fac4976687473b951908581612168bdc Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 07:19:56 +0000 Subject: password: Use gtk_box instead gtk_[v|h]box --- src/password.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index be3bcf43..32be61ea 100644 --- a/src/password.c +++ b/src/password.c @@ -55,7 +55,7 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data GTK_ICON_SIZE_DIALOG); gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); - hbox = gtk_hbox_new(FALSE, 5); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, @@ -81,10 +81,10 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data TRUE, 5); - vbox_labels = gtk_vbox_new(FALSE, 5); - vbox_entries = gtk_vbox_new(FALSE, 5); + vbox_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); + vbox_entries = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); - hbox = gtk_hbox_new(FALSE, 5); + hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), hbox, FALSE, -- cgit From 7c4cd1fc426e4e30a25a390987b139fc1d32a0b3 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 07:25:59 +0000 Subject: src/password.c: Do not use deprecated GtkAlignment widget --- src/password.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/password.c b/src/password.c index 32be61ea..c5161002 100644 --- a/src/password.c +++ b/src/password.c @@ -38,7 +38,6 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data GtkWidget *vbox_labels; GtkWidget *vbox_entries; GtkWidget *label; - GtkWidget *align; zen_data = data; @@ -103,11 +102,9 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data 12); if(password_data->username) { - align = gtk_alignment_new(0.0, 0.12, 0.0, 0.0); label = gtk_label_new(_("Username:")); - gtk_container_add(GTK_CONTAINER(align), label); gtk_box_pack_start(GTK_BOX(vbox_labels), - align, + label, TRUE, FALSE, 12); @@ -119,12 +116,9 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data 12); } - align = gtk_alignment_new(0.0, 0.5, 0.0, 0.0); label = gtk_label_new(_("Password:")); - gtk_container_add(GTK_CONTAINER(align), label); - gtk_box_pack_start(GTK_BOX(vbox_labels), - align, + label, TRUE, FALSE, 12); -- cgit From fcb28a3a141d272a5ca8ec5ef64233b66a746395 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 08:05:26 +0000 Subject: forms: Use GtkGrid instead deprecated GtkTable/GtkAlignment --- src/forms.c | 98 ++++++++--------------------------------------------------- src/zenity.ui | 74 +++++--------------------------------------- 2 files changed, 20 insertions(+), 152 deletions(-) (limited to 'src') diff --git a/src/forms.c b/src/forms.c index 072908e6..3e19f4c5 100644 --- a/src/forms.c +++ b/src/forms.c @@ -173,13 +173,12 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) { GtkBuilder *builder = NULL; GtkWidget *dialog; - GtkWidget *table; + GtkWidget *grid; GtkWidget *text; GtkWidget *button; GSList *tmp; - gint number_of_widgets = g_slist_length (forms_data->list); int list_count = 0; int combo_count = 0; int i = 0; @@ -221,122 +220,51 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) if (forms_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text)); - table = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_table")); - - gtk_table_resize (GTK_TABLE (table), number_of_widgets, 2); + grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid")); for (tmp = forms_data->list; tmp; tmp = tmp->next) { ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; GtkWidget *label; - GtkWidget *align; label = gtk_label_new(zenity_value->option_value); - - align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); - gtk_container_add (GTK_CONTAINER (align), label); - - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (align), - 0, - 1, - i, - i+1, - GTK_FILL, - GTK_FILL, - 0, - 0); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_grid_attach (GTK_GRID (grid), + label, + 0, i, + 1, 1); switch(zenity_value->type) { case ZENITY_FORMS_ENTRY: zenity_value->forms_widget = gtk_entry_new(); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); break; case ZENITY_FORMS_PASSWORD: zenity_value->forms_widget = gtk_entry_new(); gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget), FALSE); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); break; case ZENITY_FORMS_CALENDAR: zenity_value->forms_widget = gtk_calendar_new(); - gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); - align = gtk_alignment_new (0.0, 0.5, 0.0, 0.0); - gtk_container_add (GTK_CONTAINER (align), zenity_value->forms_widget); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (align), - 1, - 2, - i, - i+1, - GTK_FILL, - GTK_FILL, - 0, - 0); break; case ZENITY_FORMS_LIST: zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, zenity_value->option_value); - gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); list_count++; break; case ZENITY_FORMS_COMBO: zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count); - gtk_alignment_set (GTK_ALIGNMENT (align), 0.0, 0.02, 0.0, 0.0); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); combo_count++; break; default: zenity_value->forms_widget = gtk_entry_new(); - gtk_table_attach (GTK_TABLE (table), - GTK_WIDGET (zenity_value->forms_widget), - 1, - 2, - i, - i+1, - GTK_EXPAND | GTK_FILL, - GTK_EXPAND | GTK_FILL, - 0, - 0); break; } + + gtk_grid_attach_next_to (GTK_GRID (grid), + GTK_WIDGET (zenity_value->forms_widget), + label, + GTK_POS_RIGHT, + 1, 1); i++; } diff --git a/src/zenity.ui b/src/zenity.ui index fed8c23b..edd30585 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -606,75 +606,15 @@ False 0 - + True False - 12 - 12 - 6 - - - True - False - 2 - 10 - 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 12 + 6 + 12 + 6 + 6 + 10 -- cgit From 81d9a261e25f5fe612affa1372e7abd95fbcf1e4 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 08:52:44 +0000 Subject: src/zenity.ui: Use GtkBox instead deprecated Gtk[H|V]Box --- src/zenity.ui | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index edd30585..79827a90 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -62,10 +62,11 @@ - + True False 5 + vertical 6 @@ -166,7 +167,7 @@ - + True False 5 @@ -277,13 +278,14 @@ - + True False 5 + vertical 6 - + True False 6 @@ -406,12 +408,13 @@ - + True False 6 + vertical - + True False 6 @@ -493,12 +496,12 @@ - + True False 6 - + True False 5 @@ -681,7 +684,7 @@ - + True False 5 @@ -784,10 +787,11 @@ - + True False 5 + vertical 6 @@ -867,7 +871,7 @@ - + True False 5 @@ -967,10 +971,11 @@ - + True False 5 + vertical 6 @@ -1062,7 +1067,7 @@ - + True False 5 -- cgit From d97b99cfc32abe024564622b0904ff773ff81107 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 09:00:16 +0000 Subject: Use GtkScale instead deprecated GtkHScale --- src/zenity.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 79827a90..f6bc0c7a 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -83,7 +83,7 @@ - + True True adjustment1 -- cgit From a3568bc51baa1ceccb430c31b0f95c2672eccbcb Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 09:05:23 +0000 Subject: src/notification.c: Remove non-used variable --- src/notification.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 06ac1dde..2bdd05b6 100644 --- a/src/notification.c +++ b/src/notification.c @@ -175,10 +175,6 @@ zenity_notification_handle_stdin (GIOChannel *channel, GIOCondition condition, gpointer user_data) { - ZenityData *zen_data; - - zen_data = (ZenityData *)user_data; - if ((condition & G_IO_IN) != 0) { GString *string; GError *error = NULL; -- cgit From f01d7220db8d62846a01ab044a5976dd1304f446 Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 09:07:34 +0000 Subject: src/tree.c: Do not use deprecated gtk_tree_view_set_rules_hint() --- src/tree.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index ac61cd87..a979d8a1 100644 --- a/src/tree.c +++ b/src/tree.c @@ -551,8 +551,6 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) column_index++; } - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE); - if (tree_data->hide_header) gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); -- cgit From c45daa96bfdc5a958cc0f2cdaf4db71ac61b8fde Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Sun, 22 Mar 2015 09:24:26 +0000 Subject: src/tree.c: avoid a compilation warning --- src/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index a979d8a1..c87958f0 100644 --- a/src/tree.c +++ b/src/tree.c @@ -305,8 +305,9 @@ zenity_mid_search_func (GtkTreeModel *model, gint column, { gchar *iter_string = NULL; gtk_tree_model_get (model, iter, column, &iter_string, -1); - return ! g_strrstr (g_utf8_strdown(iter_string, -1), - g_utf8_strdown(key, -1)) != NULL; + return ! (g_strrstr (g_utf8_strdown(iter_string, -1), + g_utf8_strdown(key, -1)) != NULL); + } static void -- cgit From 4fe3fa98d941f2a00750bc5ce0c2a23846006265 Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Tue, 21 Apr 2015 09:55:40 +0200 Subject: Bug #734196 --info destroys X11 primary selection content, and does not document that either --- src/msg.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 4132ae98..fb549421 100644 --- a/src/msg.c +++ b/src/msg.c @@ -51,6 +51,31 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data } } +static void +zenity_label_widget_clipboard_selection(GtkWidget *widget) +{ + /* Workaround hotfix for suspected toolkit issue: + since focus change of the dialog's focussed widget (text) + somehow currently chooses to destroy + a pre-existing (read: foreign, user-initiated) X11 primary selection + (via gtk_label_select_region() -> ... + -> gtk_clipboard_set_contents()/gtk_clipboard_clear()), + we need to ensure + that the widget does have its gtk-label-select-on-focus property off, + in order to avoid having the label become selected automatically + and thereby having pre-existing clipboard content nullified. + Side note: this selection issue only applies to widgets + which have both + True + True + . + */ + g_object_set(gtk_widget_get_settings (widget), + "gtk-label-select-on-focus", + FALSE, + NULL); +} + void zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { @@ -164,6 +189,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); else gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); } if (msg_data->ellipsize) -- cgit From 5c9095731e7995974de2468debbf1b82593445fd Mon Sep 17 00:00:00 2001 From: Jason Penney Date: Thu, 30 Oct 2014 06:09:59 -0400 Subject: allow build if GDK_WINDOWING_X11 not set --- src/util.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/util.h b/src/util.h index f9db4bea..ada73b14 100644 --- a/src/util.h +++ b/src/util.h @@ -6,6 +6,8 @@ #ifdef GDK_WINDOWING_X11 #include +#else +typedef gint Window; #endif G_BEGIN_DECLS -- cgit From ba5ea0386de2a80a664fb28d3af7e8d395968314 Mon Sep 17 00:00:00 2001 From: Gama Anderson Date: Sat, 28 Feb 2015 20:06:09 +0100 Subject: ADD gchar **extra_label TO struct ZenityData this is done to keep the name of the extra buttons ADD general option "extra-button" with string array as argument This will upon consecutive calls save the name of buttons in an array of strings To all MODES, except notification.c and about.c ADD if (data->extra_label) { gint i=0; while(data->extra_label[i]!=NULL){ gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); i++; } } This add the extra buttons to the dialog. The response is the number of the button To all MODES response, except notification.c and about.c ADD default: if (response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); This will print the button name to stdout when they are pressed ADD question option "switch" This will suppress the standard "ok" and "cancel" button in question. This just wort in combination with --extra-button, otherwise error is raised. https://bugzilla.gnome.org/show_bug.cgi?id=118016 --- src/calendar.c | 13 +++++++++++-- src/color.c | 10 ++++++++++ src/entry.c | 13 +++++++++++-- src/fileselection.c | 11 ++++++++++- src/forms.c | 10 ++++++++++ src/msg.c | 21 ++++++++++++++++++++- src/option.c | 40 +++++++++++++++++++++++++++++++++++----- src/password.c | 10 ++++++++++ src/progress.c | 11 ++++++++++- src/scale.c | 12 +++++++++++- src/text.c | 11 ++++++++++- src/tree.c | 11 ++++++++++- src/util.c | 2 +- src/zenity.h | 2 ++ 14 files changed, 161 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index e8967974..8e2f6950 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -91,7 +91,15 @@ zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); } - + + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -149,7 +157,8 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/color.c b/src/color.c index e3b8a428..be63068b 100644 --- a/src/color.c +++ b/src/color.c @@ -57,6 +57,14 @@ void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) &color); } + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -109,6 +117,8 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/entry.c b/src/entry.c index ca5e3752..5066f71e 100644 --- a/src/entry.c +++ b/src/entry.c @@ -83,7 +83,15 @@ zenity_entry (ZenityData *data, ZenityEntryData *entry_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - + + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -188,7 +196,8 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/fileselection.c b/src/fileselection.c index 9edbb6ae..fbf0e5de 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -62,6 +62,14 @@ void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_fileselection_dialog_response), file_data); + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->dialog_title) gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); @@ -181,7 +189,8 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/forms.c b/src/forms.c index 59c6461f..1923790f 100644 --- a/src/forms.c +++ b/src/forms.c @@ -206,6 +206,14 @@ void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) if (data->width > -1 || data->height > -1) gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -439,6 +447,8 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/msg.c b/src/msg.c index fb549421..6f077501 100644 --- a/src/msg.c +++ b/src/msg.c @@ -31,8 +31,10 @@ static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocat static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { + + GtkWidget *cancel_button, *ok_button; - + cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_NO, GTK_RESPONSE_CANCEL); ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_YES, GTK_RESPONSE_OK); @@ -49,6 +51,8 @@ zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data gtk_button_set_image (GTK_BUTTON (ok_button), gtk_image_new_from_stock (GTK_STOCK_OK, GTK_ICON_SIZE_BUTTON)); } + + } static void @@ -95,6 +99,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; case ZENITY_MSG_QUESTION: + case ZENITY_MSG_SWITCH: builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); text = gtk_builder_get_object (builder, "zenity_question_text"); @@ -128,6 +133,14 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) break; } + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (builder == NULL) { data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); return; @@ -159,6 +172,10 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) zenity_msg_construct_question_dialog (dialog, msg_data, data); break; + case ZENITY_MSG_SWITCH: + zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_QUESTION); + break; + case ZENITY_MSG_ERROR: zenity_util_set_window_icon_from_stock (dialog, data->window_icon, GTK_STOCK_DIALOG_ERROR); break; @@ -233,6 +250,8 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/option.c b/src/option.c index eb0a03a3..7ec4b634 100644 --- a/src/option.c +++ b/src/option.c @@ -45,6 +45,7 @@ static gboolean zenity_general_dialog_no_markup; static gint zenity_general_timeout_delay; static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; +static gchar **zenity_general_extra_buttons; static gboolean zenity_general_modal; static gint zenity_general_attach; static gboolean zenity_general_dialog_ellipsize; @@ -104,6 +105,7 @@ static gboolean zenity_progress_time_remaining; /* Question Dialog Options */ static gboolean zenity_question_active; static gboolean zenity_question_default_cancel; +static gboolean zenity_question_switch; /* Text Dialog Options */ static gboolean zenity_text_active; @@ -222,6 +224,15 @@ static GOptionEntry general_options[] = { N_("Sets the label of the Cancel button"), N_("TEXT") }, + { + "extra-button", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_general_extra_buttons, + N_("Add extra-button"), + N_("TEXT") + }, { "modal", '\0', @@ -855,6 +866,15 @@ static GOptionEntry question_options[] = { &zenity_general_dialog_ellipsize, N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") }, + { + "switch", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_question_switch, + N_("Supress ok and cancel buttons"), + NULL + }, { NULL } @@ -1341,7 +1361,9 @@ zenity_option_free (void) { g_free (zenity_general_ok_button); if (zenity_general_cancel_button) g_free (zenity_general_cancel_button); - + if (zenity_general_extra_buttons) + g_strfreev (zenity_general_extra_buttons); + if (zenity_calendar_date_format) g_free (zenity_calendar_date_format); @@ -1463,6 +1485,7 @@ zenity_general_pre_callback (GOptionContext *context, zenity_general_uri = NULL; zenity_general_ok_button = NULL; zenity_general_cancel_button = NULL; + zenity_general_extra_buttons = NULL; zenity_general_dialog_no_wrap = FALSE; zenity_general_dialog_no_markup = FALSE; zenity_general_timeout_delay = -1; @@ -1594,7 +1617,7 @@ zenity_question_pre_callback (GOptionContext *context, { zenity_question_active = FALSE; zenity_question_default_cancel = FALSE; - + zenity_question_switch = FALSE; return TRUE; } @@ -1710,6 +1733,7 @@ zenity_general_post_callback (GOptionContext *context, results->data->timeout_delay = zenity_general_timeout_delay; results->data->ok_label = zenity_general_ok_button; results->data->cancel_label = zenity_general_cancel_button; + results->data->extra_label = zenity_general_extra_buttons; results->data->modal = zenity_general_modal; results->data->attach = zenity_general_attach; @@ -2012,13 +2036,18 @@ zenity_question_post_callback (GOptionContext *context, if (results->mode == MODE_QUESTION) { results->msg_data->dialog_text = zenity_general_dialog_text; results->msg_data->dialog_icon = zenity_general_dialog_icon; - results->msg_data->mode = ZENITY_MSG_QUESTION; + if(zenity_question_switch) + results->msg_data->mode = ZENITY_MSG_SWITCH; + else + results->msg_data->mode = ZENITY_MSG_QUESTION; results->msg_data->no_wrap = zenity_general_dialog_no_wrap; results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ellipsize = zenity_general_dialog_ellipsize; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; results->msg_data->default_cancel = zenity_question_default_cancel; } - + if(zenity_question_switch && zenity_general_extra_buttons==NULL) + zenity_option_error (zenity_option_get_name (question_options, &zenity_question_switch), ERROR_SYNTAX); + return TRUE; } @@ -2495,5 +2524,6 @@ zenity_option_parse (gint argc, gchar **argv) if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_ellipsize), ERROR_SUPPORT); + return results; } diff --git a/src/password.c b/src/password.c index ff254fde..23357467 100644 --- a/src/password.c +++ b/src/password.c @@ -44,6 +44,14 @@ void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data dialog = gtk_dialog_new (); + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + gtk_dialog_add_button(GTK_DIALOG(dialog), data->cancel_label != NULL ? data->cancel_label : GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); @@ -177,6 +185,8 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/progress.c b/src/progress.c index 3fd2c2ef..409175fa 100644 --- a/src/progress.c +++ b/src/progress.c @@ -316,6 +316,14 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -389,7 +397,8 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data); break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/scale.c b/src/scale.c index adcf67be..92c9818d 100644 --- a/src/scale.c +++ b/src/scale.c @@ -78,7 +78,15 @@ zenity_scale (ZenityData *data, ZenityScaleData *scale_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - + + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -145,6 +153,8 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/text.c b/src/text.c index 8f383b9c..f9daa73f 100644 --- a/src/text.c +++ b/src/text.c @@ -276,6 +276,14 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) if (text_data->editable) zen_text_data->buffer = text_buffer; + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); gtk_button_set_image (GTK_BUTTON (ok_button), @@ -398,7 +406,8 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); break; } diff --git a/src/tree.c b/src/tree.c index 819f9a8e..0e2665c1 100644 --- a/src/tree.c +++ b/src/tree.c @@ -396,6 +396,14 @@ zenity_tree (ZenityData *data, ZenityTreeData *tree_data) if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + if (data->extra_label) { + gint i=0; + while(data->extra_label[i]!=NULL){ + gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + if (data->ok_label) { button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); gtk_button_set_label (GTK_BUTTON (button), data->ok_label); @@ -708,7 +716,8 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - /* Esc dialog */ + if (response < g_strv_length(zen_data->extra_label)) + printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; } diff --git a/src/util.c b/src/util.c index d63aecaf..730b7a93 100644 --- a/src/util.c +++ b/src/util.c @@ -76,7 +76,7 @@ zenity_util_load_ui_file (const gchar *root_widget, ...) /* Enforce terminating NULL */ g_ptr_array_add (ptrarray, NULL); objects = (gchar**) g_ptr_array_free (ptrarray, FALSE); - + if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { /* Try current dir, for debugging */ result = gtk_builder_add_objects_from_file (builder, diff --git a/src/zenity.h b/src/zenity.h index 6390b007..77f0c050 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -28,6 +28,7 @@ typedef struct { gchar *window_icon; gchar *ok_label; gchar *cancel_label; + gchar **extra_label; gint width; gint height; gint exit_code; @@ -56,6 +57,7 @@ typedef struct { typedef enum { ZENITY_MSG_WARNING, ZENITY_MSG_QUESTION, + ZENITY_MSG_SWITCH, ZENITY_MSG_ERROR, ZENITY_MSG_INFO } MsgMode; -- cgit From fd024c53e67b55a8979f24952d5340a779248fe7 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 21 Apr 2015 14:59:29 +0200 Subject: option.c: Fixing typo in extra-button option --- src/option.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 7ec4b634..6a95dea7 100644 --- a/src/option.c +++ b/src/option.c @@ -872,7 +872,7 @@ static GOptionEntry question_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_question_switch, - N_("Supress ok and cancel buttons"), + N_("Suppress ok and cancel buttons"), NULL }, { -- cgit From 996711f016c68dacaa204cfa9b8568e0d4564477 Mon Sep 17 00:00:00 2001 From: Piotr DrÄ…g Date: Wed, 22 Apr 2015 00:49:31 +0200 Subject: Improve some strings --- src/option.c | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 6a95dea7..431b9b60 100644 --- a/src/option.c +++ b/src/option.c @@ -212,7 +212,7 @@ static GOptionEntry general_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_ok_button, - N_("Sets the label of the Ok button"), + N_("Set the label of the OK button"), N_("TEXT") }, { @@ -221,7 +221,7 @@ static GOptionEntry general_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_general_cancel_button, - N_("Sets the label of the Cancel button"), + N_("Set the label of the Cancel button"), N_("TEXT") }, { @@ -230,7 +230,7 @@ static GOptionEntry general_options[] = { 0, G_OPTION_ARG_STRING_ARRAY, &zenity_general_extra_buttons, - N_("Add extra-button"), + N_("Add an extra button"), N_("TEXT") }, { @@ -402,7 +402,7 @@ static GOptionEntry error_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_markup, - N_("Do not enable pango markup") + N_("Do not enable Pango markup") }, { "ellipsize", @@ -460,7 +460,7 @@ static GOptionEntry info_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_markup, - N_("Do not enable pango markup") + N_("Do not enable Pango markup") }, { "ellipsize", @@ -545,7 +545,7 @@ static GOptionEntry file_selection_options[] = { 0, G_OPTION_ARG_STRING_ARRAY, &zenity_file_filter, - N_("Sets a filename filter"), + N_("Set a filename filter"), /* Help for file-filter argument (name and patterns for file selection) */ N_("NAME | PATTERN1 PATTERN2 ..."), }, @@ -588,7 +588,7 @@ static GOptionEntry list_options[] = { 0, G_OPTION_ARG_NONE, &zenity_list_checklist, - N_("Use check boxes for first column"), + N_("Use check boxes for the first column"), NULL }, { @@ -597,7 +597,7 @@ static GOptionEntry list_options[] = { 0, G_OPTION_ARG_NONE, &zenity_list_radiolist, - N_("Use radio buttons for first column"), + N_("Use radio buttons for the first column"), NULL }, { @@ -606,7 +606,7 @@ static GOptionEntry list_options[] = { 0, G_OPTION_ARG_NONE, &zenity_list_imagelist, - N_("Use an image for first column"), + N_("Use an image for the first column"), NULL }, { @@ -661,7 +661,7 @@ static GOptionEntry list_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_list_hide_header, - N_("Hides the column headers"), + N_("Hide the column headers"), NULL }, { @@ -776,7 +776,6 @@ static GOptionEntry progress_options[] = { 0, G_OPTION_ARG_NONE, &zenity_progress_auto_kill, - /* xgettext: no-c-format */ N_("Kill parent process if Cancel button is pressed"), NULL }, @@ -786,7 +785,6 @@ static GOptionEntry progress_options[] = { 0, G_OPTION_ARG_NONE, &zenity_progress_no_cancel, - /* xgettext: no-c-format */ N_("Hide Cancel button"), NULL }, @@ -796,6 +794,7 @@ static GOptionEntry progress_options[] = { 0, G_OPTION_ARG_NONE, &zenity_progress_time_remaining, + /* xgettext: no-c-format */ N_("Estimate when progress will reach 100%"), NULL }, @@ -847,7 +846,7 @@ static GOptionEntry question_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_markup, - N_("Do not enable pango markup") + N_("Do not enable Pango markup") }, { "default-cancel", @@ -855,7 +854,7 @@ static GOptionEntry question_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_question_default_cancel, - N_("Give cancel button focus by default"), + N_("Give Cancel button focus by default"), NULL }, { @@ -872,7 +871,7 @@ static GOptionEntry question_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_question_switch, - N_("Suppress ok and cancel buttons"), + N_("Suppress OK and Cancel buttons"), NULL }, { @@ -933,7 +932,7 @@ static GOptionEntry text_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_text_enable_html, - N_("Enable html support"), + N_("Enable HTML support"), NULL }, { @@ -951,7 +950,7 @@ static GOptionEntry text_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_STRING, &zenity_text_url, - N_("Sets an url instead of a file. Only works if you use --html option"), + N_("Set an URL instead of a file. Only works if you use --html option"), N_("URL") }, #endif @@ -1012,7 +1011,7 @@ static GOptionEntry warning_options[] = { G_OPTION_FLAG_NOALIAS, G_OPTION_ARG_NONE, &zenity_general_dialog_no_markup, - N_("Do not enable pango markup") + N_("Do not enable Pango markup") }, { "ellipsize", -- cgit From d59ce70285a0c5d7dd634ba5cc746b331edac4ce Mon Sep 17 00:00:00 2001 From: Javier Jardón Date: Wed, 22 Apr 2015 19:59:56 +0100 Subject: Do not make zenity_util_show_dialog() X11 specific --- src/option.c | 2 +- src/util.c | 6 +++++- src/util.h | 7 +------ src/zenity.h | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/option.c b/src/option.c index 431b9b60..3e351448 100644 --- a/src/option.c +++ b/src/option.c @@ -47,7 +47,7 @@ static gchar *zenity_general_ok_button; static gchar *zenity_general_cancel_button; static gchar **zenity_general_extra_buttons; static gboolean zenity_general_modal; -static gint zenity_general_attach; +static guintptr zenity_general_attach; static gboolean zenity_general_dialog_ellipsize; /* Calendar Dialog Options */ diff --git a/src/util.c b/src/util.c index 9693b0b2..ddb0146f 100644 --- a/src/util.c +++ b/src/util.c @@ -39,6 +39,10 @@ #include "util.h" #include "zenity.h" +#ifdef GDK_WINDOWING_X11 +#include +#endif + #define ZENITY_OK_DEFAULT 0 #define ZENITY_CANCEL_DEFAULT 1 #define ZENITY_ESC_DEFAULT 1 @@ -402,7 +406,7 @@ zenity_util_make_transient (GdkWindow *window, Window parent) #endif /* GDK_WINDOWING_X11 */ void -zenity_util_show_dialog (GtkWidget *dialog, Window parent) +zenity_util_show_dialog (GtkWidget *dialog, guintptr parent) { gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 diff --git a/src/util.h b/src/util.h index 4296ab93..c847cd4c 100644 --- a/src/util.h +++ b/src/util.h @@ -4,11 +4,6 @@ #include #include "zenity.h" -#ifdef GDK_WINDOWING_X11 -#include -#else -typedef gint Window; -#endif G_BEGIN_DECLS @@ -34,7 +29,7 @@ void zenity_util_show_help (GError **error); gint zenity_util_return_exit_code (ZenityExitCode value); void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data); -void zenity_util_show_dialog (GtkWidget *widget, Window parent); +void zenity_util_show_dialog (GtkWidget *widget, guintptr parent); gboolean zenity_util_timeout_handle (gpointer data); diff --git a/src/zenity.h b/src/zenity.h index 77f0c050..bab11e31 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -34,7 +34,7 @@ typedef struct { gint exit_code; gint timeout_delay; gboolean modal; - gint attach; + guintptr attach; } ZenityData; typedef enum { -- cgit From 08e8f3e05da467930bb7c24ca7280f7d18fc9122 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Thu, 14 May 2015 16:54:34 +0200 Subject: Bug #749359 zenity --list produces incorrect output --- src/zenity.ui | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index f6bc0c7a..72be5221 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -995,6 +995,7 @@ True True in + True True -- cgit From ec0a74004526eab4d3bfba8f841a5b357026d4f5 Mon Sep 17 00:00:00 2001 From: Hristo Venev Date: Sun, 24 May 2015 19:38:25 +0300 Subject: Port to webkit2gtk --- src/text.c | 70 +++++++++++++++++++++++++------------------------------------- 1 file changed, 28 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/text.c b/src/text.c index 581b3666..5657f21c 100644 --- a/src/text.c +++ b/src/text.c @@ -28,7 +28,7 @@ #include "util.h" #ifdef HAVE_WEBKITGTK -#include +#include #endif static ZenityTextData *zen_text_data; @@ -40,12 +40,9 @@ static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data); static void zenity_configure_webkit (WebKitWebView *web_view) { - WebKitWebSettings *settings; + WebKitSettings *settings; settings = webkit_web_view_get_settings(web_view); - g_object_set(G_OBJECT(settings), "enable-scripts", FALSE, NULL); g_object_set(G_OBJECT(settings), "auto-load-images", TRUE, NULL); - g_object_set(G_OBJECT(settings), "auto-resize-window", TRUE, NULL); - g_object_set(G_OBJECT(settings), "auto-shrink-images", TRUE, NULL); /* Stick to the defaults "cursive-font-family" gchar* : Read / Write / Construct @@ -56,35 +53,21 @@ zenity_configure_webkit (WebKitWebView *web_view) "editing-behavior" WebKitEditingBehavior : Read / Write / Construct */ g_object_set(G_OBJECT(settings), "enable-caret-browsing", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-default-context-menu", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL); - /* unexisting property? g_object_set(G_OBJECT(settings), "enable-dns-prefetching", FALSE, NULL);*/ - g_object_set(G_OBJECT(settings), "enable-dom-paste", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-file-access-from-file-uris", TRUE, NULL); - /* unexisting property? g_object_set(G_OBJECT(settings), "enable-frame-flattening", FALSE, NULL);*/ - /* unexisting property? g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL);*/ + g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-html5-database", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-html5-local-storage", FALSE, NULL); - /* unexisting property? g_object_set(G_OBJECT(settings), "enable-hyperlink-auditing", FALSE, NULL);*/ - g_object_set(G_OBJECT(settings), "enable-java-applet", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-java", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-javascript", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-offline-web-application-cache", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-page-cache", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL); g_object_set(G_OBJECT(settings), "enable-private-browsing", TRUE, NULL); - g_object_set(G_OBJECT(settings), "enable-scripts", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-site-specific-quirks", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-spatial-navigation", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-spell-checking", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-universal-access-from-file-uris", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-xss-auditor", TRUE, NULL); /* Stick to defaults "enforce-96-dpi" gboolean : Read / Write / Construct "fantasy-font-family" gchar* : Read / Write / Construct */ - g_object_set(G_OBJECT(settings), "javascript-can-access-clipboard", FALSE, NULL); - g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", FALSE, NULL); - g_object_set(G_OBJECT(settings), "javascript-can-open-windows-automatically", FALSE, NULL); /* Stick to defaults "minimum-font-size" gint : Read / Write / Construct @@ -96,7 +79,7 @@ zenity_configure_webkit (WebKitWebView *web_view) "serif-font-family" gchar* : Read / Write / Construct "spell-checking-languages" gchar* : Read / Write / Construct */ - g_object_set(G_OBJECT(settings), "tab-key-cycles-through-elements", FALSE, NULL); + g_object_set(G_OBJECT(settings), "enable-tabs-to-links", FALSE, NULL); g_object_set(G_OBJECT(settings), "user-agent", "Zenity with WebKit (KHTML, like Gecko) support", NULL); /* @@ -107,29 +90,32 @@ zenity_configure_webkit (WebKitWebView *web_view) } static gboolean -zenity_text_webview_decision_request (WebKitWebView *webkitwebview, - WebKitWebFrame *frame, - WebKitNetworkRequest *request, - WebKitWebNavigationAction *navigation_action, - WebKitWebPolicyDecision *policy_decision, - gpointer user_data) +zenity_text_webview_decision_request (WebKitWebView *web_view, + WebKitPolicyDecision *decision, + WebKitPolicyDecisionType type) { - webkit_web_policy_decision_ignore (policy_decision); - if (!zen_text_data->no_interaction && - webkit_web_navigation_action_get_reason (navigation_action) == WEBKIT_WEB_NAVIGATION_REASON_LINK_CLICKED) { - g_app_info_launch_default_for_uri (webkit_web_navigation_action_get_original_uri(navigation_action), - NULL, NULL); + if (type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) { + WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); + WebKitNavigationAction *navigation_action = webkit_navigation_policy_decision_get_navigation_action(navigation_decision); + webkit_policy_decision_ignore (decision); + if (!zen_text_data->no_interaction && + webkit_navigation_action_get_navigation_type (navigation_action) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) { + WebKitURIRequest *request = webkit_navigation_action_get_request(navigation_action); + g_app_info_launch_default_for_uri (webkit_uri_request_get_uri(request), NULL, NULL); + } } return TRUE; } static void -zenity_text_webview_load_finished (WebKitWebView *webkitwebview, - WebKitWebFrame *frame, - gpointer user_data) +zenity_text_webview_load_changed (WebKitWebView *webkitwebview, + WebKitLoadEvent event, + gpointer user_data) { - g_signal_connect (G_OBJECT (webkitwebview), "navigation-policy-decision-requested", - G_CALLBACK (zenity_text_webview_decision_request), NULL); + if (event == WEBKIT_LOAD_FINISHED) { + g_signal_connect (G_OBJECT (webkitwebview), "decide-policy", + G_CALLBACK (zenity_text_webview_decision_request), NULL); + } } #endif @@ -337,7 +323,7 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) gtk_text_buffer_get_start_iter (text_buffer, &start_iter); gtk_text_buffer_get_end_iter (text_buffer, &end_iter); content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE); - webkit_web_view_load_string (WEBKIT_WEB_VIEW(web_kit), content, "text/html", "UTF-8", dirname_uri); + webkit_web_view_load_html (WEBKIT_WEB_VIEW(web_kit), content, dirname_uri); g_free (dirname_uri); g_free (content); } @@ -345,8 +331,8 @@ zenity_text (ZenityData *data, ZenityTextData *text_data) // We don't want user to click on links and navigate to another page. // So, when the page finishes loading, we take handle of the requests. - g_signal_connect (G_OBJECT (web_kit), "document-load-finished", - G_CALLBACK (zenity_text_webview_load_finished), NULL); + g_signal_connect (G_OBJECT (web_kit), "load-changed", + G_CALLBACK (zenity_text_webview_load_changed), NULL); gtk_widget_destroy (GTK_WIDGET (text_view)); gtk_container_add (GTK_CONTAINER(scrolled_window), web_kit); -- cgit From 8fcde2b8423526eb1f2ab8bbe8e07a0350283927 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 May 2015 13:53:25 +0200 Subject: Fix uninitialized progress_bar error --- src/progress.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/progress.c b/src/progress.c index d8ecea52..8e458c66 100644 --- a/src/progress.c +++ b/src/progress.c @@ -292,6 +292,8 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_dialog")); + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (zenity_progress_dialog_response), data); @@ -337,8 +339,6 @@ zenity_progress (ZenityData *data, ZenityProgressData *progress_data) if (progress_data->dialog_text) gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); - progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); - if (progress_data->percentage > -1) gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0); -- cgit From e6055cc19a2b8b04cd472e1e3511d48ba83bc046 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 May 2015 13:55:27 +0200 Subject: Fixing deprecated declarations --- src/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/tree.c b/src/tree.c index 0849946c..7398fc26 100644 --- a/src/tree.c +++ b/src/tree.c @@ -210,7 +210,7 @@ zenity_tree_handle_stdin (GIOChannel *channel, GtkWidget *scrolled_window; GtkRequisition rectangle; - gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle); + gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), &rectangle, NULL); scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_window")); gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); -- cgit From 160f0442c62579b79b15f953a9e6766a833952fd Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 May 2015 14:29:12 +0200 Subject: Fix GLib critical messages --- src/notification.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 2bdd05b6..a4355a1e 100644 --- a/src/notification.c +++ b/src/notification.c @@ -342,9 +342,11 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data NULL); /* set the notification hints for the displayed notification */ - notification_hints = zenity_notification_parse_hints_array (notification_data->notification_hints); - zenity_notification_set_hints(notification, notification_hints); - g_hash_table_unref (notification_hints); + if (notification_data->notification_hints != NULL) { + notification_hints = zenity_notification_parse_hints_array (notification_data->notification_hints); + zenity_notification_set_hints(notification, notification_hints); + g_hash_table_unref (notification_hints); + } /* Show icon and wait */ error = NULL; -- cgit From 297380bad9004876c873a86dbd25bc5fa420e4a3 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 May 2015 14:46:37 +0200 Subject: Bug #742963 - Basic notifications do not return --- src/notification.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index a4355a1e..3169a994 100644 --- a/src/notification.c +++ b/src/notification.c @@ -323,6 +323,7 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data if (notification_data->listen) { zenity_notification_listen_on_stdin (data); + gtk_main(); } else { if (notification_data->notification_text == NULL) { exit (1); @@ -362,9 +363,8 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); + gtk_main(); } - - gtk_main (); } #endif -- cgit From b5c909902e28128a0a821b0040525d2083ed213b Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 29 May 2015 20:11:34 +0200 Subject: Bug #672090 - Impossible to confirm --text-info --- src/zenity.ui | 52 ++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 72be5221..8a6c9ff7 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,5 +1,5 @@ - + @@ -72,9 +72,9 @@ True False - 0 4 Adjust the scale value + 0 False @@ -151,6 +151,7 @@ True True right + False @@ -171,6 +172,7 @@ True False 5 + vertical True @@ -293,9 +295,9 @@ True False - 0 Select a date from below. True + 0 False @@ -314,10 +316,10 @@ True False - 0 C_alendar: True zenity_calendar + 0 @@ -422,9 +424,9 @@ True False - 0 _Enter new text: True + 0 False @@ -524,10 +526,10 @@ True True - 0 An error has occurred. True True + 0 False @@ -618,6 +620,33 @@ 6 6 10 + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -707,10 +736,10 @@ True True - 0 All updates are complete. True True + 0 False @@ -797,9 +826,9 @@ True False - 0 Running... True + 0 False @@ -895,10 +924,10 @@ True True - 0 Are you sure you want to proceed? True True + 0 False @@ -981,8 +1010,8 @@ True False - 0 Select items from the list below. + 0 False @@ -995,7 +1024,6 @@ True True in - True True @@ -1092,10 +1120,10 @@ True True - 0 Are you sure you want to proceed? True True + 0 False -- cgit From d44ca5978053bb79a406acb4c824f79068f329b8 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 3 Jun 2015 11:54:52 +0200 Subject: Add the possibility to pass title and the summary to zenity notification Now you can use zenity --notification --text="Title\nSummary" and it will use the first string before the first escape \n as the title, and the rest of the string as summary text. --- src/notification.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 3169a994..8086be61 100644 --- a/src/notification.c +++ b/src/notification.c @@ -315,6 +315,7 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data GError *error; NotifyNotification *notification; GHashTable *notification_hints; + gchar **message; /* create the notification widget */ if (!notify_is_initted ()) { @@ -328,8 +329,16 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data if (notification_data->notification_text == NULL) { exit (1); } + + message = g_strsplit (g_strcompress (notification_data->notification_text), "\n", 2); + if (*message == NULL) { + g_printerr (_("Could not parse message\n")); + exit (1); + } - notification = notify_notification_new (notification_data->notification_text, NULL, data->window_icon); + notification = notify_notification_new (message[0], /* title */ + message[1], /* summary */ + data->window_icon); if (notification == NULL) { exit (1); } -- cgit From abf0777b35e70c23688a4c29dc1a0fb241b770c6 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Wed, 3 Jun 2015 13:32:32 +0200 Subject: Bug #638582 - zenity --notification --listen can't show multi line tooltip This create a new function to call the notify_notification_new handling properly the multi line parser --- src/notification.c | 56 ++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/notification.c b/src/notification.c index 8086be61..9bbd6ce1 100644 --- a/src/notification.c +++ b/src/notification.c @@ -40,6 +40,25 @@ static char *icon_file; static GHashTable *notification_hints; +static NotifyNotification * +zenity_notification_new(gchar *message, gchar *icon_file) +{ + NotifyNotification *notif; + gchar **text; + + text = g_strsplit (g_strcompress (message), "\n", 2); + if (*text == NULL) { + g_printerr (_("Could not parse message\n")); + return NULL; + } + + notif = notify_notification_new (text[0], /* title */ + text[1], /* summary */ + icon_file); + g_strfreev (text); + return notif; +} + static void on_notification_default_action (NotifyNotification *n, const char *action, @@ -229,24 +248,11 @@ zenity_notification_handle_stdin (GIOChannel *channel, g_warning ("Invalid UTF-8 in input!"); } else { NotifyNotification *notif; - gchar **message; error = NULL; - /* message[1] (the summary) will be NULL in case there's - * no \n in the string. In which case only the title is - * defined */ - message = g_strsplit (g_strcompress (value), "\n", 2); - - if (*message == NULL) { - g_printerr (_("Could not parse message from stdin\n")); - continue; - } - - notif = notify_notification_new (message[0] /* title */, - message[1] /* summary */, - icon_file); - - g_strfreev (message); + notif = zenity_notification_new (value, icon_file); + if (notif == NULL) + continue; zenity_notification_set_hints (notif, notification_hints); @@ -264,10 +270,9 @@ zenity_notification_handle_stdin (GIOChannel *channel, g_warning ("Invalid UTF-8 in input!"); } else { NotifyNotification *notif; - - notif = notify_notification_new (value, - NULL, - icon_file); + notif = zenity_notification_new (value, icon_file); + if (notif == NULL) + continue; zenity_notification_set_hints (notif, notification_hints); @@ -315,7 +320,6 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data GError *error; NotifyNotification *notification; GHashTable *notification_hints; - gchar **message; /* create the notification widget */ if (!notify_is_initted ()) { @@ -329,16 +333,10 @@ zenity_notification (ZenityData *data, ZenityNotificationData *notification_data if (notification_data->notification_text == NULL) { exit (1); } - - message = g_strsplit (g_strcompress (notification_data->notification_text), "\n", 2); - if (*message == NULL) { - g_printerr (_("Could not parse message\n")); - exit (1); - } - notification = notify_notification_new (message[0], /* title */ - message[1], /* summary */ + notification = zenity_notification_new (notification_data->notification_text, data->window_icon); + if (notification == NULL) { exit (1); } -- cgit From 6f1deca5c032909d24a318cf073914d6cb0e6d4a Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 23 Jun 2015 11:12:40 +0200 Subject: Bug #751332 - zenity --forms does not center in the screen --- src/zenity.ui | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 8a6c9ff7..d313932b 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -202,7 +202,6 @@ True False - 0 True @@ -560,6 +559,7 @@ False 5 + center normal -- cgit From 95530a164781a1dce681ac445d3f4e1248d448d9 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 23 Jun 2015 11:25:29 +0200 Subject: Fix zenity --list For some reason, glade is removing some properties from the xml file --- src/zenity.ui | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index d313932b..b16ea73d 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1024,6 +1024,7 @@ True True in + True True -- cgit From 2ec897cf63094c68fd787e2081f911e0deb3b596 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Mon, 21 Sep 2015 14:38:55 +0200 Subject: This is a simple build fix --- src/Makefile.am | 1 - 1 file changed, 1 deletion(-) (limited to 'src') diff --git a/src/Makefile.am b/src/Makefile.am index f6e9e981..bcdd2056 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,7 +24,6 @@ zenity_SOURCES = \ zenity.h zenity_CPPFLAGS = \ - -I$(includedir) \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ -DZENITY_DATADIR=\""$(pkgdatadir)"\" \ $(AM_CPPFLAGS) -- cgit From 9fe89f903f33e8a7d893a0baa52a957e85c96a16 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 2 Oct 2015 13:39:49 +0200 Subject: Fixing glade file. The entry dialog was with wrong box position --- src/zenity.ui | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index b16ea73d..43b884f6 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,5 +1,5 @@ - + @@ -202,6 +202,7 @@ True False + 0.5 True @@ -365,6 +366,7 @@ True False + vertical 2 @@ -413,11 +415,11 @@ True False 6 - vertical True False + vertical 6 -- cgit From fac40e9c46160a0915d528062dfd19c1afaeac0e Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 2 Oct 2015 13:41:57 +0200 Subject: Fixing html option being parsed to other dialogs rather then text-info --- src/option.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 3e351448..79a6f926 100644 --- a/src/option.c +++ b/src/option.c @@ -2074,6 +2074,9 @@ zenity_text_post_callback (GOptionContext *context, if (zenity_text_font) zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), ERROR_SUPPORT); + if (zenity_text_enable_html) + zenity_option_error (zenity_option_get_name (text_options, &zenity_text_enable_html), + ERROR_SUPPORT); } return TRUE; } -- cgit From d063797fdfa73e5bec96d9399ab1bf47173a62d4 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 2 Oct 2015 14:35:06 +0200 Subject: Fixing GLib-CRITICAL messages --- src/calendar.c | 2 +- src/color.c | 2 +- src/entry.c | 2 +- src/fileselection.c | 2 +- src/forms.c | 2 +- src/msg.c | 2 +- src/password.c | 2 +- src/progress.c | 2 +- src/scale.c | 2 +- src/text.c | 2 +- src/tree.c | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/calendar.c b/src/calendar.c index 0e6cb329..9f82cc63 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -153,7 +153,7 @@ zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/color.c b/src/color.c index 05898c4d..ae47b19b 100644 --- a/src/color.c +++ b/src/color.c @@ -104,7 +104,7 @@ zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/entry.c b/src/entry.c index 80367260..8e47ebd8 100644 --- a/src/entry.c +++ b/src/entry.c @@ -192,7 +192,7 @@ zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/fileselection.c b/src/fileselection.c index 3ccd11dd..27db0f40 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -189,7 +189,7 @@ zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/forms.c b/src/forms.c index 53e94238..5241780c 100644 --- a/src/forms.c +++ b/src/forms.c @@ -371,7 +371,7 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/msg.c b/src/msg.c index ddaab266..da4783d4 100644 --- a/src/msg.c +++ b/src/msg.c @@ -244,7 +244,7 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/password.c b/src/password.c index 1d17d913..d8f492f6 100644 --- a/src/password.c +++ b/src/password.c @@ -179,7 +179,7 @@ zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/progress.c b/src/progress.c index 8e458c66..4995c5fd 100644 --- a/src/progress.c +++ b/src/progress.c @@ -393,7 +393,7 @@ zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data); break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/scale.c b/src/scale.c index cc9ce105..3eb5c174 100644 --- a/src/scale.c +++ b/src/scale.c @@ -149,7 +149,7 @@ zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; diff --git a/src/text.c b/src/text.c index 5657f21c..1deecc64 100644 --- a/src/text.c +++ b/src/text.c @@ -388,7 +388,7 @@ zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); break; diff --git a/src/tree.c b/src/tree.c index 7398fc26..058b6b61 100644 --- a/src/tree.c +++ b/src/tree.c @@ -711,7 +711,7 @@ zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) break; default: - if (response < g_strv_length(zen_data->extra_label)) + if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) printf("%s\n",zen_data->extra_label[response]); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); break; -- cgit From 61c53a042418562c30e816fdd0c63caf2fa9f1b3 Mon Sep 17 00:00:00 2001 From: Tom Schoonjans Date: Sat, 17 Oct 2015 17:52:44 +0100 Subject: fix compilation when webkitgtk is not installed --- src/option.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/option.c b/src/option.c index 79a6f926..246cf226 100644 --- a/src/option.c +++ b/src/option.c @@ -2074,9 +2074,11 @@ zenity_text_post_callback (GOptionContext *context, if (zenity_text_font) zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), ERROR_SUPPORT); +#ifdef HAVE_WEBKITGTK if (zenity_text_enable_html) zenity_option_error (zenity_option_get_name (text_options, &zenity_text_enable_html), ERROR_SUPPORT); +#endif } return TRUE; } -- cgit From db4a0c3c0f8b224870ea23a3b3c25f800ee4870a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 17 Mar 2017 14:10:10 -0400 Subject: Fix misleading indentation Coverity flagged this. https://bugzilla.gnome.org/show_bug.cgi?id=780217 --- src/msg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index da4783d4..3fe102fa 100644 --- a/src/msg.c +++ b/src/msg.c @@ -200,7 +200,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); else gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); + zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); } if (msg_data->ellipsize) -- cgit From ef14066564b664328c69569aa0c66bdb49b496d5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Tue, 4 Apr 2017 15:08:33 +0200 Subject: Bug 762347: Addition of entry text width option This is a bug in the glade file, where the GtkEntry wasn't being filled to fill the width of the window. There is no need to add a --entry-text-width option --- src/zenity.ui | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/zenity.ui b/src/zenity.ui index 43b884f6..07915d34 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -1,5 +1,5 @@ - + @@ -440,7 +440,7 @@ - False + True True 0 -- cgit From 3b64d05e8a1aae1581d2bec7288d80ac4699e1b1 Mon Sep 17 00:00:00 2001 From: Alan Date: Sat, 18 Mar 2017 10:24:47 +0000 Subject: Fix message dialog width and height on recent Gtk The fix for Zenity bug 670496 "Zenity info/error windows grow in height with message length" (https://bugzilla.gnome.org/show_bug.cgi?id=670496) stopped working on recent Gtk, which doesn't seem to honor gtk_widget_set_size_request. This commit workarounds Gtk bug 657621 "Calculate the wrong height of labels wrapping on words" (https://bugzilla.gnome.org/show_bug.cgi?id=657621) by setting label's width-chars and max-width-chars to 60. This magic number was picked from GtkMessageDialog source (https://git.gnome.org/browse/gtk+/tree/gtk/ui/gtkmessagedialog.ui#n48). --- src/msg.c | 17 +++++++---------- src/zenity.ui | 8 ++++---- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/msg.c b/src/msg.c index 3fe102fa..d1ea6fae 100644 --- a/src/msg.c +++ b/src/msg.c @@ -27,7 +27,6 @@ #include "util.h" static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); -static void zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data); static void zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { @@ -188,9 +187,13 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) if (data->width > -1) gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); else - if (!msg_data->ellipsize) - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); + if (!msg_data->ellipsize && !msg_data->no_wrap) { + // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui + // however, 60 would increase the distance between the icon and the text, + // decreasing to 10 fix it. + gtk_label_set_width_chars (text, 10); + gtk_label_set_max_width_chars (text, 10); + } if (data->modal) gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); @@ -223,12 +226,6 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) gtk_main (); } -static void -zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) -{ - gtk_widget_set_size_request (widget, allocation->width/2, -1); -} - static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { diff --git a/src/zenity.ui b/src/zenity.ui index 07915d34..13594422 100644 --- a/src/zenity.ui +++ b/src/zenity.ui @@ -518,8 +518,8 @@ 6 - True - True + False + False 0 @@ -729,8 +729,8 @@ 6 - True - True + False + False 0 -- cgit From 4eddb202cafdcabc254aa941ad1348ff09372627 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 7 Apr 2017 14:00:42 +0200 Subject: Fix style Fixing style in all zenity code, removing useless spaces, empty lines, all code in 80 columns, etc. --- src/about.c | 161 +- src/calendar.c | 268 ++-- src/color.c | 166 +- src/entry.c | 324 ++-- src/fileselection.c | 344 +++-- src/forms.c | 708 ++++----- src/main.c | 145 +- src/msg.c | 435 +++--- src/notification.c | 606 ++++---- src/option.c | 4180 ++++++++++++++++++++++++--------------------------- src/option.h | 80 +- src/password.c | 298 ++-- src/progress.c | 673 +++++---- src/scale.c | 257 ++-- src/text.c | 695 +++++---- src/tree.c | 1392 +++++++++-------- src/util.c | 630 ++++---- src/util.h | 53 +- src/zenity.h | 271 ++-- 19 files changed, 5798 insertions(+), 5888 deletions(-) (limited to 'src') diff --git a/src/about.c b/src/about.c index 486b6416..627aa1ea 100644 --- a/src/about.c +++ b/src/about.c @@ -25,10 +25,10 @@ */ #include "config.h" -#include "zenity.h" #include "util.h" -#include +#include "zenity.h" #include +#include #define GTK_RESPONSE_CREDITS 0 #define ZENITY_HELP_PATH ZENITY_DATADIR "/help/" @@ -39,39 +39,38 @@ static GtkWidget *dialog; -static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_about_dialog_response ( + GtkWidget *widget, int response, gpointer data); /* Sync with the people in the THANKS file */ -static const gchar *const authors[] = { - "Glynn Foster ", - "Lucas Rocha ", - "Mike Newman ", - NULL -}; +static const gchar *const authors[] = {"Glynn Foster ", + "Lucas Rocha ", + "Mike Newman ", + NULL}; -static const char *documenters[] = { - "Glynn Foster ", - "Lucas Rocha ", - "Java Desktop System Documentation Team", - "GNOME Documentation Project", - NULL -}; +static const char *documenters[] = {"Glynn Foster ", + "Lucas Rocha ", + "Java Desktop System Documentation Team", + "GNOME Documentation Project", + NULL}; static gchar *translators; static const char *license[] = { - N_("This program is free software; you can redistribute it and/or modify " - "it under the terms of the GNU Lesser General Public License as published by " - "the Free Software Foundation; either version 2 of the License, or " - "(at your option) any later version.\n"), - N_("This program is distributed in the hope that it will be useful, " - "but WITHOUT ANY WARRANTY; without even the implied warranty of " - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " - "GNU Lesser General Public License for more details.\n"), - N_("You should have received a copy of the GNU Lesser General Public License " - "along with this program; if not, write to the Free Software " - "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.") -}; + N_ ("This program is free software; you can redistribute it and/or modify " + "it under the terms of the GNU Lesser General Public License as " + "published by " + "the Free Software Foundation; either version 2 of the License, or " + "(at your option) any later version.\n"), + N_ ("This program is distributed in the hope that it will be useful, " + "but WITHOUT ANY WARRANTY; without even the implied warranty of " + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the " + "GNU Lesser General Public License for more details.\n"), + N_ ("You should have received a copy of the GNU Lesser General Public " + "License " + "along with this program; if not, write to the Free Software " + "Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA " + "02110-1301, USA.")}; #if 0 static gint @@ -253,66 +252,78 @@ zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data) } #endif -void -zenity_about (ZenityData *data) -{ - GdkPixbuf *logo; - char *license_trans; - - - translators = _("translator-credits"); - logo = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); - - license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n", - _(license[2]), "\n", NULL); - - dialog = gtk_about_dialog_new (); - - g_object_set (G_OBJECT (dialog), - "name", "Zenity", - "version", VERSION, - "copyright", "Copyright \xc2\xa9 2003 Sun Microsystems", - "comments", _("Display dialog boxes from shell scripts"), - "authors", authors, - "documenters", documenters, - "translator-credits", translators, - "website", "http://live.gnome.org/Zenity", - "logo", logo, - "wrap-license", TRUE, - "license", license_trans, +void +zenity_about (ZenityData *data) { + GdkPixbuf *logo; + char *license_trans; + + translators = _ ("translator-credits"); + logo = + gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL); + + license_trans = g_strconcat ( + _ (license[0]), "\n", _ (license[1]), "\n", _ (license[2]), "\n", NULL); + + dialog = gtk_about_dialog_new (); + + g_object_set (G_OBJECT (dialog), + "name", + "Zenity", + "version", + VERSION, + "copyright", + "Copyright \xc2\xa9 2003 Sun Microsystems", + "comments", + _ ("Display dialog boxes from shell scripts"), + "authors", + authors, + "documenters", + documenters, + "translator-credits", + translators, + "website", + "http://live.gnome.org/Zenity", + "logo", + logo, + "wrap-license", + TRUE, + "license", + license_trans, NULL); - - g_free (license_trans); - zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); + g_free (license_trans); + + zenity_util_set_window_icon ( + dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png")); - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_about_dialog_response), data); + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_about_dialog_response), + data); #if 0 g_signal_connect (G_OBJECT (dialog), "key_press_event", G_CALLBACK (zenity_zen_wisdom), NULL); #endif - zenity_util_show_dialog (dialog, data->attach); - gtk_main (); + zenity_util_show_dialog (dialog, data->attach); + gtk_main (); } static void -zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; +zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; - switch (response) { - case GTK_RESPONSE_CLOSE: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - break; + switch (response) { + case GTK_RESPONSE_CLOSE: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + break; - default: - /* Esc dialog */ - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } + default: + /* Esc dialog */ + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } - gtk_main_quit (); + gtk_main_quit (); } diff --git a/src/calendar.c b/src/calendar.c index 9f82cc63..9aaf927f 100644 --- a/src/calendar.c +++ b/src/calendar.c @@ -23,146 +23,158 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" - +#include "zenity.h" +#include static GtkWidget *calendar; static ZenityCalendarData *zen_cal_data; -static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_calendar_dialog_response ( + GtkWidget *widget, int response, gpointer data); static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data); -void -zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - - zen_cal_data = cal_data; - - builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_calendar_dialog")); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_calendar_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - text = gtk_builder_get_object (builder, "zenity_calendar_text"); - - if (cal_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); - - calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); - - if (cal_data->month > 0 || cal_data->year > 0) - gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); - if (cal_data->day > 0) - gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); - - g_signal_connect (calendar, "day-selected-double-click", - G_CALLBACK (zenity_calendar_double_click), data); - - gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); - zenity_util_show_dialog (dialog, data->attach); - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - g_object_unref (builder); - - gtk_main (); +void +zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + + zen_cal_data = cal_data; + + builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_dialog")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_calendar_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon (dialog, + data->window_icon, + ZENITY_IMAGE_FULLPATH ("zenity-calendar.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + text = gtk_builder_get_object (builder, "zenity_calendar_text"); + + if (cal_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (cal_data->dialog_text)); + + calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar")); + + if (cal_data->month > 0 || cal_data->year > 0) + gtk_calendar_select_month ( + GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year); + if (cal_data->day > 0) + gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day); + + g_signal_connect (calendar, + "day-selected-double-click", + G_CALLBACK (zenity_calendar_double_click), + data); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar); + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_calendar_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_calendar_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + g_object_unref (builder); + + gtk_main (); } -static void -zenity_calendar_dialog_output (void) -{ - guint day, month, year; - gchar time_string[128]; - GDate *date = NULL; - - gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, zen_cal_data->date_format, date); - g_print ("%s\n", time_string); - - if (date != NULL) - g_date_free (date); +static void +zenity_calendar_dialog_output (void) { + guint day, month, year; + gchar time_string[128]; + GDate *date = NULL; + + gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime (time_string, 127, zen_cal_data->date_format, date); + g_print ("%s\n", time_string); + + if (date != NULL) + g_date_free (date); } static void -zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data; - - zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_calendar_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_calendar_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_calendar_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data; + + zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_calendar_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } static void -zenity_calendar_double_click (GtkCalendar *cal, gpointer data) -{ - zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); +zenity_calendar_double_click (GtkCalendar *cal, gpointer data) { + zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data); } diff --git a/src/color.c b/src/color.c index ae47b19b..9ef233eb 100644 --- a/src/color.c +++ b/src/color.c @@ -23,92 +23,96 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include static ZenityData *zen_data; -static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data); - -void zenity_colorselection (ZenityData *data, ZenityColorData *color_data) -{ - GtkWidget *dialog; - GtkWidget *button; - GdkRGBA color; - - zen_data = data; - - dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_colorselection_dialog_response), - color_data); - - if (color_data->color) { - if (gdk_rgba_parse (&color, color_data->color)) { - gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); - } - } - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - g_object_unref (G_OBJECT (button)); - } - - if (data->cancel_label) { - g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - g_object_unref (G_OBJECT (button)); - } - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); - - zenity_util_show_dialog (dialog, data->attach); - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, - (GSourceFunc) zenity_util_timeout_handle, - dialog); - } - - gtk_main(); +static void zenity_colorselection_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_colorselection (ZenityData *data, ZenityColorData *color_data) { + GtkWidget *dialog; + GtkWidget *button; + GdkRGBA color; + + zen_data = data; + + dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_colorselection_dialog_response), + color_data); + + if (color_data->color) { + if (gdk_rgba_parse (&color, color_data->color)) { + gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color); + } + } + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + g_object_unref (G_OBJECT (button)); + } + + if (data->cancel_label) { + g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + g_object_unref (G_OBJECT (button)); + } + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + g_object_set (dialog, "show-editor", !color_data->show_palette, NULL); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); } static void -zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - GdkRGBA color; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); - g_print ("%s\n", gdk_rgba_to_string (&color)); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - - gtk_main_quit (); +zenity_colorselection_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + GdkRGBA color; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color); + g_print ("%s\n", gdk_rgba_to_string (&color)); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); } diff --git a/src/entry.c b/src/entry.c index 8e47ebd8..bf3db713 100644 --- a/src/entry.c +++ b/src/entry.c @@ -23,179 +23,189 @@ #include "config.h" -#include "zenity.h" #include "util.h" +#include "zenity.h" -static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_entry_dialog_response ( + GtkWidget *widget, int response, gpointer data); static GtkWidget *entry; static gint n_entries = 0; static void -zenity_entry_fill_entries (GSList **entries, const gchar **args) -{ - gint i = 0; - - while (args[i] != NULL) { - *entries = g_slist_append (*entries, (gchar *) args[i]); - i++; - } +zenity_entry_fill_entries (GSList **entries, const gchar **args) { + gint i = 0; + + while (args[i] != NULL) { + *entries = g_slist_append (*entries, (gchar *) args[i]); + i++; + } } static void -zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) -{ - gtk_window_activate_default (GTK_WINDOW (window)); +zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) { + gtk_window_activate_default (GTK_WINDOW (window)); } -void -zenity_entry (ZenityData *data, ZenityEntryData *entry_data) -{ - GtkBuilder *builder = NULL; - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - GSList *entries = NULL; - GSList *tmp; - GObject *vbox; - - builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_entry_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - text = gtk_builder_get_object (builder, "zenity_entry_text"); - - if (entry_data->dialog_text) - gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); - - vbox = gtk_builder_get_object (builder, "vbox4"); - - zenity_entry_fill_entries(&entries, entry_data->data); - - n_entries = g_slist_length (entries); - - if (n_entries > 1) { - entry = gtk_combo_box_text_new_with_entry (); - - for (tmp = entries; tmp; tmp = tmp->next) { - gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data); - } - - if (entry_data->entry_text) { - gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); - gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); - } - - g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate", - G_CALLBACK (zenity_entry_combo_activate_default), - GTK_WINDOW (dialog)); - } else { - entry = gtk_entry_new(); - - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - - if (entry_data->entry_text) - gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); - - if (entry_data->hide_text) - g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); - } - - gtk_widget_show (entry); - - gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); - - g_object_unref (builder); - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - gtk_main (); -} +void +zenity_entry (ZenityData *data, ZenityEntryData *entry_data) { + GtkBuilder *builder = NULL; + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + GSList *entries = NULL; + GSList *tmp; + GObject *vbox; -static void -zenity_entry_dialog_output (void) -{ - const gchar *text; - if (n_entries > 1) - text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); - else - text = gtk_entry_get_text (GTK_ENTRY (entry)); + builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_entry_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_entry_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_entry_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + text = gtk_builder_get_object (builder, "zenity_entry_text"); + + if (entry_data->dialog_text) + gtk_label_set_text_with_mnemonic ( + GTK_LABEL (text), g_strcompress (entry_data->dialog_text)); - if (text != NULL) - g_print ("%s\n", text); + vbox = gtk_builder_get_object (builder, "vbox4"); + zenity_entry_fill_entries (&entries, entry_data->data); + + n_entries = g_slist_length (entries); + + if (n_entries > 1) { + entry = gtk_combo_box_text_new_with_entry (); + + for (tmp = entries; tmp; tmp = tmp->next) { + gtk_combo_box_text_append_text ( + GTK_COMBO_BOX_TEXT (entry), tmp->data); + } + + if (entry_data->entry_text) { + gtk_combo_box_text_prepend_text ( + GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text); + gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0); + } + + g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), + "activate", + G_CALLBACK (zenity_entry_combo_activate_default), + GTK_WINDOW (dialog)); + } else { + entry = gtk_entry_new (); + + gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); + + if (entry_data->entry_text) + gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text); + + if (entry_data->hide_text) + g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL); + } + + gtk_widget_show (entry); + + gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0); + + gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry); + + g_object_unref (builder); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); +} + +static void +zenity_entry_dialog_output (void) { + const gchar *text; + if (n_entries > 1) + text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry)); + else + text = gtk_entry_get_text (GTK_ENTRY (entry)); + + if (text != NULL) + g_print ("%s\n", text); } static void -zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_entry_dialog_output (); - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_entry_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_entry_dialog_output (); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_entry_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } diff --git a/src/fileselection.c b/src/fileselection.c index 27db0f40..521464b0 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -23,176 +23,192 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include -static ZenityData *zen_data; - -static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data); - -void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) -{ - GtkWidget *dialog; - gchar *dir; - gchar *basename; - GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; - - zen_data = data; - - if (file_data->directory) { - if (file_data->save) - action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; - else - action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; - } else { - if (file_data->save) - action = GTK_FILE_CHOOSER_ACTION_SAVE; - } - - dialog = gtk_file_chooser_dialog_new (NULL, NULL, - action, - _("_Cancel"), GTK_RESPONSE_CANCEL, - _("_OK"), GTK_RESPONSE_OK, - NULL); - - gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), - file_data->confirm_overwrite); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_fileselection_dialog_response), file_data); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (file_data->uri) { - dir = g_path_get_dirname (file_data->uri); - - if (g_path_is_absolute (file_data->uri) == TRUE) - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir); - - if (file_data->uri[strlen (file_data->uri) - 1] != '/') { - basename = g_path_get_basename (file_data->uri); - if (file_data->save) - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); - else - (void) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_data->uri); - g_free (basename); - } - g_free (dir); - } - - if (file_data->multi) - gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); - - if (file_data->filter) { - /* Filter format: Executables | *.exe *.bat *.com */ - gint filter_i; - - for (filter_i = 0; file_data->filter [filter_i]; filter_i++) { - GtkFileFilter *filter = gtk_file_filter_new(); - gchar *filter_str = file_data->filter [filter_i]; - gchar **pattern, **patterns; - gchar *name = NULL; - gint i; - - /* Set name */ - for (i = 0; filter_str[i] != '\0'; i++) - if (filter_str[i] == '|') - break; - - if (filter_str[i] == '|') { - name = g_strndup (filter_str, i); - g_strstrip (name); - } - - if (name) { - gtk_file_filter_set_name (filter, name); - - /* Point i to the right position for split */ - for (++i; filter_str[i] == ' '; i++); - } else { - gtk_file_filter_set_name (filter, filter_str); - i = 0; - } - - /* Get patterns */ - patterns = g_strsplit_set (filter_str + i, " ", -1); - - for (pattern = patterns; *pattern; pattern++) - gtk_file_filter_add_pattern (filter, *pattern); - - if (name) - g_free (name); - - g_strfreev (patterns); - - gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); - } - } - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - gtk_main (); +static ZenityData *zen_data; + +static void zenity_fileselection_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { + GtkWidget *dialog; + gchar *dir; + gchar *basename; + GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; + + zen_data = data; + + if (file_data->directory) { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER; + else + action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER; + } else { + if (file_data->save) + action = GTK_FILE_CHOOSER_ACTION_SAVE; + } + + dialog = gtk_file_chooser_dialog_new (NULL, + NULL, + action, + _ ("_Cancel"), + GTK_RESPONSE_CANCEL, + _ ("_OK"), + GTK_RESPONSE_OK, + NULL); + + gtk_file_chooser_set_do_overwrite_confirmation ( + GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_fileselection_dialog_response), + file_data); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (file_data->uri) { + dir = g_path_get_dirname (file_data->uri); + + if (g_path_is_absolute (file_data->uri) == TRUE) + gtk_file_chooser_set_current_folder ( + GTK_FILE_CHOOSER (dialog), dir); + + if (file_data->uri[strlen (file_data->uri) - 1] != '/') { + basename = g_path_get_basename (file_data->uri); + if (file_data->save) + gtk_file_chooser_set_current_name ( + GTK_FILE_CHOOSER (dialog), basename); + else + (void) gtk_file_chooser_set_filename ( + GTK_FILE_CHOOSER (dialog), file_data->uri); + g_free (basename); + } + g_free (dir); + } + + if (file_data->multi) + gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE); + + if (file_data->filter) { + /* Filter format: Executables | *.exe *.bat *.com */ + gint filter_i; + + for (filter_i = 0; file_data->filter[filter_i]; filter_i++) { + GtkFileFilter *filter = gtk_file_filter_new (); + gchar *filter_str = file_data->filter[filter_i]; + gchar **pattern, **patterns; + gchar *name = NULL; + gint i; + + /* Set name */ + for (i = 0; filter_str[i] != '\0'; i++) + if (filter_str[i] == '|') + break; + + if (filter_str[i] == '|') { + name = g_strndup (filter_str, i); + g_strstrip (name); + } + + if (name) { + gtk_file_filter_set_name (filter, name); + + /* Point i to the right position for split */ + for (++i; filter_str[i] == ' '; i++) + ; + } else { + gtk_file_filter_set_name (filter, filter_str); + i = 0; + } + + /* Get patterns */ + patterns = g_strsplit_set (filter_str + i, " ", -1); + + for (pattern = patterns; *pattern; pattern++) + gtk_file_filter_add_pattern (filter, *pattern); + + if (name) + g_free (name); + + g_strfreev (patterns); + + gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); + } + } + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); } static void -zenity_fileselection_dialog_output (GtkWidget *widget, ZenityFileData *file_data) -{ - GSList *selections, *iter; - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); - for (iter = selections;iter != NULL; iter = iter->next) { - g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL)); - g_free (iter->data); - if (iter->next != NULL) - g_print ("%s",file_data->separator); - } - g_print("\n"); - g_slist_free(selections); +zenity_fileselection_dialog_output ( + GtkWidget *widget, ZenityFileData *file_data) { + GSList *selections, *iter; + selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + for (iter = selections; iter != NULL; iter = iter->next) { + g_print ("%s", + g_filename_to_utf8 ((gchar *) iter->data, -1, NULL, NULL, NULL)); + g_free (iter->data); + if (iter->next != NULL) + g_print ("%s", file_data->separator); + } + g_print ("\n"); + g_slist_free (selections); } static void -zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityFileData *file_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_fileselection_dialog_output (widget, file_data); - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_fileselection_dialog_output (widget, file_data); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_fileselection_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + ZenityFileData *file_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_fileselection_dialog_output (widget, file_data); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_fileselection_dialog_output (widget, file_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } diff --git a/src/forms.c b/src/forms.c index 5241780c..4e6fca5d 100644 --- a/src/forms.c +++ b/src/forms.c @@ -22,360 +22,390 @@ */ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include static ZenityData *zen_data; static GSList *selected; -static void zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data); - -static void zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) -{ - gint n_columns = 0; - gint i = 0; - GValue value = {0, }; - - n_columns = gtk_tree_model_get_n_columns (model); - for (i = 0; i < n_columns; i++) { - gtk_tree_model_get_value (model, iter, i, &value); - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); - } +static void zenity_forms_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +static void +zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, + GtkTreeIter *iter, GtkTreeView *tree_view) { + gint n_columns = 0; + gint i = 0; + GValue value = { + 0, + }; + + n_columns = gtk_tree_model_get_n_columns (model); + for (i = 0; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } } static GtkWidget * -zenity_forms_create_and_fill_combo (ZenityFormsData *forms_data, int combo_number) -{ - GtkListStore *list_store; - GtkWidget *combo_box; - GtkCellRenderer *renderer; - gchar *combo_values; - - list_store = gtk_list_store_new (1, G_TYPE_STRING); - - if (forms_data->combo_values) { - combo_values = g_slist_nth_data (forms_data->combo_values, combo_number); - if (combo_values) { - gchar **row_values = g_strsplit_set (combo_values, "|", -1); - if (row_values) { - gint i = 0; - GtkTreeIter iter; - gchar *row = row_values[i]; - - while (row != NULL) { - gtk_list_store_append (list_store, &iter); - gtk_list_store_set (list_store, &iter, 0, row, -1); - row = row_values[++i]; - } - g_strfreev (row_values); - } - g_free (combo_values); - } - } - - combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); - g_object_unref (G_OBJECT (list_store)); - - renderer = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL); - - return combo_box; +zenity_forms_create_and_fill_combo ( + ZenityFormsData *forms_data, int combo_number) { + GtkListStore *list_store; + GtkWidget *combo_box; + GtkCellRenderer *renderer; + gchar *combo_values; + + list_store = gtk_list_store_new (1, G_TYPE_STRING); + + if (forms_data->combo_values) { + combo_values = + g_slist_nth_data (forms_data->combo_values, combo_number); + if (combo_values) { + gchar **row_values = g_strsplit_set (combo_values, "|", -1); + if (row_values) { + gint i = 0; + GtkTreeIter iter; + gchar *row = row_values[i]; + + while (row != NULL) { + gtk_list_store_append (list_store, &iter); + gtk_list_store_set (list_store, &iter, 0, row, -1); + row = row_values[++i]; + } + g_strfreev (row_values); + } + g_free (combo_values); + } + } + + combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store)); + g_object_unref (G_OBJECT (list_store)); + + renderer = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); + gtk_cell_layout_set_attributes ( + GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL); + + return combo_box; } -static GtkWidget * -zenity_forms_create_and_fill_list (ZenityFormsData *forms_data, - int list_number, gchar *header) -{ - GtkListStore *list_store; - GtkWidget *tree_view; - GtkWidget *scrolled_window; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GType *column_types = NULL; - gchar *list_values; - gchar *column_values; - - gint i = 0; - /* If no column names available, default is one */ - gint n_columns = 1; - gint column_index = 0; - - tree_view = gtk_tree_view_new (); - - if (forms_data->column_values) { - column_values = g_slist_nth_data (forms_data->column_values, list_number); - if (column_values) { - gchar **values = g_strsplit_set (column_values, "|", -1); - if (values) { - n_columns = g_strv_length (values); - column_types = g_new (GType, n_columns); - for (i = 0; i < n_columns; i++) - column_types[i] = G_TYPE_STRING; - - for (i = 0; i < n_columns; i++) { - gchar *column_name = values[i]; - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (column_name, - renderer, - "text", column_index, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); - column_index++; - } - } - } - } - - list_store = g_object_new (GTK_TYPE_LIST_STORE, NULL); - - gtk_list_store_set_column_types (list_store, n_columns, column_types); - - if (forms_data->list_values) { - list_values = g_slist_nth_data (forms_data->list_values, list_number); - if (list_values) { - gchar **row_values = g_strsplit_set (list_values, "|", -1); - if (row_values) { - GtkTreeIter iter; - gchar *row = row_values[0]; - gint position = -1; - i = 0; - - while (row != NULL) { - if (position >= n_columns || position == -1) { - position = 0; - gtk_list_store_append (list_store, &iter); - } - gtk_list_store_set (list_store, &iter, position, row, -1); - position++; - row = row_values[++i]; - } - g_strfreev (row_values); - } - g_free (list_values); - } - } - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); - g_object_unref (list_store); - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - //gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window), - // GTK_WIDGET (tree_view)); - gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view)); - gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), forms_data->show_header); - - return scrolled_window; +static GtkWidget * +zenity_forms_create_and_fill_list ( + ZenityFormsData *forms_data, int list_number, gchar *header) { + GtkListStore *list_store; + GtkWidget *tree_view; + GtkWidget *scrolled_window; + GtkCellRenderer *renderer; + GtkTreeViewColumn *column; + GType *column_types = NULL; + gchar *list_values; + gchar *column_values; + + gint i = 0; + /* If no column names available, default is one */ + gint n_columns = 1; + gint column_index = 0; + + tree_view = gtk_tree_view_new (); + + if (forms_data->column_values) { + column_values = + g_slist_nth_data (forms_data->column_values, list_number); + if (column_values) { + gchar **values = g_strsplit_set (column_values, "|", -1); + if (values) { + n_columns = g_strv_length (values); + column_types = g_new (GType, n_columns); + for (i = 0; i < n_columns; i++) + column_types[i] = G_TYPE_STRING; + + for (i = 0; i < n_columns; i++) { + gchar *column_name = values[i]; + renderer = gtk_cell_renderer_text_new (); + column = gtk_tree_view_column_new_with_attributes ( + column_name, renderer, "text", column_index, NULL); + gtk_tree_view_append_column ( + GTK_TREE_VIEW (tree_view), column); + column_index++; + } + } + } + } + + list_store = g_object_new (GTK_TYPE_LIST_STORE, NULL); + + gtk_list_store_set_column_types (list_store, n_columns, column_types); + + if (forms_data->list_values) { + list_values = g_slist_nth_data (forms_data->list_values, list_number); + if (list_values) { + gchar **row_values = g_strsplit_set (list_values, "|", -1); + if (row_values) { + GtkTreeIter iter; + gchar *row = row_values[0]; + gint position = -1; + i = 0; + + while (row != NULL) { + if (position >= n_columns || position == -1) { + position = 0; + gtk_list_store_append (list_store, &iter); + } + gtk_list_store_set (list_store, &iter, position, row, -1); + position++; + row = row_values[++i]; + } + g_strfreev (row_values); + } + g_free (list_values); + } + } + + gtk_tree_view_set_model ( + GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store)); + g_object_unref (list_store); + scrolled_window = gtk_scrolled_window_new (NULL, NULL); + // gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW + // (scrolled_window), + // GTK_WIDGET (tree_view)); + gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view)); + gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100); + gtk_tree_view_set_headers_visible ( + GTK_TREE_VIEW (tree_view), forms_data->show_header); + + return scrolled_window; } -void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) -{ - GtkBuilder *builder = NULL; - GtkWidget *dialog; - GtkWidget *grid; - GtkWidget *text; - GtkWidget *button; - - GSList *tmp; - - int list_count = 0; - int combo_count = 0; - int i = 0; - - zen_data = data; - - builder = zenity_util_load_ui_file("zenity_forms_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals(builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog")); - - g_signal_connect (G_OBJECT(dialog), "response", - G_CALLBACK (zenity_forms_dialog_response), forms_data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); - - if (forms_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text)); - - grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid")); - - for (tmp = forms_data->list; tmp; tmp = tmp->next) { - ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; - GtkWidget *label; - - label = gtk_label_new(zenity_value->option_value); - gtk_widget_set_halign (label, GTK_ALIGN_START); - gtk_grid_attach (GTK_GRID (grid), - label, - 0, i, - 1, 1); - - switch(zenity_value->type) - { - case ZENITY_FORMS_ENTRY: - zenity_value->forms_widget = gtk_entry_new(); - break; - case ZENITY_FORMS_PASSWORD: - zenity_value->forms_widget = gtk_entry_new(); - gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget), - FALSE); - break; - case ZENITY_FORMS_CALENDAR: - zenity_value->forms_widget = gtk_calendar_new(); - break; - case ZENITY_FORMS_LIST: - zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count, - zenity_value->option_value); - list_count++; - break; - case ZENITY_FORMS_COMBO: - zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count); - combo_count++; - break; - default: - zenity_value->forms_widget = gtk_entry_new(); - break; - } - - gtk_grid_attach_next_to (GTK_GRID (grid), - GTK_WIDGET (zenity_value->forms_widget), - label, - GTK_POS_RIGHT, - 1, 1); - - i++; - } - - gtk_widget_show_all (GTK_WIDGET (dialog)); - - g_object_unref (builder); - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - gtk_main(); +void +zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) { + GtkBuilder *builder = NULL; + GtkWidget *dialog; + GtkWidget *grid; + GtkWidget *text; + GtkWidget *button; + + GSList *tmp; + + int list_count = 0; + int combo_count = 0; + int i = 0; + + zen_data = data; + + builder = zenity_util_load_ui_file ("zenity_forms_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_forms_dialog_response), + forms_data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_forms_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_forms_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text")); + + if (forms_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (forms_data->dialog_text)); + + grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid")); + + for (tmp = forms_data->list; tmp; tmp = tmp->next) { + ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; + GtkWidget *label; + + label = gtk_label_new (zenity_value->option_value); + gtk_widget_set_halign (label, GTK_ALIGN_START); + gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1); + + switch (zenity_value->type) { + case ZENITY_FORMS_ENTRY: + zenity_value->forms_widget = gtk_entry_new (); + break; + case ZENITY_FORMS_PASSWORD: + zenity_value->forms_widget = gtk_entry_new (); + gtk_entry_set_visibility ( + GTK_ENTRY (zenity_value->forms_widget), FALSE); + break; + case ZENITY_FORMS_CALENDAR: + zenity_value->forms_widget = gtk_calendar_new (); + break; + case ZENITY_FORMS_LIST: + zenity_value->forms_widget = zenity_forms_create_and_fill_list ( + forms_data, list_count, zenity_value->option_value); + list_count++; + break; + case ZENITY_FORMS_COMBO: + zenity_value->forms_widget = + zenity_forms_create_and_fill_combo ( + forms_data, combo_count); + combo_count++; + break; + default: + zenity_value->forms_widget = gtk_entry_new (); + break; + } + + gtk_grid_attach_next_to (GTK_GRID (grid), + GTK_WIDGET (zenity_value->forms_widget), + label, + GTK_POS_RIGHT, + 1, + 1); + + i++; + } + + gtk_widget_show_all (GTK_WIDGET (dialog)); + + g_object_unref (builder); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); } static void -zenity_forms_dialog_output (ZenityFormsData *forms_data) -{ - GSList *tmp, *tmp2; - guint day, year, month; - GDate *date = NULL; - gchar time_string[128]; - gchar *combo_value = NULL; - GtkTreeSelection *selection; - GtkListStore *list_store; - GtkTreeIter iter; - - for (tmp = forms_data->list; tmp; tmp = tmp->next) { - ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; - switch (zenity_value->type) { - case ZENITY_FORMS_PASSWORD: - case ZENITY_FORMS_ENTRY: - g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget))); - break; - case ZENITY_FORMS_LIST: - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected, - GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); - - for (tmp2 = selected; tmp2; tmp2 = tmp2->next) { - if (tmp->next != NULL) { - g_print ("%s,", (gchar *) tmp2->data); - } - else - g_print ("%s", (gchar *) tmp2->data); - } - - g_slist_foreach (selected, (GFunc) g_free, NULL); - selected = NULL; - - break; - case ZENITY_FORMS_CALENDAR: - gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year); - date = g_date_new_dmy (year, month + 1, day); - g_date_strftime (time_string, 127, forms_data->date_format, date); - g_print ("%s", time_string); - break; - case ZENITY_FORMS_COMBO: - if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (zenity_value->forms_widget), &iter)) { - list_store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (zenity_value->forms_widget))); - gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, 0, &combo_value, -1); - g_object_unref (G_OBJECT (list_store)); - - g_print ("%s", combo_value); - g_free (combo_value); - } else - g_print (" "); - break; - - } - if (tmp->next != NULL) - g_print("%s", forms_data->separator); - } - g_print("\n"); +zenity_forms_dialog_output (ZenityFormsData *forms_data) { + GSList *tmp, *tmp2; + guint day, year, month; + GDate *date = NULL; + gchar time_string[128]; + gchar *combo_value = NULL; + GtkTreeSelection *selection; + GtkListStore *list_store; + GtkTreeIter iter; + + for (tmp = forms_data->list; tmp; tmp = tmp->next) { + ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data; + switch (zenity_value->type) { + case ZENITY_FORMS_PASSWORD: + case ZENITY_FORMS_ENTRY: + g_print ("%s", + gtk_entry_get_text ( + GTK_ENTRY (zenity_value->forms_widget))); + break; + case ZENITY_FORMS_LIST: + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW ( + gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget)))); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) + zenity_forms_dialog_get_selected, + GTK_TREE_VIEW (gtk_bin_get_child ( + GTK_BIN (zenity_value->forms_widget)))); + + for (tmp2 = selected; tmp2; tmp2 = tmp2->next) { + if (tmp->next != NULL) { + g_print ("%s,", (gchar *) tmp2->data); + } else + g_print ("%s", (gchar *) tmp2->data); + } + + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; + + break; + case ZENITY_FORMS_CALENDAR: + gtk_calendar_get_date ( + GTK_CALENDAR (zenity_value->forms_widget), + &day, + &month, + &year); + date = g_date_new_dmy (year, month + 1, day); + g_date_strftime ( + time_string, 127, forms_data->date_format, date); + g_print ("%s", time_string); + break; + case ZENITY_FORMS_COMBO: + if (gtk_combo_box_get_active_iter ( + GTK_COMBO_BOX (zenity_value->forms_widget), &iter)) { + list_store = GTK_LIST_STORE (gtk_combo_box_get_model ( + GTK_COMBO_BOX (zenity_value->forms_widget))); + gtk_tree_model_get (GTK_TREE_MODEL (list_store), + &iter, + 0, + &combo_value, + -1); + g_object_unref (G_OBJECT (list_store)); + + g_print ("%s", combo_value); + g_free (combo_value); + } else + g_print (" "); + break; + } + if (tmp->next != NULL) + g_print ("%s", forms_data->separator); + } + g_print ("\n"); } static void -zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityFormsData *forms_data = (ZenityFormsData *) data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_forms_dialog_output (forms_data); - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_forms_dialog_output (forms_data); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - - gtk_main_quit (); +zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityFormsData *forms_data = (ZenityFormsData *) data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_forms_dialog_output (forms_data); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_forms_dialog_output (forms_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); } diff --git a/src/main.c b/src/main.c index e667ee1a..7f0c2db7 100644 --- a/src/main.c +++ b/src/main.c @@ -23,97 +23,98 @@ #include -#include "zenity.h" #include "option.h" +#include "zenity.h" -#include #include #include #include +#include #ifdef HAVE_LOCALE_H #include #endif -gint +gint main (gint argc, gchar **argv) { - ZenityParsingOptions *results; - gint retval; + ZenityParsingOptions *results; + gint retval; #ifdef HAVE_LOCALE_H - setlocale(LC_ALL,""); + setlocale (LC_ALL, ""); #endif - bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR); - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); - textdomain(GETTEXT_PACKAGE); + bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); + bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); + textdomain (GETTEXT_PACKAGE); - gtk_init (&argc, &argv); + gtk_init (&argc, &argv); - results = zenity_option_parse (argc, argv); + results = zenity_option_parse (argc, argv); - switch (results->mode) { - case MODE_CALENDAR: - zenity_calendar (results->data, results->calendar_data); - break; - case MODE_ENTRY: - results->entry_data->data = (const gchar **) argv + 1; - zenity_entry (results->data, results->entry_data); - break; - case MODE_ERROR: - case MODE_QUESTION: - case MODE_WARNING: - case MODE_INFO: - zenity_msg (results->data, results->msg_data); - break; - case MODE_SCALE: - zenity_scale (results->data, results->scale_data); - break; - case MODE_FILE: - zenity_fileselection (results->data, results->file_data); - break; - case MODE_LIST: - results->tree_data->data = (const gchar **) argv + 1; - zenity_tree (results->data, results->tree_data); - break; + switch (results->mode) { + case MODE_CALENDAR: + zenity_calendar (results->data, results->calendar_data); + break; + case MODE_ENTRY: + results->entry_data->data = (const gchar **) argv + 1; + zenity_entry (results->data, results->entry_data); + break; + case MODE_ERROR: + case MODE_QUESTION: + case MODE_WARNING: + case MODE_INFO: + zenity_msg (results->data, results->msg_data); + break; + case MODE_SCALE: + zenity_scale (results->data, results->scale_data); + break; + case MODE_FILE: + zenity_fileselection (results->data, results->file_data); + break; + case MODE_LIST: + results->tree_data->data = (const gchar **) argv + 1; + zenity_tree (results->data, results->tree_data); + break; #ifdef HAVE_LIBNOTIFY - case MODE_NOTIFICATION: - zenity_notification (results->data, results->notification_data); - break; + case MODE_NOTIFICATION: + zenity_notification (results->data, results->notification_data); + break; #endif - case MODE_PROGRESS: - zenity_progress (results->data, results->progress_data); - break; - case MODE_TEXTINFO: - zenity_text (results->data, results->text_data); - break; - case MODE_COLOR: - zenity_colorselection (results->data, results->color_data); - break; - case MODE_PASSWORD: - zenity_password_dialog (results->data, results->password_data); - break; - case MODE_ABOUT: - zenity_about (results->data); - break; - case MODE_FORMS: - zenity_forms_dialog (results->data, results->forms_data); - break; - case MODE_VERSION: - g_print ("%s\n", VERSION); - break; - case MODE_LAST: - g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n")); - zenity_option_free (); - exit (-1); - default: - g_assert_not_reached (); - zenity_option_free (); - exit (-1); - } + case MODE_PROGRESS: + zenity_progress (results->data, results->progress_data); + break; + case MODE_TEXTINFO: + zenity_text (results->data, results->text_data); + break; + case MODE_COLOR: + zenity_colorselection (results->data, results->color_data); + break; + case MODE_PASSWORD: + zenity_password_dialog (results->data, results->password_data); + break; + case MODE_ABOUT: + zenity_about (results->data); + break; + case MODE_FORMS: + zenity_forms_dialog (results->data, results->forms_data); + break; + case MODE_VERSION: + g_print ("%s\n", VERSION); + break; + case MODE_LAST: + g_printerr (_ ("You must specify a dialog type. See 'zenity " + "--help' for details\n")); + zenity_option_free (); + exit (-1); + default: + g_assert_not_reached (); + zenity_option_free (); + exit (-1); + } + + retval = results->data->exit_code; - retval = results->data->exit_code; - - zenity_option_free (); + zenity_option_free (); - exit (retval); + exit (retval); } diff --git a/src/msg.c b/src/msg.c index d1ea6fae..ca14d867 100644 --- a/src/msg.c +++ b/src/msg.c @@ -23,228 +23,247 @@ #include "config.h" -#include "zenity.h" #include "util.h" +#include "zenity.h" -static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_msg_dialog_response ( + GtkWidget *widget, int response, gpointer data); static void -zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) -{ - +zenity_msg_construct_question_dialog ( + GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) { - GtkWidget *cancel_button, *ok_button; - - cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL); - ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Yes"), GTK_RESPONSE_OK); + GtkWidget *cancel_button, *ok_button; - gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button); + cancel_button = gtk_dialog_add_button ( + GTK_DIALOG (dialog), _ ("_No"), GTK_RESPONSE_CANCEL); + ok_button = gtk_dialog_add_button ( + GTK_DIALOG (dialog), _ ("_Yes"), GTK_RESPONSE_OK); - if (data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - } + gtk_widget_grab_focus ( + msg_data->default_cancel ? cancel_button : ok_button); - if (data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - } - + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); + } + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + } } static void -zenity_label_widget_clipboard_selection(GtkWidget *widget) -{ - /* Workaround hotfix for suspected toolkit issue: - since focus change of the dialog's focussed widget (text) - somehow currently chooses to destroy - a pre-existing (read: foreign, user-initiated) X11 primary selection - (via gtk_label_select_region() -> ... - -> gtk_clipboard_set_contents()/gtk_clipboard_clear()), - we need to ensure - that the widget does have its gtk-label-select-on-focus property off, - in order to avoid having the label become selected automatically - and thereby having pre-existing clipboard content nullified. - Side note: this selection issue only applies to widgets - which have both - True - True - . - */ - g_object_set(gtk_widget_get_settings (widget), - "gtk-label-select-on-focus", - FALSE, - NULL); +zenity_label_widget_clipboard_selection (GtkWidget *widget) { + /* Workaround hotfix for suspected toolkit issue: + since focus change of the dialog's focussed widget (text) + somehow currently chooses to destroy + a pre-existing (read: foreign, user-initiated) X11 primary selection + (via gtk_label_select_region() -> ... + -> gtk_clipboard_set_contents()/gtk_clipboard_clear()), + we need to ensure + that the widget does have its gtk-label-select-on-focus property off, + in order to avoid having the label become selected automatically + and thereby having pre-existing clipboard content nullified. + Side note: this selection issue only applies to widgets + which have both + True + True + . + */ + g_object_set (gtk_widget_get_settings (widget), + "gtk-label-select-on-focus", + FALSE, + NULL); } -void -zenity_msg (ZenityData *data, ZenityMsgData *msg_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *ok_button; - GObject *text; - GObject *image; - - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog")); - text = gtk_builder_get_object (builder, "zenity_warning_text"); - image = gtk_builder_get_object (builder, "zenity_warning_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button")); - break; - - case ZENITY_MSG_QUESTION: - case ZENITY_MSG_SWITCH: - builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog")); - text = gtk_builder_get_object (builder, "zenity_question_text"); - image = gtk_builder_get_object (builder, "zenity_question_image"); - ok_button = NULL; - break; - - case ZENITY_MSG_ERROR: - builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog")); - text = gtk_builder_get_object (builder, "zenity_error_text"); - image = gtk_builder_get_object (builder, "zenity_error_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button")); - break; - - case ZENITY_MSG_INFO: - builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog")); - text = gtk_builder_get_object (builder, "zenity_info_text"); - image = gtk_builder_get_object (builder, "zenity_info_image"); - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button")); - break; - - default: - builder = NULL; - dialog = NULL; - text = NULL; - image = NULL; - ok_button = NULL; - g_assert_not_reached (); - break; - } - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_msg_dialog_response), data); - - gtk_builder_connect_signals (builder, NULL); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - if (ok_button) { - if (data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - } - } - - switch (msg_data->mode) { - case ZENITY_MSG_WARNING: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-warning"); - break; - - case ZENITY_MSG_QUESTION: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); - zenity_msg_construct_question_dialog (dialog, msg_data, data); - break; - - case ZENITY_MSG_SWITCH: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question"); - break; - - case ZENITY_MSG_ERROR: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error"); - break; - - case ZENITY_MSG_INFO: - zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-information"); - break; - - default: - break; - } - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->width > -1) - gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); - else - if (!msg_data->ellipsize && !msg_data->no_wrap) { - // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui - // however, 60 would increase the distance between the icon and the text, - // decreasing to 10 fix it. - gtk_label_set_width_chars (text, 10); - gtk_label_set_max_width_chars (text, 10); - } - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (msg_data->dialog_text) { - if (msg_data->no_markup) - gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); - else - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); - zenity_label_widget_clipboard_selection(GTK_WIDGET (text)); - } - - if (msg_data->ellipsize) - gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT); - - if (msg_data->dialog_icon) - gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); - - if (msg_data->no_wrap) - gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); - } - - g_object_unref (builder); - - gtk_main (); +void +zenity_msg (ZenityData *data, ZenityMsgData *msg_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *ok_button; + GObject *text; + GObject *image; + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_warning_dialog")); + text = gtk_builder_get_object (builder, "zenity_warning_text"); + image = gtk_builder_get_object (builder, "zenity_warning_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_warning_ok_button")); + break; + + case ZENITY_MSG_QUESTION: + case ZENITY_MSG_SWITCH: + builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_question_dialog")); + text = gtk_builder_get_object (builder, "zenity_question_text"); + image = gtk_builder_get_object (builder, "zenity_question_image"); + ok_button = NULL; + break; + + case ZENITY_MSG_ERROR: + builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_error_dialog")); + text = gtk_builder_get_object (builder, "zenity_error_text"); + image = gtk_builder_get_object (builder, "zenity_error_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_error_ok_button")); + break; + + case ZENITY_MSG_INFO: + builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL); + dialog = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_info_dialog")); + text = gtk_builder_get_object (builder, "zenity_info_text"); + image = gtk_builder_get_object (builder, "zenity_info_image"); + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_info_ok_button")); + break; + + default: + builder = NULL; + dialog = NULL; + text = NULL; + image = NULL; + ok_button = NULL; + g_assert_not_reached (); + break; + } + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_msg_dialog_response), + data); + + gtk_builder_connect_signals (builder, NULL); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (ok_button) { + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + } + } + + switch (msg_data->mode) { + case ZENITY_MSG_WARNING: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-warning"); + break; + + case ZENITY_MSG_QUESTION: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-question"); + zenity_msg_construct_question_dialog (dialog, msg_data, data); + break; + + case ZENITY_MSG_SWITCH: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-question"); + break; + + case ZENITY_MSG_ERROR: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-error"); + break; + + case ZENITY_MSG_INFO: + zenity_util_set_window_icon_from_icon_name ( + dialog, data->window_icon, "dialog-information"); + break; + + default: + break; + } + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->width > -1) + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + else if (!msg_data->ellipsize && !msg_data->no_wrap) { + // the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui + // however, 60 would increase the distance between the icon and the + // text, + // decreasing to 10 fix it. + gtk_label_set_width_chars (text, 10); + gtk_label_set_max_width_chars (text, 10); + } + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (msg_data->dialog_text) { + if (msg_data->no_markup) + gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text); + else + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (msg_data->dialog_text)); + zenity_label_widget_clipboard_selection (GTK_WIDGET (text)); + } + + if (msg_data->ellipsize) + gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ALIGN_RIGHT); + + if (msg_data->dialog_icon) + gtk_image_set_from_icon_name ( + GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG); + + if (msg_data->no_wrap) + gtk_label_set_line_wrap (GTK_LABEL (text), FALSE); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + + g_object_unref (builder); + + gtk_main (); } static void -zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } diff --git a/src/notification.c b/src/notification.c index 9bbd6ce1..eb0e79eb 100644 --- a/src/notification.c +++ b/src/notification.c @@ -24,16 +24,16 @@ #include -#include -#include #include -#include +#include #include +#include +#include #ifdef HAVE_LIBNOTIFY #include -#include "zenity.h" #include "util.h" +#include "zenity.h" #define MAX_HINTS 16 @@ -41,337 +41,331 @@ static char *icon_file; static GHashTable *notification_hints; static NotifyNotification * -zenity_notification_new(gchar *message, gchar *icon_file) -{ - NotifyNotification *notif; - gchar **text; - - text = g_strsplit (g_strcompress (message), "\n", 2); - if (*text == NULL) { - g_printerr (_("Could not parse message\n")); - return NULL; - } - - notif = notify_notification_new (text[0], /* title */ - text[1], /* summary */ - icon_file); - g_strfreev (text); - return notif; +zenity_notification_new (gchar *message, gchar *icon_file) { + NotifyNotification *notif; + gchar **text; + + text = g_strsplit (g_strcompress (message), "\n", 2); + if (*text == NULL) { + g_printerr (_ ("Could not parse message\n")); + return NULL; + } + + notif = notify_notification_new (text[0], /* title */ + text[1], /* summary */ + icon_file); + g_strfreev (text); + return notif; } static void -on_notification_default_action (NotifyNotification *n, - const char *action, - void *user_data) -{ - ZenityData *zen_data; +on_notification_default_action ( + NotifyNotification *n, const char *action, void *user_data) { + ZenityData *zen_data; - zen_data = (ZenityData *)user_data; - notify_notification_close (n, NULL); + zen_data = (ZenityData *) user_data; + notify_notification_close (n, NULL); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); + gtk_main_quit (); } static GHashTable * -zenity_notification_parse_hints_array (gchar **hints) -{ - GHashTable *result; - gchar** pair; - int i; - - result = g_hash_table_new_full (g_str_hash, - g_str_equal, - g_free, - g_free); - - for(i = 0; i < g_strv_length (hints); i++) { - pair = g_strsplit (hints[i], ":", 2); - g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1])); - g_strfreev (pair); - } - if (g_hash_table_size (result) == 0) { - g_hash_table_unref (result); - return NULL; - } else { - return result; - } +zenity_notification_parse_hints_array (gchar **hints) { + GHashTable *result; + gchar **pair; + int i; + + result = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free); + + for (i = 0; i < g_strv_length (hints); i++) { + pair = g_strsplit (hints[i], ":", 2); + g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1])); + g_strfreev (pair); + } + if (g_hash_table_size (result) == 0) { + g_hash_table_unref (result); + return NULL; + } else { + return result; + } } static GHashTable * -zenity_notification_parse_hints (gchar *hints) -{ - GHashTable *result; - gchar** hint_array; - - hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS); - result = zenity_notification_parse_hints_array (hint_array); - g_strfreev (hint_array); - return result; +zenity_notification_parse_hints (gchar *hints) { + GHashTable *result; + gchar **hint_array; + + hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS); + result = zenity_notification_parse_hints_array (hint_array); + g_strfreev (hint_array); + return result; } static void -zenity_notification_set_hint(gpointer key, gpointer value, gpointer user_data) -{ - NotifyNotification *notification; - gchar *hint_name; - GVariant *hint_value; - - gchar *string_value; - gboolean boolean_value; - gint32 int_value; - guchar byte_value; - - hint_name = (gchar *) key; - string_value = (gchar *) value; - notification = (NotifyNotification *) user_data; - - if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0) - || (g_ascii_strcasecmp ("resident", hint_name) == 0) - || (g_ascii_strcasecmp ("suppress-sound", hint_name) == 0) - || (g_ascii_strcasecmp ("transient", hint_name) == 0)) { - /* boolean hints */ - if (g_ascii_strcasecmp ("true", string_value) == 0) { - boolean_value = TRUE; - } else if (g_ascii_strcasecmp ("false", string_value) == 0) { - boolean_value = FALSE; - } else { - g_printerr (_("Invalid value for a boolean typed hint.\nSupported values are 'true' or 'false'.\n")); - return; - } - hint_value = g_variant_new_boolean (boolean_value); - } else if ((g_ascii_strcasecmp ("category", hint_name) == 0) - || (g_ascii_strcasecmp ("desktop-entry", hint_name) == 0) - || (g_ascii_strcasecmp ("image-path", hint_name) == 0) - || (g_ascii_strcasecmp ("image_path", hint_name) == 0) - || (g_ascii_strcasecmp ("sound-file", hint_name) == 0) - || (g_ascii_strcasecmp ("sound-name", hint_name) == 0)) { - /* string hints */ - hint_value = g_variant_new_string (string_value); - } else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0) - || (g_ascii_strcasecmp ("image_data", hint_name) == 0) - || (g_ascii_strcasecmp ("icon-data", hint_name) == 0)) { - /* (iibiiay) */ - g_printerr (_("Unsupported hint. Skipping.\n")); - return; - } else if ((g_ascii_strcasecmp ("x", hint_name) == 0) - || (g_ascii_strcasecmp ("y", hint_name) == 0)) { - /* int hints */ - if (string_value == NULL) - string_value = ""; - int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0); - hint_value = g_variant_new_int32 (int_value); - } else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) { - /* byte hints */ - if (string_value == NULL) - string_value = ""; - byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0); - hint_value = g_variant_new_byte (byte_value); - } else { - /* unknown hints */ - g_printerr (_("Unknown hint name. Skipping.\n")); - return; - } - - notify_notification_set_hint (notification, - hint_name, - hint_value); +zenity_notification_set_hint ( + gpointer key, gpointer value, gpointer user_data) { + NotifyNotification *notification; + gchar *hint_name; + GVariant *hint_value; + + gchar *string_value; + gboolean boolean_value; + gint32 int_value; + guchar byte_value; + + hint_name = (gchar *) key; + string_value = (gchar *) value; + notification = (NotifyNotification *) user_data; + + if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0) || + (g_ascii_strcasecmp ("resident", hint_name) == 0) || + (g_ascii_strcasecmp ("suppress-sound", hint_name) == 0) || + (g_ascii_strcasecmp ("transient", hint_name) == 0)) { + /* boolean hints */ + if (g_ascii_strcasecmp ("true", string_value) == 0) { + boolean_value = TRUE; + } else if (g_ascii_strcasecmp ("false", string_value) == 0) { + boolean_value = FALSE; + } else { + g_printerr (_ ("Invalid value for a boolean typed hint.\nSupported " + "values are 'true' or 'false'.\n")); + return; + } + hint_value = g_variant_new_boolean (boolean_value); + } else if ((g_ascii_strcasecmp ("category", hint_name) == 0) || + (g_ascii_strcasecmp ("desktop-entry", hint_name) == 0) || + (g_ascii_strcasecmp ("image-path", hint_name) == 0) || + (g_ascii_strcasecmp ("image_path", hint_name) == 0) || + (g_ascii_strcasecmp ("sound-file", hint_name) == 0) || + (g_ascii_strcasecmp ("sound-name", hint_name) == 0)) { + /* string hints */ + hint_value = g_variant_new_string (string_value); + } else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0) || + (g_ascii_strcasecmp ("image_data", hint_name) == 0) || + (g_ascii_strcasecmp ("icon-data", hint_name) == 0)) { + /* (iibiiay) */ + g_printerr (_ ("Unsupported hint. Skipping.\n")); + return; + } else if ((g_ascii_strcasecmp ("x", hint_name) == 0) || + (g_ascii_strcasecmp ("y", hint_name) == 0)) { + /* int hints */ + if (string_value == NULL) + string_value = ""; + int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0); + hint_value = g_variant_new_int32 (int_value); + } else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) { + /* byte hints */ + if (string_value == NULL) + string_value = ""; + byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0); + hint_value = g_variant_new_byte (byte_value); + } else { + /* unknown hints */ + g_printerr (_ ("Unknown hint name. Skipping.\n")); + return; + } + + notify_notification_set_hint (notification, hint_name, hint_value); } static void -zenity_notification_set_hints (NotifyNotification *notification, GHashTable *hints) -{ - if (hints == NULL) { - return; - } +zenity_notification_set_hints ( + NotifyNotification *notification, GHashTable *hints) { + if (hints == NULL) { + return; + } - g_hash_table_foreach (hints, zenity_notification_set_hint, notification); + g_hash_table_foreach (hints, zenity_notification_set_hint, notification); } static gboolean -zenity_notification_handle_stdin (GIOChannel *channel, - GIOCondition condition, - gpointer user_data) -{ - if ((condition & G_IO_IN) != 0) { - GString *string; - GError *error = NULL; - - string = g_string_new (NULL); - while (channel->is_readable == FALSE) - ; - do { - gint status; - gchar *command, *value, *colon; - - do { - status = g_io_channel_read_line_string (channel, string, NULL, &error); - while (gdk_events_pending ()) - gtk_main_iteration (); - - } while (status == G_IO_STATUS_AGAIN); - - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_warning ("zenity_notification_handle_stdin () : %s", - error->message); - g_error_free (error); - error = NULL; +zenity_notification_handle_stdin ( + GIOChannel *channel, GIOCondition condition, gpointer user_data) { + if ((condition & G_IO_IN) != 0) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + while (channel->is_readable == FALSE) + ; + do { + gint status; + gchar *command, *value, *colon; + + do { + status = g_io_channel_read_line_string ( + channel, string, NULL, &error); + while (gdk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_notification_handle_stdin () : %s", + error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + zenity_util_strip_newline (string->str); + colon = strchr (string->str, ':'); + if (colon == NULL) { + g_printerr (_ ("Could not parse command from stdin\n")); + continue; + } + /* split off the command and value */ + command = g_strstrip (g_strndup (string->str, colon - string->str)); + + value = colon + 1; + while (*value && g_ascii_isspace (*value)) + value++; + + if (!g_ascii_strcasecmp (command, "icon")) { + g_free (icon_file); + icon_file = g_strdup (value); + } else if (!g_ascii_strcasecmp (command, "hints")) { + if (notification_hints != NULL) { + g_hash_table_unref (notification_hints); + } + notification_hints = zenity_notification_parse_hints (value); + } else if (!g_ascii_strcasecmp (command, "message")) { + /* display a notification bubble */ + if (!g_utf8_validate (value, -1, NULL)) { + g_warning ("Invalid UTF-8 in input!"); + } else { + NotifyNotification *notif; + error = NULL; + + notif = zenity_notification_new (value, icon_file); + if (notif == NULL) + continue; + + zenity_notification_set_hints (notif, notification_hints); + + notify_notification_show (notif, &error); + if (error) { + g_warning ( + "Error showing notification: %s", error->message); + g_error_free (error); + error = NULL; + } + + g_object_unref (notif); + } + } else if (!g_ascii_strcasecmp (command, "tooltip")) { + if (!g_utf8_validate (value, -1, NULL)) { + g_warning ("Invalid UTF-8 in input!"); + } else { + NotifyNotification *notif; + notif = zenity_notification_new (value, icon_file); + if (notif == NULL) + continue; + + zenity_notification_set_hints (notif, notification_hints); + + notify_notification_show (notif, &error); + if (error) { + g_warning ( + "Error showing notification: %s", error->message); + g_error_free (error); + error = NULL; + } + } + } else if (!g_ascii_strcasecmp (command, "visible")) { + + } else { + g_warning ("Unknown command '%s'", command); + } + g_free (command); + + } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); + g_string_free (string, TRUE); + } + + if ((condition & G_IO_HUP) != 0) { + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; } - continue; - } - - zenity_util_strip_newline (string->str); - colon = strchr(string->str, ':'); - if (colon == NULL) { - g_printerr (_("Could not parse command from stdin\n")); - continue; - } - /* split off the command and value */ - command = g_strstrip (g_strndup (string->str, colon - string->str)); - - value = colon + 1; - while (*value && g_ascii_isspace (*value)) value++; - - if (!g_ascii_strcasecmp (command, "icon")) { - g_free (icon_file); - icon_file = g_strdup (value); - } else if (!g_ascii_strcasecmp (command, "hints")) { - if (notification_hints != NULL) { - g_hash_table_unref (notification_hints); - } - notification_hints = zenity_notification_parse_hints (value); - } else if (!g_ascii_strcasecmp (command, "message")) { - /* display a notification bubble */ - if (!g_utf8_validate (value, -1, NULL)) { - g_warning ("Invalid UTF-8 in input!"); - } else { - NotifyNotification *notif; - error = NULL; - - notif = zenity_notification_new (value, icon_file); - if (notif == NULL) - continue; - - zenity_notification_set_hints (notif, notification_hints); - - notify_notification_show (notif, &error); - if (error) { - g_warning ("Error showing notification: %s", error->message); - g_error_free (error); - error = NULL; - } - - g_object_unref (notif); - } - } else if (!g_ascii_strcasecmp (command, "tooltip")) { - if (!g_utf8_validate (value, -1, NULL)) { - g_warning ("Invalid UTF-8 in input!"); - } else { - NotifyNotification *notif; - notif = zenity_notification_new (value, icon_file); - if (notif == NULL) - continue; - - zenity_notification_set_hints (notif, notification_hints); - - notify_notification_show (notif, &error); - if (error) { - g_warning ("Error showing notification: %s", error->message); - g_error_free (error); - error = NULL; - } - } - } else if (!g_ascii_strcasecmp (command, "visible")) { - - } else { - g_warning ("Unknown command '%s'", command); - } - g_free (command); - - } while (g_io_channel_get_buffer_condition (channel) == G_IO_IN); - g_string_free (string, TRUE); - } - - if ((condition & G_IO_HUP) != 0) { - g_io_channel_shutdown (channel, TRUE, NULL); - return FALSE; - } - - return TRUE; + + return TRUE; } static void -zenity_notification_listen_on_stdin (ZenityData *data) -{ - GIOChannel *channel; - - channel = g_io_channel_unix_new (0); - g_io_channel_set_encoding (channel, NULL, NULL); - g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, - zenity_notification_handle_stdin, data); +zenity_notification_listen_on_stdin (ZenityData *data) { + GIOChannel *channel; + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch ( + channel, G_IO_IN | G_IO_HUP, zenity_notification_handle_stdin, data); } void -zenity_notification (ZenityData *data, ZenityNotificationData *notification_data) -{ - GError *error; - NotifyNotification *notification; - GHashTable *notification_hints; - - /* create the notification widget */ - if (!notify_is_initted ()) { - notify_init (_("Zenity notification")); - } - - if (notification_data->listen) { - zenity_notification_listen_on_stdin (data); - gtk_main(); - } else { - if (notification_data->notification_text == NULL) { - exit (1); - } - - notification = zenity_notification_new (notification_data->notification_text, - data->window_icon); - - if (notification == NULL) { - exit (1); - } - - /* if we aren't listening for changes, then close on default action */ - notify_notification_add_action (notification, - "default", - "Do Default Action", - (NotifyActionCallback) on_notification_default_action, - data, - NULL); - - /* set the notification hints for the displayed notification */ - if (notification_data->notification_hints != NULL) { - notification_hints = zenity_notification_parse_hints_array (notification_data->notification_hints); - zenity_notification_set_hints(notification, notification_hints); - g_hash_table_unref (notification_hints); - } - - /* Show icon and wait */ - error = NULL; - if (!notify_notification_show (notification, &error)) { - if (error != NULL) { - g_warning ("Error showing notification: %s", error->message); - g_error_free (error); - } - exit (1); - } - - } - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); - gtk_main(); - } +zenity_notification ( + ZenityData *data, ZenityNotificationData *notification_data) { + GError *error; + NotifyNotification *notification; + GHashTable *notification_hints; + + /* create the notification widget */ + if (!notify_is_initted ()) { + notify_init (_ ("Zenity notification")); + } + + if (notification_data->listen) { + zenity_notification_listen_on_stdin (data); + gtk_main (); + } else { + if (notification_data->notification_text == NULL) { + exit (1); + } + + notification = zenity_notification_new ( + notification_data->notification_text, data->window_icon); + + if (notification == NULL) { + exit (1); + } + + /* if we aren't listening for changes, then close on default action */ + notify_notification_add_action (notification, + "default", + "Do Default Action", + (NotifyActionCallback) on_notification_default_action, + data, + NULL); + + /* set the notification hints for the displayed notification */ + if (notification_data->notification_hints != NULL) { + notification_hints = zenity_notification_parse_hints_array ( + notification_data->notification_hints); + zenity_notification_set_hints (notification, notification_hints); + g_hash_table_unref (notification_hints); + } + + /* Show icon and wait */ + error = NULL; + if (!notify_notification_show (notification, &error)) { + if (error != NULL) { + g_warning ("Error showing notification: %s", error->message); + g_error_free (error); + } + exit (1); + } + } + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + gtk_main (); + } } #endif diff --git a/src/option.c b/src/option.c index 246cf226..61df34d3 100644 --- a/src/option.c +++ b/src/option.c @@ -25,41 +25,41 @@ #include "config.h" #include "option.h" -#include #include #include +#include /* General Options */ -static gchar *zenity_general_dialog_title; -static gchar *zenity_general_window_icon; -static int zenity_general_width; -static int zenity_general_height; -static gchar *zenity_general_dialog_text; -static gchar *zenity_general_dialog_icon; -static gchar *zenity_general_separator; +static gchar *zenity_general_dialog_title; +static gchar *zenity_general_window_icon; +static int zenity_general_width; +static int zenity_general_height; +static gchar *zenity_general_dialog_text; +static gchar *zenity_general_dialog_icon; +static gchar *zenity_general_separator; static gboolean zenity_general_multiple; static gboolean zenity_general_editable; -static gchar *zenity_general_uri; +static gchar *zenity_general_uri; static gboolean zenity_general_dialog_no_wrap; static gboolean zenity_general_dialog_no_markup; -static gint zenity_general_timeout_delay; -static gchar *zenity_general_ok_button; -static gchar *zenity_general_cancel_button; -static gchar **zenity_general_extra_buttons; +static gint zenity_general_timeout_delay; +static gchar *zenity_general_ok_button; +static gchar *zenity_general_cancel_button; +static gchar **zenity_general_extra_buttons; static gboolean zenity_general_modal; static guintptr zenity_general_attach; static gboolean zenity_general_dialog_ellipsize; /* Calendar Dialog Options */ static gboolean zenity_calendar_active; -static int zenity_calendar_day; -static int zenity_calendar_month; -static int zenity_calendar_year; -static gchar *zenity_calendar_date_format; +static int zenity_calendar_day; +static int zenity_calendar_month; +static int zenity_calendar_year; +static gchar *zenity_calendar_date_format; /* Entry Dialog Options */ static gboolean zenity_entry_active; -static gchar *zenity_entry_entry_text; +static gchar *zenity_entry_entry_text; static gboolean zenity_entry_hide_text; /* Error Dialog Options */ @@ -69,19 +69,19 @@ static gboolean zenity_error_active; static gboolean zenity_info_active; /* File Selection Dialog Options */ -static gboolean zenity_file_active; -static gboolean zenity_file_directory; -static gboolean zenity_file_save; -static gboolean zenity_file_confirm_overwrite; -static gchar **zenity_file_filter; +static gboolean zenity_file_active; +static gboolean zenity_file_directory; +static gboolean zenity_file_save; +static gboolean zenity_file_confirm_overwrite; +static gchar **zenity_file_filter; /* List Dialog Options */ static gboolean zenity_list_active; -static gchar **zenity_list_columns; +static gchar **zenity_list_columns; static gboolean zenity_list_checklist; static gboolean zenity_list_radiolist; -static gchar *zenity_list_print_column; -static gchar *zenity_list_hide_column; +static gchar *zenity_list_print_column; +static gchar *zenity_list_hide_column; static gboolean zenity_list_hide_header; static gboolean zenity_list_imagelist; static gboolean zenity_list_mid_search; @@ -90,12 +90,12 @@ static gboolean zenity_list_mid_search; /* Notification Dialog Options */ static gboolean zenity_notification_active; static gboolean zenity_notification_listen; -static gchar **zenity_notification_hints; +static gchar **zenity_notification_hints; #endif /* Progress Dialog Options */ static gboolean zenity_progress_active; -static int zenity_progress_percentage; +static int zenity_progress_percentage; static gboolean zenity_progress_pulsate; static gboolean zenity_progress_auto_close; static gboolean zenity_progress_auto_kill; @@ -109,14 +109,14 @@ static gboolean zenity_question_switch; /* Text Dialog Options */ static gboolean zenity_text_active; -static gchar *zenity_text_font; -static gchar *zenity_text_checkbox; +static gchar *zenity_text_font; +static gchar *zenity_text_checkbox; static gboolean zenity_text_auto_scroll; #ifdef HAVE_WEBKITGTK static gboolean zenity_text_enable_html; static gboolean zenity_text_no_interaction; -static gchar *zenity_text_url; +static gchar *zenity_text_url; #endif /* Warning Dialog Options */ @@ -133,7 +133,7 @@ static gboolean zenity_scale_hide_value; /* Color Selection Dialog Options */ static gboolean zenity_colorsel_active; -static gchar *zenity_colorsel_color; +static gchar *zenity_colorsel_color; static gboolean zenity_colorsel_show_palette; /* Password Dialog Options */ @@ -143,1180 +143,893 @@ static gboolean zenity_password_show_username; /* Forms Dialog Options */ static gboolean zenity_forms_active; static gboolean zenity_forms_show_header; -static gchar *zenity_forms_date_format; -//static gchar *zenity_forms_hide_column; -static gchar **zenity_forms_list_values; -static gchar **zenity_forms_column_values; -static gchar **zenity_forms_combo_values; +static gchar *zenity_forms_date_format; +// static gchar *zenity_forms_hide_column; +static gchar **zenity_forms_list_values; +static gchar **zenity_forms_column_values; +static gchar **zenity_forms_combo_values; /* Miscelaneus Options */ static gboolean zenity_misc_about; static gboolean zenity_misc_version; -static gboolean -zenity_forms_callback (const gchar *option_name, - const gchar *value, - gpointer data, - GError **error); - -static GOptionEntry general_options[] = { - { - "title", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_general_dialog_title, - N_("Set the dialog title"), - N_("TITLE") - }, - { - "window-icon", - '\0', - 0, - G_OPTION_ARG_FILENAME, - &zenity_general_window_icon, - N_("Set the window icon"), - N_("ICONPATH") - }, - { - "width", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_general_width, - N_("Set the width"), - N_("WIDTH") - }, - { - "height", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_general_height, - N_("Set the height"), - N_("HEIGHT") - }, - { - "timeout", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_general_timeout_delay, - N_("Set dialog timeout in seconds"), - /* Timeout for closing the dialog */ - N_("TIMEOUT") - }, - { - "ok-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_ok_button, - N_("Set the label of the OK button"), - N_("TEXT") - }, - { - "cancel-label", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_cancel_button, - N_("Set the label of the Cancel button"), - N_("TEXT") - }, - { - "extra-button", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_general_extra_buttons, - N_("Add an extra button"), - N_("TEXT") - }, - { - "modal", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_modal, - N_("Set the modal hint"), - NULL - }, - { - "attach", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_INT, - &zenity_general_attach, - N_("Set the parent window to attach to"), - N_("WINDOW") - }, - { - NULL - } -}; - -static GOptionEntry calendar_options[] = { - { - "calendar", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_calendar_active, - N_("Display calendar dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "day", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_calendar_day, - N_("Set the calendar day"), - N_("DAY") - }, - { - "month", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_calendar_month, - N_("Set the calendar month"), - N_("MONTH") - }, - { - "year", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_calendar_year, - N_("Set the calendar year"), - N_("YEAR") - }, - { - "date-format", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_calendar_date_format, - N_("Set the format for the returned date"), - N_("PATTERN") - }, - { - NULL - } -}; - -static GOptionEntry entry_options[] = { - { - "entry", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_entry_active, - N_("Display text entry dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "entry-text", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_entry_entry_text, - N_("Set the entry text"), - N_("TEXT") - }, - { - "hide-text", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_entry_hide_text, - N_("Hide the entry text"), - NULL - }, - { - NULL - } -}; - - -static GOptionEntry error_options[] = { - { - "error", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_error_active, - N_("Display error dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "icon-name", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_icon, - N_("Set the dialog icon"), - N_("ICON-NAME") - }, - { - "no-wrap", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_wrap, - N_("Do not enable text wrapping"), - NULL - }, - { - "no-markup", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_markup, - N_("Do not enable Pango markup") - }, - { - "ellipsize", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_ellipsize, - N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") - }, - { - NULL - } -}; - -static GOptionEntry info_options[] = { - { - "info", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_info_active, - N_("Display info dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "icon-name", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_icon, - N_("Set the dialog icon"), - N_("ICON-NAME") - }, - { - "no-wrap", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_wrap, - N_("Do not enable text wrapping"), - NULL - }, - { - "no-markup", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_markup, - N_("Do not enable Pango markup") - }, - { - "ellipsize", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_ellipsize, - N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") - }, - { - NULL - } -}; - -static GOptionEntry file_selection_options[] = { - { - "file-selection", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_file_active, - N_("Display file selection dialog"), - NULL - }, - { - "filename", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_FILENAME, - &zenity_general_uri, - N_("Set the filename"), - N_("FILENAME") - }, - { - "multiple", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_multiple, - N_("Allow multiple files to be selected"), - NULL - }, - { - "directory", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_file_directory, - N_("Activate directory-only selection"), - NULL - }, - { - "save", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_file_save, - N_("Activate save mode"), - NULL - }, - { - "separator", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_separator, - N_("Set output separator character"), - N_("SEPARATOR") - }, - { - "confirm-overwrite", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_file_confirm_overwrite, - N_("Confirm file selection if filename already exists"), - NULL - }, - { - "file-filter", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_file_filter, - N_("Set a filename filter"), - /* Help for file-filter argument (name and patterns for file selection) */ - N_("NAME | PATTERN1 PATTERN2 ..."), - }, - { - NULL - } -}; - -static GOptionEntry list_options[] = { - { - "list", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_list_active, - N_("Display list dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "column", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_list_columns, - N_("Set the column header"), - N_("COLUMN") - }, - { - "checklist", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_list_checklist, - N_("Use check boxes for the first column"), - NULL - }, - { - "radiolist", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_list_radiolist, - N_("Use radio buttons for the first column"), - NULL - }, - { - "imagelist", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_list_imagelist, - N_("Use an image for the first column"), - NULL - }, - { - "separator", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_separator, - N_("Set output separator character"), - N_("SEPARATOR") - }, - { - "multiple", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_multiple, - N_("Allow multiple rows to be selected"), - NULL - }, - { - "editable", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_editable, - N_("Allow changes to text"), - NULL - }, - { - "print-column", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_list_print_column, - N_("Print a specific column (Default is 1. 'ALL' can be used to print all columns)"), - /* Column index number to print out on a list dialog */ - N_("NUMBER") - }, - { - "hide-column", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_list_hide_column, - N_("Hide a specific column"), - N_("NUMBER") - }, - { - "hide-header", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_list_hide_header, - N_("Hide the column headers"), - NULL - }, - { - "mid-search", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_list_mid_search, - N_("Change list default search function searching for text in the middle, not on the beginning"), - NULL - }, - { - NULL - } -}; +static gboolean zenity_forms_callback (const gchar *option_name, + const gchar *value, gpointer data, GError **error); + +static GOptionEntry general_options[] = {{"title", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_general_dialog_title, + N_ ("Set the dialog title"), + N_ ("TITLE")}, + {"window-icon", + '\0', + 0, + G_OPTION_ARG_FILENAME, + &zenity_general_window_icon, + N_ ("Set the window icon"), + N_ ("ICONPATH")}, + {"width", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_width, + N_ ("Set the width"), + N_ ("WIDTH")}, + {"height", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_height, + N_ ("Set the height"), + N_ ("HEIGHT")}, + {"timeout", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_general_timeout_delay, + N_ ("Set dialog timeout in seconds"), + /* Timeout for closing the dialog */ + N_ ("TIMEOUT")}, + {"ok-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_ok_button, + N_ ("Set the label of the OK button"), + N_ ("TEXT")}, + {"cancel-label", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_cancel_button, + N_ ("Set the label of the Cancel button"), + N_ ("TEXT")}, + {"extra-button", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_general_extra_buttons, + N_ ("Add an extra button"), + N_ ("TEXT")}, + {"modal", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_modal, + N_ ("Set the modal hint"), + NULL}, + {"attach", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_INT, + &zenity_general_attach, + N_ ("Set the parent window to attach to"), + N_ ("WINDOW")}, + {NULL}}; + +static GOptionEntry calendar_options[] = {{"calendar", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_calendar_active, + N_ ("Display calendar dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"day", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_day, + N_ ("Set the calendar day"), + N_ ("DAY")}, + {"month", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_month, + N_ ("Set the calendar month"), + N_ ("MONTH")}, + {"year", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_calendar_year, + N_ ("Set the calendar year"), + N_ ("YEAR")}, + {"date-format", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_calendar_date_format, + N_ ("Set the format for the returned date"), + N_ ("PATTERN")}, + {NULL}}; + +static GOptionEntry entry_options[] = {{"entry", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_entry_active, + N_ ("Display text entry dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"entry-text", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_entry_entry_text, + N_ ("Set the entry text"), + N_ ("TEXT")}, + {"hide-text", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_entry_hide_text, + N_ ("Hide the entry text"), + NULL}, + {NULL}}; + +static GOptionEntry error_options[] = {{"error", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_error_active, + N_ ("Display error dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_ ("Set the dialog icon"), + N_ ("ICON-NAME")}, + {"no-wrap", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_ ("Do not enable text wrapping"), + NULL}, + {"no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_ ("Do not enable Pango markup")}, + {"ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_ ("Enable ellipsizing in the dialog text. This fixes the high window " + "size with long texts")}, + {NULL}}; + +static GOptionEntry info_options[] = {{"info", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_info_active, + N_ ("Display info dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_ ("Set the dialog icon"), + N_ ("ICON-NAME")}, + {"no-wrap", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_ ("Do not enable text wrapping"), + NULL}, + {"no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_ ("Do not enable Pango markup")}, + {"ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_ ("Enable ellipsizing in the dialog text. This fixes the high window " + "size with long texts")}, + {NULL}}; + +static GOptionEntry file_selection_options[] = + {{"file-selection", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_file_active, + N_ ("Display file selection dialog"), + NULL}, + {"filename", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_FILENAME, + &zenity_general_uri, + N_ ("Set the filename"), + N_ ("FILENAME")}, + {"multiple", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_multiple, + N_ ("Allow multiple files to be selected"), + NULL}, + {"directory", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_directory, + N_ ("Activate directory-only selection"), + NULL}, + {"save", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_save, + N_ ("Activate save mode"), + NULL}, + {"separator", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_ ("Set output separator character"), + N_ ("SEPARATOR")}, + {"confirm-overwrite", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_file_confirm_overwrite, + N_ ("Confirm file selection if filename already exists"), + NULL}, + { + "file-filter", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_file_filter, + N_ ("Set a filename filter"), + /* Help for file-filter argument (name and patterns for file + selection) */ + N_ ("NAME | PATTERN1 PATTERN2 ..."), + }, + {NULL}}; + +static GOptionEntry list_options[] = {{"list", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_list_active, + N_ ("Display list dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"column", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_list_columns, + N_ ("Set the column header"), + N_ ("COLUMN")}, + {"checklist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_checklist, + N_ ("Use check boxes for the first column"), + NULL}, + {"radiolist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_radiolist, + N_ ("Use radio buttons for the first column"), + NULL}, + {"imagelist", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_list_imagelist, + N_ ("Use an image for the first column"), + NULL}, + {"separator", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_ ("Set output separator character"), + N_ ("SEPARATOR")}, + {"multiple", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_multiple, + N_ ("Allow multiple rows to be selected"), + NULL}, + {"editable", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_editable, + N_ ("Allow changes to text"), + NULL}, + {"print-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_list_print_column, + N_ ("Print a specific column (Default is 1. 'ALL' can be used to print " + "all columns)"), + /* Column index number to print out on a list dialog */ + N_ ("NUMBER")}, + {"hide-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_list_hide_column, + N_ ("Hide a specific column"), + N_ ("NUMBER")}, + {"hide-header", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_list_hide_header, + N_ ("Hide the column headers"), + NULL}, + {"mid-search", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_list_mid_search, + N_ ("Change list default search function searching for text in the " + "middle, not on the beginning"), + NULL}, + {NULL}}; #ifdef HAVE_LIBNOTIFY -static GOptionEntry notification_options[] = { - { - "notification", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_notification_active, - N_("Display notification"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the notification text"), - N_("TEXT") - }, - { - "listen", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_notification_listen, - N_("Listen for commands on stdin"), - NULL - }, - { - "hint", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING_ARRAY, - &zenity_notification_hints, - N_("Set the notification hints"), - N_("TEXT") - }, - { - NULL - } -}; +static GOptionEntry notification_options[] = {{"notification", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_notification_active, + N_ ("Display notification"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the notification text"), + N_ ("TEXT")}, + {"listen", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_notification_listen, + N_ ("Listen for commands on stdin"), + NULL}, + {"hint", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING_ARRAY, + &zenity_notification_hints, + N_ ("Set the notification hints"), + N_ ("TEXT")}, + {NULL}}; #endif static GOptionEntry progress_options[] = { - { - "progress", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_progress_active, - N_("Display progress indication dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "percentage", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_progress_percentage, - N_("Set initial percentage"), - N_("PERCENTAGE") - }, - { - "pulsate", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_progress_pulsate, - N_("Pulsate progress bar"), - NULL - }, - { - "auto-close", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_progress_auto_close, - /* xgettext: no-c-format */ - N_("Dismiss the dialog when 100% has been reached"), - NULL - }, - { - "auto-kill", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_progress_auto_kill, - N_("Kill parent process if Cancel button is pressed"), - NULL - }, - { - "no-cancel", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_progress_no_cancel, - N_("Hide Cancel button"), - NULL - }, - { - "time-remaining", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_progress_time_remaining, - /* xgettext: no-c-format */ - N_("Estimate when progress will reach 100%"), - NULL - }, - { - NULL - } -}; - -static GOptionEntry question_options[] = { - { - "question", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_question_active, - N_("Display question dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "icon-name", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_icon, - N_("Set the dialog icon"), - N_("ICON-NAME") - }, - { - "no-wrap", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_wrap, - N_("Do not enable text wrapping"), - NULL - }, - { - "no-markup", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_markup, - N_("Do not enable Pango markup") - }, - { - "default-cancel", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_question_default_cancel, - N_("Give Cancel button focus by default"), - NULL - }, - { - "ellipsize", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_ellipsize, - N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") - }, - { - "switch", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_question_switch, - N_("Suppress OK and Cancel buttons"), - NULL - }, - { - NULL - } -}; + {"progress", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_progress_active, + N_ ("Display progress indication dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"percentage", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_progress_percentage, + N_ ("Set initial percentage"), + N_ ("PERCENTAGE")}, + {"pulsate", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_pulsate, + N_ ("Pulsate progress bar"), + NULL}, + {"auto-close", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_auto_close, + /* xgettext: no-c-format */ + N_ ("Dismiss the dialog when 100% has been reached"), + NULL}, + {"auto-kill", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_auto_kill, + N_ ("Kill parent process if Cancel button is pressed"), + NULL}, + {"no-cancel", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_no_cancel, + N_ ("Hide Cancel button"), + NULL}, + {"time-remaining", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_progress_time_remaining, + /* xgettext: no-c-format */ + N_ ("Estimate when progress will reach 100%"), + NULL}, + {NULL}}; + +static GOptionEntry question_options[] = {{"question", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_question_active, + N_ ("Display question dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_ ("Set the dialog icon"), + N_ ("ICON-NAME")}, + {"no-wrap", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_ ("Do not enable text wrapping"), + NULL}, + {"no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_ ("Do not enable Pango markup")}, + {"default-cancel", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_question_default_cancel, + N_ ("Give Cancel button focus by default"), + NULL}, + {"ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_ ("Enable ellipsizing in the dialog text. This fixes the high window " + "size with long texts")}, + {"switch", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_question_switch, + N_ ("Suppress OK and Cancel buttons"), + NULL}, + {NULL}}; static GOptionEntry text_options[] = { - { - "text-info", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_text_active, - N_("Display text information dialog"), - NULL - }, - { - "filename", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_FILENAME, - &zenity_general_uri, - N_("Open file"), - N_("FILENAME") - }, - { - "editable", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_editable, - N_("Allow changes to text"), - NULL - }, - { - "font", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_text_font, - N_("Set the text font"), - N_("TEXT") - }, - { - "checkbox", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_text_checkbox, - N_("Enable an I read and agree checkbox"), - N_("TEXT") - }, + {"text-info", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_text_active, + N_ ("Display text information dialog"), + NULL}, + {"filename", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_FILENAME, + &zenity_general_uri, + N_ ("Open file"), + N_ ("FILENAME")}, + {"editable", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_editable, + N_ ("Allow changes to text"), + NULL}, + {"font", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_text_font, + N_ ("Set the text font"), + N_ ("TEXT")}, + {"checkbox", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_text_checkbox, + N_ ("Enable an I read and agree checkbox"), + N_ ("TEXT")}, #ifdef HAVE_WEBKITGTK - { - "html", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_text_enable_html, - N_("Enable HTML support"), - NULL - }, - { - "no-interaction", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_text_no_interaction, - N_("Do not enable user interaction with the WebView. Only works if you use --html option"), - NULL - }, - { - "url", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_text_url, - N_("Set an URL instead of a file. Only works if you use --html option"), - N_("URL") - }, + {"html", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_enable_html, + N_ ("Enable HTML support"), + NULL}, + {"no-interaction", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_no_interaction, + N_ ("Do not enable user interaction with the WebView. Only works if " + "you use --html option"), + NULL}, + {"url", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_text_url, + N_ ("Set an URL instead of a file. Only works if you use --html " + "option"), + N_ ("URL")}, #endif - { - "auto-scroll", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_text_auto_scroll, - N_("Auto scroll the text to the end. Only when text is captured from stdin"), - NULL - }, - { - NULL - } -}; - -static GOptionEntry warning_options[] = { - { - "warning", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_warning_active, - N_("Display warning dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "icon-name", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_icon, - N_("Set the dialog icon"), - N_("ICON-NAME") - }, - { - "no-wrap", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_wrap, - N_("Do not enable text wrapping"), - NULL - }, - { - "no-markup", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_no_markup, - N_("Do not enable Pango markup") - }, - { - "ellipsize", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_NONE, - &zenity_general_dialog_ellipsize, - N_("Enable ellipsizing in the dialog text. This fixes the high window size with long texts") - }, - { - NULL - } -}; - -static GOptionEntry scale_options[] = { - { - "scale", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_scale_active, - N_("Display scale dialog"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "value", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_scale_value, - N_("Set initial value"), - N_("VALUE") - }, - { - "min-value", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_scale_min_value, - N_("Set minimum value"), - N_("VALUE") - }, - { - "max-value", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_scale_max_value, - N_("Set maximum value"), - N_("VALUE") - }, - { - "step", - '\0', - 0, - G_OPTION_ARG_INT, - &zenity_scale_step, - N_("Set step size"), - N_("VALUE") - }, - { - "print-partial", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_scale_print_partial, - N_("Print partial values"), - NULL - }, - { - "hide-value", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_scale_hide_value, - N_("Hide value"), - NULL - }, - { - NULL - } -}; - -static GOptionEntry forms_dialog_options[] = { - { - "forms", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_forms_active, - N_("Display forms dialog"), - NULL - }, - { - "add-entry", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new Entry in forms dialog"), - N_("Field name") - }, - { - "add-password", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new Password Entry in forms dialog"), - N_("Field name") - }, - { - "add-calendar", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new Calendar in forms dialog"), - N_("Calendar field name") - }, - { - "add-list", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new List in forms dialog"), - N_("List field and header name") - }, - { - "list-values", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_forms_list_values, - N_("List of values for List"), - N_("List of values separated by |") - }, - { - "column-values", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_forms_column_values, - N_("List of values for columns"), - N_("List of values separated by |") - }, - { - "add-combo", - '\0', - 0, - G_OPTION_ARG_CALLBACK, - zenity_forms_callback, - N_("Add a new combo box in forms dialog"), - N_("Combo box field name") - }, - { - "combo-values", - '\0', - 0, - G_OPTION_ARG_STRING_ARRAY, - &zenity_forms_combo_values, - N_("List of values for combo box"), - N_("List of values separated by |") - }, - /* TODO: Implement how to hide specifc column - { - "hide-column", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_forms_hide_column, - N_("Hide a specific column"), - N_("NUMBER") - },*/ - { - "show-header", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_forms_show_header, - N_("Show the columns header"), - NULL - }, - { - "text", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_dialog_text, - N_("Set the dialog text"), - N_("TEXT") - }, - { - "separator", - '\0', - G_OPTION_FLAG_NOALIAS, - G_OPTION_ARG_STRING, - &zenity_general_separator, - N_("Set output separator character"), - N_("SEPARATOR") - }, - { - "date-format", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_forms_date_format, - N_("Set the format for the returned date"), - N_("PATTERN") - }, - { - NULL - } -}; + {"auto-scroll", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_text_auto_scroll, + N_ ("Auto scroll the text to the end. Only when text is captured from " + "stdin"), + NULL}, + {NULL}}; + +static GOptionEntry warning_options[] = {{"warning", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_warning_active, + N_ ("Display warning dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"icon-name", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_icon, + N_ ("Set the dialog icon"), + N_ ("ICON-NAME")}, + {"no-wrap", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_wrap, + N_ ("Do not enable text wrapping"), + NULL}, + {"no-markup", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_no_markup, + N_ ("Do not enable Pango markup")}, + {"ellipsize", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_NONE, + &zenity_general_dialog_ellipsize, + N_ ("Enable ellipsizing in the dialog text. This fixes the high window " + "size with long texts")}, + {NULL}}; + +static GOptionEntry scale_options[] = {{"scale", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_scale_active, + N_ ("Display scale dialog"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_value, + N_ ("Set initial value"), + N_ ("VALUE")}, + {"min-value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_min_value, + N_ ("Set minimum value"), + N_ ("VALUE")}, + {"max-value", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_max_value, + N_ ("Set maximum value"), + N_ ("VALUE")}, + {"step", + '\0', + 0, + G_OPTION_ARG_INT, + &zenity_scale_step, + N_ ("Set step size"), + N_ ("VALUE")}, + {"print-partial", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_scale_print_partial, + N_ ("Print partial values"), + NULL}, + {"hide-value", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_scale_hide_value, + N_ ("Hide value"), + NULL}, + {NULL}}; + +static GOptionEntry forms_dialog_options[] = {{"forms", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_forms_active, + N_ ("Display forms dialog"), + NULL}, + {"add-entry", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_ ("Add a new Entry in forms dialog"), + N_ ("Field name")}, + {"add-password", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_ ("Add a new Password Entry in forms dialog"), + N_ ("Field name")}, + {"add-calendar", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_ ("Add a new Calendar in forms dialog"), + N_ ("Calendar field name")}, + {"add-list", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_ ("Add a new List in forms dialog"), + N_ ("List field and header name")}, + {"list-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_list_values, + N_ ("List of values for List"), + N_ ("List of values separated by |")}, + {"column-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_column_values, + N_ ("List of values for columns"), + N_ ("List of values separated by |")}, + {"add-combo", + '\0', + 0, + G_OPTION_ARG_CALLBACK, + zenity_forms_callback, + N_ ("Add a new combo box in forms dialog"), + N_ ("Combo box field name")}, + {"combo-values", + '\0', + 0, + G_OPTION_ARG_STRING_ARRAY, + &zenity_forms_combo_values, + N_ ("List of values for combo box"), + N_ ("List of values separated by |")}, + /* TODO: Implement how to hide specifc column + { + "hide-column", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_forms_hide_column, + N_("Hide a specific column"), + N_("NUMBER") + },*/ + {"show-header", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_forms_show_header, + N_ ("Show the columns header"), + NULL}, + {"text", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_dialog_text, + N_ ("Set the dialog text"), + N_ ("TEXT")}, + {"separator", + '\0', + G_OPTION_FLAG_NOALIAS, + G_OPTION_ARG_STRING, + &zenity_general_separator, + N_ ("Set output separator character"), + N_ ("SEPARATOR")}, + {"date-format", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_forms_date_format, + N_ ("Set the format for the returned date"), + N_ ("PATTERN")}, + {NULL}}; static GOptionEntry password_dialog_options[] = { - { - "password", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_password_active, - N_("Display password dialog"), - NULL - }, - { - "username", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_password_show_username, - N_("Display the username option"), - NULL - }, - { - NULL - } -}; + {"password", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_password_active, + N_ ("Display password dialog"), + NULL}, + {"username", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_password_show_username, + N_ ("Display the username option"), + NULL}, + {NULL}}; static GOptionEntry color_selection_options[] = { - { - "color-selection", - '\0', - G_OPTION_FLAG_IN_MAIN, - G_OPTION_ARG_NONE, - &zenity_colorsel_active, - N_("Display color selection dialog"), - NULL - }, - { - "color", - '\0', - 0, - G_OPTION_ARG_STRING, - &zenity_colorsel_color, - N_("Set the color"), - N_("VALUE") - }, - { - "show-palette", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_colorsel_show_palette, - N_("Show the palette"), - NULL - }, - { - NULL - } -}; - -static GOptionEntry miscellaneous_options[] = { - { - "about", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_misc_about, - N_("About zenity"), - NULL - }, - { - "version", - '\0', - 0, - G_OPTION_ARG_NONE, - &zenity_misc_version, - N_("Print version"), - NULL - }, - { - NULL - } -}; + {"color-selection", + '\0', + G_OPTION_FLAG_IN_MAIN, + G_OPTION_ARG_NONE, + &zenity_colorsel_active, + N_ ("Display color selection dialog"), + NULL}, + {"color", + '\0', + 0, + G_OPTION_ARG_STRING, + &zenity_colorsel_color, + N_ ("Set the color"), + N_ ("VALUE")}, + {"show-palette", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_colorsel_show_palette, + N_ ("Show the palette"), + NULL}, + {NULL}}; + +static GOptionEntry miscellaneous_options[] = {{"about", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_misc_about, + N_ ("About zenity"), + NULL}, + {"version", + '\0', + 0, + G_OPTION_ARG_NONE, + &zenity_misc_version, + N_ ("Print version"), + NULL}, + {NULL}}; static ZenityParsingOptions *results; static GOptionContext *ctx; @@ -1324,1210 +1037,1193 @@ static GOptionContext *ctx; static void zenity_option_init (void) { - results = g_new0 (ZenityParsingOptions, 1); - - /* Initialize the various dialog structures */ - results->mode = MODE_LAST; - results->data = g_new0 (ZenityData, 1); - results->calendar_data = g_new0 (ZenityCalendarData, 1); - results->msg_data = g_new0 (ZenityMsgData, 1); - results->scale_data = g_new0 (ZenityScaleData, 1); - results->file_data = g_new0 (ZenityFileData, 1); - results->entry_data = g_new0 (ZenityEntryData, 1); - results->progress_data = g_new0 (ZenityProgressData, 1); - results->text_data = g_new0 (ZenityTextData, 1); - results->tree_data = g_new0 (ZenityTreeData, 1); + results = g_new0 (ZenityParsingOptions, 1); + + /* Initialize the various dialog structures */ + results->mode = MODE_LAST; + results->data = g_new0 (ZenityData, 1); + results->calendar_data = g_new0 (ZenityCalendarData, 1); + results->msg_data = g_new0 (ZenityMsgData, 1); + results->scale_data = g_new0 (ZenityScaleData, 1); + results->file_data = g_new0 (ZenityFileData, 1); + results->entry_data = g_new0 (ZenityEntryData, 1); + results->progress_data = g_new0 (ZenityProgressData, 1); + results->text_data = g_new0 (ZenityTextData, 1); + results->tree_data = g_new0 (ZenityTreeData, 1); #ifdef HAVE_LIBNOTIFY - results->notification_data = g_new0 (ZenityNotificationData, 1); + results->notification_data = g_new0 (ZenityNotificationData, 1); #endif - results->color_data = g_new0 (ZenityColorData, 1); - results->password_data = g_new0 (ZenityPasswordData, 1); - results->forms_data = g_new0 (ZenityFormsData, 1); + results->color_data = g_new0 (ZenityColorData, 1); + results->password_data = g_new0 (ZenityPasswordData, 1); + results->forms_data = g_new0 (ZenityFormsData, 1); } void zenity_option_free (void) { - if (zenity_general_dialog_title) - g_free (zenity_general_dialog_title); - if (zenity_general_window_icon) - g_free (zenity_general_window_icon); - if (zenity_general_dialog_text) - g_free (zenity_general_dialog_text); - if (zenity_general_uri) - g_free (zenity_general_uri); - g_free (zenity_general_separator); - if (zenity_general_ok_button) - g_free (zenity_general_ok_button); - if (zenity_general_cancel_button) - g_free (zenity_general_cancel_button); - if (zenity_general_extra_buttons) - g_strfreev (zenity_general_extra_buttons); - - if (zenity_calendar_date_format) - g_free (zenity_calendar_date_format); - - if (zenity_forms_date_format) - g_free (zenity_forms_date_format); - if (zenity_forms_list_values) - g_strfreev (zenity_forms_list_values); - if (zenity_forms_combo_values) - g_strfreev (zenity_forms_combo_values); - if (zenity_forms_column_values) - g_strfreev (zenity_forms_column_values); -// if (zenity_forms_hide_column) -// g_free (zenity_forms_hide_column); - if (zenity_entry_entry_text) - g_free (zenity_entry_entry_text); - - if (zenity_file_filter) - g_strfreev (zenity_file_filter); - - if (zenity_list_columns) - g_strfreev (zenity_list_columns); - if (zenity_list_print_column) - g_free (zenity_list_print_column); - if (zenity_list_hide_column) - g_free (zenity_list_hide_column); + if (zenity_general_dialog_title) + g_free (zenity_general_dialog_title); + if (zenity_general_window_icon) + g_free (zenity_general_window_icon); + if (zenity_general_dialog_text) + g_free (zenity_general_dialog_text); + if (zenity_general_uri) + g_free (zenity_general_uri); + g_free (zenity_general_separator); + if (zenity_general_ok_button) + g_free (zenity_general_ok_button); + if (zenity_general_cancel_button) + g_free (zenity_general_cancel_button); + if (zenity_general_extra_buttons) + g_strfreev (zenity_general_extra_buttons); + + if (zenity_calendar_date_format) + g_free (zenity_calendar_date_format); + + if (zenity_forms_date_format) + g_free (zenity_forms_date_format); + if (zenity_forms_list_values) + g_strfreev (zenity_forms_list_values); + if (zenity_forms_combo_values) + g_strfreev (zenity_forms_combo_values); + if (zenity_forms_column_values) + g_strfreev (zenity_forms_column_values); + // if (zenity_forms_hide_column) + // g_free (zenity_forms_hide_column); + if (zenity_entry_entry_text) + g_free (zenity_entry_entry_text); + + if (zenity_file_filter) + g_strfreev (zenity_file_filter); + + if (zenity_list_columns) + g_strfreev (zenity_list_columns); + if (zenity_list_print_column) + g_free (zenity_list_print_column); + if (zenity_list_hide_column) + g_free (zenity_list_hide_column); #ifdef HAVE_LIBNOTIFY - if (zenity_notification_hints) - g_strfreev (zenity_notification_hints); + if (zenity_notification_hints) + g_strfreev (zenity_notification_hints); #endif - if (zenity_text_font) - g_free (zenity_text_font); - if (zenity_text_checkbox) - g_free (zenity_text_checkbox); + if (zenity_text_font) + g_free (zenity_text_font); + if (zenity_text_checkbox) + g_free (zenity_text_checkbox); - if (zenity_colorsel_color) - g_free (zenity_colorsel_color); - - g_option_context_free (ctx); + if (zenity_colorsel_color) + g_free (zenity_colorsel_color); + + g_option_context_free (ctx); } static void -zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) -{ - if (is_active == TRUE) { - if (results->mode == MODE_LAST) - results->mode = mode; - else - zenity_option_error (NULL, ERROR_DIALOG); - } +zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) { + if (is_active == TRUE) { + if (results->mode == MODE_LAST) + results->mode = mode; + else + zenity_option_error (NULL, ERROR_DIALOG); + } } static gchar * -zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) -{ - int i; - - for (i = 1; entries[i].long_name != NULL; i++) { - if (entries[i].arg_data == arg_data) - return (gchar *) entries[i].long_name; - } - return NULL; +zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) { + int i; + + for (i = 1; entries[i].long_name != NULL; i++) { + if (entries[i].arg_data == arg_data) + return (gchar *) entries[i].long_name; + } + return NULL; } /* Forms callback */ static gboolean -zenity_forms_callback (const gchar *option_name, - const gchar *value, - gpointer data, - GError **error) -{ - ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); - - forms_value->option_value = g_strdup (value); - - if (g_strcmp0 (option_name, "--add-entry") == 0) - forms_value->type = ZENITY_FORMS_ENTRY; - else if (g_strcmp0 (option_name, "--add-calendar") == 0) - forms_value->type = ZENITY_FORMS_CALENDAR; - else if (g_strcmp0 (option_name, "--add-password") == 0) - forms_value->type = ZENITY_FORMS_PASSWORD; - else if (g_strcmp0 (option_name, "--add-list") == 0) - forms_value->type = ZENITY_FORMS_LIST; - else if (g_strcmp0 (option_name, "--add-combo") == 0) - forms_value->type = ZENITY_FORMS_COMBO; - - results->forms_data->list = g_slist_append(results->forms_data->list, forms_value); - - return TRUE; +zenity_forms_callback (const gchar *option_name, const gchar *value, + gpointer data, GError **error) { + ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1); + + forms_value->option_value = g_strdup (value); + + if (g_strcmp0 (option_name, "--add-entry") == 0) + forms_value->type = ZENITY_FORMS_ENTRY; + else if (g_strcmp0 (option_name, "--add-calendar") == 0) + forms_value->type = ZENITY_FORMS_CALENDAR; + else if (g_strcmp0 (option_name, "--add-password") == 0) + forms_value->type = ZENITY_FORMS_PASSWORD; + else if (g_strcmp0 (option_name, "--add-list") == 0) + forms_value->type = ZENITY_FORMS_LIST; + else if (g_strcmp0 (option_name, "--add-combo") == 0) + forms_value->type = ZENITY_FORMS_COMBO; + + results->forms_data->list = + g_slist_append (results->forms_data->list, forms_value); + + return TRUE; } /* Error callback */ -static void -zenity_option_error_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_error (NULL, ERROR_SYNTAX); +static void +zenity_option_error_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_error (NULL, ERROR_SYNTAX); } /* Pre parse callbacks set the default option values */ static gboolean -zenity_general_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_general_dialog_title = NULL; - zenity_general_window_icon = NULL; - zenity_general_width = -1; - zenity_general_height = -1; - zenity_general_dialog_text = NULL; - zenity_general_separator = g_strdup ("|"); - zenity_general_multiple = FALSE; - zenity_general_editable = FALSE; - zenity_general_uri = NULL; - zenity_general_ok_button = NULL; - zenity_general_cancel_button = NULL; - zenity_general_extra_buttons = NULL; - zenity_general_dialog_no_wrap = FALSE; - zenity_general_dialog_no_markup = FALSE; - zenity_general_timeout_delay = -1; - zenity_general_modal = FALSE; - zenity_general_attach = 0; - - return TRUE; +zenity_general_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_general_dialog_title = NULL; + zenity_general_window_icon = NULL; + zenity_general_width = -1; + zenity_general_height = -1; + zenity_general_dialog_text = NULL; + zenity_general_separator = g_strdup ("|"); + zenity_general_multiple = FALSE; + zenity_general_editable = FALSE; + zenity_general_uri = NULL; + zenity_general_ok_button = NULL; + zenity_general_cancel_button = NULL; + zenity_general_extra_buttons = NULL; + zenity_general_dialog_no_wrap = FALSE; + zenity_general_dialog_no_markup = FALSE; + zenity_general_timeout_delay = -1; + zenity_general_modal = FALSE; + zenity_general_attach = 0; + + return TRUE; } static gboolean -zenity_calendar_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_calendar_active = FALSE; - zenity_calendar_date_format = NULL; - zenity_calendar_day = -1; - zenity_calendar_month = -1; - zenity_calendar_year = -1; - - return TRUE; +zenity_calendar_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_calendar_active = FALSE; + zenity_calendar_date_format = NULL; + zenity_calendar_day = -1; + zenity_calendar_month = -1; + zenity_calendar_year = -1; + + return TRUE; } static gboolean -zenity_entry_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_entry_active = FALSE; - zenity_entry_entry_text = NULL; - zenity_entry_hide_text = FALSE; - - return TRUE; +zenity_entry_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_entry_active = FALSE; + zenity_entry_entry_text = NULL; + zenity_entry_hide_text = FALSE; + + return TRUE; } static gboolean -zenity_error_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_error_active = FALSE; - - return TRUE; +zenity_error_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_error_active = FALSE; + + return TRUE; } static gboolean -zenity_info_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_info_active = FALSE; - - return TRUE; +zenity_info_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_info_active = FALSE; + + return TRUE; } static gboolean -zenity_file_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_file_active = FALSE; - zenity_file_directory = FALSE; - zenity_file_save = FALSE; - zenity_file_confirm_overwrite = FALSE; - zenity_file_filter = NULL; - - return TRUE; +zenity_file_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_file_active = FALSE; + zenity_file_directory = FALSE; + zenity_file_save = FALSE; + zenity_file_confirm_overwrite = FALSE; + zenity_file_filter = NULL; + + return TRUE; } static gboolean -zenity_list_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_list_active = FALSE; - zenity_list_columns = NULL; - zenity_list_checklist = FALSE; - zenity_list_radiolist = FALSE; - zenity_list_imagelist = FALSE; - zenity_list_hide_header = FALSE; - zenity_list_print_column = NULL; - zenity_list_hide_column = NULL; - zenity_list_mid_search = FALSE; - - return TRUE; +zenity_list_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_list_active = FALSE; + zenity_list_columns = NULL; + zenity_list_checklist = FALSE; + zenity_list_radiolist = FALSE; + zenity_list_imagelist = FALSE; + zenity_list_hide_header = FALSE; + zenity_list_print_column = NULL; + zenity_list_hide_column = NULL; + zenity_list_mid_search = FALSE; + + return TRUE; } #ifdef HAVE_LIBNOTIFY static gboolean -zenity_notification_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_notification_active = FALSE; - zenity_notification_listen = FALSE; - - return TRUE; +zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_notification_active = FALSE; + zenity_notification_listen = FALSE; + + return TRUE; } #endif static gboolean -zenity_progress_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_progress_active = FALSE; - zenity_progress_percentage = 0; - zenity_progress_pulsate = FALSE; - zenity_progress_auto_close = FALSE; - zenity_progress_auto_kill = FALSE; - zenity_progress_no_cancel = FALSE; - zenity_progress_time_remaining = FALSE; - return TRUE; +zenity_progress_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_progress_active = FALSE; + zenity_progress_percentage = 0; + zenity_progress_pulsate = FALSE; + zenity_progress_auto_close = FALSE; + zenity_progress_auto_kill = FALSE; + zenity_progress_no_cancel = FALSE; + zenity_progress_time_remaining = FALSE; + return TRUE; } static gboolean -zenity_question_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_question_active = FALSE; - zenity_question_default_cancel = FALSE; - zenity_question_switch = FALSE; - return TRUE; +zenity_question_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_question_active = FALSE; + zenity_question_default_cancel = FALSE; + zenity_question_switch = FALSE; + return TRUE; } static gboolean -zenity_text_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_text_active = FALSE; - zenity_text_font = NULL; - zenity_text_checkbox = NULL; - zenity_text_auto_scroll = FALSE; +zenity_text_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_text_active = FALSE; + zenity_text_font = NULL; + zenity_text_checkbox = NULL; + zenity_text_auto_scroll = FALSE; #ifdef HAVE_WEBKITGTK - zenity_text_enable_html = FALSE; - zenity_text_no_interaction = FALSE; - zenity_text_url = NULL; + zenity_text_enable_html = FALSE; + zenity_text_no_interaction = FALSE; + zenity_text_url = NULL; #endif - return TRUE; + return TRUE; } static gboolean -zenity_warning_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_warning_active = FALSE; - - return TRUE; +zenity_warning_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_warning_active = FALSE; + + return TRUE; } static gboolean -zenity_scale_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_scale_active = FALSE; - zenity_scale_value = 0; - zenity_scale_min_value = 0; - zenity_scale_max_value = 100; - zenity_scale_step = 1; - zenity_scale_print_partial = FALSE; - zenity_scale_hide_value = FALSE; - - return TRUE; +zenity_scale_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_scale_active = FALSE; + zenity_scale_value = 0; + zenity_scale_min_value = 0; + zenity_scale_max_value = 100; + zenity_scale_step = 1; + zenity_scale_print_partial = FALSE; + zenity_scale_hide_value = FALSE; + + return TRUE; } static gboolean -zenity_color_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_colorsel_active = FALSE; - zenity_colorsel_color = NULL; - zenity_colorsel_show_palette = FALSE; - - return TRUE; +zenity_color_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_colorsel_active = FALSE; + zenity_colorsel_color = NULL; + zenity_colorsel_show_palette = FALSE; + + return TRUE; } static gboolean -zenity_password_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_password_active = FALSE; - zenity_password_show_username = FALSE; - - return TRUE; +zenity_password_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_password_active = FALSE; + zenity_password_show_username = FALSE; + + return TRUE; } static gboolean -zenity_forms_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_forms_active = FALSE; - zenity_forms_show_header = FALSE; - zenity_forms_date_format = NULL; -// zenity_forms_hide_column = NULL; - return TRUE; +zenity_forms_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_forms_active = FALSE; + zenity_forms_show_header = FALSE; + zenity_forms_date_format = NULL; + // zenity_forms_hide_column = NULL; + return TRUE; } static gboolean -zenity_misc_pre_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_misc_about = FALSE; - zenity_misc_version = FALSE; - - return TRUE; +zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_misc_about = FALSE; + zenity_misc_version = FALSE; + + return TRUE; } /* Post parse callbacks assign the option values to parsing result and makes some post condition tests */ static gboolean -zenity_general_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - results->data->dialog_title = zenity_general_dialog_title; - results->data->window_icon = zenity_general_window_icon; - results->data->width = zenity_general_width; - results->data->height = zenity_general_height; - results->data->timeout_delay = zenity_general_timeout_delay; - results->data->ok_label = zenity_general_ok_button; - results->data->cancel_label = zenity_general_cancel_button; - results->data->extra_label = zenity_general_extra_buttons; - results->data->modal = zenity_general_modal; - results->data->attach = zenity_general_attach; - - return TRUE; +zenity_general_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + results->data->dialog_title = zenity_general_dialog_title; + results->data->window_icon = zenity_general_window_icon; + results->data->width = zenity_general_width; + results->data->height = zenity_general_height; + results->data->timeout_delay = zenity_general_timeout_delay; + results->data->ok_label = zenity_general_ok_button; + results->data->cancel_label = zenity_general_cancel_button; + results->data->extra_label = zenity_general_extra_buttons; + results->data->modal = zenity_general_modal; + results->data->attach = zenity_general_attach; + + return TRUE; } static gboolean -zenity_calendar_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR); - - if (results->mode == MODE_CALENDAR) { - struct tm *t; - time_t current_time; - - time (¤t_time); - t = localtime (¤t_time); - - if (zenity_calendar_day < 0) - zenity_calendar_day = t->tm_mday; - if (zenity_calendar_month < 0) - zenity_calendar_month = t->tm_mon + 1; - if (zenity_calendar_year < 0) - zenity_calendar_year = t->tm_year + 1900; - - results->calendar_data->dialog_text = zenity_general_dialog_text; - results->calendar_data->day = zenity_calendar_day; - results->calendar_data->month = zenity_calendar_month; - results->calendar_data->year = zenity_calendar_year; - - if (zenity_calendar_date_format) - results->calendar_data->date_format = zenity_calendar_date_format; - else - results->calendar_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); - - } else { - if (zenity_calendar_day > -1) - zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_day), - ERROR_SUPPORT); - - if (zenity_calendar_month > -1) - zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_month), - ERROR_SUPPORT); - - if (zenity_calendar_year > -1) - zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_year), - ERROR_SUPPORT); - - if (zenity_calendar_date_format) - zenity_option_error (zenity_option_get_name (calendar_options, &zenity_calendar_date_format), - ERROR_SUPPORT); - } - - return TRUE; +zenity_calendar_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR); + + if (results->mode == MODE_CALENDAR) { + struct tm *t; + time_t current_time; + + time (¤t_time); + t = localtime (¤t_time); + + if (zenity_calendar_day < 0) + zenity_calendar_day = t->tm_mday; + if (zenity_calendar_month < 0) + zenity_calendar_month = t->tm_mon + 1; + if (zenity_calendar_year < 0) + zenity_calendar_year = t->tm_year + 1900; + + results->calendar_data->dialog_text = zenity_general_dialog_text; + results->calendar_data->day = zenity_calendar_day; + results->calendar_data->month = zenity_calendar_month; + results->calendar_data->year = zenity_calendar_year; + + if (zenity_calendar_date_format) + results->calendar_data->date_format = zenity_calendar_date_format; + else + results->calendar_data->date_format = + g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); + + } else { + if (zenity_calendar_day > -1) + zenity_option_error ( + zenity_option_get_name (calendar_options, &zenity_calendar_day), + ERROR_SUPPORT); + + if (zenity_calendar_month > -1) + zenity_option_error (zenity_option_get_name ( + calendar_options, &zenity_calendar_month), + ERROR_SUPPORT); + + if (zenity_calendar_year > -1) + zenity_option_error (zenity_option_get_name ( + calendar_options, &zenity_calendar_year), + ERROR_SUPPORT); + + if (zenity_calendar_date_format) + zenity_option_error (zenity_option_get_name (calendar_options, + &zenity_calendar_date_format), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_entry_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY); - - if (results->mode == MODE_ENTRY) { - results->entry_data->dialog_text = zenity_general_dialog_text; - results->entry_data->entry_text = zenity_entry_entry_text; - results->entry_data->hide_text= zenity_entry_hide_text; - } else { - if (zenity_entry_entry_text) - zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_entry_text), - ERROR_SUPPORT); - - if (zenity_entry_hide_text) - zenity_option_error (zenity_option_get_name (entry_options, &zenity_entry_hide_text), - ERROR_SUPPORT); - } - - return TRUE; +zenity_entry_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY); + + if (results->mode == MODE_ENTRY) { + results->entry_data->dialog_text = zenity_general_dialog_text; + results->entry_data->entry_text = zenity_entry_entry_text; + results->entry_data->hide_text = zenity_entry_hide_text; + } else { + if (zenity_entry_entry_text) + zenity_option_error (zenity_option_get_name ( + entry_options, &zenity_entry_entry_text), + ERROR_SUPPORT); + + if (zenity_entry_hide_text) + zenity_option_error ( + zenity_option_get_name (entry_options, &zenity_entry_hide_text), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_error_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_error_active, MODE_ERROR); - - if (results->mode == MODE_ERROR) { - results->msg_data->dialog_text = zenity_general_dialog_text; - results->msg_data->dialog_icon = zenity_general_dialog_icon; - results->msg_data->mode = ZENITY_MSG_ERROR; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; - results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ellipsize = zenity_general_dialog_ellipsize; - } - - return TRUE; +zenity_error_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_error_active, MODE_ERROR); + + if (results->mode == MODE_ERROR) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; + results->msg_data->mode = ZENITY_MSG_ERROR; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; + } + + return TRUE; } static gboolean -zenity_info_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_info_active, MODE_INFO); - - if (results->mode == MODE_INFO) { - results->msg_data->dialog_text = zenity_general_dialog_text; - results->msg_data->dialog_icon = zenity_general_dialog_icon; - results->msg_data->mode = ZENITY_MSG_INFO; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; - results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ellipsize = zenity_general_dialog_ellipsize; - } - - return TRUE; +zenity_info_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_info_active, MODE_INFO); + + if (results->mode == MODE_INFO) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; + results->msg_data->mode = ZENITY_MSG_INFO; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; + } + + return TRUE; } static gboolean -zenity_file_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_file_active, MODE_FILE); - - if (results->mode == MODE_FILE) { - results->file_data->uri = zenity_general_uri; - results->file_data->multi = zenity_general_multiple; - results->file_data->directory = zenity_file_directory; - results->file_data->save = zenity_file_save; - results->file_data->confirm_overwrite = zenity_file_confirm_overwrite; - results->file_data->separator = zenity_general_separator; - results->file_data->filter = zenity_file_filter; - } else { - if (zenity_file_directory) - zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_directory), - ERROR_SUPPORT); - - if (zenity_file_save) - zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_save), - ERROR_SUPPORT); - - if (zenity_file_filter) - zenity_option_error (zenity_option_get_name (file_selection_options, &zenity_file_filter), - ERROR_SUPPORT); - } - - return TRUE; +zenity_file_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_file_active, MODE_FILE); + + if (results->mode == MODE_FILE) { + results->file_data->uri = zenity_general_uri; + results->file_data->multi = zenity_general_multiple; + results->file_data->directory = zenity_file_directory; + results->file_data->save = zenity_file_save; + results->file_data->confirm_overwrite = zenity_file_confirm_overwrite; + results->file_data->separator = zenity_general_separator; + results->file_data->filter = zenity_file_filter; + } else { + if (zenity_file_directory) + zenity_option_error (zenity_option_get_name (file_selection_options, + &zenity_file_directory), + ERROR_SUPPORT); + + if (zenity_file_save) + zenity_option_error (zenity_option_get_name ( + file_selection_options, &zenity_file_save), + ERROR_SUPPORT); + + if (zenity_file_filter) + zenity_option_error (zenity_option_get_name (file_selection_options, + &zenity_file_filter), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_list_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - int i = 0; - gchar *column; - - zenity_option_set_dialog_mode (zenity_list_active, MODE_LIST); - - if (results->mode == MODE_LIST) { - results->tree_data->dialog_text = zenity_general_dialog_text; - - if (zenity_list_columns) { - column = zenity_list_columns[0]; - while (column != NULL) { - results->tree_data->columns = g_slist_append (results->tree_data->columns, column); - column = zenity_list_columns[++i]; - } - } - - results->tree_data->checkbox = zenity_list_checklist; - results->tree_data->radiobox = zenity_list_radiolist; - results->tree_data->imagebox = zenity_list_imagelist; - results->tree_data->multi = zenity_general_multiple; - results->tree_data->editable = zenity_general_editable; - results->tree_data->print_column = zenity_list_print_column; - results->tree_data->hide_column = zenity_list_hide_column; - results->tree_data->hide_header = zenity_list_hide_header; - results->tree_data->separator = zenity_general_separator; - results->tree_data->mid_search = zenity_list_mid_search; - } else { - if (zenity_list_columns) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_columns), - ERROR_SUPPORT); - - if (zenity_list_checklist) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_checklist), - ERROR_SUPPORT); - - if (zenity_list_radiolist) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_radiolist), - ERROR_SUPPORT); - - if (zenity_list_imagelist) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_imagelist), - ERROR_SUPPORT); - - if (zenity_list_print_column) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_print_column), - ERROR_SUPPORT); - - if (zenity_list_hide_column) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_column), - ERROR_SUPPORT); - - if (zenity_list_hide_header) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_hide_header), - ERROR_SUPPORT); - if (zenity_list_mid_search) - zenity_option_error (zenity_option_get_name (list_options, &zenity_list_mid_search), - ERROR_SUPPORT); - } - - return TRUE; +zenity_list_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + int i = 0; + gchar *column; + + zenity_option_set_dialog_mode (zenity_list_active, MODE_LIST); + + if (results->mode == MODE_LIST) { + results->tree_data->dialog_text = zenity_general_dialog_text; + + if (zenity_list_columns) { + column = zenity_list_columns[0]; + while (column != NULL) { + results->tree_data->columns = + g_slist_append (results->tree_data->columns, column); + column = zenity_list_columns[++i]; + } + } + + results->tree_data->checkbox = zenity_list_checklist; + results->tree_data->radiobox = zenity_list_radiolist; + results->tree_data->imagebox = zenity_list_imagelist; + results->tree_data->multi = zenity_general_multiple; + results->tree_data->editable = zenity_general_editable; + results->tree_data->print_column = zenity_list_print_column; + results->tree_data->hide_column = zenity_list_hide_column; + results->tree_data->hide_header = zenity_list_hide_header; + results->tree_data->separator = zenity_general_separator; + results->tree_data->mid_search = zenity_list_mid_search; + } else { + if (zenity_list_columns) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_columns), + ERROR_SUPPORT); + + if (zenity_list_checklist) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_checklist), + ERROR_SUPPORT); + + if (zenity_list_radiolist) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_radiolist), + ERROR_SUPPORT); + + if (zenity_list_imagelist) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_imagelist), + ERROR_SUPPORT); + + if (zenity_list_print_column) + zenity_option_error (zenity_option_get_name ( + list_options, &zenity_list_print_column), + ERROR_SUPPORT); + + if (zenity_list_hide_column) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_hide_column), + ERROR_SUPPORT); + + if (zenity_list_hide_header) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_hide_header), + ERROR_SUPPORT); + if (zenity_list_mid_search) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_list_mid_search), + ERROR_SUPPORT); + } + + return TRUE; } #ifdef HAVE_LIBNOTIFY static gboolean -zenity_notification_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_notification_active, MODE_NOTIFICATION); - - if (results->mode == MODE_NOTIFICATION) { - results->notification_data->notification_text = zenity_general_dialog_text; - results->notification_data->listen = zenity_notification_listen; - results->notification_data->notification_hints = zenity_notification_hints; - } else { - if (zenity_notification_listen) - zenity_option_error (zenity_option_get_name (notification_options, &zenity_notification_listen), - ERROR_SUPPORT); - } - - return TRUE; +zenity_notification_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode ( + zenity_notification_active, MODE_NOTIFICATION); + + if (results->mode == MODE_NOTIFICATION) { + results->notification_data->notification_text = + zenity_general_dialog_text; + results->notification_data->listen = zenity_notification_listen; + results->notification_data->notification_hints = + zenity_notification_hints; + } else { + if (zenity_notification_listen) + zenity_option_error (zenity_option_get_name (notification_options, + &zenity_notification_listen), + ERROR_SUPPORT); + } + + return TRUE; } #endif static gboolean -zenity_progress_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS); - if (results->mode == MODE_PROGRESS) { - results->progress_data->dialog_text = zenity_general_dialog_text; - results->progress_data->pulsate = zenity_progress_pulsate; - results->progress_data->autoclose = zenity_progress_auto_close; - results->progress_data->autokill = zenity_progress_auto_kill; - results->progress_data->percentage = zenity_progress_percentage; - results->progress_data->no_cancel = zenity_progress_no_cancel; - results->progress_data->time_remaining = zenity_progress_time_remaining; - } else { - if (zenity_progress_pulsate) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_pulsate), - ERROR_SUPPORT); - - if (zenity_progress_percentage) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_percentage), - ERROR_SUPPORT); - - if (zenity_progress_auto_close) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_close), - ERROR_SUPPORT); - - if (zenity_progress_auto_kill) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_auto_kill), - ERROR_SUPPORT); - - if (zenity_progress_no_cancel) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_no_cancel), - ERROR_SUPPORT); - - if (zenity_progress_time_remaining) - zenity_option_error (zenity_option_get_name (progress_options, &zenity_progress_time_remaining), - ERROR_SUPPORT); - } - - return TRUE; +zenity_progress_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS); + if (results->mode == MODE_PROGRESS) { + results->progress_data->dialog_text = zenity_general_dialog_text; + results->progress_data->pulsate = zenity_progress_pulsate; + results->progress_data->autoclose = zenity_progress_auto_close; + results->progress_data->autokill = zenity_progress_auto_kill; + results->progress_data->percentage = zenity_progress_percentage; + results->progress_data->no_cancel = zenity_progress_no_cancel; + results->progress_data->time_remaining = zenity_progress_time_remaining; + } else { + if (zenity_progress_pulsate) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_pulsate), + ERROR_SUPPORT); + + if (zenity_progress_percentage) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_percentage), + ERROR_SUPPORT); + + if (zenity_progress_auto_close) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_auto_close), + ERROR_SUPPORT); + + if (zenity_progress_auto_kill) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_auto_kill), + ERROR_SUPPORT); + + if (zenity_progress_no_cancel) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_no_cancel), + ERROR_SUPPORT); + + if (zenity_progress_time_remaining) + zenity_option_error (zenity_option_get_name (progress_options, + &zenity_progress_time_remaining), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_question_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION); - if (results->mode == MODE_QUESTION) { - results->msg_data->dialog_text = zenity_general_dialog_text; - results->msg_data->dialog_icon = zenity_general_dialog_icon; - if(zenity_question_switch) - results->msg_data->mode = ZENITY_MSG_SWITCH; - else - results->msg_data->mode = ZENITY_MSG_QUESTION; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; - results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ellipsize = zenity_general_dialog_ellipsize; - results->msg_data->default_cancel = zenity_question_default_cancel; - } - if(zenity_question_switch && zenity_general_extra_buttons==NULL) - zenity_option_error (zenity_option_get_name (question_options, &zenity_question_switch), ERROR_SYNTAX); - - return TRUE; +zenity_question_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION); + if (results->mode == MODE_QUESTION) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; + if (zenity_question_switch) + results->msg_data->mode = ZENITY_MSG_SWITCH; + else + results->msg_data->mode = ZENITY_MSG_QUESTION; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; + results->msg_data->default_cancel = zenity_question_default_cancel; + } + if (zenity_question_switch && zenity_general_extra_buttons == NULL) + zenity_option_error ( + zenity_option_get_name (question_options, &zenity_question_switch), + ERROR_SYNTAX); + + return TRUE; } static gboolean -zenity_text_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_text_active, MODE_TEXTINFO); - - if (results->mode == MODE_TEXTINFO) { - results->text_data->uri = zenity_general_uri; - results->text_data->editable = zenity_general_editable; - results->text_data->no_wrap = zenity_general_dialog_no_wrap; - results->text_data->font = zenity_text_font; - results->text_data->checkbox = zenity_text_checkbox; - results->text_data->auto_scroll = zenity_text_auto_scroll; +zenity_text_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_text_active, MODE_TEXTINFO); + + if (results->mode == MODE_TEXTINFO) { + results->text_data->uri = zenity_general_uri; + results->text_data->editable = zenity_general_editable; + results->text_data->no_wrap = zenity_general_dialog_no_wrap; + results->text_data->font = zenity_text_font; + results->text_data->checkbox = zenity_text_checkbox; + results->text_data->auto_scroll = zenity_text_auto_scroll; #ifdef HAVE_WEBKITGTK - results->text_data->html = zenity_text_enable_html; - results->text_data->no_interaction = zenity_text_no_interaction; - results->text_data->url = zenity_text_url; + results->text_data->html = zenity_text_enable_html; + results->text_data->no_interaction = zenity_text_no_interaction; + results->text_data->url = zenity_text_url; #endif - } else { - if (zenity_text_font) - zenity_option_error (zenity_option_get_name (text_options, &zenity_text_font), - ERROR_SUPPORT); + } else { + if (zenity_text_font) + zenity_option_error ( + zenity_option_get_name (text_options, &zenity_text_font), + ERROR_SUPPORT); #ifdef HAVE_WEBKITGTK - if (zenity_text_enable_html) - zenity_option_error (zenity_option_get_name (text_options, &zenity_text_enable_html), - ERROR_SUPPORT); + if (zenity_text_enable_html) + zenity_option_error ( + zenity_option_get_name (text_options, &zenity_text_enable_html), + ERROR_SUPPORT); #endif - } - return TRUE; + } + return TRUE; } static gboolean -zenity_warning_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_warning_active, MODE_WARNING); - - if (results->mode == MODE_WARNING) { - results->msg_data->dialog_text = zenity_general_dialog_text; - results->msg_data->dialog_icon = zenity_general_dialog_icon; - results->msg_data->mode = ZENITY_MSG_WARNING; - results->msg_data->no_wrap = zenity_general_dialog_no_wrap; - results->msg_data->no_markup = zenity_general_dialog_no_markup; - results->msg_data->ellipsize = zenity_general_dialog_ellipsize; - } - - return TRUE; +zenity_warning_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_warning_active, MODE_WARNING); + + if (results->mode == MODE_WARNING) { + results->msg_data->dialog_text = zenity_general_dialog_text; + results->msg_data->dialog_icon = zenity_general_dialog_icon; + results->msg_data->mode = ZENITY_MSG_WARNING; + results->msg_data->no_wrap = zenity_general_dialog_no_wrap; + results->msg_data->no_markup = zenity_general_dialog_no_markup; + results->msg_data->ellipsize = zenity_general_dialog_ellipsize; + } + + return TRUE; } static gboolean -zenity_scale_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_scale_active, MODE_SCALE); - - if (results->mode == MODE_SCALE) { - results->scale_data->dialog_text = zenity_general_dialog_text; - results->scale_data->value = zenity_scale_value; - results->scale_data->min_value = zenity_scale_min_value; - results->scale_data->max_value = zenity_scale_max_value; - results->scale_data->step = zenity_scale_step; - results->scale_data->print_partial = zenity_scale_print_partial; - results->scale_data->hide_value = zenity_scale_hide_value; - } - - return TRUE; +zenity_scale_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_scale_active, MODE_SCALE); + + if (results->mode == MODE_SCALE) { + results->scale_data->dialog_text = zenity_general_dialog_text; + results->scale_data->value = zenity_scale_value; + results->scale_data->min_value = zenity_scale_min_value; + results->scale_data->max_value = zenity_scale_max_value; + results->scale_data->step = zenity_scale_step; + results->scale_data->print_partial = zenity_scale_print_partial; + results->scale_data->hide_value = zenity_scale_hide_value; + } + + return TRUE; } static gboolean -zenity_color_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_colorsel_active, MODE_COLOR); - - if (results->mode == MODE_COLOR) { - results->color_data->color = zenity_colorsel_color; - results->color_data->show_palette = zenity_colorsel_show_palette; - } else { - if (zenity_colorsel_color) - zenity_option_error (zenity_option_get_name(color_selection_options, &zenity_colorsel_color), - ERROR_SUPPORT); - - if (zenity_colorsel_show_palette) - zenity_option_error (zenity_option_get_name(color_selection_options, &zenity_colorsel_show_palette), - ERROR_SUPPORT); - } - - return TRUE; +zenity_color_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_colorsel_active, MODE_COLOR); + + if (results->mode == MODE_COLOR) { + results->color_data->color = zenity_colorsel_color; + results->color_data->show_palette = zenity_colorsel_show_palette; + } else { + if (zenity_colorsel_color) + zenity_option_error ( + zenity_option_get_name ( + color_selection_options, &zenity_colorsel_color), + ERROR_SUPPORT); + + if (zenity_colorsel_show_palette) + zenity_option_error ( + zenity_option_get_name ( + color_selection_options, &zenity_colorsel_show_palette), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_forms_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - gchar *values; - int i = 0; - - zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); - if (results->mode == MODE_FORMS) { - results->forms_data->dialog_text = zenity_general_dialog_text; - results->forms_data->separator = zenity_general_separator; -// results->forms_data->hide_column = zenity_forms_hide_column; - results->forms_data->show_header = zenity_forms_show_header; - - if (zenity_forms_list_values) { - values = zenity_forms_list_values[0]; - while (values != NULL) { - results->forms_data->list_values = g_slist_append (results->forms_data->list_values, values); - values = zenity_forms_list_values[++i]; - } - } - if (zenity_forms_column_values) { - i = 0; - values = zenity_forms_column_values[0]; - while (values != NULL) { - results->forms_data->column_values = g_slist_append (results->forms_data->column_values, values); - values = zenity_forms_list_values[++i]; - } - } else - results->forms_data->column_values = g_slist_append (NULL, "column"); - - if (zenity_forms_combo_values) { - i = 0; - values = zenity_forms_combo_values[0]; - while (values != NULL) { - results->forms_data->combo_values = g_slist_append (results->forms_data->combo_values, values); - values = zenity_forms_combo_values[++i]; - } - } - if (zenity_forms_date_format) - results->forms_data->date_format = zenity_forms_date_format; - else - results->forms_data->date_format = g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); - } else { - if (zenity_forms_date_format) - zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_date_format), - ERROR_SUPPORT); - if (zenity_forms_list_values) - zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_list_values), - ERROR_SUPPORT); -// if (zenity_forms_hide_column) -// zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_hide_column), -// ERROR_SUPPORT); - if (zenity_forms_column_values) - zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_column_values), - ERROR_SUPPORT); - if (zenity_forms_combo_values) - zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_combo_values), - ERROR_SUPPORT); - if (zenity_forms_show_header) - zenity_option_error (zenity_option_get_name (forms_dialog_options, &zenity_forms_show_header), - ERROR_SUPPORT); - } - - return TRUE; +zenity_forms_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + gchar *values; + int i = 0; + + zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS); + if (results->mode == MODE_FORMS) { + results->forms_data->dialog_text = zenity_general_dialog_text; + results->forms_data->separator = zenity_general_separator; + // results->forms_data->hide_column = zenity_forms_hide_column; + results->forms_data->show_header = zenity_forms_show_header; + + if (zenity_forms_list_values) { + values = zenity_forms_list_values[0]; + while (values != NULL) { + results->forms_data->list_values = + g_slist_append (results->forms_data->list_values, values); + values = zenity_forms_list_values[++i]; + } + } + if (zenity_forms_column_values) { + i = 0; + values = zenity_forms_column_values[0]; + while (values != NULL) { + results->forms_data->column_values = + g_slist_append (results->forms_data->column_values, values); + values = zenity_forms_list_values[++i]; + } + } else + results->forms_data->column_values = + g_slist_append (NULL, "column"); + + if (zenity_forms_combo_values) { + i = 0; + values = zenity_forms_combo_values[0]; + while (values != NULL) { + results->forms_data->combo_values = + g_slist_append (results->forms_data->combo_values, values); + values = zenity_forms_combo_values[++i]; + } + } + if (zenity_forms_date_format) + results->forms_data->date_format = zenity_forms_date_format; + else + results->forms_data->date_format = + g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL); + } else { + if (zenity_forms_date_format) + zenity_option_error (zenity_option_get_name (forms_dialog_options, + &zenity_forms_date_format), + ERROR_SUPPORT); + if (zenity_forms_list_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, + &zenity_forms_list_values), + ERROR_SUPPORT); + // if (zenity_forms_hide_column) + // zenity_option_error (zenity_option_get_name + // (forms_dialog_options, &zenity_forms_hide_column), + // ERROR_SUPPORT); + if (zenity_forms_column_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, + &zenity_forms_column_values), + ERROR_SUPPORT); + if (zenity_forms_combo_values) + zenity_option_error (zenity_option_get_name (forms_dialog_options, + &zenity_forms_combo_values), + ERROR_SUPPORT); + if (zenity_forms_show_header) + zenity_option_error (zenity_option_get_name (forms_dialog_options, + &zenity_forms_show_header), + ERROR_SUPPORT); + } + + return TRUE; } - static gboolean -zenity_password_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_password_active, MODE_PASSWORD); - if (results->mode == MODE_PASSWORD) { - results->password_data->username = zenity_password_show_username; - } else { - if (zenity_password_show_username) - zenity_option_error (zenity_option_get_name(password_dialog_options, &zenity_password_show_username), - ERROR_SUPPORT); - } - - return TRUE; +zenity_password_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_password_active, MODE_PASSWORD); + if (results->mode == MODE_PASSWORD) { + results->password_data->username = zenity_password_show_username; + } else { + if (zenity_password_show_username) + zenity_option_error ( + zenity_option_get_name ( + password_dialog_options, &zenity_password_show_username), + ERROR_SUPPORT); + } + + return TRUE; } static gboolean -zenity_misc_post_callback (GOptionContext *context, - GOptionGroup *group, - gpointer data, - GError **error) -{ - zenity_option_set_dialog_mode (zenity_misc_about, MODE_ABOUT); - zenity_option_set_dialog_mode (zenity_misc_version, MODE_VERSION); - - return TRUE; +zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group, + gpointer data, GError **error) { + zenity_option_set_dialog_mode (zenity_misc_about, MODE_ABOUT); + zenity_option_set_dialog_mode (zenity_misc_version, MODE_VERSION); + + return TRUE; } static GOptionContext * -zenity_create_context (void) -{ - GOptionContext *tmp_ctx; - GOptionGroup *a_group; - - tmp_ctx = g_option_context_new(NULL); - - /* Adds general option entries */ - a_group = g_option_group_new("general", - N_("General options"), - N_("Show general options"), NULL, NULL); - g_option_group_add_entries(a_group, general_options); - g_option_group_set_parse_hooks (a_group, - zenity_general_pre_callback, zenity_general_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds calendar option entries */ - a_group = g_option_group_new("calendar", - N_("Calendar options"), - N_("Show calendar options"), NULL, NULL); - g_option_group_add_entries(a_group, calendar_options); - g_option_group_set_parse_hooks (a_group, - zenity_calendar_pre_callback, zenity_calendar_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds entry option entries */ - a_group = g_option_group_new("entry", - N_("Text entry options"), - N_("Show text entry options"), NULL, NULL); - g_option_group_add_entries(a_group, entry_options); - g_option_group_set_parse_hooks (a_group, - zenity_entry_pre_callback, zenity_entry_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds error option entries */ - a_group = g_option_group_new("error", - N_("Error options"), - N_("Show error options"), NULL, NULL); - g_option_group_add_entries(a_group, error_options); - g_option_group_set_parse_hooks (a_group, - zenity_error_pre_callback, zenity_error_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds info option entries */ - a_group = g_option_group_new("info", - N_("Info options"), - N_("Show info options"), NULL, NULL); - g_option_group_add_entries(a_group, info_options); - g_option_group_set_parse_hooks (a_group, - zenity_info_pre_callback, zenity_info_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds file selection option entries */ - a_group = g_option_group_new("file-selection", - N_("File selection options"), - N_("Show file selection options"), NULL, NULL); - g_option_group_add_entries(a_group, file_selection_options); - g_option_group_set_parse_hooks (a_group, - zenity_file_pre_callback, zenity_file_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds list option entries */ - a_group = g_option_group_new("list", - N_("List options"), - N_("Show list options"), NULL, NULL); - g_option_group_add_entries(a_group, list_options); - g_option_group_set_parse_hooks (a_group, - zenity_list_pre_callback, zenity_list_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - -#ifdef HAVE_LIBNOTIFY - /* Adds notification option entries */ - a_group = g_option_group_new("notification", - N_("Notification icon options"), - N_("Show notification icon options"), NULL, NULL); - g_option_group_add_entries(a_group, notification_options); - g_option_group_set_parse_hooks (a_group, - zenity_notification_pre_callback, zenity_notification_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); +zenity_create_context (void) { + GOptionContext *tmp_ctx; + GOptionGroup *a_group; + + tmp_ctx = g_option_context_new (NULL); + + /* Adds general option entries */ + a_group = g_option_group_new ("general", + N_ ("General options"), + N_ ("Show general options"), + NULL, + NULL); + g_option_group_add_entries (a_group, general_options); + g_option_group_set_parse_hooks ( + a_group, zenity_general_pre_callback, zenity_general_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds calendar option entries */ + a_group = g_option_group_new ("calendar", + N_ ("Calendar options"), + N_ ("Show calendar options"), + NULL, + NULL); + g_option_group_add_entries (a_group, calendar_options); + g_option_group_set_parse_hooks ( + a_group, zenity_calendar_pre_callback, zenity_calendar_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds entry option entries */ + a_group = g_option_group_new ("entry", + N_ ("Text entry options"), + N_ ("Show text entry options"), + NULL, + NULL); + g_option_group_add_entries (a_group, entry_options); + g_option_group_set_parse_hooks ( + a_group, zenity_entry_pre_callback, zenity_entry_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds error option entries */ + a_group = g_option_group_new ( + "error", N_ ("Error options"), N_ ("Show error options"), NULL, NULL); + g_option_group_add_entries (a_group, error_options); + g_option_group_set_parse_hooks ( + a_group, zenity_error_pre_callback, zenity_error_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds info option entries */ + a_group = g_option_group_new ( + "info", N_ ("Info options"), N_ ("Show info options"), NULL, NULL); + g_option_group_add_entries (a_group, info_options); + g_option_group_set_parse_hooks ( + a_group, zenity_info_pre_callback, zenity_info_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds file selection option entries */ + a_group = g_option_group_new ("file-selection", + N_ ("File selection options"), + N_ ("Show file selection options"), + NULL, + NULL); + g_option_group_add_entries (a_group, file_selection_options); + g_option_group_set_parse_hooks ( + a_group, zenity_file_pre_callback, zenity_file_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds list option entries */ + a_group = g_option_group_new ( + "list", N_ ("List options"), N_ ("Show list options"), NULL, NULL); + g_option_group_add_entries (a_group, list_options); + g_option_group_set_parse_hooks ( + a_group, zenity_list_pre_callback, zenity_list_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + +#ifdef HAVE_LIBNOTIFY + /* Adds notification option entries */ + a_group = g_option_group_new ("notification", + N_ ("Notification icon options"), + N_ ("Show notification icon options"), + NULL, + NULL); + g_option_group_add_entries (a_group, notification_options); + g_option_group_set_parse_hooks (a_group, + zenity_notification_pre_callback, + zenity_notification_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); #endif - - /* Adds progress option entries */ - a_group = g_option_group_new("progress", - N_("Progress options"), - N_("Show progress options"), NULL, NULL); - g_option_group_add_entries(a_group, progress_options); - g_option_group_set_parse_hooks (a_group, - zenity_progress_pre_callback, zenity_progress_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds question option entries */ - a_group = g_option_group_new("question", - N_("Question options"), - N_("Show question options"), NULL, NULL); - g_option_group_add_entries(a_group, question_options); - g_option_group_set_parse_hooks (a_group, - zenity_question_pre_callback, zenity_question_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds warning option entries */ - a_group = g_option_group_new("warning", - N_("Warning options"), - N_("Show warning options"), NULL, NULL); - g_option_group_add_entries(a_group, warning_options); - g_option_group_set_parse_hooks (a_group, - zenity_warning_pre_callback, zenity_warning_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds scale option entries */ - a_group = g_option_group_new("scale", - N_("Scale options"), - N_("Show scale options"), NULL, NULL); - g_option_group_add_entries(a_group, scale_options); - g_option_group_set_parse_hooks (a_group, - zenity_scale_pre_callback, zenity_scale_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds text option entries */ - a_group = g_option_group_new("text-info", - N_("Text information options"), - N_("Show text information options"), NULL, NULL); - g_option_group_add_entries(a_group, text_options); - g_option_group_set_parse_hooks (a_group, - zenity_text_pre_callback, zenity_text_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds color selection option entries */ - a_group = g_option_group_new("color-selection", - N_("Color selection options"), - N_("Show color selection options"), NULL, NULL); - g_option_group_add_entries(a_group, color_selection_options); - g_option_group_set_parse_hooks (a_group, - zenity_color_pre_callback, zenity_color_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds password dialog option entries */ - a_group = g_option_group_new("password", - N_("Password dialog options"), - N_("Show password dialog options"), NULL, NULL); - g_option_group_add_entries (a_group, password_dialog_options); - g_option_group_set_parse_hooks (a_group, - zenity_password_pre_callback, zenity_password_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds forms dialog option entries */ - a_group = g_option_group_new("forms", - N_("Forms dialog options"), - N_("Show forms dialog options"), NULL, NULL); - g_option_group_add_entries (a_group, forms_dialog_options); - g_option_group_set_parse_hooks (a_group, - zenity_forms_pre_callback, zenity_forms_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds misc option entries */ - a_group = g_option_group_new("misc", - N_("Miscellaneous options"), - N_("Show miscellaneous options"), NULL, NULL); - g_option_group_add_entries(a_group, miscellaneous_options); - g_option_group_set_parse_hooks (a_group, - zenity_misc_pre_callback, zenity_misc_post_callback); - g_option_group_set_error_hook (a_group, zenity_option_error_callback); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Adds gtk option entries */ - a_group = gtk_get_option_group(TRUE); - g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); - g_option_context_add_group(tmp_ctx, a_group); - - /* Enable help options */ - g_option_context_set_help_enabled (tmp_ctx, TRUE); - g_option_context_set_ignore_unknown_options (tmp_ctx, FALSE); - - return tmp_ctx; + + /* Adds progress option entries */ + a_group = g_option_group_new ("progress", + N_ ("Progress options"), + N_ ("Show progress options"), + NULL, + NULL); + g_option_group_add_entries (a_group, progress_options); + g_option_group_set_parse_hooks ( + a_group, zenity_progress_pre_callback, zenity_progress_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds question option entries */ + a_group = g_option_group_new ("question", + N_ ("Question options"), + N_ ("Show question options"), + NULL, + NULL); + g_option_group_add_entries (a_group, question_options); + g_option_group_set_parse_hooks ( + a_group, zenity_question_pre_callback, zenity_question_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds warning option entries */ + a_group = g_option_group_new ("warning", + N_ ("Warning options"), + N_ ("Show warning options"), + NULL, + NULL); + g_option_group_add_entries (a_group, warning_options); + g_option_group_set_parse_hooks ( + a_group, zenity_warning_pre_callback, zenity_warning_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds scale option entries */ + a_group = g_option_group_new ( + "scale", N_ ("Scale options"), N_ ("Show scale options"), NULL, NULL); + g_option_group_add_entries (a_group, scale_options); + g_option_group_set_parse_hooks ( + a_group, zenity_scale_pre_callback, zenity_scale_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds text option entries */ + a_group = g_option_group_new ("text-info", + N_ ("Text information options"), + N_ ("Show text information options"), + NULL, + NULL); + g_option_group_add_entries (a_group, text_options); + g_option_group_set_parse_hooks ( + a_group, zenity_text_pre_callback, zenity_text_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds color selection option entries */ + a_group = g_option_group_new ("color-selection", + N_ ("Color selection options"), + N_ ("Show color selection options"), + NULL, + NULL); + g_option_group_add_entries (a_group, color_selection_options); + g_option_group_set_parse_hooks ( + a_group, zenity_color_pre_callback, zenity_color_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds password dialog option entries */ + a_group = g_option_group_new ("password", + N_ ("Password dialog options"), + N_ ("Show password dialog options"), + NULL, + NULL); + g_option_group_add_entries (a_group, password_dialog_options); + g_option_group_set_parse_hooks ( + a_group, zenity_password_pre_callback, zenity_password_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds forms dialog option entries */ + a_group = g_option_group_new ("forms", + N_ ("Forms dialog options"), + N_ ("Show forms dialog options"), + NULL, + NULL); + g_option_group_add_entries (a_group, forms_dialog_options); + g_option_group_set_parse_hooks ( + a_group, zenity_forms_pre_callback, zenity_forms_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds misc option entries */ + a_group = g_option_group_new ("misc", + N_ ("Miscellaneous options"), + N_ ("Show miscellaneous options"), + NULL, + NULL); + g_option_group_add_entries (a_group, miscellaneous_options); + g_option_group_set_parse_hooks ( + a_group, zenity_misc_pre_callback, zenity_misc_post_callback); + g_option_group_set_error_hook (a_group, zenity_option_error_callback); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Adds gtk option entries */ + a_group = gtk_get_option_group (TRUE); + g_option_group_set_translation_domain (a_group, GETTEXT_PACKAGE); + g_option_context_add_group (tmp_ctx, a_group); + + /* Enable help options */ + g_option_context_set_help_enabled (tmp_ctx, TRUE); + g_option_context_set_ignore_unknown_options (tmp_ctx, FALSE); + + return tmp_ctx; } void -zenity_option_error (gchar *string, ZenityError error) -{ - switch (error) { - case ERROR_SYNTAX: - g_printerr (_("This option is not available. Please see --help for all possible usages.\n")); - zenity_option_free (); - exit (-1); - case ERROR_SUPPORT: - g_printerr (_("--%s is not supported for this dialog\n"), string); - zenity_option_free (); - exit (-1); - case ERROR_DIALOG: - g_printerr (_("Two or more dialog options specified\n")); - zenity_option_free (); - exit (-1); - default: - return; - } +zenity_option_error (gchar *string, ZenityError error) { + switch (error) { + case ERROR_SYNTAX: + g_printerr (_ ("This option is not available. Please see --help " + "for all possible usages.\n")); + zenity_option_free (); + exit (-1); + case ERROR_SUPPORT: + g_printerr (_ ("--%s is not supported for this dialog\n"), string); + zenity_option_free (); + exit (-1); + case ERROR_DIALOG: + g_printerr (_ ("Two or more dialog options specified\n")); + zenity_option_free (); + exit (-1); + default: + return; + } } ZenityParsingOptions * -zenity_option_parse (gint argc, gchar **argv) -{ - GError *error = NULL; - - zenity_option_init (); - - ctx = zenity_create_context (); - - g_option_context_parse (ctx, &argc, &argv, &error); - - /* Some option pointer a shared among more than one group and don't - have their post condition tested. This test is done here. */ - - if (zenity_general_dialog_text) - if (results->mode == MODE_ABOUT || results->mode == MODE_VERSION) - zenity_option_error (zenity_option_get_name (calendar_options, &zenity_general_dialog_text), ERROR_SUPPORT); - - if (strcmp (zenity_general_separator, "|") != 0) - if (results->mode != MODE_LIST && results->mode != MODE_FILE && results->mode != MODE_FORMS) - zenity_option_error (zenity_option_get_name (list_options, &zenity_general_separator), ERROR_SUPPORT); - - if (zenity_general_multiple) - if (results->mode != MODE_FILE && results->mode != MODE_LIST) - zenity_option_error (zenity_option_get_name (list_options, &zenity_general_multiple), ERROR_SUPPORT); - - if (zenity_general_editable) - if (results->mode != MODE_TEXTINFO && results->mode != MODE_LIST) - zenity_option_error (zenity_option_get_name (list_options, &zenity_general_editable), ERROR_SUPPORT); - - if (zenity_general_uri) - if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) - zenity_option_error (zenity_option_get_name (text_options, &zenity_general_uri), ERROR_SUPPORT); - - if (zenity_general_ok_button) - if(results->mode == MODE_FILE) - zenity_option_error (zenity_option_get_name (general_options, &zenity_general_ok_button), ERROR_SUPPORT); - - if (zenity_general_cancel_button) - if(results->mode == MODE_FILE || results->mode == MODE_ERROR || results->mode == MODE_WARNING || results->mode == MODE_INFO) - zenity_option_error (zenity_option_get_name (general_options, &zenity_general_cancel_button), ERROR_SUPPORT); - - if (zenity_general_dialog_no_wrap) - if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING && results->mode != MODE_TEXTINFO) - zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_no_wrap), ERROR_SUPPORT); - - if (zenity_general_dialog_ellipsize) - if (results->mode != MODE_INFO && results->mode != MODE_ERROR && results->mode != MODE_QUESTION && results->mode != MODE_WARNING) - zenity_option_error (zenity_option_get_name (text_options, &zenity_general_dialog_ellipsize), ERROR_SUPPORT); - - - return results; +zenity_option_parse (gint argc, gchar **argv) { + GError *error = NULL; + + zenity_option_init (); + + ctx = zenity_create_context (); + + g_option_context_parse (ctx, &argc, &argv, &error); + + /* Some option pointer a shared among more than one group and don't + have their post condition tested. This test is done here. */ + + if (zenity_general_dialog_text) + if (results->mode == MODE_ABOUT || results->mode == MODE_VERSION) + zenity_option_error (zenity_option_get_name (calendar_options, + &zenity_general_dialog_text), + ERROR_SUPPORT); + + if (strcmp (zenity_general_separator, "|") != 0) + if (results->mode != MODE_LIST && results->mode != MODE_FILE && + results->mode != MODE_FORMS) + zenity_option_error (zenity_option_get_name ( + list_options, &zenity_general_separator), + ERROR_SUPPORT); + + if (zenity_general_multiple) + if (results->mode != MODE_FILE && results->mode != MODE_LIST) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_general_multiple), + ERROR_SUPPORT); + + if (zenity_general_editable) + if (results->mode != MODE_TEXTINFO && results->mode != MODE_LIST) + zenity_option_error ( + zenity_option_get_name (list_options, &zenity_general_editable), + ERROR_SUPPORT); + + if (zenity_general_uri) + if (results->mode != MODE_FILE && results->mode != MODE_TEXTINFO) + zenity_option_error ( + zenity_option_get_name (text_options, &zenity_general_uri), + ERROR_SUPPORT); + + if (zenity_general_ok_button) + if (results->mode == MODE_FILE) + zenity_option_error (zenity_option_get_name (general_options, + &zenity_general_ok_button), + ERROR_SUPPORT); + + if (zenity_general_cancel_button) + if (results->mode == MODE_FILE || results->mode == MODE_ERROR || + results->mode == MODE_WARNING || results->mode == MODE_INFO) + zenity_option_error (zenity_option_get_name (general_options, + &zenity_general_cancel_button), + ERROR_SUPPORT); + + if (zenity_general_dialog_no_wrap) + if (results->mode != MODE_INFO && results->mode != MODE_ERROR && + results->mode != MODE_QUESTION && results->mode != MODE_WARNING && + results->mode != MODE_TEXTINFO) + zenity_option_error (zenity_option_get_name (text_options, + &zenity_general_dialog_no_wrap), + ERROR_SUPPORT); + + if (zenity_general_dialog_ellipsize) + if (results->mode != MODE_INFO && results->mode != MODE_ERROR && + results->mode != MODE_QUESTION && results->mode != MODE_WARNING) + zenity_option_error (zenity_option_get_name (text_options, + &zenity_general_dialog_ellipsize), + ERROR_SUPPORT); + + return results; } diff --git a/src/option.h b/src/option.h index d77c5631..b495e0e7 100644 --- a/src/option.h +++ b/src/option.h @@ -31,61 +31,59 @@ #endif typedef enum { - MODE_CALENDAR, - MODE_ENTRY, - MODE_ERROR, - MODE_FILE, - MODE_LIST, - MODE_PROGRESS, - MODE_QUESTION, - MODE_TEXTINFO, - MODE_WARNING, - MODE_SCALE, - MODE_INFO, + MODE_CALENDAR, + MODE_ENTRY, + MODE_ERROR, + MODE_FILE, + MODE_LIST, + MODE_PROGRESS, + MODE_QUESTION, + MODE_TEXTINFO, + MODE_WARNING, + MODE_SCALE, + MODE_INFO, #ifdef HAVE_LIBNOTIFY - MODE_NOTIFICATION, + MODE_NOTIFICATION, #endif - MODE_COLOR, - MODE_PASSWORD, - MODE_FORMS, - MODE_ABOUT, - MODE_VERSION, - MODE_LAST + MODE_COLOR, + MODE_PASSWORD, + MODE_FORMS, + MODE_ABOUT, + MODE_VERSION, + MODE_LAST } ZenityDialogMode; typedef enum { - ERROR_SYNTAX, - ERROR_SUPPORT, - ERROR_DIALOG, - ERROR_LAST + ERROR_SYNTAX, + ERROR_SUPPORT, + ERROR_DIALOG, + ERROR_LAST } ZenityError; typedef struct { - ZenityDialogMode mode; - ZenityData *data; + ZenityDialogMode mode; + ZenityData *data; - ZenityCalendarData *calendar_data; - ZenityMsgData *msg_data; - ZenityScaleData *scale_data; - ZenityFileData *file_data; - ZenityEntryData *entry_data; - ZenityProgressData *progress_data; - ZenityTextData *text_data; - ZenityTreeData *tree_data; + ZenityCalendarData *calendar_data; + ZenityMsgData *msg_data; + ZenityScaleData *scale_data; + ZenityFileData *file_data; + ZenityEntryData *entry_data; + ZenityProgressData *progress_data; + ZenityTextData *text_data; + ZenityTreeData *tree_data; #ifdef HAVE_LIBNOTIFY - ZenityNotificationData *notification_data; + ZenityNotificationData *notification_data; #endif - ZenityColorData *color_data; - ZenityPasswordData *password_data; - ZenityFormsData *forms_data; + ZenityColorData *color_data; + ZenityPasswordData *password_data; + ZenityFormsData *forms_data; } ZenityParsingOptions; -void zenity_option_error (gchar *string, - ZenityError error); +void zenity_option_error (gchar *string, ZenityError error); -ZenityParsingOptions * zenity_option_parse (gint argc, - gchar **argv); +ZenityParsingOptions *zenity_option_parse (gint argc, gchar **argv); -void zenity_option_free (void); +void zenity_option_free (void); #endif /* OPTION_H */ diff --git a/src/password.c b/src/password.c index d8f492f6..44a2a204 100644 --- a/src/password.c +++ b/src/password.c @@ -22,168 +22,152 @@ */ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include static ZenityData *zen_data; -static void zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data); - -void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data) -{ - GtkWidget *dialog; - GtkWidget *image; - GtkWidget *hbox; - GtkWidget *vbox_labels; - GtkWidget *vbox_entries; - GtkWidget *label; - - zen_data = data; - - dialog = gtk_dialog_new (); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - gtk_dialog_add_button(GTK_DIALOG(dialog), - data->cancel_label != NULL ? data->cancel_label : _("_Cancel"), - GTK_RESPONSE_CANCEL); - gtk_dialog_add_button(GTK_DIALOG(dialog), - data->ok_label != NULL ? data->ok_label : _("_OK"), - GTK_RESPONSE_OK); - - image = gtk_image_new_from_icon_name("dialog-password", - GTK_ICON_SIZE_DIALOG); - gtk_dialog_set_default_response(GTK_DIALOG(dialog), - GTK_RESPONSE_OK); - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); - gtk_box_pack_start(GTK_BOX(hbox), - image, - FALSE, - FALSE, - 12); - - /* Checks if username has been passed as a parameter */ - gchar *title_text = N_("Type your password"); - - if(password_data->username) - title_text = N_("Type your username and password"); - - label = gtk_label_new(title_text); - - gtk_box_pack_start(GTK_BOX(hbox), - label, - FALSE, - FALSE, - 12); - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), - hbox, - FALSE, - TRUE, - 5); - - vbox_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); - vbox_entries = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5); - - hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5); - gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))), - hbox, - FALSE, - TRUE, - 5); - - gtk_box_pack_start(GTK_BOX(hbox), - vbox_labels, - FALSE, - TRUE, - 12); - gtk_box_pack_start(GTK_BOX(hbox), - vbox_entries, - TRUE, - TRUE, - 12); - - if(password_data->username) { - label = gtk_label_new(_("Username:")); - gtk_box_pack_start(GTK_BOX(vbox_labels), - label, - TRUE, - FALSE, - 12); - password_data->entry_username = gtk_entry_new(); - gtk_box_pack_start(GTK_BOX(vbox_entries), - password_data->entry_username, - TRUE, - TRUE, - 12); - } - - label = gtk_label_new(_("Password:")); - gtk_box_pack_start(GTK_BOX(vbox_labels), - label, - TRUE, - FALSE, - 12); - password_data->entry_password = gtk_entry_new(); - gtk_entry_set_visibility(GTK_ENTRY(password_data->entry_password), - FALSE); - gtk_entry_set_activates_default (GTK_ENTRY(password_data->entry_password), - TRUE); - gtk_box_pack_start(GTK_BOX(vbox_entries), - password_data->entry_password, - TRUE, - TRUE, - 12); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_password_dialog_response), - password_data); - gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog)))); - zenity_util_show_dialog (dialog, data->attach); - - if (data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, - (GSourceFunc) zenity_util_timeout_handle, - dialog); - } - gtk_main(); +static void zenity_password_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data) { + GtkWidget *dialog; + GtkWidget *image; + GtkWidget *hbox; + GtkWidget *vbox_labels; + GtkWidget *vbox_entries; + GtkWidget *label; + + zen_data = data; + + dialog = gtk_dialog_new (); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + gtk_dialog_add_button (GTK_DIALOG (dialog), + data->cancel_label != NULL ? data->cancel_label : _ ("_Cancel"), + GTK_RESPONSE_CANCEL); + gtk_dialog_add_button (GTK_DIALOG (dialog), + data->ok_label != NULL ? data->ok_label : _ ("_OK"), + GTK_RESPONSE_OK); + + image = + gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG); + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 12); + + /* Checks if username has been passed as a parameter */ + gchar *title_text = N_ ("Type your password"); + + if (password_data->username) + title_text = N_ ("Type your username and password"); + + label = gtk_label_new (title_text); + + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 12); + gtk_box_pack_start ( + GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + hbox, + FALSE, + TRUE, + 5); + + vbox_labels = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + vbox_entries = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5); + + hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5); + gtk_box_pack_start ( + GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), + hbox, + FALSE, + TRUE, + 5); + + gtk_box_pack_start (GTK_BOX (hbox), vbox_labels, FALSE, TRUE, 12); + gtk_box_pack_start (GTK_BOX (hbox), vbox_entries, TRUE, TRUE, 12); + + if (password_data->username) { + label = gtk_label_new (_ ("Username:")); + gtk_box_pack_start (GTK_BOX (vbox_labels), label, TRUE, FALSE, 12); + password_data->entry_username = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (vbox_entries), + password_data->entry_username, + TRUE, + TRUE, + 12); + } + + label = gtk_label_new (_ ("Password:")); + gtk_box_pack_start (GTK_BOX (vbox_labels), label, TRUE, FALSE, 12); + password_data->entry_password = gtk_entry_new (); + gtk_entry_set_visibility (GTK_ENTRY (password_data->entry_password), FALSE); + gtk_entry_set_activates_default ( + GTK_ENTRY (password_data->entry_password), TRUE); + gtk_box_pack_start ( + GTK_BOX (vbox_entries), password_data->entry_password, TRUE, TRUE, 12); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_password_dialog_response), + password_data); + gtk_widget_show_all ( + GTK_WIDGET (gtk_dialog_get_content_area (GTK_DIALOG (dialog)))); + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + gtk_main (); } static void -zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityPasswordData *password_data = (ZenityPasswordData *) data; - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - if (password_data->username) - g_print("%s|%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_username)), gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); - else - g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_password))); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - - gtk_main_quit (); +zenity_password_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + ZenityPasswordData *password_data = (ZenityPasswordData *) data; + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + if (password_data->username) + g_print ("%s|%s\n", + gtk_entry_get_text ( + GTK_ENTRY (password_data->entry_username)), + gtk_entry_get_text ( + GTK_ENTRY (password_data->entry_password))); + else + g_print ("%s\n", + gtk_entry_get_text ( + GTK_ENTRY (password_data->entry_password))); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + + gtk_main_quit (); } diff --git a/src/progress.c b/src/progress.c index 4995c5fd..1a5a68fd 100644 --- a/src/progress.c +++ b/src/progress.c @@ -23,15 +23,15 @@ #include "config.h" +#include "util.h" +#include "zenity.h" +#include #include -#include #include +#include #include -#include -#include #include -#include "zenity.h" -#include "util.h" +#include static GtkBuilder *builder; static ZenityData *zen_data; @@ -45,358 +45,385 @@ static gboolean auto_close; gint zenity_progress_timeout (gpointer data); gint zenity_progress_pulsate_timeout (gpointer data); -static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data); +static void zenity_progress_dialog_response ( + GtkWidget *widget, int response, gpointer data); static gboolean -zenity_progress_pulsate_progress_bar (gpointer user_data) -{ - gtk_progress_bar_pulse (GTK_PROGRESS_BAR (user_data)); - return TRUE; +zenity_progress_pulsate_progress_bar (gpointer user_data) { + gtk_progress_bar_pulse (GTK_PROGRESS_BAR (user_data)); + return TRUE; } static void -zenity_progress_pulsate_stop (void) -{ - if (pulsate_timeout > 0) { - g_source_remove (pulsate_timeout); - pulsate_timeout = -1; - } +zenity_progress_pulsate_stop (void) { + if (pulsate_timeout > 0) { + g_source_remove (pulsate_timeout); + pulsate_timeout = -1; + } } static void -zenity_progress_pulsate_start (GObject *progress_bar) -{ - if (pulsate_timeout == -1) { - pulsate_timeout = g_timeout_add (100, - zenity_progress_pulsate_progress_bar, - progress_bar); - } +zenity_progress_pulsate_start (GObject *progress_bar) { + if (pulsate_timeout == -1) { + pulsate_timeout = g_timeout_add ( + 100, zenity_progress_pulsate_progress_bar, progress_bar); + } } static void -zenity_progress_update_time_remaining (ZenityProgressData *progress_data) -{ - static GObject *progress_time = NULL; - static time_t start_time = (time_t)(-1); - float percentage = progress_data->percentage; - - if (progress_time == NULL) - progress_time = gtk_builder_get_object (builder, "zenity_progress_time"); - if (start_time == (time_t)(-1) || percentage <= 0.0 || percentage >= 100.0) { - start_time = time(NULL); - gtk_label_set_text (GTK_LABEL (progress_time), ""); - } else { - time_t current_time = time (NULL); - time_t elapsed_time = current_time - start_time; - time_t total_time = (time_t) (100.0*elapsed_time/progress_data->percentage); - time_t remaining_time = total_time - elapsed_time; - gulong hours, minutes, seconds; - gchar *remaining_message; - - seconds = (gulong) (remaining_time%60); - remaining_time /= 60; - minutes = (gulong) (remaining_time%60); - remaining_time /= 60; - hours = (gulong) remaining_time; - - remaining_message = g_strdup_printf (_("Time remaining: %lu:%02lu:%02lu"), - hours, minutes, seconds); - gtk_label_set_text (GTK_LABEL (progress_time), remaining_message); - g_free (remaining_message); - } +zenity_progress_update_time_remaining (ZenityProgressData *progress_data) { + static GObject *progress_time = NULL; + static time_t start_time = (time_t) (-1); + float percentage = progress_data->percentage; + + if (progress_time == NULL) + progress_time = + gtk_builder_get_object (builder, "zenity_progress_time"); + if (start_time == (time_t) (-1) || percentage <= 0.0 || + percentage >= 100.0) { + start_time = time (NULL); + gtk_label_set_text (GTK_LABEL (progress_time), ""); + } else { + time_t current_time = time (NULL); + time_t elapsed_time = current_time - start_time; + time_t total_time = + (time_t) (100.0 * elapsed_time / progress_data->percentage); + time_t remaining_time = total_time - elapsed_time; + gulong hours, minutes, seconds; + gchar *remaining_message; + + seconds = (gulong) (remaining_time % 60); + remaining_time /= 60; + minutes = (gulong) (remaining_time % 60); + remaining_time /= 60; + hours = (gulong) remaining_time; + + remaining_message = g_strdup_printf ( + _ ("Time remaining: %lu:%02lu:%02lu"), hours, minutes, seconds); + gtk_label_set_text (GTK_LABEL (progress_time), remaining_message); + g_free (remaining_message); + } } static gboolean -zenity_progress_handle_stdin (GIOChannel *channel, - GIOCondition condition, - gpointer data) -{ - static ZenityProgressData *progress_data; - static GObject *progress_bar; - static GObject *progress_label; - float percentage = 0.0; - GIOStatus status = G_IO_STATUS_NORMAL; - - progress_data = (ZenityProgressData *) data; - progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); - progress_label = gtk_builder_get_object (builder, "zenity_progress_text"); - - if ((condition & G_IO_IN) != 0) { - GString *string; - GError *error = NULL; - - string = g_string_new (NULL); - - while (channel->is_readable != TRUE) - ; - do { - do { - status = g_io_channel_read_line_string (channel, string, NULL, &error); - - while (gtk_events_pending ()) - gtk_main_iteration (); - - } while (status == G_IO_STATUS_AGAIN); - - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_warning ("zenity_progress_handle_stdin () : %s", error->message); - g_error_free (error); - error = NULL; - } - continue; - } - - if (!g_ascii_strncasecmp (string->str, "#", 1)) { - gchar *match; - - /* We have a comment, so let's try to change the label */ - match = g_strstr_len (string->str, strlen (string->str), "#"); - match++; - gtk_label_set_text (GTK_LABEL (progress_label), g_strcompress(g_strchomp (g_strchug (match)))); - - } else if (g_str_has_prefix (string->str, "pulsate")) { - gchar *colon, *command, *value; - - zenity_util_strip_newline (string->str); - - colon = strchr(string->str, ':'); - if (colon == NULL) { - continue; - } - - /* split off the command and value */ - command = g_strstrip (g_strndup (string->str, colon - string->str)); - - value = colon + 1; - while (*value && g_ascii_isspace (*value)) value++; - - if (!g_ascii_strcasecmp (value, "false")) { - zenity_progress_pulsate_stop (); - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), - progress_data->percentage / 100.0); - } else { - zenity_progress_pulsate_start (progress_bar); - } - - g_free (command); - } else { - - if (!g_ascii_isdigit (*(string->str))) - continue; - - /* Now try to convert the thing to a number */ - percentage = CLAMP(atoi (string->str), 0, 100); - - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), - percentage / 100.0); - - progress_data->percentage = percentage; - - if (progress_data->time_remaining == TRUE) - zenity_progress_update_time_remaining (progress_data); +zenity_progress_handle_stdin ( + GIOChannel *channel, GIOCondition condition, gpointer data) { + static ZenityProgressData *progress_data; + static GObject *progress_bar; + static GObject *progress_label; + float percentage = 0.0; + GIOStatus status = G_IO_STATUS_NORMAL; + + progress_data = (ZenityProgressData *) data; + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + progress_label = gtk_builder_get_object (builder, "zenity_progress_text"); + + if ((condition & G_IO_IN) != 0) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + + while (channel->is_readable != TRUE) + ; + do { + do { + status = g_io_channel_read_line_string ( + channel, string, NULL, &error); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ( + "zenity_progress_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + if (!g_ascii_strncasecmp (string->str, "#", 1)) { + gchar *match; - if (percentage == 100) { - GObject *button; + /* We have a comment, so let's try to change the label */ + match = g_strstr_len (string->str, strlen (string->str), "#"); + match++; + gtk_label_set_text (GTK_LABEL (progress_label), + g_strcompress (g_strchomp (g_strchug (match)))); + + } else if (g_str_has_prefix (string->str, "pulsate")) { + gchar *colon, *command, *value; + + zenity_util_strip_newline (string->str); + + colon = strchr (string->str, ':'); + if (colon == NULL) { + continue; + } + + /* split off the command and value */ + command = + g_strstrip (g_strndup (string->str, colon - string->str)); + + value = colon + 1; + while (*value && g_ascii_isspace (*value)) + value++; + + if (!g_ascii_strcasecmp (value, "false")) { + zenity_progress_pulsate_stop (); + + gtk_progress_bar_set_fraction ( + GTK_PROGRESS_BAR (progress_bar), + progress_data->percentage / 100.0); + } else { + zenity_progress_pulsate_start (progress_bar); + } + + g_free (command); + } else { + + if (!g_ascii_isdigit (*(string->str))) + continue; + + /* Now try to convert the thing to a number */ + percentage = CLAMP (atoi (string->str), 0, 100); + + gtk_progress_bar_set_fraction ( + GTK_PROGRESS_BAR (progress_bar), percentage / 100.0); + + progress_data->percentage = percentage; + + if (progress_data->time_remaining == TRUE) + zenity_progress_update_time_remaining (progress_data); + + if (percentage == 100) { + GObject *button; + + button = gtk_builder_get_object ( + builder, "zenity_progress_ok_button"); + gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE); + gtk_widget_grab_focus (GTK_WIDGET (button)); + + if (progress_data->autoclose) { + zen_data->exit_code = + zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); + } + } + } - button = gtk_builder_get_object(builder, "zenity_progress_ok_button"); - gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE); - gtk_widget_grab_focus(GTK_WIDGET (button)); + } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == + G_IO_IN && + status != G_IO_STATUS_EOF); + g_string_free (string, TRUE); + } - if (progress_data->autoclose) { - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit(); - } - } - } + if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { + /* We assume that we are done, so stop the pulsating and de-sensitize + * the buttons */ + GtkWidget *button; - } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF); - g_string_free (string, TRUE); - } + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_progress_ok_button")); + gtk_widget_set_sensitive (button, TRUE); + gtk_widget_grab_focus (button); - if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { - /* We assume that we are done, so stop the pulsating and de-sensitize the buttons */ - GtkWidget *button; + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_progress_cancel_button")); - button = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_ok_button")); - gtk_widget_set_sensitive (button, TRUE); - gtk_widget_grab_focus (button); + gtk_widget_set_sensitive (button, FALSE); + + gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); - button = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_cancel_button")); + zenity_progress_pulsate_stop (); - gtk_widget_set_sensitive (button, FALSE); + g_object_unref (builder); - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0); + if (progress_data->autoclose) { + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); + } - zenity_progress_pulsate_stop (); - - g_object_unref (builder); - - if (progress_data->autoclose) { - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit(); - } - - g_io_channel_shutdown (channel, TRUE, NULL); - return FALSE; - } - return TRUE; + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; + } + return TRUE; } static void -zenity_progress_read_info (ZenityProgressData *progress_data) -{ - channel = g_io_channel_unix_new (0); - g_io_channel_set_encoding (channel, NULL, NULL); - g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_progress_handle_stdin, progress_data); - /* We need to check the pulsate state here, because, the g_io_add_watch - doesn't call the zenity_progress_handle_stdin function if there's no - input. This fix the Bug 567663 */ - if (progress_data->pulsate) { - GObject *progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); - zenity_progress_pulsate_start (progress_bar); - } +zenity_progress_read_info (ZenityProgressData *progress_data) { + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch (channel, + G_IO_IN | G_IO_HUP, + zenity_progress_handle_stdin, + progress_data); + /* We need to check the pulsate state here, because, the g_io_add_watch + doesn't call the zenity_progress_handle_stdin function if there's no + input. This fix the Bug 567663 */ + if (progress_data->pulsate) { + GObject *progress_bar = + gtk_builder_get_object (builder, "zenity_progress_bar"); + zenity_progress_pulsate_start (progress_bar); + } } static void -zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data) -{ - gtk_widget_set_size_request (widget, allocation->width/2, -1); +zenity_text_size_allocate ( + GtkWidget *widget, GtkAllocation *allocation, gpointer data) { + gtk_widget_set_size_request (widget, allocation->width / 2, -1); } void -zenity_progress (ZenityData *data, ZenityProgressData *progress_data) -{ - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - GObject *progress_bar; - GObject *cancel_button,*ok_button; - - zen_data = data; - builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - text = gtk_builder_get_object (builder, "zenity_progress_text"); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_progress_dialog")); - - progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_progress_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->width > -1) { - gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); - } - else { - g_signal_connect_after (G_OBJECT (text), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - g_signal_connect_after (G_OBJECT (progress_bar), "size-allocate", - G_CALLBACK (zenity_text_size_allocate), data); - } - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - if (progress_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); - - if (progress_data->percentage > -1) - gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), - progress_data->percentage/100.0); - - autokill = progress_data->autokill; - - auto_close = progress_data->autoclose; - ok_button = gtk_builder_get_object (builder, "zenity_progress_ok_button"); - - no_cancel = progress_data->no_cancel; - cancel_button = gtk_builder_get_object (builder, "zenity_progress_cancel_button"); - - if (no_cancel) { - gtk_widget_hide (GTK_WIDGET(cancel_button)); - gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE); - } - - if (no_cancel && auto_close) - gtk_widget_hide(GTK_WIDGET(ok_button)); - - zenity_util_show_dialog (dialog, data->attach); - zenity_progress_read_info (progress_data); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL); - } - - gtk_main (); +zenity_progress (ZenityData *data, ZenityProgressData *progress_data) { + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + GObject *progress_bar; + GObject *cancel_button, *ok_button; + + zen_data = data; + builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + text = gtk_builder_get_object (builder, "zenity_progress_text"); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_dialog")); + + progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar"); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_progress_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon (dialog, + data->window_icon, + ZENITY_IMAGE_FULLPATH ("zenity-progress.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->width > -1) { + gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1); + } else { + g_signal_connect_after (G_OBJECT (text), + "size-allocate", + G_CALLBACK (zenity_text_size_allocate), + data); + g_signal_connect_after (G_OBJECT (progress_bar), + "size-allocate", + G_CALLBACK (zenity_text_size_allocate), + data); + } + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_progress_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_progress_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + if (progress_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (progress_data->dialog_text)); + + if (progress_data->percentage > -1) + gtk_progress_bar_set_fraction ( + GTK_PROGRESS_BAR (progress_bar), progress_data->percentage / 100.0); + + autokill = progress_data->autokill; + + auto_close = progress_data->autoclose; + ok_button = gtk_builder_get_object (builder, "zenity_progress_ok_button"); + + no_cancel = progress_data->no_cancel; + cancel_button = + gtk_builder_get_object (builder, "zenity_progress_cancel_button"); + + if (no_cancel) { + gtk_widget_hide (GTK_WIDGET (cancel_button)); + gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE); + } + + if (no_cancel && auto_close) + gtk_widget_hide (GTK_WIDGET (ok_button)); + + zenity_util_show_dialog (dialog, data->attach); + zenity_progress_read_info (progress_data); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + NULL); + } + + gtk_main (); } static void -zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - /* We do not want to kill the parent process, in order to give the user - the ability to choose the action to be taken. See bug #310824. - But we want to give people the option to choose this behavior. - -- Monday 27, March 2006 - */ - if (autokill) { - kill (getppid (), 1); - } - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data); - break; - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_progress_dialog_response ( + GtkWidget *widget, int response, gpointer data) { + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + /* We do not want to kill the parent process, in order to give the + user + the ability to choose the action to be taken. See bug #310824. + But we want to give people the option to choose this behavior. + -- Monday 27, March 2006 + */ + if (autokill) { + kill (getppid (), 1); + } + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data); + break; + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } diff --git a/src/scale.c b/src/scale.c index 3eb5c174..7e6686b3 100644 --- a/src/scale.c +++ b/src/scale.c @@ -23,136 +23,151 @@ #include "config.h" -#include "zenity.h" #include "util.h" +#include "zenity.h" static GtkWidget *scale; static void zenity_scale_value_changed (GtkWidget *widget, gpointer data); -static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data); - -void -zenity_scale (ZenityData *data, ZenityScaleData *scale_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *button; - GObject *text; - - builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog")); - scale = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale")); - text = gtk_builder_get_object (builder, "zenity_scale_text"); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_scale_dialog_response), data); - - if (scale_data->min_value >= scale_data->max_value) { - g_printerr (_("Maximum value must be greater than minimum value.\n")); - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - if (scale_data->value < scale_data->min_value || - scale_data->value > scale_data->max_value) { - g_printerr (_("Value out of range.\n")); - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-scale.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - if (scale_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text)); - - gtk_range_set_range (GTK_RANGE (scale), scale_data->min_value, scale_data->max_value); - gtk_range_set_value (GTK_RANGE (scale), scale_data->value); - gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0); - - if (scale_data->print_partial) - g_signal_connect (G_OBJECT (scale), "value-changed", - G_CALLBACK (zenity_scale_value_changed), data); - - if (scale_data->hide_value) - gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); - - zenity_util_show_dialog (dialog, data->attach); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - g_object_unref (builder); - - gtk_main (); +static void zenity_scale_dialog_response ( + GtkWidget *widget, int response, gpointer data); + +void +zenity_scale (ZenityData *data, ZenityScaleData *scale_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *button; + GObject *text; + + builder = + zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog")); + scale = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale")); + text = gtk_builder_get_object (builder, "zenity_scale_text"); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_scale_dialog_response), + data); + + if (scale_data->min_value >= scale_data->max_value) { + g_printerr (_ ("Maximum value must be greater than minimum value.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + if (scale_data->value < scale_data->min_value || + scale_data->value > scale_data->max_value) { + g_printerr (_ ("Value out of range.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-scale.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_scale_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_scale_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + if (scale_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (scale_data->dialog_text)); + + gtk_range_set_range ( + GTK_RANGE (scale), scale_data->min_value, scale_data->max_value); + gtk_range_set_value (GTK_RANGE (scale), scale_data->value); + gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0); + + if (scale_data->print_partial) + g_signal_connect (G_OBJECT (scale), + "value-changed", + G_CALLBACK (zenity_scale_value_changed), + data); + + if (scale_data->hide_value) + gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE); + + zenity_util_show_dialog (dialog, data->attach); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + g_object_unref (builder); + + gtk_main (); } static void -zenity_scale_value_changed (GtkWidget *widget, gpointer data) -{ - g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (widget))); +zenity_scale_value_changed (GtkWidget *widget, gpointer data) { + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (widget))); } static void -zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - gtk_main_quit (); +zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale))); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + gtk_main_quit (); } diff --git a/src/text.c b/src/text.c index 1deecc64..ffe7b35e 100644 --- a/src/text.c +++ b/src/text.c @@ -23,375 +23,426 @@ #include "config.h" -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include #ifdef HAVE_WEBKITGTK #include #endif -static ZenityTextData *zen_text_data; +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); static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data); #ifdef HAVE_WEBKITGTK static void -zenity_configure_webkit (WebKitWebView *web_view) -{ - WebKitSettings *settings; - settings = webkit_web_view_get_settings(web_view); - g_object_set(G_OBJECT(settings), "auto-load-images", TRUE, NULL); - /* - Stick to the defaults - "cursive-font-family" gchar* : Read / Write / Construct - "default-encoding" gchar* : Read / Write / Construct - "default-font-family" gchar* : Read / Write / Construct - "default-font-size" gint : Read / Write / Construct - "default-monospace-font-size" gint : Read / Write / Construct - "editing-behavior" WebKitEditingBehavior : Read / Write / Construct - */ - g_object_set(G_OBJECT(settings), "enable-caret-browsing", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-html5-database", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-html5-local-storage", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-java", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-javascript", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-offline-web-application-cache", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-page-cache", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL); - g_object_set(G_OBJECT(settings), "enable-private-browsing", TRUE, NULL); - /* - Stick to defaults - "enforce-96-dpi" gboolean : Read / Write / Construct - "fantasy-font-family" gchar* : Read / Write / Construct - */ - /* - Stick to defaults - "minimum-font-size" gint : Read / Write / Construct - "minimum-logical-font-size" gint : Read / Write / Construct - "monospace-font-family" gchar* : Read / Write / Construct - "print-backgrounds" gboolean : Read / Write / Construct - "resizable-text-areas" gboolean : Read / Write / Construct - "sans-serif-font-family" gchar* : Read / Write / Construct - "serif-font-family" gchar* : Read / Write / Construct - "spell-checking-languages" gchar* : Read / Write / Construct - */ - g_object_set(G_OBJECT(settings), "enable-tabs-to-links", FALSE, NULL); - g_object_set(G_OBJECT(settings), "user-agent", - "Zenity with WebKit (KHTML, like Gecko) support", NULL); - /* - Stick to defaults - "user-stylesheet-uri" gchar* : Read / Write / Construct - "zoom-step" gfloat : Read / Write / Construct - */ +zenity_configure_webkit (WebKitWebView *web_view) { + WebKitSettings *settings; + settings = webkit_web_view_get_settings (web_view); + g_object_set (G_OBJECT (settings), "auto-load-images", TRUE, NULL); + /* + Stick to the defaults + "cursive-font-family" gchar* : Read / Write / + Construct + "default-encoding" gchar* : Read / Write / + Construct + "default-font-family" gchar* : Read / Write / + Construct + "default-font-size" gint : Read / Write / + Construct + "default-monospace-font-size" gint : Read / Write / + Construct + "editing-behavior" WebKitEditingBehavior : Read / Write / + Construct + */ + g_object_set (G_OBJECT (settings), "enable-caret-browsing", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-developer-extras", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-fullscreen", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-html5-database", FALSE, NULL); + g_object_set ( + G_OBJECT (settings), "enable-html5-local-storage", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-java", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-javascript", FALSE, NULL); + g_object_set (G_OBJECT (settings), + "enable-offline-web-application-cache", + FALSE, + NULL); + g_object_set (G_OBJECT (settings), "enable-page-cache", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-plugins", FALSE, NULL); + g_object_set (G_OBJECT (settings), "enable-private-browsing", TRUE, NULL); + /* + Stick to defaults + "enforce-96-dpi" gboolean : Read / Write / + Construct + "fantasy-font-family" gchar* : Read / Write / + Construct + */ + /* + Stick to defaults + "minimum-font-size" gint : Read / Write / + Construct + "minimum-logical-font-size" gint : Read / Write / + Construct + "monospace-font-family" gchar* : Read / Write / + Construct + "print-backgrounds" gboolean : Read / Write / + Construct + "resizable-text-areas" gboolean : Read / Write / + Construct + "sans-serif-font-family" gchar* : Read / Write / + Construct + "serif-font-family" gchar* : Read / Write / + Construct + "spell-checking-languages" gchar* : Read / Write / + Construct + */ + g_object_set (G_OBJECT (settings), "enable-tabs-to-links", FALSE, NULL); + g_object_set (G_OBJECT (settings), + "user-agent", + "Zenity with WebKit (KHTML, like Gecko) support", + NULL); + /* + Stick to defaults + "user-stylesheet-uri" gchar* : Read / Write / + Construct + "zoom-step" gfloat : Read / Write / + Construct + */ } static gboolean zenity_text_webview_decision_request (WebKitWebView *web_view, - WebKitPolicyDecision *decision, - WebKitPolicyDecisionType type) -{ - if (type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) { - WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision); - WebKitNavigationAction *navigation_action = webkit_navigation_policy_decision_get_navigation_action(navigation_decision); - webkit_policy_decision_ignore (decision); - if (!zen_text_data->no_interaction && - webkit_navigation_action_get_navigation_type (navigation_action) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) { - WebKitURIRequest *request = webkit_navigation_action_get_request(navigation_action); - g_app_info_launch_default_for_uri (webkit_uri_request_get_uri(request), NULL, NULL); - } - } - return TRUE; + WebKitPolicyDecision *decision, WebKitPolicyDecisionType type) { + if (type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) { + WebKitNavigationPolicyDecision *navigation_decision = + WEBKIT_NAVIGATION_POLICY_DECISION (decision); + WebKitNavigationAction *navigation_action = + webkit_navigation_policy_decision_get_navigation_action ( + navigation_decision); + webkit_policy_decision_ignore (decision); + if (!zen_text_data->no_interaction && + webkit_navigation_action_get_navigation_type (navigation_action) == + WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) { + WebKitURIRequest *request = + webkit_navigation_action_get_request (navigation_action); + g_app_info_launch_default_for_uri ( + webkit_uri_request_get_uri (request), NULL, NULL); + } + } + return TRUE; } static void -zenity_text_webview_load_changed (WebKitWebView *webkitwebview, - WebKitLoadEvent event, - gpointer user_data) -{ - if (event == WEBKIT_LOAD_FINISHED) { - g_signal_connect (G_OBJECT (webkitwebview), "decide-policy", - G_CALLBACK (zenity_text_webview_decision_request), NULL); - } +zenity_text_webview_load_changed ( + WebKitWebView *webkitwebview, WebKitLoadEvent event, gpointer user_data) { + if (event == WEBKIT_LOAD_FINISHED) { + g_signal_connect (G_OBJECT (webkitwebview), + "decide-policy", + G_CALLBACK (zenity_text_webview_decision_request), + NULL); + } } #endif static gboolean -zenity_text_handle_stdin (GIOChannel *channel, - GIOCondition condition, - gpointer data) -{ - static GtkTextBuffer *buffer; - static GtkTextView *text_view; - gchar buf[1024]; - - gsize len; - - text_view = GTK_TEXT_VIEW (data); - buffer = gtk_text_view_get_buffer (text_view); - - if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) { - GError *error = NULL; - gint status; - - while (channel->is_readable != TRUE) - ; - - do { - status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); - - while (gtk_events_pending ()) - gtk_main_iteration (); - - } while (status == G_IO_STATUS_AGAIN); - - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_warning ("zenity_text_handle_stdin () : %s", error->message); - g_error_free (error); - error = NULL; - } - return FALSE; - } - - if (len > 0) { - GtkTextIter end; - gchar *utftext; - gsize localelen; - gsize utflen; - - gtk_text_buffer_get_end_iter (buffer, &end); - - if (!g_utf8_validate (buf, len, NULL)) { - utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL); - gtk_text_buffer_insert (buffer, &end, utftext, utflen); - g_free (utftext); - } else { - gtk_text_buffer_insert (buffer, &end, buf, len); - } - if (zen_text_data->auto_scroll) { - GtkTextMark *mark = NULL; - mark = gtk_text_buffer_get_insert (buffer); - if (mark != NULL) - gtk_text_view_scroll_to_mark (text_view, mark, 0.0, FALSE, 0, 0); - } - } - } - - return TRUE; +zenity_text_handle_stdin ( + GIOChannel *channel, GIOCondition condition, gpointer data) { + static GtkTextBuffer *buffer; + static GtkTextView *text_view; + gchar buf[1024]; + + gsize len; + + text_view = GTK_TEXT_VIEW (data); + buffer = gtk_text_view_get_buffer (text_view); + + if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) { + GError *error = NULL; + gint status; + + while (channel->is_readable != TRUE) + ; + + do { + status = g_io_channel_read_chars (channel, buf, 1024, &len, &error); + + while (gtk_events_pending ()) + gtk_main_iteration (); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ("zenity_text_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + return FALSE; + } + + if (len > 0) { + GtkTextIter end; + gchar *utftext; + gsize localelen; + gsize utflen; + + gtk_text_buffer_get_end_iter (buffer, &end); + + if (!g_utf8_validate (buf, len, NULL)) { + utftext = g_convert_with_fallback (buf, + len, + "UTF-8", + "ISO-8859-1", + NULL, + &localelen, + &utflen, + NULL); + gtk_text_buffer_insert (buffer, &end, utftext, utflen); + g_free (utftext); + } else { + gtk_text_buffer_insert (buffer, &end, buf, len); + } + if (zen_text_data->auto_scroll) { + GtkTextMark *mark = NULL; + mark = gtk_text_buffer_get_insert (buffer); + if (mark != NULL) + gtk_text_view_scroll_to_mark ( + text_view, mark, 0.0, FALSE, 0, 0); + } + } + } + + return TRUE; } static void -zenity_text_fill_entries_from_stdin (GtkTextView *text_view) -{ - GIOChannel *channel; - - channel = g_io_channel_unix_new (0); - g_io_channel_set_encoding (channel, "UTF-8", NULL); - g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view); +zenity_text_fill_entries_from_stdin (GtkTextView *text_view) { + GIOChannel *channel; + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, "UTF-8", NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch ( + channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view); } void -zenity_text (ZenityData *data, ZenityTextData *text_data) -{ - GtkBuilder *builder; - GtkWidget *dialog; - GtkWidget *ok_button; - GtkWidget *checkbox; - GtkWidget *cancel_button; +zenity_text (ZenityData *data, ZenityTextData *text_data) { + GtkBuilder *builder; + GtkWidget *dialog; + GtkWidget *ok_button; + GtkWidget *checkbox; + GtkWidget *cancel_button; - GObject *text_view; - GtkTextBuffer *text_buffer; + GObject *text_view; + GtkTextBuffer *text_buffer; #ifdef HAVE_WEBKITGTK - GtkWidget *web_kit; - GtkWidget *scrolled_window; - GtkTextIter start_iter, end_iter; - gchar *content; + GtkWidget *web_kit; + GtkWidget *scrolled_window; + GtkTextIter start_iter, end_iter; + gchar *content; #endif - zen_text_data = text_data; - builder = zenity_util_load_ui_file ("zenity_text_dialog", - "textbuffer1", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog")); - - ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_close_button")); - cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_cancel_button")); - checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_checkbox")); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_text_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); - - text_buffer = gtk_text_buffer_new (NULL); - text_view = gtk_builder_get_object (builder, "zenity_text_view"); - 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->no_wrap) - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(text_view), GTK_WRAP_NONE); - - if (text_data->font) { - PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font); - gtk_widget_override_font (GTK_WIDGET(text_view), fontDesc); - } - - if (text_data->uri) - zenity_util_fill_file_buffer (text_buffer, text_data->uri); - else - zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW(text_view)); - - if (text_data->editable) - zen_text_data->buffer = text_buffer; - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); - } - - if (data->cancel_label) { - gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); - } - - if (text_data->checkbox) { - gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE); - gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE); - gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox); - - g_signal_connect (G_OBJECT (checkbox), "toggled", - G_CALLBACK (zenity_text_toggle_button), ok_button); - } - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - else - gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + zen_text_data = text_data; + builder = + zenity_util_load_ui_file ("zenity_text_dialog", "textbuffer1", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog")); + + ok_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_text_close_button")); + cancel_button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_text_cancel_button")); + checkbox = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_checkbox")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_text_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-text.png")); + + gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE); + + text_buffer = gtk_text_buffer_new (NULL); + text_view = gtk_builder_get_object (builder, "zenity_text_view"); + 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->no_wrap) + gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_NONE); + + if (text_data->font) { + PangoFontDescription *fontDesc = + pango_font_description_from_string (text_data->font); + gtk_widget_override_font (GTK_WIDGET (text_view), fontDesc); + } + + if (text_data->uri) + zenity_util_fill_file_buffer (text_buffer, text_data->uri); + else + zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW (text_view)); + + if (text_data->editable) + zen_text_data->buffer = text_buffer; + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label); + } + + if (data->cancel_label) { + gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label); + } + + if (text_data->checkbox) { + gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE); + gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE); + gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox); + + g_signal_connect (G_OBJECT (checkbox), + "toggled", + G_CALLBACK (zenity_text_toggle_button), + ok_button); + } + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + else + gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); #ifdef HAVE_WEBKITGTK - if(text_data->html) { - web_kit = webkit_web_view_new(); - scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_scrolled_window")); - - zenity_configure_webkit (WEBKIT_WEB_VIEW (web_kit)); - - if (text_data->url) - { - if (!(g_str_has_prefix (text_data->url, "http://") || g_str_has_prefix (text_data->url, "https://"))) - text_data->url = g_strdup_printf ("http://%s", text_data->url); - - - webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_kit), text_data->url); - } - else - { - gchar *cwd; - gchar *dirname; - gchar *dirname_uri; - dirname = text_data->uri ? g_path_get_dirname (text_data->uri) : g_strdup ("/"); - cwd = g_get_current_dir (); - dirname_uri = g_strconcat ("file://", cwd, "/", dirname, "/", NULL); - g_free (cwd); - g_free (dirname); - gtk_text_buffer_get_start_iter (text_buffer, &start_iter); - gtk_text_buffer_get_end_iter (text_buffer, &end_iter); - content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE); - webkit_web_view_load_html (WEBKIT_WEB_VIEW(web_kit), content, dirname_uri); - g_free (dirname_uri); - g_free (content); - } - - // We don't want user to click on links and navigate to another page. - // So, when the page finishes loading, we take handle of the requests. - - g_signal_connect (G_OBJECT (web_kit), "load-changed", - G_CALLBACK (zenity_text_webview_load_changed), NULL); - - gtk_widget_destroy (GTK_WIDGET (text_view)); - gtk_container_add (GTK_CONTAINER(scrolled_window), web_kit); - gtk_widget_show (GTK_WIDGET (web_kit)); - } + if (text_data->html) { + web_kit = webkit_web_view_new (); + scrolled_window = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_text_scrolled_window")); + + zenity_configure_webkit (WEBKIT_WEB_VIEW (web_kit)); + + if (text_data->url) { + if (!(g_str_has_prefix (text_data->url, "http://") || + g_str_has_prefix (text_data->url, "https://"))) + text_data->url = g_strdup_printf ("http://%s", text_data->url); + + webkit_web_view_load_uri ( + WEBKIT_WEB_VIEW (web_kit), text_data->url); + } else { + gchar *cwd; + gchar *dirname; + gchar *dirname_uri; + dirname = text_data->uri ? g_path_get_dirname (text_data->uri) + : g_strdup ("/"); + cwd = g_get_current_dir (); + dirname_uri = g_strconcat ("file://", cwd, "/", dirname, "/", NULL); + g_free (cwd); + g_free (dirname); + gtk_text_buffer_get_start_iter (text_buffer, &start_iter); + gtk_text_buffer_get_end_iter (text_buffer, &end_iter); + content = gtk_text_buffer_get_text ( + text_buffer, &start_iter, &end_iter, TRUE); + webkit_web_view_load_html ( + WEBKIT_WEB_VIEW (web_kit), content, dirname_uri); + g_free (dirname_uri); + g_free (content); + } + + // We don't want user to click on links and navigate to another page. + // So, when the page finishes loading, we take handle of the requests. + + g_signal_connect (G_OBJECT (web_kit), + "load-changed", + G_CALLBACK (zenity_text_webview_load_changed), + NULL); + + gtk_widget_destroy (GTK_WIDGET (text_view)); + gtk_container_add (GTK_CONTAINER (scrolled_window), web_kit); + gtk_widget_show (GTK_WIDGET (web_kit)); + } #endif - zenity_util_show_dialog (dialog, data->attach); + zenity_util_show_dialog (dialog, data->attach); - g_object_unref (builder); + g_object_unref (builder); - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } - gtk_main (); + gtk_main (); } static void -zenity_text_toggle_button (GtkToggleButton *button, gpointer data) -{ - GtkWidget *ok_button = (GtkWidget *)data; - gtk_widget_set_sensitive (GTK_WIDGET(ok_button), gtk_toggle_button_get_active(button)); +zenity_text_toggle_button (GtkToggleButton *button, gpointer data) { + GtkWidget *ok_button = (GtkWidget *) data; + gtk_widget_set_sensitive ( + GTK_WIDGET (ok_button), gtk_toggle_button_get_active (button)); } static void -zenity_text_dialog_output (ZenityData *zen_data) -{ - if (zen_text_data->editable) { - GtkTextIter start, end; - gchar *text; - gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); - text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); - g_print ("%s", text); - g_free (text); - } +zenity_text_dialog_output (ZenityData *zen_data) { + if (zen_text_data->editable) { + GtkTextIter start, end; + gchar *text; + gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end); + text = + gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0); + g_print ("%s", text); + g_free (text); + } } static void -zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_CLOSE: - zenity_text_dialog_output (zen_data); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - break; - - case ZENITY_TIMEOUT: - zenity_text_dialog_output (zen_data); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zenity_util_exit_code_with_data(ZENITY_ESC, zen_data); - break; - } - gtk_main_quit (); +zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_CLOSE: + zenity_text_dialog_output (zen_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + break; + + case ZENITY_TIMEOUT: + zenity_text_dialog_output (zen_data); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zenity_util_exit_code_with_data (ZENITY_ESC, zen_data); + break; + } + gtk_main_quit (); } diff --git a/src/tree.c b/src/tree.c index 058b6b61..d94ce7e8 100644 --- a/src/tree.c +++ b/src/tree.c @@ -25,10 +25,10 @@ #include "config.h" -#include -#include -#include "zenity.h" #include "util.h" +#include "zenity.h" +#include +#include #define MAX_ELEMENTS_BEFORE_SCROLLING 5 #define PRINT_HIDE_COLUMN_SEPARATOR "," @@ -43,733 +43,803 @@ static GIOChannel *channel; static int *zenity_tree_extract_column_indexes (char *indexes, gint n_columns); static gboolean zenity_tree_column_is_hidden (gint column_index); -static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data); -static void zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, - GtkTreeViewColumn *tree_col, gpointer data); +static void zenity_tree_dialog_response ( + GtkWidget *widget, int response, gpointer data); +static void zenity_tree_row_activated (GtkTreeView *tree_view, + GtkTreePath *tree_path, GtkTreeViewColumn *tree_col, gpointer data); static gboolean -zenity_tree_dialog_untoggle (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) -{ - GValue toggle_value = {0, }; +zenity_tree_dialog_untoggle ( + GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) { + GValue toggle_value = { + 0, + }; - gtk_tree_model_get_value (model, iter, 0, &toggle_value); + gtk_tree_model_get_value (model, iter, 0, &toggle_value); - if (g_value_get_boolean (&toggle_value)) - gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1); - return FALSE; + if (g_value_get_boolean (&toggle_value)) + gtk_list_store_set (GTK_LIST_STORE (model), iter, 0, FALSE, -1); + return FALSE; } static void -zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data) -{ - GtkTreeModel *model; - GtkTreeIter iter; - GtkTreePath *path; - gboolean value; +zenity_tree_toggled_callback ( + GtkCellRendererToggle *cell, gchar *path_string, gpointer data) { + GtkTreeModel *model; + GtkTreeIter iter; + GtkTreePath *path; + gboolean value; - model = GTK_TREE_MODEL (data); + model = GTK_TREE_MODEL (data); - /* Because this is a radio list, we should untoggle the previous toggle so that - * we only have one selection at any given time - */ + /* Because this is a radio list, we should untoggle the previous toggle so + * that + * we only have one selection at any given time + */ - if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) { - gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL); - } + if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (model), "radio")) == 1) { + gtk_tree_model_foreach (model, zenity_tree_dialog_untoggle, NULL); + } - path = gtk_tree_path_new_from_string (path_string); - gtk_tree_model_get_iter (model, &iter, path); - gtk_tree_model_get (model, &iter, 0, &value, -1); + path = gtk_tree_path_new_from_string (path_string); + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, 0, &value, -1); - value = !value; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1); + value = !value; + gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1); - gtk_tree_path_free (path); + gtk_tree_path_free (path); } static void -zenity_load_pixbuf (GtkTreeViewColumn *tree_column, - GtkCellRenderer *cell, - GtkTreeModel *tree_model, - GtkTreeIter *iter, - gpointer data) -{ - static GHashTable *pixbuf_cache = NULL; - GError *error = NULL; - GdkPixbuf *pixbuf; - gchar *str; +zenity_load_pixbuf (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, + GtkTreeModel *tree_model, GtkTreeIter *iter, gpointer data) { + static GHashTable *pixbuf_cache = NULL; + GError *error = NULL; + GdkPixbuf *pixbuf; + gchar *str; - gtk_tree_model_get (tree_model, iter, 0, &str, -1); + gtk_tree_model_get (tree_model, iter, 0, &str, -1); - if (!str) - return; + if (!str) + return; - if (!pixbuf_cache) { - pixbuf_cache = g_hash_table_new (g_str_hash, g_str_equal); - g_assert(pixbuf_cache); - } + if (!pixbuf_cache) { + pixbuf_cache = g_hash_table_new (g_str_hash, g_str_equal); + g_assert (pixbuf_cache); + } - pixbuf = g_hash_table_lookup (pixbuf_cache, str); + pixbuf = g_hash_table_lookup (pixbuf_cache, str); - if (!pixbuf) { - pixbuf = gdk_pixbuf_new_from_file (str, &error); - if (!pixbuf) - g_warning ("Failed to load '%s'", str); + if (!pixbuf) { + pixbuf = gdk_pixbuf_new_from_file (str, &error); + if (!pixbuf) + g_warning ("Failed to load '%s'", str); - g_hash_table_insert (pixbuf_cache, g_strdup (str), pixbuf); - } + g_hash_table_insert (pixbuf_cache, g_strdup (str), pixbuf); + } - if (pixbuf) - g_object_set (cell, "pixbuf", pixbuf, NULL); + if (pixbuf) + g_object_set (cell, "pixbuf", pixbuf, NULL); - g_free (str); + g_free (str); } static gboolean -zenity_tree_handle_stdin (GIOChannel *channel, - GIOCondition condition, - gpointer data) -{ - static GtkTreeView *tree_view; - GtkTreeModel *model; - static GtkTreeIter iter; - static gint column_count = 0; - static gint row_count = 0; - static gint n_columns; - static gboolean editable; - static gboolean toggles; - static gboolean first_time = TRUE; - GIOStatus status = G_IO_STATUS_NORMAL; - - tree_view = GTK_TREE_VIEW (data); - n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); - editable = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "editable")); - toggles = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "toggles")); - - model = gtk_tree_view_get_model (tree_view); - - if (first_time) { - first_time = FALSE; - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - } - - if ((condition & G_IO_IN) == G_IO_IN) { - GString *string; - GError *error = NULL; - - string = g_string_new (NULL); - - while ((g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) != G_IO_FLAG_IS_READABLE) - ; - do { - do { - if (g_io_channel_get_flags(channel) & G_IO_FLAG_IS_READABLE) - status = g_io_channel_read_line_string (channel, string, NULL, &error); - else - return FALSE; - - while (gtk_events_pending ()) - gtk_main_iteration (); - - // TODO: Find a better way to avoid 100% cpu utilization - g_usleep(10000); - - } while (status == G_IO_STATUS_AGAIN); - - if (status != G_IO_STATUS_NORMAL) { - if (error) { - g_warning ("zenity_tree_handle_stdin () : %s", error->message); - g_error_free (error); - error = NULL; - } - continue; - } - - if (column_count == n_columns) { - /* We're starting a new row */ - column_count = 0; - row_count++; - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - } - - if (toggles && column_count == 0) { - if (strcmp (g_ascii_strdown (zenity_util_strip_newline (string->str), -1), "true") == 0) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); - else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); - } - else { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column_count, zenity_util_strip_newline (string->str), -1); - } - - if (editable) { - gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); - } - - if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) { - GtkWidget *scrolled_window; - GtkRequisition rectangle; - - gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), &rectangle, NULL); - scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_tree_window")); - gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - } - - column_count++; - - } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF); - g_string_free (string, TRUE); - } - - if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { - g_io_channel_shutdown (channel, TRUE, NULL); - return FALSE; - } - return TRUE; +zenity_tree_handle_stdin ( + GIOChannel *channel, GIOCondition condition, gpointer data) { + static GtkTreeView *tree_view; + GtkTreeModel *model; + static GtkTreeIter iter; + static gint column_count = 0; + static gint row_count = 0; + static gint n_columns; + static gboolean editable; + static gboolean toggles; + static gboolean first_time = TRUE; + GIOStatus status = G_IO_STATUS_NORMAL; + + tree_view = GTK_TREE_VIEW (data); + n_columns = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); + editable = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "editable")); + toggles = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "toggles")); + + model = gtk_tree_view_get_model (tree_view); + + if (first_time) { + first_time = FALSE; + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } + + if ((condition & G_IO_IN) == G_IO_IN) { + GString *string; + GError *error = NULL; + + string = g_string_new (NULL); + + while ((g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE) != + G_IO_FLAG_IS_READABLE) + ; + do { + do { + if (g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE) + status = g_io_channel_read_line_string ( + channel, string, NULL, &error); + else + return FALSE; + + while (gtk_events_pending ()) + gtk_main_iteration (); + + // TODO: Find a better way to avoid 100% cpu utilization + g_usleep (10000); + + } while (status == G_IO_STATUS_AGAIN); + + if (status != G_IO_STATUS_NORMAL) { + if (error) { + g_warning ( + "zenity_tree_handle_stdin () : %s", error->message); + g_error_free (error); + error = NULL; + } + continue; + } + + if (column_count == n_columns) { + /* We're starting a new row */ + column_count = 0; + row_count++; + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + } + + if (toggles && column_count == 0) { + if (strcmp (g_ascii_strdown ( + zenity_util_strip_newline (string->str), -1), + "true") == 0) + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, column_count, TRUE, -1); + else + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, column_count, FALSE, -1); + } else { + gtk_list_store_set (GTK_LIST_STORE (model), + &iter, + column_count, + zenity_util_strip_newline (string->str), + -1); + } + + if (editable) { + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + } + + if (row_count == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_get_preferred_size ( + GTK_WIDGET (tree_view), &rectangle, NULL); + scrolled_window = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_tree_window")); + gtk_widget_set_size_request ( + scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + } + + column_count++; + + } while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == + G_IO_IN && + status != G_IO_STATUS_EOF); + g_string_free (string, TRUE); + } + + if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) { + g_io_channel_shutdown (channel, TRUE, NULL); + return FALSE; + } + return TRUE; } static void -zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, - gint n_columns, - gboolean toggles, - gboolean editable) -{ - g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); - g_object_set_data (G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles)); - g_object_set_data (G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable)); - - channel = g_io_channel_unix_new (0); - g_io_channel_set_encoding (channel, NULL, NULL); - g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); - g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_tree_handle_stdin, tree_view); +zenity_tree_fill_entries_from_stdin (GtkTreeView *tree_view, gint n_columns, + gboolean toggles, gboolean editable) { + g_object_set_data ( + G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); + g_object_set_data ( + G_OBJECT (tree_view), "toggles", GINT_TO_POINTER (toggles)); + g_object_set_data ( + G_OBJECT (tree_view), "editable", GINT_TO_POINTER (editable)); + + channel = g_io_channel_unix_new (0); + g_io_channel_set_encoding (channel, NULL, NULL); + g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL); + g_io_add_watch ( + channel, G_IO_IN | G_IO_HUP, zenity_tree_handle_stdin, tree_view); } static void -zenity_tree_fill_entries (GtkTreeView *tree_view, - const gchar **args, - gint n_columns, - gboolean toggles, - gboolean editable) -{ - GtkTreeModel *model; - GtkTreeIter iter; - gint i = 0; - - model = gtk_tree_view_get_model (tree_view); - - g_object_set_data (G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); - - while (args[i] != NULL) { - gint j; - - gtk_list_store_append (GTK_LIST_STORE (model), &iter); - - for (j = 0; j < n_columns; j++) { - - if (toggles && j == 0) { - if (strcmp (g_ascii_strdown ((gchar *) args[i+j], -1), "true") == 0) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1); - else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1); - } - else - gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1); - } - - if (editable) - gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); - - if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { - GtkWidget *scrolled_window; - GtkRequisition rectangle; - - gtk_widget_get_preferred_size (GTK_WIDGET (tree_view), &rectangle, NULL); - scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, - "zenity_tree_window")); - gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - } - - i += n_columns; - } +zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, + gint n_columns, gboolean toggles, gboolean editable) { + GtkTreeModel *model; + GtkTreeIter iter; + gint i = 0; + + model = gtk_tree_view_get_model (tree_view); + + g_object_set_data ( + G_OBJECT (tree_view), "n_columns", GINT_TO_POINTER (n_columns)); + + while (args[i] != NULL) { + gint j; + + gtk_list_store_append (GTK_LIST_STORE (model), &iter); + + for (j = 0; j < n_columns; j++) { + + if (toggles && j == 0) { + if (strcmp (g_ascii_strdown ((gchar *) args[i + j], -1), + "true") == 0) + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, j, TRUE, -1); + else + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, j, FALSE, -1); + } else + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, j, args[i + j], -1); + } + + if (editable) + gtk_list_store_set ( + GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1); + + if (i == MAX_ELEMENTS_BEFORE_SCROLLING) { + GtkWidget *scrolled_window; + GtkRequisition rectangle; + + gtk_widget_get_preferred_size ( + GTK_WIDGET (tree_view), &rectangle, NULL); + scrolled_window = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_tree_window")); + gtk_widget_set_size_request (scrolled_window, -1, rectangle.height); + gtk_scrolled_window_set_policy ( + GTK_SCROLLED_WINDOW (scrolled_window), + GTK_POLICY_AUTOMATIC, + GTK_POLICY_AUTOMATIC); + } + + i += n_columns; + } } static gboolean -zenity_mid_search_func (GtkTreeModel *model, gint column, - const gchar *key, GtkTreeIter *iter, - gpointer search_data) -{ - gchar *iter_string = NULL; - gtk_tree_model_get (model, iter, column, &iter_string, -1); - return ! (g_strrstr (g_utf8_strdown(iter_string, -1), - g_utf8_strdown(key, -1)) != NULL); - +zenity_mid_search_func (GtkTreeModel *model, gint column, const gchar *key, + GtkTreeIter *iter, gpointer search_data) { + gchar *iter_string = NULL; + gtk_tree_model_get (model, iter, column, &iter_string, -1); + return !(g_strrstr (g_utf8_strdown (iter_string, -1), + g_utf8_strdown (key, -1)) != NULL); } static void -zenity_cell_edited_callback (GtkCellRendererText *cell, - const gchar *path_string, - const gchar *new_text, - gpointer data) -{ - GtkTreeModel *model; - GtkTreePath *path; - GtkTreeIter iter; - gint column; - - model = GTK_TREE_MODEL (data); - path = gtk_tree_path_new_from_string (path_string); - - column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); - gtk_tree_model_get_iter (model, &iter, path); - - gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1); - - gtk_tree_path_free (path); -} +zenity_cell_edited_callback (GtkCellRendererText *cell, + const gchar *path_string, const gchar *new_text, gpointer data) { + GtkTreeModel *model; + GtkTreePath *path; + GtkTreeIter iter; + gint column; -void -zenity_tree (ZenityData *data, ZenityTreeData *tree_data) -{ - GtkWidget *dialog; - GtkWidget *button; - GObject *tree_view; - GObject *text; - GtkTreeViewColumn *column; - GtkListStore *model; - GType *column_types; - GSList *tmp; - gboolean first_column = FALSE; - gint i, column_index, n_columns; - - builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL); - - if (builder == NULL) { - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - separator = g_strcompress (tree_data->separator); - - n_columns = g_slist_length (tree_data->columns); - - if (tree_data->print_column) { - if (strcmp (g_ascii_strdown (tree_data->print_column, -1), "all") == 0) - print_all_columns = TRUE; - else - print_columns = zenity_tree_extract_column_indexes (tree_data->print_column, n_columns); - } - else { - print_columns = g_new (gint, 2); - print_columns[0] = (tree_data->radiobox || tree_data->checkbox ? 2 : 1); - print_columns[1] = 0; - } - - if (tree_data->hide_column) - hide_columns = zenity_tree_extract_column_indexes (tree_data->hide_column, n_columns); - - if (n_columns == 0) { - g_printerr (_("No column titles specified for List dialog.\n")); - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - if (tree_data->checkbox + tree_data->radiobox + tree_data->imagebox > 1) { - g_printerr (_("You should use only one List dialog type.\n")); - data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); - return; - } - - gtk_builder_connect_signals (builder, NULL); - - dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog")); - - g_signal_connect (G_OBJECT (dialog), "response", - G_CALLBACK (zenity_tree_dialog_response), data); - - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - - if (data->extra_label) { - gint i=0; - while(data->extra_label[i]!=NULL){ - gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i); - i++; - } - } - - if (data->ok_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_ok_button")); - gtk_button_set_label (GTK_BUTTON (button), data->ok_label); - } - - if (data->cancel_label) { - button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_cancel_button")); - gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); - } - - text = gtk_builder_get_object (builder, "zenity_tree_text"); - - if (tree_data->dialog_text) - gtk_label_set_markup (GTK_LABEL (text), g_strcompress (tree_data->dialog_text)); - - zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); - - if (data->width > -1 || data->height > -1) - gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height); - - tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); - - if (!(tree_data->radiobox || tree_data->checkbox)) - g_signal_connect (tree_view, "row-activated", - G_CALLBACK (zenity_tree_row_activated), data); - - /* Create an empty list store */ - model = g_object_new (GTK_TYPE_LIST_STORE, NULL); - - if (tree_data->editable) - column_types = g_new (GType, n_columns + 1); - else - column_types = g_new (GType, n_columns); - - for (i = 0; i < n_columns; i++) { - /* Have the limitation that the radioboxes and checkboxes are in the first column */ - if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) - column_types[i] = G_TYPE_BOOLEAN; - else - column_types[i] = G_TYPE_STRING; - } - - if (tree_data->editable) - column_types[n_columns] = G_TYPE_BOOLEAN; - - if (tree_data->editable) - gtk_list_store_set_column_types (model, n_columns + 1, column_types); - else - gtk_list_store_set_column_types (model, n_columns, column_types); - - gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); - - if (!(tree_data->radiobox || tree_data->checkbox)) { - if (tree_data->multi) - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_MULTIPLE); - else - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_SINGLE); - } - else - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), - GTK_SELECTION_NONE); - - column_index = 0; - - for (tmp = tree_data->columns; tmp; tmp = tmp->next) { - if (!first_column) { - if (tree_data->checkbox || tree_data->radiobox) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_toggle_new (); - - if (tree_data->radiobox) { - g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL); - g_object_set_data (G_OBJECT (model), "radio", GINT_TO_POINTER (1)); - } - - g_signal_connect (cell_renderer, "toggled", - G_CALLBACK (zenity_tree_toggled_callback), model); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "active", column_index, NULL); - } else if (tree_data->imagebox) { - GtkCellRenderer *cell_renderer = gtk_cell_renderer_pixbuf_new (); - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, NULL); - gtk_tree_view_column_set_cell_data_func (column, cell_renderer, - zenity_load_pixbuf, NULL, NULL); - } - else { - if (tree_data->editable) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_text_new (); - g_signal_connect (G_OBJECT (cell_renderer), "edited", - G_CALLBACK (zenity_cell_edited_callback), - gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index)); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "text", column_index, - "editable", n_columns, - NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, - NULL); - } - - gtk_tree_view_column_set_sort_column_id (column, column_index); - gtk_tree_view_column_set_resizable (column, TRUE); - } - if (zenity_tree_column_is_hidden (1)) - gtk_tree_view_column_set_visible (column, FALSE); - - first_column = TRUE; - } - else { - if (tree_data->editable) { - GtkCellRenderer *cell_renderer; - - cell_renderer = gtk_cell_renderer_text_new (); - g_signal_connect (G_OBJECT (cell_renderer), "edited", - G_CALLBACK (zenity_cell_edited_callback), - gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); - g_object_set_data (G_OBJECT (cell_renderer), "column", GINT_TO_POINTER (column_index)); - - column = gtk_tree_view_column_new_with_attributes (tmp->data, - cell_renderer, - "text", column_index, - "editable", n_columns, - NULL); - } - else { - column = gtk_tree_view_column_new_with_attributes (tmp->data, - gtk_cell_renderer_text_new (), - "text", column_index, NULL); - } - - gtk_tree_view_column_set_sort_column_id (column, column_index); - gtk_tree_view_column_set_resizable (column, TRUE); - - if (zenity_tree_column_is_hidden (column_index + 1)) - gtk_tree_view_column_set_visible (column, FALSE); - } - - gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); - column_index++; - } - - if (tree_data->hide_header) - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); - - if (tree_data->radiobox || tree_data->checkbox) { - if (tree_data->data && *tree_data->data) - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable); - else - zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, TRUE, tree_data->editable); - } - else { - if (tree_data->data && *tree_data->data) - zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable); - else - zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), n_columns, FALSE, tree_data->editable); - } - - zenity_util_show_dialog (dialog, data->attach); - - if (tree_data->mid_search) - gtk_tree_view_set_search_equal_func(GTK_TREE_VIEW(tree_view), (GtkTreeViewSearchEqualFunc) zenity_mid_search_func, model, NULL); - - if(data->timeout_delay > 0) { - g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog); - } - - gtk_main (); - - g_object_unref (builder); -} + model = GTK_TREE_MODEL (data); + path = gtk_tree_path_new_from_string (path_string); -static void -zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view) -{ - GValue value = {0, }; - gint n_columns, i; + column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column")); + gtk_tree_model_get_iter (model, &iter, path); - n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); + gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1); - if (print_all_columns) { - for (i = 0; i < n_columns; i++) { - gtk_tree_model_get_value (model, iter, i, &value); - - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); - } - return; - } + gtk_tree_path_free (path); +} - for (i = 0; print_columns[i] != 0; i++) { - gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); +void +zenity_tree (ZenityData *data, ZenityTreeData *tree_data) { + GtkWidget *dialog; + GtkWidget *button; + GObject *tree_view; + GObject *text; + GtkTreeViewColumn *column; + GtkListStore *model; + GType *column_types; + GSList *tmp; + gboolean first_column = FALSE; + gint i, column_index, n_columns; + + builder = zenity_util_load_ui_file ("zenity_tree_dialog", NULL); + + if (builder == NULL) { + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + separator = g_strcompress (tree_data->separator); + + n_columns = g_slist_length (tree_data->columns); + + if (tree_data->print_column) { + if (strcmp (g_ascii_strdown (tree_data->print_column, -1), "all") == 0) + print_all_columns = TRUE; + else + print_columns = zenity_tree_extract_column_indexes ( + tree_data->print_column, n_columns); + } else { + print_columns = g_new (gint, 2); + print_columns[0] = (tree_data->radiobox || tree_data->checkbox ? 2 : 1); + print_columns[1] = 0; + } + + if (tree_data->hide_column) + hide_columns = zenity_tree_extract_column_indexes ( + tree_data->hide_column, n_columns); + + if (n_columns == 0) { + g_printerr (_ ("No column titles specified for List dialog.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + if (tree_data->checkbox + tree_data->radiobox + tree_data->imagebox > 1) { + g_printerr (_ ("You should use only one List dialog type.\n")); + data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR); + return; + } + + gtk_builder_connect_signals (builder, NULL); + + dialog = + GTK_WIDGET (gtk_builder_get_object (builder, "zenity_tree_dialog")); + + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_tree_dialog_response), + data); + + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); + + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + if (data->extra_label) { + gint i = 0; + while (data->extra_label[i] != NULL) { + gtk_dialog_add_button ( + GTK_DIALOG (dialog), data->extra_label[i], i); + i++; + } + } + + if (data->ok_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_tree_ok_button")); + gtk_button_set_label (GTK_BUTTON (button), data->ok_label); + } + + if (data->cancel_label) { + button = GTK_WIDGET ( + gtk_builder_get_object (builder, "zenity_tree_cancel_button")); + gtk_button_set_label (GTK_BUTTON (button), data->cancel_label); + } + + text = gtk_builder_get_object (builder, "zenity_tree_text"); + + if (tree_data->dialog_text) + gtk_label_set_markup ( + GTK_LABEL (text), g_strcompress (tree_data->dialog_text)); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-list.png")); + + if (data->width > -1 || data->height > -1) + gtk_window_set_default_size ( + GTK_WINDOW (dialog), data->width, data->height); + + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); + + if (!(tree_data->radiobox || tree_data->checkbox)) + g_signal_connect (tree_view, + "row-activated", + G_CALLBACK (zenity_tree_row_activated), + data); + + /* Create an empty list store */ + model = g_object_new (GTK_TYPE_LIST_STORE, NULL); + + if (tree_data->editable) + column_types = g_new (GType, n_columns + 1); + else + column_types = g_new (GType, n_columns); + + for (i = 0; i < n_columns; i++) { + /* Have the limitation that the radioboxes and checkboxes are in the + * first column */ + if (i == 0 && (tree_data->checkbox || tree_data->radiobox)) + column_types[i] = G_TYPE_BOOLEAN; + else + column_types[i] = G_TYPE_STRING; + } + + if (tree_data->editable) + column_types[n_columns] = G_TYPE_BOOLEAN; + + if (tree_data->editable) + gtk_list_store_set_column_types (model, n_columns + 1, column_types); + else + gtk_list_store_set_column_types (model, n_columns, column_types); + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model)); + + if (!(tree_data->radiobox || tree_data->checkbox)) { + if (tree_data->multi) + gtk_tree_selection_set_mode ( + gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_MULTIPLE); + else + gtk_tree_selection_set_mode ( + gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_SINGLE); + } else + gtk_tree_selection_set_mode ( + gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)), + GTK_SELECTION_NONE); + + column_index = 0; + + for (tmp = tree_data->columns; tmp; tmp = tmp->next) { + if (!first_column) { + if (tree_data->checkbox || tree_data->radiobox) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_toggle_new (); + + if (tree_data->radiobox) { + g_object_set ( + G_OBJECT (cell_renderer), "radio", TRUE, NULL); + g_object_set_data ( + G_OBJECT (model), "radio", GINT_TO_POINTER (1)); + } + + g_signal_connect (cell_renderer, + "toggled", + G_CALLBACK (zenity_tree_toggled_callback), + model); + + column = gtk_tree_view_column_new_with_attributes ( + tmp->data, cell_renderer, "active", column_index, NULL); + } else if (tree_data->imagebox) { + GtkCellRenderer *cell_renderer = + gtk_cell_renderer_pixbuf_new (); + column = gtk_tree_view_column_new_with_attributes ( + tmp->data, cell_renderer, NULL); + gtk_tree_view_column_set_cell_data_func ( + column, cell_renderer, zenity_load_pixbuf, NULL, NULL); + } else { + if (tree_data->editable) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), + "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), + "column", + GINT_TO_POINTER (column_index)); + + column = + gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", + column_index, + "editable", + n_columns, + NULL); + } else { + column = + gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", + column_index, + NULL); + } + + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + } + if (zenity_tree_column_is_hidden (1)) + gtk_tree_view_column_set_visible (column, FALSE); + + first_column = TRUE; + } else { + if (tree_data->editable) { + GtkCellRenderer *cell_renderer; + + cell_renderer = gtk_cell_renderer_text_new (); + g_signal_connect (G_OBJECT (cell_renderer), + "edited", + G_CALLBACK (zenity_cell_edited_callback), + gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view))); + g_object_set_data (G_OBJECT (cell_renderer), + "column", + GINT_TO_POINTER (column_index)); + + column = gtk_tree_view_column_new_with_attributes (tmp->data, + cell_renderer, + "text", + column_index, + "editable", + n_columns, + NULL); + } else { + column = gtk_tree_view_column_new_with_attributes (tmp->data, + gtk_cell_renderer_text_new (), + "text", + column_index, + NULL); + } + + gtk_tree_view_column_set_sort_column_id (column, column_index); + gtk_tree_view_column_set_resizable (column, TRUE); + + if (zenity_tree_column_is_hidden (column_index + 1)) + gtk_tree_view_column_set_visible (column, FALSE); + } + + gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column); + column_index++; + } + + if (tree_data->hide_header) + gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE); + + if (tree_data->radiobox || tree_data->checkbox) { + if (tree_data->data && *tree_data->data) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), + tree_data->data, + n_columns, + TRUE, + tree_data->editable); + else + zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), + n_columns, + TRUE, + tree_data->editable); + } else { + if (tree_data->data && *tree_data->data) + zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), + tree_data->data, + n_columns, + FALSE, + tree_data->editable); + else + zenity_tree_fill_entries_from_stdin (GTK_TREE_VIEW (tree_view), + n_columns, + FALSE, + tree_data->editable); + } + + zenity_util_show_dialog (dialog, data->attach); + + if (tree_data->mid_search) + gtk_tree_view_set_search_equal_func (GTK_TREE_VIEW (tree_view), + (GtkTreeViewSearchEqualFunc) zenity_mid_search_func, + model, + NULL); + + if (data->timeout_delay > 0) { + g_timeout_add_seconds (data->timeout_delay, + (GSourceFunc) zenity_util_timeout_handle, + dialog); + } + + gtk_main (); + + g_object_unref (builder); +} - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); - } +static void +zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, + GtkTreeIter *iter, GtkTreeView *tree_view) { + GValue value = { + 0, + }; + gint n_columns, i; + + n_columns = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); + + if (print_all_columns) { + for (i = 0; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); + + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } + return; + } + + for (i = 0; print_columns[i] != 0; i++) { + gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); + + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } } static gboolean -zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, GtkTreeView *tree_view) -{ - GValue toggle_value = {0, }; - gint n_columns, i; - - n_columns = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); - - gtk_tree_model_get_value (model, iter, 0, &toggle_value); - - if (g_value_get_boolean (&toggle_value)) { - GValue value = {0, }; - - if (print_all_columns) { - for (i = 1; i < n_columns; i++) { - gtk_tree_model_get_value (model, iter, i, &value); - - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); - } - g_value_unset (&toggle_value); - return FALSE; - } - - for (i = 0; print_columns[i] != 0; i++) { - gtk_tree_model_get_value (model, iter, print_columns[i] - 1, &value); - - selected = g_slist_append (selected, g_value_dup_string (&value)); - g_value_unset (&value); - } - } - - g_value_unset (&toggle_value); - - return FALSE; +zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, + GtkTreeIter *iter, GtkTreeView *tree_view) { + GValue toggle_value = { + 0, + }; + gint n_columns, i; + + n_columns = + GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tree_view), "n_columns")); + + gtk_tree_model_get_value (model, iter, 0, &toggle_value); + + if (g_value_get_boolean (&toggle_value)) { + GValue value = { + 0, + }; + + if (print_all_columns) { + for (i = 1; i < n_columns; i++) { + gtk_tree_model_get_value (model, iter, i, &value); + + selected = + g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } + g_value_unset (&toggle_value); + return FALSE; + } + + for (i = 0; print_columns[i] != 0; i++) { + gtk_tree_model_get_value ( + model, iter, print_columns[i] - 1, &value); + + selected = g_slist_append (selected, g_value_dup_string (&value)); + g_value_unset (&value); + } + } + + g_value_unset (&toggle_value); + + return FALSE; } static void -zenity_tree_dialog_output (void) -{ -GObject *tree_view; - GtkTreeSelection *selection; - GtkTreeModel *model; - - tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); - - if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) - gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, - GTK_TREE_VIEW (tree_view)); - else { - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); - gtk_tree_selection_selected_foreach (selection, - (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, - GTK_TREE_VIEW (tree_view)); - } - - GSList *tmp; - - for (tmp = selected; tmp; tmp = tmp->next) { - if (tmp->next != NULL) { - g_print ("%s%s", (gchar *) tmp->data, separator); - } - else - g_print ("%s\n", (gchar *) tmp->data); - } - - g_free (print_columns); - g_free (hide_columns); - g_free (separator); - g_slist_foreach (selected, (GFunc) g_free, NULL); - selected = NULL; +zenity_tree_dialog_output (void) { + GObject *tree_view; + GtkTreeSelection *selection; + GtkTreeModel *model; + + tree_view = gtk_builder_get_object (builder, "zenity_tree_view"); + model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)); + + if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) + gtk_tree_model_foreach (model, + (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, + GTK_TREE_VIEW (tree_view)); + else { + selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)); + gtk_tree_selection_selected_foreach (selection, + (GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected, + GTK_TREE_VIEW (tree_view)); + } + + GSList *tmp; + + for (tmp = selected; tmp; tmp = tmp->next) { + if (tmp->next != NULL) { + g_print ("%s%s", (gchar *) tmp->data, separator); + } else + g_print ("%s\n", (gchar *) tmp->data); + } + + g_free (print_columns); + g_free (hide_columns); + g_free (separator); + g_slist_foreach (selected, (GFunc) g_free, NULL); + selected = NULL; } static void -zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) -{ - ZenityData *zen_data = data; - - switch (response) { - case GTK_RESPONSE_OK: - zenity_tree_dialog_output (); - zenity_util_exit_code_with_data(ZENITY_OK, zen_data); - break; - - case GTK_RESPONSE_CANCEL: - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); - break; - - case ZENITY_TIMEOUT: - zenity_tree_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); - break; - - default: - if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label)) - printf("%s\n",zen_data->extra_label[response]); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); - break; - } - if (channel != NULL && g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE) - g_io_channel_shutdown (channel, TRUE, NULL); - - gtk_main_quit (); +zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data) { + ZenityData *zen_data = data; + + switch (response) { + case GTK_RESPONSE_OK: + zenity_tree_dialog_output (); + zenity_util_exit_code_with_data (ZENITY_OK, zen_data); + break; + + case GTK_RESPONSE_CANCEL: + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL); + break; + + case ZENITY_TIMEOUT: + zenity_tree_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); + break; + + default: + if (zen_data->extra_label && + response < g_strv_length (zen_data->extra_label)) + printf ("%s\n", zen_data->extra_label[response]); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC); + break; + } + if (channel != NULL && + g_io_channel_get_flags (channel) & G_IO_FLAG_IS_READABLE) + g_io_channel_shutdown (channel, TRUE, NULL); + + gtk_main_quit (); } static void -zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, - GtkTreeViewColumn *tree_col, gpointer data) -{ - ZenityData *zen_data = data; - - zenity_tree_dialog_output (); - zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); - gtk_main_quit (); +zenity_tree_row_activated (GtkTreeView *tree_view, GtkTreePath *tree_path, + GtkTreeViewColumn *tree_col, gpointer data) { + ZenityData *zen_data = data; + + zenity_tree_dialog_output (); + zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK); + gtk_main_quit (); } static gboolean -zenity_tree_column_is_hidden (gint column_index) -{ - gint i; +zenity_tree_column_is_hidden (gint column_index) { + gint i; - if (hide_columns != NULL) - for (i = 0; hide_columns[i] != 0; i++) - if (hide_columns[i] == column_index) - return TRUE; + if (hide_columns != NULL) + for (i = 0; hide_columns[i] != 0; i++) + if (hide_columns[i] == column_index) + return TRUE; - return FALSE; + return FALSE; } static gint * -zenity_tree_extract_column_indexes (char *indexes, int n_columns) -{ - char **tmp; - gint *result; - gint i, j, index; +zenity_tree_extract_column_indexes (char *indexes, int n_columns) { + char **tmp; + gint *result; + gint i, j, index; - tmp = g_strsplit (indexes, - PRINT_HIDE_COLUMN_SEPARATOR, 0); + tmp = g_strsplit (indexes, PRINT_HIDE_COLUMN_SEPARATOR, 0); - result = g_new (gint, 1); + result = g_new (gint, 1); - for (j = i = 0; tmp[i] != NULL; i++) { - index = atoi (tmp[i]); + for (j = i = 0; tmp[i] != NULL; i++) { + index = atoi (tmp[i]); - if (index > 0 && index <= n_columns) { - result[j] = index; - j++; - result = g_renew (gint, result, j + 1); - } - } - result[j] = 0; + if (index > 0 && index <= n_columns) { + result[j] = index; + j++; + result = g_renew (gint, result, j + 1); + } + } + result[j] = 0; - g_strfreev (tmp); + g_strfreev (tmp); - return result; + return result; } diff --git a/src/util.c b/src/util.c index ddb0146f..0c101866 100644 --- a/src/util.c +++ b/src/util.c @@ -29,340 +29,330 @@ #include "config.h" -#include -#include -#include -#include -#include -#include #include "config.h" #include "util.h" #include "zenity.h" +#include +#include +#include +#include +#include +#include #ifdef GDK_WINDOWING_X11 #include #endif -#define ZENITY_OK_DEFAULT 0 -#define ZENITY_CANCEL_DEFAULT 1 -#define ZENITY_ESC_DEFAULT 1 -#define ZENITY_ERROR_DEFAULT -1 -#define ZENITY_EXTRA_DEFAULT 127 - -GtkBuilder* -zenity_util_load_ui_file (const gchar *root_widget, ...) -{ - va_list args; - gchar *arg = NULL; - GPtrArray *ptrarray; - GtkBuilder *builder = gtk_builder_new (); - GError *error = NULL; - gchar **objects; - guint result = 0; - - gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); - - /* We have at least the root_widget and a NULL */ - ptrarray = g_ptr_array_sized_new (2); - - g_ptr_array_add (ptrarray, g_strdup (root_widget)); - - va_start (args, root_widget); - - arg = va_arg (args, gchar*); - - while (arg) { - g_ptr_array_add (ptrarray, g_strdup (arg)); - arg = va_arg (args, gchar*); - } - va_end (args); - - /* Enforce terminating NULL */ - g_ptr_array_add (ptrarray, NULL); - objects = (gchar**) g_ptr_array_free (ptrarray, FALSE); - - if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { - /* Try current dir, for debugging */ - result = gtk_builder_add_objects_from_file (builder, - ZENITY_UI_FILE_RELATIVEPATH, - objects, NULL); - } - - if (result == 0) - result = gtk_builder_add_objects_from_file (builder, - ZENITY_UI_FILE_FULLPATH, - objects, &error); - - g_strfreev (objects); - - if (result == 0) { - g_warning ("Could not load ui file %s: %s", ZENITY_UI_FILE_FULLPATH, - error->message); - g_error_free (error); - g_object_unref (builder); - return NULL; - } - - return builder; +#define ZENITY_OK_DEFAULT 0 +#define ZENITY_CANCEL_DEFAULT 1 +#define ZENITY_ESC_DEFAULT 1 +#define ZENITY_ERROR_DEFAULT -1 +#define ZENITY_EXTRA_DEFAULT 127 + +GtkBuilder * +zenity_util_load_ui_file (const gchar *root_widget, ...) { + va_list args; + gchar *arg = NULL; + GPtrArray *ptrarray; + GtkBuilder *builder = gtk_builder_new (); + GError *error = NULL; + gchar **objects; + guint result = 0; + + gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE); + + /* We have at least the root_widget and a NULL */ + ptrarray = g_ptr_array_sized_new (2); + + g_ptr_array_add (ptrarray, g_strdup (root_widget)); + + va_start (args, root_widget); + + arg = va_arg (args, gchar *); + + while (arg) { + g_ptr_array_add (ptrarray, g_strdup (arg)); + arg = va_arg (args, gchar *); + } + va_end (args); + + /* Enforce terminating NULL */ + g_ptr_array_add (ptrarray, NULL); + objects = (gchar **) g_ptr_array_free (ptrarray, FALSE); + + if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) { + /* Try current dir, for debugging */ + result = gtk_builder_add_objects_from_file ( + builder, ZENITY_UI_FILE_RELATIVEPATH, objects, NULL); + } + + if (result == 0) + result = gtk_builder_add_objects_from_file ( + builder, ZENITY_UI_FILE_FULLPATH, objects, &error); + + g_strfreev (objects); + + if (result == 0) { + g_warning ("Could not load ui file %s: %s", + ZENITY_UI_FILE_FULLPATH, + error->message); + g_error_free (error); + g_object_unref (builder); + return NULL; + } + + return builder; } -gchar* -zenity_util_strip_newline (gchar *string) -{ - gsize len; - - g_return_val_if_fail (string != NULL, NULL); - - len = strlen (string); - while (len--) - { - if (string[len] == '\n') - string[len] = '\0'; - else - break; - } - - return string; +gchar * +zenity_util_strip_newline (gchar *string) { + gsize len; + + g_return_val_if_fail (string != NULL, NULL); + + len = strlen (string); + while (len--) { + if (string[len] == '\n') + string[len] = '\0'; + else + break; + } + + return string; } gboolean -zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) -{ - GtkTextIter iter, end; - FILE *f; - gchar buf[2048]; - gint remaining = 0; +zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) { + GtkTextIter iter, end; + FILE *f; + gchar buf[2048]; + gint remaining = 0; - if (filename == NULL) - return FALSE; + if (filename == NULL) + return FALSE; - f = fopen (filename, "r"); + f = fopen (filename, "r"); - if (f == NULL) { - g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno)); - return FALSE; - } + if (f == NULL) { + g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno)); + return FALSE; + } - gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); + gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0); - while (!feof (f)) { - gint count; - const char *leftover; - int to_read = 2047 - remaining; + while (!feof (f)) { + gint count; + const char *leftover; + int to_read = 2047 - remaining; - count = fread (buf + remaining, 1, to_read, f); - buf[count + remaining] = '\0'; + count = fread (buf + remaining, 1, to_read, f); + buf[count + remaining] = '\0'; - g_utf8_validate (buf, count + remaining, &leftover); + g_utf8_validate (buf, count + remaining, &leftover); - g_assert (g_utf8_validate (buf, leftover - buf, NULL)); - gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); + g_assert (g_utf8_validate (buf, leftover - buf, NULL)); + gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf); - remaining = (buf + remaining + count) - leftover; - g_memmove (buf, leftover, remaining); + remaining = (buf + remaining + count) - leftover; + g_memmove (buf, leftover, remaining); - if (remaining > 6 || count < to_read) - break; - } + if (remaining > 6 || count < to_read) + break; + } - if (remaining) { - g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename); - return FALSE; - } + if (remaining) { + g_warning ( + "Invalid UTF-8 data encountered reading file '%s'", filename); + return FALSE; + } - /* We had a newline in the buffer to begin with. (The buffer always contains - * a newline, so we delete to the end of the buffer to clean up. - */ - - gtk_text_buffer_get_end_iter (buffer, &end); - gtk_text_buffer_delete (buffer, &iter, &end); + /* We had a newline in the buffer to begin with. (The buffer always contains + * a newline, so we delete to the end of the buffer to clean up. + */ - gtk_text_buffer_set_modified (buffer, FALSE); + gtk_text_buffer_get_end_iter (buffer, &end); + gtk_text_buffer_delete (buffer, &iter, &end); - return TRUE; + gtk_text_buffer_set_modified (buffer, FALSE); + + return TRUE; } const gchar * -zenity_util_icon_name_from_filename (const gchar *filename) -{ - if (!filename || !filename[0]) - return "dialog-warning"; /* default */ - - if (!g_ascii_strcasecmp (filename, "warning")) - return "dialog-warning"; - if (!g_ascii_strcasecmp (filename, "info")) - return "dialog-information"; - if (!g_ascii_strcasecmp (filename, "question")) - return "dialog-question"; - if (!g_ascii_strcasecmp (filename, "error")) - return "dialog-error"; - return NULL; +zenity_util_icon_name_from_filename (const gchar *filename) { + if (!filename || !filename[0]) + return "dialog-warning"; /* default */ + + if (!g_ascii_strcasecmp (filename, "warning")) + return "dialog-warning"; + if (!g_ascii_strcasecmp (filename, "info")) + return "dialog-information"; + if (!g_ascii_strcasecmp (filename, "question")) + return "dialog-question"; + if (!g_ascii_strcasecmp (filename, "error")) + return "dialog-error"; + return NULL; } void -zenity_util_set_window_icon_from_file (GtkWidget *widget, const gchar *filename) -{ - GdkPixbuf *pixbuf; - const gchar *icon_name; - - icon_name = zenity_util_icon_name_from_filename (filename); - if (icon_name) { - gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name); - } else { - pixbuf = gdk_pixbuf_new_from_file (filename, NULL); - gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); - g_object_unref (pixbuf); - } +zenity_util_set_window_icon_from_file ( + GtkWidget *widget, const gchar *filename) { + GdkPixbuf *pixbuf; + const gchar *icon_name; + + icon_name = zenity_util_icon_name_from_filename (filename); + if (icon_name) { + gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name); + } else { + pixbuf = gdk_pixbuf_new_from_file (filename, NULL); + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); + } } void -zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file) -{ - GdkPixbuf *pixbuf; - - if (filename != NULL) { - zenity_util_set_window_icon_from_file (widget, filename); - } else { - pixbuf = gdk_pixbuf_new_from_file (default_file, NULL); - if (pixbuf != NULL) { - gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); - g_object_unref (pixbuf); - } - } +zenity_util_set_window_icon ( + GtkWidget *widget, const gchar *filename, const gchar *default_file) { + GdkPixbuf *pixbuf; + + if (filename != NULL) { + zenity_util_set_window_icon_from_file (widget, filename); + } else { + pixbuf = gdk_pixbuf_new_from_file (default_file, NULL); + if (pixbuf != NULL) { + gtk_window_set_icon (GTK_WINDOW (widget), pixbuf); + g_object_unref (pixbuf); + } + } } void -zenity_util_set_window_icon_from_icon_name (GtkWidget *widget, const gchar *filename, const gchar *default_icon_name) -{ - if (filename != NULL) - zenity_util_set_window_icon_from_file (widget, filename); - else - gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name); +zenity_util_set_window_icon_from_icon_name ( + GtkWidget *widget, const gchar *filename, const gchar *default_icon_name) { + if (filename != NULL) + zenity_util_set_window_icon_from_file (widget, filename); + else + gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name); } void -zenity_util_show_help (GError **error) -{ - gchar *tmp; - tmp = g_find_program_in_path ("yelp"); - - if (tmp) { - g_free (tmp); - g_spawn_command_line_async ("yelp help:zenity", error); - } +zenity_util_show_help (GError **error) { + gchar *tmp; + tmp = g_find_program_in_path ("yelp"); + + if (tmp) { + g_free (tmp); + g_spawn_command_line_async ("yelp help:zenity", error); + } } -gint -zenity_util_return_exit_code ( ZenityExitCode value ) -{ - - const gchar *env_var = NULL; - gint retval; - - switch (value) { - - case ZENITY_OK: - env_var = g_getenv("ZENITY_OK"); - if (! env_var) - env_var = g_getenv("DIALOG_OK"); - if (! env_var) - retval = ZENITY_OK_DEFAULT; - break; - - case ZENITY_CANCEL: - env_var = g_getenv("ZENITY_CANCEL"); - if (! env_var) - env_var = g_getenv("DIALOG_CANCEL"); - if (! env_var) - retval = ZENITY_CANCEL_DEFAULT; - break; - - case ZENITY_ESC: - env_var = g_getenv("ZENITY_ESC"); - if (! env_var) - env_var = g_getenv("DIALOG_ESC"); - if (! env_var) - retval = ZENITY_ESC_DEFAULT; - break; - - case ZENITY_EXTRA: - env_var = g_getenv("ZENITY_EXTRA"); - if (! env_var) - env_var = g_getenv("DIALOG_EXTRA"); - if (! env_var) - retval = ZENITY_EXTRA_DEFAULT; - break; - - case ZENITY_ERROR: - env_var = g_getenv("ZENITY_ERROR"); - if (! env_var) - env_var = g_getenv("DIALOG_ERROR"); - if (! env_var) - retval = ZENITY_ERROR_DEFAULT; - break; - - case ZENITY_TIMEOUT: - env_var = g_getenv("ZENITY_TIMEOUT"); - if (! env_var) - env_var = g_getenv("DIALOG_TIMEOUT"); - if (! env_var) - retval = ZENITY_TIMEOUT; - break; - - default: - retval = 1; - } - - if (env_var) - retval = atoi (env_var); - return retval; +gint +zenity_util_return_exit_code (ZenityExitCode value) { + + const gchar *env_var = NULL; + gint retval; + + switch (value) { + + case ZENITY_OK: + env_var = g_getenv ("ZENITY_OK"); + if (!env_var) + env_var = g_getenv ("DIALOG_OK"); + if (!env_var) + retval = ZENITY_OK_DEFAULT; + break; + + case ZENITY_CANCEL: + env_var = g_getenv ("ZENITY_CANCEL"); + if (!env_var) + env_var = g_getenv ("DIALOG_CANCEL"); + if (!env_var) + retval = ZENITY_CANCEL_DEFAULT; + break; + + case ZENITY_ESC: + env_var = g_getenv ("ZENITY_ESC"); + if (!env_var) + env_var = g_getenv ("DIALOG_ESC"); + if (!env_var) + retval = ZENITY_ESC_DEFAULT; + break; + + case ZENITY_EXTRA: + env_var = g_getenv ("ZENITY_EXTRA"); + if (!env_var) + env_var = g_getenv ("DIALOG_EXTRA"); + if (!env_var) + retval = ZENITY_EXTRA_DEFAULT; + break; + + case ZENITY_ERROR: + env_var = g_getenv ("ZENITY_ERROR"); + if (!env_var) + env_var = g_getenv ("DIALOG_ERROR"); + if (!env_var) + retval = ZENITY_ERROR_DEFAULT; + break; + + case ZENITY_TIMEOUT: + env_var = g_getenv ("ZENITY_TIMEOUT"); + if (!env_var) + env_var = g_getenv ("DIALOG_TIMEOUT"); + if (!env_var) + retval = ZENITY_TIMEOUT; + break; + + default: + retval = 1; + } + + if (env_var) + retval = atoi (env_var); + return retval; } void -zenity_util_exit_code_with_data(ZenityExitCode value, ZenityData *zen_data) -{ - zen_data->exit_code = zenity_util_return_exit_code (value); +zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *zen_data) { + zen_data->exit_code = zenity_util_return_exit_code (value); } #ifdef GDK_WINDOWING_X11 static Window -transient_get_xterm (void) -{ - const char *wid_str = g_getenv ("WINDOWID"); - if (wid_str) { - char *wid_str_end; - int ret; - Window wid = strtoul (wid_str, &wid_str_end, 10); - if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) { - XWindowAttributes attrs; - gdk_error_trap_push (); - ret = XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wid, &attrs); - gdk_flush(); - if (gdk_error_trap_pop () != 0 || ret == 0) { - return None; - } - return wid; - } - } - return None; +transient_get_xterm (void) { + const char *wid_str = g_getenv ("WINDOWID"); + if (wid_str) { + char *wid_str_end; + int ret; + Window wid = strtoul (wid_str, &wid_str_end, 10); + if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) { + XWindowAttributes attrs; + gdk_error_trap_push (); + ret = XGetWindowAttributes ( + GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wid, &attrs); + gdk_flush (); + if (gdk_error_trap_pop () != 0 || ret == 0) { + return None; + } + return wid; + } + } + return None; } static void -transient_x_free (void *ptr) -{ - if (ptr) - XFree (ptr); +transient_x_free (void *ptr) { + if (ptr) + XFree (ptr); } static gboolean -transient_is_toplevel (Window wid) -{ - XTextProperty prop; - Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - if (!XGetWMName (dpy, wid, &prop)) - return FALSE; - transient_x_free (prop.value); - return !!prop.value; +transient_is_toplevel (Window wid) { + XTextProperty prop; + Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + if (!XGetWMName (dpy, wid, &prop)) + return FALSE; + transient_x_free (prop.value); + return !!prop.value; } /* @@ -372,62 +362,56 @@ transient_is_toplevel (Window wid) */ static Window -transient_get_xterm_toplevel (void) -{ - Window xterm = transient_get_xterm (); - Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); - while (xterm != None && !transient_is_toplevel (xterm)) - { - Window root, parent, *children; - unsigned nchildren; - XQueryTree (dpy, xterm, - &root, &parent, - &children, &nchildren); - transient_x_free (children); - if (parent == root) - xterm = None; - else - xterm = parent; - } - return xterm; +transient_get_xterm_toplevel (void) { + Window xterm = transient_get_xterm (); + Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); + while (xterm != None && !transient_is_toplevel (xterm)) { + Window root, parent, *children; + unsigned nchildren; + XQueryTree (dpy, xterm, &root, &parent, &children, &nchildren); + transient_x_free (children); + if (parent == root) + xterm = None; + else + xterm = parent; + } + return xterm; } static void -zenity_util_make_transient (GdkWindow *window, Window parent) -{ - Window parent_window = parent; - if (parent_window == 0) - parent_window = transient_get_xterm_toplevel (); - if (parent_window != None) { - XSetTransientForHint (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_WINDOW_XID(window), parent_window); - } +zenity_util_make_transient (GdkWindow *window, Window parent) { + Window parent_window = parent; + if (parent_window == 0) + parent_window = transient_get_xterm_toplevel (); + if (parent_window != None) { + XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), + GDK_WINDOW_XID (window), + parent_window); + } } #endif /* GDK_WINDOWING_X11 */ void -zenity_util_show_dialog (GtkWidget *dialog, guintptr parent) -{ - gtk_widget_realize (dialog); +zenity_util_show_dialog (GtkWidget *dialog, guintptr parent) { + gtk_widget_realize (dialog); #ifdef GDK_WINDOWING_X11 - if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) - { - g_assert (gtk_widget_get_window(dialog)); - zenity_util_make_transient (gtk_widget_get_window(dialog), parent); - } + if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) { + g_assert (gtk_widget_get_window (dialog)); + zenity_util_make_transient (gtk_widget_get_window (dialog), parent); + } #endif - gtk_widget_show (dialog); + gtk_widget_show (dialog); } -gboolean -zenity_util_timeout_handle (gpointer data) -{ - GtkDialog *dialog = GTK_DIALOG(data); - if(dialog != NULL) - gtk_dialog_response(dialog, ZENITY_TIMEOUT); - else { - gtk_main_quit(); - exit(ZENITY_TIMEOUT); - } - return FALSE; +gboolean +zenity_util_timeout_handle (gpointer data) { + GtkDialog *dialog = GTK_DIALOG (data); + if (dialog != NULL) + gtk_dialog_response (dialog, ZENITY_TIMEOUT); + else { + gtk_main_quit (); + exit (ZENITY_TIMEOUT); + } + return FALSE; } diff --git a/src/util.h b/src/util.h index c847cd4c..3e5391b2 100644 --- a/src/util.h +++ b/src/util.h @@ -1,37 +1,34 @@ -#ifndef UTIL_H +#ifndef UTIL_H #define UTIL_H -#include #include "zenity.h" - +#include G_BEGIN_DECLS -#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" -#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui" - -#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename) - -GtkBuilder* zenity_util_load_ui_file (const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED; -gchar * zenity_util_strip_newline (gchar *string); -gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer, - const gchar *filename); -const gchar * zenity_util_icon_name_from_filename (const gchar *filename); -void zenity_util_set_window_icon (GtkWidget *widget, - const gchar *filename, - const gchar *default_file); -void zenity_util_set_window_icon_from_icon_name(GtkWidget *widget, - const gchar *filename, - const gchar *default_icon_name); -void zenity_util_set_window_icon_from_file (GtkWidget *widget, - const gchar *filename); -void zenity_util_show_help (GError **error); -gint zenity_util_return_exit_code (ZenityExitCode value); -void zenity_util_exit_code_with_data (ZenityExitCode value, - ZenityData *data); -void zenity_util_show_dialog (GtkWidget *widget, guintptr parent); - -gboolean zenity_util_timeout_handle (gpointer data); +#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui" +#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui" + +#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename) + +GtkBuilder *zenity_util_load_ui_file ( + const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED; +gchar *zenity_util_strip_newline (gchar *string); +gboolean zenity_util_fill_file_buffer ( + GtkTextBuffer *buffer, const gchar *filename); +const gchar *zenity_util_icon_name_from_filename (const gchar *filename); +void zenity_util_set_window_icon ( + GtkWidget *widget, const gchar *filename, const gchar *default_file); +void zenity_util_set_window_icon_from_icon_name ( + GtkWidget *widget, const gchar *filename, const gchar *default_icon_name); +void zenity_util_set_window_icon_from_file ( + GtkWidget *widget, const gchar *filename); +void zenity_util_show_help (GError **error); +gint zenity_util_return_exit_code (ZenityExitCode value); +void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data); +void zenity_util_show_dialog (GtkWidget *widget, guintptr parent); + +gboolean zenity_util_timeout_handle (gpointer data); G_END_DECLS diff --git a/src/zenity.h b/src/zenity.h index bab11e31..b86a264d 100644 --- a/src/zenity.h +++ b/src/zenity.h @@ -7,9 +7,9 @@ G_BEGIN_DECLS #ifdef ENABLE_NLS #include -#define _(String) dgettext(GETTEXT_PACKAGE,String) +#define _(String) dgettext (GETTEXT_PACKAGE, String) #ifdef gettext_noop -#define N_(String) gettext_noop(String) +#define N_(String) gettext_noop (String) #else #define N_(String) (String) #endif @@ -18,205 +18,196 @@ G_BEGIN_DECLS #define N_(String) (String) #define textdomain(String) (String) #define gettext(String) (String) -#define dgettext(Domain,String) (String) -#define dcgettext(Domain,String,Type) (String) -#define bindtextdomain(Domain,Directory) (Domain) +#define dgettext(Domain, String) (String) +#define dcgettext(Domain, String, Type) (String) +#define bindtextdomain(Domain, Directory) (Domain) #endif typedef struct { - gchar *dialog_title; - gchar *window_icon; - gchar *ok_label; - gchar *cancel_label; - gchar **extra_label; - gint width; - gint height; - gint exit_code; - gint timeout_delay; - gboolean modal; - guintptr attach; + gchar *dialog_title; + gchar *window_icon; + gchar *ok_label; + gchar *cancel_label; + gchar **extra_label; + gint width; + gint height; + gint exit_code; + gint timeout_delay; + gboolean modal; + guintptr attach; } ZenityData; typedef enum { - ZENITY_OK, - ZENITY_CANCEL, - ZENITY_ESC, - ZENITY_ERROR, - ZENITY_EXTRA, - ZENITY_TIMEOUT + ZENITY_OK, + ZENITY_CANCEL, + ZENITY_ESC, + ZENITY_ERROR, + ZENITY_EXTRA, + ZENITY_TIMEOUT } ZenityExitCode; typedef struct { - gchar *dialog_text; - gint day; - gint month; - gint year; - gchar *date_format; + gchar *dialog_text; + gint day; + gint month; + gint year; + gchar *date_format; } ZenityCalendarData; typedef enum { - ZENITY_MSG_WARNING, - ZENITY_MSG_QUESTION, - ZENITY_MSG_SWITCH, - ZENITY_MSG_ERROR, - ZENITY_MSG_INFO + ZENITY_MSG_WARNING, + ZENITY_MSG_QUESTION, + ZENITY_MSG_SWITCH, + ZENITY_MSG_ERROR, + ZENITY_MSG_INFO } MsgMode; typedef struct { - gchar *dialog_text; - gchar *dialog_icon; - MsgMode mode; - gboolean no_wrap; - gboolean no_markup; - gboolean default_cancel; - gboolean ellipsize; + gchar *dialog_text; + gchar *dialog_icon; + MsgMode mode; + gboolean no_wrap; + gboolean no_markup; + gboolean default_cancel; + gboolean ellipsize; } ZenityMsgData; typedef struct { - gchar *dialog_text; - gint value; - gint min_value; - gint max_value; - gint step; - gboolean print_partial; - gboolean hide_value; + gchar *dialog_text; + gint value; + gint min_value; + gint max_value; + gint step; + gboolean print_partial; + gboolean hide_value; } ZenityScaleData; typedef struct { - gchar *uri; - gboolean multi; - gboolean directory; - gboolean save; - gboolean confirm_overwrite; - gchar *separator; - gchar **filter; + gchar *uri; + gboolean multi; + gboolean directory; + gboolean save; + gboolean confirm_overwrite; + gchar *separator; + gchar **filter; } ZenityFileData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean hide_text; - const gchar **data; + gchar *dialog_text; + gchar *entry_text; + gboolean hide_text; + const gchar **data; } ZenityEntryData; typedef struct { - gchar *dialog_text; - gchar *entry_text; - gboolean pulsate; - gboolean autoclose; - gboolean autokill; - gdouble percentage; - gboolean no_cancel; - gboolean time_remaining; + gchar *dialog_text; + gchar *entry_text; + gboolean pulsate; + gboolean autoclose; + gboolean autokill; + gdouble percentage; + gboolean no_cancel; + gboolean time_remaining; } ZenityProgressData; typedef struct { - gchar *uri; - gboolean editable; - gboolean no_wrap; - gboolean auto_scroll; - gchar *font; - GtkTextBuffer *buffer; - gchar *checkbox; + gchar *uri; + gboolean editable; + gboolean no_wrap; + gboolean auto_scroll; + gchar *font; + GtkTextBuffer *buffer; + gchar *checkbox; #ifdef HAVE_WEBKITGTK - gboolean html; - gboolean no_interaction; - gchar *url; + gboolean html; + gboolean no_interaction; + gchar *url; #endif } ZenityTextData; typedef struct { - gchar *dialog_text; - GSList *columns; - gboolean checkbox; - gboolean radiobox; - gboolean hide_header; - gboolean imagebox; - gchar *separator; - gboolean multi; - gboolean editable; - gboolean mid_search; - gchar *print_column; - gchar *hide_column; - const gchar **data; + gchar *dialog_text; + GSList *columns; + gboolean checkbox; + gboolean radiobox; + gboolean hide_header; + gboolean imagebox; + gchar *separator; + gboolean multi; + gboolean editable; + gboolean mid_search; + gchar *print_column; + gchar *hide_column; + const gchar **data; } ZenityTreeData; #ifdef HAVE_LIBNOTIFY typedef struct { - gchar *notification_text; - gboolean listen; - gchar **notification_hints; + gchar *notification_text; + gboolean listen; + gchar **notification_hints; } ZenityNotificationData; #endif typedef struct { - gchar *color; - gboolean show_palette; + gchar *color; + gboolean show_palette; } ZenityColorData; typedef struct { - GSList *list; - GSList *list_widgets; - GSList *list_values; - GSList *column_values; - GSList *combo_values; - gchar *dialog_text; - gchar *separator; - gchar *date_format; -// gchar *hide_column; - gboolean show_header; + GSList *list; + GSList *list_widgets; + GSList *list_values; + GSList *column_values; + GSList *combo_values; + gchar *dialog_text; + gchar *separator; + gchar *date_format; + // gchar *hide_column; + gboolean show_header; } ZenityFormsData; typedef enum { - ZENITY_FORMS_ENTRY, - ZENITY_FORMS_PASSWORD, - ZENITY_FORMS_CALENDAR, - ZENITY_FORMS_LIST, - ZENITY_FORMS_COMBO + ZENITY_FORMS_ENTRY, + ZENITY_FORMS_PASSWORD, + ZENITY_FORMS_CALENDAR, + ZENITY_FORMS_LIST, + ZENITY_FORMS_COMBO } ZenityFormsType; typedef struct { - gchar *option_value; - ZenityFormsType type; - GtkWidget *forms_widget; + gchar *option_value; + ZenityFormsType type; + GtkWidget *forms_widget; } ZenityFormsValue; typedef struct { - gboolean username; - gchar *password; - GtkWidget *entry_username; - GtkWidget *entry_password; + gboolean username; + gchar *password; + GtkWidget *entry_username; + GtkWidget *entry_password; } ZenityPasswordData; -void zenity_calendar (ZenityData *data, - ZenityCalendarData *calendar_data); -void zenity_msg (ZenityData *data, - ZenityMsgData *msg_data); -void zenity_fileselection (ZenityData *data, - ZenityFileData *file_data); -void zenity_entry (ZenityData *data, - ZenityEntryData *entry_data); -void zenity_progress (ZenityData *data, - ZenityProgressData *progress_data); -void zenity_text (ZenityData *data, - ZenityTextData *text_data); -void zenity_tree (ZenityData *data, - ZenityTreeData *tree_data); +void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data); +void zenity_msg (ZenityData *data, ZenityMsgData *msg_data); +void zenity_fileselection (ZenityData *data, ZenityFileData *file_data); +void zenity_entry (ZenityData *data, ZenityEntryData *entry_data); +void zenity_progress (ZenityData *data, ZenityProgressData *progress_data); +void zenity_text (ZenityData *data, ZenityTextData *text_data); +void zenity_tree (ZenityData *data, ZenityTreeData *tree_data); #ifdef HAVE_LIBNOTIFY -void zenity_notification (ZenityData *data, - ZenityNotificationData *notification_data); +void zenity_notification ( + ZenityData *data, ZenityNotificationData *notification_data); #endif -void zenity_colorselection (ZenityData *data, - ZenityColorData *notification_data); -void zenity_scale (ZenityData *data, - ZenityScaleData *scale_data); -void zenity_about (ZenityData *data); +void zenity_colorselection ( + ZenityData *data, ZenityColorData *notification_data); +void zenity_scale (ZenityData *data, ZenityScaleData *scale_data); +void zenity_about (ZenityData *data); -void zenity_password_dialog (ZenityData *data, - ZenityPasswordData *password_data); -void zenity_forms_dialog (ZenityData *data, - ZenityFormsData *forms_data); +void zenity_password_dialog ( + ZenityData *data, ZenityPasswordData *password_data); +void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data); G_END_DECLS #endif /* ZENITY_H */ -- cgit From 110a851747398a59e8aa921faed57fca4b59792b Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Mon, 22 May 2017 09:30:49 -0400 Subject: Use GtkFileChooserNative --- src/fileselection.c | 69 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 521464b0..63c18439 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -30,14 +30,18 @@ static ZenityData *zen_data; static void zenity_fileselection_dialog_response ( - GtkWidget *widget, int response, gpointer data); + gpointer obj, int response, gpointer data); void zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { - GtkWidget *dialog; gchar *dir; gchar *basename; GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN; +#if GTK_CHECK_VERSION(3, 20, 0) + GtkFileChooserNative *dialog; +#else + GtkWidget *dialog; +#endif zen_data = data; @@ -51,22 +55,37 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { action = GTK_FILE_CHOOSER_ACTION_SAVE; } +#if GTK_CHECK_VERSION(3, 20, 0) + dialog = gtk_file_chooser_native_new (data->dialog_title, + NULL, /* TODO: Get parent from xid */ + action, + _ ("_OK"), + _ ("_Cancel") + ); + + if (data->modal) + gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG(dialog), TRUE); + + if (data->extra_label) + g_warning ("Cannot add extra labels to GtkFileChooserNative"); +#else dialog = gtk_file_chooser_dialog_new (NULL, NULL, action, _ ("_Cancel"), GTK_RESPONSE_CANCEL, _ ("_OK"), - GTK_RESPONSE_OK, + GTK_RESPONSE_ACCEPT, NULL); - gtk_file_chooser_set_do_overwrite_confirmation ( - GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); + if (data->dialog_title) + gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - g_signal_connect (G_OBJECT (dialog), - "response", - G_CALLBACK (zenity_fileselection_dialog_response), - file_data); + if (data->modal) + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + + zenity_util_set_window_icon ( + dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); if (data->extra_label) { gint i = 0; @@ -76,15 +95,15 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { i++; } } +#endif - if (data->dialog_title) - gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title); - - zenity_util_set_window_icon ( - dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png")); + gtk_file_chooser_set_do_overwrite_confirmation ( + GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite); - if (data->modal) - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); + g_signal_connect (G_OBJECT (dialog), + "response", + G_CALLBACK (zenity_fileselection_dialog_response), + file_data); if (file_data->uri) { dir = g_path_get_dirname (file_data->uri); @@ -156,7 +175,11 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { } } +#if GTK_CHECK_VERSION(3, 20, 0) + gtk_native_dialog_show (GTK_NATIVE_DIALOG(dialog)); +#else zenity_util_show_dialog (dialog, data->attach); +#endif if (data->timeout_delay > 0) { g_timeout_add_seconds (data->timeout_delay, @@ -169,9 +192,9 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { static void zenity_fileselection_dialog_output ( - GtkWidget *widget, ZenityFileData *file_data) { + GtkFileChooser *chooser, ZenityFileData *file_data) { GSList *selections, *iter; - selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget)); + selections = gtk_file_chooser_get_filenames (chooser); for (iter = selections; iter != NULL; iter = iter->next) { g_print ("%s", g_filename_to_utf8 ((gchar *) iter->data, -1, NULL, NULL, NULL)); @@ -185,12 +208,14 @@ zenity_fileselection_dialog_output ( static void zenity_fileselection_dialog_response ( - GtkWidget *widget, int response, gpointer data) { + gpointer obj, int response, gpointer data) { ZenityFileData *file_data = data; + GtkFileChooser *chooser = GTK_FILE_CHOOSER(obj); + switch (response) { - case GTK_RESPONSE_OK: - zenity_fileselection_dialog_output (widget, file_data); + case GTK_RESPONSE_ACCEPT: + zenity_fileselection_dialog_output (chooser, file_data); zenity_util_exit_code_with_data (ZENITY_OK, zen_data); break; @@ -199,7 +224,7 @@ zenity_fileselection_dialog_response ( break; case ZENITY_TIMEOUT: - zenity_fileselection_dialog_output (widget, file_data); + zenity_fileselection_dialog_output (chooser, file_data); zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT); break; -- cgit From ad6a345133ab026465903fc89b8275bf9c5ea8a5 Mon Sep 17 00:00:00 2001 From: Arx Cruz Date: Fri, 26 May 2017 14:27:44 +0200 Subject: Formating latest patch --- src/fileselection.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/fileselection.c b/src/fileselection.c index 63c18439..465f08ae 100644 --- a/src/fileselection.c +++ b/src/fileselection.c @@ -60,11 +60,10 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { NULL, /* TODO: Get parent from xid */ action, _ ("_OK"), - _ ("_Cancel") - ); + _ ("_Cancel")); if (data->modal) - gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG(dialog), TRUE); + gtk_native_dialog_set_modal (GTK_NATIVE_DIALOG (dialog), TRUE); if (data->extra_label) g_warning ("Cannot add extra labels to GtkFileChooserNative"); @@ -176,7 +175,7 @@ zenity_fileselection (ZenityData *data, ZenityFileData *file_data) { } #if GTK_CHECK_VERSION(3, 20, 0) - gtk_native_dialog_show (GTK_NATIVE_DIALOG(dialog)); + gtk_native_dialog_show (GTK_NATIVE_DIALOG (dialog)); #else zenity_util_show_dialog (dialog, data->attach); #endif @@ -211,7 +210,7 @@ zenity_fileselection_dialog_response ( gpointer obj, int response, gpointer data) { ZenityFileData *file_data = data; - GtkFileChooser *chooser = GTK_FILE_CHOOSER(obj); + GtkFileChooser *chooser = GTK_FILE_CHOOSER (obj); switch (response) { case GTK_RESPONSE_ACCEPT: -- cgit