Fix style
Fixing style in all zenity code, removing useless spaces, empty lines, all code in 80 columns, etc.
This commit is contained in:
parent
8c5e60de83
commit
4eddb202ca
153
src/about.c
153
src/about.c
@ -25,10 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include <string.h>
|
#include "zenity.h"
|
||||||
#include <gdk/gdkkeysyms.h>
|
#include <gdk/gdkkeysyms.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#define GTK_RESPONSE_CREDITS 0
|
#define GTK_RESPONSE_CREDITS 0
|
||||||
#define ZENITY_HELP_PATH ZENITY_DATADIR "/help/"
|
#define ZENITY_HELP_PATH ZENITY_DATADIR "/help/"
|
||||||
@ -39,39 +39,38 @@
|
|||||||
|
|
||||||
static GtkWidget *dialog;
|
static GtkWidget *dialog;
|
||||||
|
|
||||||
static void zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_about_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
/* Sync with the people in the THANKS file */
|
/* Sync with the people in the THANKS file */
|
||||||
static const gchar *const authors[] = {
|
static const gchar *const authors[] = {"Glynn Foster <glynn foster sun com>",
|
||||||
"Glynn Foster <glynn foster sun com>",
|
"Lucas Rocha <lucasr gnome org>",
|
||||||
"Lucas Rocha <lucasr gnome org>",
|
"Mike Newman <mikegtn gnome org>",
|
||||||
"Mike Newman <mikegtn gnome org>",
|
NULL};
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static const char *documenters[] = {
|
static const char *documenters[] = {"Glynn Foster <glynn.foster@sun.com>",
|
||||||
"Glynn Foster <glynn.foster@sun.com>",
|
"Lucas Rocha <lucasr@gnome.org>",
|
||||||
"Lucas Rocha <lucasr@gnome.org>",
|
"Java Desktop System Documentation Team",
|
||||||
"Java Desktop System Documentation Team",
|
"GNOME Documentation Project",
|
||||||
"GNOME Documentation Project",
|
NULL};
|
||||||
NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
static gchar *translators;
|
static gchar *translators;
|
||||||
|
|
||||||
static const char *license[] = {
|
static const char *license[] = {
|
||||||
N_("This program is free software; you can redistribute it and/or modify "
|
N_ ("This program is free software; you can redistribute it and/or modify "
|
||||||
"it under the terms of the GNU Lesser General Public License as published by "
|
"it under the terms of the GNU Lesser General Public License as "
|
||||||
"the Free Software Foundation; either version 2 of the License, or "
|
"published by "
|
||||||
"(at your option) any later version.\n"),
|
"the Free Software Foundation; either version 2 of the License, or "
|
||||||
N_("This program is distributed in the hope that it will be useful, "
|
"(at your option) any later version.\n"),
|
||||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
N_ ("This program is distributed in the hope that it will be useful, "
|
||||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
|
"but WITHOUT ANY WARRANTY; without even the implied warranty of "
|
||||||
"GNU Lesser General Public License for more details.\n"),
|
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the "
|
||||||
N_("You should have received a copy of the GNU Lesser General Public License "
|
"GNU Lesser General Public License for more details.\n"),
|
||||||
"along with this program; if not, write to the Free Software "
|
N_ ("You should have received a copy of the GNU Lesser General Public "
|
||||||
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.")
|
"License "
|
||||||
};
|
"along with this program; if not, write to the Free Software "
|
||||||
|
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA "
|
||||||
|
"02110-1301, USA.")};
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static gint
|
static gint
|
||||||
@ -253,66 +252,78 @@ zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_about (ZenityData *data)
|
zenity_about (ZenityData *data) {
|
||||||
{
|
GdkPixbuf *logo;
|
||||||
GdkPixbuf *logo;
|
char *license_trans;
|
||||||
char *license_trans;
|
|
||||||
|
|
||||||
|
translators = _ ("translator-credits");
|
||||||
|
logo =
|
||||||
|
gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL);
|
||||||
|
|
||||||
translators = _("translator-credits");
|
license_trans = g_strconcat (
|
||||||
logo = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL);
|
_ (license[0]), "\n", _ (license[1]), "\n", _ (license[2]), "\n", NULL);
|
||||||
|
|
||||||
license_trans = g_strconcat (_(license[0]), "\n", _(license[1]), "\n",
|
dialog = gtk_about_dialog_new ();
|
||||||
_(license[2]), "\n", NULL);
|
|
||||||
|
|
||||||
dialog = gtk_about_dialog_new ();
|
g_object_set (G_OBJECT (dialog),
|
||||||
|
"name",
|
||||||
g_object_set (G_OBJECT (dialog),
|
"Zenity",
|
||||||
"name", "Zenity",
|
"version",
|
||||||
"version", VERSION,
|
VERSION,
|
||||||
"copyright", "Copyright \xc2\xa9 2003 Sun Microsystems",
|
"copyright",
|
||||||
"comments", _("Display dialog boxes from shell scripts"),
|
"Copyright \xc2\xa9 2003 Sun Microsystems",
|
||||||
"authors", authors,
|
"comments",
|
||||||
"documenters", documenters,
|
_ ("Display dialog boxes from shell scripts"),
|
||||||
"translator-credits", translators,
|
"authors",
|
||||||
"website", "http://live.gnome.org/Zenity",
|
authors,
|
||||||
"logo", logo,
|
"documenters",
|
||||||
"wrap-license", TRUE,
|
documenters,
|
||||||
"license", license_trans,
|
"translator-credits",
|
||||||
|
translators,
|
||||||
|
"website",
|
||||||
|
"http://live.gnome.org/Zenity",
|
||||||
|
"logo",
|
||||||
|
logo,
|
||||||
|
"wrap-license",
|
||||||
|
TRUE,
|
||||||
|
"license",
|
||||||
|
license_trans,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
g_free (license_trans);
|
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
g_free (license_trans);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
zenity_util_set_window_icon (
|
||||||
G_CALLBACK (zenity_about_dialog_response), data);
|
dialog, NULL, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (zenity_about_dialog_response),
|
||||||
|
data);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
g_signal_connect (G_OBJECT (dialog), "key_press_event",
|
g_signal_connect (G_OBJECT (dialog), "key_press_event",
|
||||||
G_CALLBACK (zenity_zen_wisdom), NULL);
|
G_CALLBACK (zenity_zen_wisdom), NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_about_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityData *zen_data = data;
|
||||||
ZenityData *zen_data = data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_CLOSE:
|
case GTK_RESPONSE_CLOSE:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Esc dialog */
|
/* Esc dialog */
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
220
src/calendar.c
220
src/calendar.c
@ -23,146 +23,158 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <time.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
static GtkWidget *calendar;
|
static GtkWidget *calendar;
|
||||||
static ZenityCalendarData *zen_cal_data;
|
static ZenityCalendarData *zen_cal_data;
|
||||||
|
|
||||||
static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_calendar_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data);
|
static void zenity_calendar_double_click (GtkCalendar *calendar, gpointer data);
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data) {
|
||||||
{
|
GtkBuilder *builder;
|
||||||
GtkBuilder *builder;
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *button;
|
||||||
GtkWidget *button;
|
GObject *text;
|
||||||
GObject *text;
|
|
||||||
|
|
||||||
zen_cal_data = cal_data;
|
zen_cal_data = cal_data;
|
||||||
|
|
||||||
builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_calendar_dialog", NULL);
|
||||||
|
|
||||||
if (builder == NULL) {
|
if (builder == NULL) {
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder,
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
"zenity_calendar_dialog"));
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
dialog =
|
||||||
G_CALLBACK (zenity_calendar_dialog_response), data);
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_dialog"));
|
||||||
|
|
||||||
if (data->dialog_title)
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
"response",
|
||||||
|
G_CALLBACK (zenity_calendar_dialog_response),
|
||||||
|
data);
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
if (data->dialog_title)
|
||||||
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
zenity_util_set_window_icon (dialog,
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
data->window_icon,
|
||||||
|
ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
||||||
|
|
||||||
if (data->modal)
|
if (data->width > -1 || data->height > -1)
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_default_size (
|
||||||
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
text = gtk_builder_get_object (builder, "zenity_calendar_text");
|
if (data->modal)
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
if (cal_data->dialog_text)
|
text = gtk_builder_get_object (builder, "zenity_calendar_text");
|
||||||
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (cal_data->dialog_text));
|
|
||||||
|
|
||||||
calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar"));
|
if (cal_data->dialog_text)
|
||||||
|
gtk_label_set_markup (
|
||||||
if (cal_data->month > 0 || cal_data->year > 0)
|
GTK_LABEL (text), g_strcompress (cal_data->dialog_text));
|
||||||
gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
|
|
||||||
if (cal_data->day > 0)
|
|
||||||
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
|
|
||||||
|
|
||||||
g_signal_connect (calendar, "day-selected-double-click",
|
calendar = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar"));
|
||||||
G_CALLBACK (zenity_calendar_double_click), data);
|
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
|
if (cal_data->month > 0 || cal_data->year > 0)
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
gtk_calendar_select_month (
|
||||||
|
GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
|
||||||
|
if (cal_data->day > 0)
|
||||||
|
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
|
||||||
|
|
||||||
if (data->timeout_delay > 0) {
|
g_signal_connect (calendar,
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
"day-selected-double-click",
|
||||||
}
|
G_CALLBACK (zenity_calendar_double_click),
|
||||||
|
data);
|
||||||
if (data->extra_label) {
|
|
||||||
gint i=0;
|
|
||||||
while(data->extra_label[i]!=NULL){
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->ok_label) {
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_ok_button"));
|
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->cancel_label) {
|
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_calendar_cancel_button"));
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (builder);
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main ();
|
if (data->extra_label) {
|
||||||
|
gint i = 0;
|
||||||
|
while (data->extra_label[i] != NULL) {
|
||||||
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->ok_label) {
|
||||||
|
button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_calendar_ok_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->cancel_label) {
|
||||||
|
button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_calendar_cancel_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
static void
|
static void
|
||||||
zenity_calendar_dialog_output (void)
|
zenity_calendar_dialog_output (void) {
|
||||||
{
|
guint day, month, year;
|
||||||
guint day, month, year;
|
gchar time_string[128];
|
||||||
gchar time_string[128];
|
GDate *date = NULL;
|
||||||
GDate *date = NULL;
|
|
||||||
|
|
||||||
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
|
||||||
date = g_date_new_dmy (year, month + 1, day);
|
|
||||||
g_date_strftime (time_string, 127, zen_cal_data->date_format, date);
|
|
||||||
g_print ("%s\n", time_string);
|
|
||||||
|
|
||||||
if (date != NULL)
|
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
||||||
g_date_free (date);
|
date = g_date_new_dmy (year, month + 1, day);
|
||||||
|
g_date_strftime (time_string, 127, zen_cal_data->date_format, date);
|
||||||
|
g_print ("%s\n", time_string);
|
||||||
|
|
||||||
|
if (date != NULL)
|
||||||
|
g_date_free (date);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_calendar_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_calendar_dialog_response (
|
||||||
{
|
GtkWidget *widget, int response, gpointer data) {
|
||||||
ZenityData *zen_data;
|
ZenityData *zen_data;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_calendar_dialog_output ();
|
zenity_calendar_dialog_output ();
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zenity_calendar_dialog_output ();
|
zenity_calendar_dialog_output ();
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_calendar_double_click (GtkCalendar *cal, gpointer data)
|
zenity_calendar_double_click (GtkCalendar *cal, gpointer data) {
|
||||||
{
|
zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data);
|
||||||
zenity_calendar_dialog_response (NULL, GTK_RESPONSE_OK, data);
|
|
||||||
}
|
}
|
||||||
|
132
src/color.c
132
src/color.c
@ -23,92 +23,96 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static ZenityData *zen_data;
|
static ZenityData *zen_data;
|
||||||
|
|
||||||
static void zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_colorselection_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
void zenity_colorselection (ZenityData *data, ZenityColorData *color_data)
|
void
|
||||||
{
|
zenity_colorselection (ZenityData *data, ZenityColorData *color_data) {
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL);
|
dialog = gtk_color_chooser_dialog_new (data->dialog_title, NULL);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
G_CALLBACK (zenity_colorselection_dialog_response),
|
"response",
|
||||||
color_data);
|
G_CALLBACK (zenity_colorselection_dialog_response),
|
||||||
|
color_data);
|
||||||
|
|
||||||
if (color_data->color) {
|
if (color_data->color) {
|
||||||
if (gdk_rgba_parse (&color, color_data->color)) {
|
if (gdk_rgba_parse (&color, color_data->color)) {
|
||||||
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
|
gtk_color_chooser_set_rgba (GTK_COLOR_CHOOSER (dialog), &color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (data->extra_label) {
|
||||||
gint i=0;
|
gint i = 0;
|
||||||
while(data->extra_label[i]!=NULL){
|
while (data->extra_label[i] != NULL) {
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
gtk_dialog_add_button (
|
||||||
i++;
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (data->ok_label) {
|
||||||
g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
|
g_object_get (G_OBJECT (dialog), "ok-button", &button, NULL);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
g_object_unref (G_OBJECT (button));
|
g_object_unref (G_OBJECT (button));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (data->cancel_label) {
|
||||||
g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL);
|
g_object_get (G_OBJECT (dialog), "cancel-button", &button, NULL);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
g_object_unref (G_OBJECT (button));
|
g_object_unref (G_OBJECT (button));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->modal)
|
if (data->modal)
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
g_object_set (dialog, "show-editor", !color_data->show_palette, NULL);
|
g_object_set (dialog, "show-editor", !color_data->show_palette, NULL);
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
if (data->timeout_delay > 0) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay,
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
(GSourceFunc) zenity_util_timeout_handle,
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
dialog);
|
dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_main();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_colorselection_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_colorselection_dialog_response (
|
||||||
{
|
GtkWidget *widget, int response, gpointer data) {
|
||||||
GdkRGBA color;
|
GdkRGBA color;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color);
|
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (widget), &color);
|
||||||
g_print ("%s\n", gdk_rgba_to_string (&color));
|
g_print ("%s\n", gdk_rgba_to_string (&color));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
268
src/entry.c
268
src/entry.c
@ -23,179 +23,189 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
|
||||||
static void zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_entry_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
static GtkWidget *entry;
|
static GtkWidget *entry;
|
||||||
static gint n_entries = 0;
|
static gint n_entries = 0;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_entry_fill_entries (GSList **entries, const gchar **args)
|
zenity_entry_fill_entries (GSList **entries, const gchar **args) {
|
||||||
{
|
gint i = 0;
|
||||||
gint i = 0;
|
|
||||||
|
|
||||||
while (args[i] != NULL) {
|
while (args[i] != NULL) {
|
||||||
*entries = g_slist_append (*entries, (gchar *) args[i]);
|
*entries = g_slist_append (*entries, (gchar *) args[i]);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window)
|
zenity_entry_combo_activate_default (GtkEntry *entry, gpointer window) {
|
||||||
{
|
gtk_window_activate_default (GTK_WINDOW (window));
|
||||||
gtk_window_activate_default (GTK_WINDOW (window));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
zenity_entry (ZenityData *data, ZenityEntryData *entry_data) {
|
||||||
{
|
GtkBuilder *builder = NULL;
|
||||||
GtkBuilder *builder = NULL;
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *button;
|
||||||
GtkWidget *button;
|
GObject *text;
|
||||||
GObject *text;
|
GSList *entries = NULL;
|
||||||
GSList *entries = NULL;
|
GSList *tmp;
|
||||||
GSList *tmp;
|
GObject *vbox;
|
||||||
GObject *vbox;
|
|
||||||
|
|
||||||
builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL);
|
|
||||||
|
|
||||||
if (builder == NULL) {
|
builder = zenity_util_load_ui_file ("zenity_entry_dialog", NULL);
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog"));
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
|
||||||
G_CALLBACK (zenity_entry_dialog_response), data);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
if (builder == NULL) {
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
|
return;
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
}
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
|
||||||
|
|
||||||
if (data->modal)
|
dialog =
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_dialog"));
|
||||||
|
|
||||||
if (data->extra_label) {
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
gint i=0;
|
"response",
|
||||||
while(data->extra_label[i]!=NULL){
|
G_CALLBACK (zenity_entry_dialog_response),
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
data);
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (data->dialog_title)
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_ok_button"));
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->cancel_label) {
|
zenity_util_set_window_icon (
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_entry_cancel_button"));
|
dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
text = gtk_builder_get_object (builder, "zenity_entry_text");
|
if (data->width > -1 || data->height > -1)
|
||||||
|
gtk_window_set_default_size (
|
||||||
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
if (entry_data->dialog_text)
|
if (data->modal)
|
||||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (text), g_strcompress (entry_data->dialog_text));
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
vbox = gtk_builder_get_object (builder, "vbox4");
|
|
||||||
|
|
||||||
zenity_entry_fill_entries(&entries, entry_data->data);
|
|
||||||
|
|
||||||
n_entries = g_slist_length (entries);
|
|
||||||
|
|
||||||
if (n_entries > 1) {
|
if (data->extra_label) {
|
||||||
entry = gtk_combo_box_text_new_with_entry ();
|
gint i = 0;
|
||||||
|
while (data->extra_label[i] != NULL) {
|
||||||
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (tmp = entries; tmp; tmp = tmp->next) {
|
if (data->ok_label) {
|
||||||
gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (entry), tmp->data);
|
button = GTK_WIDGET (
|
||||||
}
|
gtk_builder_get_object (builder, "zenity_entry_ok_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
|
}
|
||||||
|
|
||||||
if (entry_data->entry_text) {
|
if (data->cancel_label) {
|
||||||
gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text);
|
button = GTK_WIDGET (
|
||||||
gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0);
|
gtk_builder_get_object (builder, "zenity_entry_cancel_button"));
|
||||||
}
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)), "activate",
|
text = gtk_builder_get_object (builder, "zenity_entry_text");
|
||||||
G_CALLBACK (zenity_entry_combo_activate_default),
|
|
||||||
GTK_WINDOW (dialog));
|
|
||||||
} else {
|
|
||||||
entry = gtk_entry_new();
|
|
||||||
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
if (entry_data->dialog_text)
|
||||||
|
gtk_label_set_text_with_mnemonic (
|
||||||
if (entry_data->entry_text)
|
GTK_LABEL (text), g_strcompress (entry_data->dialog_text));
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
|
|
||||||
|
|
||||||
if (entry_data->hide_text)
|
vbox = gtk_builder_get_object (builder, "vbox4");
|
||||||
g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_show (entry);
|
zenity_entry_fill_entries (&entries, entry_data->data);
|
||||||
|
|
||||||
gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
|
n_entries = g_slist_length (entries);
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);
|
if (n_entries > 1) {
|
||||||
|
entry = gtk_combo_box_text_new_with_entry ();
|
||||||
|
|
||||||
g_object_unref (builder);
|
for (tmp = entries; tmp; tmp = tmp->next) {
|
||||||
|
gtk_combo_box_text_append_text (
|
||||||
|
GTK_COMBO_BOX_TEXT (entry), tmp->data);
|
||||||
|
}
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
if (entry_data->entry_text) {
|
||||||
|
gtk_combo_box_text_prepend_text (
|
||||||
|
GTK_COMBO_BOX_TEXT (entry), entry_data->entry_text);
|
||||||
|
gtk_combo_box_set_active (GTK_COMBO_BOX (entry), 0);
|
||||||
|
}
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
g_signal_connect (gtk_bin_get_child (GTK_BIN (entry)),
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
"activate",
|
||||||
}
|
G_CALLBACK (zenity_entry_combo_activate_default),
|
||||||
|
GTK_WINDOW (dialog));
|
||||||
|
} else {
|
||||||
|
entry = gtk_entry_new ();
|
||||||
|
|
||||||
gtk_main ();
|
gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE);
|
||||||
|
|
||||||
|
if (entry_data->entry_text)
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
|
||||||
|
|
||||||
|
if (entry_data->hide_text)
|
||||||
|
g_object_set (G_OBJECT (entry), "visibility", FALSE, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_show (entry);
|
||||||
|
|
||||||
|
gtk_box_pack_end (GTK_BOX (vbox), entry, FALSE, FALSE, 0);
|
||||||
|
|
||||||
|
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_entry_dialog_output (void)
|
zenity_entry_dialog_output (void) {
|
||||||
{
|
const gchar *text;
|
||||||
const gchar *text;
|
if (n_entries > 1)
|
||||||
if (n_entries > 1)
|
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry));
|
||||||
text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (entry));
|
else
|
||||||
else
|
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
|
||||||
|
|
||||||
if (text != NULL)
|
|
||||||
g_print ("%s\n", text);
|
|
||||||
|
|
||||||
|
if (text != NULL)
|
||||||
|
g_print ("%s\n", text);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_entry_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityData *zen_data = data;
|
||||||
ZenityData *zen_data = data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_entry_dialog_output ();
|
zenity_entry_dialog_output ();
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zenity_entry_dialog_output ();
|
zenity_entry_dialog_output ();
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
@ -23,176 +23,192 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static ZenityData *zen_data;
|
static ZenityData *zen_data;
|
||||||
|
|
||||||
static void zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_fileselection_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
|
void
|
||||||
{
|
zenity_fileselection (ZenityData *data, ZenityFileData *file_data) {
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
gchar *dir;
|
gchar *dir;
|
||||||
gchar *basename;
|
gchar *basename;
|
||||||
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
GtkFileChooserAction action = GTK_FILE_CHOOSER_ACTION_OPEN;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
if (file_data->directory) {
|
if (file_data->directory) {
|
||||||
if (file_data->save)
|
if (file_data->save)
|
||||||
action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
|
action = GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER;
|
||||||
else
|
else
|
||||||
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
action = GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER;
|
||||||
} else {
|
} else {
|
||||||
if (file_data->save)
|
if (file_data->save)
|
||||||
action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
action = GTK_FILE_CHOOSER_ACTION_SAVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog = gtk_file_chooser_dialog_new (NULL, NULL,
|
dialog = gtk_file_chooser_dialog_new (NULL,
|
||||||
action,
|
NULL,
|
||||||
_("_Cancel"), GTK_RESPONSE_CANCEL,
|
action,
|
||||||
_("_OK"), GTK_RESPONSE_OK,
|
_ ("_Cancel"),
|
||||||
NULL);
|
GTK_RESPONSE_CANCEL,
|
||||||
|
_ ("_OK"),
|
||||||
|
GTK_RESPONSE_OK,
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog),
|
gtk_file_chooser_set_do_overwrite_confirmation (
|
||||||
file_data->confirm_overwrite);
|
GTK_FILE_CHOOSER (dialog), file_data->confirm_overwrite);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
G_CALLBACK (zenity_fileselection_dialog_response), file_data);
|
"response",
|
||||||
|
G_CALLBACK (zenity_fileselection_dialog_response),
|
||||||
|
file_data);
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (data->extra_label) {
|
||||||
gint i=0;
|
gint i = 0;
|
||||||
while(data->extra_label[i]!=NULL){
|
while (data->extra_label[i] != NULL) {
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
gtk_dialog_add_button (
|
||||||
i++;
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data->dialog_title)
|
if (data->dialog_title)
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
|
||||||
|
|
||||||
if (data->modal)
|
zenity_util_set_window_icon (
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
||||||
|
|
||||||
if (file_data->uri) {
|
if (data->modal)
|
||||||
dir = g_path_get_dirname (file_data->uri);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
if (g_path_is_absolute (file_data->uri) == TRUE)
|
if (file_data->uri) {
|
||||||
gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), dir);
|
dir = g_path_get_dirname (file_data->uri);
|
||||||
|
|
||||||
if (file_data->uri[strlen (file_data->uri) - 1] != '/') {
|
if (g_path_is_absolute (file_data->uri) == TRUE)
|
||||||
basename = g_path_get_basename (file_data->uri);
|
gtk_file_chooser_set_current_folder (
|
||||||
if (file_data->save)
|
GTK_FILE_CHOOSER (dialog), dir);
|
||||||
gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename);
|
|
||||||
else
|
|
||||||
(void) gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), file_data->uri);
|
|
||||||
g_free (basename);
|
|
||||||
}
|
|
||||||
g_free (dir);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file_data->multi)
|
if (file_data->uri[strlen (file_data->uri) - 1] != '/') {
|
||||||
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
|
basename = g_path_get_basename (file_data->uri);
|
||||||
|
if (file_data->save)
|
||||||
|
gtk_file_chooser_set_current_name (
|
||||||
|
GTK_FILE_CHOOSER (dialog), basename);
|
||||||
|
else
|
||||||
|
(void) gtk_file_chooser_set_filename (
|
||||||
|
GTK_FILE_CHOOSER (dialog), file_data->uri);
|
||||||
|
g_free (basename);
|
||||||
|
}
|
||||||
|
g_free (dir);
|
||||||
|
}
|
||||||
|
|
||||||
if (file_data->filter) {
|
if (file_data->multi)
|
||||||
/* Filter format: Executables | *.exe *.bat *.com */
|
gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (dialog), TRUE);
|
||||||
gint filter_i;
|
|
||||||
|
|
||||||
for (filter_i = 0; file_data->filter [filter_i]; filter_i++) {
|
if (file_data->filter) {
|
||||||
GtkFileFilter *filter = gtk_file_filter_new();
|
/* Filter format: Executables | *.exe *.bat *.com */
|
||||||
gchar *filter_str = file_data->filter [filter_i];
|
gint filter_i;
|
||||||
gchar **pattern, **patterns;
|
|
||||||
gchar *name = NULL;
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
/* Set name */
|
for (filter_i = 0; file_data->filter[filter_i]; filter_i++) {
|
||||||
for (i = 0; filter_str[i] != '\0'; i++)
|
GtkFileFilter *filter = gtk_file_filter_new ();
|
||||||
if (filter_str[i] == '|')
|
gchar *filter_str = file_data->filter[filter_i];
|
||||||
break;
|
gchar **pattern, **patterns;
|
||||||
|
gchar *name = NULL;
|
||||||
|
gint i;
|
||||||
|
|
||||||
if (filter_str[i] == '|') {
|
/* Set name */
|
||||||
name = g_strndup (filter_str, i);
|
for (i = 0; filter_str[i] != '\0'; i++)
|
||||||
g_strstrip (name);
|
if (filter_str[i] == '|')
|
||||||
}
|
break;
|
||||||
|
|
||||||
if (name) {
|
if (filter_str[i] == '|') {
|
||||||
gtk_file_filter_set_name (filter, name);
|
name = g_strndup (filter_str, i);
|
||||||
|
g_strstrip (name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Point i to the right position for split */
|
if (name) {
|
||||||
for (++i; filter_str[i] == ' '; i++);
|
gtk_file_filter_set_name (filter, name);
|
||||||
} else {
|
|
||||||
gtk_file_filter_set_name (filter, filter_str);
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Get patterns */
|
/* Point i to the right position for split */
|
||||||
patterns = g_strsplit_set (filter_str + i, " ", -1);
|
for (++i; filter_str[i] == ' '; i++)
|
||||||
|
;
|
||||||
|
} else {
|
||||||
|
gtk_file_filter_set_name (filter, filter_str);
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (pattern = patterns; *pattern; pattern++)
|
/* Get patterns */
|
||||||
gtk_file_filter_add_pattern (filter, *pattern);
|
patterns = g_strsplit_set (filter_str + i, " ", -1);
|
||||||
|
|
||||||
if (name)
|
for (pattern = patterns; *pattern; pattern++)
|
||||||
g_free (name);
|
gtk_file_filter_add_pattern (filter, *pattern);
|
||||||
|
|
||||||
g_strfreev (patterns);
|
if (name)
|
||||||
|
g_free (name);
|
||||||
|
|
||||||
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
g_strfreev (patterns);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_main ();
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_fileselection_dialog_output (GtkWidget *widget, ZenityFileData *file_data)
|
zenity_fileselection_dialog_output (
|
||||||
{
|
GtkWidget *widget, ZenityFileData *file_data) {
|
||||||
GSList *selections, *iter;
|
GSList *selections, *iter;
|
||||||
selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget));
|
selections = gtk_file_chooser_get_filenames (GTK_FILE_CHOOSER (widget));
|
||||||
for (iter = selections;iter != NULL; iter = iter->next) {
|
for (iter = selections; iter != NULL; iter = iter->next) {
|
||||||
g_print ("%s", g_filename_to_utf8 ((gchar*)iter->data, -1, NULL, NULL, NULL));
|
g_print ("%s",
|
||||||
g_free (iter->data);
|
g_filename_to_utf8 ((gchar *) iter->data, -1, NULL, NULL, NULL));
|
||||||
if (iter->next != NULL)
|
g_free (iter->data);
|
||||||
g_print ("%s",file_data->separator);
|
if (iter->next != NULL)
|
||||||
}
|
g_print ("%s", file_data->separator);
|
||||||
g_print("\n");
|
}
|
||||||
g_slist_free(selections);
|
g_print ("\n");
|
||||||
|
g_slist_free (selections);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_fileselection_dialog_response (
|
||||||
{
|
GtkWidget *widget, int response, gpointer data) {
|
||||||
ZenityFileData *file_data = data;
|
ZenityFileData *file_data = data;
|
||||||
|
|
||||||
switch (response) {
|
|
||||||
case GTK_RESPONSE_OK:
|
|
||||||
zenity_fileselection_dialog_output (widget, file_data);
|
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
switch (response) {
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
case GTK_RESPONSE_OK:
|
||||||
break;
|
zenity_fileselection_dialog_output (widget, file_data);
|
||||||
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zenity_fileselection_dialog_output (widget, file_data);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
case ZENITY_TIMEOUT:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
zenity_fileselection_dialog_output (widget, file_data);
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
break;
|
||||||
break;
|
|
||||||
}
|
default:
|
||||||
gtk_main_quit ();
|
if (zen_data->extra_label &&
|
||||||
|
response < g_strv_length (zen_data->extra_label))
|
||||||
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
620
src/forms.c
620
src/forms.c
@ -22,360 +22,390 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <string.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static ZenityData *zen_data;
|
static ZenityData *zen_data;
|
||||||
static GSList *selected;
|
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)
|
static void
|
||||||
{
|
zenity_forms_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf,
|
||||||
gint n_columns = 0;
|
GtkTreeIter *iter, GtkTreeView *tree_view) {
|
||||||
gint i = 0;
|
gint n_columns = 0;
|
||||||
GValue value = {0, };
|
gint i = 0;
|
||||||
|
GValue value = {
|
||||||
|
0,
|
||||||
|
};
|
||||||
|
|
||||||
n_columns = gtk_tree_model_get_n_columns (model);
|
n_columns = gtk_tree_model_get_n_columns (model);
|
||||||
for (i = 0; i < n_columns; i++) {
|
for (i = 0; i < n_columns; i++) {
|
||||||
gtk_tree_model_get_value (model, iter, i, &value);
|
gtk_tree_model_get_value (model, iter, i, &value);
|
||||||
selected = g_slist_append (selected, g_value_dup_string (&value));
|
selected = g_slist_append (selected, g_value_dup_string (&value));
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
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;
|
GtkListStore *list_store;
|
||||||
GtkWidget *combo_box;
|
GtkWidget *combo_box;
|
||||||
GtkCellRenderer *renderer;
|
GtkCellRenderer *renderer;
|
||||||
gchar *combo_values;
|
gchar *combo_values;
|
||||||
|
|
||||||
list_store = gtk_list_store_new (1, G_TYPE_STRING);
|
list_store = gtk_list_store_new (1, G_TYPE_STRING);
|
||||||
|
|
||||||
if (forms_data->combo_values) {
|
if (forms_data->combo_values) {
|
||||||
combo_values = g_slist_nth_data (forms_data->combo_values, combo_number);
|
combo_values =
|
||||||
if (combo_values) {
|
g_slist_nth_data (forms_data->combo_values, combo_number);
|
||||||
gchar **row_values = g_strsplit_set (combo_values, "|", -1);
|
if (combo_values) {
|
||||||
if (row_values) {
|
gchar **row_values = g_strsplit_set (combo_values, "|", -1);
|
||||||
gint i = 0;
|
if (row_values) {
|
||||||
GtkTreeIter iter;
|
gint i = 0;
|
||||||
gchar *row = row_values[i];
|
GtkTreeIter iter;
|
||||||
|
gchar *row = row_values[i];
|
||||||
|
|
||||||
while (row != NULL) {
|
while (row != NULL) {
|
||||||
gtk_list_store_append (list_store, &iter);
|
gtk_list_store_append (list_store, &iter);
|
||||||
gtk_list_store_set (list_store, &iter, 0, row, -1);
|
gtk_list_store_set (list_store, &iter, 0, row, -1);
|
||||||
row = row_values[++i];
|
row = row_values[++i];
|
||||||
}
|
}
|
||||||
g_strfreev (row_values);
|
g_strfreev (row_values);
|
||||||
}
|
}
|
||||||
g_free (combo_values);
|
g_free (combo_values);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
|
combo_box = gtk_combo_box_new_with_model (GTK_TREE_MODEL (list_store));
|
||||||
g_object_unref (G_OBJECT (list_store));
|
g_object_unref (G_OBJECT (list_store));
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE);
|
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_set_attributes (
|
||||||
|
GTK_CELL_LAYOUT (combo_box), renderer, "text", 0, NULL);
|
||||||
|
|
||||||
return combo_box;
|
return combo_box;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
zenity_forms_create_and_fill_list (ZenityFormsData *forms_data,
|
zenity_forms_create_and_fill_list (
|
||||||
int list_number, gchar *header)
|
ZenityFormsData *forms_data, int list_number, gchar *header) {
|
||||||
{
|
GtkListStore *list_store;
|
||||||
GtkListStore *list_store;
|
GtkWidget *tree_view;
|
||||||
GtkWidget *tree_view;
|
GtkWidget *scrolled_window;
|
||||||
GtkWidget *scrolled_window;
|
GtkCellRenderer *renderer;
|
||||||
GtkCellRenderer *renderer;
|
GtkTreeViewColumn *column;
|
||||||
GtkTreeViewColumn *column;
|
GType *column_types = NULL;
|
||||||
GType *column_types = NULL;
|
gchar *list_values;
|
||||||
gchar *list_values;
|
gchar *column_values;
|
||||||
gchar *column_values;
|
|
||||||
|
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
/* If no column names available, default is one */
|
/* If no column names available, default is one */
|
||||||
gint n_columns = 1;
|
gint n_columns = 1;
|
||||||
gint column_index = 0;
|
gint column_index = 0;
|
||||||
|
|
||||||
tree_view = gtk_tree_view_new ();
|
tree_view = gtk_tree_view_new ();
|
||||||
|
|
||||||
if (forms_data->column_values) {
|
if (forms_data->column_values) {
|
||||||
column_values = g_slist_nth_data (forms_data->column_values, list_number);
|
column_values =
|
||||||
if (column_values) {
|
g_slist_nth_data (forms_data->column_values, list_number);
|
||||||
gchar **values = g_strsplit_set (column_values, "|", -1);
|
if (column_values) {
|
||||||
if (values) {
|
gchar **values = g_strsplit_set (column_values, "|", -1);
|
||||||
n_columns = g_strv_length (values);
|
if (values) {
|
||||||
column_types = g_new (GType, n_columns);
|
n_columns = g_strv_length (values);
|
||||||
for (i = 0; i < n_columns; i++)
|
column_types = g_new (GType, n_columns);
|
||||||
column_types[i] = G_TYPE_STRING;
|
for (i = 0; i < n_columns; i++)
|
||||||
|
column_types[i] = G_TYPE_STRING;
|
||||||
|
|
||||||
for (i = 0; i < n_columns; i++) {
|
for (i = 0; i < n_columns; i++) {
|
||||||
gchar *column_name = values[i];
|
gchar *column_name = values[i];
|
||||||
renderer = gtk_cell_renderer_text_new ();
|
renderer = gtk_cell_renderer_text_new ();
|
||||||
column = gtk_tree_view_column_new_with_attributes (column_name,
|
column = gtk_tree_view_column_new_with_attributes (
|
||||||
renderer,
|
column_name, renderer, "text", column_index, NULL);
|
||||||
"text", column_index,
|
gtk_tree_view_append_column (
|
||||||
NULL);
|
GTK_TREE_VIEW (tree_view), column);
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
column_index++;
|
||||||
column_index++;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
list_store = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
list_store = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
||||||
|
|
||||||
gtk_list_store_set_column_types (list_store, n_columns, column_types);
|
gtk_list_store_set_column_types (list_store, n_columns, column_types);
|
||||||
|
|
||||||
if (forms_data->list_values) {
|
if (forms_data->list_values) {
|
||||||
list_values = g_slist_nth_data (forms_data->list_values, list_number);
|
list_values = g_slist_nth_data (forms_data->list_values, list_number);
|
||||||
if (list_values) {
|
if (list_values) {
|
||||||
gchar **row_values = g_strsplit_set (list_values, "|", -1);
|
gchar **row_values = g_strsplit_set (list_values, "|", -1);
|
||||||
if (row_values) {
|
if (row_values) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *row = row_values[0];
|
gchar *row = row_values[0];
|
||||||
gint position = -1;
|
gint position = -1;
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (row != NULL) {
|
|
||||||
if (position >= n_columns || position == -1) {
|
|
||||||
position = 0;
|
|
||||||
gtk_list_store_append (list_store, &iter);
|
|
||||||
}
|
|
||||||
gtk_list_store_set (list_store, &iter, position, row, -1);
|
|
||||||
position++;
|
|
||||||
row = row_values[++i];
|
|
||||||
}
|
|
||||||
g_strfreev (row_values);
|
|
||||||
}
|
|
||||||
g_free (list_values);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store));
|
while (row != NULL) {
|
||||||
g_object_unref (list_store);
|
if (position >= n_columns || position == -1) {
|
||||||
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
position = 0;
|
||||||
//gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (scrolled_window),
|
gtk_list_store_append (list_store, &iter);
|
||||||
// GTK_WIDGET (tree_view));
|
}
|
||||||
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view));
|
gtk_list_store_set (list_store, &iter, position, row, -1);
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100);
|
position++;
|
||||||
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), forms_data->show_header);
|
row = row_values[++i];
|
||||||
|
}
|
||||||
|
g_strfreev (row_values);
|
||||||
|
}
|
||||||
|
g_free (list_values);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return scrolled_window;
|
gtk_tree_view_set_model (
|
||||||
|
GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (list_store));
|
||||||
|
g_object_unref (list_store);
|
||||||
|
scrolled_window = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
// gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW
|
||||||
|
// (scrolled_window),
|
||||||
|
// GTK_WIDGET (tree_view));
|
||||||
|
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET (tree_view));
|
||||||
|
gtk_widget_set_size_request (GTK_WIDGET (scrolled_window), -1, 100);
|
||||||
|
gtk_tree_view_set_headers_visible (
|
||||||
|
GTK_TREE_VIEW (tree_view), forms_data->show_header);
|
||||||
|
|
||||||
|
return scrolled_window;
|
||||||
}
|
}
|
||||||
|
|
||||||
void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data)
|
void
|
||||||
{
|
zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data) {
|
||||||
GtkBuilder *builder = NULL;
|
GtkBuilder *builder = NULL;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *grid;
|
GtkWidget *grid;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
int list_count = 0;
|
int list_count = 0;
|
||||||
int combo_count = 0;
|
int combo_count = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
builder = zenity_util_load_ui_file("zenity_forms_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_forms_dialog", NULL);
|
||||||
|
|
||||||
if (builder == NULL) {
|
if (builder == NULL) {
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_builder_connect_signals(builder, NULL);
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog"));
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT(dialog), "response",
|
dialog =
|
||||||
G_CALLBACK (zenity_forms_dialog_response), forms_data);
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_dialog"));
|
||||||
|
|
||||||
if (data->dialog_title)
|
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
"response",
|
||||||
|
G_CALLBACK (zenity_forms_dialog_response),
|
||||||
|
forms_data);
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (data->dialog_title)
|
||||||
gint i=0;
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
while(data->extra_label[i]!=NULL){
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (data->width > -1 || data->height > -1)
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_ok_button"));
|
gtk_window_set_default_size (
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
}
|
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (data->extra_label) {
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_cancel_button"));
|
gint i = 0;
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
while (data->extra_label[i] != NULL) {
|
||||||
}
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text"));
|
if (data->ok_label) {
|
||||||
|
button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_forms_ok_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
|
}
|
||||||
|
|
||||||
if (forms_data->dialog_text)
|
if (data->cancel_label) {
|
||||||
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (forms_data->dialog_text));
|
button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_forms_cancel_button"));
|
||||||
grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid"));
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
|
}
|
||||||
|
|
||||||
for (tmp = forms_data->list; tmp; tmp = tmp->next) {
|
text = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_text"));
|
||||||
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
|
||||||
GtkWidget *label;
|
|
||||||
|
|
||||||
label = gtk_label_new(zenity_value->option_value);
|
|
||||||
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
|
||||||
gtk_grid_attach (GTK_GRID (grid),
|
|
||||||
label,
|
|
||||||
0, i,
|
|
||||||
1, 1);
|
|
||||||
|
|
||||||
switch(zenity_value->type)
|
|
||||||
{
|
|
||||||
case ZENITY_FORMS_ENTRY:
|
|
||||||
zenity_value->forms_widget = gtk_entry_new();
|
|
||||||
break;
|
|
||||||
case ZENITY_FORMS_PASSWORD:
|
|
||||||
zenity_value->forms_widget = gtk_entry_new();
|
|
||||||
gtk_entry_set_visibility(GTK_ENTRY(zenity_value->forms_widget),
|
|
||||||
FALSE);
|
|
||||||
break;
|
|
||||||
case ZENITY_FORMS_CALENDAR:
|
|
||||||
zenity_value->forms_widget = gtk_calendar_new();
|
|
||||||
break;
|
|
||||||
case ZENITY_FORMS_LIST:
|
|
||||||
zenity_value->forms_widget = zenity_forms_create_and_fill_list (forms_data, list_count,
|
|
||||||
zenity_value->option_value);
|
|
||||||
list_count++;
|
|
||||||
break;
|
|
||||||
case ZENITY_FORMS_COMBO:
|
|
||||||
zenity_value->forms_widget = zenity_forms_create_and_fill_combo (forms_data, combo_count);
|
|
||||||
combo_count++;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
zenity_value->forms_widget = gtk_entry_new();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_grid_attach_next_to (GTK_GRID (grid),
|
if (forms_data->dialog_text)
|
||||||
GTK_WIDGET (zenity_value->forms_widget),
|
gtk_label_set_markup (
|
||||||
label,
|
GTK_LABEL (text), g_strcompress (forms_data->dialog_text));
|
||||||
GTK_POS_RIGHT,
|
|
||||||
1, 1);
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_show_all (GTK_WIDGET (dialog));
|
grid = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_forms_grid"));
|
||||||
|
|
||||||
g_object_unref (builder);
|
|
||||||
|
|
||||||
if (data->timeout_delay > 0) {
|
for (tmp = forms_data->list; tmp; tmp = tmp->next) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
||||||
}
|
GtkWidget *label;
|
||||||
|
|
||||||
gtk_main();
|
label = gtk_label_new (zenity_value->option_value);
|
||||||
|
gtk_widget_set_halign (label, GTK_ALIGN_START);
|
||||||
|
gtk_grid_attach (GTK_GRID (grid), label, 0, i, 1, 1);
|
||||||
|
|
||||||
|
switch (zenity_value->type) {
|
||||||
|
case ZENITY_FORMS_ENTRY:
|
||||||
|
zenity_value->forms_widget = gtk_entry_new ();
|
||||||
|
break;
|
||||||
|
case ZENITY_FORMS_PASSWORD:
|
||||||
|
zenity_value->forms_widget = gtk_entry_new ();
|
||||||
|
gtk_entry_set_visibility (
|
||||||
|
GTK_ENTRY (zenity_value->forms_widget), FALSE);
|
||||||
|
break;
|
||||||
|
case ZENITY_FORMS_CALENDAR:
|
||||||
|
zenity_value->forms_widget = gtk_calendar_new ();
|
||||||
|
break;
|
||||||
|
case ZENITY_FORMS_LIST:
|
||||||
|
zenity_value->forms_widget = zenity_forms_create_and_fill_list (
|
||||||
|
forms_data, list_count, zenity_value->option_value);
|
||||||
|
list_count++;
|
||||||
|
break;
|
||||||
|
case ZENITY_FORMS_COMBO:
|
||||||
|
zenity_value->forms_widget =
|
||||||
|
zenity_forms_create_and_fill_combo (
|
||||||
|
forms_data, combo_count);
|
||||||
|
combo_count++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
zenity_value->forms_widget = gtk_entry_new ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_grid_attach_next_to (GTK_GRID (grid),
|
||||||
|
GTK_WIDGET (zenity_value->forms_widget),
|
||||||
|
label,
|
||||||
|
GTK_POS_RIGHT,
|
||||||
|
1,
|
||||||
|
1);
|
||||||
|
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_widget_show_all (GTK_WIDGET (dialog));
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_forms_dialog_output (ZenityFormsData *forms_data)
|
zenity_forms_dialog_output (ZenityFormsData *forms_data) {
|
||||||
{
|
GSList *tmp, *tmp2;
|
||||||
GSList *tmp, *tmp2;
|
guint day, year, month;
|
||||||
guint day, year, month;
|
GDate *date = NULL;
|
||||||
GDate *date = NULL;
|
gchar time_string[128];
|
||||||
gchar time_string[128];
|
gchar *combo_value = NULL;
|
||||||
gchar *combo_value = NULL;
|
GtkTreeSelection *selection;
|
||||||
GtkTreeSelection *selection;
|
GtkListStore *list_store;
|
||||||
GtkListStore *list_store;
|
GtkTreeIter iter;
|
||||||
GtkTreeIter iter;
|
|
||||||
|
|
||||||
for (tmp = forms_data->list; tmp; tmp = tmp->next) {
|
for (tmp = forms_data->list; tmp; tmp = tmp->next) {
|
||||||
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
ZenityFormsValue *zenity_value = (ZenityFormsValue *) tmp->data;
|
||||||
switch (zenity_value->type) {
|
switch (zenity_value->type) {
|
||||||
case ZENITY_FORMS_PASSWORD:
|
case ZENITY_FORMS_PASSWORD:
|
||||||
case ZENITY_FORMS_ENTRY:
|
case ZENITY_FORMS_ENTRY:
|
||||||
g_print("%s", gtk_entry_get_text (GTK_ENTRY (zenity_value->forms_widget)));
|
g_print ("%s",
|
||||||
break;
|
gtk_entry_get_text (
|
||||||
case ZENITY_FORMS_LIST:
|
GTK_ENTRY (zenity_value->forms_widget)));
|
||||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget))));
|
break;
|
||||||
gtk_tree_selection_selected_foreach (selection,
|
case ZENITY_FORMS_LIST:
|
||||||
(GtkTreeSelectionForeachFunc) zenity_forms_dialog_get_selected,
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (
|
||||||
GTK_TREE_VIEW (gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget))));
|
gtk_bin_get_child (GTK_BIN (zenity_value->forms_widget))));
|
||||||
|
gtk_tree_selection_selected_foreach (selection,
|
||||||
|
(GtkTreeSelectionForeachFunc)
|
||||||
|
zenity_forms_dialog_get_selected,
|
||||||
|
GTK_TREE_VIEW (gtk_bin_get_child (
|
||||||
|
GTK_BIN (zenity_value->forms_widget))));
|
||||||
|
|
||||||
for (tmp2 = selected; tmp2; tmp2 = tmp2->next) {
|
for (tmp2 = selected; tmp2; tmp2 = tmp2->next) {
|
||||||
if (tmp->next != NULL) {
|
if (tmp->next != NULL) {
|
||||||
g_print ("%s,", (gchar *) tmp2->data);
|
g_print ("%s,", (gchar *) tmp2->data);
|
||||||
}
|
} else
|
||||||
else
|
g_print ("%s", (gchar *) tmp2->data);
|
||||||
g_print ("%s", (gchar *) tmp2->data);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case ZENITY_FORMS_CALENDAR:
|
case ZENITY_FORMS_CALENDAR:
|
||||||
gtk_calendar_get_date (GTK_CALENDAR (zenity_value->forms_widget), &day, &month, &year);
|
gtk_calendar_get_date (
|
||||||
date = g_date_new_dmy (year, month + 1, day);
|
GTK_CALENDAR (zenity_value->forms_widget),
|
||||||
g_date_strftime (time_string, 127, forms_data->date_format, date);
|
&day,
|
||||||
g_print ("%s", time_string);
|
&month,
|
||||||
break;
|
&year);
|
||||||
case ZENITY_FORMS_COMBO:
|
date = g_date_new_dmy (year, month + 1, day);
|
||||||
if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (zenity_value->forms_widget), &iter)) {
|
g_date_strftime (
|
||||||
list_store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (zenity_value->forms_widget)));
|
time_string, 127, forms_data->date_format, date);
|
||||||
gtk_tree_model_get (GTK_TREE_MODEL (list_store), &iter, 0, &combo_value, -1);
|
g_print ("%s", time_string);
|
||||||
g_object_unref (G_OBJECT (list_store));
|
break;
|
||||||
|
case ZENITY_FORMS_COMBO:
|
||||||
g_print ("%s", combo_value);
|
if (gtk_combo_box_get_active_iter (
|
||||||
g_free (combo_value);
|
GTK_COMBO_BOX (zenity_value->forms_widget), &iter)) {
|
||||||
} else
|
list_store = GTK_LIST_STORE (gtk_combo_box_get_model (
|
||||||
g_print (" ");
|
GTK_COMBO_BOX (zenity_value->forms_widget)));
|
||||||
break;
|
gtk_tree_model_get (GTK_TREE_MODEL (list_store),
|
||||||
|
&iter,
|
||||||
}
|
0,
|
||||||
if (tmp->next != NULL)
|
&combo_value,
|
||||||
g_print("%s", forms_data->separator);
|
-1);
|
||||||
}
|
g_object_unref (G_OBJECT (list_store));
|
||||||
g_print("\n");
|
|
||||||
|
g_print ("%s", combo_value);
|
||||||
|
g_free (combo_value);
|
||||||
|
} else
|
||||||
|
g_print (" ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (tmp->next != NULL)
|
||||||
|
g_print ("%s", forms_data->separator);
|
||||||
|
}
|
||||||
|
g_print ("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_forms_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityFormsData *forms_data = (ZenityFormsData *) data;
|
||||||
ZenityFormsData *forms_data = (ZenityFormsData *) data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_forms_dialog_output (forms_data);
|
zenity_forms_dialog_output (forms_data);
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zenity_forms_dialog_output (forms_data);
|
zenity_forms_dialog_output (forms_data);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
145
src/main.c
145
src/main.c
@ -23,97 +23,98 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "option.h"
|
#include "option.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <langinfo.h>
|
#include <langinfo.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gint
|
gint
|
||||||
main (gint argc, gchar **argv) {
|
main (gint argc, gchar **argv) {
|
||||||
ZenityParsingOptions *results;
|
ZenityParsingOptions *results;
|
||||||
gint retval;
|
gint retval;
|
||||||
|
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
setlocale(LC_ALL,"");
|
setlocale (LC_ALL, "");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
|
||||||
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
|
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
|
||||||
textdomain(GETTEXT_PACKAGE);
|
textdomain (GETTEXT_PACKAGE);
|
||||||
|
|
||||||
gtk_init (&argc, &argv);
|
gtk_init (&argc, &argv);
|
||||||
|
|
||||||
results = zenity_option_parse (argc, argv);
|
results = zenity_option_parse (argc, argv);
|
||||||
|
|
||||||
switch (results->mode) {
|
switch (results->mode) {
|
||||||
case MODE_CALENDAR:
|
case MODE_CALENDAR:
|
||||||
zenity_calendar (results->data, results->calendar_data);
|
zenity_calendar (results->data, results->calendar_data);
|
||||||
break;
|
break;
|
||||||
case MODE_ENTRY:
|
case MODE_ENTRY:
|
||||||
results->entry_data->data = (const gchar **) argv + 1;
|
results->entry_data->data = (const gchar **) argv + 1;
|
||||||
zenity_entry (results->data, results->entry_data);
|
zenity_entry (results->data, results->entry_data);
|
||||||
break;
|
break;
|
||||||
case MODE_ERROR:
|
case MODE_ERROR:
|
||||||
case MODE_QUESTION:
|
case MODE_QUESTION:
|
||||||
case MODE_WARNING:
|
case MODE_WARNING:
|
||||||
case MODE_INFO:
|
case MODE_INFO:
|
||||||
zenity_msg (results->data, results->msg_data);
|
zenity_msg (results->data, results->msg_data);
|
||||||
break;
|
break;
|
||||||
case MODE_SCALE:
|
case MODE_SCALE:
|
||||||
zenity_scale (results->data, results->scale_data);
|
zenity_scale (results->data, results->scale_data);
|
||||||
break;
|
break;
|
||||||
case MODE_FILE:
|
case MODE_FILE:
|
||||||
zenity_fileselection (results->data, results->file_data);
|
zenity_fileselection (results->data, results->file_data);
|
||||||
break;
|
break;
|
||||||
case MODE_LIST:
|
case MODE_LIST:
|
||||||
results->tree_data->data = (const gchar **) argv + 1;
|
results->tree_data->data = (const gchar **) argv + 1;
|
||||||
zenity_tree (results->data, results->tree_data);
|
zenity_tree (results->data, results->tree_data);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
case MODE_NOTIFICATION:
|
case MODE_NOTIFICATION:
|
||||||
zenity_notification (results->data, results->notification_data);
|
zenity_notification (results->data, results->notification_data);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case MODE_PROGRESS:
|
case MODE_PROGRESS:
|
||||||
zenity_progress (results->data, results->progress_data);
|
zenity_progress (results->data, results->progress_data);
|
||||||
break;
|
break;
|
||||||
case MODE_TEXTINFO:
|
case MODE_TEXTINFO:
|
||||||
zenity_text (results->data, results->text_data);
|
zenity_text (results->data, results->text_data);
|
||||||
break;
|
break;
|
||||||
case MODE_COLOR:
|
case MODE_COLOR:
|
||||||
zenity_colorselection (results->data, results->color_data);
|
zenity_colorselection (results->data, results->color_data);
|
||||||
break;
|
break;
|
||||||
case MODE_PASSWORD:
|
case MODE_PASSWORD:
|
||||||
zenity_password_dialog (results->data, results->password_data);
|
zenity_password_dialog (results->data, results->password_data);
|
||||||
break;
|
break;
|
||||||
case MODE_ABOUT:
|
case MODE_ABOUT:
|
||||||
zenity_about (results->data);
|
zenity_about (results->data);
|
||||||
break;
|
break;
|
||||||
case MODE_FORMS:
|
case MODE_FORMS:
|
||||||
zenity_forms_dialog (results->data, results->forms_data);
|
zenity_forms_dialog (results->data, results->forms_data);
|
||||||
break;
|
break;
|
||||||
case MODE_VERSION:
|
case MODE_VERSION:
|
||||||
g_print ("%s\n", VERSION);
|
g_print ("%s\n", VERSION);
|
||||||
break;
|
break;
|
||||||
case MODE_LAST:
|
case MODE_LAST:
|
||||||
g_printerr (_("You must specify a dialog type. See 'zenity --help' for details\n"));
|
g_printerr (_ ("You must specify a dialog type. See 'zenity "
|
||||||
zenity_option_free ();
|
"--help' for details\n"));
|
||||||
exit (-1);
|
zenity_option_free ();
|
||||||
default:
|
exit (-1);
|
||||||
g_assert_not_reached ();
|
default:
|
||||||
zenity_option_free ();
|
g_assert_not_reached ();
|
||||||
exit (-1);
|
zenity_option_free ();
|
||||||
}
|
exit (-1);
|
||||||
|
}
|
||||||
|
|
||||||
retval = results->data->exit_code;
|
retval = results->data->exit_code;
|
||||||
|
|
||||||
zenity_option_free ();
|
|
||||||
|
|
||||||
exit (retval);
|
zenity_option_free ();
|
||||||
|
|
||||||
|
exit (retval);
|
||||||
}
|
}
|
||||||
|
389
src/msg.c
389
src/msg.c
@ -23,228 +23,247 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
|
||||||
static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_msg_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
static void
|
static void
|
||||||
zenity_msg_construct_question_dialog (GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data)
|
zenity_msg_construct_question_dialog (
|
||||||
{
|
GtkWidget *dialog, ZenityMsgData *msg_data, ZenityData *data) {
|
||||||
|
|
||||||
|
GtkWidget *cancel_button, *ok_button;
|
||||||
|
|
||||||
GtkWidget *cancel_button, *ok_button;
|
cancel_button = gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), _ ("_No"), GTK_RESPONSE_CANCEL);
|
||||||
cancel_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_No"), GTK_RESPONSE_CANCEL);
|
ok_button = gtk_dialog_add_button (
|
||||||
ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Yes"), GTK_RESPONSE_OK);
|
GTK_DIALOG (dialog), _ ("_Yes"), GTK_RESPONSE_OK);
|
||||||
|
|
||||||
gtk_widget_grab_focus (msg_data->default_cancel ? cancel_button : ok_button);
|
gtk_widget_grab_focus (
|
||||||
|
msg_data->default_cancel ? cancel_button : ok_button);
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (data->cancel_label) {
|
||||||
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
|
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->ok_label) {
|
|
||||||
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
if (data->ok_label) {
|
||||||
|
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_label_widget_clipboard_selection(GtkWidget *widget)
|
zenity_label_widget_clipboard_selection (GtkWidget *widget) {
|
||||||
{
|
/* Workaround hotfix for suspected toolkit issue:
|
||||||
/* Workaround hotfix for suspected toolkit issue:
|
since focus change of the dialog's focussed widget (text)
|
||||||
since focus change of the dialog's focussed widget (text)
|
somehow currently chooses to destroy
|
||||||
somehow currently chooses to destroy
|
a pre-existing (read: foreign, user-initiated) X11 primary selection
|
||||||
a pre-existing (read: foreign, user-initiated) X11 primary selection
|
(via gtk_label_select_region() -> ...
|
||||||
(via gtk_label_select_region() -> ...
|
-> gtk_clipboard_set_contents()/gtk_clipboard_clear()),
|
||||||
-> gtk_clipboard_set_contents()/gtk_clipboard_clear()),
|
we need to ensure
|
||||||
we need to ensure
|
that the widget does have its gtk-label-select-on-focus property off,
|
||||||
that the widget does have its gtk-label-select-on-focus property off,
|
in order to avoid having the label become selected automatically
|
||||||
in order to avoid having the label become selected automatically
|
and thereby having pre-existing clipboard content nullified.
|
||||||
and thereby having pre-existing clipboard content nullified.
|
Side note: this selection issue only applies to widgets
|
||||||
Side note: this selection issue only applies to widgets
|
which have both
|
||||||
which have both
|
<property name="can_focus">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="selectable">True</property>
|
||||||
<property name="selectable">True</property>
|
.
|
||||||
.
|
*/
|
||||||
*/
|
g_object_set (gtk_widget_get_settings (widget),
|
||||||
g_object_set(gtk_widget_get_settings (widget),
|
"gtk-label-select-on-focus",
|
||||||
"gtk-label-select-on-focus",
|
FALSE,
|
||||||
FALSE,
|
NULL);
|
||||||
NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
zenity_msg (ZenityData *data, ZenityMsgData *msg_data) {
|
||||||
{
|
GtkBuilder *builder;
|
||||||
GtkBuilder *builder;
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *ok_button;
|
||||||
GtkWidget *ok_button;
|
GObject *text;
|
||||||
GObject *text;
|
GObject *image;
|
||||||
GObject *image;
|
|
||||||
|
|
||||||
switch (msg_data->mode) {
|
switch (msg_data->mode) {
|
||||||
case ZENITY_MSG_WARNING:
|
case ZENITY_MSG_WARNING:
|
||||||
builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_warning_dialog", NULL);
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_dialog"));
|
dialog = GTK_WIDGET (
|
||||||
text = gtk_builder_get_object (builder, "zenity_warning_text");
|
gtk_builder_get_object (builder, "zenity_warning_dialog"));
|
||||||
image = gtk_builder_get_object (builder, "zenity_warning_image");
|
text = gtk_builder_get_object (builder, "zenity_warning_text");
|
||||||
ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_warning_ok_button"));
|
image = gtk_builder_get_object (builder, "zenity_warning_image");
|
||||||
break;
|
ok_button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_warning_ok_button"));
|
||||||
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_QUESTION:
|
case ZENITY_MSG_QUESTION:
|
||||||
case ZENITY_MSG_SWITCH:
|
case ZENITY_MSG_SWITCH:
|
||||||
builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_question_dialog", NULL);
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_question_dialog"));
|
dialog = GTK_WIDGET (
|
||||||
text = gtk_builder_get_object (builder, "zenity_question_text");
|
gtk_builder_get_object (builder, "zenity_question_dialog"));
|
||||||
image = gtk_builder_get_object (builder, "zenity_question_image");
|
text = gtk_builder_get_object (builder, "zenity_question_text");
|
||||||
ok_button = NULL;
|
image = gtk_builder_get_object (builder, "zenity_question_image");
|
||||||
break;
|
ok_button = NULL;
|
||||||
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_ERROR:
|
case ZENITY_MSG_ERROR:
|
||||||
builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_error_dialog", NULL);
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_dialog"));
|
dialog = GTK_WIDGET (
|
||||||
text = gtk_builder_get_object (builder, "zenity_error_text");
|
gtk_builder_get_object (builder, "zenity_error_dialog"));
|
||||||
image = gtk_builder_get_object (builder, "zenity_error_image");
|
text = gtk_builder_get_object (builder, "zenity_error_text");
|
||||||
ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_error_ok_button"));
|
image = gtk_builder_get_object (builder, "zenity_error_image");
|
||||||
break;
|
ok_button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_error_ok_button"));
|
||||||
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_INFO:
|
case ZENITY_MSG_INFO:
|
||||||
builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_info_dialog", NULL);
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_dialog"));
|
dialog = GTK_WIDGET (
|
||||||
text = gtk_builder_get_object (builder, "zenity_info_text");
|
gtk_builder_get_object (builder, "zenity_info_dialog"));
|
||||||
image = gtk_builder_get_object (builder, "zenity_info_image");
|
text = gtk_builder_get_object (builder, "zenity_info_text");
|
||||||
ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_info_ok_button"));
|
image = gtk_builder_get_object (builder, "zenity_info_image");
|
||||||
break;
|
ok_button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_info_ok_button"));
|
||||||
default:
|
break;
|
||||||
builder = NULL;
|
|
||||||
dialog = NULL;
|
|
||||||
text = NULL;
|
|
||||||
image = NULL;
|
|
||||||
ok_button = NULL;
|
|
||||||
g_assert_not_reached ();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->extra_label) {
|
default:
|
||||||
gint i=0;
|
builder = NULL;
|
||||||
while(data->extra_label[i]!=NULL){
|
dialog = NULL;
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
text = NULL;
|
||||||
i++;
|
image = NULL;
|
||||||
}
|
ok_button = NULL;
|
||||||
}
|
g_assert_not_reached ();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (builder == NULL) {
|
if (data->extra_label) {
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
gint i = 0;
|
||||||
return;
|
while (data->extra_label[i] != NULL) {
|
||||||
}
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
if (builder == NULL) {
|
||||||
G_CALLBACK (zenity_msg_dialog_response), data);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
|
"response",
|
||||||
if (data->dialog_title)
|
G_CALLBACK (zenity_msg_dialog_response),
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
data);
|
||||||
|
|
||||||
if (ok_button) {
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
if (data->ok_label) {
|
|
||||||
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (msg_data->mode) {
|
if (data->dialog_title)
|
||||||
case ZENITY_MSG_WARNING:
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-warning");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ZENITY_MSG_QUESTION:
|
if (ok_button) {
|
||||||
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question");
|
if (data->ok_label) {
|
||||||
zenity_msg_construct_question_dialog (dialog, msg_data, data);
|
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
||||||
break;
|
}
|
||||||
|
}
|
||||||
case ZENITY_MSG_SWITCH:
|
|
||||||
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-question");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ZENITY_MSG_ERROR:
|
|
||||||
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-error");
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ZENITY_MSG_INFO:
|
|
||||||
zenity_util_set_window_icon_from_icon_name (dialog, data->window_icon, "dialog-information");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
|
||||||
|
|
||||||
if (data->width > -1)
|
switch (msg_data->mode) {
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
case ZENITY_MSG_WARNING:
|
||||||
else
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
if (!msg_data->ellipsize && !msg_data->no_wrap) {
|
dialog, data->window_icon, "dialog-warning");
|
||||||
// the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui
|
break;
|
||||||
// however, 60 would increase the distance between the icon and the text,
|
|
||||||
// decreasing to 10 fix it.
|
|
||||||
gtk_label_set_width_chars (text, 10);
|
|
||||||
gtk_label_set_max_width_chars (text, 10);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->modal)
|
case ZENITY_MSG_QUESTION:
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
|
dialog, data->window_icon, "dialog-question");
|
||||||
if (msg_data->dialog_text) {
|
zenity_msg_construct_question_dialog (dialog, msg_data, data);
|
||||||
if (msg_data->no_markup)
|
break;
|
||||||
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
|
||||||
else
|
|
||||||
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (msg_data->dialog_text));
|
|
||||||
zenity_label_widget_clipboard_selection(GTK_WIDGET (text));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg_data->ellipsize)
|
case ZENITY_MSG_SWITCH:
|
||||||
gtk_label_set_ellipsize (GTK_LABEL(text), PANGO_ALIGN_RIGHT);
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
|
dialog, data->window_icon, "dialog-question");
|
||||||
|
break;
|
||||||
|
|
||||||
if (msg_data->dialog_icon)
|
case ZENITY_MSG_ERROR:
|
||||||
gtk_image_set_from_icon_name (GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG);
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
|
dialog, data->window_icon, "dialog-error");
|
||||||
|
break;
|
||||||
|
|
||||||
if (msg_data->no_wrap)
|
case ZENITY_MSG_INFO:
|
||||||
gtk_label_set_line_wrap (GTK_LABEL (text), FALSE);
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
|
dialog, data->window_icon, "dialog-information");
|
||||||
|
break;
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if (data->width > -1 || data->height > -1)
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
gtk_window_set_default_size (
|
||||||
}
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
g_object_unref (builder);
|
if (data->width > -1)
|
||||||
|
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
||||||
|
else if (!msg_data->ellipsize && !msg_data->no_wrap) {
|
||||||
|
// the magic number 60 is picked from gtk+/gtk/ui/gtkmessagedialog.ui
|
||||||
|
// however, 60 would increase the distance between the icon and the
|
||||||
|
// text,
|
||||||
|
// decreasing to 10 fix it.
|
||||||
|
gtk_label_set_width_chars (text, 10);
|
||||||
|
gtk_label_set_max_width_chars (text, 10);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main ();
|
if (data->modal)
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
|
if (msg_data->dialog_text) {
|
||||||
|
if (msg_data->no_markup)
|
||||||
|
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
||||||
|
else
|
||||||
|
gtk_label_set_markup (
|
||||||
|
GTK_LABEL (text), g_strcompress (msg_data->dialog_text));
|
||||||
|
zenity_label_widget_clipboard_selection (GTK_WIDGET (text));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg_data->ellipsize)
|
||||||
|
gtk_label_set_ellipsize (GTK_LABEL (text), PANGO_ALIGN_RIGHT);
|
||||||
|
|
||||||
|
if (msg_data->dialog_icon)
|
||||||
|
gtk_image_set_from_icon_name (
|
||||||
|
GTK_IMAGE (image), msg_data->dialog_icon, GTK_ICON_SIZE_DIALOG);
|
||||||
|
|
||||||
|
if (msg_data->no_wrap)
|
||||||
|
gtk_label_set_line_wrap (GTK_LABEL (text), FALSE);
|
||||||
|
|
||||||
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_msg_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityData *zen_data = data;
|
||||||
ZenityData *zen_data = data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
@ -24,16 +24,16 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
#include <time.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
#include <libnotify/notify.h>
|
#include <libnotify/notify.h>
|
||||||
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
|
||||||
#define MAX_HINTS 16
|
#define MAX_HINTS 16
|
||||||
|
|
||||||
@ -41,337 +41,331 @@ static char *icon_file;
|
|||||||
static GHashTable *notification_hints;
|
static GHashTable *notification_hints;
|
||||||
|
|
||||||
static NotifyNotification *
|
static NotifyNotification *
|
||||||
zenity_notification_new(gchar *message, gchar *icon_file)
|
zenity_notification_new (gchar *message, gchar *icon_file) {
|
||||||
{
|
NotifyNotification *notif;
|
||||||
NotifyNotification *notif;
|
gchar **text;
|
||||||
gchar **text;
|
|
||||||
|
|
||||||
text = g_strsplit (g_strcompress (message), "\n", 2);
|
text = g_strsplit (g_strcompress (message), "\n", 2);
|
||||||
if (*text == NULL) {
|
if (*text == NULL) {
|
||||||
g_printerr (_("Could not parse message\n"));
|
g_printerr (_ ("Could not parse message\n"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
notif = notify_notification_new (text[0], /* title */
|
notif = notify_notification_new (text[0], /* title */
|
||||||
text[1], /* summary */
|
text[1], /* summary */
|
||||||
icon_file);
|
icon_file);
|
||||||
g_strfreev (text);
|
g_strfreev (text);
|
||||||
return notif;
|
return notif;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_notification_default_action (NotifyNotification *n,
|
on_notification_default_action (
|
||||||
const char *action,
|
NotifyNotification *n, const char *action, void *user_data) {
|
||||||
void *user_data)
|
ZenityData *zen_data;
|
||||||
{
|
|
||||||
ZenityData *zen_data;
|
|
||||||
|
|
||||||
zen_data = (ZenityData *)user_data;
|
zen_data = (ZenityData *) user_data;
|
||||||
notify_notification_close (n, NULL);
|
notify_notification_close (n, NULL);
|
||||||
|
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
zenity_notification_parse_hints_array (gchar **hints)
|
zenity_notification_parse_hints_array (gchar **hints) {
|
||||||
{
|
GHashTable *result;
|
||||||
GHashTable *result;
|
gchar **pair;
|
||||||
gchar** pair;
|
int i;
|
||||||
int i;
|
|
||||||
|
|
||||||
result = g_hash_table_new_full (g_str_hash,
|
result = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
|
||||||
g_str_equal,
|
|
||||||
g_free,
|
|
||||||
g_free);
|
|
||||||
|
|
||||||
for(i = 0; i < g_strv_length (hints); i++) {
|
for (i = 0; i < g_strv_length (hints); i++) {
|
||||||
pair = g_strsplit (hints[i], ":", 2);
|
pair = g_strsplit (hints[i], ":", 2);
|
||||||
g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1]));
|
g_hash_table_replace (result, g_strdup (pair[0]), g_strdup (pair[1]));
|
||||||
g_strfreev (pair);
|
g_strfreev (pair);
|
||||||
}
|
}
|
||||||
if (g_hash_table_size (result) == 0) {
|
if (g_hash_table_size (result) == 0) {
|
||||||
g_hash_table_unref (result);
|
g_hash_table_unref (result);
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GHashTable *
|
static GHashTable *
|
||||||
zenity_notification_parse_hints (gchar *hints)
|
zenity_notification_parse_hints (gchar *hints) {
|
||||||
{
|
GHashTable *result;
|
||||||
GHashTable *result;
|
gchar **hint_array;
|
||||||
gchar** hint_array;
|
|
||||||
|
|
||||||
hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS);
|
hint_array = g_strsplit (g_strcompress (hints), "\n", MAX_HINTS);
|
||||||
result = zenity_notification_parse_hints_array (hint_array);
|
result = zenity_notification_parse_hints_array (hint_array);
|
||||||
g_strfreev (hint_array);
|
g_strfreev (hint_array);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_notification_set_hint(gpointer key, gpointer value, gpointer user_data)
|
zenity_notification_set_hint (
|
||||||
{
|
gpointer key, gpointer value, gpointer user_data) {
|
||||||
NotifyNotification *notification;
|
NotifyNotification *notification;
|
||||||
gchar *hint_name;
|
gchar *hint_name;
|
||||||
GVariant *hint_value;
|
GVariant *hint_value;
|
||||||
|
|
||||||
gchar *string_value;
|
gchar *string_value;
|
||||||
gboolean boolean_value;
|
gboolean boolean_value;
|
||||||
gint32 int_value;
|
gint32 int_value;
|
||||||
guchar byte_value;
|
guchar byte_value;
|
||||||
|
|
||||||
hint_name = (gchar *) key;
|
hint_name = (gchar *) key;
|
||||||
string_value = (gchar *) value;
|
string_value = (gchar *) value;
|
||||||
notification = (NotifyNotification *) user_data;
|
notification = (NotifyNotification *) user_data;
|
||||||
|
|
||||||
if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0)
|
if ((g_ascii_strcasecmp ("action-icons", hint_name) == 0) ||
|
||||||
|| (g_ascii_strcasecmp ("resident", hint_name) == 0)
|
(g_ascii_strcasecmp ("resident", hint_name) == 0) ||
|
||||||
|| (g_ascii_strcasecmp ("suppress-sound", 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 */
|
/* boolean hints */
|
||||||
if (g_ascii_strcasecmp ("true", string_value) == 0) {
|
if (g_ascii_strcasecmp ("true", string_value) == 0) {
|
||||||
boolean_value = TRUE;
|
boolean_value = TRUE;
|
||||||
} else if (g_ascii_strcasecmp ("false", string_value) == 0) {
|
} else if (g_ascii_strcasecmp ("false", string_value) == 0) {
|
||||||
boolean_value = FALSE;
|
boolean_value = FALSE;
|
||||||
} else {
|
} else {
|
||||||
g_printerr (_("Invalid value for a boolean typed hint.\nSupported values are 'true' or 'false'.\n"));
|
g_printerr (_ ("Invalid value for a boolean typed hint.\nSupported "
|
||||||
return;
|
"values are 'true' or 'false'.\n"));
|
||||||
}
|
return;
|
||||||
hint_value = g_variant_new_boolean (boolean_value);
|
}
|
||||||
} else if ((g_ascii_strcasecmp ("category", hint_name) == 0)
|
hint_value = g_variant_new_boolean (boolean_value);
|
||||||
|| (g_ascii_strcasecmp ("desktop-entry", hint_name) == 0)
|
} else if ((g_ascii_strcasecmp ("category", hint_name) == 0) ||
|
||||||
|| (g_ascii_strcasecmp ("image-path", 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 ("image_path", hint_name) == 0) ||
|
||||||
|| (g_ascii_strcasecmp ("sound-name", hint_name) == 0)) {
|
(g_ascii_strcasecmp ("sound-file", hint_name) == 0) ||
|
||||||
/* string hints */
|
(g_ascii_strcasecmp ("sound-name", hint_name) == 0)) {
|
||||||
hint_value = g_variant_new_string (string_value);
|
/* string hints */
|
||||||
} else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0)
|
hint_value = g_variant_new_string (string_value);
|
||||||
|| (g_ascii_strcasecmp ("image_data", hint_name) == 0)
|
} else if ((g_ascii_strcasecmp ("image-data", hint_name) == 0) ||
|
||||||
|| (g_ascii_strcasecmp ("icon-data", hint_name) == 0)) {
|
(g_ascii_strcasecmp ("image_data", hint_name) == 0) ||
|
||||||
/* (iibiiay) */
|
(g_ascii_strcasecmp ("icon-data", hint_name) == 0)) {
|
||||||
g_printerr (_("Unsupported hint. Skipping.\n"));
|
/* (iibiiay) */
|
||||||
return;
|
g_printerr (_ ("Unsupported hint. Skipping.\n"));
|
||||||
} else if ((g_ascii_strcasecmp ("x", hint_name) == 0)
|
return;
|
||||||
|| (g_ascii_strcasecmp ("y", hint_name) == 0)) {
|
} else if ((g_ascii_strcasecmp ("x", hint_name) == 0) ||
|
||||||
/* int hints */
|
(g_ascii_strcasecmp ("y", hint_name) == 0)) {
|
||||||
if (string_value == NULL)
|
/* int hints */
|
||||||
string_value = "";
|
if (string_value == NULL)
|
||||||
int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0);
|
string_value = "";
|
||||||
hint_value = g_variant_new_int32 (int_value);
|
int_value = (gint32) g_ascii_strtoll (string_value, NULL, 0);
|
||||||
} else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) {
|
hint_value = g_variant_new_int32 (int_value);
|
||||||
/* byte hints */
|
} else if ((g_ascii_strcasecmp ("urgency", hint_name) == 0)) {
|
||||||
if (string_value == NULL)
|
/* byte hints */
|
||||||
string_value = "";
|
if (string_value == NULL)
|
||||||
byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0);
|
string_value = "";
|
||||||
hint_value = g_variant_new_byte (byte_value);
|
byte_value = (guchar) g_ascii_strtoll (string_value, NULL, 0);
|
||||||
} else {
|
hint_value = g_variant_new_byte (byte_value);
|
||||||
/* unknown hints */
|
} else {
|
||||||
g_printerr (_("Unknown hint name. Skipping.\n"));
|
/* unknown hints */
|
||||||
return;
|
g_printerr (_ ("Unknown hint name. Skipping.\n"));
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
notify_notification_set_hint (notification,
|
notify_notification_set_hint (notification, hint_name, hint_value);
|
||||||
hint_name,
|
|
||||||
hint_value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_notification_set_hints (NotifyNotification *notification, GHashTable *hints)
|
zenity_notification_set_hints (
|
||||||
{
|
NotifyNotification *notification, GHashTable *hints) {
|
||||||
if (hints == NULL) {
|
if (hints == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_hash_table_foreach (hints, zenity_notification_set_hint, notification);
|
g_hash_table_foreach (hints, zenity_notification_set_hint, notification);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_notification_handle_stdin (GIOChannel *channel,
|
zenity_notification_handle_stdin (
|
||||||
GIOCondition condition,
|
GIOChannel *channel, GIOCondition condition, gpointer user_data) {
|
||||||
gpointer user_data)
|
if ((condition & G_IO_IN) != 0) {
|
||||||
{
|
GString *string;
|
||||||
if ((condition & G_IO_IN) != 0) {
|
GError *error = NULL;
|
||||||
GString *string;
|
|
||||||
GError *error = NULL;
|
|
||||||
|
|
||||||
string = g_string_new (NULL);
|
string = g_string_new (NULL);
|
||||||
while (channel->is_readable == FALSE)
|
while (channel->is_readable == FALSE)
|
||||||
;
|
;
|
||||||
do {
|
do {
|
||||||
gint status;
|
gint status;
|
||||||
gchar *command, *value, *colon;
|
gchar *command, *value, *colon;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
status = g_io_channel_read_line_string (channel, string, NULL, &error);
|
status = g_io_channel_read_line_string (
|
||||||
while (gdk_events_pending ())
|
channel, string, NULL, &error);
|
||||||
gtk_main_iteration ();
|
while (gdk_events_pending ())
|
||||||
|
gtk_main_iteration ();
|
||||||
|
|
||||||
} while (status == G_IO_STATUS_AGAIN);
|
} while (status == G_IO_STATUS_AGAIN);
|
||||||
|
|
||||||
if (status != G_IO_STATUS_NORMAL) {
|
if (status != G_IO_STATUS_NORMAL) {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("zenity_notification_handle_stdin () : %s",
|
g_warning ("zenity_notification_handle_stdin () : %s",
|
||||||
error->message);
|
error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
zenity_util_strip_newline (string->str);
|
||||||
|
colon = strchr (string->str, ':');
|
||||||
|
if (colon == NULL) {
|
||||||
|
g_printerr (_ ("Could not parse command from stdin\n"));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
/* split off the command and value */
|
||||||
|
command = g_strstrip (g_strndup (string->str, colon - string->str));
|
||||||
|
|
||||||
|
value = colon + 1;
|
||||||
|
while (*value && g_ascii_isspace (*value))
|
||||||
|
value++;
|
||||||
|
|
||||||
|
if (!g_ascii_strcasecmp (command, "icon")) {
|
||||||
|
g_free (icon_file);
|
||||||
|
icon_file = g_strdup (value);
|
||||||
|
} else if (!g_ascii_strcasecmp (command, "hints")) {
|
||||||
|
if (notification_hints != NULL) {
|
||||||
|
g_hash_table_unref (notification_hints);
|
||||||
|
}
|
||||||
|
notification_hints = zenity_notification_parse_hints (value);
|
||||||
|
} else if (!g_ascii_strcasecmp (command, "message")) {
|
||||||
|
/* display a notification bubble */
|
||||||
|
if (!g_utf8_validate (value, -1, NULL)) {
|
||||||
|
g_warning ("Invalid UTF-8 in input!");
|
||||||
|
} else {
|
||||||
|
NotifyNotification *notif;
|
||||||
|
error = NULL;
|
||||||
|
|
||||||
|
notif = zenity_notification_new (value, icon_file);
|
||||||
|
if (notif == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
zenity_notification_set_hints (notif, notification_hints);
|
||||||
|
|
||||||
|
notify_notification_show (notif, &error);
|
||||||
|
if (error) {
|
||||||
|
g_warning (
|
||||||
|
"Error showing notification: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (notif);
|
||||||
|
}
|
||||||
|
} else if (!g_ascii_strcasecmp (command, "tooltip")) {
|
||||||
|
if (!g_utf8_validate (value, -1, NULL)) {
|
||||||
|
g_warning ("Invalid UTF-8 in input!");
|
||||||
|
} else {
|
||||||
|
NotifyNotification *notif;
|
||||||
|
notif = zenity_notification_new (value, icon_file);
|
||||||
|
if (notif == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
zenity_notification_set_hints (notif, notification_hints);
|
||||||
|
|
||||||
|
notify_notification_show (notif, &error);
|
||||||
|
if (error) {
|
||||||
|
g_warning (
|
||||||
|
"Error showing notification: %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (!g_ascii_strcasecmp (command, "visible")) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
g_warning ("Unknown command '%s'", command);
|
||||||
|
}
|
||||||
|
g_free (command);
|
||||||
|
|
||||||
|
} while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
|
||||||
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
zenity_util_strip_newline (string->str);
|
if ((condition & G_IO_HUP) != 0) {
|
||||||
colon = strchr(string->str, ':');
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
||||||
if (colon == NULL) {
|
return FALSE;
|
||||||
g_printerr (_("Could not parse command from stdin\n"));
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
/* split off the command and value */
|
|
||||||
command = g_strstrip (g_strndup (string->str, colon - string->str));
|
|
||||||
|
|
||||||
value = colon + 1;
|
return TRUE;
|
||||||
while (*value && g_ascii_isspace (*value)) value++;
|
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp (command, "icon")) {
|
|
||||||
g_free (icon_file);
|
|
||||||
icon_file = g_strdup (value);
|
|
||||||
} else if (!g_ascii_strcasecmp (command, "hints")) {
|
|
||||||
if (notification_hints != NULL) {
|
|
||||||
g_hash_table_unref (notification_hints);
|
|
||||||
}
|
|
||||||
notification_hints = zenity_notification_parse_hints (value);
|
|
||||||
} else if (!g_ascii_strcasecmp (command, "message")) {
|
|
||||||
/* display a notification bubble */
|
|
||||||
if (!g_utf8_validate (value, -1, NULL)) {
|
|
||||||
g_warning ("Invalid UTF-8 in input!");
|
|
||||||
} else {
|
|
||||||
NotifyNotification *notif;
|
|
||||||
error = NULL;
|
|
||||||
|
|
||||||
notif = zenity_notification_new (value, icon_file);
|
|
||||||
if (notif == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
zenity_notification_set_hints (notif, notification_hints);
|
|
||||||
|
|
||||||
notify_notification_show (notif, &error);
|
|
||||||
if (error) {
|
|
||||||
g_warning ("Error showing notification: %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (notif);
|
|
||||||
}
|
|
||||||
} else if (!g_ascii_strcasecmp (command, "tooltip")) {
|
|
||||||
if (!g_utf8_validate (value, -1, NULL)) {
|
|
||||||
g_warning ("Invalid UTF-8 in input!");
|
|
||||||
} else {
|
|
||||||
NotifyNotification *notif;
|
|
||||||
notif = zenity_notification_new (value, icon_file);
|
|
||||||
if (notif == NULL)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
zenity_notification_set_hints (notif, notification_hints);
|
|
||||||
|
|
||||||
notify_notification_show (notif, &error);
|
|
||||||
if (error) {
|
|
||||||
g_warning ("Error showing notification: %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (!g_ascii_strcasecmp (command, "visible")) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
g_warning ("Unknown command '%s'", command);
|
|
||||||
}
|
|
||||||
g_free (command);
|
|
||||||
|
|
||||||
} while (g_io_channel_get_buffer_condition (channel) == G_IO_IN);
|
|
||||||
g_string_free (string, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((condition & G_IO_HUP) != 0) {
|
|
||||||
g_io_channel_shutdown (channel, TRUE, NULL);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_notification_listen_on_stdin (ZenityData *data)
|
zenity_notification_listen_on_stdin (ZenityData *data) {
|
||||||
{
|
GIOChannel *channel;
|
||||||
GIOChannel *channel;
|
|
||||||
|
|
||||||
channel = g_io_channel_unix_new (0);
|
channel = g_io_channel_unix_new (0);
|
||||||
g_io_channel_set_encoding (channel, NULL, NULL);
|
g_io_channel_set_encoding (channel, NULL, NULL);
|
||||||
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
||||||
g_io_add_watch (channel, G_IO_IN | G_IO_HUP,
|
g_io_add_watch (
|
||||||
zenity_notification_handle_stdin, data);
|
channel, G_IO_IN | G_IO_HUP, zenity_notification_handle_stdin, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_notification (ZenityData *data, ZenityNotificationData *notification_data)
|
zenity_notification (
|
||||||
{
|
ZenityData *data, ZenityNotificationData *notification_data) {
|
||||||
GError *error;
|
GError *error;
|
||||||
NotifyNotification *notification;
|
NotifyNotification *notification;
|
||||||
GHashTable *notification_hints;
|
GHashTable *notification_hints;
|
||||||
|
|
||||||
/* create the notification widget */
|
/* create the notification widget */
|
||||||
if (!notify_is_initted ()) {
|
if (!notify_is_initted ()) {
|
||||||
notify_init (_("Zenity notification"));
|
notify_init (_ ("Zenity notification"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (notification_data->listen) {
|
if (notification_data->listen) {
|
||||||
zenity_notification_listen_on_stdin (data);
|
zenity_notification_listen_on_stdin (data);
|
||||||
gtk_main();
|
gtk_main ();
|
||||||
} else {
|
} else {
|
||||||
if (notification_data->notification_text == NULL) {
|
if (notification_data->notification_text == NULL) {
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
notification = zenity_notification_new (notification_data->notification_text,
|
notification = zenity_notification_new (
|
||||||
data->window_icon);
|
notification_data->notification_text, data->window_icon);
|
||||||
|
|
||||||
if (notification == NULL) {
|
if (notification == NULL) {
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we aren't listening for changes, then close on default action */
|
/* if we aren't listening for changes, then close on default action */
|
||||||
notify_notification_add_action (notification,
|
notify_notification_add_action (notification,
|
||||||
"default",
|
"default",
|
||||||
"Do Default Action",
|
"Do Default Action",
|
||||||
(NotifyActionCallback) on_notification_default_action,
|
(NotifyActionCallback) on_notification_default_action,
|
||||||
data,
|
data,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* set the notification hints for the displayed notification */
|
/* 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);
|
notification_hints = zenity_notification_parse_hints_array (
|
||||||
zenity_notification_set_hints(notification, notification_hints);
|
notification_data->notification_hints);
|
||||||
g_hash_table_unref (notification_hints);
|
zenity_notification_set_hints (notification, notification_hints);
|
||||||
}
|
g_hash_table_unref (notification_hints);
|
||||||
|
}
|
||||||
|
|
||||||
/* Show icon and wait */
|
/* Show icon and wait */
|
||||||
error = NULL;
|
error = NULL;
|
||||||
if (!notify_notification_show (notification, &error)) {
|
if (!notify_notification_show (notification, &error)) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
g_warning ("Error showing notification: %s", error->message);
|
g_warning ("Error showing notification: %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
}
|
}
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
if (data->timeout_delay > 0) {
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
NULL);
|
||||||
gtk_main();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
4014
src/option.c
4014
src/option.c
File diff suppressed because it is too large
Load Diff
80
src/option.h
80
src/option.h
@ -31,61 +31,59 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MODE_CALENDAR,
|
MODE_CALENDAR,
|
||||||
MODE_ENTRY,
|
MODE_ENTRY,
|
||||||
MODE_ERROR,
|
MODE_ERROR,
|
||||||
MODE_FILE,
|
MODE_FILE,
|
||||||
MODE_LIST,
|
MODE_LIST,
|
||||||
MODE_PROGRESS,
|
MODE_PROGRESS,
|
||||||
MODE_QUESTION,
|
MODE_QUESTION,
|
||||||
MODE_TEXTINFO,
|
MODE_TEXTINFO,
|
||||||
MODE_WARNING,
|
MODE_WARNING,
|
||||||
MODE_SCALE,
|
MODE_SCALE,
|
||||||
MODE_INFO,
|
MODE_INFO,
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
MODE_NOTIFICATION,
|
MODE_NOTIFICATION,
|
||||||
#endif
|
#endif
|
||||||
MODE_COLOR,
|
MODE_COLOR,
|
||||||
MODE_PASSWORD,
|
MODE_PASSWORD,
|
||||||
MODE_FORMS,
|
MODE_FORMS,
|
||||||
MODE_ABOUT,
|
MODE_ABOUT,
|
||||||
MODE_VERSION,
|
MODE_VERSION,
|
||||||
MODE_LAST
|
MODE_LAST
|
||||||
} ZenityDialogMode;
|
} ZenityDialogMode;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ERROR_SYNTAX,
|
ERROR_SYNTAX,
|
||||||
ERROR_SUPPORT,
|
ERROR_SUPPORT,
|
||||||
ERROR_DIALOG,
|
ERROR_DIALOG,
|
||||||
ERROR_LAST
|
ERROR_LAST
|
||||||
} ZenityError;
|
} ZenityError;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
ZenityDialogMode mode;
|
ZenityDialogMode mode;
|
||||||
ZenityData *data;
|
ZenityData *data;
|
||||||
|
|
||||||
ZenityCalendarData *calendar_data;
|
ZenityCalendarData *calendar_data;
|
||||||
ZenityMsgData *msg_data;
|
ZenityMsgData *msg_data;
|
||||||
ZenityScaleData *scale_data;
|
ZenityScaleData *scale_data;
|
||||||
ZenityFileData *file_data;
|
ZenityFileData *file_data;
|
||||||
ZenityEntryData *entry_data;
|
ZenityEntryData *entry_data;
|
||||||
ZenityProgressData *progress_data;
|
ZenityProgressData *progress_data;
|
||||||
ZenityTextData *text_data;
|
ZenityTextData *text_data;
|
||||||
ZenityTreeData *tree_data;
|
ZenityTreeData *tree_data;
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
ZenityNotificationData *notification_data;
|
ZenityNotificationData *notification_data;
|
||||||
#endif
|
#endif
|
||||||
ZenityColorData *color_data;
|
ZenityColorData *color_data;
|
||||||
ZenityPasswordData *password_data;
|
ZenityPasswordData *password_data;
|
||||||
ZenityFormsData *forms_data;
|
ZenityFormsData *forms_data;
|
||||||
} ZenityParsingOptions;
|
} ZenityParsingOptions;
|
||||||
|
|
||||||
void zenity_option_error (gchar *string,
|
void zenity_option_error (gchar *string, ZenityError error);
|
||||||
ZenityError error);
|
|
||||||
|
|
||||||
ZenityParsingOptions * zenity_option_parse (gint argc,
|
ZenityParsingOptions *zenity_option_parse (gint argc, gchar **argv);
|
||||||
gchar **argv);
|
|
||||||
|
|
||||||
void zenity_option_free (void);
|
void zenity_option_free (void);
|
||||||
|
|
||||||
#endif /* OPTION_H */
|
#endif /* OPTION_H */
|
||||||
|
258
src/password.c
258
src/password.c
@ -22,168 +22,152 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <string.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
static ZenityData *zen_data;
|
static ZenityData *zen_data;
|
||||||
|
|
||||||
static void zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_password_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
void zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data)
|
void
|
||||||
{
|
zenity_password_dialog (ZenityData *data, ZenityPasswordData *password_data) {
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *vbox_labels;
|
GtkWidget *vbox_labels;
|
||||||
GtkWidget *vbox_entries;
|
GtkWidget *vbox_entries;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
dialog = gtk_dialog_new ();
|
dialog = gtk_dialog_new ();
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (data->extra_label) {
|
||||||
gint i=0;
|
gint i = 0;
|
||||||
while(data->extra_label[i]!=NULL){
|
while (data->extra_label[i] != NULL) {
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
gtk_dialog_add_button (
|
||||||
i++;
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtk_dialog_add_button(GTK_DIALOG(dialog),
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||||
data->cancel_label != NULL ? data->cancel_label : _("_Cancel"),
|
data->cancel_label != NULL ? data->cancel_label : _ ("_Cancel"),
|
||||||
GTK_RESPONSE_CANCEL);
|
GTK_RESPONSE_CANCEL);
|
||||||
gtk_dialog_add_button(GTK_DIALOG(dialog),
|
gtk_dialog_add_button (GTK_DIALOG (dialog),
|
||||||
data->ok_label != NULL ? data->ok_label : _("_OK"),
|
data->ok_label != NULL ? data->ok_label : _ ("_OK"),
|
||||||
GTK_RESPONSE_OK);
|
GTK_RESPONSE_OK);
|
||||||
|
|
||||||
image = gtk_image_new_from_icon_name("dialog-password",
|
|
||||||
GTK_ICON_SIZE_DIALOG);
|
|
||||||
gtk_dialog_set_default_response(GTK_DIALOG(dialog),
|
|
||||||
GTK_RESPONSE_OK);
|
|
||||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox),
|
|
||||||
image,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
12);
|
|
||||||
|
|
||||||
/* Checks if username has been passed as a parameter */
|
image =
|
||||||
gchar *title_text = N_("Type your password");
|
gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
|
||||||
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
|
||||||
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 12);
|
||||||
|
|
||||||
if(password_data->username)
|
/* Checks if username has been passed as a parameter */
|
||||||
title_text = N_("Type your username and password");
|
gchar *title_text = N_ ("Type your password");
|
||||||
|
|
||||||
label = gtk_label_new(title_text);
|
if (password_data->username)
|
||||||
|
title_text = N_ ("Type your username and password");
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox),
|
label = gtk_label_new (title_text);
|
||||||
label,
|
|
||||||
FALSE,
|
|
||||||
FALSE,
|
|
||||||
12);
|
|
||||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
|
|
||||||
hbox,
|
|
||||||
FALSE,
|
|
||||||
TRUE,
|
|
||||||
5);
|
|
||||||
|
|
||||||
vbox_labels = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
|
|
||||||
vbox_entries = gtk_box_new(GTK_ORIENTATION_VERTICAL, 5);
|
|
||||||
|
|
||||||
hbox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 5);
|
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 12);
|
||||||
gtk_box_pack_start(GTK_BOX(gtk_dialog_get_content_area(GTK_DIALOG(dialog))),
|
gtk_box_pack_start (
|
||||||
hbox,
|
GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||||
FALSE,
|
hbox,
|
||||||
TRUE,
|
FALSE,
|
||||||
5);
|
TRUE,
|
||||||
|
5);
|
||||||
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox),
|
vbox_labels = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||||
vbox_labels,
|
vbox_entries = gtk_box_new (GTK_ORIENTATION_VERTICAL, 5);
|
||||||
FALSE,
|
|
||||||
TRUE,
|
|
||||||
12);
|
|
||||||
gtk_box_pack_start(GTK_BOX(hbox),
|
|
||||||
vbox_entries,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
12);
|
|
||||||
|
|
||||||
if(password_data->username) {
|
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 5);
|
||||||
label = gtk_label_new(_("Username:"));
|
gtk_box_pack_start (
|
||||||
gtk_box_pack_start(GTK_BOX(vbox_labels),
|
GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
||||||
label,
|
hbox,
|
||||||
TRUE,
|
FALSE,
|
||||||
FALSE,
|
TRUE,
|
||||||
12);
|
5);
|
||||||
password_data->entry_username = gtk_entry_new();
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox_entries),
|
|
||||||
password_data->entry_username,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
12);
|
|
||||||
}
|
|
||||||
|
|
||||||
label = gtk_label_new(_("Password:"));
|
gtk_box_pack_start (GTK_BOX (hbox), vbox_labels, FALSE, TRUE, 12);
|
||||||
gtk_box_pack_start(GTK_BOX(vbox_labels),
|
gtk_box_pack_start (GTK_BOX (hbox), vbox_entries, TRUE, TRUE, 12);
|
||||||
label,
|
|
||||||
TRUE,
|
|
||||||
FALSE,
|
|
||||||
12);
|
|
||||||
password_data->entry_password = gtk_entry_new();
|
|
||||||
gtk_entry_set_visibility(GTK_ENTRY(password_data->entry_password),
|
|
||||||
FALSE);
|
|
||||||
gtk_entry_set_activates_default (GTK_ENTRY(password_data->entry_password),
|
|
||||||
TRUE);
|
|
||||||
gtk_box_pack_start(GTK_BOX(vbox_entries),
|
|
||||||
password_data->entry_password,
|
|
||||||
TRUE,
|
|
||||||
TRUE,
|
|
||||||
12);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
if (password_data->username) {
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
label = gtk_label_new (_ ("Username:"));
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox_labels), label, TRUE, FALSE, 12);
|
||||||
|
password_data->entry_username = gtk_entry_new ();
|
||||||
|
gtk_box_pack_start (GTK_BOX (vbox_entries),
|
||||||
|
password_data->entry_username,
|
||||||
|
TRUE,
|
||||||
|
TRUE,
|
||||||
|
12);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->modal)
|
label = gtk_label_new (_ ("Password:"));
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_box_pack_start (GTK_BOX (vbox_labels), label, TRUE, FALSE, 12);
|
||||||
|
password_data->entry_password = gtk_entry_new ();
|
||||||
|
gtk_entry_set_visibility (GTK_ENTRY (password_data->entry_password), FALSE);
|
||||||
|
gtk_entry_set_activates_default (
|
||||||
|
GTK_ENTRY (password_data->entry_password), TRUE);
|
||||||
|
gtk_box_pack_start (
|
||||||
|
GTK_BOX (vbox_entries), password_data->entry_password, TRUE, TRUE, 12);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
if (data->dialog_title)
|
||||||
G_CALLBACK (zenity_password_dialog_response),
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
password_data);
|
|
||||||
gtk_widget_show_all(GTK_WIDGET(gtk_dialog_get_content_area(GTK_DIALOG(dialog))));
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
|
||||||
|
|
||||||
if (data->timeout_delay > 0) {
|
if (data->modal)
|
||||||
g_timeout_add_seconds (data->timeout_delay,
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
(GSourceFunc) zenity_util_timeout_handle,
|
|
||||||
dialog);
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
}
|
"response",
|
||||||
gtk_main();
|
G_CALLBACK (zenity_password_dialog_response),
|
||||||
|
password_data);
|
||||||
|
gtk_widget_show_all (
|
||||||
|
GTK_WIDGET (gtk_dialog_get_content_area (GTK_DIALOG (dialog))));
|
||||||
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_password_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_password_dialog_response (
|
||||||
{
|
GtkWidget *widget, int response, gpointer data) {
|
||||||
ZenityPasswordData *password_data = (ZenityPasswordData *) data;
|
ZenityPasswordData *password_data = (ZenityPasswordData *) data;
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
if (password_data->username)
|
if (password_data->username)
|
||||||
g_print("%s|%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_username)), gtk_entry_get_text (GTK_ENTRY(password_data->entry_password)));
|
g_print ("%s|%s\n",
|
||||||
else
|
gtk_entry_get_text (
|
||||||
g_print ("%s\n", gtk_entry_get_text (GTK_ENTRY(password_data->entry_password)));
|
GTK_ENTRY (password_data->entry_username)),
|
||||||
break;
|
gtk_entry_get_text (
|
||||||
|
GTK_ENTRY (password_data->entry_password)));
|
||||||
|
else
|
||||||
|
g_print ("%s\n",
|
||||||
|
gtk_entry_get_text (
|
||||||
|
GTK_ENTRY (password_data->entry_password)));
|
||||||
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
571
src/progress.c
571
src/progress.c
@ -23,15 +23,15 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <signal.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <time.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
static GtkBuilder *builder;
|
static GtkBuilder *builder;
|
||||||
static ZenityData *zen_data;
|
static ZenityData *zen_data;
|
||||||
@ -45,358 +45,385 @@ static gboolean auto_close;
|
|||||||
gint zenity_progress_timeout (gpointer data);
|
gint zenity_progress_timeout (gpointer data);
|
||||||
gint zenity_progress_pulsate_timeout (gpointer data);
|
gint zenity_progress_pulsate_timeout (gpointer data);
|
||||||
|
|
||||||
static void zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_progress_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_progress_pulsate_progress_bar (gpointer user_data)
|
zenity_progress_pulsate_progress_bar (gpointer user_data) {
|
||||||
{
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (user_data));
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (user_data));
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_pulsate_stop (void)
|
zenity_progress_pulsate_stop (void) {
|
||||||
{
|
if (pulsate_timeout > 0) {
|
||||||
if (pulsate_timeout > 0) {
|
g_source_remove (pulsate_timeout);
|
||||||
g_source_remove (pulsate_timeout);
|
pulsate_timeout = -1;
|
||||||
pulsate_timeout = -1;
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_pulsate_start (GObject *progress_bar)
|
zenity_progress_pulsate_start (GObject *progress_bar) {
|
||||||
{
|
if (pulsate_timeout == -1) {
|
||||||
if (pulsate_timeout == -1) {
|
pulsate_timeout = g_timeout_add (
|
||||||
pulsate_timeout = g_timeout_add (100,
|
100, zenity_progress_pulsate_progress_bar, progress_bar);
|
||||||
zenity_progress_pulsate_progress_bar,
|
}
|
||||||
progress_bar);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_update_time_remaining (ZenityProgressData *progress_data)
|
zenity_progress_update_time_remaining (ZenityProgressData *progress_data) {
|
||||||
{
|
static GObject *progress_time = NULL;
|
||||||
static GObject *progress_time = NULL;
|
static time_t start_time = (time_t) (-1);
|
||||||
static time_t start_time = (time_t)(-1);
|
float percentage = progress_data->percentage;
|
||||||
float percentage = progress_data->percentage;
|
|
||||||
|
|
||||||
if (progress_time == NULL)
|
if (progress_time == NULL)
|
||||||
progress_time = gtk_builder_get_object (builder, "zenity_progress_time");
|
progress_time =
|
||||||
if (start_time == (time_t)(-1) || percentage <= 0.0 || percentage >= 100.0) {
|
gtk_builder_get_object (builder, "zenity_progress_time");
|
||||||
start_time = time(NULL);
|
if (start_time == (time_t) (-1) || percentage <= 0.0 ||
|
||||||
gtk_label_set_text (GTK_LABEL (progress_time), "");
|
percentage >= 100.0) {
|
||||||
} else {
|
start_time = time (NULL);
|
||||||
time_t current_time = time (NULL);
|
gtk_label_set_text (GTK_LABEL (progress_time), "");
|
||||||
time_t elapsed_time = current_time - start_time;
|
} else {
|
||||||
time_t total_time = (time_t) (100.0*elapsed_time/progress_data->percentage);
|
time_t current_time = time (NULL);
|
||||||
time_t remaining_time = total_time - elapsed_time;
|
time_t elapsed_time = current_time - start_time;
|
||||||
gulong hours, minutes, seconds;
|
time_t total_time =
|
||||||
gchar *remaining_message;
|
(time_t) (100.0 * elapsed_time / progress_data->percentage);
|
||||||
|
time_t remaining_time = total_time - elapsed_time;
|
||||||
|
gulong hours, minutes, seconds;
|
||||||
|
gchar *remaining_message;
|
||||||
|
|
||||||
seconds = (gulong) (remaining_time%60);
|
seconds = (gulong) (remaining_time % 60);
|
||||||
remaining_time /= 60;
|
remaining_time /= 60;
|
||||||
minutes = (gulong) (remaining_time%60);
|
minutes = (gulong) (remaining_time % 60);
|
||||||
remaining_time /= 60;
|
remaining_time /= 60;
|
||||||
hours = (gulong) remaining_time;
|
hours = (gulong) remaining_time;
|
||||||
|
|
||||||
remaining_message = g_strdup_printf (_("Time remaining: %lu:%02lu:%02lu"),
|
remaining_message = g_strdup_printf (
|
||||||
hours, minutes, seconds);
|
_ ("Time remaining: %lu:%02lu:%02lu"), hours, minutes, seconds);
|
||||||
gtk_label_set_text (GTK_LABEL (progress_time), remaining_message);
|
gtk_label_set_text (GTK_LABEL (progress_time), remaining_message);
|
||||||
g_free (remaining_message);
|
g_free (remaining_message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_progress_handle_stdin (GIOChannel *channel,
|
zenity_progress_handle_stdin (
|
||||||
GIOCondition condition,
|
GIOChannel *channel, GIOCondition condition, gpointer data) {
|
||||||
gpointer data)
|
static ZenityProgressData *progress_data;
|
||||||
{
|
static GObject *progress_bar;
|
||||||
static ZenityProgressData *progress_data;
|
static GObject *progress_label;
|
||||||
static GObject *progress_bar;
|
float percentage = 0.0;
|
||||||
static GObject *progress_label;
|
GIOStatus status = G_IO_STATUS_NORMAL;
|
||||||
float percentage = 0.0;
|
|
||||||
GIOStatus status = G_IO_STATUS_NORMAL;
|
|
||||||
|
|
||||||
progress_data = (ZenityProgressData *) data;
|
|
||||||
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
|
|
||||||
progress_label = gtk_builder_get_object (builder, "zenity_progress_text");
|
|
||||||
|
|
||||||
if ((condition & G_IO_IN) != 0) {
|
progress_data = (ZenityProgressData *) data;
|
||||||
GString *string;
|
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
|
||||||
GError *error = NULL;
|
progress_label = gtk_builder_get_object (builder, "zenity_progress_text");
|
||||||
|
|
||||||
string = g_string_new (NULL);
|
if ((condition & G_IO_IN) != 0) {
|
||||||
|
GString *string;
|
||||||
|
GError *error = NULL;
|
||||||
|
|
||||||
while (channel->is_readable != TRUE)
|
string = g_string_new (NULL);
|
||||||
;
|
|
||||||
do {
|
|
||||||
do {
|
|
||||||
status = g_io_channel_read_line_string (channel, string, NULL, &error);
|
|
||||||
|
|
||||||
while (gtk_events_pending ())
|
while (channel->is_readable != TRUE)
|
||||||
gtk_main_iteration ();
|
;
|
||||||
|
do {
|
||||||
|
do {
|
||||||
|
status = g_io_channel_read_line_string (
|
||||||
|
channel, string, NULL, &error);
|
||||||
|
|
||||||
} while (status == G_IO_STATUS_AGAIN);
|
while (gtk_events_pending ())
|
||||||
|
gtk_main_iteration ();
|
||||||
|
|
||||||
if (status != G_IO_STATUS_NORMAL) {
|
} while (status == G_IO_STATUS_AGAIN);
|
||||||
if (error) {
|
|
||||||
g_warning ("zenity_progress_handle_stdin () : %s", error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
error = NULL;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!g_ascii_strncasecmp (string->str, "#", 1)) {
|
if (status != G_IO_STATUS_NORMAL) {
|
||||||
gchar *match;
|
if (error) {
|
||||||
|
g_warning (
|
||||||
|
"zenity_progress_handle_stdin () : %s", error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
error = NULL;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
/* We have a comment, so let's try to change the label */
|
if (!g_ascii_strncasecmp (string->str, "#", 1)) {
|
||||||
match = g_strstr_len (string->str, strlen (string->str), "#");
|
gchar *match;
|
||||||
match++;
|
|
||||||
gtk_label_set_text (GTK_LABEL (progress_label), g_strcompress(g_strchomp (g_strchug (match))));
|
|
||||||
|
|
||||||
} else if (g_str_has_prefix (string->str, "pulsate")) {
|
/* We have a comment, so let's try to change the label */
|
||||||
gchar *colon, *command, *value;
|
match = g_strstr_len (string->str, strlen (string->str), "#");
|
||||||
|
match++;
|
||||||
|
gtk_label_set_text (GTK_LABEL (progress_label),
|
||||||
|
g_strcompress (g_strchomp (g_strchug (match))));
|
||||||
|
|
||||||
zenity_util_strip_newline (string->str);
|
} else if (g_str_has_prefix (string->str, "pulsate")) {
|
||||||
|
gchar *colon, *command, *value;
|
||||||
|
|
||||||
colon = strchr(string->str, ':');
|
zenity_util_strip_newline (string->str);
|
||||||
if (colon == NULL) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* split off the command and value */
|
colon = strchr (string->str, ':');
|
||||||
command = g_strstrip (g_strndup (string->str, colon - string->str));
|
if (colon == NULL) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
value = colon + 1;
|
/* split off the command and value */
|
||||||
while (*value && g_ascii_isspace (*value)) value++;
|
command =
|
||||||
|
g_strstrip (g_strndup (string->str, colon - string->str));
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp (value, "false")) {
|
value = colon + 1;
|
||||||
zenity_progress_pulsate_stop ();
|
while (*value && g_ascii_isspace (*value))
|
||||||
|
value++;
|
||||||
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
if (!g_ascii_strcasecmp (value, "false")) {
|
||||||
progress_data->percentage / 100.0);
|
zenity_progress_pulsate_stop ();
|
||||||
} else {
|
|
||||||
zenity_progress_pulsate_start (progress_bar);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (command);
|
gtk_progress_bar_set_fraction (
|
||||||
} else {
|
GTK_PROGRESS_BAR (progress_bar),
|
||||||
|
progress_data->percentage / 100.0);
|
||||||
|
} else {
|
||||||
|
zenity_progress_pulsate_start (progress_bar);
|
||||||
|
}
|
||||||
|
|
||||||
if (!g_ascii_isdigit (*(string->str)))
|
g_free (command);
|
||||||
continue;
|
} else {
|
||||||
|
|
||||||
/* Now try to convert the thing to a number */
|
if (!g_ascii_isdigit (*(string->str)))
|
||||||
percentage = CLAMP(atoi (string->str), 0, 100);
|
continue;
|
||||||
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
/* Now try to convert the thing to a number */
|
||||||
percentage / 100.0);
|
percentage = CLAMP (atoi (string->str), 0, 100);
|
||||||
|
|
||||||
progress_data->percentage = percentage;
|
gtk_progress_bar_set_fraction (
|
||||||
|
GTK_PROGRESS_BAR (progress_bar), percentage / 100.0);
|
||||||
|
|
||||||
if (progress_data->time_remaining == TRUE)
|
progress_data->percentage = percentage;
|
||||||
zenity_progress_update_time_remaining (progress_data);
|
|
||||||
|
|
||||||
if (percentage == 100) {
|
if (progress_data->time_remaining == TRUE)
|
||||||
GObject *button;
|
zenity_progress_update_time_remaining (progress_data);
|
||||||
|
|
||||||
button = gtk_builder_get_object(builder, "zenity_progress_ok_button");
|
if (percentage == 100) {
|
||||||
gtk_widget_set_sensitive(GTK_WIDGET (button), TRUE);
|
GObject *button;
|
||||||
gtk_widget_grab_focus(GTK_WIDGET (button));
|
|
||||||
|
|
||||||
if (progress_data->autoclose) {
|
button = gtk_builder_get_object (
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
builder, "zenity_progress_ok_button");
|
||||||
gtk_main_quit();
|
gtk_widget_set_sensitive (GTK_WIDGET (button), TRUE);
|
||||||
}
|
gtk_widget_grab_focus (GTK_WIDGET (button));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) == G_IO_IN && status != G_IO_STATUS_EOF);
|
if (progress_data->autoclose) {
|
||||||
g_string_free (string, TRUE);
|
zen_data->exit_code =
|
||||||
}
|
zenity_util_return_exit_code (ZENITY_OK);
|
||||||
|
gtk_main_quit ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) {
|
} while ((g_io_channel_get_buffer_condition (channel) & G_IO_IN) ==
|
||||||
/* We assume that we are done, so stop the pulsating and de-sensitize the buttons */
|
G_IO_IN &&
|
||||||
GtkWidget *button;
|
status != G_IO_STATUS_EOF);
|
||||||
|
g_string_free (string, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder,
|
if ((condition & G_IO_IN) != G_IO_IN || status == G_IO_STATUS_EOF) {
|
||||||
"zenity_progress_ok_button"));
|
/* We assume that we are done, so stop the pulsating and de-sensitize
|
||||||
gtk_widget_set_sensitive (button, TRUE);
|
* the buttons */
|
||||||
gtk_widget_grab_focus (button);
|
GtkWidget *button;
|
||||||
|
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder,
|
button = GTK_WIDGET (
|
||||||
"zenity_progress_cancel_button"));
|
gtk_builder_get_object (builder, "zenity_progress_ok_button"));
|
||||||
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
|
gtk_widget_grab_focus (button);
|
||||||
|
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_progress_cancel_button"));
|
||||||
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
|
||||||
zenity_progress_pulsate_stop ();
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), 1.0);
|
||||||
|
|
||||||
g_object_unref (builder);
|
zenity_progress_pulsate_stop ();
|
||||||
|
|
||||||
if (progress_data->autoclose) {
|
g_object_unref (builder);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
|
||||||
gtk_main_quit();
|
|
||||||
}
|
|
||||||
|
|
||||||
g_io_channel_shutdown (channel, TRUE, NULL);
|
if (progress_data->autoclose) {
|
||||||
return FALSE;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
||||||
}
|
gtk_main_quit ();
|
||||||
return TRUE;
|
}
|
||||||
|
|
||||||
|
g_io_channel_shutdown (channel, TRUE, NULL);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_read_info (ZenityProgressData *progress_data)
|
zenity_progress_read_info (ZenityProgressData *progress_data) {
|
||||||
{
|
channel = g_io_channel_unix_new (0);
|
||||||
channel = g_io_channel_unix_new (0);
|
g_io_channel_set_encoding (channel, NULL, NULL);
|
||||||
g_io_channel_set_encoding (channel, NULL, NULL);
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
||||||
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
g_io_add_watch (channel,
|
||||||
g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_progress_handle_stdin, progress_data);
|
G_IO_IN | G_IO_HUP,
|
||||||
/* We need to check the pulsate state here, because, the g_io_add_watch
|
zenity_progress_handle_stdin,
|
||||||
doesn't call the zenity_progress_handle_stdin function if there's no
|
progress_data);
|
||||||
input. This fix the Bug 567663 */
|
/* We need to check the pulsate state here, because, the g_io_add_watch
|
||||||
if (progress_data->pulsate) {
|
doesn't call the zenity_progress_handle_stdin function if there's no
|
||||||
GObject *progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
|
input. This fix the Bug 567663 */
|
||||||
zenity_progress_pulsate_start (progress_bar);
|
if (progress_data->pulsate) {
|
||||||
}
|
GObject *progress_bar =
|
||||||
|
gtk_builder_get_object (builder, "zenity_progress_bar");
|
||||||
|
zenity_progress_pulsate_start (progress_bar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_size_allocate (GtkWidget *widget, GtkAllocation *allocation, gpointer data)
|
zenity_text_size_allocate (
|
||||||
{
|
GtkWidget *widget, GtkAllocation *allocation, gpointer data) {
|
||||||
gtk_widget_set_size_request (widget, allocation->width/2, -1);
|
gtk_widget_set_size_request (widget, allocation->width / 2, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
zenity_progress (ZenityData *data, ZenityProgressData *progress_data) {
|
||||||
{
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *button;
|
||||||
GtkWidget *button;
|
GObject *text;
|
||||||
GObject *text;
|
GObject *progress_bar;
|
||||||
GObject *progress_bar;
|
GObject *cancel_button, *ok_button;
|
||||||
GObject *cancel_button,*ok_button;
|
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL);
|
builder = zenity_util_load_ui_file ("zenity_progress_dialog", NULL);
|
||||||
|
|
||||||
if (builder == NULL) {
|
if (builder == NULL) {
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
|
|
||||||
text = gtk_builder_get_object (builder, "zenity_progress_text");
|
text = gtk_builder_get_object (builder, "zenity_progress_text");
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder,
|
dialog =
|
||||||
"zenity_progress_dialog"));
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_dialog"));
|
||||||
|
|
||||||
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
|
progress_bar = gtk_builder_get_object (builder, "zenity_progress_bar");
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
G_CALLBACK (zenity_progress_dialog_response), data);
|
"response",
|
||||||
|
G_CALLBACK (zenity_progress_dialog_response),
|
||||||
|
data);
|
||||||
|
|
||||||
if (data->dialog_title)
|
if (data->dialog_title)
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-progress.png"));
|
zenity_util_set_window_icon (dialog,
|
||||||
|
data->window_icon,
|
||||||
|
ZENITY_IMAGE_FULLPATH ("zenity-progress.png"));
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
if (data->width > -1 || data->height > -1)
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
gtk_window_set_default_size (
|
||||||
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
|
||||||
if (data->width > -1) {
|
if (data->width > -1) {
|
||||||
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
gtk_widget_set_size_request (GTK_WIDGET (text), data->width, -1);
|
||||||
}
|
} else {
|
||||||
else {
|
g_signal_connect_after (G_OBJECT (text),
|
||||||
g_signal_connect_after (G_OBJECT (text), "size-allocate",
|
"size-allocate",
|
||||||
G_CALLBACK (zenity_text_size_allocate), data);
|
G_CALLBACK (zenity_text_size_allocate),
|
||||||
g_signal_connect_after (G_OBJECT (progress_bar), "size-allocate",
|
data);
|
||||||
G_CALLBACK (zenity_text_size_allocate), data);
|
g_signal_connect_after (G_OBJECT (progress_bar),
|
||||||
}
|
"size-allocate",
|
||||||
|
G_CALLBACK (zenity_text_size_allocate),
|
||||||
|
data);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->modal)
|
if (data->modal)
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (data->extra_label) {
|
||||||
gint i=0;
|
gint i = 0;
|
||||||
while(data->extra_label[i]!=NULL){
|
while (data->extra_label[i] != NULL) {
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
gtk_dialog_add_button (
|
||||||
i++;
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
}
|
i++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (data->ok_label) {
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_ok_button"));
|
button = GTK_WIDGET (
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
gtk_builder_get_object (builder, "zenity_progress_ok_button"));
|
||||||
}
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
|
}
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (data->cancel_label) {
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_progress_cancel_button"));
|
button = GTK_WIDGET (
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
gtk_builder_get_object (builder, "zenity_progress_cancel_button"));
|
||||||
}
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
|
}
|
||||||
|
|
||||||
if (progress_data->dialog_text)
|
if (progress_data->dialog_text)
|
||||||
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (progress_data->dialog_text));
|
gtk_label_set_markup (
|
||||||
|
GTK_LABEL (text), g_strcompress (progress_data->dialog_text));
|
||||||
|
|
||||||
if (progress_data->percentage > -1)
|
if (progress_data->percentage > -1)
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
gtk_progress_bar_set_fraction (
|
||||||
progress_data->percentage/100.0);
|
GTK_PROGRESS_BAR (progress_bar), progress_data->percentage / 100.0);
|
||||||
|
|
||||||
autokill = progress_data->autokill;
|
autokill = progress_data->autokill;
|
||||||
|
|
||||||
auto_close = progress_data->autoclose;
|
auto_close = progress_data->autoclose;
|
||||||
ok_button = gtk_builder_get_object (builder, "zenity_progress_ok_button");
|
ok_button = gtk_builder_get_object (builder, "zenity_progress_ok_button");
|
||||||
|
|
||||||
no_cancel = progress_data->no_cancel;
|
no_cancel = progress_data->no_cancel;
|
||||||
cancel_button = gtk_builder_get_object (builder, "zenity_progress_cancel_button");
|
cancel_button =
|
||||||
|
gtk_builder_get_object (builder, "zenity_progress_cancel_button");
|
||||||
|
|
||||||
if (no_cancel) {
|
if (no_cancel) {
|
||||||
gtk_widget_hide (GTK_WIDGET(cancel_button));
|
gtk_widget_hide (GTK_WIDGET (cancel_button));
|
||||||
gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
|
gtk_window_set_deletable (GTK_WINDOW (dialog), FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (no_cancel && auto_close)
|
if (no_cancel && auto_close)
|
||||||
gtk_widget_hide(GTK_WIDGET(ok_button));
|
gtk_widget_hide (GTK_WIDGET (ok_button));
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
zenity_progress_read_info (progress_data);
|
zenity_progress_read_info (progress_data);
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, NULL);
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
}
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_progress_dialog_response (
|
||||||
{
|
GtkWidget *widget, int response, gpointer data) {
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
/* We do not want to kill the parent process, in order to give the user
|
/* We do not want to kill the parent process, in order to give the
|
||||||
the ability to choose the action to be taken. See bug #310824.
|
user
|
||||||
But we want to give people the option to choose this behavior.
|
the ability to choose the action to be taken. See bug #310824.
|
||||||
-- Monday 27, March 2006
|
But we want to give people the option to choose this behavior.
|
||||||
*/
|
-- Monday 27, March 2006
|
||||||
if (autokill) {
|
*/
|
||||||
kill (getppid (), 1);
|
if (autokill) {
|
||||||
}
|
kill (getppid (), 1);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
}
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_TIMEOUT, zen_data);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
213
src/scale.c
213
src/scale.c
@ -23,136 +23,151 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
|
||||||
static GtkWidget *scale;
|
static GtkWidget *scale;
|
||||||
|
|
||||||
static void zenity_scale_value_changed (GtkWidget *widget, gpointer data);
|
static void zenity_scale_value_changed (GtkWidget *widget, gpointer data);
|
||||||
static void zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_scale_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_scale (ZenityData *data, ZenityScaleData *scale_data)
|
zenity_scale (ZenityData *data, ZenityScaleData *scale_data) {
|
||||||
{
|
GtkBuilder *builder;
|
||||||
GtkBuilder *builder;
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *button;
|
||||||
GtkWidget *button;
|
GObject *text;
|
||||||
GObject *text;
|
|
||||||
|
|
||||||
builder = zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL);
|
builder =
|
||||||
|
zenity_util_load_ui_file ("zenity_scale_dialog", "adjustment1", NULL);
|
||||||
|
|
||||||
if (builder == NULL) {
|
if (builder == NULL) {
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog"));
|
dialog =
|
||||||
scale = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale"));
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_dialog"));
|
||||||
text = gtk_builder_get_object (builder, "zenity_scale_text");
|
scale =
|
||||||
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_hscale"));
|
||||||
|
text = gtk_builder_get_object (builder, "zenity_scale_text");
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
G_CALLBACK (zenity_scale_dialog_response), data);
|
"response",
|
||||||
|
G_CALLBACK (zenity_scale_dialog_response),
|
||||||
if (scale_data->min_value >= scale_data->max_value) {
|
data);
|
||||||
g_printerr (_("Maximum value must be greater than minimum value.\n"));
|
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scale_data->value < scale_data->min_value ||
|
if (scale_data->min_value >= scale_data->max_value) {
|
||||||
scale_data->value > scale_data->max_value) {
|
g_printerr (_ ("Maximum value must be greater than minimum value.\n"));
|
||||||
g_printerr (_("Value out of range.\n"));
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
if (scale_data->value < scale_data->min_value ||
|
||||||
|
scale_data->value > scale_data->max_value) {
|
||||||
if (data->dialog_title)
|
g_printerr (_ ("Value out of range.\n"));
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-scale.png"));
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
|
||||||
|
|
||||||
if (data->modal)
|
if (data->dialog_title)
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
if (data->extra_label) {
|
zenity_util_set_window_icon (
|
||||||
gint i=0;
|
dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-scale.png"));
|
||||||
while(data->extra_label[i]!=NULL){
|
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (data->width > -1 || data->height > -1)
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_ok_button"));
|
gtk_window_set_default_size (
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
}
|
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (data->modal)
|
||||||
button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_scale_cancel_button"));
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (scale_data->dialog_text)
|
if (data->extra_label) {
|
||||||
gtk_label_set_markup (GTK_LABEL (text), g_strcompress (scale_data->dialog_text));
|
gint i = 0;
|
||||||
|
while (data->extra_label[i] != NULL) {
|
||||||
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gtk_range_set_range (GTK_RANGE (scale), scale_data->min_value, scale_data->max_value);
|
if (data->ok_label) {
|
||||||
gtk_range_set_value (GTK_RANGE (scale), scale_data->value);
|
button = GTK_WIDGET (
|
||||||
gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0);
|
gtk_builder_get_object (builder, "zenity_scale_ok_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->ok_label);
|
||||||
|
}
|
||||||
|
|
||||||
if (scale_data->print_partial)
|
if (data->cancel_label) {
|
||||||
g_signal_connect (G_OBJECT (scale), "value-changed",
|
button = GTK_WIDGET (
|
||||||
G_CALLBACK (zenity_scale_value_changed), data);
|
gtk_builder_get_object (builder, "zenity_scale_cancel_button"));
|
||||||
|
gtk_button_set_label (GTK_BUTTON (button), data->cancel_label);
|
||||||
if (scale_data->hide_value)
|
}
|
||||||
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if (scale_data->dialog_text)
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
gtk_label_set_markup (
|
||||||
}
|
GTK_LABEL (text), g_strcompress (scale_data->dialog_text));
|
||||||
|
|
||||||
g_object_unref (builder);
|
gtk_range_set_range (
|
||||||
|
GTK_RANGE (scale), scale_data->min_value, scale_data->max_value);
|
||||||
|
gtk_range_set_value (GTK_RANGE (scale), scale_data->value);
|
||||||
|
gtk_range_set_increments (GTK_RANGE (scale), scale_data->step, 0);
|
||||||
|
|
||||||
gtk_main ();
|
if (scale_data->print_partial)
|
||||||
|
g_signal_connect (G_OBJECT (scale),
|
||||||
|
"value-changed",
|
||||||
|
G_CALLBACK (zenity_scale_value_changed),
|
||||||
|
data);
|
||||||
|
|
||||||
|
if (scale_data->hide_value)
|
||||||
|
gtk_scale_set_draw_value (GTK_SCALE (scale), FALSE);
|
||||||
|
|
||||||
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
|
if (data->timeout_delay > 0) {
|
||||||
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_object_unref (builder);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_scale_value_changed (GtkWidget *widget, gpointer data)
|
zenity_scale_value_changed (GtkWidget *widget, gpointer data) {
|
||||||
{
|
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (widget)));
|
||||||
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (widget)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_scale_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityData *zen_data = data;
|
||||||
ZenityData *zen_data = data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zenity_util_exit_code_with_data(ZENITY_OK, zen_data);
|
zenity_util_exit_code_with_data (ZENITY_OK, zen_data);
|
||||||
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale)));
|
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_CANCEL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale)));
|
g_print ("%.0f\n", gtk_range_get_value (GTK_RANGE (scale)));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_ESC);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
617
src/text.c
617
src/text.c
@ -23,375 +23,426 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <gio/gio.h>
|
|
||||||
#include "zenity.h"
|
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
#include "zenity.h"
|
||||||
|
#include <gio/gio.h>
|
||||||
|
|
||||||
#ifdef HAVE_WEBKITGTK
|
#ifdef HAVE_WEBKITGTK
|
||||||
#include <webkit2/webkit2.h>
|
#include <webkit2/webkit2.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static ZenityTextData *zen_text_data;
|
static ZenityTextData *zen_text_data;
|
||||||
|
|
||||||
static void zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data);
|
static void zenity_text_dialog_response (
|
||||||
|
GtkWidget *widget, int response, gpointer data);
|
||||||
static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data);
|
static void zenity_text_toggle_button (GtkToggleButton *button, gpointer data);
|
||||||
|
|
||||||
#ifdef HAVE_WEBKITGTK
|
#ifdef HAVE_WEBKITGTK
|
||||||
static void
|
static void
|
||||||
zenity_configure_webkit (WebKitWebView *web_view)
|
zenity_configure_webkit (WebKitWebView *web_view) {
|
||||||
{
|
WebKitSettings *settings;
|
||||||
WebKitSettings *settings;
|
settings = webkit_web_view_get_settings (web_view);
|
||||||
settings = webkit_web_view_get_settings(web_view);
|
g_object_set (G_OBJECT (settings), "auto-load-images", TRUE, NULL);
|
||||||
g_object_set(G_OBJECT(settings), "auto-load-images", TRUE, NULL);
|
/*
|
||||||
/*
|
Stick to the defaults
|
||||||
Stick to the defaults
|
"cursive-font-family" gchar* : Read / Write /
|
||||||
"cursive-font-family" gchar* : Read / Write / Construct
|
Construct
|
||||||
"default-encoding" gchar* : Read / Write / Construct
|
"default-encoding" gchar* : Read / Write /
|
||||||
"default-font-family" gchar* : Read / Write / Construct
|
Construct
|
||||||
"default-font-size" gint : Read / Write / Construct
|
"default-font-family" gchar* : Read / Write /
|
||||||
"default-monospace-font-size" gint : Read / Write / Construct
|
Construct
|
||||||
"editing-behavior" WebKitEditingBehavior : Read / Write / Construct
|
"default-font-size" gint : Read / Write /
|
||||||
*/
|
Construct
|
||||||
g_object_set(G_OBJECT(settings), "enable-caret-browsing", FALSE, NULL);
|
"default-monospace-font-size" gint : Read / Write /
|
||||||
g_object_set(G_OBJECT(settings), "enable-developer-extras", FALSE, NULL);
|
Construct
|
||||||
g_object_set(G_OBJECT(settings), "enable-fullscreen", FALSE, NULL);
|
"editing-behavior" WebKitEditingBehavior : Read / Write /
|
||||||
g_object_set(G_OBJECT(settings), "enable-html5-database", FALSE, NULL);
|
Construct
|
||||||
g_object_set(G_OBJECT(settings), "enable-html5-local-storage", FALSE, NULL);
|
*/
|
||||||
g_object_set(G_OBJECT(settings), "enable-java", FALSE, NULL);
|
g_object_set (G_OBJECT (settings), "enable-caret-browsing", FALSE, NULL);
|
||||||
g_object_set(G_OBJECT(settings), "enable-javascript", FALSE, NULL);
|
g_object_set (G_OBJECT (settings), "enable-developer-extras", FALSE, NULL);
|
||||||
g_object_set(G_OBJECT(settings), "enable-offline-web-application-cache", FALSE, NULL);
|
g_object_set (G_OBJECT (settings), "enable-fullscreen", FALSE, NULL);
|
||||||
g_object_set(G_OBJECT(settings), "enable-page-cache", FALSE, NULL);
|
g_object_set (G_OBJECT (settings), "enable-html5-database", FALSE, NULL);
|
||||||
g_object_set(G_OBJECT(settings), "enable-plugins", FALSE, NULL);
|
g_object_set (
|
||||||
g_object_set(G_OBJECT(settings), "enable-private-browsing", TRUE, NULL);
|
G_OBJECT (settings), "enable-html5-local-storage", FALSE, NULL);
|
||||||
/*
|
g_object_set (G_OBJECT (settings), "enable-java", FALSE, NULL);
|
||||||
Stick to defaults
|
g_object_set (G_OBJECT (settings), "enable-javascript", FALSE, NULL);
|
||||||
"enforce-96-dpi" gboolean : Read / Write / Construct
|
g_object_set (G_OBJECT (settings),
|
||||||
"fantasy-font-family" gchar* : Read / Write / Construct
|
"enable-offline-web-application-cache",
|
||||||
*/
|
FALSE,
|
||||||
/*
|
NULL);
|
||||||
Stick to defaults
|
g_object_set (G_OBJECT (settings), "enable-page-cache", FALSE, NULL);
|
||||||
"minimum-font-size" gint : Read / Write / Construct
|
g_object_set (G_OBJECT (settings), "enable-plugins", FALSE, NULL);
|
||||||
"minimum-logical-font-size" gint : Read / Write / Construct
|
g_object_set (G_OBJECT (settings), "enable-private-browsing", TRUE, NULL);
|
||||||
"monospace-font-family" gchar* : Read / Write / Construct
|
/*
|
||||||
"print-backgrounds" gboolean : Read / Write / Construct
|
Stick to defaults
|
||||||
"resizable-text-areas" gboolean : Read / Write / Construct
|
"enforce-96-dpi" gboolean : Read / Write /
|
||||||
"sans-serif-font-family" gchar* : Read / Write / Construct
|
Construct
|
||||||
"serif-font-family" gchar* : Read / Write / Construct
|
"fantasy-font-family" gchar* : Read / Write /
|
||||||
"spell-checking-languages" gchar* : Read / Write / Construct
|
Construct
|
||||||
*/
|
*/
|
||||||
g_object_set(G_OBJECT(settings), "enable-tabs-to-links", FALSE, NULL);
|
/*
|
||||||
g_object_set(G_OBJECT(settings), "user-agent",
|
Stick to defaults
|
||||||
"Zenity with WebKit (KHTML, like Gecko) support", NULL);
|
"minimum-font-size" gint : Read / Write /
|
||||||
/*
|
Construct
|
||||||
Stick to defaults
|
"minimum-logical-font-size" gint : Read / Write /
|
||||||
"user-stylesheet-uri" gchar* : Read / Write / Construct
|
Construct
|
||||||
"zoom-step" gfloat : Read / Write / Construct
|
"monospace-font-family" gchar* : Read / Write /
|
||||||
*/
|
Construct
|
||||||
|
"print-backgrounds" gboolean : Read / Write /
|
||||||
|
Construct
|
||||||
|
"resizable-text-areas" gboolean : Read / Write /
|
||||||
|
Construct
|
||||||
|
"sans-serif-font-family" gchar* : Read / Write /
|
||||||
|
Construct
|
||||||
|
"serif-font-family" gchar* : Read / Write /
|
||||||
|
Construct
|
||||||
|
"spell-checking-languages" gchar* : Read / Write /
|
||||||
|
Construct
|
||||||
|
*/
|
||||||
|
g_object_set (G_OBJECT (settings), "enable-tabs-to-links", FALSE, NULL);
|
||||||
|
g_object_set (G_OBJECT (settings),
|
||||||
|
"user-agent",
|
||||||
|
"Zenity with WebKit (KHTML, like Gecko) support",
|
||||||
|
NULL);
|
||||||
|
/*
|
||||||
|
Stick to defaults
|
||||||
|
"user-stylesheet-uri" gchar* : Read / Write /
|
||||||
|
Construct
|
||||||
|
"zoom-step" gfloat : Read / Write /
|
||||||
|
Construct
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_text_webview_decision_request (WebKitWebView *web_view,
|
zenity_text_webview_decision_request (WebKitWebView *web_view,
|
||||||
WebKitPolicyDecision *decision,
|
WebKitPolicyDecision *decision, WebKitPolicyDecisionType type) {
|
||||||
WebKitPolicyDecisionType type)
|
if (type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) {
|
||||||
{
|
WebKitNavigationPolicyDecision *navigation_decision =
|
||||||
if (type == WEBKIT_POLICY_DECISION_TYPE_NAVIGATION_ACTION) {
|
WEBKIT_NAVIGATION_POLICY_DECISION (decision);
|
||||||
WebKitNavigationPolicyDecision *navigation_decision = WEBKIT_NAVIGATION_POLICY_DECISION (decision);
|
WebKitNavigationAction *navigation_action =
|
||||||
WebKitNavigationAction *navigation_action = webkit_navigation_policy_decision_get_navigation_action(navigation_decision);
|
webkit_navigation_policy_decision_get_navigation_action (
|
||||||
webkit_policy_decision_ignore (decision);
|
navigation_decision);
|
||||||
if (!zen_text_data->no_interaction &&
|
webkit_policy_decision_ignore (decision);
|
||||||
webkit_navigation_action_get_navigation_type (navigation_action) == WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) {
|
if (!zen_text_data->no_interaction &&
|
||||||
WebKitURIRequest *request = webkit_navigation_action_get_request(navigation_action);
|
webkit_navigation_action_get_navigation_type (navigation_action) ==
|
||||||
g_app_info_launch_default_for_uri (webkit_uri_request_get_uri(request), NULL, NULL);
|
WEBKIT_NAVIGATION_TYPE_LINK_CLICKED) {
|
||||||
}
|
WebKitURIRequest *request =
|
||||||
}
|
webkit_navigation_action_get_request (navigation_action);
|
||||||
return TRUE;
|
g_app_info_launch_default_for_uri (
|
||||||
|
webkit_uri_request_get_uri (request), NULL, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_webview_load_changed (WebKitWebView *webkitwebview,
|
zenity_text_webview_load_changed (
|
||||||
WebKitLoadEvent event,
|
WebKitWebView *webkitwebview, WebKitLoadEvent event, gpointer user_data) {
|
||||||
gpointer user_data)
|
if (event == WEBKIT_LOAD_FINISHED) {
|
||||||
{
|
g_signal_connect (G_OBJECT (webkitwebview),
|
||||||
if (event == WEBKIT_LOAD_FINISHED) {
|
"decide-policy",
|
||||||
g_signal_connect (G_OBJECT (webkitwebview), "decide-policy",
|
G_CALLBACK (zenity_text_webview_decision_request),
|
||||||
G_CALLBACK (zenity_text_webview_decision_request), NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_text_handle_stdin (GIOChannel *channel,
|
zenity_text_handle_stdin (
|
||||||
GIOCondition condition,
|
GIOChannel *channel, GIOCondition condition, gpointer data) {
|
||||||
gpointer data)
|
static GtkTextBuffer *buffer;
|
||||||
{
|
static GtkTextView *text_view;
|
||||||
static GtkTextBuffer *buffer;
|
gchar buf[1024];
|
||||||
static GtkTextView *text_view;
|
|
||||||
gchar buf[1024];
|
|
||||||
|
|
||||||
gsize len;
|
gsize len;
|
||||||
|
|
||||||
text_view = GTK_TEXT_VIEW (data);
|
text_view = GTK_TEXT_VIEW (data);
|
||||||
buffer = gtk_text_view_get_buffer (text_view);
|
buffer = gtk_text_view_get_buffer (text_view);
|
||||||
|
|
||||||
if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) {
|
if ((condition & G_IO_IN) || (condition & (G_IO_IN | G_IO_HUP))) {
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint status;
|
gint status;
|
||||||
|
|
||||||
while (channel->is_readable != TRUE)
|
while (channel->is_readable != TRUE)
|
||||||
;
|
;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
status = g_io_channel_read_chars (channel, buf, 1024, &len, &error);
|
status = g_io_channel_read_chars (channel, buf, 1024, &len, &error);
|
||||||
|
|
||||||
while (gtk_events_pending ())
|
while (gtk_events_pending ())
|
||||||
gtk_main_iteration ();
|
gtk_main_iteration ();
|
||||||
|
|
||||||
} while (status == G_IO_STATUS_AGAIN);
|
} while (status == G_IO_STATUS_AGAIN);
|
||||||
|
|
||||||
if (status != G_IO_STATUS_NORMAL) {
|
if (status != G_IO_STATUS_NORMAL) {
|
||||||
if (error) {
|
if (error) {
|
||||||
g_warning ("zenity_text_handle_stdin () : %s", error->message);
|
g_warning ("zenity_text_handle_stdin () : %s", error->message);
|
||||||
g_error_free (error);
|
g_error_free (error);
|
||||||
error = NULL;
|
error = NULL;
|
||||||
}
|
}
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
GtkTextIter end;
|
GtkTextIter end;
|
||||||
gchar *utftext;
|
gchar *utftext;
|
||||||
gsize localelen;
|
gsize localelen;
|
||||||
gsize utflen;
|
gsize utflen;
|
||||||
|
|
||||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||||
|
|
||||||
if (!g_utf8_validate (buf, len, NULL)) {
|
if (!g_utf8_validate (buf, len, NULL)) {
|
||||||
utftext = g_convert_with_fallback (buf, len, "UTF-8", "ISO-8859-1", NULL, &localelen, &utflen, NULL);
|
utftext = g_convert_with_fallback (buf,
|
||||||
gtk_text_buffer_insert (buffer, &end, utftext, utflen);
|
len,
|
||||||
g_free (utftext);
|
"UTF-8",
|
||||||
} else {
|
"ISO-8859-1",
|
||||||
gtk_text_buffer_insert (buffer, &end, buf, len);
|
NULL,
|
||||||
}
|
&localelen,
|
||||||
if (zen_text_data->auto_scroll) {
|
&utflen,
|
||||||
GtkTextMark *mark = NULL;
|
NULL);
|
||||||
mark = gtk_text_buffer_get_insert (buffer);
|
gtk_text_buffer_insert (buffer, &end, utftext, utflen);
|
||||||
if (mark != NULL)
|
g_free (utftext);
|
||||||
gtk_text_view_scroll_to_mark (text_view, mark, 0.0, FALSE, 0, 0);
|
} else {
|
||||||
}
|
gtk_text_buffer_insert (buffer, &end, buf, len);
|
||||||
}
|
}
|
||||||
}
|
if (zen_text_data->auto_scroll) {
|
||||||
|
GtkTextMark *mark = NULL;
|
||||||
|
mark = gtk_text_buffer_get_insert (buffer);
|
||||||
|
if (mark != NULL)
|
||||||
|
gtk_text_view_scroll_to_mark (
|
||||||
|
text_view, mark, 0.0, FALSE, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_fill_entries_from_stdin (GtkTextView *text_view)
|
zenity_text_fill_entries_from_stdin (GtkTextView *text_view) {
|
||||||
{
|
GIOChannel *channel;
|
||||||
GIOChannel *channel;
|
|
||||||
|
|
||||||
channel = g_io_channel_unix_new (0);
|
channel = g_io_channel_unix_new (0);
|
||||||
g_io_channel_set_encoding (channel, "UTF-8", NULL);
|
g_io_channel_set_encoding (channel, "UTF-8", NULL);
|
||||||
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
g_io_channel_set_flags (channel, G_IO_FLAG_NONBLOCK, NULL);
|
||||||
g_io_add_watch (channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view);
|
g_io_add_watch (
|
||||||
|
channel, G_IO_IN | G_IO_HUP, zenity_text_handle_stdin, text_view);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_text (ZenityData *data, ZenityTextData *text_data)
|
zenity_text (ZenityData *data, ZenityTextData *text_data) {
|
||||||
{
|
GtkBuilder *builder;
|
||||||
GtkBuilder *builder;
|
GtkWidget *dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *ok_button;
|
||||||
GtkWidget *ok_button;
|
GtkWidget *checkbox;
|
||||||
GtkWidget *checkbox;
|
GtkWidget *cancel_button;
|
||||||
GtkWidget *cancel_button;
|
|
||||||
|
|
||||||
GObject *text_view;
|
GObject *text_view;
|
||||||
GtkTextBuffer *text_buffer;
|
GtkTextBuffer *text_buffer;
|
||||||
|
|
||||||
#ifdef HAVE_WEBKITGTK
|
#ifdef HAVE_WEBKITGTK
|
||||||
GtkWidget *web_kit;
|
GtkWidget *web_kit;
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkTextIter start_iter, end_iter;
|
GtkTextIter start_iter, end_iter;
|
||||||
gchar *content;
|
gchar *content;
|
||||||
#endif
|
#endif
|
||||||
zen_text_data = text_data;
|
zen_text_data = text_data;
|
||||||
builder = zenity_util_load_ui_file ("zenity_text_dialog",
|
builder =
|
||||||
"textbuffer1", NULL);
|
zenity_util_load_ui_file ("zenity_text_dialog", "textbuffer1", NULL);
|
||||||
|
|
||||||
if (builder == NULL) {
|
|
||||||
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_builder_connect_signals (builder, NULL);
|
|
||||||
|
|
||||||
dialog = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog"));
|
|
||||||
|
|
||||||
ok_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_close_button"));
|
if (builder == NULL) {
|
||||||
cancel_button = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_cancel_button"));
|
data->exit_code = zenity_util_return_exit_code (ZENITY_ERROR);
|
||||||
checkbox = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_checkbox"));
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
gtk_builder_connect_signals (builder, NULL);
|
||||||
G_CALLBACK (zenity_text_dialog_response), data);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
dialog =
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_dialog"));
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
ok_button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_text_close_button"));
|
||||||
|
cancel_button = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_text_cancel_button"));
|
||||||
|
checkbox =
|
||||||
|
GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_checkbox"));
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
g_signal_connect (G_OBJECT (dialog),
|
||||||
|
"response",
|
||||||
|
G_CALLBACK (zenity_text_dialog_response),
|
||||||
|
data);
|
||||||
|
|
||||||
text_buffer = gtk_text_buffer_new (NULL);
|
if (data->dialog_title)
|
||||||
text_view = gtk_builder_get_object (builder, "zenity_text_view");
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
|
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
|
|
||||||
|
|
||||||
if (text_data->no_wrap)
|
zenity_util_set_window_icon (
|
||||||
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW(text_view), GTK_WRAP_NONE);
|
dialog, data->window_icon, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
||||||
|
|
||||||
if (text_data->font) {
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||||
PangoFontDescription *fontDesc = pango_font_description_from_string (text_data->font);
|
|
||||||
gtk_widget_override_font (GTK_WIDGET(text_view), fontDesc);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text_data->uri)
|
text_buffer = gtk_text_buffer_new (NULL);
|
||||||
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
|
text_view = gtk_builder_get_object (builder, "zenity_text_view");
|
||||||
else
|
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
|
||||||
zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW(text_view));
|
gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), text_data->editable);
|
||||||
|
|
||||||
if (text_data->editable)
|
if (text_data->no_wrap)
|
||||||
zen_text_data->buffer = text_buffer;
|
gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_NONE);
|
||||||
|
|
||||||
if (data->extra_label) {
|
if (text_data->font) {
|
||||||
gint i=0;
|
PangoFontDescription *fontDesc =
|
||||||
while(data->extra_label[i]!=NULL){
|
pango_font_description_from_string (text_data->font);
|
||||||
gtk_dialog_add_button (GTK_DIALOG (dialog), data->extra_label[i], i);
|
gtk_widget_override_font (GTK_WIDGET (text_view), fontDesc);
|
||||||
i++;
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (data->ok_label) {
|
if (text_data->uri)
|
||||||
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
|
||||||
}
|
else
|
||||||
|
zenity_text_fill_entries_from_stdin (GTK_TEXT_VIEW (text_view));
|
||||||
|
|
||||||
if (data->cancel_label) {
|
if (text_data->editable)
|
||||||
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
|
zen_text_data->buffer = text_buffer;
|
||||||
}
|
|
||||||
|
|
||||||
if (text_data->checkbox) {
|
if (data->extra_label) {
|
||||||
gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE);
|
gint i = 0;
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
|
while (data->extra_label[i] != NULL) {
|
||||||
gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox);
|
gtk_dialog_add_button (
|
||||||
|
GTK_DIALOG (dialog), data->extra_label[i], i);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (checkbox), "toggled",
|
if (data->ok_label) {
|
||||||
G_CALLBACK (zenity_text_toggle_button), ok_button);
|
gtk_button_set_label (GTK_BUTTON (ok_button), data->ok_label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->width > -1 || data->height > -1)
|
if (data->cancel_label) {
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), data->width, data->height);
|
gtk_button_set_label (GTK_BUTTON (cancel_button), data->cancel_label);
|
||||||
else
|
}
|
||||||
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
|
|
||||||
|
|
||||||
if (data->modal)
|
if (text_data->checkbox) {
|
||||||
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
gtk_widget_set_visible (GTK_WIDGET (checkbox), TRUE);
|
||||||
|
gtk_widget_set_sensitive (GTK_WIDGET (ok_button), FALSE);
|
||||||
|
gtk_button_set_label (GTK_BUTTON (checkbox), text_data->checkbox);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (checkbox),
|
||||||
|
"toggled",
|
||||||
|
G_CALLBACK (zenity_text_toggle_button),
|
||||||
|
ok_button);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data->width > -1 || data->height > -1)
|
||||||
|
gtk_window_set_default_size (
|
||||||
|
GTK_WINDOW (dialog), data->width, data->height);
|
||||||
|
else
|
||||||
|
gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 400);
|
||||||
|
|
||||||
|
if (data->modal)
|
||||||
|
gtk_window_set_modal (GTK_WINDOW (dialog), TRUE);
|
||||||
|
|
||||||
#ifdef HAVE_WEBKITGTK
|
#ifdef HAVE_WEBKITGTK
|
||||||
if(text_data->html) {
|
if (text_data->html) {
|
||||||
web_kit = webkit_web_view_new();
|
web_kit = webkit_web_view_new ();
|
||||||
scrolled_window = GTK_WIDGET (gtk_builder_get_object (builder, "zenity_text_scrolled_window"));
|
scrolled_window = GTK_WIDGET (
|
||||||
|
gtk_builder_get_object (builder, "zenity_text_scrolled_window"));
|
||||||
|
|
||||||
zenity_configure_webkit (WEBKIT_WEB_VIEW (web_kit));
|
zenity_configure_webkit (WEBKIT_WEB_VIEW (web_kit));
|
||||||
|
|
||||||
if (text_data->url)
|
if (text_data->url) {
|
||||||
{
|
if (!(g_str_has_prefix (text_data->url, "http://") ||
|
||||||
if (!(g_str_has_prefix (text_data->url, "http://") || g_str_has_prefix (text_data->url, "https://")))
|
g_str_has_prefix (text_data->url, "https://")))
|
||||||
text_data->url = g_strdup_printf ("http://%s", text_data->url);
|
text_data->url = g_strdup_printf ("http://%s", text_data->url);
|
||||||
|
|
||||||
|
|
||||||
webkit_web_view_load_uri (WEBKIT_WEB_VIEW (web_kit), text_data->url);
|
webkit_web_view_load_uri (
|
||||||
}
|
WEBKIT_WEB_VIEW (web_kit), text_data->url);
|
||||||
else
|
} else {
|
||||||
{
|
gchar *cwd;
|
||||||
gchar *cwd;
|
gchar *dirname;
|
||||||
gchar *dirname;
|
gchar *dirname_uri;
|
||||||
gchar *dirname_uri;
|
dirname = text_data->uri ? g_path_get_dirname (text_data->uri)
|
||||||
dirname = text_data->uri ? g_path_get_dirname (text_data->uri) : g_strdup ("/");
|
: g_strdup ("/");
|
||||||
cwd = g_get_current_dir ();
|
cwd = g_get_current_dir ();
|
||||||
dirname_uri = g_strconcat ("file://", cwd, "/", dirname, "/", NULL);
|
dirname_uri = g_strconcat ("file://", cwd, "/", dirname, "/", NULL);
|
||||||
g_free (cwd);
|
g_free (cwd);
|
||||||
g_free (dirname);
|
g_free (dirname);
|
||||||
gtk_text_buffer_get_start_iter (text_buffer, &start_iter);
|
gtk_text_buffer_get_start_iter (text_buffer, &start_iter);
|
||||||
gtk_text_buffer_get_end_iter (text_buffer, &end_iter);
|
gtk_text_buffer_get_end_iter (text_buffer, &end_iter);
|
||||||
content = gtk_text_buffer_get_text (text_buffer, &start_iter, &end_iter, TRUE);
|
content = gtk_text_buffer_get_text (
|
||||||
webkit_web_view_load_html (WEBKIT_WEB_VIEW(web_kit), content, dirname_uri);
|
text_buffer, &start_iter, &end_iter, TRUE);
|
||||||
g_free (dirname_uri);
|
webkit_web_view_load_html (
|
||||||
g_free (content);
|
WEBKIT_WEB_VIEW (web_kit), content, dirname_uri);
|
||||||
}
|
g_free (dirname_uri);
|
||||||
|
g_free (content);
|
||||||
|
}
|
||||||
|
|
||||||
// We don't want user to click on links and navigate to another page.
|
// We don't want user to click on links and navigate to another page.
|
||||||
// So, when the page finishes loading, we take handle of the requests.
|
// So, when the page finishes loading, we take handle of the requests.
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (web_kit), "load-changed",
|
g_signal_connect (G_OBJECT (web_kit),
|
||||||
G_CALLBACK (zenity_text_webview_load_changed), NULL);
|
"load-changed",
|
||||||
|
G_CALLBACK (zenity_text_webview_load_changed),
|
||||||
|
NULL);
|
||||||
|
|
||||||
gtk_widget_destroy (GTK_WIDGET (text_view));
|
gtk_widget_destroy (GTK_WIDGET (text_view));
|
||||||
gtk_container_add (GTK_CONTAINER(scrolled_window), web_kit);
|
gtk_container_add (GTK_CONTAINER (scrolled_window), web_kit);
|
||||||
gtk_widget_show (GTK_WIDGET (web_kit));
|
gtk_widget_show (GTK_WIDGET (web_kit));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
zenity_util_show_dialog (dialog, data->attach);
|
zenity_util_show_dialog (dialog, data->attach);
|
||||||
|
|
||||||
g_object_unref (builder);
|
g_object_unref (builder);
|
||||||
|
|
||||||
if(data->timeout_delay > 0) {
|
if (data->timeout_delay > 0) {
|
||||||
g_timeout_add_seconds (data->timeout_delay, (GSourceFunc) zenity_util_timeout_handle, dialog);
|
g_timeout_add_seconds (data->timeout_delay,
|
||||||
}
|
(GSourceFunc) zenity_util_timeout_handle,
|
||||||
|
dialog);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_toggle_button (GtkToggleButton *button, gpointer data)
|
zenity_text_toggle_button (GtkToggleButton *button, gpointer data) {
|
||||||
{
|
GtkWidget *ok_button = (GtkWidget *) data;
|
||||||
GtkWidget *ok_button = (GtkWidget *)data;
|
gtk_widget_set_sensitive (
|
||||||
gtk_widget_set_sensitive (GTK_WIDGET(ok_button), gtk_toggle_button_get_active(button));
|
GTK_WIDGET (ok_button), gtk_toggle_button_get_active (button));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_dialog_output (ZenityData *zen_data)
|
zenity_text_dialog_output (ZenityData *zen_data) {
|
||||||
{
|
if (zen_text_data->editable) {
|
||||||
if (zen_text_data->editable) {
|
GtkTextIter start, end;
|
||||||
GtkTextIter start, end;
|
gchar *text;
|
||||||
gchar *text;
|
gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end);
|
||||||
gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end);
|
text =
|
||||||
text = gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0);
|
gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0);
|
||||||
g_print ("%s", text);
|
g_print ("%s", text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_text_dialog_response (GtkWidget *widget, int response, gpointer data) {
|
||||||
{
|
ZenityData *zen_data = data;
|
||||||
ZenityData *zen_data = data;
|
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_CLOSE:
|
case GTK_RESPONSE_CLOSE:
|
||||||
zenity_text_dialog_output (zen_data);
|
zenity_text_dialog_output (zen_data);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_OK);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
zenity_text_dialog_output (zen_data);
|
zenity_text_dialog_output (zen_data);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
zen_data->exit_code = zenity_util_return_exit_code (ZENITY_TIMEOUT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (zen_data->extra_label && response < g_strv_length(zen_data->extra_label))
|
if (zen_data->extra_label &&
|
||||||
printf("%s\n",zen_data->extra_label[response]);
|
response < g_strv_length (zen_data->extra_label))
|
||||||
zenity_util_exit_code_with_data(ZENITY_ESC, zen_data);
|
printf ("%s\n", zen_data->extra_label[response]);
|
||||||
break;
|
zenity_util_exit_code_with_data (ZENITY_ESC, zen_data);
|
||||||
}
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
|
gtk_main_quit ();
|
||||||
}
|
}
|
||||||
|
1202
src/tree.c
1202
src/tree.c
File diff suppressed because it is too large
Load Diff
594
src/util.c
594
src/util.c
@ -29,340 +29,330 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <locale.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
#include "zenity.h"
|
#include "zenity.h"
|
||||||
|
#include <errno.h>
|
||||||
|
#include <locale.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
#include <gdk/gdkx.h>
|
#include <gdk/gdkx.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define ZENITY_OK_DEFAULT 0
|
#define ZENITY_OK_DEFAULT 0
|
||||||
#define ZENITY_CANCEL_DEFAULT 1
|
#define ZENITY_CANCEL_DEFAULT 1
|
||||||
#define ZENITY_ESC_DEFAULT 1
|
#define ZENITY_ESC_DEFAULT 1
|
||||||
#define ZENITY_ERROR_DEFAULT -1
|
#define ZENITY_ERROR_DEFAULT -1
|
||||||
#define ZENITY_EXTRA_DEFAULT 127
|
#define ZENITY_EXTRA_DEFAULT 127
|
||||||
|
|
||||||
GtkBuilder*
|
GtkBuilder *
|
||||||
zenity_util_load_ui_file (const gchar *root_widget, ...)
|
zenity_util_load_ui_file (const gchar *root_widget, ...) {
|
||||||
{
|
va_list args;
|
||||||
va_list args;
|
gchar *arg = NULL;
|
||||||
gchar *arg = NULL;
|
GPtrArray *ptrarray;
|
||||||
GPtrArray *ptrarray;
|
GtkBuilder *builder = gtk_builder_new ();
|
||||||
GtkBuilder *builder = gtk_builder_new ();
|
GError *error = NULL;
|
||||||
GError *error = NULL;
|
gchar **objects;
|
||||||
gchar **objects;
|
guint result = 0;
|
||||||
guint result = 0;
|
|
||||||
|
|
||||||
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
|
gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);
|
||||||
|
|
||||||
/* We have at least the root_widget and a NULL */
|
/* We have at least the root_widget and a NULL */
|
||||||
ptrarray = g_ptr_array_sized_new (2);
|
ptrarray = g_ptr_array_sized_new (2);
|
||||||
|
|
||||||
g_ptr_array_add (ptrarray, g_strdup (root_widget));
|
g_ptr_array_add (ptrarray, g_strdup (root_widget));
|
||||||
|
|
||||||
va_start (args, root_widget);
|
va_start (args, root_widget);
|
||||||
|
|
||||||
arg = va_arg (args, gchar*);
|
arg = va_arg (args, gchar *);
|
||||||
|
|
||||||
while (arg) {
|
while (arg) {
|
||||||
g_ptr_array_add (ptrarray, g_strdup (arg));
|
g_ptr_array_add (ptrarray, g_strdup (arg));
|
||||||
arg = va_arg (args, gchar*);
|
arg = va_arg (args, gchar *);
|
||||||
}
|
}
|
||||||
va_end (args);
|
va_end (args);
|
||||||
|
|
||||||
/* Enforce terminating NULL */
|
/* Enforce terminating NULL */
|
||||||
g_ptr_array_add (ptrarray, NULL);
|
g_ptr_array_add (ptrarray, NULL);
|
||||||
objects = (gchar**) g_ptr_array_free (ptrarray, FALSE);
|
objects = (gchar **) g_ptr_array_free (ptrarray, FALSE);
|
||||||
|
|
||||||
if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
|
|
||||||
/* Try current dir, for debugging */
|
|
||||||
result = gtk_builder_add_objects_from_file (builder,
|
|
||||||
ZENITY_UI_FILE_RELATIVEPATH,
|
|
||||||
objects, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == 0)
|
if (g_file_test (ZENITY_UI_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
|
||||||
result = gtk_builder_add_objects_from_file (builder,
|
/* Try current dir, for debugging */
|
||||||
ZENITY_UI_FILE_FULLPATH,
|
result = gtk_builder_add_objects_from_file (
|
||||||
objects, &error);
|
builder, ZENITY_UI_FILE_RELATIVEPATH, objects, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
g_strfreev (objects);
|
if (result == 0)
|
||||||
|
result = gtk_builder_add_objects_from_file (
|
||||||
|
builder, ZENITY_UI_FILE_FULLPATH, objects, &error);
|
||||||
|
|
||||||
if (result == 0) {
|
g_strfreev (objects);
|
||||||
g_warning ("Could not load ui file %s: %s", ZENITY_UI_FILE_FULLPATH,
|
|
||||||
error->message);
|
|
||||||
g_error_free (error);
|
|
||||||
g_object_unref (builder);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return builder;
|
if (result == 0) {
|
||||||
|
g_warning ("Could not load ui file %s: %s",
|
||||||
|
ZENITY_UI_FILE_FULLPATH,
|
||||||
|
error->message);
|
||||||
|
g_error_free (error);
|
||||||
|
g_object_unref (builder);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
gchar*
|
gchar *
|
||||||
zenity_util_strip_newline (gchar *string)
|
zenity_util_strip_newline (gchar *string) {
|
||||||
{
|
gsize len;
|
||||||
gsize len;
|
|
||||||
|
g_return_val_if_fail (string != NULL, NULL);
|
||||||
g_return_val_if_fail (string != NULL, NULL);
|
|
||||||
|
len = strlen (string);
|
||||||
len = strlen (string);
|
while (len--) {
|
||||||
while (len--)
|
if (string[len] == '\n')
|
||||||
{
|
string[len] = '\0';
|
||||||
if (string[len] == '\n')
|
else
|
||||||
string[len] = '\0';
|
break;
|
||||||
else
|
}
|
||||||
break;
|
|
||||||
}
|
return string;
|
||||||
|
|
||||||
return string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename)
|
zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename) {
|
||||||
{
|
GtkTextIter iter, end;
|
||||||
GtkTextIter iter, end;
|
FILE *f;
|
||||||
FILE *f;
|
gchar buf[2048];
|
||||||
gchar buf[2048];
|
gint remaining = 0;
|
||||||
gint remaining = 0;
|
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
f = fopen (filename, "r");
|
f = fopen (filename, "r");
|
||||||
|
|
||||||
if (f == NULL) {
|
if (f == NULL) {
|
||||||
g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno));
|
g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
|
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
|
||||||
|
|
||||||
while (!feof (f)) {
|
while (!feof (f)) {
|
||||||
gint count;
|
gint count;
|
||||||
const char *leftover;
|
const char *leftover;
|
||||||
int to_read = 2047 - remaining;
|
int to_read = 2047 - remaining;
|
||||||
|
|
||||||
count = fread (buf + remaining, 1, to_read, f);
|
count = fread (buf + remaining, 1, to_read, f);
|
||||||
buf[count + remaining] = '\0';
|
buf[count + remaining] = '\0';
|
||||||
|
|
||||||
g_utf8_validate (buf, count + remaining, &leftover);
|
g_utf8_validate (buf, count + remaining, &leftover);
|
||||||
|
|
||||||
g_assert (g_utf8_validate (buf, leftover - buf, NULL));
|
g_assert (g_utf8_validate (buf, leftover - buf, NULL));
|
||||||
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
|
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
|
||||||
|
|
||||||
remaining = (buf + remaining + count) - leftover;
|
remaining = (buf + remaining + count) - leftover;
|
||||||
g_memmove (buf, leftover, remaining);
|
g_memmove (buf, leftover, remaining);
|
||||||
|
|
||||||
if (remaining > 6 || count < to_read)
|
if (remaining > 6 || count < to_read)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (remaining) {
|
if (remaining) {
|
||||||
g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename);
|
g_warning (
|
||||||
return FALSE;
|
"Invalid UTF-8 data encountered reading file '%s'", filename);
|
||||||
}
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
/* We had a newline in the buffer to begin with. (The buffer always contains
|
/* We had a newline in the buffer to begin with. (The buffer always contains
|
||||||
* a newline, so we delete to the end of the buffer to clean up.
|
* a newline, so we delete to the end of the buffer to clean up.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gtk_text_buffer_get_end_iter (buffer, &end);
|
|
||||||
gtk_text_buffer_delete (buffer, &iter, &end);
|
|
||||||
|
|
||||||
gtk_text_buffer_set_modified (buffer, FALSE);
|
gtk_text_buffer_get_end_iter (buffer, &end);
|
||||||
|
gtk_text_buffer_delete (buffer, &iter, &end);
|
||||||
|
|
||||||
return TRUE;
|
gtk_text_buffer_set_modified (buffer, FALSE);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
const gchar *
|
const gchar *
|
||||||
zenity_util_icon_name_from_filename (const gchar *filename)
|
zenity_util_icon_name_from_filename (const gchar *filename) {
|
||||||
{
|
if (!filename || !filename[0])
|
||||||
if (!filename || !filename[0])
|
return "dialog-warning"; /* default */
|
||||||
return "dialog-warning"; /* default */
|
|
||||||
|
|
||||||
if (!g_ascii_strcasecmp (filename, "warning"))
|
if (!g_ascii_strcasecmp (filename, "warning"))
|
||||||
return "dialog-warning";
|
return "dialog-warning";
|
||||||
if (!g_ascii_strcasecmp (filename, "info"))
|
if (!g_ascii_strcasecmp (filename, "info"))
|
||||||
return "dialog-information";
|
return "dialog-information";
|
||||||
if (!g_ascii_strcasecmp (filename, "question"))
|
if (!g_ascii_strcasecmp (filename, "question"))
|
||||||
return "dialog-question";
|
return "dialog-question";
|
||||||
if (!g_ascii_strcasecmp (filename, "error"))
|
if (!g_ascii_strcasecmp (filename, "error"))
|
||||||
return "dialog-error";
|
return "dialog-error";
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_set_window_icon_from_file (GtkWidget *widget, const gchar *filename)
|
zenity_util_set_window_icon_from_file (
|
||||||
{
|
GtkWidget *widget, const gchar *filename) {
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
const gchar *icon_name;
|
const gchar *icon_name;
|
||||||
|
|
||||||
icon_name = zenity_util_icon_name_from_filename (filename);
|
icon_name = zenity_util_icon_name_from_filename (filename);
|
||||||
if (icon_name) {
|
if (icon_name) {
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name);
|
gtk_window_set_icon_name (GTK_WINDOW (widget), icon_name);
|
||||||
} else {
|
} else {
|
||||||
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
pixbuf = gdk_pixbuf_new_from_file (filename, NULL);
|
||||||
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file)
|
zenity_util_set_window_icon (
|
||||||
{
|
GtkWidget *widget, const gchar *filename, const gchar *default_file) {
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
if (filename != NULL) {
|
if (filename != NULL) {
|
||||||
zenity_util_set_window_icon_from_file (widget, filename);
|
zenity_util_set_window_icon_from_file (widget, filename);
|
||||||
} else {
|
} else {
|
||||||
pixbuf = gdk_pixbuf_new_from_file (default_file, NULL);
|
pixbuf = gdk_pixbuf_new_from_file (default_file, NULL);
|
||||||
if (pixbuf != NULL) {
|
if (pixbuf != NULL) {
|
||||||
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_set_window_icon_from_icon_name (GtkWidget *widget, const gchar *filename, const gchar *default_icon_name)
|
zenity_util_set_window_icon_from_icon_name (
|
||||||
{
|
GtkWidget *widget, const gchar *filename, const gchar *default_icon_name) {
|
||||||
if (filename != NULL)
|
if (filename != NULL)
|
||||||
zenity_util_set_window_icon_from_file (widget, filename);
|
zenity_util_set_window_icon_from_file (widget, filename);
|
||||||
else
|
else
|
||||||
gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name);
|
gtk_window_set_icon_name (GTK_WINDOW (widget), default_icon_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_show_help (GError **error)
|
zenity_util_show_help (GError **error) {
|
||||||
{
|
gchar *tmp;
|
||||||
gchar *tmp;
|
tmp = g_find_program_in_path ("yelp");
|
||||||
tmp = g_find_program_in_path ("yelp");
|
|
||||||
|
|
||||||
if (tmp) {
|
if (tmp) {
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
g_spawn_command_line_async ("yelp help:zenity", error);
|
g_spawn_command_line_async ("yelp help:zenity", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
zenity_util_return_exit_code ( ZenityExitCode value )
|
zenity_util_return_exit_code (ZenityExitCode value) {
|
||||||
{
|
|
||||||
|
|
||||||
const gchar *env_var = NULL;
|
const gchar *env_var = NULL;
|
||||||
gint retval;
|
gint retval;
|
||||||
|
|
||||||
switch (value) {
|
switch (value) {
|
||||||
|
|
||||||
case ZENITY_OK:
|
case ZENITY_OK:
|
||||||
env_var = g_getenv("ZENITY_OK");
|
env_var = g_getenv ("ZENITY_OK");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_OK");
|
env_var = g_getenv ("DIALOG_OK");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_OK_DEFAULT;
|
retval = ZENITY_OK_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_CANCEL:
|
case ZENITY_CANCEL:
|
||||||
env_var = g_getenv("ZENITY_CANCEL");
|
env_var = g_getenv ("ZENITY_CANCEL");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_CANCEL");
|
env_var = g_getenv ("DIALOG_CANCEL");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_CANCEL_DEFAULT;
|
retval = ZENITY_CANCEL_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_ESC:
|
case ZENITY_ESC:
|
||||||
env_var = g_getenv("ZENITY_ESC");
|
env_var = g_getenv ("ZENITY_ESC");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_ESC");
|
env_var = g_getenv ("DIALOG_ESC");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_ESC_DEFAULT;
|
retval = ZENITY_ESC_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_EXTRA:
|
case ZENITY_EXTRA:
|
||||||
env_var = g_getenv("ZENITY_EXTRA");
|
env_var = g_getenv ("ZENITY_EXTRA");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_EXTRA");
|
env_var = g_getenv ("DIALOG_EXTRA");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_EXTRA_DEFAULT;
|
retval = ZENITY_EXTRA_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_ERROR:
|
case ZENITY_ERROR:
|
||||||
env_var = g_getenv("ZENITY_ERROR");
|
env_var = g_getenv ("ZENITY_ERROR");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_ERROR");
|
env_var = g_getenv ("DIALOG_ERROR");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_ERROR_DEFAULT;
|
retval = ZENITY_ERROR_DEFAULT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_TIMEOUT:
|
case ZENITY_TIMEOUT:
|
||||||
env_var = g_getenv("ZENITY_TIMEOUT");
|
env_var = g_getenv ("ZENITY_TIMEOUT");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
env_var = g_getenv("DIALOG_TIMEOUT");
|
env_var = g_getenv ("DIALOG_TIMEOUT");
|
||||||
if (! env_var)
|
if (!env_var)
|
||||||
retval = ZENITY_TIMEOUT;
|
retval = ZENITY_TIMEOUT;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
retval = 1;
|
retval = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (env_var)
|
if (env_var)
|
||||||
retval = atoi (env_var);
|
retval = atoi (env_var);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_exit_code_with_data(ZenityExitCode value, ZenityData *zen_data)
|
zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *zen_data) {
|
||||||
{
|
zen_data->exit_code = zenity_util_return_exit_code (value);
|
||||||
zen_data->exit_code = zenity_util_return_exit_code (value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
|
|
||||||
static Window
|
static Window
|
||||||
transient_get_xterm (void)
|
transient_get_xterm (void) {
|
||||||
{
|
const char *wid_str = g_getenv ("WINDOWID");
|
||||||
const char *wid_str = g_getenv ("WINDOWID");
|
if (wid_str) {
|
||||||
if (wid_str) {
|
char *wid_str_end;
|
||||||
char *wid_str_end;
|
int ret;
|
||||||
int ret;
|
Window wid = strtoul (wid_str, &wid_str_end, 10);
|
||||||
Window wid = strtoul (wid_str, &wid_str_end, 10);
|
if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) {
|
||||||
if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) {
|
XWindowAttributes attrs;
|
||||||
XWindowAttributes attrs;
|
gdk_error_trap_push ();
|
||||||
gdk_error_trap_push ();
|
ret = XGetWindowAttributes (
|
||||||
ret = XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wid, &attrs);
|
GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), wid, &attrs);
|
||||||
gdk_flush();
|
gdk_flush ();
|
||||||
if (gdk_error_trap_pop () != 0 || ret == 0) {
|
if (gdk_error_trap_pop () != 0 || ret == 0) {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
return wid;
|
return wid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
transient_x_free (void *ptr)
|
transient_x_free (void *ptr) {
|
||||||
{
|
if (ptr)
|
||||||
if (ptr)
|
XFree (ptr);
|
||||||
XFree (ptr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
transient_is_toplevel (Window wid)
|
transient_is_toplevel (Window wid) {
|
||||||
{
|
XTextProperty prop;
|
||||||
XTextProperty prop;
|
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||||
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
if (!XGetWMName (dpy, wid, &prop))
|
||||||
if (!XGetWMName (dpy, wid, &prop))
|
return FALSE;
|
||||||
return FALSE;
|
transient_x_free (prop.value);
|
||||||
transient_x_free (prop.value);
|
return !!prop.value;
|
||||||
return !!prop.value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -372,62 +362,56 @@ transient_is_toplevel (Window wid)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static Window
|
static Window
|
||||||
transient_get_xterm_toplevel (void)
|
transient_get_xterm_toplevel (void) {
|
||||||
{
|
Window xterm = transient_get_xterm ();
|
||||||
Window xterm = transient_get_xterm ();
|
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
||||||
Display *dpy = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ());
|
while (xterm != None && !transient_is_toplevel (xterm)) {
|
||||||
while (xterm != None && !transient_is_toplevel (xterm))
|
Window root, parent, *children;
|
||||||
{
|
unsigned nchildren;
|
||||||
Window root, parent, *children;
|
XQueryTree (dpy, xterm, &root, &parent, &children, &nchildren);
|
||||||
unsigned nchildren;
|
transient_x_free (children);
|
||||||
XQueryTree (dpy, xterm,
|
if (parent == root)
|
||||||
&root, &parent,
|
xterm = None;
|
||||||
&children, &nchildren);
|
else
|
||||||
transient_x_free (children);
|
xterm = parent;
|
||||||
if (parent == root)
|
}
|
||||||
xterm = None;
|
return xterm;
|
||||||
else
|
|
||||||
xterm = parent;
|
|
||||||
}
|
|
||||||
return xterm;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_util_make_transient (GdkWindow *window, Window parent)
|
zenity_util_make_transient (GdkWindow *window, Window parent) {
|
||||||
{
|
Window parent_window = parent;
|
||||||
Window parent_window = parent;
|
if (parent_window == 0)
|
||||||
if (parent_window == 0)
|
parent_window = transient_get_xterm_toplevel ();
|
||||||
parent_window = transient_get_xterm_toplevel ();
|
if (parent_window != None) {
|
||||||
if (parent_window != None) {
|
XSetTransientForHint (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()),
|
||||||
XSetTransientForHint (GDK_DISPLAY_XDISPLAY(gdk_display_get_default()), GDK_WINDOW_XID(window), parent_window);
|
GDK_WINDOW_XID (window),
|
||||||
}
|
parent_window);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* GDK_WINDOWING_X11 */
|
#endif /* GDK_WINDOWING_X11 */
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_show_dialog (GtkWidget *dialog, guintptr parent)
|
zenity_util_show_dialog (GtkWidget *dialog, guintptr parent) {
|
||||||
{
|
gtk_widget_realize (dialog);
|
||||||
gtk_widget_realize (dialog);
|
|
||||||
#ifdef GDK_WINDOWING_X11
|
#ifdef GDK_WINDOWING_X11
|
||||||
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
|
if (GDK_IS_X11_DISPLAY (gdk_display_get_default ())) {
|
||||||
{
|
g_assert (gtk_widget_get_window (dialog));
|
||||||
g_assert (gtk_widget_get_window(dialog));
|
zenity_util_make_transient (gtk_widget_get_window (dialog), parent);
|
||||||
zenity_util_make_transient (gtk_widget_get_window(dialog), parent);
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
zenity_util_timeout_handle (gpointer data)
|
zenity_util_timeout_handle (gpointer data) {
|
||||||
{
|
GtkDialog *dialog = GTK_DIALOG (data);
|
||||||
GtkDialog *dialog = GTK_DIALOG(data);
|
if (dialog != NULL)
|
||||||
if(dialog != NULL)
|
gtk_dialog_response (dialog, ZENITY_TIMEOUT);
|
||||||
gtk_dialog_response(dialog, ZENITY_TIMEOUT);
|
else {
|
||||||
else {
|
gtk_main_quit ();
|
||||||
gtk_main_quit();
|
exit (ZENITY_TIMEOUT);
|
||||||
exit(ZENITY_TIMEOUT);
|
}
|
||||||
}
|
return FALSE;
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
47
src/util.h
47
src/util.h
@ -1,37 +1,34 @@
|
|||||||
#ifndef UTIL_H
|
#ifndef UTIL_H
|
||||||
#define UTIL_H
|
#define UTIL_H
|
||||||
|
|
||||||
#include <gtk/gtk.h>
|
|
||||||
#include "zenity.h"
|
#include "zenity.h"
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui"
|
#define ZENITY_UI_FILE_FULLPATH ZENITY_DATADIR "/zenity.ui"
|
||||||
#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui"
|
#define ZENITY_UI_FILE_RELATIVEPATH "./zenity.ui"
|
||||||
|
|
||||||
#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename)
|
#define ZENITY_IMAGE_FULLPATH(filename) (ZENITY_DATADIR "/" filename)
|
||||||
|
|
||||||
GtkBuilder* zenity_util_load_ui_file (const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED;
|
GtkBuilder *zenity_util_load_ui_file (
|
||||||
gchar * zenity_util_strip_newline (gchar *string);
|
const gchar *widget_root, ...) G_GNUC_NULL_TERMINATED;
|
||||||
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
|
gchar *zenity_util_strip_newline (gchar *string);
|
||||||
const gchar *filename);
|
gboolean zenity_util_fill_file_buffer (
|
||||||
const gchar * zenity_util_icon_name_from_filename (const gchar *filename);
|
GtkTextBuffer *buffer, const gchar *filename);
|
||||||
void zenity_util_set_window_icon (GtkWidget *widget,
|
const gchar *zenity_util_icon_name_from_filename (const gchar *filename);
|
||||||
const gchar *filename,
|
void zenity_util_set_window_icon (
|
||||||
const gchar *default_file);
|
GtkWidget *widget, const gchar *filename, const gchar *default_file);
|
||||||
void zenity_util_set_window_icon_from_icon_name(GtkWidget *widget,
|
void zenity_util_set_window_icon_from_icon_name (
|
||||||
const gchar *filename,
|
GtkWidget *widget, const gchar *filename, const gchar *default_icon_name);
|
||||||
const gchar *default_icon_name);
|
void zenity_util_set_window_icon_from_file (
|
||||||
void zenity_util_set_window_icon_from_file (GtkWidget *widget,
|
GtkWidget *widget, const gchar *filename);
|
||||||
const gchar *filename);
|
void zenity_util_show_help (GError **error);
|
||||||
void zenity_util_show_help (GError **error);
|
gint zenity_util_return_exit_code (ZenityExitCode value);
|
||||||
gint zenity_util_return_exit_code (ZenityExitCode value);
|
void zenity_util_exit_code_with_data (ZenityExitCode value, ZenityData *data);
|
||||||
void zenity_util_exit_code_with_data (ZenityExitCode value,
|
void zenity_util_show_dialog (GtkWidget *widget, guintptr parent);
|
||||||
ZenityData *data);
|
|
||||||
void zenity_util_show_dialog (GtkWidget *widget, guintptr parent);
|
|
||||||
|
|
||||||
gboolean zenity_util_timeout_handle (gpointer data);
|
gboolean zenity_util_timeout_handle (gpointer data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
271
src/zenity.h
271
src/zenity.h
@ -7,9 +7,9 @@ G_BEGIN_DECLS
|
|||||||
|
|
||||||
#ifdef ENABLE_NLS
|
#ifdef ENABLE_NLS
|
||||||
#include <libintl.h>
|
#include <libintl.h>
|
||||||
#define _(String) dgettext(GETTEXT_PACKAGE,String)
|
#define _(String) dgettext (GETTEXT_PACKAGE, String)
|
||||||
#ifdef gettext_noop
|
#ifdef gettext_noop
|
||||||
#define N_(String) gettext_noop(String)
|
#define N_(String) gettext_noop (String)
|
||||||
#else
|
#else
|
||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
#endif
|
#endif
|
||||||
@ -18,205 +18,196 @@ G_BEGIN_DECLS
|
|||||||
#define N_(String) (String)
|
#define N_(String) (String)
|
||||||
#define textdomain(String) (String)
|
#define textdomain(String) (String)
|
||||||
#define gettext(String) (String)
|
#define gettext(String) (String)
|
||||||
#define dgettext(Domain,String) (String)
|
#define dgettext(Domain, String) (String)
|
||||||
#define dcgettext(Domain,String,Type) (String)
|
#define dcgettext(Domain, String, Type) (String)
|
||||||
#define bindtextdomain(Domain,Directory) (Domain)
|
#define bindtextdomain(Domain, Directory) (Domain)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_title;
|
gchar *dialog_title;
|
||||||
gchar *window_icon;
|
gchar *window_icon;
|
||||||
gchar *ok_label;
|
gchar *ok_label;
|
||||||
gchar *cancel_label;
|
gchar *cancel_label;
|
||||||
gchar **extra_label;
|
gchar **extra_label;
|
||||||
gint width;
|
gint width;
|
||||||
gint height;
|
gint height;
|
||||||
gint exit_code;
|
gint exit_code;
|
||||||
gint timeout_delay;
|
gint timeout_delay;
|
||||||
gboolean modal;
|
gboolean modal;
|
||||||
guintptr attach;
|
guintptr attach;
|
||||||
} ZenityData;
|
} ZenityData;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZENITY_OK,
|
ZENITY_OK,
|
||||||
ZENITY_CANCEL,
|
ZENITY_CANCEL,
|
||||||
ZENITY_ESC,
|
ZENITY_ESC,
|
||||||
ZENITY_ERROR,
|
ZENITY_ERROR,
|
||||||
ZENITY_EXTRA,
|
ZENITY_EXTRA,
|
||||||
ZENITY_TIMEOUT
|
ZENITY_TIMEOUT
|
||||||
} ZenityExitCode;
|
} ZenityExitCode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gint day;
|
gint day;
|
||||||
gint month;
|
gint month;
|
||||||
gint year;
|
gint year;
|
||||||
gchar *date_format;
|
gchar *date_format;
|
||||||
} ZenityCalendarData;
|
} ZenityCalendarData;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZENITY_MSG_WARNING,
|
ZENITY_MSG_WARNING,
|
||||||
ZENITY_MSG_QUESTION,
|
ZENITY_MSG_QUESTION,
|
||||||
ZENITY_MSG_SWITCH,
|
ZENITY_MSG_SWITCH,
|
||||||
ZENITY_MSG_ERROR,
|
ZENITY_MSG_ERROR,
|
||||||
ZENITY_MSG_INFO
|
ZENITY_MSG_INFO
|
||||||
} MsgMode;
|
} MsgMode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *dialog_icon;
|
gchar *dialog_icon;
|
||||||
MsgMode mode;
|
MsgMode mode;
|
||||||
gboolean no_wrap;
|
gboolean no_wrap;
|
||||||
gboolean no_markup;
|
gboolean no_markup;
|
||||||
gboolean default_cancel;
|
gboolean default_cancel;
|
||||||
gboolean ellipsize;
|
gboolean ellipsize;
|
||||||
} ZenityMsgData;
|
} ZenityMsgData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gint value;
|
gint value;
|
||||||
gint min_value;
|
gint min_value;
|
||||||
gint max_value;
|
gint max_value;
|
||||||
gint step;
|
gint step;
|
||||||
gboolean print_partial;
|
gboolean print_partial;
|
||||||
gboolean hide_value;
|
gboolean hide_value;
|
||||||
} ZenityScaleData;
|
} ZenityScaleData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
gboolean multi;
|
gboolean multi;
|
||||||
gboolean directory;
|
gboolean directory;
|
||||||
gboolean save;
|
gboolean save;
|
||||||
gboolean confirm_overwrite;
|
gboolean confirm_overwrite;
|
||||||
gchar *separator;
|
gchar *separator;
|
||||||
gchar **filter;
|
gchar **filter;
|
||||||
} ZenityFileData;
|
} ZenityFileData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *entry_text;
|
gchar *entry_text;
|
||||||
gboolean hide_text;
|
gboolean hide_text;
|
||||||
const gchar **data;
|
const gchar **data;
|
||||||
} ZenityEntryData;
|
} ZenityEntryData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *entry_text;
|
gchar *entry_text;
|
||||||
gboolean pulsate;
|
gboolean pulsate;
|
||||||
gboolean autoclose;
|
gboolean autoclose;
|
||||||
gboolean autokill;
|
gboolean autokill;
|
||||||
gdouble percentage;
|
gdouble percentage;
|
||||||
gboolean no_cancel;
|
gboolean no_cancel;
|
||||||
gboolean time_remaining;
|
gboolean time_remaining;
|
||||||
} ZenityProgressData;
|
} ZenityProgressData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
gboolean no_wrap;
|
gboolean no_wrap;
|
||||||
gboolean auto_scroll;
|
gboolean auto_scroll;
|
||||||
gchar *font;
|
gchar *font;
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
gchar *checkbox;
|
gchar *checkbox;
|
||||||
#ifdef HAVE_WEBKITGTK
|
#ifdef HAVE_WEBKITGTK
|
||||||
gboolean html;
|
gboolean html;
|
||||||
gboolean no_interaction;
|
gboolean no_interaction;
|
||||||
gchar *url;
|
gchar *url;
|
||||||
#endif
|
#endif
|
||||||
} ZenityTextData;
|
} ZenityTextData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
GSList *columns;
|
GSList *columns;
|
||||||
gboolean checkbox;
|
gboolean checkbox;
|
||||||
gboolean radiobox;
|
gboolean radiobox;
|
||||||
gboolean hide_header;
|
gboolean hide_header;
|
||||||
gboolean imagebox;
|
gboolean imagebox;
|
||||||
gchar *separator;
|
gchar *separator;
|
||||||
gboolean multi;
|
gboolean multi;
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
gboolean mid_search;
|
gboolean mid_search;
|
||||||
gchar *print_column;
|
gchar *print_column;
|
||||||
gchar *hide_column;
|
gchar *hide_column;
|
||||||
const gchar **data;
|
const gchar **data;
|
||||||
} ZenityTreeData;
|
} ZenityTreeData;
|
||||||
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *notification_text;
|
gchar *notification_text;
|
||||||
gboolean listen;
|
gboolean listen;
|
||||||
gchar **notification_hints;
|
gchar **notification_hints;
|
||||||
} ZenityNotificationData;
|
} ZenityNotificationData;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *color;
|
gchar *color;
|
||||||
gboolean show_palette;
|
gboolean show_palette;
|
||||||
} ZenityColorData;
|
} ZenityColorData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
GSList *list;
|
GSList *list;
|
||||||
GSList *list_widgets;
|
GSList *list_widgets;
|
||||||
GSList *list_values;
|
GSList *list_values;
|
||||||
GSList *column_values;
|
GSList *column_values;
|
||||||
GSList *combo_values;
|
GSList *combo_values;
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *separator;
|
gchar *separator;
|
||||||
gchar *date_format;
|
gchar *date_format;
|
||||||
// gchar *hide_column;
|
// gchar *hide_column;
|
||||||
gboolean show_header;
|
gboolean show_header;
|
||||||
} ZenityFormsData;
|
} ZenityFormsData;
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZENITY_FORMS_ENTRY,
|
ZENITY_FORMS_ENTRY,
|
||||||
ZENITY_FORMS_PASSWORD,
|
ZENITY_FORMS_PASSWORD,
|
||||||
ZENITY_FORMS_CALENDAR,
|
ZENITY_FORMS_CALENDAR,
|
||||||
ZENITY_FORMS_LIST,
|
ZENITY_FORMS_LIST,
|
||||||
ZENITY_FORMS_COMBO
|
ZENITY_FORMS_COMBO
|
||||||
} ZenityFormsType;
|
} ZenityFormsType;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *option_value;
|
gchar *option_value;
|
||||||
ZenityFormsType type;
|
ZenityFormsType type;
|
||||||
GtkWidget *forms_widget;
|
GtkWidget *forms_widget;
|
||||||
} ZenityFormsValue;
|
} ZenityFormsValue;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gboolean username;
|
gboolean username;
|
||||||
gchar *password;
|
gchar *password;
|
||||||
GtkWidget *entry_username;
|
GtkWidget *entry_username;
|
||||||
GtkWidget *entry_password;
|
GtkWidget *entry_password;
|
||||||
} ZenityPasswordData;
|
} ZenityPasswordData;
|
||||||
|
|
||||||
void zenity_calendar (ZenityData *data,
|
void zenity_calendar (ZenityData *data, ZenityCalendarData *calendar_data);
|
||||||
ZenityCalendarData *calendar_data);
|
void zenity_msg (ZenityData *data, ZenityMsgData *msg_data);
|
||||||
void zenity_msg (ZenityData *data,
|
void zenity_fileselection (ZenityData *data, ZenityFileData *file_data);
|
||||||
ZenityMsgData *msg_data);
|
void zenity_entry (ZenityData *data, ZenityEntryData *entry_data);
|
||||||
void zenity_fileselection (ZenityData *data,
|
void zenity_progress (ZenityData *data, ZenityProgressData *progress_data);
|
||||||
ZenityFileData *file_data);
|
void zenity_text (ZenityData *data, ZenityTextData *text_data);
|
||||||
void zenity_entry (ZenityData *data,
|
void zenity_tree (ZenityData *data, ZenityTreeData *tree_data);
|
||||||
ZenityEntryData *entry_data);
|
|
||||||
void zenity_progress (ZenityData *data,
|
|
||||||
ZenityProgressData *progress_data);
|
|
||||||
void zenity_text (ZenityData *data,
|
|
||||||
ZenityTextData *text_data);
|
|
||||||
void zenity_tree (ZenityData *data,
|
|
||||||
ZenityTreeData *tree_data);
|
|
||||||
#ifdef HAVE_LIBNOTIFY
|
#ifdef HAVE_LIBNOTIFY
|
||||||
void zenity_notification (ZenityData *data,
|
void zenity_notification (
|
||||||
ZenityNotificationData *notification_data);
|
ZenityData *data, ZenityNotificationData *notification_data);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void zenity_colorselection (ZenityData *data,
|
void zenity_colorselection (
|
||||||
ZenityColorData *notification_data);
|
ZenityData *data, ZenityColorData *notification_data);
|
||||||
void zenity_scale (ZenityData *data,
|
void zenity_scale (ZenityData *data, ZenityScaleData *scale_data);
|
||||||
ZenityScaleData *scale_data);
|
void zenity_about (ZenityData *data);
|
||||||
void zenity_about (ZenityData *data);
|
|
||||||
|
|
||||||
void zenity_password_dialog (ZenityData *data,
|
void zenity_password_dialog (
|
||||||
ZenityPasswordData *password_data);
|
ZenityData *data, ZenityPasswordData *password_data);
|
||||||
void zenity_forms_dialog (ZenityData *data,
|
void zenity_forms_dialog (ZenityData *data, ZenityFormsData *forms_data);
|
||||||
ZenityFormsData *forms_data);
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* ZENITY_H */
|
#endif /* ZENITY_H */
|
||||||
|
Reference in New Issue
Block a user