Commit c8d0a622 authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin
Browse files

add egg-screen-exec file to the build.

2002-08-08  Mark McLoughlin  <mark@skynet.ie>

        * Makefile.am: add egg-screen-exec file to the build.

        * panel-util.[ch]:
        (panel_show_help), (panel_show_gnome_help),
        (panel_show_kde_help), (panel_show_gnome_kde_help):
        add a GdkScreen* arg and use the egg_screen_help
        variants in all of these.

        * applet.c, launcher.c, menu-ditem.c, menu.c,
          panel-config.c: pass a GdkScreen* to the help
        functions and use egg_screen_url_show instead of
        gnome_url_show.

2002-08-08  Mark McLoughlin  <mark@skynet.ie>

        * Makefile.am: add egg-screen-exec files to the build.

        * clock.c: (properties_response_cb), (display_help_dialog):
        * mailcheck.c: (phelp_cb), (help_callback):
        * pager.c: (response_cb), (display_help_dialog):
        * tasklist.c: (response_cb), (display_help_dialog):
        use egg_screen_display_desktop().

2002-08-08  Mark McLoughlin  <mark@skynet.ie>

        * Makefile.am: add egg-screen-exec files to
        the build.

        * fish.c: (phelp),
        (display_help_dialog): use egg_screen_help_displ_desktop.
