Initial revision

This commit is contained in:
Glynn Foster 2003-01-03 13:26:04 +00:00
commit 48c1564ac5
30 changed files with 3087 additions and 0 deletions

1
AUTHORS Normal file
View File

@ -0,0 +1 @@
Glynn Foster <glynn.foster@sun.com>

4
ChangeLog Normal file
View File

@ -0,0 +1,4 @@
2002-12-15 Glynn Foster <glynn.foster@sun.com>
* zenity/*: Initial import into cvs.gnome.org. Don't
expect things to work very well.

2
HACKING Normal file
View File

@ -0,0 +1,2 @@
Please send patches to any of the people listed in the MAINTAINERS file
for the moment.

1
MAINTAINERS Normal file
View File

@ -0,0 +1 @@
Glynn Foster <glynn.foster@sun.com>

3
Makefile.am Normal file
View File

@ -0,0 +1,3 @@
SUBDIRS = \
src \
data

0
NEWS Normal file
View File

3
README Normal file
View File

@ -0,0 +1,3 @@
This is very beta, unfinished and mostly useless right now.
It's very non-compatible with gdialog. It's also apparently
very Zen. Obviously.

9
TODO Normal file
View File

@ -0,0 +1,9 @@
* Finish off commandline support for list dialog
* Finish off support for progress dialog
* Implement error/return values for all dialogs
* Initialize the ZenityParsingOptions struct properly [nicer way of doing this?]
* Add some accessibility I guess
* Find some nice default window icons
* Implement about box
* Remove extraneous cruft from configure.in
* Start writing help documentation

22
autogen.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.
srcdir=`dirname $0`
test -z "$srcdir" && srcdir=.
PKG_NAME="zenity"
(test -f $srcdir/configure.in \
&& test -f $srcdir/ChangeLog \
&& test -d $srcdir/src) || {
echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
echo " top-level zenity directory"
exit 1
}
which gnome-autogen.sh || {
echo "You need to install gnome-common from the GNOME CVS"
exit 1
}
USE_GNOME2_MACROS=1 . gnome-autogen.sh

71
configure.in Normal file
View File

@ -0,0 +1,71 @@
AC_INIT(src)
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE(zenity, 0.1)
AM_MAINTAINER_MODE
AC_PROG_INTLTOOL([0.21])
dnl ********************************
dnl I bet I don't need half of these
dnl ********************************
AC_ISC_POSIX
AC_PROG_CXX
AC_PROG_CC
AC_PROG_CPP
AC_STDC_HEADERS
AC_PROG_YACC
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PATH_XTRA
GNOME_COMPILE_WARNINGS
PKG_CHECK_MODULES(ZENITY, gtk+-2.0 libglade-2.0)
AC_SUBST(ZENITY_CFLAGS)
AC_SUBST(ZENITY_LIBS)
AC_CHECK_LIB(popt, poptHelpOptions,, AC_MSG_ERROR([popt is required to build script.]))
dnl ***********************************************
dnl scrollkeeper checks - don't use these currently
dnl ***********************************************
dnl
dnl AC_PATH_PROG(SCROLLKEEPER_CONFIG, scrollkeeper-config,no)
dnl if test x$SCROLLKEEPER_CONFIG = xno; then
dnl AC_MSG_ERROR(Couldn't find scrollkeeper-config. Please install the scrollkeeper package)
dnl fi
dnl *******************************
dnl Internationalization
dnl *******************************
ALL_LINGUAS=""
GETTEXT_PACKAGE=zenity-0.1
AC_SUBST(GETTEXT_PACKAGE)
AM_GLIB_GNU_GETTEXT
dnl **************************************************************
dnl AM_GLIB_GNU_GETTEXT above substs $DATADIRNAME
dnl this is the directory where the *.{mo,gmo} files are installed
dnl **************************************************************
zenitylocaledir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(zenitylocaledir)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Finding gettext package])
AC_DEFINE_UNQUOTED(GNOME_ICONDIR, "${prefix}/share/pixmaps", [Determining icon location])
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_OUTPUT([
Makefile
po/Makefile.in
src/Makefile
data/Makefile
])

8
data/Makefile.am Normal file
View File

@ -0,0 +1,8 @@
imagesdir = $(datadir)/zenity/
images_DATA = \
zenity-calendar.png \
zenity-list.png \
zenity-file.png \
zenity-progress.png
EXTRA_DIST = $(images_DATA)

BIN
data/zenity-calendar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

BIN
data/zenity-file.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
data/zenity-list.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

BIN
data/zenity-progress.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

1
po/POTFILES.in Normal file
View File

@ -0,0 +1 @@
src/main.c

11
po/POTFILES.skip Normal file
View File

@ -0,0 +1,11 @@
src/gscript.h
src/calendar.c
src/entry.c
src/fileselection.c
src/gscript.glade
src/msg.c
src/progress.c
src/text.c
src/tree.c
src/util.c
src/util.h

28
src/Makefile.am Normal file
View File

@ -0,0 +1,28 @@
bin_PROGRAMS = zenity
zenity_SOURCES = \
main.c \
zenity.h \
calendar.c \
msg.c \
fileselection.c \
entry.c \
text.c \
progress.c \
tree.c \
util.h \
util.c
INCLUDES = \
$(ZENITY_CFLAGS) \
-I$(includedir) \
-DGNOMELOCALEDIR=\""$(zenitylocaledir)"\" \
-DZENITY_DATADIR=\""$(datadir)/zenity"\"
zenity_LDADD = \
$(ZENITY_LIBS)
gladedir = $(datadir)/zenity
glade_DATA = \
zenity.glade

90
src/calendar.c Normal file
View File

@ -0,0 +1,90 @@
/*
* calendar.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
void zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data);
int zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
GtkWidget *calendar;
GtkWidget *text;
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text);
calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar");
if (cal_data->month != 0 && cal_data->year !=0)
gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month, cal_data->year);
if (cal_data->day)
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_calendar_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

94
src/entry.c Normal file
View File

@ -0,0 +1,94 @@
/*
* entry.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
void zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data);
int zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
GtkWidget *text;
GtkWidget *entry;
glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else
/* FIXME: Come up with a nice default window icon */;
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
if (entry_data->dialog_text)
gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text);
entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input");
if (entry_data->entry_text)
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
if (entry_data->visible == FALSE)
g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL);
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_entry_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

