Mass indentation cleanup. Make sure the glade dialogs aren't initially
2003-03-10 Glynn Foster <glynn.foster@sun.com> * src/about.c, src/calendar.c, src/entry.c, src/fileselection.c, src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c, src/util.c, src/util.h, src/zenity.glade, src/zenity.h: Mass indentation cleanup. Make sure the glade dialogs aren't initially visible because this avoids a visibility jump. Apparently == TRUE is bad mojo. Fix up.
This commit is contained in:
parent
aaf773626e
commit
49f8979534
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
2003-03-10 Glynn Foster <glynn.foster@sun.com>
|
||||||
|
|
||||||
|
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
|
||||||
|
src/main.c, src/msg.c, src/progress.c, src/text.c, src/tree.c,
|
||||||
|
src/util.c, src/util.h, src/zenity.glade, src/zenity.h:
|
||||||
|
|
||||||
|
Mass indentation cleanup. Make sure the glade dialogs aren't initially
|
||||||
|
visible because this avoids a visibility jump. Apparently == TRUE is
|
||||||
|
bad mojo. Fix up.
|
||||||
|
|
||||||
2003-03-08 Evandro Fernandes Giovanini <evandrofg@ig.com.br>
|
2003-03-08 Evandro Fernandes Giovanini <evandrofg@ig.com.br>
|
||||||
|
|
||||||
* configure.in(ALL_LINGUAS): Added "pt_BR" (Brazilian Portuguese).
|
* configure.in(ALL_LINGUAS): Added "pt_BR" (Brazilian Portuguese).
|
||||||
|
558
src/about.c
558
src/about.c
@ -45,410 +45,416 @@ static void zenity_about_dialog_response (GtkWidget *widget, int response, gpoin
|
|||||||
|
|
||||||
/* Sync with the people in the THANKS file */
|
/* Sync with the people in the THANKS file */
|
||||||
static const gchar *author_credits[] = {
|
static const gchar *author_credits[] = {
|
||||||
"Author -",
|
"Author -",
|
||||||
"Glynn Foster <glynn.foster@sun.com>",
|
"Glynn Foster <glynn.foster@sun.com>",
|
||||||
"",
|
"",
|
||||||
"Thanks to -",
|
"Thanks to -",
|
||||||
"Jonathan Blandford <jrb@redhat.com>",
|
"Jonathan Blandford <jrb@redhat.com>",
|
||||||
"Ross Burton <ross@burtonini.com>",
|
"Ross Burton <ross@burtonini.com>",
|
||||||
"Anders Carlsson <andersca@codefactory.se>",
|
"Anders Carlsson <andersca@codefactory.se>",
|
||||||
"John Fleck <jfleck@inkstain.net>",
|
"John Fleck <jfleck@inkstain.net>",
|
||||||
"James Henstridge <james@daa.com.au>",
|
"James Henstridge <james@daa.com.au>",
|
||||||
"Mihai T. Lazarescu <mihai@email.it>",
|
"Mihai T. Lazarescu <mihai@email.it>",
|
||||||
"Mike Newman <mike@gtnorthern.demon.co.uk>",
|
"Mike Newman <mike@gtnorthern.demon.co.uk>",
|
||||||
"Havoc Pennington <hp@redhat.com>",
|
"Havoc Pennington <hp@redhat.com>",
|
||||||
"Kristian Rietveld <kris@gtk.org>",
|
"Kristian Rietveld <kris@gtk.org>",
|
||||||
"Jakub Steiner <jimmac@ximian.com>",
|
"Jakub Steiner <jimmac@ximian.com>",
|
||||||
"Tom Tromey <tromey@redhat.com>",
|
"Tom Tromey <tromey@redhat.com>",
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
gchar *translator_credits;
|
gchar *translator_credits;
|
||||||
|
|
||||||
static gint
|
static gint
|
||||||
zenity_move_clothes_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
|
zenity_move_clothes_event (GnomeCanvasItem *item,
|
||||||
|
GdkEvent *event,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
static double x, y;
|
static double x, y;
|
||||||
double new_x, new_y;
|
double new_x, new_y;
|
||||||
static int dragging;
|
static int dragging;
|
||||||
double item_x, item_y;
|
double item_x, item_y;
|
||||||
|
|
||||||
/* set item_[xy] to the event x,y position in the parent's item-relative coordinates */
|
/* set item_[xy] to the event x,y position in the parent's
|
||||||
item_x = event->button.x;
|
* item-relative coordinates
|
||||||
item_y = event->button.y;
|
*/
|
||||||
gnome_canvas_item_w2i (item->parent, &item_x, &item_y);
|
|
||||||
|
item_x = event->button.x;
|
||||||
|
item_y = event->button.y;
|
||||||
|
gnome_canvas_item_w2i (item->parent, &item_x, &item_y);
|
||||||
|
|
||||||
switch (event->type) {
|
switch (event->type) {
|
||||||
case GDK_BUTTON_PRESS:
|
case GDK_BUTTON_PRESS:
|
||||||
x = item_x;
|
x = item_x;
|
||||||
y = item_y;
|
y = item_y;
|
||||||
gnome_canvas_item_ungrab (item, event->button.time);
|
gnome_canvas_item_ungrab (item, event->button.time);
|
||||||
gnome_canvas_item_raise_to_top (item);
|
gnome_canvas_item_raise_to_top (item);
|
||||||
dragging = TRUE;
|
dragging = TRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MOTION_NOTIFY:
|
case GDK_MOTION_NOTIFY:
|
||||||
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
|
if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
|
||||||
new_x = item_x;
|
new_x = item_x;
|
||||||
new_y = item_y;
|
new_y = item_y;
|
||||||
|
|
||||||
gnome_canvas_item_move (item, new_x - x, new_y - y);
|
gnome_canvas_item_move (item, new_x - x, new_y - y);
|
||||||
x = new_x;
|
x = new_x;
|
||||||
y = new_y;
|
y = new_y;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_BUTTON_RELEASE:
|
case GDK_BUTTON_RELEASE:
|
||||||
gnome_canvas_item_ungrab (item, event->button.time);
|
gnome_canvas_item_ungrab (item, event->button.time);
|
||||||
dragging = FALSE;
|
dragging = FALSE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
const gchar *filename;
|
const gchar *filename;
|
||||||
gdouble x, y;
|
gdouble x, y;
|
||||||
} MonkClothes;
|
} MonkClothes;
|
||||||
|
|
||||||
static MonkClothes monk_clothes[] = {
|
static MonkClothes monk_clothes[] = {
|
||||||
{"gnome-tshirt.png", 30.0, 20.0},
|
{"gnome-tshirt.png", 30.0, 20.0},
|
||||||
{"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 },
|
{"sunglasses.png", ZENITY_CANVAS_X - 100.0 , ZENITY_CANVAS_Y - 150.0 },
|
||||||
{"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0},
|
{"surfboard.png", 30.0, ZENITY_CANVAS_Y - 200.0},
|
||||||
{"hawaii-shirt.png", ZENITY_CANVAS_X - 50.0, 20.0}
|
{"hawaii-shirt.png", ZENITY_CANVAS_X - 50.0, 20.0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_create_clothes (GtkWidget *canvas_board)
|
zenity_create_clothes (GtkWidget *canvas_board)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GnomeCanvasItem *canvas_item;
|
GnomeCanvasItem *canvas_item;
|
||||||
gchar *pixbuf_path;
|
gchar *pixbuf_path;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) {
|
for (i = 0; i < G_N_ELEMENTS (monk_clothes); i++) {
|
||||||
pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL);
|
pixbuf_path = g_strconcat (ZENITY_CLOTHES_PATH, monk_clothes[i].filename, NULL);
|
||||||
pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL);
|
pixbuf = gdk_pixbuf_new_from_file (pixbuf_path, NULL);
|
||||||
|
|
||||||
canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
|
canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
|
||||||
gnome_canvas_pixbuf_get_type (),
|
gnome_canvas_pixbuf_get_type (),
|
||||||
"x", monk_clothes[i].x,
|
"x", monk_clothes[i].x,
|
||||||
"y", monk_clothes[i].y,
|
"y", monk_clothes[i].y,
|
||||||
"pixbuf", pixbuf,
|
"pixbuf", pixbuf,
|
||||||
"anchor", GTK_ANCHOR_NW,
|
"anchor", GTK_ANCHOR_NW,
|
||||||
NULL);
|
NULL);
|
||||||
g_signal_connect (G_OBJECT (canvas_item), "event",
|
g_signal_connect (G_OBJECT (canvas_item), "event",
|
||||||
G_CALLBACK (zenity_move_clothes_event), NULL);
|
G_CALLBACK (zenity_move_clothes_event), NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
zenity_create_monk (void)
|
zenity_create_monk (void)
|
||||||
{
|
{
|
||||||
GtkWidget *canvas_board;
|
GtkWidget *canvas_board;
|
||||||
GnomeCanvasItem *canvas_item;
|
GnomeCanvasItem *canvas_item;
|
||||||
GnomeCanvasGroup *root;
|
GnomeCanvasGroup *root;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GdkColor color = { 0, 0xffff, 0xffff, 0xffff };
|
GdkColor color = { 0, 0xffff, 0xffff, 0xffff };
|
||||||
|
|
||||||
canvas_board = gnome_canvas_new ();
|
canvas_board = gnome_canvas_new ();
|
||||||
|
|
||||||
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0,
|
gnome_canvas_set_scroll_region (GNOME_CANVAS (canvas_board), 0, 0,
|
||||||
ZENITY_CANVAS_X, ZENITY_CANVAS_Y);
|
ZENITY_CANVAS_X, ZENITY_CANVAS_Y);
|
||||||
|
|
||||||
gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y);
|
gtk_widget_set_size_request (canvas_board, ZENITY_CANVAS_X, ZENITY_CANVAS_Y);
|
||||||
|
|
||||||
gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)),
|
gdk_colormap_alloc_color (gtk_widget_get_colormap (GTK_WIDGET (canvas_board)),
|
||||||
&color, FALSE, TRUE);
|
&color, FALSE, TRUE);
|
||||||
|
|
||||||
gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color);
|
gtk_widget_modify_bg (GTK_WIDGET (canvas_board), GTK_STATE_NORMAL, &color);
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL);
|
pixbuf = gdk_pixbuf_new_from_file (ZENITY_CLOTHES_PATH "monk.png", NULL);
|
||||||
|
|
||||||
canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
|
canvas_item = gnome_canvas_item_new (GNOME_CANVAS_GROUP (GNOME_CANVAS (canvas_board)->root),
|
||||||
gnome_canvas_pixbuf_get_type (),
|
gnome_canvas_pixbuf_get_type (),
|
||||||
"x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0,
|
"x", (ZENITY_CANVAS_X / 2.0)/2.0 + 10.0,
|
||||||
"y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0,
|
"y", (ZENITY_CANVAS_Y / 2.0)/2.0 - 50.0,
|
||||||
"pixbuf", pixbuf,
|
"pixbuf", pixbuf,
|
||||||
"anchor", GTK_ANCHOR_NW,
|
"anchor", GTK_ANCHOR_NW,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
zenity_create_clothes (canvas_board);
|
zenity_create_clothes (canvas_board);
|
||||||
|
|
||||||
return canvas_board;
|
return canvas_board;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
zenity_create_boutique (void)
|
zenity_create_boutique (void)
|
||||||
{
|
{
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
GtkWidget *canvas;
|
GtkWidget *canvas;
|
||||||
|
|
||||||
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
||||||
|
|
||||||
zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
zenity_util_set_window_icon (window, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
||||||
canvas = zenity_create_monk ();
|
canvas = zenity_create_monk ();
|
||||||
gtk_container_add (GTK_CONTAINER (window), canvas);
|
gtk_container_add (GTK_CONTAINER (window), canvas);
|
||||||
|
|
||||||
return window;
|
return window;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data)
|
zenity_zen_wisdom (GtkDialog *dialog, GdkEventKey *event, gpointer user_data)
|
||||||
{
|
{
|
||||||
static gint string_count;
|
static gint string_count;
|
||||||
|
|
||||||
if (string_count >= 3)
|
if (string_count >= 3)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
switch (event->keyval) {
|
switch (event->keyval) {
|
||||||
case GDK_N:
|
case GDK_N:
|
||||||
case GDK_n:
|
case GDK_n:
|
||||||
if (string_count == 2) {
|
if (string_count == 2) {
|
||||||
GtkWidget *window;
|
GtkWidget *window;
|
||||||
window = zenity_create_boutique ();
|
window = zenity_create_boutique ();
|
||||||
gtk_widget_show_all (window);
|
gtk_widget_show_all (window);
|
||||||
string_count++;
|
string_count++;
|
||||||
} else {
|
} else {
|
||||||
string_count = 0;
|
string_count = 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GDK_Z:
|
case GDK_Z:
|
||||||
case GDK_z:
|
case GDK_z:
|
||||||
if (string_count == 0)
|
if (string_count == 0)
|
||||||
string_count++;
|
string_count++;
|
||||||
else
|
else
|
||||||
string_count = 0;
|
string_count = 0;
|
||||||
break;
|
break;
|
||||||
case GDK_E:
|
case GDK_E:
|
||||||
case GDK_e:
|
case GDK_e:
|
||||||
if (string_count == 1)
|
if (string_count == 1)
|
||||||
string_count++;
|
string_count++;
|
||||||
else
|
else
|
||||||
string_count = 0;
|
string_count = 0;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
string_count = 0;
|
string_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_about (ZenityData *data)
|
zenity_about (ZenityData *data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog = NULL;
|
GladeXML *glade_dialog = NULL;
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
GtkWidget *image;
|
GtkWidget *image;
|
||||||
gchar *text;
|
gchar *text;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_about_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
translator_credits = _("translator_credits");
|
translator_credits = _("translator_credits");
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_about_dialog");
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
G_CALLBACK (zenity_about_dialog_response), data);
|
G_CALLBACK (zenity_about_dialog_response), data);
|
||||||
g_signal_connect (G_OBJECT (dialog), "key_press_event",
|
g_signal_connect (G_OBJECT (dialog), "key_press_event",
|
||||||
G_CALLBACK (zenity_zen_wisdom), glade_dialog);
|
G_CALLBACK (zenity_zen_wisdom), glade_dialog);
|
||||||
|
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity.png"));
|
||||||
|
|
||||||
image = glade_xml_get_widget (glade_dialog, "zenity_about_image");
|
image = glade_xml_get_widget (glade_dialog, "zenity_about_image");
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL);
|
pixbuf = gdk_pixbuf_new_from_file (ZENITY_IMAGE_FULLPATH ("zenity.png"), NULL);
|
||||||
|
|
||||||
if (pixbuf != NULL) {
|
if (pixbuf != NULL) {
|
||||||
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
gtk_image_set_from_pixbuf (GTK_IMAGE (image), pixbuf);
|
||||||
g_object_unref (pixbuf);
|
g_object_unref (pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
label = glade_xml_get_widget (glade_dialog, "zenity_about_version");
|
label = glade_xml_get_widget (glade_dialog, "zenity_about_version");
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
||||||
text = g_strdup_printf ("<span size=\"xx-large\" weight=\"bold\">Zenity %s</span>", VERSION);
|
text = g_strdup_printf ("<span size=\"xx-large\" weight=\"bold\">Zenity %s</span>", VERSION);
|
||||||
gtk_label_set_markup (GTK_LABEL (label), text);
|
gtk_label_set_markup (GTK_LABEL (label), text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
|
|
||||||
label = glade_xml_get_widget (glade_dialog, "zenity_about_description");
|
label = glade_xml_get_widget (glade_dialog, "zenity_about_description");
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
||||||
gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts"));
|
gtk_label_set_text (GTK_LABEL (label), _("Display dialog boxes from shell scripts"));
|
||||||
|
|
||||||
label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright");
|
label = glade_xml_get_widget (glade_dialog, "zenity_about_copyright");
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
gtk_label_set_selectable (GTK_LABEL (label), FALSE);
|
||||||
text = g_strdup_printf ("<span size=\"small\">%s</span>", _("(C) 2003 Sun Microsystems"));
|
text = g_strdup_printf ("<span size=\"small\">%s</span>", _("(C) 2003 Sun Microsystems"));
|
||||||
gtk_label_set_markup (GTK_LABEL (label), text);
|
gtk_label_set_markup (GTK_LABEL (label), text);
|
||||||
g_free (text);
|
g_free (text);
|
||||||
|
|
||||||
if (glade_dialog)
|
if (glade_dialog)
|
||||||
g_object_unref (glade_dialog);
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static GtkWidget *
|
static GtkWidget *
|
||||||
zenity_about_create_label (void)
|
zenity_about_create_label (void)
|
||||||
{
|
{
|
||||||
GtkWidget *label;
|
GtkWidget *label;
|
||||||
|
|
||||||
label = gtk_label_new ("");
|
label = gtk_label_new ("");
|
||||||
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
gtk_label_set_selectable (GTK_LABEL (label), TRUE);
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.0);
|
||||||
gtk_misc_set_padding (GTK_MISC (label), 8, 8);
|
gtk_misc_set_padding (GTK_MISC (label), 8, 8);
|
||||||
|
|
||||||
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
|
||||||
|
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_about_update_author_label (GtkWidget *label)
|
zenity_about_update_author_label (GtkWidget *label)
|
||||||
{
|
{
|
||||||
GString *string;
|
GString *string;
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
|
|
||||||
string = g_string_new ("");
|
string = g_string_new ("");
|
||||||
|
|
||||||
for (i = 0; author_credits[i] != NULL; i++) {
|
for (i = 0; author_credits[i] != NULL; i++) {
|
||||||
tmp = g_markup_escape_text (author_credits[i], -1);
|
tmp = g_markup_escape_text (author_credits[i], -1);
|
||||||
g_string_append (string, tmp);
|
g_string_append (string, tmp);
|
||||||
|
|
||||||
if (author_credits[i+1] != NULL)
|
if (author_credits[i+1] != NULL)
|
||||||
g_string_append (string, "\n");
|
g_string_append (string, "\n");
|
||||||
|
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
}
|
}
|
||||||
gtk_label_set_markup (GTK_LABEL (label), string->str);
|
gtk_label_set_markup (GTK_LABEL (label), string->str);
|
||||||
g_string_free (string, TRUE);
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_about_update_translator_label (GtkWidget *label)
|
zenity_about_update_translator_label (GtkWidget *label)
|
||||||
{
|
{
|
||||||
GString *string;
|
GString *string;
|
||||||
gchar *tmp;
|
gchar *tmp;
|
||||||
|
|
||||||
if (strcmp (translator_credits, "translator_credits") == 0) {
|
if (strcmp (translator_credits, "translator_credits") == 0) {
|
||||||
gtk_widget_hide (label);
|
gtk_widget_hide (label);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
gtk_widget_show (label);
|
gtk_widget_show (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
string = g_string_new ("");
|
string = g_string_new ("");
|
||||||
|
|
||||||
tmp = g_markup_escape_text (translator_credits, -1);
|
tmp = g_markup_escape_text (translator_credits, -1);
|
||||||
g_string_append (string, tmp);
|
g_string_append (string, tmp);
|
||||||
g_free (tmp);
|
g_free (tmp);
|
||||||
|
|
||||||
gtk_label_set_markup (GTK_LABEL (label), string->str);
|
gtk_label_set_markup (GTK_LABEL (label), string->str);
|
||||||
g_string_free (string, TRUE);
|
g_string_free (string, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_about_dialog_credits_response (GtkWidget *widget, int response, gpointer data)
|
zenity_about_dialog_credits_response (GtkWidget *widget, int response, gpointer data)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy (widget);
|
gtk_widget_destroy (widget);
|
||||||
widget = NULL;
|
widget = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_about_display_credits_dialog (void)
|
zenity_about_display_credits_dialog (void)
|
||||||
{
|
{
|
||||||
GtkWidget *credits_dialog;
|
GtkWidget *credits_dialog;
|
||||||
GtkWidget *label, *notebook, *sw;
|
GtkWidget *label, *notebook, *sw;
|
||||||
|
|
||||||
if (cred_dialog != NULL) {
|
if (cred_dialog != NULL) {
|
||||||
gtk_window_present (GTK_WINDOW (cred_dialog));
|
gtk_window_present (GTK_WINDOW (cred_dialog));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
credits_dialog = gtk_dialog_new_with_buttons (_("Credits"),
|
credits_dialog = gtk_dialog_new_with_buttons (_("Credits"),
|
||||||
GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT,
|
GTK_WINDOW (dialog), GTK_DIALOG_DESTROY_WITH_PARENT,
|
||||||
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
GTK_STOCK_OK, GTK_RESPONSE_OK, NULL);
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (credits_dialog), "response",
|
g_signal_connect (G_OBJECT (credits_dialog), "response",
|
||||||
G_CALLBACK (gtk_widget_destroy), credits_dialog);
|
G_CALLBACK (gtk_widget_destroy), credits_dialog);
|
||||||
g_signal_connect (G_OBJECT (credits_dialog), "destroy",
|
g_signal_connect (G_OBJECT (credits_dialog), "destroy",
|
||||||
G_CALLBACK (gtk_widget_destroyed), &cred_dialog);
|
G_CALLBACK (gtk_widget_destroyed), &cred_dialog);
|
||||||
|
|
||||||
cred_dialog = credits_dialog;
|
cred_dialog = credits_dialog;
|
||||||
|
|
||||||
gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260);
|
gtk_window_set_default_size (GTK_WINDOW (credits_dialog), 360, 260);
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK);
|
gtk_dialog_set_default_response (GTK_DIALOG (credits_dialog), GTK_RESPONSE_OK);
|
||||||
|
|
||||||
notebook = gtk_notebook_new ();
|
notebook = gtk_notebook_new ();
|
||||||
gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
|
gtk_container_set_border_width (GTK_CONTAINER (notebook), 8);
|
||||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0);
|
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (credits_dialog)->vbox), notebook, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
if (author_credits != NULL) {
|
||||||
|
label = zenity_about_create_label ();
|
||||||
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
|
GTK_POLICY_AUTOMATIC,
|
||||||
|
GTK_POLICY_AUTOMATIC);
|
||||||
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label);
|
||||||
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE);
|
||||||
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw,
|
||||||
|
gtk_label_new (_("Written by")));
|
||||||
|
zenity_about_update_author_label (label);
|
||||||
|
}
|
||||||
|
|
||||||
if (author_credits != NULL) {
|
if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) {
|
||||||
label = zenity_about_create_label ();
|
label = zenity_about_create_label ();
|
||||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
sw = gtk_scrolled_window_new (NULL, NULL);
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
||||||
GTK_POLICY_AUTOMATIC,
|
GTK_POLICY_AUTOMATIC,
|
||||||
GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_AUTOMATIC);
|
||||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label);
|
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label);
|
||||||
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE);
|
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE);
|
||||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw,
|
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw,
|
||||||
gtk_label_new (_("Written by")));
|
gtk_label_new (_("Translated by")));
|
||||||
zenity_about_update_author_label (label);
|
zenity_about_update_translator_label (label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (translator_credits != NULL && strcmp (translator_credits, "translator_credits") != 0) {
|
gtk_widget_show_all (credits_dialog);
|
||||||
label = zenity_about_create_label ();
|
|
||||||
sw = gtk_scrolled_window_new (NULL, NULL);
|
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw),
|
|
||||||
GTK_POLICY_AUTOMATIC,
|
|
||||||
GTK_POLICY_AUTOMATIC);
|
|
||||||
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), label);
|
|
||||||
gtk_viewport_set_shadow_type (GTK_VIEWPORT (GTK_BIN (sw)->child), GTK_SHADOW_NONE);
|
|
||||||
gtk_notebook_append_page (GTK_NOTEBOOK (notebook), sw,
|
|
||||||
gtk_label_new (_("Translated by")));
|
|
||||||
zenity_about_update_translator_label (label);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_widget_show_all (credits_dialog);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_HELP:
|
case GTK_RESPONSE_HELP:
|
||||||
zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL);
|
zenity_util_show_help (ZENITY_HELP_PATH, "zenity.xml", NULL);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CREDITS:
|
case GTK_RESPONSE_CREDITS:
|
||||||
zenity_about_display_credits_dialog ();
|
zenity_about_display_credits_dialog ();
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
/* Esc dialog */
|
default:
|
||||||
zen_data->exit_code = 1;
|
/* Esc dialog */
|
||||||
break;
|
zen_data->exit_code = 1;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
118
src/calendar.c
118
src/calendar.c
@ -35,85 +35,87 @@ static void zenity_calendar_dialog_response (GtkWidget *widget, int response, gp
|
|||||||
void
|
void
|
||||||
zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
zenity_calendar (ZenityData *data, ZenityCalendarData *cal_data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog = NULL;
|
GladeXML *glade_dialog = NULL;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
|
|
||||||
zen_cal_data = cal_data;
|
zen_cal_data = cal_data;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_calendar_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_calendar_dialog");
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
G_CALLBACK (zenity_calendar_dialog_response), data);
|
G_CALLBACK (zenity_calendar_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);
|
||||||
|
|
||||||
if (data->window_icon)
|
if (data->window_icon)
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-calendar.png"));
|
||||||
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_calendar_text");
|
||||||
|
|
||||||
if (cal_data->dialog_text)
|
if (cal_data->dialog_text)
|
||||||
gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text);
|
gtk_label_set_text (GTK_LABEL (text), cal_data->dialog_text);
|
||||||
|
|
||||||
calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar");
|
calendar = glade_xml_get_widget (glade_dialog, "zenity_calendar");
|
||||||
|
|
||||||
if (glade_dialog)
|
if (glade_dialog)
|
||||||
g_object_unref (glade_dialog);
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
if (cal_data->month > 0 && cal_data->year > 0)
|
if (cal_data->month > 0 && cal_data->year > 0)
|
||||||
gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
|
gtk_calendar_select_month (GTK_CALENDAR (calendar), cal_data->month - 1, cal_data->year);
|
||||||
if (cal_data->day > 0)
|
if (cal_data->day > 0)
|
||||||
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
|
gtk_calendar_select_day (GTK_CALENDAR (calendar), cal_data->day);
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
|
gtk_label_set_mnemonic_widget (GTK_LABEL (text), calendar);
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
gint day, month, year;
|
gint day, month, year;
|
||||||
gchar time_string[128];
|
gchar time_string[128];
|
||||||
GDate *date = NULL;
|
GDate *date = NULL;
|
||||||
|
|
||||||
zen_data = data;
|
zen_data = data;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
gtk_calendar_get_date (GTK_CALENDAR (calendar), &day, &month, &year);
|
||||||
date = g_date_new_dmy (year, month + 1, day);
|
date = g_date_new_dmy (year, month + 1, day);
|
||||||
g_date_strftime (time_string, 127,
|
g_date_strftime (time_string, 127,
|
||||||
zen_cal_data->date_format, date);
|
zen_cal_data->date_format, date);
|
||||||
g_printerr ("%s\n", time_string);
|
g_printerr ("%s\n", time_string);
|
||||||
if (date != NULL)
|
|
||||||
g_date_free (date);
|
if (date != NULL)
|
||||||
zen_data->exit_code = 0;
|
g_date_free (date);
|
||||||
gtk_main_quit ();
|
|
||||||
break;
|
zen_data->exit_code = 0;
|
||||||
|
gtk_main_quit ();
|
||||||
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Esc dialog */
|
/* Esc dialog */
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
109
src/entry.c
109
src/entry.c
@ -32,79 +32,80 @@ static GtkWidget *entry;
|
|||||||
void
|
void
|
||||||
zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
zenity_entry (ZenityData *data, ZenityEntryData *entry_data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog = NULL;
|
GladeXML *glade_dialog = NULL;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_entry_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog");
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
|
||||||
G_CALLBACK (zenity_entry_dialog_response), data);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
|
||||||
|
|
||||||
if (data->window_icon)
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_entry_dialog");
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
|
||||||
else
|
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
|
||||||
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
|
G_CALLBACK (zenity_entry_dialog_response), data);
|
||||||
|
|
||||||
if (entry_data->dialog_text)
|
if (data->dialog_title)
|
||||||
gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text);
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input");
|
|
||||||
|
|
||||||
if (glade_dialog)
|
if (data->window_icon)
|
||||||
g_object_unref (glade_dialog);
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
|
else
|
||||||
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-entry.png"));
|
||||||
|
|
||||||
|
text = glade_xml_get_widget (glade_dialog, "zenity_entry_text");
|
||||||
|
|
||||||
if (entry_data->entry_text)
|
if (entry_data->dialog_text)
|
||||||
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
|
gtk_label_set_text_with_mnemonic (GTK_LABEL (text), entry_data->dialog_text);
|
||||||
|
|
||||||
if (entry_data->visible == FALSE)
|
entry = glade_xml_get_widget (glade_dialog, "zenity_entry_input");
|
||||||
g_object_set (G_OBJECT (entry), "visibility", entry_data->visible, NULL);
|
|
||||||
|
if (glade_dialog)
|
||||||
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
gtk_label_set_mnemonic_widget (GTK_LABEL (text), entry);
|
if (entry_data->entry_text)
|
||||||
|
gtk_entry_set_text (GTK_ENTRY (entry), entry_data->entry_text);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
if (!entry_data->visible)
|
||||||
gtk_main ();
|
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
const gchar *text;
|
const gchar *text;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||||
|
|
||||||
if (text != NULL)
|
if (text != NULL)
|
||||||
g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
|
g_printerr ("%s\n", gtk_entry_get_text (GTK_ENTRY (entry)));
|
||||||
|
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* Esc dialog */
|
/* Esc dialog */
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,60 +29,61 @@ static void zenity_fileselection_dialog_response (GtkWidget *widget, int respons
|
|||||||
|
|
||||||
void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
|
void zenity_fileselection (ZenityData *data, ZenityFileData *file_data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog;
|
GladeXML *glade_dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_fileselection_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog");
|
|
||||||
|
|
||||||
if (glade_dialog)
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_fileselection_dialog");
|
||||||
g_object_unref (glade_dialog);
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
|
||||||
G_CALLBACK (zenity_fileselection_dialog_response), data);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
|
||||||
|
|
||||||
if (data->window_icon)
|
if (glade_dialog)
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
g_object_unref (glade_dialog);
|
||||||
else
|
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-file.png"));
|
|
||||||
|
|
||||||
if (file_data->uri)
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
gtk_file_selection_set_filename (GTK_FILE_SELECTION (dialog), file_data->uri);
|
G_CALLBACK (zenity_fileselection_dialog_response), data);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
if (data->dialog_title)
|
||||||
gtk_main ();
|
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 ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_fileselection_dialog_response (GtkWidget *widget, int response, gpointer data)
|
||||||
{
|
{
|
||||||
ZenityData *zen_data = data;
|
ZenityData *zen_data = data;
|
||||||
|
|
||||||
|
switch (response) {
|
||||||
|
case GTK_RESPONSE_OK:
|
||||||
|
zen_data->exit_code = 0;
|
||||||
|
g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget)));
|
||||||
|
gtk_main_quit ();
|
||||||
|
break;
|
||||||
|
|
||||||
switch (response) {
|
case GTK_RESPONSE_CANCEL:
|
||||||
case GTK_RESPONSE_OK:
|
zen_data->exit_code = 1;
|
||||||
zen_data->exit_code = 0;
|
gtk_main_quit ();
|
||||||
g_printerr ("%s\n", gtk_file_selection_get_filename (GTK_FILE_SELECTION (widget)));
|
break;
|
||||||
gtk_main_quit ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
default:
|
||||||
zen_data->exit_code = 1;
|
/* Esc dialog */
|
||||||
gtk_main_quit ();
|
zen_data->exit_code = 1;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
default:
|
|
||||||
zen_data->exit_code = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
1898
src/main.c
1898
src/main.c
File diff suppressed because it is too large
Load Diff
169
src/msg.c
169
src/msg.c
@ -30,105 +30,108 @@ static void zenity_msg_dialog_response (GtkWidget *widget, int response, gpointe
|
|||||||
void
|
void
|
||||||
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
zenity_msg (ZenityData *data, ZenityMsgData *msg_data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog;
|
GladeXML *glade_dialog;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
|
|
||||||
switch (msg_data->mode) {
|
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_WARNING:
|
case ZENITY_MSG_QUESTION:
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_warning_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog");
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_warning_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog");
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_warning_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_question_text");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_QUESTION:
|
case ZENITY_MSG_ERROR:
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_question_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog");
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_question_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog");
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_question_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_error_text");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_ERROR:
|
case ZENITY_MSG_INFO:
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_error_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog");
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_error_dialog");
|
dialog= glade_xml_get_widget (glade_dialog, "zenity_info_dialog");
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_error_text");
|
text = glade_xml_get_widget (glade_dialog, "zenity_info_text");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ZENITY_MSG_INFO:
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_info_dialog");
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_info_dialog");
|
|
||||||
text = glade_xml_get_widget (glade_dialog, "zenity_info_text");
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
G_CALLBACK (zenity_msg_dialog_response), data);
|
G_CALLBACK (zenity_msg_dialog_response), data);
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
|
||||||
data->exit_code = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
if (glade_dialog == NULL) {
|
||||||
|
data->exit_code = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (glade_dialog)
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
g_object_unref (glade_dialog);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
|
||||||
|
|
||||||
if (data->window_icon)
|
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
|
||||||
else {
|
|
||||||
GdkPixbuf *pixbuf = NULL;
|
|
||||||
switch (msg_data->mode) {
|
|
||||||
|
|
||||||
case ZENITY_MSG_WARNING:
|
|
||||||
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING);
|
|
||||||
break;
|
|
||||||
case ZENITY_MSG_QUESTION:
|
|
||||||
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION);
|
|
||||||
break;
|
|
||||||
case ZENITY_MSG_ERROR:
|
|
||||||
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR);
|
|
||||||
break;
|
|
||||||
case ZENITY_MSG_INFO:
|
|
||||||
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (msg_data->dialog_text)
|
if (glade_dialog)
|
||||||
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
if (data->dialog_title)
|
||||||
gtk_main ();
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
|
if (data->window_icon)
|
||||||
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
|
else {
|
||||||
|
GdkPixbuf *pixbuf = NULL;
|
||||||
|
|
||||||
|
switch (msg_data->mode) {
|
||||||
|
case ZENITY_MSG_WARNING:
|
||||||
|
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_WARNING);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZENITY_MSG_QUESTION:
|
||||||
|
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_QUESTION);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZENITY_MSG_ERROR:
|
||||||
|
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_ERROR);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ZENITY_MSG_INFO:
|
||||||
|
zenity_util_set_window_icon_from_stock (dialog, GTK_STOCK_DIALOG_INFO);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (msg_data->dialog_text)
|
||||||
|
gtk_label_set_text (GTK_LABEL (text), msg_data->dialog_text);
|
||||||
|
|
||||||
|
gtk_widget_show (dialog);
|
||||||
|
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:
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
200
src/progress.c
200
src/progress.c
@ -37,142 +37,142 @@ static void zenity_progress_dialog_response (GtkWidget *widget, int response, gp
|
|||||||
void
|
void
|
||||||
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
zenity_progress (ZenityData *data, ZenityProgressData *progress_data)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text;
|
GtkWidget *text;
|
||||||
GtkWidget *progress_bar;
|
GtkWidget *progress_bar;
|
||||||
guint input;
|
guint input;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_progress_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog");
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
|
||||||
G_CALLBACK (zenity_progress_dialog_response), data);
|
|
||||||
|
|
||||||
if (data->dialog_title)
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_progress_dialog");
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
|
||||||
|
|
||||||
if (data->window_icon)
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
G_CALLBACK (zenity_progress_dialog_response), data);
|
||||||
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");
|
|
||||||
|
|
||||||
if (progress_data->percentage > -1)
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
|
||||||
progress_data->percentage/100.0);
|
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
if (data->dialog_title)
|
||||||
if (progress_data->pulsate != TRUE)
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
|
|
||||||
else
|
|
||||||
timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar);
|
|
||||||
|
|
||||||
gtk_main ();
|
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");
|
||||||
|
|
||||||
|
if (progress_data->percentage > -1)
|
||||||
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress_bar),
|
||||||
|
progress_data->percentage/100.0);
|
||||||
|
|
||||||
|
gtk_widget_show (dialog);
|
||||||
|
if (!progress_data->pulsate)
|
||||||
|
timer = gtk_timeout_add (100, zenity_progress_timeout, progress_bar);
|
||||||
|
else
|
||||||
|
timer = gtk_timeout_add (100, zenity_progress_pulsate_timeout, progress_bar);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
zenity_progress_timeout (gpointer data)
|
zenity_progress_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
gchar buffer[256];
|
gchar buffer[256];
|
||||||
float percentage;
|
float percentage;
|
||||||
|
|
||||||
while(gtk_events_pending()) {
|
while(gtk_events_pending()) {
|
||||||
gtk_main_iteration();
|
gtk_main_iteration();
|
||||||
|
|
||||||
if (timer == 0)
|
if (timer == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scanf ("%255s", buffer) == EOF) {
|
if (scanf ("%255s", buffer) == EOF) {
|
||||||
GtkWidget *button;
|
GtkWidget *button;
|
||||||
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
||||||
gtk_widget_set_sensitive (button, TRUE);
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
gtk_widget_grab_focus (button);
|
gtk_widget_grab_focus (button);
|
||||||
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
|
||||||
|
if (glade_dialog)
|
||||||
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
if (glade_dialog)
|
return FALSE;
|
||||||
g_object_unref (glade_dialog);
|
} else {
|
||||||
|
percentage = atoi (buffer);
|
||||||
|
|
||||||
return FALSE;
|
if (percentage > 100)
|
||||||
} else {
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
||||||
percentage = atoi (buffer);
|
else
|
||||||
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0);
|
||||||
|
|
||||||
if (percentage > 100)
|
return TRUE;
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
}
|
||||||
else
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), percentage / 100.0);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gint
|
gint
|
||||||
zenity_progress_pulsate_timeout (gpointer data)
|
zenity_progress_pulsate_timeout (gpointer data)
|
||||||
{
|
{
|
||||||
|
|
||||||
while(gtk_events_pending()) {
|
while(gtk_events_pending()) {
|
||||||
gtk_main_iteration();
|
gtk_main_iteration();
|
||||||
|
|
||||||
if (timer == 0)
|
if (timer == 0)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (feof (stdin)) {
|
if (feof (stdin)) {
|
||||||
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
|
gtk_progress_bar_pulse (GTK_PROGRESS_BAR (data));
|
||||||
|
return FALSE;
|
||||||
|
} else {
|
||||||
|
GtkWidget *button;
|
||||||
|
|
||||||
return FALSE;
|
/* We stop the pulsating and switch the focus on the dialog buttons */
|
||||||
} else {
|
|
||||||
GtkWidget *button;
|
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
||||||
|
|
||||||
/* We stop the pulsating and switch the focus on the dialog buttons */
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
||||||
|
gtk_widget_set_sensitive (button, TRUE);
|
||||||
|
gtk_widget_grab_focus (button);
|
||||||
|
|
||||||
gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (data), 1.0);
|
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
||||||
|
gtk_widget_set_sensitive (button, FALSE);
|
||||||
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_ok_button");
|
return TRUE;
|
||||||
gtk_widget_set_sensitive (button, TRUE);
|
}
|
||||||
gtk_widget_grab_focus (button);
|
|
||||||
|
|
||||||
button = glade_xml_get_widget (glade_dialog, "zenity_progress_cancel_button");
|
|
||||||
gtk_widget_set_sensitive (button, FALSE);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_progress_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_progress_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:
|
||||||
zen_data->exit_code = 0;
|
zen_data->exit_code = 0;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
zen_data->exit_code = 1;
|
/* Esc dialog */
|
||||||
break;
|
zen_data->exit_code = 1;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
107
src/text.c
107
src/text.c
@ -32,74 +32,75 @@ static void zenity_text_dialog_response (GtkWidget *widget, int response, gpoint
|
|||||||
void
|
void
|
||||||
zenity_text (ZenityData *data, ZenityTextData *text_data)
|
zenity_text (ZenityData *data, ZenityTextData *text_data)
|
||||||
{
|
{
|
||||||
GladeXML *glade_dialog = NULL;
|
GladeXML *glade_dialog = NULL;
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *text_view;
|
GtkWidget *text_view;
|
||||||
GtkTextBuffer *text_buffer;
|
GtkTextBuffer *text_buffer;
|
||||||
|
|
||||||
zen_text_data = text_data;
|
zen_text_data = text_data;
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_text_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
|
||||||
data->exit_code = -1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
if (glade_dialog == NULL) {
|
||||||
|
data->exit_code = -1;
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
G_CALLBACK (zenity_text_dialog_response), data);
|
|
||||||
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_text_dialog");
|
||||||
|
|
||||||
if (data->dialog_title)
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
G_CALLBACK (zenity_text_dialog_response), data);
|
||||||
|
|
||||||
|
if (data->dialog_title)
|
||||||
|
gtk_window_set_title (GTK_WINDOW (dialog), data->dialog_title);
|
||||||
|
|
||||||
if (data->window_icon)
|
if (data->window_icon)
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-text.png"));
|
||||||
|
|
||||||
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
|
||||||
|
|
||||||
text_buffer = gtk_text_buffer_new (NULL);
|
text_buffer = gtk_text_buffer_new (NULL);
|
||||||
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
|
text_view = glade_xml_get_widget (glade_dialog, "zenity_text_view");
|
||||||
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
|
gtk_text_view_set_buffer (GTK_TEXT_VIEW (text_view), text_buffer);
|
||||||
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
|
gtk_text_view_set_editable (GTK_TEXT_VIEW(text_view), text_data->editable);
|
||||||
if (text_data->uri) {
|
|
||||||
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text_data->editable) {
|
if (text_data->uri)
|
||||||
zen_text_data->buffer = text_buffer;
|
zenity_util_fill_file_buffer (text_buffer, text_data->uri);
|
||||||
}
|
|
||||||
gtk_widget_show (dialog);
|
|
||||||
|
|
||||||
if (glade_dialog)
|
if (text_data->editable)
|
||||||
g_object_unref (glade_dialog);
|
zen_text_data->buffer = text_buffer;
|
||||||
|
|
||||||
gtk_main ();
|
gtk_widget_show (dialog);
|
||||||
|
|
||||||
|
if (glade_dialog)
|
||||||
|
g_object_unref (glade_dialog);
|
||||||
|
|
||||||
|
gtk_main ();
|
||||||
}
|
}
|
||||||
|
|
||||||
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:
|
||||||
if (zen_text_data->editable) {
|
if (zen_text_data->editable) {
|
||||||
GtkTextIter start, end;
|
GtkTextIter start, end;
|
||||||
|
|
||||||
|
gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end);
|
||||||
|
g_printerr (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0));
|
||||||
|
}
|
||||||
|
zen_data->exit_code = 0;
|
||||||
|
gtk_main_quit ();
|
||||||
|
break;
|
||||||
|
|
||||||
gtk_text_buffer_get_bounds (zen_text_data->buffer, &start, &end);
|
default:
|
||||||
g_printerr (gtk_text_buffer_get_text (zen_text_data->buffer, &start, &end, 0));
|
/* Esc dialog */
|
||||||
}
|
zen_data->exit_code = 1;
|
||||||
zen_data->exit_code = 0;
|
break;
|
||||||
gtk_main_quit ();
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
zen_data->exit_code = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
505
src/tree.c
505
src/tree.c
@ -39,351 +39,352 @@ static void zenity_tree_dialog_response (GtkWidget *widget, int response, gpoint
|
|||||||
static void
|
static void
|
||||||
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
|
zenity_tree_toggled_callback (GtkCellRendererToggle *cell, gchar *path_string, gpointer data)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
gboolean value;
|
gboolean value;
|
||||||
|
|
||||||
model = GTK_TREE_MODEL (data);
|
model = GTK_TREE_MODEL (data);
|
||||||
path = gtk_tree_path_new_from_string (path_string);
|
path = gtk_tree_path_new_from_string (path_string);
|
||||||
|
|
||||||
gtk_tree_model_get_iter (model, &iter, path);
|
gtk_tree_model_get_iter (model, &iter, path);
|
||||||
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
gtk_tree_model_get (model, &iter, 0, &value, -1);
|
||||||
|
|
||||||
value = !value;
|
value = !value;
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, value, -1);
|
||||||
|
|
||||||
gtk_tree_path_free (path);
|
gtk_tree_path_free (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_fill_entries (GtkTreeView *tree_view, const gchar **args, gint n_columns, gboolean toggles, gboolean editable)
|
zenity_tree_fill_entries (GtkTreeView *tree_view,
|
||||||
|
const gchar **args,
|
||||||
|
gint n_columns,
|
||||||
|
gboolean toggles,
|
||||||
|
gboolean editable)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint i = 0;
|
gint i = 0;
|
||||||
|
|
||||||
model = gtk_tree_view_get_model (tree_view);
|
model = gtk_tree_view_get_model (tree_view);
|
||||||
|
|
||||||
while (args[i] != NULL) {
|
while (args[i] != NULL) {
|
||||||
gint j;
|
gint j;
|
||||||
|
|
||||||
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
gtk_list_store_append (GTK_LIST_STORE (model), &iter);
|
||||||
|
|
||||||
for (j = 0; j < n_columns; j++) {
|
for (j = 0; j < n_columns; j++) {
|
||||||
|
|
||||||
if (toggles && j == 0) {
|
if (toggles && j == 0) {
|
||||||
if (strcmp (args[i+j], "TRUE") == 0)
|
if (strcmp (args[i+j], "TRUE") == 0)
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, TRUE, -1);
|
||||||
else
|
else
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, FALSE, -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, j, args[i+j], -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (editable)
|
if (editable)
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1);
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, n_columns, TRUE, -1);
|
||||||
|
|
||||||
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
if (i == MAX_ELEMENTS_BEFORE_SCROLLING) {
|
||||||
GtkWidget *scrolled_window;
|
GtkWidget *scrolled_window;
|
||||||
GtkRequisition rectangle;
|
GtkRequisition rectangle;
|
||||||
|
|
||||||
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
|
gtk_widget_size_request (GTK_WIDGET (tree_view), &rectangle);
|
||||||
scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window");
|
scrolled_window = glade_xml_get_widget (glade_dialog, "zenity_tree_window");
|
||||||
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
|
gtk_widget_set_size_request (scrolled_window, -1, rectangle.height);
|
||||||
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window),
|
||||||
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
|
||||||
}
|
}
|
||||||
i += n_columns;
|
i += n_columns;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_cell_edited_callback (GtkCellRendererText *cell, const gchar *path_string, const gchar *new_text, gpointer data)
|
zenity_cell_edited_callback (GtkCellRendererText *cell,
|
||||||
|
const gchar *path_string,
|
||||||
|
const gchar *new_text,
|
||||||
|
gpointer data)
|
||||||
{
|
{
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkTreePath *path;
|
GtkTreePath *path;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gint column;
|
gint column;
|
||||||
|
|
||||||
model = GTK_TREE_MODEL (data);
|
model = GTK_TREE_MODEL (data);
|
||||||
path = gtk_tree_path_new_from_string (path_string);
|
path = gtk_tree_path_new_from_string (path_string);
|
||||||
|
|
||||||
column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
|
column = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (cell), "column"));
|
||||||
gtk_tree_model_get_iter (model, &iter, path);
|
gtk_tree_model_get_iter (model, &iter, path);
|
||||||
|
|
||||||
|
gtk_list_store_set (GTK_LIST_STORE (model), &iter, column, new_text, -1);
|
||||||
|
|
||||||
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
|
gtk_tree_path_free (path);
|
||||||
column, new_text, -1);
|
|
||||||
|
|
||||||
gtk_tree_path_free (path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
zenity_tree (ZenityData *data, ZenityTreeData *tree_data)
|
||||||
{
|
{
|
||||||
GtkWidget *dialog;
|
GtkWidget *dialog;
|
||||||
GtkWidget *tree_view;
|
GtkWidget *tree_view;
|
||||||
GtkTreeViewColumn *column;
|
GtkTreeViewColumn *column;
|
||||||
GtkListStore *model;
|
GtkListStore *model;
|
||||||
GType *column_types;
|
GType *column_types;
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
gboolean first_column = FALSE;
|
gboolean first_column = FALSE;
|
||||||
gint i, column_index, n_columns;
|
gint i, column_index, n_columns;
|
||||||
|
|
||||||
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
|
glade_dialog = zenity_util_load_glade_file ("zenity_tree_dialog");
|
||||||
|
|
||||||
if (glade_dialog == NULL) {
|
if (glade_dialog == NULL) {
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
separator = g_strdup (tree_data->separator);
|
separator = g_strdup (tree_data->separator);
|
||||||
|
|
||||||
n_columns = g_slist_length (tree_data->columns);
|
n_columns = g_slist_length (tree_data->columns);
|
||||||
|
|
||||||
if (n_columns == 0) {
|
if (n_columns == 0) {
|
||||||
g_printerr (_("No column titles specified for --list\n"));
|
g_printerr (_("No column titles specified for --list\n"));
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree_data->data == NULL) {
|
if (tree_data->data == NULL) {
|
||||||
g_printerr (_("No contents specified for --list\n"));
|
g_printerr (_("No contents specified for --list\n"));
|
||||||
data->exit_code = -1;
|
data->exit_code = -1;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
glade_xml_signal_autoconnect (glade_dialog);
|
glade_xml_signal_autoconnect (glade_dialog);
|
||||||
|
|
||||||
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
|
dialog = glade_xml_get_widget (glade_dialog, "zenity_tree_dialog");
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (dialog), "response",
|
g_signal_connect (G_OBJECT (dialog), "response",
|
||||||
G_CALLBACK (zenity_tree_dialog_response), data);
|
G_CALLBACK (zenity_tree_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);
|
||||||
|
|
||||||
if (data->window_icon)
|
if (data->window_icon)
|
||||||
zenity_util_set_window_icon (dialog, data->window_icon);
|
zenity_util_set_window_icon (dialog, data->window_icon);
|
||||||
else
|
else
|
||||||
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
zenity_util_set_window_icon (dialog, ZENITY_IMAGE_FULLPATH ("zenity-list.png"));
|
||||||
|
|
||||||
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
||||||
|
|
||||||
/* Create an empty list store */
|
/* Create an empty list store */
|
||||||
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
model = g_object_new (GTK_TYPE_LIST_STORE, NULL);
|
||||||
|
|
||||||
if (tree_data->editable)
|
if (tree_data->editable)
|
||||||
column_types = g_new (GType, n_columns + 1);
|
column_types = g_new (GType, n_columns + 1);
|
||||||
else
|
else
|
||||||
column_types = g_new (GType, n_columns);
|
column_types = g_new (GType, n_columns);
|
||||||
|
|
||||||
for (i = 0; i < n_columns; i++) {
|
for (i = 0; i < n_columns; i++) {
|
||||||
/* Have the limitation that the radioboxes and checkboxes are in the first column */
|
/* Have the limitation that the radioboxes and checkboxes are in the first column */
|
||||||
if (i == 0 && (tree_data->checkbox || tree_data->radiobox))
|
if (i == 0 && (tree_data->checkbox || tree_data->radiobox))
|
||||||
column_types[i] = G_TYPE_BOOLEAN;
|
column_types[i] = G_TYPE_BOOLEAN;
|
||||||
else
|
else
|
||||||
column_types[i] = G_TYPE_STRING;
|
column_types[i] = G_TYPE_STRING;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tree_data->editable)
|
if (tree_data->editable)
|
||||||
column_types[n_columns] = G_TYPE_BOOLEAN;
|
column_types[n_columns] = G_TYPE_BOOLEAN;
|
||||||
|
|
||||||
if (tree_data->editable)
|
if (tree_data->editable)
|
||||||
gtk_list_store_set_column_types (model, n_columns + 1, column_types);
|
gtk_list_store_set_column_types (model, n_columns + 1, column_types);
|
||||||
else
|
else
|
||||||
gtk_list_store_set_column_types (model, n_columns, column_types);
|
gtk_list_store_set_column_types (model, n_columns, column_types);
|
||||||
|
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
gtk_tree_view_set_model (GTK_TREE_VIEW (tree_view), GTK_TREE_MODEL (model));
|
||||||
|
|
||||||
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view)),
|
||||||
GTK_SELECTION_MULTIPLE);
|
GTK_SELECTION_MULTIPLE);
|
||||||
|
|
||||||
column_index = 0;
|
column_index = 0;
|
||||||
|
|
||||||
for (tmp = tree_data->columns; tmp; tmp = tmp->next) {
|
for (tmp = tree_data->columns; tmp; tmp = tmp->next) {
|
||||||
if (first_column == FALSE) {
|
if (!first_column) {
|
||||||
if (tree_data->checkbox || tree_data->radiobox) {
|
if (tree_data->checkbox || tree_data->radiobox) {
|
||||||
GtkCellRenderer *cell_renderer;
|
GtkCellRenderer *cell_renderer;
|
||||||
|
|
||||||
cell_renderer = gtk_cell_renderer_toggle_new ();
|
cell_renderer = gtk_cell_renderer_toggle_new ();
|
||||||
|
|
||||||
if (tree_data->radiobox)
|
if (tree_data->radiobox)
|
||||||
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
|
g_object_set (G_OBJECT (cell_renderer), "radio", TRUE, NULL);
|
||||||
|
|
||||||
g_signal_connect (cell_renderer, "toggled",
|
g_signal_connect (cell_renderer, "toggled",
|
||||||
G_CALLBACK (zenity_tree_toggled_callback), model);
|
G_CALLBACK (zenity_tree_toggled_callback), model);
|
||||||
|
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
cell_renderer,
|
cell_renderer,
|
||||||
"active", column_index, NULL);
|
"active", column_index, NULL);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
if (tree_data->editable) {
|
||||||
|
GtkCellRenderer *cell_renderer;
|
||||||
|
|
||||||
else {
|
cell_renderer = gtk_cell_renderer_text_new ();
|
||||||
if (tree_data->editable == TRUE) {
|
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
||||||
GtkCellRenderer *cell_renderer;
|
G_CALLBACK (zenity_cell_edited_callback),
|
||||||
|
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
||||||
|
g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index);
|
||||||
|
|
||||||
cell_renderer = gtk_cell_renderer_text_new ();
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
cell_renderer,
|
||||||
G_CALLBACK (zenity_cell_edited_callback),
|
"text", column_index,
|
||||||
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
"editable", n_columns,
|
||||||
g_object_set_data (G_OBJECT (cell_renderer), "column",
|
NULL);
|
||||||
(gint *) column_index);
|
}
|
||||||
|
else {
|
||||||
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
|
gtk_cell_renderer_text_new (),
|
||||||
|
"text", column_index,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
||||||
cell_renderer,
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||||
"text", column_index,
|
}
|
||||||
"editable", n_columns,
|
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
|
||||||
gtk_cell_renderer_text_new (),
|
|
||||||
"text", column_index, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
|
||||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
first_column = TRUE;
|
first_column = TRUE;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (tree_data->editable == TRUE) {
|
if (tree_data->editable) {
|
||||||
GtkCellRenderer *cell_renderer;
|
GtkCellRenderer *cell_renderer;
|
||||||
|
|
||||||
cell_renderer = gtk_cell_renderer_text_new ();
|
cell_renderer = gtk_cell_renderer_text_new ();
|
||||||
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
g_signal_connect (G_OBJECT (cell_renderer), "edited",
|
||||||
G_CALLBACK (zenity_cell_edited_callback),
|
G_CALLBACK (zenity_cell_edited_callback),
|
||||||
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view)));
|
||||||
g_object_set_data (G_OBJECT (cell_renderer), "column",
|
g_object_set_data (G_OBJECT (cell_renderer), "column", (gint *) column_index);
|
||||||
(gint *) column_index);
|
|
||||||
|
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
cell_renderer,
|
cell_renderer,
|
||||||
"text", column_index,
|
"text", column_index,
|
||||||
"editable", n_columns,
|
"editable", n_columns,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
column = gtk_tree_view_column_new_with_attributes (tmp->data,
|
||||||
gtk_cell_renderer_text_new (),
|
gtk_cell_renderer_text_new (),
|
||||||
"text", column_index, NULL);
|
"text", column_index, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
gtk_tree_view_column_set_sort_column_id (column, column_index);
|
||||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
|
||||||
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view), column);
|
||||||
column_index++;
|
column_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
|
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tree_view), TRUE);
|
||||||
|
|
||||||
if (tree_data->radiobox || tree_data->checkbox)
|
if (tree_data->radiobox || tree_data->checkbox)
|
||||||
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable);
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, TRUE, tree_data->editable);
|
||||||
else
|
else
|
||||||
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable);
|
zenity_tree_fill_entries (GTK_TREE_VIEW (tree_view), tree_data->data, n_columns, FALSE, tree_data->editable);
|
||||||
|
|
||||||
gtk_widget_show (dialog);
|
gtk_widget_show (dialog);
|
||||||
gtk_main ();
|
gtk_main ();
|
||||||
|
|
||||||
if (glade_dialog)
|
if (glade_dialog)
|
||||||
g_object_unref (glade_dialog);
|
g_object_unref (glade_dialog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view)
|
zenity_tree_dialog_get_selected (GtkTreeModel *model, GtkTreePath *path_buf, GtkTreeIter *iter, GtkTreeView *tree_view)
|
||||||
{
|
{
|
||||||
GValue value = {0, };
|
GValue value = {0, };
|
||||||
|
|
||||||
gtk_tree_model_get_value (model, iter, 0, &value);
|
gtk_tree_model_get_value (model, iter, 0, &value);
|
||||||
|
|
||||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
zenity_tree_dialog_toggle_get_selected (GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data)
|
||||||
{
|
{
|
||||||
GValue toggle_value = {0, };
|
GValue toggle_value = {0, };
|
||||||
|
|
||||||
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
gtk_tree_model_get_value (model, iter, 0, &toggle_value);
|
||||||
|
|
||||||
if (g_value_get_boolean (&toggle_value) == TRUE) {
|
if (g_value_get_boolean (&toggle_value)) {
|
||||||
GValue value = {0, };
|
GValue value = {0, };
|
||||||
gtk_tree_model_get_value (model, iter, 1, &value);
|
gtk_tree_model_get_value (model, iter, 1, &value);
|
||||||
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
selected = g_slist_append (selected, g_strdup (g_value_get_string (&value)));
|
||||||
g_value_unset (&value);
|
g_value_unset (&value);
|
||||||
}
|
}
|
||||||
g_value_unset (&toggle_value);
|
g_value_unset (&toggle_value);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_dialog_output (void)
|
zenity_tree_dialog_output (void)
|
||||||
{
|
{
|
||||||
GSList *tmp;
|
GSList *tmp;
|
||||||
|
|
||||||
for (tmp = selected; tmp; tmp = tmp->next) {
|
for (tmp = selected; tmp; tmp = tmp->next) {
|
||||||
if (tmp->next != NULL) {
|
if (tmp->next != NULL) {
|
||||||
/* FIXME: There must be a nicer way to do this. This is just arse */
|
/* FIXME: There must be a nicer way to do this. This is just arse */
|
||||||
if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL)
|
if (strstr ((const gchar *) separator, (const gchar *) "\\n") != NULL)
|
||||||
g_printerr ("%s\n", tmp->data);
|
g_printerr ("%s\n", tmp->data);
|
||||||
else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL)
|
else if (strstr ((const gchar *) separator, (const gchar *) "\\t") != NULL)
|
||||||
g_printerr ("%s\t", tmp->data);
|
g_printerr ("%s\t", tmp->data);
|
||||||
else
|
else
|
||||||
g_printerr ("%s%s", tmp->data, separator);
|
g_printerr ("%s%s", tmp->data, separator);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
g_printerr ("%s\n", tmp->data);
|
g_printerr ("%s\n", tmp->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (separator);
|
g_free (separator);
|
||||||
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
g_slist_foreach (selected, (GFunc) g_free, NULL);
|
||||||
selected = NULL;
|
selected = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
zenity_tree_dialog_response (GtkWidget *widget, int response, gpointer data)
|
||||||
{
|
{
|
||||||
ZenityData *zen_data = data;
|
ZenityData *zen_data = data;
|
||||||
GtkWidget *tree_view;
|
GtkWidget *tree_view;
|
||||||
GtkTreeSelection *selection;
|
GtkTreeSelection *selection;
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
|
|
||||||
switch (response) {
|
switch (response) {
|
||||||
case GTK_RESPONSE_OK:
|
case GTK_RESPONSE_OK:
|
||||||
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
tree_view = glade_xml_get_widget (glade_dialog, "zenity_tree_view");
|
||||||
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree_view));
|
||||||
|
|
||||||
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN) {
|
if (gtk_tree_model_get_column_type (model, 0) == G_TYPE_BOOLEAN)
|
||||||
gtk_tree_model_foreach (model,
|
gtk_tree_model_foreach (model, (GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected, NULL);
|
||||||
(GtkTreeModelForeachFunc) zenity_tree_dialog_toggle_get_selected,
|
else {
|
||||||
NULL);
|
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
||||||
}
|
gtk_tree_selection_selected_foreach (selection,
|
||||||
else {
|
(GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected,
|
||||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
|
GTK_TREE_VIEW (tree_view));
|
||||||
gtk_tree_selection_selected_foreach (selection,
|
}
|
||||||
(GtkTreeSelectionForeachFunc) zenity_tree_dialog_get_selected,
|
zenity_tree_dialog_output ();
|
||||||
GTK_TREE_VIEW (tree_view));
|
zen_data->exit_code = 0;
|
||||||
}
|
gtk_main_quit ();
|
||||||
zenity_tree_dialog_output ();
|
break;
|
||||||
zen_data->exit_code = 0;
|
|
||||||
gtk_main_quit ();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GTK_RESPONSE_CANCEL:
|
case GTK_RESPONSE_CANCEL:
|
||||||
zen_data->exit_code = 1;
|
zen_data->exit_code = 1;
|
||||||
gtk_main_quit ();
|
gtk_main_quit ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
zen_data->exit_code = 1;
|
/* Esc dialog */
|
||||||
break;
|
zen_data->exit_code = 1;
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
665
src/util.c
665
src/util.c
@ -41,131 +41,131 @@
|
|||||||
GladeXML*
|
GladeXML*
|
||||||
zenity_util_load_glade_file (const gchar *widget_root)
|
zenity_util_load_glade_file (const gchar *widget_root)
|
||||||
{
|
{
|
||||||
GladeXML *xml = NULL;
|
GladeXML *xml = NULL;
|
||||||
|
|
||||||
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH,
|
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
|
||||||
G_FILE_TEST_EXISTS)) {
|
/* Try current dir, for debugging */
|
||||||
/* Try current dir, for debugging */
|
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
|
||||||
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (xml == NULL)
|
if (xml == NULL)
|
||||||
xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE);
|
xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE);
|
||||||
|
|
||||||
if (xml == NULL) {
|
if (xml == NULL) {
|
||||||
g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH);
|
g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ("Invalid UTF-8 data encountered reading file '%s'", filename);
|
||||||
return FALSE;
|
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_get_end_iter (buffer, &end);
|
||||||
|
gtk_text_buffer_delete (buffer, &iter, &end);
|
||||||
|
|
||||||
gtk_text_buffer_set_modified (buffer, FALSE);
|
gtk_text_buffer_set_modified (buffer, FALSE);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
zenity_util_list_from_char_array (const char **s)
|
zenity_util_list_from_char_array (const char **s)
|
||||||
{
|
{
|
||||||
GList *list = NULL;
|
GList *list = NULL;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
for (i = 0; s[i]; i++) {
|
for (i = 0; s[i]; i++) {
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
pixbuf = gdk_pixbuf_new_from_file (s[i], NULL);
|
pixbuf = gdk_pixbuf_new_from_file (s[i], NULL);
|
||||||
if (pixbuf)
|
if (pixbuf)
|
||||||
list = g_list_prepend (list, pixbuf);
|
list = g_list_prepend (list, pixbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
zenity_util_free_list (GList *list)
|
zenity_util_free_list (GList *list)
|
||||||
{
|
{
|
||||||
g_list_foreach (list, (GFunc) g_object_unref, NULL);
|
g_list_foreach (list, (GFunc) g_object_unref, NULL);
|
||||||
g_list_free (list);
|
g_list_free (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename)
|
zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename)
|
||||||
{
|
{
|
||||||
const gchar *filenames[2] = { NULL};
|
const gchar *filenames[2] = { NULL};
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
g_return_if_fail (widget != NULL);
|
g_return_if_fail (widget != NULL);
|
||||||
g_return_if_fail (GTK_IS_WINDOW (widget));
|
g_return_if_fail (GTK_IS_WINDOW (widget));
|
||||||
|
|
||||||
if (filename == NULL)
|
if (filename == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
filenames[0] = filename;
|
filenames[0] = filename;
|
||||||
list = zenity_util_list_from_char_array (filenames);
|
list = zenity_util_list_from_char_array (filenames);
|
||||||
gtk_window_set_icon_list (GTK_WINDOW (widget), list);
|
gtk_window_set_icon_list (GTK_WINDOW (widget), list);
|
||||||
zenity_util_free_list (list);
|
zenity_util_free_list (list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id)
|
zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *stock_id)
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf;
|
GdkPixbuf *pixbuf;
|
||||||
|
|
||||||
pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, NULL);
|
pixbuf = gtk_widget_render_icon (widget, stock_id, (GtkIconSize) -1, 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is copied from libgnome/gnome-i18n.c since we try and avoid using
|
/* This is copied from libgnome/gnome-i18n.c since we try and avoid using
|
||||||
@ -178,70 +178,70 @@ static GHashTable *alias_table = NULL;
|
|||||||
static void
|
static void
|
||||||
zenity_read_aliases (char *file)
|
zenity_read_aliases (char *file)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char buf[256];
|
char buf[256];
|
||||||
|
|
||||||
if (!alias_table)
|
if (!alias_table)
|
||||||
alias_table = g_hash_table_new (g_str_hash, g_str_equal);
|
alias_table = g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
|
|
||||||
fp = fopen (file,"r");
|
fp = fopen (file,"r");
|
||||||
|
|
||||||
if (!fp)
|
if (!fp)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (fgets (buf,256,fp)) {
|
while (fgets (buf,256,fp)) {
|
||||||
gchar *p;
|
gchar *p;
|
||||||
g_strstrip (buf);
|
g_strstrip (buf);
|
||||||
|
|
||||||
if (buf[0]=='#' || buf[0]=='\0')
|
if (buf[0]=='#' || buf[0]=='\0')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p = (gchar *) strtok (buf, "\t ");
|
p = (gchar *) strtok (buf, "\t ");
|
||||||
|
|
||||||
if (!p)
|
if (!p)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
p = (gchar *) strtok (NULL, "\t ");
|
p = (gchar *) strtok (NULL, "\t ");
|
||||||
|
|
||||||
if(!p)
|
if(!p)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (!g_hash_table_lookup (alias_table, buf))
|
if (!g_hash_table_lookup (alias_table, buf))
|
||||||
g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p));
|
g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (p));
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*return the un-aliased language as a newly allocated string*/
|
/*return the un-aliased language as a newly allocated string*/
|
||||||
static char *
|
static char *
|
||||||
zenity_unalias_lang (char *lang)
|
zenity_unalias_lang (char *lang)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (!alias_table) {
|
if (!alias_table) {
|
||||||
zenity_read_aliases ("/usr/share/locale/locale.alias");
|
zenity_read_aliases ("/usr/share/locale/locale.alias");
|
||||||
zenity_read_aliases ("/usr/local/share/locale/locale.alias");
|
zenity_read_aliases ("/usr/local/share/locale/locale.alias");
|
||||||
zenity_read_aliases ("/usr/lib/X11/locale/locale.alias");
|
zenity_read_aliases ("/usr/lib/X11/locale/locale.alias");
|
||||||
zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias");
|
zenity_read_aliases ("/usr/openwin/lib/locale/locale.alias");
|
||||||
}
|
}
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) {
|
while ((p = g_hash_table_lookup (alias_table,lang)) && strcmp (p, lang)) {
|
||||||
lang = p;
|
lang = p;
|
||||||
|
|
||||||
if (i++ == 30) {
|
if (i++ == 30) {
|
||||||
static gboolean said_before = FALSE;
|
static gboolean said_before = FALSE;
|
||||||
|
|
||||||
if (!said_before)
|
if (!said_before)
|
||||||
g_warning (_("Too many alias levels for a locale may indicate a loop"));
|
g_warning (_("Too many alias levels for a locale may indicate a loop"));
|
||||||
|
|
||||||
said_before = TRUE;
|
said_before = TRUE;
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return lang;
|
return lang;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Mask for components of locale spec. The ordering here is from
|
/* Mask for components of locale spec. The ordering here is from
|
||||||
@ -249,137 +249,139 @@ zenity_unalias_lang (char *lang)
|
|||||||
*/
|
*/
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
COMPONENT_CODESET = 1 << 0,
|
COMPONENT_CODESET = 1 << 0,
|
||||||
COMPONENT_TERRITORY = 1 << 1,
|
COMPONENT_TERRITORY = 1 << 1,
|
||||||
COMPONENT_MODIFIER = 1 << 2
|
COMPONENT_MODIFIER = 1 << 2
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Break an X/Open style locale specification into components
|
/* Break an X/Open style locale specification into components
|
||||||
*/
|
*/
|
||||||
static guint
|
static guint
|
||||||
zenity_explode_locale (const gchar *locale,
|
zenity_explode_locale (const gchar *locale,
|
||||||
gchar **language,
|
gchar **language,
|
||||||
gchar **territory,
|
gchar **territory,
|
||||||
gchar **codeset,
|
gchar **codeset,
|
||||||
gchar **modifier)
|
gchar **modifier)
|
||||||
{
|
{
|
||||||
const gchar *uscore_pos;
|
const gchar *uscore_pos;
|
||||||
const gchar *at_pos;
|
const gchar *at_pos;
|
||||||
const gchar *dot_pos;
|
const gchar *dot_pos;
|
||||||
guint mask = 0;
|
guint mask = 0;
|
||||||
|
|
||||||
uscore_pos = (const gchar *) strchr (locale, '_');
|
uscore_pos = (const gchar *) strchr (locale, '_');
|
||||||
dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.');
|
dot_pos = (const gchar *) strchr (uscore_pos ? uscore_pos : locale, '.');
|
||||||
at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@');
|
at_pos = (const gchar *) strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@');
|
||||||
|
|
||||||
if (at_pos) {
|
if (at_pos) {
|
||||||
mask |= COMPONENT_MODIFIER;
|
mask |= COMPONENT_MODIFIER;
|
||||||
*modifier = g_strdup (at_pos);
|
*modifier = g_strdup (at_pos);
|
||||||
} else
|
}
|
||||||
at_pos = locale + strlen (locale);
|
else
|
||||||
|
at_pos = locale + strlen (locale);
|
||||||
|
|
||||||
if (dot_pos) {
|
if (dot_pos) {
|
||||||
mask |= COMPONENT_CODESET;
|
mask |= COMPONENT_CODESET;
|
||||||
*codeset = g_new (gchar, 1 + at_pos - dot_pos);
|
*codeset = g_new (gchar, 1 + at_pos - dot_pos);
|
||||||
strncpy (*codeset, dot_pos, at_pos - dot_pos);
|
strncpy (*codeset, dot_pos, at_pos - dot_pos);
|
||||||
(*codeset) [at_pos - dot_pos] = '\0';
|
(*codeset) [at_pos - dot_pos] = '\0';
|
||||||
} else
|
}
|
||||||
dot_pos = at_pos;
|
else
|
||||||
|
dot_pos = at_pos;
|
||||||
|
|
||||||
if (uscore_pos) {
|
if (uscore_pos) {
|
||||||
mask |= COMPONENT_TERRITORY;
|
mask |= COMPONENT_TERRITORY;
|
||||||
*territory = g_new (gchar, 1 + dot_pos - uscore_pos);
|
*territory = g_new (gchar, 1 + dot_pos - uscore_pos);
|
||||||
strncpy (*territory, uscore_pos, dot_pos - uscore_pos);
|
strncpy (*territory, uscore_pos, dot_pos - uscore_pos);
|
||||||
(*territory)[dot_pos - uscore_pos] = '\0';
|
(*territory)[dot_pos - uscore_pos] = '\0';
|
||||||
} else
|
}
|
||||||
uscore_pos = dot_pos;
|
else
|
||||||
|
uscore_pos = dot_pos;
|
||||||
|
|
||||||
*language = g_new (gchar, 1 + uscore_pos - locale);
|
*language = g_new (gchar, 1 + uscore_pos - locale);
|
||||||
strncpy (*language, locale, uscore_pos - locale);
|
strncpy (*language, locale, uscore_pos - locale);
|
||||||
(*language) [uscore_pos - locale] = '\0';
|
(*language) [uscore_pos - locale] = '\0';
|
||||||
|
|
||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
zenity_compute_locale_variants (const gchar *locale)
|
zenity_compute_locale_variants (const gchar *locale)
|
||||||
{
|
{
|
||||||
GList *retval = NULL;
|
GList *retval = NULL;
|
||||||
gchar *language;
|
gchar *language;
|
||||||
gchar *territory;
|
gchar *territory;
|
||||||
gchar *codeset;
|
gchar *codeset;
|
||||||
gchar *modifier;
|
gchar *modifier;
|
||||||
guint mask;
|
guint mask;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
|
|
||||||
g_return_val_if_fail (locale != NULL, NULL);
|
g_return_val_if_fail (locale != NULL, NULL);
|
||||||
|
|
||||||
mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier);
|
mask = zenity_explode_locale (locale, &language, &territory, &codeset, &modifier);
|
||||||
|
|
||||||
/* Iterate through all possible combinations, from least attractive
|
/* Iterate through all possible combinations, from least attractive
|
||||||
* to most attractive.
|
* to most attractive.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
for (i = 0; i <= mask; i++)
|
for (i = 0; i <= mask; i++)
|
||||||
if ((i & ~mask) == 0) {
|
if ((i & ~mask) == 0) {
|
||||||
gchar *val = g_strconcat (language,
|
gchar *val = g_strconcat (language, (i & COMPONENT_TERRITORY) ? territory : "",
|
||||||
(i & COMPONENT_TERRITORY) ? territory : "",
|
(i & COMPONENT_CODESET) ? codeset : "",
|
||||||
(i & COMPONENT_CODESET) ? codeset : "",
|
(i & COMPONENT_MODIFIER) ? modifier : "", NULL);
|
||||||
(i & COMPONENT_MODIFIER) ? modifier : "", NULL);
|
retval = g_list_prepend (retval, val);
|
||||||
retval = g_list_prepend (retval, val);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
g_free (language);
|
g_free (language);
|
||||||
|
|
||||||
if (mask & COMPONENT_CODESET)
|
if (mask & COMPONENT_CODESET)
|
||||||
g_free (codeset);
|
g_free (codeset);
|
||||||
if (mask & COMPONENT_TERRITORY)
|
if (mask & COMPONENT_TERRITORY)
|
||||||
g_free (territory);
|
g_free (territory);
|
||||||
if (mask & COMPONENT_MODIFIER)
|
if (mask & COMPONENT_MODIFIER)
|
||||||
g_free (modifier);
|
g_free (modifier);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const gchar *
|
static const gchar *
|
||||||
zenity_guess_category_value (const gchar *categoryname)
|
zenity_guess_category_value (const gchar *categoryname)
|
||||||
{
|
{
|
||||||
const gchar *retval;
|
const gchar *retval;
|
||||||
|
|
||||||
/* The highest priority value is the `LANGUAGE' environment
|
/* The highest priority value is the `LANGUAGE' environment
|
||||||
* variable. This is a GNU extension.
|
* variable. This is a GNU extension.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
retval = g_getenv ("LANGUAGE");
|
retval = g_getenv ("LANGUAGE");
|
||||||
|
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval != NULL && retval[0] != '\0')
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* `LANGUAGE' is not set. So we have to proceed with the POSIX
|
/* `LANGUAGE' is not set. So we have to proceed with the POSIX
|
||||||
* methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
|
* methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
|
||||||
* systems this can be done by the `setlocale' function itself.
|
* systems this can be done by the `setlocale' function itself.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Setting of LC_ALL overwrites all other. */
|
/* Setting of LC_ALL overwrites all other. */
|
||||||
|
|
||||||
retval = g_getenv ("LC_ALL");
|
retval = g_getenv ("LC_ALL");
|
||||||
|
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval != NULL && retval[0] != '\0')
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* Next comes the name of the desired category. */
|
/* Next comes the name of the desired category. */
|
||||||
retval = g_getenv (categoryname);
|
retval = g_getenv (categoryname);
|
||||||
|
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval != NULL && retval[0] != '\0')
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
/* Last possibility is the LANG environment variable. */
|
/* Last possibility is the LANG environment variable. */
|
||||||
retval = g_getenv ("LANG");
|
retval = g_getenv ("LANG");
|
||||||
if (retval != NULL && retval[0] != '\0')
|
if (retval != NULL && retval[0] != '\0')
|
||||||
return retval;
|
return retval;
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -388,61 +390,61 @@ static GHashTable *category_table= NULL;
|
|||||||
static const GList *
|
static const GList *
|
||||||
zenity_i18n_get_language_list (const gchar *category_name)
|
zenity_i18n_get_language_list (const gchar *category_name)
|
||||||
{
|
{
|
||||||
GList *list;
|
GList *list;
|
||||||
|
|
||||||
if (!category_name)
|
if (!category_name)
|
||||||
category_name= "LC_ALL";
|
category_name= "LC_ALL";
|
||||||
|
|
||||||
if (category_table) {
|
if (category_table) {
|
||||||
list= g_hash_table_lookup (category_table, (const gpointer) category_name);
|
list= g_hash_table_lookup (category_table, (const gpointer) category_name);
|
||||||
} else {
|
} else {
|
||||||
category_table= g_hash_table_new (g_str_hash, g_str_equal);
|
category_table= g_hash_table_new (g_str_hash, g_str_equal);
|
||||||
list= NULL;
|
list= NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!list) {
|
if (!list) {
|
||||||
gint c_locale_defined= FALSE;
|
gint c_locale_defined= FALSE;
|
||||||
const gchar *category_value;
|
const gchar *category_value;
|
||||||
gchar *category_memory, *orig_category_memory;
|
gchar *category_memory, *orig_category_memory;
|
||||||
|
|
||||||
category_value = zenity_guess_category_value (category_name);
|
category_value = zenity_guess_category_value (category_name);
|
||||||
|
|
||||||
if (! category_value)
|
if (! category_value)
|
||||||
category_value = "C";
|
category_value = "C";
|
||||||
|
|
||||||
orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1);
|
orig_category_memory = category_memory = g_malloc (strlen (category_value) + 1);
|
||||||
|
|
||||||
while (category_value[0] != '\0') {
|
while (category_value[0] != '\0') {
|
||||||
while (category_value[0] != '\0' && category_value[0] == ':')
|
while (category_value[0] != '\0' && category_value[0] == ':')
|
||||||
++category_value;
|
++category_value;
|
||||||
|
|
||||||
if (category_value[0] != '\0') {
|
if (category_value[0] != '\0') {
|
||||||
char *cp= category_memory;
|
char *cp= category_memory;
|
||||||
|
|
||||||
while (category_value[0] != '\0' && category_value[0] != ':')
|
while (category_value[0] != '\0' && category_value[0] != ':')
|
||||||
*category_memory++= *category_value++;
|
*category_memory++= *category_value++;
|
||||||
|
|
||||||
category_memory[0]= '\0';
|
category_memory[0]= '\0';
|
||||||
category_memory++;
|
category_memory++;
|
||||||
|
|
||||||
cp = zenity_unalias_lang (cp);
|
cp = zenity_unalias_lang (cp);
|
||||||
|
|
||||||
if (strcmp (cp, "C") == 0)
|
if (strcmp (cp, "C") == 0)
|
||||||
c_locale_defined= TRUE;
|
c_locale_defined= TRUE;
|
||||||
|
|
||||||
list= g_list_concat (list, zenity_compute_locale_variants (cp));
|
list= g_list_concat (list, zenity_compute_locale_variants (cp));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (orig_category_memory);
|
|
||||||
|
|
||||||
if (!c_locale_defined)
|
|
||||||
list= g_list_append (list, "C");
|
|
||||||
|
|
||||||
g_hash_table_insert (category_table, (gpointer) category_name, list);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (orig_category_memory);
|
||||||
|
|
||||||
|
if (!c_locale_defined)
|
||||||
|
list= g_list_append (list, "C");
|
||||||
|
|
||||||
|
g_hash_table_insert (category_table, (gpointer) category_name, list);
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is copied from libgnome/gnome-help.c since we try and avoid using
|
/* This is copied from libgnome/gnome-help.c since we try and avoid using
|
||||||
@ -452,37 +454,37 @@ zenity_i18n_get_language_list (const gchar *category_name)
|
|||||||
static char *
|
static char *
|
||||||
zenity_locate_help_file (const char *path, const char *doc_name)
|
zenity_locate_help_file (const char *path, const char *doc_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL };
|
char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL };
|
||||||
const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES");
|
const GList *lang_list = zenity_i18n_get_language_list ("LC_MESSAGES");
|
||||||
|
|
||||||
for (;lang_list != NULL; lang_list = lang_list->next) {
|
for (;lang_list != NULL; lang_list = lang_list->next) {
|
||||||
const char *lang = lang_list->data;
|
const char *lang = lang_list->data;
|
||||||
|
|
||||||
/* This has to be a valid language AND a language with
|
/* This has to be a valid language AND a language with
|
||||||
* no encoding postfix. The language will come up without
|
* no encoding postfix. The language will come up without
|
||||||
* encoding next
|
* encoding next
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (lang == NULL || (gchar *) strchr (lang, '.') != NULL)
|
if (lang == NULL || (gchar *) strchr (lang, '.') != NULL)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (i = 0; exts[i] != NULL; i++) {
|
for (i = 0; exts[i] != NULL; i++) {
|
||||||
char *name;
|
char *name;
|
||||||
char *full;
|
char *full;
|
||||||
|
|
||||||
name = g_strconcat (doc_name, exts[i], NULL);
|
name = g_strconcat (doc_name, exts[i], NULL);
|
||||||
full = g_build_filename (path, lang, name, NULL);
|
full = g_build_filename (path, lang, name, NULL);
|
||||||
|
|
||||||
if (g_file_test (full, G_FILE_TEST_EXISTS))
|
if (g_file_test (full, G_FILE_TEST_EXISTS))
|
||||||
return full;
|
return full;
|
||||||
|
|
||||||
g_free (full);
|
g_free (full);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This is copied from libgnome/gnome-url.c since we try and avoid using
|
/* This is copied from libgnome/gnome-url.c since we try and avoid using
|
||||||
@ -492,96 +494,81 @@ zenity_locate_help_file (const char *path, const char *doc_name)
|
|||||||
gboolean
|
gboolean
|
||||||
zenity_util_show_help (const gchar *path, const gchar *document, GError **error)
|
zenity_util_show_help (const gchar *path, const gchar *document, GError **error)
|
||||||
{
|
{
|
||||||
GConfClient *client;
|
GConfClient *client;
|
||||||
gint i;
|
gint i;
|
||||||
gchar *pos, *template;
|
gchar *pos, *template;
|
||||||
int argc;
|
int argc;
|
||||||
char **argv;
|
char **argv;
|
||||||
gboolean ret;
|
gboolean ret;
|
||||||
char *url;
|
char *url;
|
||||||
|
|
||||||
g_return_val_if_fail (path != NULL, FALSE);
|
g_return_val_if_fail (path != NULL, FALSE);
|
||||||
g_return_val_if_fail (document != NULL, FALSE);
|
g_return_val_if_fail (document != NULL, FALSE);
|
||||||
|
|
||||||
url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL);
|
url = g_strconcat ("ghelp:///", zenity_locate_help_file (path, document), NULL);
|
||||||
pos = (gchar *) strchr (url, ':');
|
pos = (gchar *) strchr (url, ':');
|
||||||
|
|
||||||
client = gconf_client_get_default ();
|
client = gconf_client_get_default ();
|
||||||
|
|
||||||
if (pos != NULL) {
|
if (pos != NULL) {
|
||||||
gchar *protocol, *path;
|
gchar *protocol, *path;
|
||||||
|
|
||||||
g_return_val_if_fail (pos >= url, FALSE);
|
|
||||||
|
|
||||||
protocol = g_new (gchar, pos - url + 1);
|
g_return_val_if_fail (pos >= url, FALSE);
|
||||||
strncpy (protocol, url, pos - url);
|
|
||||||
protocol[pos - url] = '\0';
|
|
||||||
g_ascii_strdown (protocol, -1);
|
|
||||||
|
|
||||||
path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL);
|
protocol = g_new (gchar, pos - url + 1);
|
||||||
template = gconf_client_get_string (client, path, NULL);
|
strncpy (protocol, url, pos - url);
|
||||||
|
protocol[pos - url] = '\0';
|
||||||
|
g_ascii_strdown (protocol, -1);
|
||||||
|
|
||||||
|
path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL);
|
||||||
|
template = gconf_client_get_string (client, path, NULL);
|
||||||
|
|
||||||
if (template == NULL) {
|
if (template == NULL) {
|
||||||
gchar* template_temp;
|
gchar* template_temp;
|
||||||
|
|
||||||
template_temp = gconf_client_get_string (client,
|
template_temp = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL);
|
||||||
DEFAULT_HANDLER_PATH,
|
|
||||||
NULL);
|
|
||||||
|
|
||||||
/* Retry to get the right url handler */
|
/* Retry to get the right url handler */
|
||||||
template = gconf_client_get_string (client, path, NULL);
|
template = gconf_client_get_string (client, path, NULL);
|
||||||
|
|
||||||
if (template == NULL)
|
if (template == NULL)
|
||||||
template = template_temp;
|
template = template_temp;
|
||||||
else
|
else
|
||||||
g_free (template_temp);
|
g_free (template_temp);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (path);
|
g_free (path);
|
||||||
g_free (protocol);
|
g_free (protocol);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
/* no ':' ? this shouldn't happen. Use default handler */
|
/* no ':' ? this shouldn't happen. Use default handler */
|
||||||
template = gconf_client_get_string (client,
|
template = gconf_client_get_string (client, DEFAULT_HANDLER_PATH, NULL);
|
||||||
DEFAULT_HANDLER_PATH,
|
}
|
||||||
NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (client));
|
g_object_unref (G_OBJECT (client));
|
||||||
|
|
||||||
if (!g_shell_parse_argv (template,
|
if (!g_shell_parse_argv (template, &argc, &argv, error)) {
|
||||||
&argc,
|
g_free (template);
|
||||||
&argv,
|
return FALSE;
|
||||||
error)) {
|
}
|
||||||
g_free (template);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (template);
|
g_free (template);
|
||||||
|
|
||||||
for (i = 0; i < argc; i++) {
|
for (i = 0; i < argc; i++) {
|
||||||
char *arg;
|
char *arg;
|
||||||
|
|
||||||
if (strcmp (argv[i], "%s") != 0)
|
if (strcmp (argv[i], "%s") != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
arg = argv[i];
|
arg = argv[i];
|
||||||
argv[i] = g_strdup (url);
|
argv[i] = g_strdup (url);
|
||||||
g_free (arg);
|
g_free (arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This can return some errors */
|
/* This can return some errors */
|
||||||
ret = g_spawn_async (NULL /* working directory */,
|
ret = g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, error);
|
||||||
argv,
|
g_strfreev (argv);
|
||||||
NULL,
|
|
||||||
G_SPAWN_SEARCH_PATH /* flags */,
|
|
||||||
NULL /* child_setup */,
|
|
||||||
NULL /* data */,
|
|
||||||
NULL /* child_pid */,
|
|
||||||
error);
|
|
||||||
|
|
||||||
g_strfreev (argv);
|
return ret;
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
30
src/util.h
30
src/util.h
@ -6,24 +6,20 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade"
|
#define ZENITY_GLADE_FILE_FULLPATH ZENITY_DATADIR "/zenity.glade"
|
||||||
#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade"
|
#define ZENITY_GLADE_FILE_RELATIVEPATH "./zenity.glade"
|
||||||
#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL))
|
#define ZENITY_IMAGE_FULLPATH(filename) (g_strconcat (ZENITY_DATADIR, "/", filename, NULL))
|
||||||
|
|
||||||
GladeXML* zenity_util_load_glade_file (const gchar *widget_root);
|
GladeXML* zenity_util_load_glade_file (const gchar *widget_root);
|
||||||
|
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
|
||||||
gboolean zenity_util_fill_file_buffer (GtkTextBuffer *buffer,
|
const gchar *filename);
|
||||||
const gchar *filename);
|
void zenity_util_set_window_icon (GtkWidget *widget,
|
||||||
|
const gchar *filename);
|
||||||
void zenity_util_set_window_icon (GtkWidget *widget,
|
void zenity_util_set_window_icon_from_stock (GtkWidget *widget,
|
||||||
const gchar *filename);
|
const gchar *stock_id);
|
||||||
|
gboolean zenity_util_show_help (const gchar *path,
|
||||||
void zenity_util_set_window_icon_from_stock (GtkWidget *widget,
|
const gchar *document,
|
||||||
const gchar *stock_id);
|
GError **error);
|
||||||
|
|
||||||
gboolean zenity_util_show_help (const gchar *path,
|
|
||||||
const gchar *document,
|
|
||||||
GError **error);
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* UTIL_H */
|
#endif /* UTIL_H */
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
<glade-interface>
|
<glade-interface>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_calendar_dialog">
|
<widget class="GtkDialog" id="zenity_calendar_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Calendar selection</property>
|
<property name="title" translatable="yes">Calendar selection</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -148,7 +147,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_warning_dialog">
|
<widget class="GtkDialog" id="zenity_warning_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Warning</property>
|
<property name="title" translatable="yes">Warning</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -259,7 +257,6 @@
|
|||||||
|
|
||||||
<widget class="GtkFileSelection" id="zenity_fileselection_dialog">
|
<widget class="GtkFileSelection" id="zenity_fileselection_dialog">
|
||||||
<property name="border_width">10</property>
|
<property name="border_width">10</property>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Select a file</property>
|
<property name="title" translatable="yes">Select a file</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -290,7 +287,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_question_dialog">
|
<widget class="GtkDialog" id="zenity_question_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Question</property>
|
<property name="title" translatable="yes">Question</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -400,7 +396,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_entry_dialog">
|
<widget class="GtkDialog" id="zenity_entry_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Add a new entry</property>
|
<property name="title" translatable="yes">Add a new entry</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -528,7 +523,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_text_dialog">
|
<widget class="GtkDialog" id="zenity_text_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Text View</property>
|
<property name="title" translatable="yes">Text View</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -623,7 +617,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_progress_dialog">
|
<widget class="GtkDialog" id="zenity_progress_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Progress</property>
|
<property name="title" translatable="yes">Progress</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -745,7 +738,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_error_dialog">
|
<widget class="GtkDialog" id="zenity_error_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Error</property>
|
<property name="title" translatable="yes">Error</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -855,7 +847,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_tree_dialog">
|
<widget class="GtkDialog" id="zenity_tree_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Select items from the list</property>
|
<property name="title" translatable="yes">Select items from the list</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -990,7 +981,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_info_dialog">
|
<widget class="GtkDialog" id="zenity_info_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">Information</property>
|
<property name="title" translatable="yes">Information</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
<property name="window_position">GTK_WIN_POS_CENTER</property>
|
||||||
@ -1100,7 +1090,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget class="GtkDialog" id="zenity_about_dialog">
|
<widget class="GtkDialog" id="zenity_about_dialog">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="title" translatable="yes">About Zenity</property>
|
<property name="title" translatable="yes">About Zenity</property>
|
||||||
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
<property name="type">GTK_WINDOW_TOPLEVEL</property>
|
||||||
<property name="window_position">GTK_WIN_POS_NONE</property>
|
<property name="window_position">GTK_WIN_POS_NONE</property>
|
||||||
@ -1192,7 +1181,7 @@
|
|||||||
<widget class="GtkLabel" id="zenity_about_version">
|
<widget class="GtkLabel" id="zenity_about_version">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="no">zenity_about_version</property>
|
<property name="label" translatable="yes">zenity_about_version</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
||||||
@ -1214,7 +1203,7 @@
|
|||||||
<widget class="GtkLabel" id="zenity_about_description">
|
<widget class="GtkLabel" id="zenity_about_description">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="no">zenity_about_description</property>
|
<property name="label" translatable="yes">zenity_about_description</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
||||||
@ -1236,7 +1225,7 @@
|
|||||||
<widget class="GtkLabel" id="zenity_about_copyright">
|
<widget class="GtkLabel" id="zenity_about_copyright">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<property name="label" translatable="no">zenity_about_copyright</property>
|
<property name="label" translatable="yes">zenity_about_copyright</property>
|
||||||
<property name="use_underline">False</property>
|
<property name="use_underline">False</property>
|
||||||
<property name="use_markup">True</property>
|
<property name="use_markup">True</property>
|
||||||
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
<property name="justify">GTK_JUSTIFY_CENTER</property>
|
||||||
|
92
src/zenity.h
92
src/zenity.h
@ -24,78 +24,78 @@ G_BEGIN_DECLS
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_title;
|
gchar *dialog_title;
|
||||||
gchar *window_icon;
|
gchar *window_icon;
|
||||||
gint exit_code;
|
gint exit_code;
|
||||||
} ZenityData;
|
} ZenityData;
|
||||||
|
|
||||||
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_ERROR,
|
ZENITY_MSG_ERROR,
|
||||||
ZENITY_MSG_INFO
|
ZENITY_MSG_INFO
|
||||||
} MsgMode;
|
} MsgMode;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
MsgMode mode;
|
MsgMode mode;
|
||||||
} ZenityMsgData;
|
} ZenityMsgData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
} ZenityFileData;
|
} ZenityFileData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *entry_text;
|
gchar *entry_text;
|
||||||
gboolean visible;
|
gboolean visible;
|
||||||
} ZenityEntryData;
|
} ZenityEntryData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
gchar *entry_text;
|
gchar *entry_text;
|
||||||
gboolean pulsate;
|
gboolean pulsate;
|
||||||
gdouble percentage;
|
gdouble percentage;
|
||||||
} ZenityProgressData;
|
} ZenityProgressData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *uri;
|
gchar *uri;
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
GtkTextBuffer *buffer;
|
GtkTextBuffer *buffer;
|
||||||
} ZenityTextData;
|
} ZenityTextData;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
gchar *dialog_text;
|
gchar *dialog_text;
|
||||||
GSList *columns;
|
GSList *columns;
|
||||||
gboolean checkbox;
|
gboolean checkbox;
|
||||||
gboolean radiobox;
|
gboolean radiobox;
|
||||||
gchar *separator;
|
gchar *separator;
|
||||||
gboolean editable;
|
gboolean editable;
|
||||||
const gchar **data;
|
const gchar **data;
|
||||||
} ZenityTreeData;
|
} ZenityTreeData;
|
||||||
|
|
||||||
void zenity_calendar (ZenityData *data,
|
void zenity_calendar (ZenityData *data,
|
||||||
ZenityCalendarData *calendar_data);
|
ZenityCalendarData *calendar_data);
|
||||||
void zenity_msg (ZenityData *data,
|
void zenity_msg (ZenityData *data,
|
||||||
ZenityMsgData *msg_data);
|
ZenityMsgData *msg_data);
|
||||||
void zenity_fileselection (ZenityData *data,
|
void zenity_fileselection (ZenityData *data,
|
||||||
ZenityFileData *file_data);
|
ZenityFileData *file_data);
|
||||||
void zenity_entry (ZenityData *data,
|
void zenity_entry (ZenityData *data,
|
||||||
ZenityEntryData *entry_data);
|
ZenityEntryData *entry_data);
|
||||||
void zenity_progress (ZenityData *data,
|
void zenity_progress (ZenityData *data,
|
||||||
ZenityProgressData *progress_data);
|
ZenityProgressData *progress_data);
|
||||||
void zenity_text (ZenityData *data,
|
void zenity_text (ZenityData *data,
|
||||||
ZenityTextData *text_data);
|
ZenityTextData *text_data);
|
||||||
void zenity_tree (ZenityData *data,
|
void zenity_tree (ZenityData *data,
|
||||||
ZenityTreeData *tree_data);
|
ZenityTreeData *tree_data);
|
||||||
void zenity_about (ZenityData *data);
|
void zenity_about (ZenityData *data);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
Reference in New Issue
Block a user