2003-01-03 13:26:04 +00:00
|
|
|
/*
|
|
|
|
* util.c
|
|
|
|
*
|
|
|
|
* Copyright (C) 2002 Sun Microsystems, Inc.
|
2003-01-14 15:35:24 +00:00
|
|
|
* (C) 1999, 2000 Red Hat Inc.
|
|
|
|
* (C) 1998 James Henstridge
|
2003-01-24 16:16:40 +00:00
|
|
|
* (C) 1995-2002 Free Software Foundation
|
2003-01-03 13:26:04 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c, src/entry.c,
2005-04-25 Glynn Foster <glynn.foster@sun.com>
* COPYING, src/about.c, src/calendar.c, src/eggtrayicon.c,
* src/entry.c, src/fileselection.c, src/main.c, src/msg.c,
* src/notification.c, src/option.c, src/progress.c,
* src/text.c, src/tree.c, src/util.c: Update the FSF address
to point to 51 Franklin Street, Fifth Floor as per forwarded
mail from Alvaro Lopez Ortega.
2005-04-25 03:20:45 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2003-01-03 13:26:04 +00:00
|
|
|
*
|
|
|
|
* Authors: Glynn Foster <glynn.foster@sun.com>
|
2003-01-14 15:35:24 +00:00
|
|
|
* Havoc Pennington <hp@redhat.com>
|
|
|
|
* James Henstridge <james@daa.com.au>
|
2003-01-24 16:16:40 +00:00
|
|
|
* Tom Tromey <tromey@redhat.com>
|
2003-01-03 13:26:04 +00:00
|
|
|
*/
|
|
|
|
|
2005-07-06 20:13:11 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2003-01-03 13:26:04 +00:00
|
|
|
#include <stdio.h>
|
2003-01-24 16:16:40 +00:00
|
|
|
#include <locale.h>
|
2003-01-03 13:26:04 +00:00
|
|
|
#include <errno.h>
|
2003-06-04 12:53:46 +00:00
|
|
|
#include <string.h>
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
#include <stdlib.h>
|
2003-01-03 13:26:04 +00:00
|
|
|
#include "config.h"
|
|
|
|
#include "util.h"
|
2003-01-24 16:16:40 +00:00
|
|
|
#include "zenity.h"
|
2003-01-14 15:35:24 +00:00
|
|
|
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#endif
|
|
|
|
|
2003-06-07 14:41:56 +00:00
|
|
|
#define ZENITY_OK_DEFAULT 0
|
|
|
|
#define ZENITY_CANCEL_DEFAULT 1
|
|
|
|
#define ZENITY_ESC_DEFAULT 1
|
|
|
|
#define ZENITY_ERROR_DEFAULT -1
|
|
|
|
#define ZENITY_EXTRA_DEFAULT 127
|
|
|
|
|
2003-01-03 13:26:04 +00:00
|
|
|
GladeXML*
|
|
|
|
zenity_util_load_glade_file (const gchar *widget_root)
|
|
|
|
{
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
GladeXML *xml = NULL;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (g_file_test (ZENITY_GLADE_FILE_RELATIVEPATH, G_FILE_TEST_EXISTS)) {
|
|
|
|
/* Try current dir, for debugging */
|
|
|
|
xml = glade_xml_new (ZENITY_GLADE_FILE_RELATIVEPATH, widget_root, GETTEXT_PACKAGE);
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (xml == NULL)
|
|
|
|
xml = glade_xml_new (ZENITY_GLADE_FILE_FULLPATH, widget_root, GETTEXT_PACKAGE);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (xml == NULL) {
|
|
|
|
g_warning ("Could not load glade file : %s", ZENITY_GLADE_FILE_FULLPATH);
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
return xml;
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
2003-05-05 17:17:02 +00:00
|
|
|
gchar*
|
|
|
|
zenity_util_strip_newline (gchar *string)
|
|
|
|
{
|
|
|
|
gsize len;
|
|
|
|
|
|
|
|
g_return_val_if_fail (string != NULL, NULL);
|
|
|
|
|
|
|
|
len = strlen (string);
|
|
|
|
while (len--)
|
|
|
|
{
|
|
|
|
if (string[len] == '\n')
|
|
|
|
string[len] = '\0';
|
|
|
|
else
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return string;
|
|
|
|
}
|
|
|
|
|
2003-01-03 13:26:04 +00:00
|
|
|
gboolean
|
|
|
|
zenity_util_fill_file_buffer (GtkTextBuffer *buffer, const gchar *filename)
|
|
|
|
{
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
GtkTextIter iter, end;
|
|
|
|
FILE *f;
|
|
|
|
gchar buf[2048];
|
|
|
|
gint remaining = 0;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (filename == NULL)
|
|
|
|
return FALSE;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
f = fopen (filename, "r");
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (f == NULL) {
|
|
|
|
g_warning ("Cannot open file '%s': %s", filename, g_strerror (errno));
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
while (!feof (f)) {
|
|
|
|
gint count;
|
|
|
|
const char *leftover;
|
|
|
|
int to_read = 2047 - remaining;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
count = fread (buf + remaining, 1, to_read, f);
|
|
|
|
buf[count + remaining] = '\0';
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
g_utf8_validate (buf, count + remaining, &leftover);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
g_assert (g_utf8_validate (buf, leftover - buf, NULL));
|
|
|
|
gtk_text_buffer_insert (buffer, &iter, buf, leftover - buf);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
remaining = (buf + remaining + count) - leftover;
|
|
|
|
g_memmove (buf, leftover, remaining);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (remaining > 6 || count < to_read)
|
|
|
|
break;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
if (remaining) {
|
|
|
|
g_warning ("Invalid UTF-8 data encountered reading file '%s'", filename);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
/* We had a newline in the buffer to begin with. (The buffer always contains
|
|
|
|
* a newline, so we delete to the end of the buffer to clean up.
|
|
|
|
*/
|
|
|
|
|
|
|
|
gtk_text_buffer_get_end_iter (buffer, &end);
|
|
|
|
gtk_text_buffer_delete (buffer, &iter, &end);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
gtk_text_buffer_set_modified (buffer, FALSE);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
return TRUE;
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
const gchar *
|
|
|
|
zenity_util_stock_from_filename (const gchar *filename)
|
|
|
|
{
|
|
|
|
if (!filename || !filename[0])
|
|
|
|
return GTK_STOCK_DIALOG_WARNING; /* default */
|
|
|
|
|
|
|
|
if (!g_ascii_strcasecmp (filename, "warning"))
|
|
|
|
return GTK_STOCK_DIALOG_WARNING;
|
|
|
|
if (!g_ascii_strcasecmp (filename, "info"))
|
|
|
|
return GTK_STOCK_DIALOG_INFO;
|
|
|
|
if (!g_ascii_strcasecmp (filename, "question"))
|
|
|
|
return GTK_STOCK_DIALOG_QUESTION;
|
|
|
|
if (!g_ascii_strcasecmp (filename, "error"))
|
|
|
|
return GTK_STOCK_DIALOG_ERROR;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
GdkPixbuf *
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
zenity_util_pixbuf_new_from_file (GtkWidget *widget, const gchar *filename)
|
2003-01-03 13:26:04 +00:00
|
|
|
{
|
src/notification.c (-set_scaled_pixbuf, +zenity_notification_icon_update,
2006-07-27 Lucas Rocha <lucasr@gnome.org>
* src/notification.c (-set_scaled_pixbuf,
+zenity_notification_icon_update,
-zenity_notification_icon_press_callback,
+zenity_notification_icon_size_changed_cb,
-zenity_notification_icon_expose_callback,
-zenity_notification_icon_destroy_callback,
+zenity_notification_icon_activate_cb,
zenity_notification_handle_stdin, zenity_notification),
src/util.[ch] (+zenity_util_stock_from_filename,
zenity_util_pixbuf_new_from_file), Makefile.am, configure.in:
Migration to gtk_status_icon (Fixes bug #341451). Patch from
Christian Persch <chpe@gnome.org>.
* src/eggtrayicon.[ch]: removed.
2006-07-28 21:25:11 +00:00
|
|
|
const gchar *stock;
|
|
|
|
|
|
|
|
stock = zenity_util_stock_from_filename (filename);
|
|
|
|
if (stock)
|
|
|
|
return gtk_widget_render_icon (widget, stock, GTK_ICON_SIZE_BUTTON, NULL);
|
|
|
|
|
|
|
|
return gdk_pixbuf_new_from_file (filename, NULL);
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
zenity_util_set_window_icon (GtkWidget *widget, const gchar *filename, const gchar *default_file)
|
2003-01-03 13:26:04 +00:00
|
|
|
{
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
if (filename != NULL)
|
|
|
|
pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename);
|
|
|
|
else
|
|
|
|
pixbuf = gdk_pixbuf_new_from_file (default_file, NULL);
|
2003-01-03 13:26:04 +00:00
|
|
|
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
if (pixbuf != NULL) {
|
|
|
|
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
zenity_util_set_window_icon_from_stock (GtkWidget *widget, const gchar *filename, const gchar *default_stock_id)
|
2003-01-03 13:26:04 +00:00
|
|
|
{
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
GdkPixbuf *pixbuf;
|
Add new notification icon. Update for new files. Restructure code a little
2004-09-13 Glynn Foster <glynn.foster@sun.com>
* data/Makefile.am, data/zenity-notification.png: Add new
notification icon.
* src/Makefile.am: Update for new files.
* src/about.c, src/calendar.c, src/entry.c, src/fileselection.c,
src/progress.c, src/text.c, src/tree.c, src/msg.c: Restructure code a
little bit for new utility functions for setting window icons.
* src/eggtrayicon.c, src/eggtrayicon.h: New files for notification area
support.
* src/main.c, src/notification.c, src/util.c, src/util.h, src/zenity.h:
Add support for notification area.
* data/zenity.1, help/*: Update docs for notification and new file
selection changes.
2004-09-13 07:51:51 +00:00
|
|
|
|
|
|
|
if (filename != NULL) {
|
|
|
|
pixbuf = zenity_util_pixbuf_new_from_file (widget, (gchar *) filename);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
pixbuf = gtk_widget_render_icon (widget, default_stock_id, GTK_ICON_SIZE_BUTTON, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (pixbuf != NULL) {
|
|
|
|
gtk_window_set_icon (GTK_WINDOW (widget), pixbuf);
|
|
|
|
g_object_unref (pixbuf);
|
|
|
|
}
|
2003-01-03 13:26:04 +00:00
|
|
|
}
|
2003-01-14 15:35:24 +00:00
|
|
|
|
2004-02-29 07:34:28 +00:00
|
|
|
void
|
|
|
|
zenity_util_show_help (GError **error)
|
2003-01-14 15:35:24 +00:00
|
|
|
{
|
2004-02-29 07:34:28 +00:00
|
|
|
gchar *tmp;
|
|
|
|
tmp = g_find_program_in_path ("yelp");
|
2003-01-14 15:35:24 +00:00
|
|
|
|
2004-02-29 07:34:28 +00:00
|
|
|
if (tmp) {
|
|
|
|
g_free (tmp);
|
|
|
|
g_spawn_command_line_async ("yelp ghelp:zenity", error);
|
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.
2003-03-10 17:11:18 +00:00
|
|
|
}
|
2003-01-14 15:35:24 +00:00
|
|
|
}
|
2003-06-07 14:41:56 +00:00
|
|
|
|
|
|
|
gint
|
|
|
|
zenity_util_return_exit_code ( ZenityExitCode value )
|
|
|
|
{
|
|
|
|
|
|
|
|
const gchar *env_var = NULL;
|
|
|
|
gint retval;
|
|
|
|
|
|
|
|
switch (value) {
|
|
|
|
|
|
|
|
case ZENITY_OK:
|
|
|
|
env_var = g_getenv("ZENITY_OK");
|
|
|
|
if (! env_var)
|
|
|
|
env_var = g_getenv("DIALOG_OK");
|
|
|
|
if (! env_var)
|
|
|
|
retval = ZENITY_OK_DEFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZENITY_CANCEL:
|
|
|
|
env_var = g_getenv("ZENITY_CANCEL");
|
|
|
|
if (! env_var)
|
|
|
|
env_var = g_getenv("DIALOG_CANCEL");
|
|
|
|
if (! env_var)
|
|
|
|
retval = ZENITY_CANCEL_DEFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZENITY_ESC:
|
|
|
|
env_var = g_getenv("ZENITY_ESC");
|
|
|
|
if (! env_var)
|
|
|
|
env_var = g_getenv("DIALOG_ESC");
|
|
|
|
if (! env_var)
|
|
|
|
retval = ZENITY_ESC_DEFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZENITY_EXTRA:
|
|
|
|
env_var = g_getenv("ZENITY_EXTRA");
|
|
|
|
if (! env_var)
|
|
|
|
env_var = g_getenv("DIALOG_EXTRA");
|
|
|
|
if (! env_var)
|
|
|
|
retval = ZENITY_EXTRA_DEFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ZENITY_ERROR:
|
|
|
|
env_var = g_getenv("ZENITY_ERROR");
|
|
|
|
if (! env_var)
|
|
|
|
env_var = g_getenv("DIALOG_ERROR");
|
|
|
|
if (! env_var)
|
|
|
|
retval = ZENITY_ERROR_DEFAULT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
retval = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (env_var)
|
|
|
|
retval = atoi (env_var);
|
|
|
|
return retval;
|
|
|
|
}
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
|
|
|
|
static Window
|
2004-09-17 08:57:21 +00:00
|
|
|
transient_get_xterm (void)
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
{
|
|
|
|
const char *wid_str = g_getenv ("WINDOWID");
|
|
|
|
if (wid_str) {
|
|
|
|
char *wid_str_end;
|
|
|
|
Window wid = strtoul (wid_str, &wid_str_end, 10);
|
2004-11-23 10:08:50 +00:00
|
|
|
if (*wid_str != '\0' && *wid_str_end == '\0' && wid != 0) {
|
|
|
|
XWindowAttributes attrs;
|
|
|
|
gdk_error_trap_push ();
|
|
|
|
XGetWindowAttributes (GDK_DISPLAY(), wid, &attrs);
|
|
|
|
gdk_flush();
|
|
|
|
if (gdk_error_trap_pop () != 0) {
|
|
|
|
return None;
|
|
|
|
}
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
return wid;
|
2004-11-23 10:08:50 +00:00
|
|
|
}
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
}
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
transient_x_free (void *ptr)
|
|
|
|
{
|
|
|
|
if (ptr)
|
|
|
|
XFree (ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
transient_is_toplevel (Window wid)
|
|
|
|
{
|
|
|
|
XTextProperty prop;
|
|
|
|
Display *dpy = GDK_DISPLAY ();
|
|
|
|
if (!XGetWMName (dpy, wid, &prop))
|
|
|
|
return FALSE;
|
|
|
|
transient_x_free (prop.value);
|
|
|
|
return !!prop.value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GNOME Terminal doesn't give us its toplevel window, but the WM needs a
|
|
|
|
* toplevel XID for proper stacking. Other terminals work fine without this
|
|
|
|
* magic. We can't use GDK here since "xterm" is a foreign window.
|
|
|
|
*/
|
|
|
|
|
|
|
|
static Window
|
2004-09-17 08:57:21 +00:00
|
|
|
transient_get_xterm_toplevel (void)
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
{
|
|
|
|
Window xterm = transient_get_xterm ();
|
|
|
|
Display *dpy = GDK_DISPLAY ();
|
|
|
|
while (xterm != None && !transient_is_toplevel (xterm))
|
|
|
|
{
|
|
|
|
Window root, parent, *children;
|
2005-07-08 23:21:34 +00:00
|
|
|
unsigned nchildren;
|
Add from the 2 Sebastian's, and make email addresses more spam proof.
2004-04-26 Glynn Foster <glynn.foster@sun.com>
* THANKS, src/about.c: Add from the 2 Sebastian's, and make
email addresses more spam proof.
* src/calendar.c, src/entry.c, src/fileselection.c, src/msg.c,
* src/progress.c, src/text.c, src/tree.c, src/util.c,
* src/util.h: Patch from Sebastian Kapfer to make all zenity
dialogs transients of the parent xterm. Fixes #136226.
* src/zenity.glade: Patch from Sebastian Heinlein to
improve things HIG wise. Fixes #140745.
2004-04-26 04:41:25 +00:00
|
|
|
XQueryTree (dpy, xterm,
|
|
|
|
&root, &parent,
|
|
|
|
&children, &nchildren);
|
|
|
|
transient_x_free (children);
|
|
|
|
if (parent == root)
|
|
|
|
xterm = None;
|
|
|
|
else
|
|
|
|
xterm = parent;
|
|
|
|
}
|
|
|
|
return xterm;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
zenity_util_make_transient (GdkWindow *window)
|
|
|
|
{
|
|
|
|
Window xterm = transient_get_xterm_toplevel ();
|
|
|
|
if (xterm != None) {
|
|
|
|
GdkWindow *gdkxterm = gdk_window_foreign_new (xterm);
|
|
|
|
if (gdkxterm) {
|
|
|
|
gdk_window_set_transient_for (window, gdkxterm);
|
|
|
|
g_object_unref (G_OBJECT (gdkxterm));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* GDK_WINDOWING_X11 */
|
|
|
|
|
|
|
|
void
|
|
|
|
zenity_util_show_dialog (GtkWidget *dialog)
|
|
|
|
{
|
|
|
|
gtk_widget_realize (dialog);
|
|
|
|
#ifdef GDK_WINDOWING_X11
|
|
|
|
g_assert (dialog->window);
|
|
|
|
zenity_util_make_transient (dialog->window);
|
|
|
|
#endif
|
|
|
|
gtk_widget_show (dialog);
|
|
|
|
}
|
|
|
|
|