parent b7000bda
2002-08-08 Mark McLoughlin <mark@skynet.ie>
* Makefile.am: add egg-screen-exec files to the build.
* clock.c: (properties_response_cb), (display_help_dialog):
* mailcheck.c: (phelp_cb), (help_callback):
* pager.c: (response_cb), (display_help_dialog):
* tasklist.c: (response_cb), (display_help_dialog):
use egg_screen_display_desktop().
2002-08-05 Mark McLoughlin <mark@skynet.ie>
* GNOME_ClockApplet.xml: move Copy Date/Time to
......
......@@ -26,6 +26,14 @@ DISABLE_DEPRECATED_CFLAGS = \
gladedir = $(datadir)/gen_util
glade_DATA = pager.glade tasklist.glade
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
libgen_util_applet_2_la_SOURCES = \
main.c \
clock.c \
......@@ -40,7 +48,8 @@ libgen_util_applet_2_la_SOURCES = \
popcheck.h \
remote-helper.c \
remote-helper.h \
multihead-hacks.h
multihead-hacks.h \
$(EGGFILES)
libgen_util_applet_2_la_LDFLAGS = -module -avoid-version
libgen_util_applet_2_la_LIBADD = \
......@@ -103,3 +112,8 @@ EXTRA_DIST = GNOME_GenUtilApplet_Factory.server.in.in \
$(schemas_in_files) \
$(glade_DATA) \
$(ui_DATA)
EGGDIR = $(srcdir)/../../../libegg/libegg/screen-exec
regenerate-built-sources:
EGGFILES="$(EGGFILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh
......@@ -28,6 +28,7 @@
#include "clock.h"
#include "multihead-hacks.h"
#include "egg-screen-help.h"
#define INTERNETSECOND (864)
#define INTERNETBEAT (86400)
......@@ -864,8 +865,10 @@ properties_response_cb (GtkWidget *widget,
GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);
}
gnome_help_display_desktop (applet_program, "clock",
"clock", "clock-settings", &error);
egg_screen_help_display_desktop (
gtk_widget_get_screen (cd->applet),
applet_program, "clock",
"clock", "clock-settings", &error);
if (error) {
GtkWidget *dialog;
......@@ -1103,8 +1106,9 @@ display_help_dialog (BonoboUIComponent *uic,
GNOME_PROGRAM_STANDARD_PROPERTIES, NULL);
}
gnome_help_display_desktop (applet_program, "clock",
"clock",NULL, &error);
egg_screen_help_display_desktop (
gtk_widget_get_screen (cd->applet),
applet_program, "clock", "clock",NULL, &error);
if (error) {
GtkWidget *dialog;
dialog = gtk_message_dialog_new (NULL,
......
2002-08-08 Mark McLoughlin <mark@skynet.ie>
* Makefile.am: add egg-screen-exec files to
the build.
* fish.c: (phelp),
(display_help_dialog): use egg_screen_help_displ_desktop.
2002-07-18 Mark McLoughlin <mark@skynet.ie>
* Makefile.am: install applet in libexec.
......
......@@ -12,7 +12,15 @@ SUBDIRS = help
libexec_PROGRAMS = fish-applet-2
fish_applet_2_SOURCES = fish.c
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
fish_applet_2_SOURCES = fish.c $(EGGFILES)
fish_applet_2_LDADD = \
../../libpanel-applet/libpanel-applet-2.la \
......@@ -62,3 +70,8 @@ install-data-local:
GCONF_CONFIG_SOURCE=$(GCONF_SCHEMA_CONFIG_SOURCE) $(GCONFTOOL) --makefile-install-rule $(top_builddir)/applets/fish/$$p ; \
done \
fi
EGGDIR = $(srcdir)/../../../libegg/libegg/screen-exec
regenerate-built-sources:
EGGFILES="$(EGGFILES)" EGGDIR="$(EGGDIR)" $(srcdir)/update-from-egg.sh
/* 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;
char *
egg_screen_exec_display_string (GdkScreen *screen)
{
#ifdef HAVE_GTK_MULTIHEAD
GString *str;
const char *old_display;
char *retval;
char *p;
old_display = gdk_display_get_name (gdk_display_get_default ());
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
}
char **
egg_screen_exec_environment (GdkScreen *screen)
{
char **retval = NULL;
int i;
#ifdef HAVE_GTK_MULTIHEAD
int display_index = -1;
for (i = 0; environ [i]; i++)
if (!strncmp (environ [i], "DISPLAY", 7))
display_index = i;
if (display_index == -1)
display_index = i++;
#else
for (i = 0; environ [i]; i++);
#endif
retval = g_new (char *, i + 1);
for (i = 0; environ [i]; 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]);
retval [i] = NULL;
return retval;
}
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
}
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
}
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 (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 <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glib.h>
#include <libgnome/gnome-help.h>
#include <libgnome/gnome-program.h>
#include <libgnome/gnome-i18n.h>
#include "egg-screen-url.h"
#include "egg-screen-exec.h"
/******* START COPIED + PASTED CODE TO GO AWAY ******/
/* The _with_env methods need to go into and
* be exposed from libgnome. They can then be
* removed from here.
*/
static gboolean
egg_help_display_uri_with_env (const char *help_uri,
char **envp,
GError **error)
{
GError *real_error;
gboolean retval;
real_error = NULL;
retval = _egg_url_show_with_env (help_uri, envp, &real_error);
if (real_error != NULL)
g_propagate_error (error, real_error);
return retval;
}
static char *
locate_help_file (const char *path, const char *doc_name)
{
int i;
char *exts[] = { ".xml", ".docbook", ".sgml", ".html", "", NULL };
const GList *lang_list = gnome_i18n_get_language_list ("LC_MESSAGES");
for (;lang_list != NULL; lang_list = lang_list->next) {
const char *lang = lang_list->data;
/* This has to be a valid language AND a language with
* no encoding postfix. The language will come up without
* encoding next */
if (lang == NULL ||
strchr (lang, '.') != NULL)
continue;
for (i = 0; exts[i] != NULL; i++) {
char *name;
char *full;
name = g_strconcat (doc_name, exts[i], NULL);
full = g_build_filename (path, lang, name, NULL);
g_free (name);
if (g_file_test (full, G_FILE_TEST_EXISTS))
return full;
g_free (full);
}
}
return NULL;
}
static gboolean
egg_help_display_with_doc_id_with_env (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
char **envp,
GError **error)
{
gchar *local_help_path;
gchar *global_help_path;
gchar *file;
struct stat local_help_st;
struct stat global_help_st;
gchar *uri;
gboolean retval;
g_return_val_if_fail (file_name != NULL, FALSE);
retval = FALSE;
local_help_path = NULL;
global_help_path = NULL;
file = NULL;
uri = NULL;
if (program == NULL)
program = gnome_program_get ();
if (doc_id == NULL)
doc_id = gnome_program_get_app_id (program);
/* Compute the local and global help paths */
local_help_path = gnome_program_locate_file (program,
GNOME_FILE_DOMAIN_APP_HELP,
"",
FALSE /* only_if_exists */,
NULL /* ret_locations */);
if (local_help_path == NULL) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_INTERNAL,
_("Unable to find the GNOME_FILE_DOMAIN_APP_HELP domain"));
goto out;
}
global_help_path = gnome_program_locate_file (program,
GNOME_FILE_DOMAIN_HELP,
"",
FALSE /* only_if_exists */,
NULL /* ret_locations */);
if (global_help_path == NULL) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_INTERNAL,
_("Unable to find the GNOME_FILE_DOMAIN_HELP domain."));
goto out;
}
/* Try to access the help paths, first the app-specific help path
* and then falling back to the global help path if the first one fails.
*/
if (stat (local_help_path, &local_help_st) == 0) {
if (!S_ISDIR (local_help_st.st_mode)) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Unable to show help as %s is not a directory. "
"Please check your installation."),
local_help_path);
goto out;
}
file = locate_help_file (local_help_path, file_name);
}
if (file == NULL) {
if (stat (global_help_path, &global_help_st) == 0) {
if (!S_ISDIR (global_help_st.st_mode)) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Unable to show help as %s is not a directory. "
"Please check your installation."),
global_help_path);
goto out;
}
} else {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Unable to find the help files in either %s "
"or %s. Please check your installation"),
local_help_path,
global_help_path);
goto out;
}
if (!(local_help_st.st_dev == global_help_st.st_dev
&& local_help_st.st_ino == global_help_st.st_ino))
file = locate_help_file (global_help_path, file_name);
}
if (file == NULL) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Unable to find the help files in either %s "
"or %s. Please check your installation"),
local_help_path,
global_help_path);
goto out;
}
/* Now that we have a file name, try to display it in the help browser */
if (link_id)
uri = g_strconcat ("ghelp://", file, "?", link_id, NULL);
else
uri = g_strconcat ("ghelp://", file, NULL);
retval = egg_help_display_uri_with_env (uri, envp, error);
out:
g_free (local_help_path);
g_free (global_help_path);
g_free (file);
g_free (uri);
return retval;
}
static gboolean
egg_help_display_desktop_with_env (GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
char **envp,
GError **error)
{
GSList *ret_locations, *li;
char *file;
gboolean retval;
char *url;
g_return_val_if_fail (doc_id != NULL, FALSE);
g_return_val_if_fail (file_name != NULL, FALSE);
if (program == NULL)
program = gnome_program_get ();
ret_locations = NULL;
gnome_program_locate_file (program,
GNOME_FILE_DOMAIN_HELP,
doc_id,
FALSE /* only_if_exists */,
&ret_locations);
if (ret_locations == NULL) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Unable to find doc_id %s in the help path"),
doc_id);
return FALSE;
}
file = NULL;