80
src/fileselection.c Normal file
View File

@ -0,0 +1,80 @@
/*
* fileselection.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
void zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data);
int zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
{
GladeXML *glade_dialog;
GtkWidget *dialog;
glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
if (file_data->uri)
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_fileselection_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

834
src/main.c Normal file
View File

@ -0,0 +1,834 @@
/*
* main.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include "config.h"
#include "zenity.h"
#include <popt.h>
typedef enum {
MODE_CALENDAR,
MODE_ENTRY,
MODE_ERROR,
MODE_FILE,
MODE_LIST,
MODE_PROGRESS,
MODE_QUESTION,
MODE_TEXTINFO,
MODE_WARNING,
MODE_LAST
} ZenityDialogMode;
typedef struct {
ZenityDialogMode mode;
ZenityData *data;
ZenityCalendarData *calendar_data;
ZenityMsgData *msg_data;
ZenityFileData *file_data;
ZenityEntryData *entry_data;
ZenityProgressData *progress_data;
ZenityTextData *text_data;
ZenityTreeData *tree_data;
} ZenityParsingOptions;
enum {
OPTION_CALENDAR = 1,
OPTION_ENTRY,
OPTION_ERROR,
OPTION_FILE,
OPTION_LIST,
OPTION_PROGRESS,
OPTION_QUESTION,
OPTION_TEXTINFO,
OPTION_WARNING,
OPTION_TITLE,
OPTION_ICON,
OPTION_CALENDARTEXT,
OPTION_DAY,
OPTION_MONTH,
OPTION_YEAR,
OPTION_ENTRYTEXT,
OPTION_INPUTTEXT,
OPTION_HIDETEXT,
OPTION_ERRORTEXT,
OPTION_FILENAME,
OPTION_COLUMN,
OPTION_CHECKLIST,
OPTION_RADIOLIST,
OPTION_PROGRESSTEXT,
OPTION_PERCENTAGE,
OPTION_QUESTIONTEXT,
OPTION_TEXTFILE,
OPTION_WARNINGTEXT,
OPTION_ABOUT,
OPTION_VERSION,
OPTION_LAST,
};
static void zenity_parse_options_callback (poptContext ctx,
enum poptCallbackReason reason,
const struct poptOption *opt,
const char *arg,
void *data);
struct poptOption options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"calendar",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_CALENDAR,
N_("Display calendar dialog"),
NULL
},
{
"entry",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_ENTRY,
N_("Display text entry dialog"),
NULL
},
{
"error",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_ERROR,
N_("Display error dialog"),
NULL
},
{
"file-selection",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_FILE,
N_("Display file selection dialog"),
NULL
},
{
"list",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_LIST,
N_("Display list dialog"),
NULL
},
{
"progress",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_PROGRESS,
N_("Display progress indication dialog"),
NULL
},
{
"question",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_QUESTION,
N_("Display question dialog"),
NULL
},
{
"text-info",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_TEXTINFO,
N_("Display text information dialog"),
NULL
},
{
"warning",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_WARNING,
N_("Display warning dialog"),
NULL
},
POPT_TABLEEND
};
struct poptOption general_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"title",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_TITLE,
N_("Set the dialog title"),
N_("TITLE")
},
{
"window-icon",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_ICON,
N_("Set the window icon"),
N_("ICONPATH")
},
POPT_TABLEEND
};
struct poptOption calendar_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_CALENDARTEXT,
N_("Set the dialog text"),
NULL
},
{
"day",
'\0',
POPT_ARG_INT,
NULL,
OPTION_DAY,
N_("Set the calendar day"),
NULL
},
{
"month",
'\0',
POPT_ARG_INT,
NULL,
OPTION_MONTH,
N_("Set the calendar month"),
NULL
},
{
"year",
'\0',
POPT_ARG_INT,
NULL,
OPTION_YEAR,
N_("Set the calendar year"),
NULL
},
POPT_TABLEEND
};
struct poptOption entry_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_ENTRYTEXT,
N_("Set the dialog text"),
NULL
},
{
"entry-text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_INPUTTEXT,
N_("Set the entry text"),
NULL
},
{
"hide-text",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_HIDETEXT,
N_("Hide the entry text"),
NULL
},
POPT_TABLEEND
};
struct poptOption error_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_ERRORTEXT,
N_("Set the dialog text"),
NULL
},
POPT_TABLEEND
};
struct poptOption file_selection_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"filename",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_FILENAME,
N_("Set the filename"),
N_("FILENAME")
},
POPT_TABLEEND
};
struct poptOption list_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"column",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_COLUMN,
N_("Set the column header"),
NULL
},
{
"checklist",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_CHECKLIST,
N_("Use check boxes for first column"),
NULL
},
{
"radiolist",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_RADIOLIST,
N_("Use radio buttons for first column"),
NULL
},
POPT_TABLEEND
};
struct poptOption progress_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_PROGRESSTEXT,
N_("Set the dialog text"),
NULL
},
{
"percentage",
'\0',
POPT_ARG_INT,
NULL,
OPTION_PERCENTAGE,
N_("Set initial percentage"),
NULL
},
POPT_TABLEEND
};
struct poptOption question_options[] = {
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_QUESTIONTEXT,
N_("Set the dialog text"),
NULL
},
POPT_TABLEEND
};
struct poptOption text_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"filename",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_TEXTFILE,
N_("Open file"),
N_("FILENAME")
},
POPT_TABLEEND
};
struct poptOption warning_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"text",
'\0',
POPT_ARG_STRING,
NULL,
OPTION_WARNINGTEXT,
N_("Set the dialog text"),
NULL
},
POPT_TABLEEND
};
struct poptOption miscellaneous_options[] = {
{
NULL,
'\0',
POPT_ARG_CALLBACK | POPT_CBFLAG_POST,
zenity_parse_options_callback,
0,
NULL,
NULL
},
{
"about",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_ABOUT,
N_("About zenity"),
NULL
},
{
"version",
'\0',
POPT_ARG_NONE,
NULL,
OPTION_VERSION,
N_("Print version"),
NULL
},
POPT_TABLEEND
};
struct poptOption application_options[] = {
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
options,
0,
N_("Dialog options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
general_options,
0,
N_("General options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
calendar_options,
0,
N_("Calendar options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
entry_options,
0,
N_("Text entry options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
error_options,
0,
N_("Error options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
file_selection_options,
0,
N_("File selection options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
list_options,
0,
N_("List options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
progress_options,
0,
N_("Progress options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
question_options,
0,
N_("Question options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
text_options,
0,
N_("Text options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
warning_options,
0,
N_("Warning options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
miscellaneous_options,
0,
N_("Miscellaneous options"),
NULL
},
{
NULL,
'\0',
POPT_ARG_INCLUDE_TABLE,
poptHelpOptions,
0,
N_("Help options"),
NULL
},
POPT_TABLEEND
};
ZenityParsingOptions *results;
gint
main (gint argc, gchar **argv) {
poptContext ctx;
int nextopt;
ZenityData *general;
ZenityCalendarData *cal_data;
bindtextdomain(GETTEXT_PACKAGE, GNOMELOCALEDIR);
bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
textdomain(GETTEXT_PACKAGE);
results = g_new0 (ZenityParsingOptions, 1);
results->data = g_new0 (ZenityData, 1);
results->calendar_data = g_new0 (ZenityCalendarData, 1);
results->msg_data = g_new0 (ZenityMsgData, 1);
results->file_data = g_new0 (ZenityFileData, 1);
results->entry_data = g_new0 (ZenityEntryData, 1);
results->entry_data->visible = TRUE;
results->progress_data = g_new0 (ZenityProgressData, 1);
results->text_data = g_new0 (ZenityTextData, 1);
results->tree_data = g_new0 (ZenityTreeData, 1);
results->tree_data->checkbox = FALSE;
results->tree_data->radiobox = FALSE;
/* FIXME: popt doesn't like passing stuff through data
* but it doesn't seem to cope with the data that I try
* to pass in, not quite sure why though. If someone knows
* what I'm doing wrong, we could probably put this back:
* options[0].descrip = (void*) results;
*/
ctx = poptGetContext ("zenity", argc, (const char **)argv, application_options, 0);
poptSetOtherOptionHelp(ctx, "[OPTIONS] ...");
poptReadDefaultConfig(ctx, TRUE);
while((nextopt = poptGetNextOpt(ctx)) > 0)
/*nothing*/;
gtk_init (&argc, &argv);
if (argc < 2)
exit (1);
switch (results->mode) {
case MODE_CALENDAR:
zenity_calendar (results->data, results->calendar_data);
break;
case MODE_ENTRY:
zenity_entry (results->data, results->entry_data);
break;
case MODE_ERROR:
case MODE_QUESTION:
case MODE_WARNING:
zenity_msg (results->data, results->msg_data);
break;
case MODE_FILE:
zenity_fileselection (results->data, results->file_data);
break;
case MODE_LIST:
zenity_tree (results->data, results->tree_data);
break;
case MODE_PROGRESS:
zenity_progress (results->data, results->progress_data);
break;
case MODE_TEXTINFO:
zenity_text (results->data, results->text_data);
break;
default:
break;
}
poptFreeContext(ctx);
exit (0);
}
static
void zenity_parse_options_callback (poptContext ctx,
enum poptCallbackReason reason,
const struct poptOption *opt,
const char *arg,
void *data)
{
gint i = 0;
if (reason == POPT_CALLBACK_REASON_POST) {
return;
}
else if (reason != POPT_CALLBACK_REASON_OPTION)
return;
switch (opt->val & POPT_ARG_MASK) {
case OPTION_CALENDAR:
results->mode = MODE_CALENDAR;
break;
case OPTION_ENTRY:
results->mode = MODE_ENTRY;
break;
case OPTION_ERROR:
results->mode = MODE_ERROR;
results->msg_data->mode = ZENITY_MSG_ERROR;
break;
case OPTION_FILE:
results->mode = MODE_FILE;
break;
case OPTION_LIST:
results->mode = MODE_LIST;
break;
case OPTION_PROGRESS:
results->mode = MODE_PROGRESS;
break;
case OPTION_QUESTION:
results->mode = MODE_QUESTION;
results->msg_data->mode = ZENITY_MSG_QUESTION;
break;
case OPTION_TEXTINFO:
results->mode = MODE_TEXTINFO;
break;
case OPTION_WARNING:
results->mode = MODE_WARNING;
results->msg_data->mode = ZENITY_MSG_WARNING;
break;
case OPTION_TITLE:
results->data->dialog_title = g_strdup (arg);
break;
case OPTION_ICON:
results->data->window_icon = g_strdup (arg);
break;
case OPTION_CALENDARTEXT:
case OPTION_ENTRYTEXT:
case OPTION_ERRORTEXT:
case OPTION_QUESTIONTEXT:
case OPTION_PROGRESSTEXT:
case OPTION_WARNINGTEXT:
switch (results->mode) {
case MODE_CALENDAR:
results->calendar_data->dialog_text = g_strdup (arg);
break;
case MODE_ENTRY:
results->entry_data->dialog_text = g_strdup (arg);
break;
case MODE_ERROR:
case MODE_QUESTION:
case MODE_WARNING:
results->msg_data->dialog_text = g_strdup (arg);
break;
case MODE_PROGRESS:
results->progress_data->dialog_text = g_strdup (arg);
break;
default:
break;
}
break;
case OPTION_DAY:
results->calendar_data->day = atoi (arg);
break;
case OPTION_MONTH:
results->calendar_data->month = atoi (arg);
break;
case OPTION_YEAR:
results->calendar_data->year = atoi (arg);
break;
case OPTION_INPUTTEXT:
results->entry_data->entry_text = g_strdup (arg);
break;
case OPTION_HIDETEXT:
results->entry_data->visible = FALSE;
break;
case OPTION_FILENAME:
case OPTION_TEXTFILE:
switch (results->mode) {
case MODE_FILE:
results->file_data->uri = g_strdup (arg);
break;
case MODE_TEXTINFO:
results->text_data->uri = g_strdup (arg);
break;
default:
break;
}
break;
case OPTION_COLUMN:
break;
case OPTION_CHECKLIST:
results->tree_data->checkbox = TRUE;
break;
case OPTION_RADIOLIST:
results->tree_data->radiobox = TRUE;
break;
case OPTION_PERCENTAGE:
results->progress_data->percentage = atoi (arg);
break;
case OPTION_ABOUT:
results->mode = MODE_LAST;
break;
case OPTION_VERSION:
results->mode = MODE_LAST;
g_print ("%s\n", VERSION);
break;
default:
break;
}
}

