Commit 37d94e2f authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin
Browse files

use the new libgnomeui and GDK functions to replace the egg-screen stuff.

2003-12-10  Mark McLoughlin  <mark@skynet.ie>

        * clock.c: (try_config_tool), (properties_response_cb),
        (display_help_dialog): use the new libgnomeui and
        GDK functions to replace the egg-screen stuff.

        * Makefile.am: don't do the libegg thang.

        * egg-screen-exec.[ch],
          egg-screen-help.[ch],
          egg-screen-url.[ch],
          update-from-egg.sh: die.
parent 33e3352c
2003-12-10 Mark McLoughlin <mark@skynet.ie>
* clock.c: (try_config_tool), (properties_response_cb),
(display_help_dialog): use the new libgnomeui and
GDK functions to replace the egg-screen stuff.
* Makefile.am: don't do the libegg thang.
* egg-screen-exec.[ch],
egg-screen-help.[ch],
egg-screen-url.[ch],
update-from-egg.sh: die.
==================== 2.5.2 ====================
2003-12-09 Mark McLoughlin <mark@skynet.ie>
......
......@@ -11,17 +11,7 @@ INCLUDES = \
-DPREFIX=\""$(prefix)"\" \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\"
EGGFILES = \
egg-screen-exec.h \
egg-screen-exec.c \
egg-screen-help.h \
egg-screen-help.c \
egg-screen-url.h \
egg-screen-url.c
libclock_applet_2_la_SOURCES = \
clock.c \
$(EGGFILES)
libclock_applet_2_la_SOURCES = clock.c
libclock_applet_2_la_LDFLAGS = -module -avoid-version -no-undefined
libclock_applet_2_la_LIBADD = \
......@@ -67,8 +57,3 @@ EXTRA_DIST = \
$(ui_DATA)
CLEANFILES = $(server_in_files) $(server_DATA) $(schemas_DATA)
EGGDIR = $(srcdir)/../../../libegg/libegg/screen-exec
regenerate-built-sources:
EGGFILES="$(EGGFILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh
......@@ -45,11 +45,10 @@
#include <gtk/gtk.h>
#include <libbonobo.h>
#include <libgnomeui/libgnomeui.h>
#include <libgnomeui/gnome-help.h>
#include <libgnome/libgnome.h>
#include <gconf/gconf-client.h>
#include "egg-screen-help.h"
#define INTERNETSECOND (864)
#define INTERNETBEAT (86400)
......@@ -857,9 +856,8 @@ try_config_tool (GdkScreen *screen,
argv [0] = app;
argv [1] = NULL;
/* FIXME: use egg_spawn_async_on_screen */
err = NULL;
if (g_spawn_async (NULL, argv, NULL, 0, NULL, NULL, NULL, &err)) {
if (gdk_spawn_on_screen (screen, NULL, argv, NULL, 0, NULL, NULL, NULL, &err)) {
g_free (app);
return TRUE;
}
......@@ -1324,7 +1322,7 @@ properties_response_cb (GtkWidget *widget,
if (id == GTK_RESPONSE_HELP) {
GError *error = NULL;
egg_help_display_desktop_on_screen (
gnome_help_display_desktop_on_screen (
NULL, "clock", "clock", "clock-settings",
gtk_widget_get_screen (cd->applet),
&error);
......@@ -1590,7 +1588,7 @@ display_help_dialog (BonoboUIComponent *uic,
GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);
}
egg_help_display_desktop_on_screen (
gnome_help_display_desktop_on_screen (
applet_program, "clock", "clock",NULL,
gtk_widget_get_screen (cd->applet),
&error);
......
/* egg-screen-exec.c
*
* Copyright (C) 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Mark McLoughlin <mark@skynet.ie>
*/
#include <config.h>
#include "egg-screen-exec.h"
#include <string.h>
#include <libgnome/gnome-exec.h>
#ifndef HAVE_GTK_MULTIHEAD
#include <gdk/gdkx.h>
#endif
extern char **environ;
/**
* egg_screen_exec_display_string:
* @screen: A #GdkScreen
*
* Description: Returns a string that when passed to XOpenDisplay()
* would cause @screen to be the default screen on the newly opened
* X display. This string is suitable for setting $DISPLAY when
* launching an application which should appear on @screen.
*
* Returns: a newly allocated string or %NULL on error.
**/
char *
egg_screen_exec_display_string (GdkScreen *screen)
{
#ifdef HAVE_GTK_MULTIHEAD
GString *str;
const char *old_display;
char *retval;
char *p;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
if (gdk_screen_get_default () == screen)
return g_strdup_printf ("DISPLAY=%s",
gdk_display_get_name (
gdk_screen_get_display (screen)));
old_display = gdk_display_get_name (gdk_screen_get_display (screen));
str = g_string_new ("DISPLAY=");
g_string_append (str, old_display);
p = strrchr (str->str, '.');
if (p && p > strchr (str->str, ':'))
g_string_truncate (str, p - str->str);
g_string_append_printf (str, ".%d", gdk_screen_get_number (screen));
retval = str->str;
g_string_free (str, FALSE);
return retval;
#else
return g_strdup (DisplayString (GDK_DISPLAY ()));
#endif
}
/**
* egg_screen_exec_environment:
* @screen: A #GdkScreen
*
* Description: Modifies the current program environment to
* ensure that $DISPLAY is set such that a launched application
* inheriting this environment would appear on @screen.
*
* Returns: a newly-allocated %NULL-terminated array of strings or
* %NULL on error. Use g_strfreev() to free it.
**/
char **
egg_screen_exec_environment (GdkScreen *screen)
{
char **retval = NULL;
int i, env_len;
#ifdef HAVE_GTK_MULTIHEAD
int display_index = -1;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
for (env_len = 0; environ [env_len]; env_len++)
if (!strncmp (environ [env_len], "DISPLAY", 7))
display_index = env_len;
if (display_index == -1)
display_index = env_len++;
#else
for (env_len = 0; environ [env_len]; env_len++);
#endif
retval = g_new (char *, env_len + 1);
retval [env_len] = NULL;
for (i = 0; i < env_len; i++)
#ifdef HAVE_GTK_MULTIHEAD
if (i == display_index)
retval [i] = egg_screen_exec_display_string (screen);
else
#endif
retval [i] = g_strdup (environ [i]);
g_assert (i == env_len);
return retval;
}
/**
* egg_screen_execute_async:
* @screen: A #GdkScreen
* @dir: Directory in which child should be executed, or %NULL for current
* directory
* @argc: Number of arguments
* @argv: Argument vector to exec child
*
* Description: Like gnome_execute_async(), but ensures that the child
* is launched in an environment such that if it calls XOpenDisplay()
* the resulting display would have @screen as the default screen.
*
* Returns: process id of child, or %-1 on error.
**/
int
egg_screen_execute_async (GdkScreen *screen,
const char *dir,
int argc,
char * const argv [])
{
#ifdef HAVE_GTK_MULTIHEAD
char **envp = NULL;
int envc = 0;
int retval;
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
if (gdk_screen_get_default () != screen) {
envc = 1;
envp = g_new0 (char *, 2);
envp [0] = egg_screen_exec_display_string (screen);
}
retval = gnome_execute_async_with_env (dir, argc, argv, envc, envp);
g_strfreev (envp);
return retval;
#else
return gnome_execute_async (dir, argc, argv);
#endif
}
/**
* egg_screen_execute_shell:
* @screen: A #GdkScreen.
* @dir: Directory in which child should be executed, or %NULL for current
* directory
* @commandline: Shell command to execute
*
* Description: Like gnome_execute_shell(), but ensures that the child
* is launched in an environment such that if it calls XOpenDisplay()
* the resulting display would have @screen as the default screen.
*
* Returns: process id of shell, or %-1 on error.
**/
int
egg_screen_execute_shell (GdkScreen *screen,
const char *dir,
const char *command)
{
#ifdef HAVE_GTK_MULTIHEAD
int retval = -1;
g_return_val_if_fail (GDK_IS_SCREEN (screen), -1);
if (gdk_screen_get_default () == screen)
retval = gnome_execute_shell (dir, command);
else {
char *exec;
char *display;
display = egg_screen_exec_display_string (screen);
exec = g_strconcat (display, " ", command, NULL);
retval = gnome_execute_shell (dir, exec);
g_free (display);
g_free (exec);
}
return retval;
#else
return gnome_execute_shell (dir, command);
#endif
}
/**
* egg_screen_execute_command_line_async:
* @screen: A #GdkScreen.
* @command_line: a command line
* @error: return location for errors
*
* Description: Like g_spawn_command_line_async(), but ensures that
* the child is launched in an environment such that if it calls
* XOpenDisplay() the resulting display would have @screen as the
* default screen.
*
* Returns: %TRUE on success, %FALSE if error is set.
**/
gboolean
egg_screen_execute_command_line_async (GdkScreen *screen,
const char *command,
GError **error)
{
#ifdef HAVE_GTK_MULTIHEAD
gboolean retval;
char **argv = NULL;
char **envp = NULL;
g_return_val_if_fail (GDK_IS_SCREEN (screen), FALSE);
g_return_val_if_fail (command != NULL, FALSE);
if (!g_shell_parse_argv (command, NULL, &argv, error))
return FALSE;
if (gdk_screen_get_default () != screen)
envp = egg_screen_exec_environment (screen);
retval = g_spawn_async (g_get_home_dir (),
argv, envp, G_SPAWN_SEARCH_PATH,
NULL, NULL, NULL, error);
g_strfreev (argv);
g_strfreev (envp);
return retval;
#else
return g_spawn_command_line_async (command, error);
#endif
}
/* egg-screen-exec.h
*
* Copyright (C) 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Mark McLoughlin <mark@skynet.ie>
*/
#ifndef __EGG_SCREEN_EXEC_H__
#define __EGG_SCREEN_EXEC_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
char *egg_screen_exec_display_string (GdkScreen *screen);
char **egg_screen_exec_environment (GdkScreen *screen);
int egg_screen_execute_async (GdkScreen *screen,
const char *dir,
int argc,
char * const argv []);
int egg_screen_execute_shell (GdkScreen *screen,
const char *dir,
const char *command);
gboolean egg_screen_execute_command_line_async (GdkScreen *screen,
const char *command,
GError **error);
G_END_DECLS
#endif /* __EGG_SCREEN_EXEC_H__ */
/* egg-screen-help.c
* Copyright (C) 2001 Sid Vicious
* Copyright (C) 2001 Jonathan Blandford <jrb@alum.mit.edu>
* Copyright (C) 2002 Sun Microsystems Inc.
* All rights reserved.
*
* 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, Cambridge, MA 02139, USA.
*
* Authors: Mark McLoughlin <mark@skynet.ie>
*/
#include <config.h>
#include "egg-screen-help.h"
#include <libgnome/gnome-help.h>
#include "egg-screen-exec.h"
/**
* egg_help_display_on_screen:
* @file_name: The name of the help document to display.
* @link_id: Can be %NULL. If set, refers to an anchor or section id within the
* requested document.
* @screen: a #GdkScreen.
* @error: A #GError instance that will hold the specifics of any error which
* occurs during processing, or %NULL
*
* Description: Like gnome_help_display(), but ensures that the help viewer
* application appears on @screen.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
gboolean
egg_help_display_on_screen (const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error)
{
return egg_help_display_with_doc_id_on_screen (
NULL, NULL, file_name, link_id, screen, error);
}
/**
* egg_help_display_with_doc_id_on_screen:
* @program: The current application object, or %NULL for the default one.
* @doc_id: The document identifier, or %NULL to default to the application ID
* (app_id) of the specified @program.
* @file_name: The name of the help document to display.
* @link_id: Can be %NULL. If set, refers to an anchor or section id within the
* requested document.
* @screen: a #GdkScreen.
* @error: A #GError instance that will hold the specifics of any error which
* occurs during processing, or %NULL
*
* Description: Like gnome_help_display_with_doc_id(), but ensures that the help
* viewer application appears on @screen.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
gboolean
egg_help_display_with_doc_id_on_screen (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = gnome_help_display_with_doc_id_and_env (
program, doc_id, file_name, link_id, env, error);
g_strfreev (env);
return retval;
}
/**
* egg_help_display_desktop_on_screen:
* @program: The current application object, or %NULL for the default one.
* @doc_id: The name of the help file relative to the system's help domain
* (#GNOME_FILE_DOMAIN_HELP).
* @file_name: The name of the help document to display.
* @link_id: Can be %NULL. If set, refers to an anchor or section id within the
* requested document.
* @screen: a #GdkScreen.
* @error: A #GError instance that will hold the specifics of any error which
* occurs during processing, or %NULL
*
* Description: Like gnome_help_display_desktop(), but ensures that the help
* viewer application appears on @screen.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
gboolean
egg_help_display_desktop_on_screen (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = gnome_help_display_desktop_with_env (
program, doc_id, file_name, link_id, env, error);
g_strfreev (env);
return retval;
}
/**
* egg_help_display_uri_on_screen:
* @help_uri: The URI to display.
* @screen: a #GdkScreen.
* @error: A #GError instance that will hold the specifics of any error which
* occurs during processing, or %NULL
*
* Description: Like gnome_help_display_uri(), but ensures that the help viewer
* application appears on @screen.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
gboolean
egg_help_display_uri_on_screen (const char *help_uri,
GdkScreen *screen,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = gnome_help_display_uri_with_env (help_uri, env, error);
g_strfreev (env);
return retval;
}
/* egg-screen-help.h
*
* Copyright (C) 2002 Sun Microsystems Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* Authors: Mark McLoughlin <mark@skynet.ie>
*/
#ifndef __EGG_SCREEN_HELP_H__
#define __EGG_SCREEN_HELP_H__
#include <glib.h>
#include <gdk/gdk.h>
#include <libgnome/gnome-program.h>
G_BEGIN_DECLS
/* Destined for libgnomeui.
*/
gboolean egg_help_display_on_screen (const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error);
gboolean egg_help_display_with_doc_id_on_screen (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error);
gboolean egg_help_display_desktop_on_screen (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GdkScreen *screen,
GError **error);
gboolean egg_help_display_uri_on_screen (const char *help_uri,
GdkScreen *screen,
GError **error);
G_END_DECLS
#endif /* __EGG_SCREEN_HELP_H__ */
/* egg-screen-url.c
* Copyright (C) 1998, James Henstridge <james@daa.com.au>
* Copyright (C) 1999, 2000 Red Hat, Inc.
* Copyright (C) 2002, Sun Microsystems Inc.
* All rights reserved.
*
* 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.