[Xfce4-commits] r30214 - in libxfce4ui/trunk: . docs docs/tmpl libxfce4ui
Nick Schermer
nick at xfce.org
Tue Jul 7 17:06:19 CEST 2009
Author: nick
Date: 2009-07-07 15:06:18 +0000 (Tue, 07 Jul 2009)
New Revision: 30214
Added:
libxfce4ui/trunk/docs/tmpl/xfce-spawn.sgml
libxfce4ui/trunk/libxfce4ui/xfce-spawn.c
libxfce4ui/trunk/libxfce4ui/xfce-spawn.h
Removed:
libxfce4ui/trunk/docs/tmpl/xfce-execute.sgml
libxfce4ui/trunk/libxfce4ui/xfce-execute.c
libxfce4ui/trunk/libxfce4ui/xfce-execute.h
Modified:
libxfce4ui/trunk/configure.in.in
libxfce4ui/trunk/docs/libxfce4ui-docs.sgml
libxfce4ui/trunk/docs/libxfce4ui-sections.txt
libxfce4ui/trunk/docs/tmpl/xfce-dialogs.sgml
libxfce4ui/trunk/docs/tmpl/xfce-gdk-extensions.sgml
libxfce4ui/trunk/docs/tmpl/xfce-gtk-extensions.sgml
libxfce4ui/trunk/libxfce4ui/Makefile.am
libxfce4ui/trunk/libxfce4ui/libxfce4ui-private.h
libxfce4ui/trunk/libxfce4ui/libxfce4ui.h
libxfce4ui/trunk/libxfce4ui/libxfce4ui.symbols
libxfce4ui/trunk/libxfce4ui/xfce-dialogs.c
libxfce4ui/trunk/libxfce4ui/xfce-dialogs.h
libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.c
libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.h
libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.c
libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.h
libxfce4ui/trunk/libxfce4ui/xfce-heading.c
libxfce4ui/trunk/libxfce4ui/xfce-titled-dialog.c
Log:
API changes requested by Brian.
Rename xfce_execute to xfce_spawn. I've also renamed both
functions to match Glib/Gdk.
Remove xfce_gdk_pixbuf_new_from_inline_at_size and
xfce_gtk_dialog_parse_parent.
Use GtkWindows's for the parents of the dialogs.
Add support for secondary text in the info, warnings
and questions dialog functions.
Rename the internal function xfce_message_dialog_vnew to
xfce_message_dialog_new_valist.
Modified: libxfce4ui/trunk/configure.in.in
===================================================================
--- libxfce4ui/trunk/configure.in.in 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/configure.in.in 2009-07-07 15:06:18 UTC (rev 30214)
@@ -9,7 +9,7 @@
m4_define([libxfce4ui_verinfo], [0:0:0])
m4_define([libxfce4ui_version_api], [1])
m4_define([libxfce4ui_version_major], [4])
-m4_define([libxfce4ui_version_minor], [5])
+m4_define([libxfce4ui_version_minor], [7])
m4_define([libxfce4ui_version_micro], [0])
m4_define([libxfce4ui_version_build], [r at REVISION@])
m4_define([libxfce4ui_version_tag], [svn])
@@ -102,9 +102,9 @@
dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
-XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.12.0])
-XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.10.0])
-XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([GOBJECT], [gobject-2.0], [2.16.0])
+XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.14.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.6.0])
dnl *************************************************
dnl *** Optional support for startup notification ***
Modified: libxfce4ui/trunk/docs/libxfce4ui-docs.sgml
===================================================================
--- libxfce4ui/trunk/docs/libxfce4ui-docs.sgml 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/docs/libxfce4ui-docs.sgml 2009-07-07 15:06:18 UTC (rev 30214)
@@ -2,7 +2,7 @@
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd"[
<!ENTITY libxfce4ui-config SYSTEM "xml/libxfce4ui-config.xml">
-<!ENTITY xfce-execute SYSTEM "xml/xfce-execute.xml">
+<!ENTITY xfce-spawn SYSTEM "xml/xfce-spawn.xml">
<!ENTITY xfce-gdk-extensions SYSTEM "xml/xfce-gdk-extensions.xml">
<!ENTITY xfce-gtk-extensions SYSTEM "xml/xfce-gtk-extensions.xml">
<!ENTITY xfce-dialogs SYSTEM "xml/xfce-dialogs.xml">
@@ -19,7 +19,7 @@
<pubdate>&date;</pubdate>
<copyright>
- <year>2007</year>
+ <year>2009</year>
<holder>The Xfce Development Team</holder>
</copyright>
@@ -56,7 +56,7 @@
<part id="libxfce4ui-fundamentals">
<title>Xfce Fundamentals</title>
&libxfce4ui-config;
- &xfce-execute;
+ &xfce-spawn;
</part>
<part id="libxfce4ui-extensions">
Modified: libxfce4ui/trunk/docs/libxfce4ui-sections.txt
===================================================================
--- libxfce4ui/trunk/docs/libxfce4ui-sections.txt 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/docs/libxfce4ui-sections.txt 2009-07-07 15:06:18 UTC (rev 30214)
@@ -14,14 +14,13 @@
</SECTION>
<SECTION>
-<FILE>xfce-execute</FILE>
-xfce_execute_argv_on_screen
-xfce_execute_on_screen
+<FILE>xfce-spawn</FILE>
+xfce_spawn_on_screen
+xfce_spawn_command_line_on_screen
</SECTION>
<SECTION>
<FILE>xfce-gdk-extensions</FILE>
-xfce_gdk_pixbuf_new_from_inline_at_size G_GNUC_MALLOC
xfce_gdk_screen_get_active
</SECTION>
@@ -31,7 +30,6 @@
xfce_gtk_label_new_with_style
xfce_gtk_frame_box_new
xfce_gtk_frame_box_new_with_content
-xfce_gtk_dialog_parse_parent
xfce_gtk_window_center_on_active_screen
<SUBSECTION>
xfce_gtk_label_new_big_bold
@@ -43,7 +41,7 @@
<SECTION>
<FILE>xfce-dialogs</FILE>
xfce_message_dialog_new
-xfce_message_dialog_run
+xfce_message_dialog
xfce_dialog_show_info
xfce_dialog_show_warning
xfce_dialog_show_error
Modified: libxfce4ui/trunk/docs/tmpl/xfce-dialogs.sgml
===================================================================
--- libxfce4ui/trunk/docs/tmpl/xfce-dialogs.sgml 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/docs/tmpl/xfce-dialogs.sgml 2009-07-07 15:06:18 UTC (rev 30214)
@@ -33,7 +33,7 @@
@Returns:
-<!-- ##### FUNCTION xfce_message_dialog_run ##### -->
+<!-- ##### FUNCTION xfce_message_dialog ##### -->
<para>
</para>
@@ -54,7 +54,8 @@
</para>
@parent:
- at format:
+ at secondary_text:
+ at primary_format:
@Varargs:
@@ -64,7 +65,8 @@
</para>
@parent:
- at format:
+ at secondary_text:
+ at primary_format:
@Varargs:
@@ -75,7 +77,7 @@
@parent:
@error:
- at format:
+ at primary_format:
@Varargs:
@@ -87,7 +89,8 @@
@parent:
@stock_id:
@confirm_label:
- at format:
+ at secondary_text:
+ at primary_format:
@Varargs:
@Returns:
Modified: libxfce4ui/trunk/docs/tmpl/xfce-gdk-extensions.sgml
===================================================================
--- libxfce4ui/trunk/docs/tmpl/xfce-gdk-extensions.sgml 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/docs/tmpl/xfce-gdk-extensions.sgml 2009-07-07 15:06:18 UTC (rev 30214)
@@ -19,22 +19,12 @@
<!-- ##### SECTION Stability_Level ##### -->
-<!-- ##### FUNCTION xfce_gdk_pixbuf_new_from_inline_at_size ##### -->
-<para>
-
-</para>
-
- at data:
- at width:
- at height:
- at Returns:
-
-
<!-- ##### FUNCTION xfce_gdk_screen_get_active ##### -->
<para>
</para>
+ at monitor_return:
@Returns:
Modified: libxfce4ui/trunk/docs/tmpl/xfce-gtk-extensions.sgml
===================================================================
--- libxfce4ui/trunk/docs/tmpl/xfce-gtk-extensions.sgml 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/docs/tmpl/xfce-gtk-extensions.sgml 2009-07-07 15:06:18 UTC (rev 30214)
@@ -30,19 +30,6 @@
@Returns:
-<!-- ##### FUNCTION xfce_gtk_label_new_with_style ##### -->
-<para>
-
-</para>
-
- at label:
- at scale_factor:
- at style:
- at weight:
- at underline:
- at Returns:
-
-
<!-- ##### FUNCTION xfce_gtk_frame_box_new ##### -->
<para>
@@ -63,16 +50,6 @@
@Returns:
-<!-- ##### FUNCTION xfce_gtk_dialog_parse_parent ##### -->
-<para>
-
-</para>
-
- at parent:
- at window_return:
- at Returns:
-
-
<!-- ##### FUNCTION xfce_gtk_window_center_on_active_screen ##### -->
<para>
@@ -81,39 +58,3 @@
@window:
-<!-- ##### MACRO xfce_gtk_label_new_big_bold ##### -->
-<para>
-Convenient macro for xfce_gtk_label_new_with_style(). It returns a
-large bold #GtkLabel.
-</para>
-
- at label: the text of the label.
-
-
-<!-- ##### MACRO xfce_gtk_label_new_bold ##### -->
-<para>
-Convenient macro for xfce_gtk_label_new_with_style(). It returns a
-bold #GtkLabel.
-</para>
-
- at label: the text of the label.
-
-
-<!-- ##### MACRO xfce_gtk_label_new_italic ##### -->
-<para>
-Convenient macro for xfce_gtk_label_new_with_style(). It returns an
-italic #GtkLabel.
-</para>
-
- at label: the text of the label.
-
-
-<!-- ##### MACRO xfce_gtk_label_new_small_italic ##### -->
-<para>
-Convenient macro for xfce_gtk_label_new_with_style(). It returns a
-small italic #GtkLabel.
-</para>
-
- at label: the text of the label.
-
-
Added: libxfce4ui/trunk/docs/tmpl/xfce-spawn.sgml
===================================================================
--- libxfce4ui/trunk/docs/tmpl/xfce-spawn.sgml (rev 0)
+++ libxfce4ui/trunk/docs/tmpl/xfce-spawn.sgml 2009-07-07 15:06:18 UTC (rev 30214)
@@ -0,0 +1,50 @@
+<!-- ##### SECTION Title ##### -->
+Xfce Spawn
+
+<!-- ##### SECTION Short_Description ##### -->
+Functions to spawn a command with startup notification support.
+
+<!-- ##### SECTION Long_Description ##### -->
+<para>
+On a desktop it is important that applications are execute with
+startup notification and they show up on the correct screen and workspace.
+</para>
+
+<!-- ##### SECTION See_Also ##### -->
+<para>
+
+</para>
+
+<!-- ##### SECTION Stability_Level ##### -->
+
+
+<!-- ##### FUNCTION xfce_spawn_on_screen ##### -->
+<para>
+
+</para>
+
+ at screen:
+ at working_directory:
+ at argv:
+ at envp:
+ at flags:
+ at startup_notify:
+ at startup_timestamp:
+ at icon_name:
+ at error:
+ at Returns:
+
+
+<!-- ##### FUNCTION xfce_spawn_command_line_on_screen ##### -->
+<para>
+
+</para>
+
+ at screen:
+ at command_line:
+ at in_terminal:
+ at startup_notify:
+ at error:
+ at Returns:
+
+
Modified: libxfce4ui/trunk/libxfce4ui/Makefile.am
===================================================================
--- libxfce4ui/trunk/libxfce4ui/Makefile.am 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/Makefile.am 2009-07-07 15:06:18 UTC (rev 30214)
@@ -9,18 +9,15 @@
-DLIBEXECDIR=\"$(libexecdir)\" \
-DLIBXFCE4UI_VERSION_API=\"$(LIBXFCE4UI_VERSION_API)\" \
-DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
- -DG_DISABLE_DEPRECATED \
- -DGTK_DISABLE_DEPRECATED \
- -DGDK_DISABLE_DEPRECATED \
$(PLATFORM_CPPFLAGS)
lib_LTLIBRARIES = libxfce4ui-1.la
libxfce4ui_headers = \
- xfce-execute.h \
xfce-dialogs.h \
xfce-gdk-extensions.h \
xfce-gtk-extensions.h \
+ xfce-spawn.h \
xfce-titled-dialog.h
libxfce4ui_built_sources = \
@@ -40,12 +37,12 @@
$(libxfce4ui_built_sources) \
libxfce4ui-config.c \
libxfce4ui-private.h \
- xfce-execute.c \
xfce-dialogs.c \
xfce-gdk-extensions.c \
xfce-gtk-extensions.c \
xfce-heading.c \
xfce-heading.h \
+ xfce-spawn.c \
xfce-titled-dialog.c
libxfce4ui_1_la_CFLAGS = \
Modified: libxfce4ui/trunk/libxfce4ui/libxfce4ui-private.h
===================================================================
--- libxfce4ui/trunk/libxfce4ui/libxfce4ui-private.h 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/libxfce4ui-private.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -29,45 +29,9 @@
G_BEGIN_DECLS
-/* avoid copying name, nick and blurb */
-#define LIBXFCE4UI_PARAM_READABLE (G_PARAM_READABLE \
- | G_PARAM_STATIC_NAME \
- | G_PARAM_STATIC_NICK \
- | G_PARAM_STATIC_BLURB)
-#define LIBXFCE4UI_PARAM_WRITABLE (G_PARAM_WRITABLE \
- | G_PARAM_STATIC_NAME \
- | G_PARAM_STATIC_NICK \
- | G_PARAM_STATIC_BLURB)
-#define LIBXFCE4UI_PARAM_READWRITE (G_PARAM_READWRITE \
- | G_PARAM_STATIC_NAME \
- | G_PARAM_STATIC_NICK \
- | G_PARAM_STATIC_BLURB)
-
/* support for canonical representations of strings */
#define I_(string) (g_intern_static_string ((string)))
-/* avoid trivial g_value_get_*() function calls */
-#ifdef NDEBUG
-#define g_value_get_boolean(v) (((const GValue *) (v))->data[0].v_int)
-#define g_value_get_char(v) (((const GValue *) (v))->data[0].v_int)
-#define g_value_get_uchar(v) (((const GValue *) (v))->data[0].v_uint)
-#define g_value_get_int(v) (((const GValue *) (v))->data[0].v_int)
-#define g_value_get_uint(v) (((const GValue *) (v))->data[0].v_uint)
-#define g_value_get_long(v) (((const GValue *) (v))->data[0].v_long)
-#define g_value_get_ulong(v) (((const GValue *) (v))->data[0].v_ulong)
-#define g_value_get_int64(v) (((const GValue *) (v))->data[0].v_int64)
-#define g_value_get_uint64(v) (((const GValue *) (v))->data[0].v_uint64)
-#define g_value_get_enum(v) (((const GValue *) (v))->data[0].v_long)
-#define g_value_get_flags(v) (((const GValue *) (v))->data[0].v_ulong)
-#define g_value_get_float(v) (((const GValue *) (v))->data[0].v_float)
-#define g_value_get_double(v) (((const GValue *) (v))->data[0].v_double)
-#define g_value_get_string(v) (((const GValue *) (v))->data[0].v_pointer)
-#define g_value_get_param(v) (((const GValue *) (v))->data[0].v_pointer)
-#define g_value_get_boxed(v) (((const GValue *) (v))->data[0].v_pointer)
-#define g_value_get_pointer(v) (((const GValue *) (v))->data[0].v_pointer)
-#define g_value_get_object(v) (((const GValue *) (v))->data[0].v_pointer)
-#endif
-
G_END_DECLS
#endif /* !__LIBXFCE4UI_PRIVATE_H__ */
Modified: libxfce4ui/trunk/libxfce4ui/libxfce4ui.h
===================================================================
--- libxfce4ui/trunk/libxfce4ui/libxfce4ui.h 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/libxfce4ui.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -24,10 +24,10 @@
#define LIBXFCE4UI_INSIDE_LIBXFCE4UI_H
#include <libxfce4ui/libxfce4ui-config.h>
-#include <libxfce4ui/xfce-execute.h>
#include <libxfce4ui/xfce-dialogs.h>
#include <libxfce4ui/xfce-gdk-extensions.h>
#include <libxfce4ui/xfce-gtk-extensions.h>
+#include <libxfce4ui/xfce-spawn.h>
#include <libxfce4ui/xfce-titled-dialog.h>
#undef LIBXFCE4UI_INSIDE_LIBXFCE4UI_H
Modified: libxfce4ui/trunk/libxfce4ui/libxfce4ui.symbols
===================================================================
--- libxfce4ui/trunk/libxfce4ui/libxfce4ui.symbols 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/libxfce4ui.symbols 2009-07-07 15:06:18 UTC (rev 30214)
@@ -49,27 +49,18 @@
/* xfce-dialogs functions */
#if IN_HEADER(__XFCE_DIALOGS_H__)
#if IN_SOURCE(__XFCE_DIALOGS_C__)
-xfce_dialog_show_info G_GNUC_PRINTF (2, 3)
-xfce_dialog_show_warning G_GNUC_PRINTF (2, 3)
+xfce_dialog_show_info G_GNUC_PRINTF (3, 4)
+xfce_dialog_show_warning G_GNUC_PRINTF (3, 4)
xfce_dialog_show_error G_GNUC_PRINTF (3, 4)
-xfce_dialog_confirm G_GNUC_PRINTF (4, 5)
-xfce_message_dialog_new G_GNUC_NULL_TERMINATED
-xfce_message_dialog_run G_GNUC_NULL_TERMINATED
+xfce_dialog_confirm G_GNUC_PRINTF (5, 6)
+xfce_message_dialog_new G_GNUC_NULL_TERMINATED G_GNUC_MALLOC
+xfce_message_dialog G_GNUC_NULL_TERMINATED
#endif
#endif
-/* xfce-execute functions */
-#if IN_HEADER(__XFCE_EXECUTE_H__)
-#if IN_SOURCE(__XFCE_EXECUTE_C__)
-xfce_execute_argv_on_screen
-xfce_execute_on_screen
-#endif
-#endif
-
/* xfce-gdk-extensions functions */
#if IN_HEADER(__XFCE_GDK_EXTENSIONS_H__)
#if IN_SOURCE(__XFCE_GDK_EXTENSIONS_C__)
-xfce_gdk_pixbuf_new_from_inline_at_size G_GNUC_MALLOC
xfce_gdk_screen_get_active
#endif
#endif
@@ -80,11 +71,18 @@
xfce_gtk_button_new_mixed G_GNUC_MALLOC
xfce_gtk_frame_box_new G_GNUC_MALLOC
xfce_gtk_frame_box_new_with_content G_GNUC_MALLOC
-xfce_gtk_dialog_parse_parent
xfce_gtk_window_center_on_active_screen
#endif
#endif
+/* xfce-spawn functions */
+#if IN_HEADER(__XFCE_SPAWN_H__)
+#if IN_SOURCE(__XFCE_SPAWN_C__)
+xfce_spawn_on_screen
+xfce_spawn_command_line_on_screen
+#endif
+#endif
+
/* xfce-titled-dialog functions */
#if IN_HEADER(__XFCE_TITLED_DIALOG_H__)
#if IN_SOURCE(__XFCE_TITLED_DIALOG_C__)
Modified: libxfce4ui/trunk/libxfce4ui/xfce-dialogs.c
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-dialogs.c 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-dialogs.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -43,17 +43,15 @@
static GtkWidget *
-xfce_message_dialog_vnew (gpointer parent,
- const gchar *title,
- const gchar *icon_stock_id,
- const gchar *primary_text,
- const gchar *secondary_text,
- const gchar *first_button_type,
- va_list args)
+xfce_message_dialog_new_valist (GtkWindow *parent,
+ const gchar *title,
+ const gchar *icon_stock_id,
+ const gchar *primary_text,
+ const gchar *secondary_text,
+ const gchar *first_button_type,
+ va_list args)
{
GtkWidget *dialog;
- GtkWindow *window;
- GdkScreen *screen;
GtkWidget *image;
GtkWidget *button;
const gchar *text = first_button_type;
@@ -64,20 +62,18 @@
gint w, h;
g_return_val_if_fail (primary_text != NULL || secondary_text != NULL, NULL);
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
- /* parse the parent pointer */
- screen = xfce_gtk_dialog_parse_parent (parent, &window);
-
/* create the dialog */
if (G_LIKELY (primary_text != NULL))
{
/* create dialog with large bold text */
- dialog = gtk_message_dialog_new_with_markup (window,
+ dialog = gtk_message_dialog_new_with_markup (parent,
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_OTHER, GTK_BUTTONS_NONE,
- "<span weight='bold' size='large'>%s</span>",
+ "<span weight='bold' size='large'>%s</span>",
primary_text);
-
+
/* set secondary text */
if (secondary_text != NULL)
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", secondary_text);
@@ -85,19 +81,12 @@
else
{
/* create dialog with normal seconday text */
- dialog = gtk_message_dialog_new (window,
+ dialog = gtk_message_dialog_new (parent,
GTK_DIALOG_DESTROY_WITH_PARENT | GTK_DIALOG_MODAL,
GTK_MESSAGE_OTHER, GTK_BUTTONS_NONE,
"%s", secondary_text);
}
- /* move the dialog to the appropriate screen and center it */
- if (G_UNLIKELY (window == NULL && screen != NULL))
- {
- gtk_window_set_screen (GTK_WINDOW (dialog), screen);
- gtk_window_set_position (GTK_WINDOW (dialog), GTK_WIN_POS_CENTER);
- }
-
/* set title */
if (title != NULL)
gtk_window_set_title (GTK_WINDOW (dialog), title);
@@ -176,32 +165,33 @@
/**
* xfce_dialog_show_info:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
- * @format : the printf()-style format for the primary problem description.
- * @... : argument list for the @format.
+ * @parent : transient parent of the dialog, or %NULL.
+ * @secondary_text : secondary text of the dialog or %NULL.
+ * @primary_format : the printf()-style format for the primary problem description.
+ * @... : argument list for the @format.
*
- * Displays an information dialog on @parent using the @format as message.
- *
- * If @widget is not %NULL and @widget is part of a #GtkWindow, the function makes sure
- * that the toplevel window is visible prior to displaying the information dialog.
+ * Displays an information dialog on @parent using the @primary_format as message.
*/
void
-xfce_dialog_show_info (gpointer parent,
- const gchar *format,
+xfce_dialog_show_info (GtkWindow *parent,
+ const gchar *secondary_text,
+ const gchar *primary_format,
...)
{
va_list args;
gchar *primary_text;
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
/* create primary text */
- va_start (args, format);
- primary_text = g_strdup_vprintf (format, args);
+ va_start (args, primary_format);
+ primary_text = g_strdup_vprintf (primary_format, args);
va_end (args);
/* run dialog */
- xfce_message_dialog_run (parent, _("Information"), GTK_STOCK_DIALOG_INFO,
- primary_text, NULL,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ xfce_message_dialog (parent, _("Information"), GTK_STOCK_DIALOG_INFO,
+ primary_text, secondary_text,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
/* cleanup */
g_free (primary_text);
@@ -211,32 +201,33 @@
/**
* xfce_dialog_show_warning:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
- * @format : the printf()-style format for the primary problem description.
- * @... : argument list for the @format.
+ * @parent : transient parent of the dialog, or %NULL.
+ * @secondary_text : secondary text of the dialog or %NULL.
+ * @primary_format : the printf()-style format for the primary problem description.
+ * @... : argument list for the @format.
*
- * Displays a warning dialog on @parent using the @format as message.
- *
- * If @widget is not %NULL and @widget is part of a #GtkWindow, the function makes sure
- * that the toplevel window is visible prior to displaying the message dialog.
+ * Displays a warning dialog on @parent using the @primary_format as message.
*/
void
-xfce_dialog_show_warning (gpointer parent,
- const gchar *format,
+xfce_dialog_show_warning (GtkWindow *parent,
+ const gchar *secondary_text,
+ const gchar *primary_format,
...)
{
va_list args;
gchar *primary_text;
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
/* create primary text */
- va_start (args, format);
- primary_text = g_strdup_vprintf (format, args);
+ va_start (args, primary_format);
+ primary_text = g_strdup_vprintf (primary_format, args);
va_end (args);
/* run dialog */
- xfce_message_dialog_run (parent, _("Warning"), GTK_STOCK_DIALOG_WARNING,
- primary_text, NULL,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ xfce_message_dialog (parent, _("Warning"), GTK_STOCK_DIALOG_WARNING,
+ primary_text, secondary_text,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
/* cleanup */
g_free (primary_text);
@@ -246,35 +237,34 @@
/**
* xfce_dialog_show_error:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
- * @error : a #GError, which gives a more precise description of the problem or %NULL.
- * @format : the printf()-style format for the primary problem description.
- * @... : argument list for the @format.
+ * @parent : transient parent of the dialog, or %NULL.
+ * @error : a #GError, which gives a more precise description of the problem or %NULL.
+ * @primary_format : the printf()-style format for the primary problem description.
+ * @... : argument list for the @primary_format.
*
- * Displays an error dialog on @parent using the @format as primary message and optionally
+ * Displays an error dialog on @parent using the @primary_format as primary message and optionally
* displaying @error as secondary error text.
- *
- * If @parent is not %NULL and @parent is part of a #GtkWindow, the function makes sure
- * that the toplevel window is visible prior to displaying the error dialog.
*/
void
-xfce_dialog_show_error (gpointer parent,
+xfce_dialog_show_error (GtkWindow *parent,
const GError *error,
- const gchar *format,
+ const gchar *primary_format,
...)
{
va_list args;
gchar *primary_text;
+ g_return_if_fail (parent == NULL || GTK_IS_WINDOW (parent));
+
/* create primary text */
- va_start (args, format);
- primary_text = g_strdup_vprintf (format, args);
+ va_start (args, primary_format);
+ primary_text = g_strdup_vprintf (primary_format, args);
va_end (args);
/* run dialog */
- xfce_message_dialog_run (parent, _("Error"), GTK_STOCK_DIALOG_ERROR,
- primary_text, error ? error->message : NULL,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
+ xfce_message_dialog (parent, _("Error"), GTK_STOCK_DIALOG_ERROR,
+ primary_text, error ? error->message : NULL,
+ GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
/* cleanup */
g_free (primary_text);
@@ -284,11 +274,11 @@
/**
* xfce_dialog_confirm:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
- * @stock_id : the stock name of the confirm button, for example #GTK_STOCK_YES or #GTK_STOCK_CLEAR.
- * @confirm_label : if non-%NULL, this text is used on the confirm button together with the @stock_id icon.
- * @format : the printf()-style format for the dialog question.
- * @... : argument list for the @format.
+ * @parent : transient parent of the dialog, or %NULL.
+ * @stock_id : the stock name of the confirm button, for example #GTK_STOCK_YES or #GTK_STOCK_CLEAR.
+ * @confirm_label : if non-%NULL, this text is used on the confirm button together with the @stock_id icon.
+ * @primary_format : the printf()-style format for the dialog question.
+ * @... : argument list for the @primary_format.
*
* Runs a questions dialog, that has a 'Cancel' and a 'Confirm' button. The 'Confirm'
* button text can be set by @action if given.
@@ -298,10 +288,11 @@
* Return value: TRUE if the user confirms, else FALSE.
*/
gboolean
-xfce_dialog_confirm (gpointer parent,
+xfce_dialog_confirm (GtkWindow *parent,
const gchar *stock_id,
const gchar *confirm_label,
- const gchar *format,
+ const gchar *secondary_text,
+ const gchar *primary_format,
...)
{
va_list args;
@@ -310,10 +301,11 @@
gint response_id;
g_return_val_if_fail (stock_id != NULL || confirm_label != NULL, FALSE);
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), FALSE);
/* create primary text */
- va_start (args, format);
- primary_text = g_strdup_vprintf (format, args);
+ va_start (args, primary_format);
+ primary_text = g_strdup_vprintf (primary_format, args);
va_end (args);
/* whether this will be a yes/no dialog */
@@ -323,10 +315,12 @@
no_stock_id = GTK_STOCK_CANCEL;
/* run dialog */
- response_id = xfce_message_dialog_run (parent, _("Question"), GTK_STOCK_DIALOG_QUESTION,
- primary_text, NULL,
- no_stock_id, GTK_RESPONSE_NO,
- XFCE_BUTTON_TYPE_MIXED, stock_id, confirm_label, GTK_RESPONSE_YES, NULL);
+ response_id = xfce_message_dialog (parent, _("Question"),
+ GTK_STOCK_DIALOG_QUESTION,
+ primary_text, secondary_text,
+ no_stock_id, GTK_RESPONSE_NO,
+ XFCE_BUTTON_TYPE_MIXED, stock_id,
+ confirm_label, GTK_RESPONSE_YES, NULL);
/* cleanup */
g_free (primary_text);
@@ -338,13 +332,13 @@
/**
* xfce_message_dialog_new:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
+ * @parent : transient parent of the dialog, or %NULL.
* @title : title of the dialog, or %NULL.
* @stock_id : gtk stock icon name to show in the dialog.
* @primary_text : primary text shown in large bold font.
* @secondary_text : secondary text shown in normal font.
* @first_button_text : text for the first button.
- * @... : %NULL ended list of parameters.
+ * @... : %NULL terminated list of parameters.
*
* xfce_message_dialog_new() allows you to easily create Gtk+ message dialogs.
* It accepts GTK+ stock buttons, mixed buttons (using XFCE_BUTTON_TYPE_MIXED)
@@ -411,7 +405,7 @@
* Return value: A new #GtkMessageDialog.
**/
GtkWidget *
-xfce_message_dialog_new (gpointer parent,
+xfce_message_dialog_new (GtkWindow *parent,
const gchar *title,
const gchar *stock_id,
const gchar *primary_text,
@@ -422,9 +416,12 @@
va_list args;
GtkWidget *dialog;
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL);
+
/* create dialog */
va_start (args, first_button_text);
- dialog = xfce_message_dialog_vnew (parent, title, stock_id, primary_text, secondary_text, first_button_text, args);
+ dialog = xfce_message_dialog_new_valist (parent, title, stock_id, primary_text,
+ secondary_text, first_button_text, args);
va_end (args);
return dialog;
@@ -433,8 +430,8 @@
/**
- * xfce_message_dialog_run:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL, see xfce_gtk_dialog_parse_parent() for more information.
+ * xfce_message_dialog:
+ * @parent : transient parent of the dialog, or %NULL.
* @title : title of the dialog, or %NULL.
* @stock_id : gtk stock icon name to show in the dialog.
* @primary_text : primary text shown in large bold font.
@@ -443,28 +440,31 @@
* @... : %NULL ended list of parameters.
*
* Create a new dialog as in xfce_message_dialog_new(), then runs the
- * dialog and return the response id selected by the user.
+ * dialog using #gtk_dialog_run and return the response id selected by the user.
*
* See xfce_message_dialog_new() for more information.
*
* Returns: the selected response id.
**/
gint
-xfce_message_dialog_run (gpointer parent,
- const gchar *title,
- const gchar *stock_id,
- const gchar *primary_text,
- const gchar *secondary_text,
- const gchar *first_button_text,
- ...)
+xfce_message_dialog (GtkWindow *parent,
+ const gchar *title,
+ const gchar *stock_id,
+ const gchar *primary_text,
+ const gchar *secondary_text,
+ const gchar *first_button_text,
+ ...)
{
va_list args;
GtkWidget *dialog;
gint response_id;
+ g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), 0);
+
/* create dialog */
va_start (args, first_button_text);
- dialog = xfce_message_dialog_vnew (parent, title, stock_id, primary_text, secondary_text, first_button_text, args);
+ dialog = xfce_message_dialog_new_valist (parent, title, stock_id, primary_text,
+ secondary_text, first_button_text, args);
va_end (args);
/* run the dialog */
Modified: libxfce4ui/trunk/libxfce4ui/xfce-dialogs.h
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-dialogs.h 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-dialogs.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -32,34 +32,37 @@
#define XFCE_BUTTON_TYPE_MIXED "button-mixed"
#define XFCE_BUTTON_TYPE_PIXBUF "button-pixbuf"
-void xfce_dialog_show_info (gpointer parent,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
+void xfce_dialog_show_info (GtkWindow *parent,
+ const gchar *secondary_text,
+ const gchar *primary_format,
+ ...) G_GNUC_PRINTF (3, 4);
-void xfce_dialog_show_warning (gpointer parent,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
+void xfce_dialog_show_warning (GtkWindow *parent,
+ const gchar *secondary_text,
+ const gchar *primary_format,
+ ...) G_GNUC_PRINTF (3, 4);
-void xfce_dialog_show_error (gpointer parent,
+void xfce_dialog_show_error (GtkWindow *parent,
const GError *error,
- const gchar *format,
+ const gchar *primary_format,
...) G_GNUC_PRINTF (3, 4);
-gboolean xfce_dialog_confirm (gpointer parent,
+gboolean xfce_dialog_confirm (GtkWindow *parent,
const gchar *stock_id,
const gchar *confirm_label,
- const gchar *format,
- ...) G_GNUC_PRINTF (4, 5);
+ const gchar *secondary_text,
+ const gchar *primary_format,
+ ...) G_GNUC_PRINTF (5, 6);
-GtkWidget *xfce_message_dialog_new (gpointer parent,
+GtkWidget *xfce_message_dialog_new (GtkWindow *parent,
const gchar *title,
const gchar *stock_id,
const gchar *primary_text,
const gchar *secondary_text,
const gchar *first_button_text,
- ...) G_GNUC_NULL_TERMINATED;
+ ...) G_GNUC_NULL_TERMINATED G_GNUC_MALLOC;
-gint xfce_message_dialog_run (gpointer parent,
+gint xfce_message_dialog (GtkWindow *parent,
const gchar *title,
const gchar *stock_id,
const gchar *primary_text,
Modified: libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.c
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.c 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -38,57 +38,6 @@
/**
- * xfce_gdk_pixbuf_new_from_inline_at_size:
- * @data : byte data containing a serialized #GdkPixdata structure.
- * @width : the width of the returned pixbuf or -1 to not constrain the width.
- * @height : the height of the returned pixbuf or -1 to not constrain the height.
- *
- * Creates a #GdkPixbuf from a flat representation that is suitable
- * for storing as inline data in a program. The image will be scaled
- * to fit in the requested size, preserving the image's aspect ratio.
- *
- * See also: gdk_pixbuf_new_from_inline(), gdk_pixbuf_scale_simple().
- *
- * Return value: a newly-created pixbuf with a reference count of 1,
- * or %NULL on failure. This data must be freed with
- * g_object_unref() after use.
- **/
-GdkPixbuf *
-xfce_gdk_pixbuf_new_from_inline_at_size (const guint8 *data,
- gint width,
- gint height)
-{
- GdkPixbuf *pixbuf, *scaled;
-
- /*create a pixbuf from the inline data */
- pixbuf = gdk_pixbuf_new_from_inline (-1, data, FALSE, NULL);
-
- if (G_LIKELY (pixbuf != NULL))
- {
- /* check pixbuf size */
- if ((width > 0 && gdk_pixbuf_get_width (pixbuf) != width)
- || (height > 0 && gdk_pixbuf_get_height (pixbuf) != height))
- {
- /* scale pixbuf */
- scaled = gdk_pixbuf_scale_simple (pixbuf,
- width > 0 ? width : gdk_pixbuf_get_width (pixbuf),
- height > 0 ? height : gdk_pixbuf_get_height (pixbuf),
- GDK_INTERP_BILINEAR);
-
- /* release the old pixbuf */
- g_object_unref (G_OBJECT (pixbuf));
-
- /* set */
- pixbuf = scaled;
- }
- }
-
- return pixbuf;
-}
-
-
-
-/**
* xfce_gdk_screen_get_active:
* @monitor_return : Address to store the monitor number to or %NULL.
*
@@ -104,12 +53,12 @@
#ifdef GDK_WINDOWING_X11
GdkScreen *screen;
Window child;
- Window root;
+ Window root;
GSList *displays;
GSList *lp;
- guint xmask;
- gint rootx, rooty;
- gint winx, winy;
+ guint xmask;
+ gint rootx, rooty;
+ gint winx, winy;
gint n;
/* determine the list of active displays */
@@ -128,7 +77,7 @@
/* return the monitor number */
if (monitor_return)
*monitor_return = gdk_screen_get_monitor_at_point (screen, rootx, rooty);
-
+
/* yap, this screen contains the pointer, hence it's the active screen */
goto out;
}
@@ -137,7 +86,7 @@
/* fallback to the default screen */
screen = gdk_screen_get_default ();
-
+
/* no monitor was found */
if (monitor_return)
*monitor_return = 0;
Modified: libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.h
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.h 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-gdk-extensions.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -30,12 +30,8 @@
G_BEGIN_DECLS
-GdkPixbuf *xfce_gdk_pixbuf_new_from_inline_at_size (const guint8 *data,
- gint width,
- gint height) G_GNUC_MALLOC;
+GdkScreen *xfce_gdk_screen_get_active (gint *monitor_return);
-GdkScreen *xfce_gdk_screen_get_active (gint *monitor_return);
-
G_END_DECLS
#endif /* !__XFCE_GDK_EXTENSIONS_H__ */
Modified: libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.c
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.c 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -168,77 +168,13 @@
/**
- * xfce_gtk_dialog_parse_parent:
- * @parent : a #GtkWidget, a #GdkScreen or %NULL.
- * @window_return : return location for the toplevel #GtkWindow or %NULL.
- *
- * Determines the screen for the @parent and returns that #GdkScreen.
- * If @window_return is not %NULL, the pointer to the #GtkWindow is
- * placed into it, or %NULL if the window could not be determined.
- *
- * If @parent is %NULL, the active #GdkScreen is set, see
- * xfce_gdk_screen_get_active() for more information.
- *
- * Return value: the #GdkScreen for the @parent.
- **/
-GdkScreen *
-xfce_gtk_dialog_parse_parent (gpointer parent,
- GtkWindow **window_return)
-{
- GdkScreen *screen = NULL;
- GtkWidget *window = NULL;
-
- g_return_val_if_fail (parent == NULL || GDK_IS_SCREEN (parent) || GTK_IS_WIDGET (parent), NULL);
-
- /* determine the proper parent if one was set */
- if (parent != NULL)
- {
- if (GDK_IS_SCREEN (parent))
- {
- /* yep, that's a screen */
- screen = GDK_SCREEN (parent);
- }
- else if (GTK_IS_WIDGET (parent))
- {
- /* parent is a widget, so let's determine the toplevel window */
- window = gtk_widget_get_toplevel (GTK_WIDGET (parent));
- if (GTK_WIDGET_TOPLEVEL (window))
- {
- /* make sure the toplevel window is shown */
- gtk_widget_show_now (window);
- }
- else
- {
- /* no toplevel, not usable then */
- window = NULL;
- }
-
- /* determine the screen for the widget */
- screen = gtk_widget_get_screen (GTK_WIDGET (parent));
- }
- }
-
- /* use the active screen */
- if (screen == NULL)
- screen = xfce_gdk_screen_get_active (NULL);
-
- /* return the window */
- if (G_LIKELY (window_return != NULL))
- *window_return = GTK_WINDOW (window);
-
- return screen;
-}
-
-
-
-/**
* xfce_gtk_window_center_on_active_screen:
* @window: the #GtkWindow to center.
*
* Determines the screen that contains the pointer and centers the
* @window on it. If it failes to determine the current pointer position,
* @window is centered on the default screen.
- *
+ *
* This function only works properly if you call it before realizing the
* window and you haven't set a fixed window position using gtk_window_move().
*
@@ -256,7 +192,7 @@
/* set the window screen */
gtk_window_set_screen (window, screen);
-
+
/* gtk+ handles the centering of the window properly after resize */
gtk_window_set_position (window, GTK_WIN_POS_CENTER);
}
Modified: libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.h
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.h 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-gtk-extensions.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -38,9 +38,6 @@
GtkWidget *xfce_gtk_frame_box_new_with_content (const gchar *label,
GtkWidget *content) G_GNUC_MALLOC;
-GdkScreen *xfce_gtk_dialog_parse_parent (gpointer parent,
- GtkWindow **window_return);
-
void xfce_gtk_window_center_on_active_screen (GtkWindow *window);
G_END_DECLS
Modified: libxfce4ui/trunk/libxfce4ui/xfce-heading.c
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-heading.c 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-heading.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -130,7 +130,8 @@
"icon",
"icon",
GDK_TYPE_PIXBUF,
- LIBXFCE4UI_PARAM_READWRITE));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
/**
* XfceHeading:icon-name:
@@ -148,7 +149,8 @@
"icon-name",
"icon-name",
NULL,
- LIBXFCE4UI_PARAM_READWRITE));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
/**
* XfceHeading:subtitle:
@@ -165,7 +167,8 @@
"subtitle",
"subtitle",
NULL,
- LIBXFCE4UI_PARAM_READWRITE));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
/**
* XfceHeading:title:
@@ -180,7 +183,8 @@
"title",
"title",
NULL,
- LIBXFCE4UI_PARAM_READWRITE));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
}
Copied: libxfce4ui/trunk/libxfce4ui/xfce-spawn.c (from rev 30213, libxfce4ui/trunk/libxfce4ui/xfce-execute.c)
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-spawn.c (rev 0)
+++ libxfce4ui/trunk/libxfce4ui/xfce-spawn.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -0,0 +1,417 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2005-2007 Benedikt Meurer <benny at xfce.org>
+ * Copyright (c) 2007 The Xfce Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <gdk/gdk.h>
+
+#ifdef GDK_WINDOWING_X11
+#include <X11/Xatom.h>
+#include <gdk/gdkx.h>
+#endif
+
+#ifdef HAVE_LIBSTARTUP_NOTIFICATION
+#include <libsn/sn.h>
+#endif
+
+#include <libxfce4ui/xfce-spawn.h>
+#include <libxfce4ui/xfce-gdk-extensions.h>
+#include <libxfce4ui/libxfce4ui-private.h>
+#include <libxfce4ui/libxfce4ui-alias.h>
+
+/* the maximum time for an application to startup */
+#define XFCE_SPAWN_STARTUP_TIMEOUT (30 * 1000)
+
+
+
+#ifdef HAVE_LIBSTARTUP_NOTIFICATION
+typedef struct
+{
+ SnLauncherContext *sn_launcher;
+ guint timeout_id;
+ guint watch_id;
+ GPid pid;
+} XfceSpawnData;
+
+
+
+
+static gboolean
+xfce_spawn_startup_timeout (gpointer user_data)
+{
+ XfceSpawnData *spawn_data = user_data;
+ GTimeVal now;
+ gdouble elapsed;
+ glong tv_sec;
+ glong tv_usec;
+
+ GDK_THREADS_ENTER ();
+
+ /* determine the amount of elapsed time */
+ g_get_current_time (&now);
+ sn_launcher_context_get_last_active_time (spawn_data->sn_launcher, &tv_sec, &tv_usec);
+ elapsed = (((gdouble) now.tv_sec - tv_sec) * G_USEC_PER_SEC + (now.tv_usec - tv_usec)) / 1000.0;
+
+ /* check if the timeout was reached */
+ if (elapsed >= XFCE_SPAWN_STARTUP_TIMEOUT)
+ {
+ /* abort the startup notification */
+ sn_launcher_context_complete (spawn_data->sn_launcher);
+ sn_launcher_context_unref (spawn_data->sn_launcher);
+ spawn_data->sn_launcher = NULL;
+ }
+
+ GDK_THREADS_LEAVE ();
+
+ /* keep the startup timeout if not elapsed */
+ return (elapsed < XFCE_SPAWN_STARTUP_TIMEOUT);
+}
+
+
+
+static void
+xfce_spawn_startup_timeout_destroy (gpointer user_data)
+{
+ XfceSpawnData *spawn_data = user_data;
+
+ g_return_if_fail (spawn_data->sn_launcher == NULL);
+
+ /* cancel the watch (if any) */
+ if (spawn_data->watch_id != 0)
+ g_source_remove (spawn_data->watch_id);
+
+ /* make sure we don't leave zombies */
+ g_child_watch_add_full (G_PRIORITY_LOW, spawn_data->pid,
+ (GChildWatchFunc) g_spawn_close_pid,
+ NULL, NULL);
+
+ /* release the startup data */
+ g_slice_free (XfceSpawnData, spawn_data);
+}
+
+
+
+static void
+xfce_spawn_startup_watch (GPid pid,
+ gint status,
+ gpointer user_data)
+{
+ XfceSpawnData *spawn_data = user_data;
+
+ g_return_if_fail (spawn_data->sn_launcher != NULL);
+ g_return_if_fail (spawn_data->watch_id != 0);
+ g_return_if_fail (spawn_data->pid == pid);
+
+ /* abort the startup notification (application exited) */
+ sn_launcher_context_complete (spawn_data->sn_launcher);
+ sn_launcher_context_unref (spawn_data->sn_launcher);
+ spawn_data->sn_launcher = NULL;
+
+ /* cancel the startup notification timeout */
+ g_source_remove (spawn_data->timeout_id);
+}
+
+
+
+static gint
+xfce_spawn_get_active_workspace_number (GdkScreen *screen)
+{
+ GdkWindow *root;
+ gulong bytes_after_ret = 0;
+ gulong nitems_ret = 0;
+ guint *prop_ret = NULL;
+ Atom _NET_CURRENT_DESKTOP;
+ Atom _WIN_WORKSPACE;
+ Atom type_ret = None;
+ gint format_ret;
+ gint ws_num = 0;
+
+ gdk_error_trap_push ();
+
+ root = gdk_screen_get_root_window (screen);
+
+ /* determine the X atom values */
+ _NET_CURRENT_DESKTOP = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_NET_CURRENT_DESKTOP", False);
+ _WIN_WORKSPACE = XInternAtom (GDK_WINDOW_XDISPLAY (root), "_WIN_WORKSPACE", False);
+
+ if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root), GDK_WINDOW_XWINDOW (root),
+ _NET_CURRENT_DESKTOP, 0, 32, False, XA_CARDINAL,
+ &type_ret, &format_ret, &nitems_ret, &bytes_after_ret,
+ (gpointer) &prop_ret) != Success)
+ {
+ if (XGetWindowProperty (GDK_WINDOW_XDISPLAY (root), GDK_WINDOW_XWINDOW (root),
+ _WIN_WORKSPACE, 0, 32, False, XA_CARDINAL,
+ &type_ret, &format_ret, &nitems_ret, &bytes_after_ret,
+ (gpointer) &prop_ret) != Success)
+ {
+ if (G_UNLIKELY (prop_ret != NULL))
+ {
+ XFree (prop_ret);
+ prop_ret = NULL;
+ }
+ }
+ }
+
+ if (G_LIKELY (prop_ret != NULL))
+ {
+ if (G_LIKELY (type_ret != None && format_ret != 0))
+ ws_num = *prop_ret;
+ XFree (prop_ret);
+ }
+
+ gdk_error_trap_pop ();
+
+ return ws_num;
+}
+#endif
+
+
+
+/**
+ * xfce_spawn_on_screen:
+ * @screen : a #GdkScreen or %NULL to use the active screen,
+ * see xfce_gdk_screen_get_active().
+ * @working_directory : child's current working directory or %NULL to
+ * inherit parent's.
+ * @argv : child's argument vector.
+ * @envp : child's environment vector or %NULL to inherit
+ * parent's.
+ * @flags : flags from #GSpawnFlags.
+ * @startup_notify : whether to use startup notification.
+ * @startup_timestamp : the timestamp to pass to startup notification, use
+ * the event time here if possible to make focus
+ * stealing prevention work property. If you don't
+ * have direct access to the event time you could use
+ * gtk_get_current_event_time() or if nothing is
+ * available 0 is valid too.
+ * @icon_name : application icon or %NULL.
+ * @error : return location for errors or %NULL.
+ *
+ * Like gdk_spawn_on_screen(), but also supports startup notification
+ * (if Libxfce4ui was built with startup notification support).
+ *
+ * Return value: %TRUE on success, %FALSE if @error is set.
+ **/
+gboolean
+xfce_spawn_on_screen (GdkScreen *screen,
+ const gchar *working_directory,
+ gchar **argv,
+ gchar **envp,
+ GSpawnFlags flags,
+ gboolean startup_notify,
+ guint32 startup_timestamp,
+ const gchar *icon_name,
+ GError **error)
+{
+ gboolean succeed;
+ gchar **cenvp;
+ gint n;
+ gint n_cenvp;
+ gchar *display_name;
+ GPid pid;
+#ifdef HAVE_LIBSTARTUP_NOTIFICATION
+ SnLauncherContext *sn_launcher = NULL;
+ XfceSpawnData *spawn_data;
+ SnDisplay *sn_display = NULL;
+ gint sn_workspace;
+#endif
+
+ g_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ /* lookup the screen with the pointer */
+ if (screen == NULL)
+ screen = xfce_gdk_screen_get_active (NULL);
+
+ /* setup the child environment, without startup id and display */
+ if (G_LIKELY (envp == NULL))
+ {
+ /* use the portable g_listenv, but note that this function only returns the
+ * variable names, not with values, therefore the call to g_getenv */
+ envp = g_listenv ();
+ cenvp = g_new0 (gchar *, g_strv_length (envp) + 3);
+ for (n = n_cenvp = 0; envp[n] != NULL; n++)
+ if (strcmp (envp[n], "DESKTOP_STARTUP_ID") != 0
+ && strcmp (envp[n], "DISPLAY") != 0)
+ cenvp[n_cenvp++] = g_strconcat (envp[n], "=", g_getenv (envp[n]), NULL);
+
+ /* cleanup */
+ g_strfreev (envp);
+ envp = NULL;
+ }
+ else
+ {
+ cenvp = g_new0 (gchar *, g_strv_length (envp) + 3);
+ for (n = n_cenvp = 0; envp[n] != NULL; n++)
+ if (strncmp (envp[n], "DESKTOP_STARTUP_ID", 18) != 0
+ && strncmp (envp[n], "DISPLAY", 7) != 0)
+ cenvp[n_cenvp++] = g_strdup (envp[n]);
+ }
+
+ /* add the real display name */
+ display_name = gdk_screen_make_display_name (screen);
+ cenvp[n_cenvp++] = g_strconcat ("DISPLAY=", display_name, NULL);
+ g_free (display_name);
+
+#ifdef HAVE_LIBSTARTUP_NOTIFICATION
+ /* initialize the sn launcher context */
+ if (G_LIKELY (startup_notify))
+ {
+ sn_display = sn_display_new (GDK_SCREEN_XDISPLAY (screen),
+ (SnDisplayErrorTrapPush) gdk_error_trap_push,
+ (SnDisplayErrorTrapPop) gdk_error_trap_pop);
+
+ if (G_LIKELY (sn_display != NULL))
+ {
+ sn_launcher = sn_launcher_context_new (sn_display, GDK_SCREEN_XNUMBER (screen));
+
+ if (G_LIKELY (sn_launcher != NULL && !sn_launcher_context_get_initiated (sn_launcher)))
+ {
+ /* initiate the sn launcher context */
+ sn_workspace = xfce_spawn_get_active_workspace_number (screen);
+ sn_launcher_context_set_binary_name (sn_launcher, argv[0]);
+ sn_launcher_context_set_workspace (sn_launcher, sn_workspace);
+ sn_launcher_context_set_icon_name (sn_launcher, (icon_name != NULL) ? icon_name : "applications-other");
+ sn_launcher_context_initiate (sn_launcher, g_get_prgname (), argv[0], startup_timestamp);
+
+ /* add the real startup id to the child environment */
+ cenvp[n_cenvp++] = g_strconcat ("DESKTOP_STARTUP_ID=", sn_launcher_context_get_startup_id (sn_launcher), NULL);
+
+ /* we want to watch the child process */
+ flags |= G_SPAWN_DO_NOT_REAP_CHILD;
+ }
+ }
+ }
+#endif
+
+ /* try to spawn the new process */
+ succeed = g_spawn_async (working_directory, argv, cenvp, flags, NULL, NULL, &pid, error);
+
+#ifdef HAVE_LIBSTARTUP_NOTIFICATION
+ if (G_LIKELY (sn_launcher != NULL))
+ {
+ if (G_UNLIKELY (!succeed))
+ {
+ /* abort the startup notification sequence */
+ sn_launcher_context_complete (sn_launcher);
+ sn_launcher_context_unref (sn_launcher);
+ }
+ else
+ {
+ /* schedule a startup notification timeout */
+ spawn_data = g_slice_new0 (XfceSpawnData);
+ spawn_data->sn_launcher = sn_launcher;
+ spawn_data->timeout_id = g_timeout_add_full (G_PRIORITY_LOW, XFCE_SPAWN_STARTUP_TIMEOUT, xfce_spawn_startup_timeout,
+ spawn_data, xfce_spawn_startup_timeout_destroy);
+ spawn_data->watch_id = g_child_watch_add_full (G_PRIORITY_LOW, pid, xfce_spawn_startup_watch, spawn_data, NULL);
+ spawn_data->pid = pid;
+ }
+ }
+ else if (G_LIKELY (succeed))
+ {
+ /* make sure we don't leave zombies */
+ g_child_watch_add_full (G_PRIORITY_LOW, pid, (GChildWatchFunc) g_spawn_close_pid, NULL, NULL);
+ }
+
+ /* release the sn display */
+ if (G_LIKELY (sn_display != NULL))
+ sn_display_unref (sn_display);
+#endif
+
+ /* cleanup */
+ g_strfreev (cenvp);
+
+ return succeed;
+}
+
+
+
+/**
+ * xfce_spawn_command_line_on_screen:
+ * @screen : a #GdkScreen or %NULL to use the active screen, see xfce_gdk_screen_get_active().
+ * @command_line : command line to run.
+ * @in_terminal : whether to run @command_line in a terminal.
+ * @startup_notify : whether to use startup notification.
+ * @error : location for a #GError or %NULL.
+ *
+ * Executes the given @command_line and returns %TRUE if the
+ * command terminated successfully. Else, the @error is set
+ * to the standard error output.
+ *
+ * Returns: %TRUE if the @command_line was executed
+ * successfully, %FALSE if @error is set.
+ */
+gboolean
+xfce_spawn_command_line_on_screen (GdkScreen *screen,
+ const gchar *command_line,
+ gboolean in_terminal,
+ gboolean startup_notify,
+ GError **error)
+{
+ gchar **argv;
+ gboolean succeed;
+
+ g_return_val_if_fail (screen == NULL || GDK_IS_SCREEN (screen), FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+ g_return_val_if_fail (command_line != NULL, FALSE);
+
+ /* parse the command */
+ if (in_terminal == FALSE)
+ {
+ /* parse the command, retrun false with error when this fails */
+ if (G_UNLIKELY (!g_shell_parse_argv (command_line, NULL, &argv, error)))
+ return FALSE;
+ }
+ else
+ {
+ /* create an argv to run the command in a terminal */
+ argv = g_new0 (gchar *, 5);
+ argv[0] = g_strdup ("exo-open");
+ argv[1] = g_strdup ("--launch");
+ argv[2] = g_strdup ("TerminalEmulator");
+ argv[3] = g_strdup (command_line);
+ argv[4] = NULL;
+ }
+
+ /* execute the function */
+ succeed = xfce_spawn_on_screen (screen, NULL, argv, NULL,
+ G_SPAWN_SEARCH_PATH, startup_notify,
+ gtk_get_current_event_time (), NULL, error);
+
+ /* cleanup */
+ g_strfreev (argv);
+
+ return succeed;
+}
+
+
+
+#define __XFCE_SPAWN_C__
+#include <libxfce4ui/libxfce4ui-aliasdef.c>
Copied: libxfce4ui/trunk/libxfce4ui/xfce-spawn.h (from rev 30213, libxfce4ui/trunk/libxfce4ui/xfce-execute.h)
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-spawn.h (rev 0)
+++ libxfce4ui/trunk/libxfce4ui/xfce-spawn.h 2009-07-07 15:06:18 UTC (rev 30214)
@@ -0,0 +1,50 @@
+/* $Id$ */
+/*-
+ * Copyright (c) 2007 The Xfce Development Team
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#if !defined (LIBXFCE4UI_INSIDE_LIBXFCE4UI_H) && !defined (LIBXFCE4UI_COMPILATION)
+#error "Only <libxfce4ui/libxfce4ui.h> can be included directly, this file is not part of the public API."
+#endif
+
+#ifndef __XFCE_SPAWN_H__
+#define __XFCE_SPAWN_H__
+
+#include <gdk/gdk.h>
+
+G_BEGIN_DECLS
+
+gboolean xfce_spawn_on_screen (GdkScreen *screen,
+ const gchar *working_directory,
+ gchar **argv,
+ gchar **envp,
+ GSpawnFlags flags,
+ gboolean startup_notify,
+ guint32 startup_timestamp,
+ const gchar *icon_name,
+ GError **error);
+
+gboolean xfce_spawn_command_line_on_screen (GdkScreen *screen,
+ const gchar *command_line,
+ gboolean in_terminal,
+ gboolean startup_notify,
+ GError **error);
+
+G_END_DECLS
+
+#endif /* !__XFCE_SPAWN_H__ */
Modified: libxfce4ui/trunk/libxfce4ui/xfce-titled-dialog.c
===================================================================
--- libxfce4ui/trunk/libxfce4ui/xfce-titled-dialog.c 2009-07-07 13:49:13 UTC (rev 30213)
+++ libxfce4ui/trunk/libxfce4ui/xfce-titled-dialog.c 2009-07-07 15:06:18 UTC (rev 30214)
@@ -102,7 +102,8 @@
"subtitle",
"subtitle",
NULL,
- LIBXFCE4UI_PARAM_READWRITE));
+ G_PARAM_READWRITE
+ | G_PARAM_STATIC_STRINGS));
/* connect additional key bindings to the GtkDialog::close action signal */
binding_set = gtk_binding_set_by_class (klass);
More information about the Xfce4-commits
mailing list