117
src/msg.c Normal file
View File

@ -0,0 +1,117 @@
/*
* msg.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
void zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data);
int zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
{
GladeXML *glade_dialog;
GtkWidget *dialog;
GtkWidget *text;
switch (msg_data->mode) {
case ZENITY_MSG_WARNING:
glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_warning_text");
break;
case ZENITY_MSG_QUESTION:
glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_question_text");
break;
case ZENITY_MSG_ERROR:
glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog");
dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog");
text = glade_xml_get_widget (glade_dialog, "zenity_error_text");
break;
default:
g_assert_not_reached ();
break;
}
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else {
GdkPixbuf *pixbuf = NULL;
switch (msg_data->mode) {
case ZENITY_MSG_WARNING:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING);
break;
case ZENITY_MSG_QUESTION:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION);
break;
case ZENITY_MSG_ERROR:
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR);
break;
default:
break;
}
}
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_msg_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

139
src/progress.c Normal file
View File

@ -0,0 +1,139 @@
/*
* progress.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <stdio.h>
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
static guint timer;
static GladeXML *glade_dialog;
static gboolean zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data);
static gboolean zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data);
void zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data);
gint
zenity_progress_timeout (gpointer data)
{
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
return TRUE;
}
int zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
{
GtkWidget *dialog;
GtkWidget *text;
GtkWidget *progress_bar;
GIOChannel *giochannel;
guint input;
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else {
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-progress.png"));
}
text = glade_xml_get_widget (glade_dialog, "zenity_progress_text");
gtk_label_set_text (GTK_LABEL (text), progress_data->dialog_text);
progress_bar = glade_xml_get_widget (glade_dialog, "zenity_progress_bar");
giochannel = g_io_channel_unix_new (0);
if (progress_data->pulsate != TRUE) {
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar), progress_data->percentage/100.0);
}
else {
input = g_io_add_watch (giochannel, G_IO_IN | G_IO_HUP, zenity_progress_pulsate_bar, NULL);
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
}
g_io_channel_unref (giochannel);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
static gboolean
zenity_progress_pulsate_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data)
{
gchar buf[1024];
if (!feof (stdin)) {
GtkWidget *button;
gtk_timeout_remove (timer);
g_io_channel_shutdown (giochannel, 0, NULL);
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
gtk_widget_set_sensitive (button, TRUE);
gtk_widget_grab_focus (button);
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
gtk_widget_set_sensitive (button, FALSE);
return FALSE;
}
fgets (buf, sizeof (buf)-1, stdin);
return TRUE;
}
static gboolean
zenity_progress_increment_bar (GIOChannel *giochannel, GIOCondition condition, gpointer data)
{
/* FIXME: Do nothing at the moment */
}
void
zenity_progress_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

