[zenity/gtk4-port: 4/25] forms, msg, notification, option: make build against gtk4
- From: Logan Rathbone <larathbone src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [zenity/gtk4-port: 4/25] forms, msg, notification, option: make build against gtk4
- Date: Tue, 29 Jun 2021 02:19:12 +0000 (UTC)
commit acac6061539e6f6e0b74f9a7fcedc54553aad500
Author: Logan Rathbone <poprocks gmail com>
Date: Thu Feb 11 10:43:19 2021 -0500
forms,msg,notification,option: make build against gtk4
src/forms.c | 357 +++++----
src/msg.c | 19 +-
src/notification.c | 236 +++---
src/option.c | 2048 +++++++++++++++++++++++++++-------------------------
src/option.h | 7 +-
src/zenity.h | 25 +-
6 files changed, 1466 insertions(+), 1226 deletions(-)
---
diff --git a/src/forms.c b/src/forms.c
index 15df7189..86b8499b 100644
--- a/src/forms.c
+++ b/src/forms.c
@@ -1,47 +1,55 @@
+/* vim: colorcolumn=80 ts=4 sw=4
+ */
/*
* forms.c
*
- * Copyright (C) 2010 Arx Cruz
+ * Copyright © 2010 Arx Cruz
+ * Copyright © 2021 Logan Rathbone
*
* This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Library General Public
+ * 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
- * Library General Public License for more details.
+ * Lesser General Public License for more details.
*
- * You should have received a copy of the GNU Library General Public
+ * 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., 121 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
- * Authors: Arx Cruz <arxcruz gnome org>
+ * Original Author: Arx Cruz <arxcruz gnome org>
*/
-#include "config.h"
#include "util.h"
#include "zenity.h"
+
#include <string.h>
+#include <config.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_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,
- };
+ GtkTreeIter *iter, gpointer data)
+{
+ int n_columns = 0;
+ GValue value = G_VALUE_INIT;
+ GtkTreeView *tree_view = GTK_TREE_VIEW(data);
+
+ g_return_if_fail (GTK_IS_TREE_VIEW (tree_view));
n_columns = gtk_tree_model_get_n_columns (model);
- for (i = 0; i < n_columns; i++) {
+
+ for (int 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);
@@ -49,26 +57,32 @@ zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf,
}
static GtkWidget *
-zenity_forms_create_and_fill_combo (
- ZenityFormsData *forms_data, int combo_number) {
+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 =
+ if (forms_data->combo_values)
+ {
+ char *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;
+
+ if (combo_values)
+ {
+ char **row_values = g_strsplit_set (combo_values, "|", -1);
+
+ if (row_values)
+ {
+ int i = 0;
GtkTreeIter iter;
- gchar *row = row_values[i];
+ char *row = row_values[i];
- while (row != NULL) {
+ while (row != NULL)
+ {
gtk_list_store_append (list_store, &iter);
gtk_list_store_set (list_store, &iter, 0, row, -1);
row = row_values[++i];
@@ -79,65 +93,81 @@ zenity_forms_create_and_fill_combo (
}
}
- combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
- g_object_unref (G_OBJECT (list_store));
+ combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL(list_store));
+ g_object_unref (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);
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT(combo_box),
+ renderer,
+ TRUE); /* gboolean expand */
+ 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) {
+zenity_forms_create_and_fill_list (ZenityFormsData *forms_data,
+ int list_number, char *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;
+ int i = 0;
/* If no column names available, default is one */
- gint n_columns = 1;
- gint column_index = 0;
+ int n_columns = 1;
+ int column_index = 0;
tree_view = gtk_tree_view_new ();
- if (forms_data->column_values) {
- int columns_values_count =
- g_slist_length (forms_data->column_values);
+ if (forms_data->column_values)
+ {
+ char *column_values;
+ int columns_values_count = g_slist_length (forms_data->column_values);
int column_number = 0;
+
if (list_number < columns_values_count) {
column_number = list_number;
}
- column_values =
- g_slist_nth_data (forms_data->column_values, column_number);
- if (column_values) {
- gchar **values = g_strsplit_set (column_values, "|", -1);
- if (values) {
+ column_values = g_slist_nth_data (forms_data->column_values,
+ column_number);
+
+ if (column_values)
+ {
+ char **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];
+ for (i = 0; i < n_columns; i++)
+ {
+ GtkCellRenderer *renderer;
+ GtkTreeViewColumn *column;
+ char *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 =
+ 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++;
}
}
- } else {
+ }
+ else
+ {
/* If no values available, add one with string type*/
column_types = g_new (GType, n_columns);
column_types[0] = G_TYPE_STRING;
@@ -148,18 +178,26 @@ zenity_forms_create_and_fill_list (
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) {
+ if (forms_data->list_values)
+ {
+ char *list_values =
+ g_slist_nth_data (forms_data->list_values, list_number);
+
+ if (list_values)
+ {
+ char **row_values = g_strsplit_set (list_values, "|", -1);
+
+ if (row_values)
+ {
GtkTreeIter iter;
- gchar *row = row_values[0];
- gint position = -1;
+ char *row = row_values[0];
+ int position = -1;
i = 0;
- while (row != NULL) {
- if (position >= n_columns || position == -1) {
+ while (row != NULL)
+ {
+ if (position >= n_columns || position == -1)
+ {
position = 0;
gtk_list_store_append (list_store, &iter);
}
@@ -173,31 +211,29 @@ zenity_forms_create_and_fill_list (
}
}
- 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_model (GTK_TREE_VIEW (tree_view),
+ GTK_TREE_MODEL (list_store));
gtk_tree_view_set_headers_visible (
GTK_TREE_VIEW (tree_view), forms_data->show_header);
+ g_object_unref (list_store);
+
+ scrolled_window = gtk_scrolled_window_new ();
+ gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW(scrolled_window),
+ tree_view);
+ gtk_widget_set_size_request (scrolled_window, -1, 100);
return scrolled_window;
}
void
-zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) {
+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;
@@ -211,29 +247,26 @@ zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) {
return;
}
- gtk_builder_connect_signals (builder, NULL);
-
- dialog =
- GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog"));
+ 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);
+ g_signal_connect (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++;
+ 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)
+ {
+ for (i = 0; data->extra_label[i] != NULL; ++i)
+ {
+ gtk_dialog_add_button (GTK_DIALOG(dialog),
+ data->extra_label[i], i);
}
}
@@ -257,37 +290,48 @@ zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) {
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;
+ i = 0;
+ for (GSList *tmp = forms_data->list;
+ tmp != NULL;
+ tmp = tmp->next)
+ {
+ ZenityFormsValue *zenity_value = 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) {
+ 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);
+ 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);
+ 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);
+ zenity_forms_create_and_fill_combo (forms_data,
+ combo_count);
combo_count++;
break;
+
default:
zenity_value->forms_widget = gtk_entry_new ();
break;
@@ -300,90 +344,104 @@ zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) {
1,
1);
- i++;
+ ++i;
}
- gtk_widget_show_all (GTK_WIDGET (dialog));
+ zenity_util_show_dialog (dialog);
g_object_unref (builder);
- if (data->timeout_delay > 0) {
+ if (data->timeout_delay > 0)
+ {
g_timeout_add_seconds (data->timeout_delay,
(GSourceFunc) zenity_util_timeout_handle,
dialog);
}
-
- gtk_main ();
+ zenity_util_gapp_main (GTK_WINDOW(dialog));
}
static void
-zenity_forms_dialog_output (ZenityFormsData *forms_data) {
+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;
+ char time_string[128];
+ char *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) {
+ for (tmp = forms_data->list; tmp; tmp = tmp->next)
+ {
+ ZenityFormsValue *zenity_value = 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)));
+ gtk_entry_buffer_get_text (gtk_entry_get_buffer
+ (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))));
+ selection =
+ gtk_tree_view_get_selection
+ (GTK_TREE_VIEW(gtk_scrolled_window_get_child
+ (GTK_SCROLLED_WINDOW(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_get_selected,
+ GTK_TREE_VIEW(gtk_scrolled_window_get_child
+ (GTK_SCROLLED_WINDOW(zenity_value->forms_widget))));
- for (tmp2 = selected; tmp2; tmp2 = tmp2->next) {
+ for (tmp2 = selected; tmp2; tmp2 = tmp2->next)
+ {
if (tmp->next != NULL) {
- g_print ("%s,", (gchar *) tmp2->data);
+ g_print ("%s,", (char *)tmp2->data);
} else
- g_print ("%s", (gchar *) tmp2->data);
+ g_print ("%s", (char *)tmp2->data);
}
- g_slist_foreach (selected, (GFunc) g_free, NULL);
- selected = NULL;
-
+ g_slist_free_full (g_steal_pointer (&selected), g_free);
break;
+
case ZENITY_FORMS_CALENDAR:
- gtk_calendar_get_date (
- GTK_CALENDAR (zenity_value->forms_widget),
- &day,
- &month,
- &year);
+ g_object_get (zenity_value->forms_widget,
+ "day", &day,
+ "month", &month,
+ "year", &year,
+ NULL);
date = g_date_new_dmy (year, month + 1, day);
- g_date_strftime (
- time_string, 127, forms_data->date_format, date);
+ 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),
+ 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
+ }
+ else
g_print (" ");
break;
+
}
if (tmp->next != NULL)
g_print ("%s", forms_data->separator);
@@ -392,10 +450,12 @@ zenity_forms_dialog_output (ZenityFormsData *forms_data) {
}
static void
-zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) {
- ZenityFormsData *forms_data = (ZenityFormsData *) data;
+zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data)
+{
+ ZenityFormsData *forms_data = data;
- switch (response) {
+ switch (response)
+ {
case GTK_RESPONSE_OK:
zenity_forms_dialog_output (forms_data);
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
@@ -412,11 +472,10 @@ zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) {
default:
if (zen_data->extra_label &&
- response < g_strv_length (zen_data->extra_label))
+ response < (int)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_util_gapp_quit (GTK_WINDOW(widget));
}
diff --git a/src/msg.c b/src/msg.c
index 181353e5..45c138dd 100644
--- a/src/msg.c
+++ b/src/msg.c
@@ -80,14 +80,16 @@ zenity_label_widget_clipboard_selection (GtkWidget *widget) {
}
void
-zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
+zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
+{
GtkBuilder *builder;
GtkWidget *dialog;
GtkWidget *ok_button;
GObject *text;
GObject *image;
- switch (msg_data->mode) {
+ switch (msg_data->mode)
+ {
case ZENITY_MSG_WARNING:
builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL);
dialog = GTK_WIDGET (
@@ -166,7 +168,8 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
}
}
- switch (msg_data->mode) {
+ switch (msg_data->mode)
+ {
case ZENITY_MSG_WARNING:
zenity_util_set_window_icon_from_icon_name (
dialog, data->window_icon, "dialog-warning");
@@ -234,7 +237,7 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
if (msg_data->no_wrap)
gtk_label_set_wrap (GTK_LABEL (text), FALSE);
- zenity_util_show_dialog (dialog, data->attach);
+ zenity_util_show_dialog (dialog);
if (data->timeout_delay > 0) {
g_timeout_add_seconds (data->timeout_delay,
@@ -244,14 +247,15 @@ zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
g_object_unref (builder);
- zenity_util_gapp_main ();
+ zenity_util_gapp_main (GTK_WINDOW(dialog));
}
static void
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) {
ZenityData *zen_data = data;
- switch (response) {
+ switch (response)
+ {
case GTK_RESPONSE_OK:
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
break;
@@ -267,6 +271,5 @@ zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) {
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
break;
}
-
- // FIXME - replace gtk_main_quit here.
+ zenity_util_gapp_quit (GTK_WINDOW(widget));
}
diff --git a/src/notification.c b/src/notification.c
index eb0e79eb..928a9abd 100644
--- a/src/notification.c
+++ b/src/notification.c
@@ -1,8 +1,11 @@
+/* vim: colorcolumn=80 ts=4 sw=4
+ */
/*
* notification.c
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
- * Copyright (C) 2006 Christian Persch
+ * Copyright © 2002 Sun Microsystems, Inc.
+ * Copyright © 2006 Christian Persch
+ * Copyright © 2021 Logan Rathbone
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,7 +22,7 @@
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*
- * Authors: Glynn Foster <glynn foster sun com>
+ * Original Author: Glynn Foster <glynn foster sun com>
*/
#include <config.h>
@@ -41,12 +44,14 @@ static char *icon_file;
static GHashTable *notification_hints;
static NotifyNotification *
-zenity_notification_new (gchar *message, gchar *icon_file) {
+zenity_notification_new (gchar *message, gchar *icon_file)
+{
NotifyNotification *notif;
- gchar **text;
+ char **text;
text = g_strsplit (g_strcompress (message), "\n", 2);
- if (*text == NULL) {
+ if (*text == NULL)
+ {
g_printerr (_ ("Could not parse message\n"));
return NULL;
}
@@ -54,36 +59,41 @@ zenity_notification_new (gchar *message, gchar *icon_file) {
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 = user_data;
- zen_data = (ZenityData *) user_data;
notify_notification_close (n, NULL);
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
- gtk_main_quit ();
+ exit(zen_data->exit_code);
}
static GHashTable *
-zenity_notification_parse_hints_array (gchar **hints) {
+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++) {
+ for (i = 0; i < (int)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;
@@ -93,36 +103,36 @@ zenity_notification_parse_hints_array (gchar **hints) {
}
static GHashTable *
-zenity_notification_parse_hints (gchar *hints) {
+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;
+zenity_notification_set_hint (gpointer key, gpointer value,
+ gpointer user_data)
+{
+ NotifyNotification *notification = user_data;
+ char *hint_name = key;
+ char *string_value = value;
- gchar *string_value;
+ GVariant *hint_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)) {
+ (g_ascii_strcasecmp ("transient", hint_name) == 0))
+ {
/* boolean hints */
if (g_ascii_strcasecmp ("true", string_value) == 0) {
boolean_value = TRUE;
@@ -134,36 +144,46 @@ zenity_notification_set_hint (
return;
}
hint_value = g_variant_new_boolean (boolean_value);
- } else if ((g_ascii_strcasecmp ("category", hint_name) == 0) ||
+ }
+ 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)) {
+ (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) ||
+ }
+ 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)) {
+ (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)) {
+ }
+ 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)) {
+ }
+ 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 {
+ }
+ else
+ {
/* unknown hints */
- g_printerr (_ ("Unknown hint name. Skipping.\n"));
+ g_printerr (_("Unknown hint name. Skipping.\n"));
return;
}
@@ -171,41 +191,49 @@ zenity_notification_set_hint (
}
static void
-zenity_notification_set_hints (
- NotifyNotification *notification, GHashTable *hints) {
- if (hints == NULL) {
+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, gpointer user_data) {
- if ((condition & G_IO_IN) != 0) {
+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)
;
+
+ string = g_string_new (NULL);
+
do {
- gint status;
- gchar *command, *value, *colon;
+ int status;
+ char *command, *value, *colon;
do {
- status = g_io_channel_read_line_string (
- channel, string, NULL, &error);
- while (gdk_events_pending ())
- gtk_main_iteration ();
+ status = g_io_channel_read_line_string (channel, string,
+ NULL, &error);
+
+ while (g_main_context_pending (NULL)) {
+ g_main_context_iteration (NULL, FALSE);
+ }
} while (status == G_IO_STATUS_AGAIN);
- if (status != G_IO_STATUS_NORMAL) {
+ if (status != G_IO_STATUS_NORMAL)
+ {
if (error) {
- g_warning ("zenity_notification_handle_stdin () : %s",
- error->message);
+ g_warning ("%s: %s",
+ __func__,
+ error->message);
g_error_free (error);
error = NULL;
}
@@ -214,10 +242,12 @@ zenity_notification_handle_stdin (
zenity_util_strip_newline (string->str);
colon = strchr (string->str, ':');
- if (colon == NULL) {
- g_printerr (_ ("Could not parse command from stdin\n"));
+ 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));
@@ -225,19 +255,27 @@ zenity_notification_handle_stdin (
while (*value && g_ascii_isspace (*value))
value++;
- if (!g_ascii_strcasecmp (command, "icon")) {
+ if (! g_ascii_strcasecmp (command, "icon"))
+ {
g_free (icon_file);
icon_file = g_strdup (value);
- } else if (!g_ascii_strcasecmp (command, "hints")) {
+ }
+ 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")) {
+ }
+ else if (!g_ascii_strcasecmp (command, "message"))
+ {
/* display a notification bubble */
- if (!g_utf8_validate (value, -1, NULL)) {
+ if (! g_utf8_validate (value, -1, NULL))
+ {
g_warning ("Invalid UTF-8 in input!");
- } else {
+ }
+ else
+ {
NotifyNotification *notif;
error = NULL;
@@ -257,37 +295,51 @@ zenity_notification_handle_stdin (
g_object_unref (notif);
}
- } else if (!g_ascii_strcasecmp (command, "tooltip")) {
- if (!g_utf8_validate (value, -1, NULL)) {
+ }
+ 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);
+ }
+ else
+ {
+ NotifyNotification *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);
+ if (error)
+ {
+ g_warning ("Error showing notification: %s",
+ error->message);
g_error_free (error);
+
error = NULL;
}
}
- } else if (!g_ascii_strcasecmp (command, "visible")) {
+ }
+ else if (!g_ascii_strcasecmp (command, "visible"))
+ {
- } else {
+ }
+ 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) {
+ if ((condition & G_IO_HUP) != 0)
+ {
g_io_channel_shutdown (channel, TRUE, NULL);
return FALSE;
}
@@ -296,19 +348,23 @@ zenity_notification_handle_stdin (
}
static void
-zenity_notification_listen_on_stdin (ZenityData *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);
+ g_io_add_watch (channel,
+ G_IO_IN | G_IO_HUP,
+ zenity_notification_handle_stdin,
+ data);
}
void
-zenity_notification (
- ZenityData *data, ZenityNotificationData *notification_data) {
+zenity_notification (ZenityData *data,
+ ZenityNotificationData *notification_data)
+{
GError *error;
NotifyNotification *notification;
GHashTable *notification_hints;
@@ -318,20 +374,23 @@ zenity_notification (
notify_init (_ ("Zenity notification"));
}
- if (notification_data->listen) {
+ if (notification_data->listen)
+ {
zenity_notification_listen_on_stdin (data);
- gtk_main ();
- } else {
- if (notification_data->notification_text == NULL) {
+ // FIXME - not sure what to replace this with atm.
+// gtk_main ();
+ }
+ else
+ {
+ if (notification_data->notification_text == NULL)
exit (1);
- }
- notification = zenity_notification_new (
- notification_data->notification_text, data->window_icon);
+ notification =
+ zenity_notification_new (notification_data->notification_text,
+ data->window_icon);
- if (notification == NULL) {
+ if (notification == NULL)
exit (1);
- }
/* if we aren't listening for changes, then close on default action */
notify_notification_add_action (notification,
@@ -342,16 +401,20 @@ zenity_notification (
NULL);
/* set the notification hints for the displayed notification */
- if (notification_data->notification_hints != NULL) {
+ 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 (! notify_notification_show (notification, &error))
+ {
if (error != NULL) {
g_warning ("Error showing notification: %s", error->message);
g_error_free (error);
@@ -364,7 +427,8 @@ zenity_notification (
g_timeout_add_seconds (data->timeout_delay,
(GSourceFunc) zenity_util_timeout_handle,
NULL);
- gtk_main ();
+ // FIXME - not sure what to replace this with here.
+// gtk_main ();
}
}
diff --git a/src/option.c b/src/option.c
index fb65cd59..1b67fad3 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1,3 +1,5 @@
+/* vim: colorcolumn=80 ts=4 sw=4
+ */
/*
* option.h
*
@@ -22,30 +24,30 @@
* Lucas Rocha <lucasr im ufba br>
*/
-#include "config.h"
-
#include "option.h"
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <config.h>
+
/* General Options */
-static gchar *zenity_general_dialog_title;
-static gchar *zenity_general_window_icon;
+static char *zenity_general_dialog_title;
+static char *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 char *zenity_general_dialog_text;
+static char *zenity_general_dialog_icon;
+static char *zenity_general_separator;
static gboolean zenity_general_multiple;
static gboolean zenity_general_editable;
-static gchar *zenity_general_uri;
+static char *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 int zenity_general_timeout_delay;
+static char *zenity_general_ok_button;
+static char *zenity_general_cancel_button;
+static char **zenity_general_extra_buttons;
static gboolean zenity_general_modal;
static gboolean zenity_general_dialog_ellipsize;
@@ -54,11 +56,11 @@ 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 char *zenity_calendar_date_format;
/* Entry Dialog Options */
static gboolean zenity_entry_active;
-static gchar *zenity_entry_entry_text;
+static char *zenity_entry_entry_text;
static gboolean zenity_entry_hide_text;
/* Error Dialog Options */
@@ -71,15 +73,15 @@ static gboolean zenity_info_active;
static gboolean zenity_file_active;
static gboolean zenity_file_directory;
static gboolean zenity_file_save;
-static gchar **zenity_file_filter;
+static char **zenity_file_filter;
/* List Dialog Options */
static gboolean zenity_list_active;
-static gchar **zenity_list_columns;
+static char **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 char *zenity_list_print_column;
+static char *zenity_list_hide_column;
static gboolean zenity_list_hide_header;
static gboolean zenity_list_imagelist;
static gboolean zenity_list_mid_search;
@@ -88,7 +90,7 @@ 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 char **zenity_notification_hints;
#endif
/* Progress Dialog Options */
@@ -107,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 char *zenity_text_font;
+static char *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 char *zenity_text_url;
#endif
/* Warning Dialog Options */
@@ -122,16 +124,16 @@ 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 int zenity_scale_value;
+static int zenity_scale_min_value;
+static int zenity_scale_max_value;
+static int 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 char *zenity_colorsel_color;
static gboolean zenity_colorsel_show_palette;
/* Password Dialog Options */
@@ -141,244 +143,254 @@ 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 char *zenity_forms_date_format;
+static char **zenity_forms_list_values;
+static char **zenity_forms_column_values;
+static char **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},
- {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 gboolean zenity_forms_callback (const char *option_name,
+ const char *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},
+ {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 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 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 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 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 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"),
+ 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"),
+ NULL},
+ {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"),
+ 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"),
+ NULL},
+ {NULL}};
static GOptionEntry file_selection_options[] =
{{"file-selection",
@@ -435,530 +447,542 @@ static GOptionEntry file_selection_options[] =
},
{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}};
-
-#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 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 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}};
+#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 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")},
-#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")},
#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 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 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",
+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"),
+ NULL},
+ {"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"),
+ NULL},
+ {"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',
- 0,
+ G_OPTION_FLAG_IN_MAIN,
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",
+ &zenity_text_active,
+ N_ ("Display text information dialog"),
+ NULL},
+ {"filename",
'\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",
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_FILENAME,
+ &zenity_general_uri,
+ N_ ("Open file"),
+ N_ ("FILENAME")},
+ {"editable",
'\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",
+ G_OPTION_FLAG_NOALIAS,
+ G_OPTION_ARG_NONE,
+ &zenity_general_editable,
+ N_ ("Allow changes to text"),
+ NULL},
+ {"font",
'\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",
+ G_OPTION_ARG_STRING,
+ &zenity_text_font,
+ N_ ("Set the text font"),
+ N_ ("TEXT")},
+ {"checkbox",
'\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",
+ 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',
- 0,
+ G_OPTION_FLAG_NOALIAS,
G_OPTION_ARG_NONE,
- &zenity_forms_show_header,
- N_ ("Show the columns header"),
+ &zenity_text_enable_html,
+ N_ ("Enable HTML support"),
NULL},
- {"text",
+ {"no-interaction",
'\0',
G_OPTION_FLAG_NOALIAS,
- G_OPTION_ARG_STRING,
- &zenity_general_dialog_text,
- N_ ("Set the dialog text"),
- N_ ("TEXT")},
- {"separator",
+ 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_general_separator,
- N_ ("Set output separator character"),
- N_ ("SEPARATOR")},
- {"date-format",
+ &zenity_text_url,
+ N_ ("Set an URL instead of a file. Only works if you use --html "
+ "option"),
+ N_ ("URL")},
+#endif
+ {"auto-scroll",
'\0',
- 0,
- G_OPTION_ARG_STRING,
- &zenity_forms_date_format,
- N_ ("Set the format for the returned date"),
- N_ ("PATTERN")},
+ 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 password_dialog_options[] = {
- {"password",
+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"),
+ 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"),
+ NULL},
+ {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,
@@ -974,8 +998,8 @@ static GOptionEntry password_dialog_options[] = {
NULL},
{NULL}};
-static GOptionEntry color_selection_options[] = {
- {"color-selection",
+static GOptionEntry color_selection_options[] =
+ {{"color-selection",
'\0',
G_OPTION_FLAG_IN_MAIN,
G_OPTION_ARG_NONE,
@@ -998,28 +1022,29 @@ static GOptionEntry color_selection_options[] = {
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 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;
static void
-zenity_option_init (void) {
-
+zenity_option_init (void)
+{
results = g_new0 (ZenityParsingOptions, 1);
/* Initialize the various dialog structures */
@@ -1042,7 +1067,8 @@ zenity_option_init (void) {
}
void
-zenity_option_free (void) {
+zenity_option_free (void)
+{
if (zenity_general_dialog_title)
g_free (zenity_general_dialog_title);
if (zenity_general_window_icon)
@@ -1070,8 +1096,6 @@ zenity_option_free (void) {
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);
@@ -1102,8 +1126,10 @@ zenity_option_free (void) {
}
static void
-zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) {
- if (is_active == TRUE) {
+zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode)
+{
+ if (is_active == TRUE)
+ {
if (results->mode == MODE_LAST)
results->mode = mode;
else
@@ -1111,21 +1137,22 @@ zenity_option_set_dialog_mode (gboolean is_active, ZenityDialogMode mode) {
}
}
-static gchar *
-zenity_option_get_name (GOptionEntry *entries, gpointer arg_data) {
- int i;
-
- for (i = 1; entries[i].long_name != NULL; i++) {
+static char *
+zenity_option_get_name (GOptionEntry *entries, gpointer arg_data)
+{
+ for (int i = 1; entries[i].long_name != NULL; i++)
+ {
if (entries[i].arg_data == arg_data)
- return (gchar *) entries[i].long_name;
+ return (char *)entries[i].long_name;
}
return NULL;
}
/* Forms callback */
static gboolean
-zenity_forms_callback (const gchar *option_name, const gchar *value,
- gpointer data, GError **error) {
+zenity_forms_callback (const char *option_name, const char *value,
+ gpointer data, GError **error)
+{
ZenityFormsValue *forms_value = g_new0 (ZenityFormsValue, 1);
forms_value->option_value = g_strdup (value);
@@ -1150,7 +1177,8 @@ zenity_forms_callback (const gchar *option_name, const gchar *value,
/* Error callback */
static void
zenity_option_error_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_error (NULL, ERROR_SYNTAX);
}
@@ -1158,7 +1186,8 @@ zenity_option_error_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_general_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_general_dialog_title = NULL;
zenity_general_window_icon = NULL;
zenity_general_width = -1;
@@ -1181,7 +1210,8 @@ zenity_general_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_calendar_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_calendar_active = FALSE;
zenity_calendar_date_format = NULL;
zenity_calendar_day = -1;
@@ -1193,7 +1223,8 @@ zenity_calendar_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_entry_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_entry_active = FALSE;
zenity_entry_entry_text = NULL;
zenity_entry_hide_text = FALSE;
@@ -1203,7 +1234,8 @@ zenity_entry_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_error_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_error_active = FALSE;
return TRUE;
@@ -1211,7 +1243,8 @@ zenity_error_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_info_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_info_active = FALSE;
return TRUE;
@@ -1219,7 +1252,8 @@ zenity_info_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_file_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_file_active = FALSE;
zenity_file_directory = FALSE;
zenity_file_save = FALSE;
@@ -1230,7 +1264,8 @@ zenity_file_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_list_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_list_active = FALSE;
zenity_list_columns = NULL;
zenity_list_checklist = FALSE;
@@ -1247,7 +1282,8 @@ zenity_list_pre_callback (GOptionContext *context, GOptionGroup *group,
#ifdef HAVE_LIBNOTIFY
static gboolean
zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_notification_active = FALSE;
zenity_notification_listen = FALSE;
@@ -1257,7 +1293,8 @@ zenity_notification_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_progress_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_progress_active = FALSE;
zenity_progress_percentage = 0;
zenity_progress_pulsate = FALSE;
@@ -1265,21 +1302,25 @@ zenity_progress_pre_callback (GOptionContext *context, GOptionGroup *group,
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) {
+ 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) {
+ gpointer data, GError **error)
+{
zenity_text_active = FALSE;
zenity_text_font = NULL;
zenity_text_checkbox = NULL;
@@ -1289,12 +1330,14 @@ zenity_text_pre_callback (GOptionContext *context, GOptionGroup *group,
zenity_text_no_interaction = FALSE;
zenity_text_url = NULL;
#endif
+
return TRUE;
}
static gboolean
zenity_warning_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_warning_active = FALSE;
return TRUE;
@@ -1302,7 +1345,8 @@ zenity_warning_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_scale_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_scale_active = FALSE;
zenity_scale_value = 0;
zenity_scale_min_value = 0;
@@ -1316,7 +1360,8 @@ zenity_scale_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_color_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_colorsel_active = FALSE;
zenity_colorsel_color = NULL;
zenity_colorsel_show_palette = FALSE;
@@ -1326,7 +1371,8 @@ zenity_color_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_password_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_password_active = FALSE;
zenity_password_show_username = FALSE;
@@ -1335,17 +1381,19 @@ zenity_password_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_forms_pre_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ 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) {
+ gpointer data, GError **error)
+{
zenity_misc_about = FALSE;
zenity_misc_version = FALSE;
@@ -1357,7 +1405,8 @@ zenity_misc_pre_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_general_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ 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;
@@ -1373,10 +1422,12 @@ zenity_general_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_calendar_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_calendar_active, MODE_CALENDAR);
- if (results->mode == MODE_CALENDAR) {
+ if (results->mode == MODE_CALENDAR)
+ {
struct tm *t;
time_t current_time;
@@ -1395,67 +1446,79 @@ zenity_calendar_post_callback (GOptionContext *context, GOptionGroup *group,
results->calendar_data->month = zenity_calendar_month;
results->calendar_data->year = zenity_calendar_year;
- if (zenity_calendar_date_format)
+ if (zenity_calendar_date_format) {
results->calendar_data->date_format = zenity_calendar_date_format;
- else
+ } 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),
+ }
+ }
+ 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),
+ 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),
+ if (zenity_calendar_year > -1) {
+ zenity_option_error (zenity_option_get_name (calendar_options,
+ &zenity_calendar_year),
ERROR_SUPPORT);
+ }
- if (zenity_calendar_date_format)
+ if (zenity_calendar_date_format) {
zenity_option_error (zenity_option_get_name (calendar_options,
- &zenity_calendar_date_format),
+ &zenity_calendar_date_format),
ERROR_SUPPORT);
+ }
}
-
return TRUE;
}
static gboolean
zenity_entry_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_entry_active, MODE_ENTRY);
- if (results->mode == 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),
+ }
+ 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),
+ 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) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_error_active, MODE_ERROR);
- if (results->mode == 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;
@@ -1469,10 +1532,12 @@ zenity_error_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_info_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_info_active, MODE_INFO);
- if (results->mode == 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;
@@ -1486,50 +1551,61 @@ zenity_info_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_file_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_file_active, MODE_FILE);
- if (results->mode == 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->separator = zenity_general_separator;
results->file_data->filter = zenity_file_filter;
- } else {
- if (zenity_file_directory)
+ }
+ else
+ {
+ if (zenity_file_directory) {
zenity_option_error (zenity_option_get_name (file_selection_options,
- &zenity_file_directory),
+ &zenity_file_directory),
ERROR_SUPPORT);
+ }
- if (zenity_file_save)
- zenity_option_error (zenity_option_get_name (
- file_selection_options,
&zenity_file_save),
+ if (zenity_file_save) {
+ zenity_option_error (zenity_option_get_name (file_selection_options,
+ &zenity_file_save),
ERROR_SUPPORT);
+ }
- if (zenity_file_filter)
+ if (zenity_file_filter) {
zenity_option_error (zenity_option_get_name (file_selection_options,
- &zenity_file_filter),
+ &zenity_file_filter),
ERROR_SUPPORT);
+ }
}
-
return TRUE;
}
static gboolean
zenity_list_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
int i = 0;
- gchar *column;
+ char *column;
zenity_option_set_dialog_mode (zenity_list_active, MODE_LIST);
- if (results->mode == MODE_LIST) {
+ if (results->mode == MODE_LIST)
+ {
results->tree_data->dialog_text = zenity_general_dialog_text;
- if (zenity_list_columns) {
+ if (zenity_list_columns)
+ {
column = zenity_list_columns[0];
- while (column != NULL) {
+
+ while (column != NULL)
+ {
results->tree_data->columns =
g_slist_append (results->tree_data->columns, column);
column = zenity_list_columns[++i];
@@ -1546,7 +1622,9 @@ zenity_list_post_callback (GOptionContext *context, GOptionGroup *group,
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 {
+ }
+ else
+ {
if (zenity_list_columns)
zenity_option_error (
zenity_option_get_name (list_options, &zenity_list_columns),
@@ -1586,39 +1664,44 @@ zenity_list_post_callback (GOptionContext *context, GOptionGroup *group,
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);
+ gpointer data, GError **error)
+{
+ zenity_option_set_dialog_mode (zenity_notification_active,
+ MODE_NOTIFICATION);
- if (results->mode == 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)
+ }
+ else
+ {
+ if (zenity_notification_listen) {
zenity_option_error (zenity_option_get_name (notification_options,
- &zenity_notification_listen),
+ &zenity_notification_listen),
ERROR_SUPPORT);
+ }
}
-
return TRUE;
}
#endif
static gboolean
zenity_progress_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_progress_active, MODE_PROGRESS);
- if (results->mode == 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;
@@ -1626,46 +1709,56 @@ zenity_progress_post_callback (GOptionContext *context, GOptionGroup *group,
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)
+ }
+ else
+ {
+ if (zenity_progress_pulsate) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_pulsate),
+ &zenity_progress_pulsate),
ERROR_SUPPORT);
+ }
- if (zenity_progress_percentage)
+ if (zenity_progress_percentage) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_percentage),
+ &zenity_progress_percentage),
ERROR_SUPPORT);
+ }
- if (zenity_progress_auto_close)
+ if (zenity_progress_auto_close) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_auto_close),
+ &zenity_progress_auto_close),
ERROR_SUPPORT);
+ }
- if (zenity_progress_auto_kill)
+ if (zenity_progress_auto_kill) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_auto_kill),
+ &zenity_progress_auto_kill),
ERROR_SUPPORT);
+ }
- if (zenity_progress_no_cancel)
+ if (zenity_progress_no_cancel) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_no_cancel),
+ &zenity_progress_no_cancel),
ERROR_SUPPORT);
+ }
- if (zenity_progress_time_remaining)
+ if (zenity_progress_time_remaining) {
zenity_option_error (zenity_option_get_name (progress_options,
- &zenity_progress_time_remaining),
+ &zenity_progress_time_remaining),
ERROR_SUPPORT);
+ }
}
-
return TRUE;
}
static gboolean
zenity_question_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_question_active, MODE_QUESTION);
- if (results->mode == 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)
@@ -1677,20 +1770,24 @@ zenity_question_post_callback (GOptionContext *context, GOptionGroup *group,
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);
+ 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) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_text_active, MODE_TEXTINFO);
- if (results->mode == 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;
@@ -1702,16 +1799,20 @@ zenity_text_post_callback (GOptionContext *context, GOptionGroup *group,
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),
+ if (zenity_text_enable_html) {
+ zenity_option_error (zenity_option_get_name (text_options,
+ &zenity_text_enable_html),
ERROR_SUPPORT);
+ }
#endif
}
return TRUE;
@@ -1719,10 +1820,12 @@ zenity_text_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_warning_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_warning_active, MODE_WARNING);
- if (results->mode == 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;
@@ -1736,10 +1839,12 @@ zenity_warning_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_scale_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_scale_active, MODE_SCALE);
- if (results->mode == 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;
@@ -1754,40 +1859,47 @@ zenity_scale_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_color_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_colorsel_active, MODE_COLOR);
- if (results->mode == 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);
}
+ 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;
+ gpointer data, GError **error)
+{
+ char *values;
int i = 0;
zenity_option_set_dialog_mode (zenity_forms_active, MODE_FORMS);
- if (results->mode == 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) {
@@ -1824,7 +1936,9 @@ zenity_forms_post_callback (GOptionContext *context, GOptionGroup *group,
else
results->forms_data->date_format =
g_locale_to_utf8 (nl_langinfo (D_FMT), -1, NULL, NULL, NULL);
- } else {
+ }
+ else
+ {
if (zenity_forms_date_format)
zenity_option_error (zenity_option_get_name (forms_dialog_options,
&zenity_forms_date_format),
@@ -1833,10 +1947,6 @@ zenity_forms_post_callback (GOptionContext *context, GOptionGroup *group,
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),
@@ -1856,24 +1966,26 @@ zenity_forms_post_callback (GOptionContext *context, GOptionGroup *group,
static gboolean
zenity_password_post_callback (GOptionContext *context, GOptionGroup *group,
- gpointer data, GError **error) {
+ 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);
+ 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) {
+ gpointer data, GError **error)
+{
zenity_option_set_dialog_mode (zenity_misc_about, MODE_ABOUT);
zenity_option_set_dialog_mode (zenity_misc_version, MODE_VERSION);
@@ -1881,7 +1993,8 @@ zenity_misc_post_callback (GOptionContext *context, GOptionGroup *group,
}
static GOptionContext *
-zenity_create_context (void) {
+zenity_create_context (void)
+{
GOptionContext *tmp_ctx;
GOptionGroup *a_group;
@@ -1894,8 +2007,8 @@ zenity_create_context (void) {
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_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);
@@ -1907,8 +2020,8 @@ zenity_create_context (void) {
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_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);
@@ -1920,15 +2033,15 @@ zenity_create_context (void) {
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_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);
+ 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);
@@ -1937,8 +2050,8 @@ zenity_create_context (void) {
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);
+ 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);
@@ -2005,8 +2118,8 @@ zenity_create_context (void) {
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_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);
@@ -2018,15 +2131,15 @@ zenity_create_context (void) {
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_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);
+ 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);
@@ -2054,8 +2167,8 @@ zenity_create_context (void) {
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_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);
@@ -2067,8 +2180,8 @@ zenity_create_context (void) {
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_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);
@@ -2080,8 +2193,8 @@ zenity_create_context (void) {
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_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);
@@ -2093,17 +2206,12 @@ zenity_create_context (void) {
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_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);
@@ -2112,28 +2220,34 @@ zenity_create_context (void) {
}
void
-zenity_option_error (gchar *string, ZenityError error) {
- switch (error) {
+zenity_option_error (char *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) {
+zenity_option_parse (int argc, char **argv)
+{
GError *error = NULL;
zenity_option_init ();
diff --git a/src/option.h b/src/option.h
index b495e0e7..ab76f1ed 100644
--- a/src/option.h
+++ b/src/option.h
@@ -1,7 +1,8 @@
/*
* option.h
*
- * Copyright (C) 2002 Sun Microsystems, Inc.
+ * Copyright © 2002 Sun Microsystems, Inc.
+ * Copyright © 2021 Logan Rathbone
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -80,9 +81,9 @@ typedef struct {
ZenityFormsData *forms_data;
} ZenityParsingOptions;
-void zenity_option_error (gchar *string, ZenityError error);
+void zenity_option_error (char *string, ZenityError error);
-ZenityParsingOptions *zenity_option_parse (gint argc, gchar **argv);
+ZenityParsingOptions *zenity_option_parse (int argc, char **argv);
void zenity_option_free (void);
diff --git a/src/zenity.h b/src/zenity.h
index 953f014e..a23f00d4 100644
--- a/src/zenity.h
+++ b/src/zenity.h
@@ -24,15 +24,15 @@ G_BEGIN_DECLS
#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;
+ char *dialog_title;
+ char *window_icon;
+ char *ok_label;
+ char *cancel_label;
+ char **extra_label;
+ int width;
+ int height;
+ int exit_code;
+ int timeout_delay;
gboolean modal;
} ZenityData;
@@ -158,10 +158,9 @@ typedef struct {
GSList *list_values;
GSList *column_values;
GSList *combo_values;
- gchar *dialog_text;
- gchar *separator;
- gchar *date_format;
- // gchar *hide_column;
+ char *dialog_text;
+ char *separator;
+ char *date_format;
gboolean show_header;
} ZenityFormsData;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]