83
src/text.c Normal file
View File

@ -0,0 +1,83 @@
/*
* text.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
void zenity_text_dialog_response (GtkWindow *window, int button, gpointer data);
int zenity_text (ZenityData *data, ZenityTextData *text_data)
{
GladeXML *glade_dialog = NULL;
GtkWidget *dialog;
GtkWidget *text_view;
GtkTextBuffer *text_buffer;
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else
;
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
text_buffer = gtk_text_buffer_new (NULL);
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
if (zenity_util_fill_file_buffer (text_buffer, text_data->uri))
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_text_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_CLOSE:
gtk_main_quit ();
break;
default:
break;
}
}

208
src/tree.c Normal file
View File

@ -0,0 +1,208 @@
/*
* tree.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
* Jonathan Blanford <jrb@redhat.com>
* Kristian Rietveld <kris@gtk.org>
*/
#include <glade/glade.h>
#include "zenity.h"
#include "util.h"
#define MAX_ELEMENTS_BEFORE_SCROLLING 8
static GladeXML *glade_dialog;
enum
{
NAME_COLUMN,
DESCRIPTION_COLUMN,
N_COLUMNS
};
void zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data);
static void
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
{
GtkTreeModel *model;
GtkTreeIter iter;
GtkTreePath *path;
gboolean value;
model = GTK_TREE_MODEL (data);
path = gtk_tree_path_new_from_string (path_string);
gtk_tree_model_get_iter (model, &iter, path);
gtk_tree_model_get (model, &iter, NAME_COLUMN, &value, -1);
value = !value;
gtk_list_store_set (GTK_LIST_STORE (model), &iter, NAME_COLUMN, value, -1);
gtk_tree_path_free (path);
}
static gboolean
count_rows_foreach (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
{
gint *rows = data;
(*rows)++;
return FALSE;
}
static void
zenity_tree_fill_entries (GtkTreeView *tree_view, const **argv)
{
GtkTreeModel *model;
GtkTreeIter iter;
gint i = 0;
model = gtk_tree_view_get_model (tree_view);
gtk_tree_model_foreach (model, count_rows_foreach, &i);
while (i<10) {
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
NAME_COLUMN, "TRUE",
DESCRIPTION_COLUMN, "This is the bar above foobar",
-1);
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
GtkWidget *scrolled_window;
GtkRequisition rectangle;
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window");
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
}
i++;
}
}
int
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
{
GtkWidget *dialog;
GtkWidget *tree_view;
GtkTreeViewColumn *column;
GtkListStore *model;
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
if (glade_dialog == NULL)
return FALSE;
glade_xml_signal_autoconnect (glade_dialog);
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
if (data->dialog_title)
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
if (data->window_icon)
zenity_util_set_window_icon (dialog, data->window_icon);
else
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
if (tree_data->checkbox || tree_data->radiobox)
model = gtk_list_store_new (N_COLUMNS, G_TYPE_BOOLEAN, G_TYPE_STRING);
else
model = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING);
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
if (tree_data->checkbox) {
GtkCellRenderer *cell_renderer;
cell_renderer = gtk_cell_renderer_toggle_new ();
g_signal_connect (cell_renderer, "toggled",
G_CALLBACK (zenity_tree_toggled_callback), model);
column = gtk_tree_view_column_new_with_attributes (NULL,
cell_renderer,
"active", NAME_COLUMN, NULL);
}
else if (tree_data->radiobox) {
GtkCellRenderer *cell_renderer;
cell_renderer = gtk_cell_renderer_toggle_new ();
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
g_signal_connect (cell_renderer, "toggled",
G_CALLBACK (zenity_tree_toggled_callback), model);
column = gtk_tree_view_column_new_with_attributes (NULL,
cell_renderer,
"active", NAME_COLUMN, NULL);
}
else {
column = gtk_tree_view_column_new_with_attributes (tree_data->column_one_header,
gtk_cell_renderer_text_new (),
"text", NAME_COLUMN, NULL);
gtk_tree_view_column_set_sort_column_id (column, NAME_COLUMN);
}
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
column = gtk_tree_view_column_new_with_attributes (tree_data->column_two_header,
gtk_cell_renderer_text_new (),
"text", DESCRIPTION_COLUMN, NULL);
gtk_tree_view_column_set_sort_column_id (column, DESCRIPTION_COLUMN);
gtk_tree_view_column_set_resizable (column, TRUE);
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), NULL);
gtk_widget_show (dialog);
gtk_main ();
if (glade_dialog)
g_object_unref (glade_dialog);
return TRUE;
}
void
zenity_tree_dialog_response (GtkWindow *window, int button, gpointer data)
{
GError *error = NULL;
switch (button) {
case GTK_RESPONSE_OK:
gtk_main_quit ();
break;
case GTK_RESPONSE_CANCEL:
gtk_main_quit ();
break;
default:
break;
}
}

158
src/util.c Normal file
View File

@ -0,0 +1,158 @@
/*
* util.c
*
* Copyright (C) 2002 Sun Microsystems, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Glynn Foster <glynn.foster@sun.com>
* Havoc Pennington <hp@redhat.com>
*/
#include <stdio.h>
#include <errno.h>
#include "config.h"
#include "util.h"
GladeXML*
zenity_util_load_glade_file (const gchar *widget_root)
{
GladeXML *xml = NULL;
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH,
G_FILE_TEST_EXISTS)) {
/* Try current dir, for debugging */
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
}
if (xml == NULL)
xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE);
if (xml == NULL) {
g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH);
return NULL;
}
return xml;
}
gboolean
zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename)
{
GtkTextIter iter, end;
FILE* f;
gchar buf[2048];
gint remaining = 0;
if (filename == NULL)
return FALSE;
f = fopen (filename, "r");
if (f == NULL) {
g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno));
return FALSE;
}
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
while (!feof (f)) {
gint count;
const char *leftover;
int to_read = 2047 - remaining;
count = fread (buf + remaining, 1, to_read, f);
buf[count + remaining] = '\0';
g_utf8_validate (buf, count + remaining, &leftover);
g_assert (g_utf8_validate (buf, leftover - buf, NULL));
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
remaining = (buf + remaining + count) - leftover;
g_memmove (buf, leftover, remaining);
if (remaining > 6 || count < to_read)
break;
}
if (remaining) {
g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename);
return FALSE;
}
/* We had a newline in the buffer to begin with. (The buffer always contains
* a newline, so we delete to the end of the buffer to clean up.
*/
gtk_text_buffer_get_end_iter (buffer, &end);
gtk_text_buffer_delete (buffer, &iter, &end);
gtk_text_buffer_set_modified (buffer, FALSE);
return TRUE;
}
static GList *
zenity_util_list_from_char_array (const char **s)
{
GList *list = NULL;
gint i;
for (i = 0; s[i]; i++) {
GdkPixbuf *pixbuf;
pixbuf = gdk_pixbuf_new_from_file (s[i], NULL);
if (pixbuf)
list = g_list_prepend (list, pixbuf);
}
return list;
}
static void
zenity_util_free_list (GList *list)
{
g_list_foreach (list, (GFunc) g_object_unref, NULL);
g_list_free (list);
}
void
zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename)
{
const gchar *filenames[2] = { NULL};
GList *list;
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_WINDOW (widget));
if (filename == NULL)
return;
filenames[0] = filename;
list = zenity_util_list_from_char_array (filenames);
gtk_window_set_icon_list (GTK_WINDOW (widget), list);
zenity_util_free_list (list);
}
void
zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id)
{
GdkPixbuf *pixbuf;
pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL);
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
g_object_unref (pixbuf);
}

26
src/util.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef UTIL_H
#define UTIL_H
#include <gtk/gtk.h>
#include <glade/glade.h>
G_BEGIN_DECLS
#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade"
#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade"
#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL))
GladeXML* zenity_util_load_glade_file (const gchar *widget_root);
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
const gchar *filename);
void zenity_util_set_window_icon (GtkWidget *widget,
const gchar *filename);
void zenity_util_set_window_icon_from_stock (GtkWidget *widget,
const gchar *stock_id);
G_END_DECLS
#endif /* UTIL_H */

999
src/zenity.glade Normal file
View File

@ -0,0 +1,999 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd">
<glade-interface>
<widget class="GtkDialog" id="zenity_calendar_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_calendar_dialog_title</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_calendar_dialog_response" last_modification_time="Fri, 27 Dec 2002 19:07:38 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Fri, 27 Dec 2002 19:08:11 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox1">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area1">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_calendar_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_calendar_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox1">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">4</property>
<child>
<widget class="GtkLabel" id="zenity_calendar_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_calendar_text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">12</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="zenity_calendar_label">
<property name="visible">True</property>
<property name="label" translatable="yes">C_alendar:</property>
<property name="use_underline">True</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<accessibility>
<atkrelation target="zenity_calendar" type="label-for"/>
</accessibility>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkCalendar" id="zenity_calendar">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="display_options">GTK_CALENDAR_SHOW_HEADING|GTK_CALENDAR_SHOW_DAY_NAMES</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_warning_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_warning_dialog_title</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Fri, 27 Dec 2002 23:23:57 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Fri, 27 Dec 2002 23:24:20 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox2">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area2">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_warning_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_warning_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="border_width">13</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image1">
<property name="visible">True</property>
<property name="stock">gtk-dialog-warning</property>
<property name="icon_size">6</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="zenity_warning_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_warning_text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">7</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkFileSelection" id="zenity_fileselection_dialog">
<property name="border_width">10</property>
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_fileselection_dialog_text</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="show_fileops">True</property>
<signal name="response" handler="zenity_fileselection_dialog_response" last_modification_time="Sat, 28 Dec 2002 11:48:14 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 11:48:27 GMT"/>
<child internal-child="cancel_button">
<widget class="GtkButton" id="zenity_fileselection_cancel_button1">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
<child internal-child="ok_button">
<widget class="GtkButton" id="zenity_fileselection_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_question_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_question_dialog_text</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:03:43 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:03:54 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area3">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_question_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_question_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="border_width">13</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-dialog-question</property>
<property name="icon_size">6</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="zenity_question_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_question_text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">7</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_entry_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_entry_dialog_text</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_entry_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:15:25 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:15:37 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox4">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area4">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_entry_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_entry_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox3">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkLabel" id="zenity_entry_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_entry_text:</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
<accessibility>
<atkrelation target="zenity_entry_input" type="label-for"/>
</accessibility>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="zenity_entry_input">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">zenity_entry_input</property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_text_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_text_dialog</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="default_width">300</property>
<property name="default_height">200</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_text_dialog_response" last_modification_time="Sat, 28 Dec 2002 12:34:28 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 12:34:38 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox5">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area5">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_text_close_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-close</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-7</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox5">
<property name="border_width">7</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_ETCHED_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTextView" id="zenity_text_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="justification">GTK_JUSTIFY_LEFT</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="cursor_visible">True</property>
<property name="pixels_above_lines">2</property>
<property name="pixels_below_lines">2</property>
<property name="pixels_inside_wrap">0</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="indent">0</property>
<property name="text" translatable="yes">zenity_text_view</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_progress_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_progress_dialog</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_progress_dialog_response" last_modification_time="Sat, 28 Dec 2002 14:46:19 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 14:46:29 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox6">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area6">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_progress_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_progress_ok_button">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox6">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">5</property>
<child>
<widget class="GtkLabel" id="zenity_progress_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_progress text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkProgressBar" id="zenity_progress_bar">
<property name="visible">True</property>
<property name="orientation">GTK_PROGRESS_LEFT_TO_RIGHT</property>
<property name="fraction">0</property>
<property name="pulse_step">0.1</property>
<property name="text" translatable="yes"></property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_error_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">zenity_error_dialog</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="resizable">False</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_msg_dialog_response" last_modification_time="Sat, 28 Dec 2002 15:05:31 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 15:05:42 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox7">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area7">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_error_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox8">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox3">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkImage" id="image3">
<property name="visible">True</property>
<property name="stock">gtk-dialog-error</property>
<property name="icon_size">6</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="zenity_error_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_error_text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
<widget class="GtkDialog" id="zenity_tree_dialog">
<property name="visible">True</property>
<property name="title" translatable="yes">dialog1</property>
<property name="type">GTK_WINDOW_TOPLEVEL</property>
<property name="window_position">GTK_WIN_POS_CENTER</property>
<property name="modal">False</property>
<property name="default_width">300</property>
<property name="default_height">200</property>
<property name="resizable">True</property>
<property name="destroy_with_parent">False</property>
<property name="has_separator">True</property>
<signal name="response" handler="zenity_tree_dialog_response" last_modification_time="Sat, 28 Dec 2002 22:18:54 GMT"/>
<signal name="destroy" handler="gtk_main_quit" last_modification_time="Sat, 28 Dec 2002 22:19:04 GMT"/>
<child internal-child="vbox">
<widget class="GtkVBox" id="dialog-vbox8">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child internal-child="action_area">
<widget class="GtkHButtonBox" id="dialog-action_area8">
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="zenity_tree_cancel_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="label">gtk-cancel</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-6</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="zenity_tree_ok_button">
<property name="visible">True</property>
<property name="can_default">True</property>
<property name="can_focus">True</property>
<property name="has_focus">True</property>
<property name="label">gtk-ok</property>
<property name="use_stock">True</property>
<property name="relief">GTK_RELIEF_NORMAL</property>
<property name="response_id">-5</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="vbox9">
<property name="border_width">6</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox10">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">6</property>
<child>
<widget class="GtkLabel" id="zenity_tree_text">
<property name="visible">True</property>
<property name="label" translatable="yes">zenity_tree_text</property>
<property name="use_underline">False</property>
<property name="use_markup">True</property>
<property name="justify">GTK_JUSTIFY_LEFT</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0</property>
<property name="yalign">0.5</property>
<property name="xpad">0</property>
<property name="ypad">0</property>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="zenity_tree_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="zenity_tree_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">True</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
</widget>
</child>
</widget>
</glade-interface>

95
src/zenity.h Normal file
View File

@ -0,0 +1,95 @@
#ifndef ZENITY_H
#define ZENITY_H
#include <gtk/gtk.h>
G_BEGIN_DECLS
#ifdef ENABLE_NLS
#include<libintl.h>
#define _(String) dgettext(GETTEXT_PACKAGE,String)
#ifdef gettext_noop
#define N_(String) gettext_noop(String)
#else
#define N_(String) (String)
#endif
#else /* NLS is disabled */
#define _(String) (String)
#define N_(String) (String)
#define textdomain(String) (String)
#define gettext(String) (String)
#define dgettext(Domain,String) (String)
#define dcgettext(Domain,String,Type) (String)
#define bindtextdomain(Domain,Directory) (Domain)
#endif
typedef struct {
gchar *dialog_title;
gchar *window_icon;
} ZenityData;
typedef struct {
gchar *dialog_text;
gint day;
gint month;
gint year;
} ZenityCalendarData;
typedef enum {
ZENITY_MSG_WARNING,
ZENITY_MSG_QUESTION,
ZENITY_MSG_ERROR
} MsgMode;
typedef struct {
gchar *dialog_text;
MsgMode mode;
} ZenityMsgData;
typedef struct {
gchar *uri;
} ZenityFileData;
typedef struct {
gchar *dialog_text;
gchar *entry_text;
gboolean visible;
} ZenityEntryData;
typedef struct {
gchar *dialog_text;
gchar *entry_text;
gboolean pulsate;
gdouble percentage;
} ZenityProgressData;
typedef struct {
gchar *uri;
} ZenityTextData;
typedef struct {
gchar *dialog_text;
gchar *column_one_header;
gchar *column_two_header;
gboolean checkbox;
gboolean radiobox;
} ZenityTreeData;
int zenity_calendar (ZenityData *data,
ZenityCalendarData *calendar_data);
int zenity_msg (ZenityData *data,
ZenityMsgData *msg_data);
int zenity_fileselection (ZenityData *data,
ZenityFileData *file_data);
int zenity_entry (ZenityData *data,
ZenityEntryData *entry_data);
int zenity_progress (ZenityData *data,
ZenityProgressData *progress_data);
int zenity_text (ZenityData *data,
ZenityTextData *text_data);
int zenity_tree (ZenityData *data,
ZenityTreeData *tree_data);
G_END_DECLS
#endif /* ZENITY_H */