Commit 3e6bfd6a authored by Mark McLoughlin's avatar Mark McLoughlin Committed by Mark McLoughlin

Merge the multihead branch into HEAD and :

2002-10-02  Mark McLoughlin  <mark@skynet.ie>

        * acconfig.h: define HAVE_GTK_MULTIHEAD for
        egg-screen-exec methods.

        * configure.in: require gtk 2.1.0 and don't
        define HAVE_GTK_MULTIHEAD.

        * libnautilus-private/nautilus-multihead-hacks.h: kill.

        * libnautilus-private/nautilus-directory-background:
        (make_root_pixmap), (set_root_pixmap): use
         gdk_screen_get_display instead of assuming the default
        display.

        * src/nautilus-shell.c: (restore_one_window_callback):
        add backwards compat support for sessions without
        a screen number.
parent 3fa3cfe9
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* acconfig.h: define HAVE_GTK_MULTIHEAD for
egg-screen-exec methods.
* configure.in: require gtk 2.1.0 and don't
define HAVE_GTK_MULTIHEAD.
* libnautilus-private/nautilus-multihead-hacks.h: kill.
* libnautilus-private/nautilus-directory-background:
(make_root_pixmap), (set_root_pixmap): use
gdk_screen_get_display instead of assuming the default
display.
* src/nautilus-shell.c: (restore_one_window_callback):
add backwards compat support for sessions without
a screen number.
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* libnautilus-private/nautilus-program-choosing.c:
(nautilus_launch_application_from_command):
s/eel_gnome_screen_exec/eel_gnome_exec..._on_screen/g
* src/file-manager/fm-desktop-icon-view.c:
(new_terminal_callback): ditto.
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* libnautilus-private/Makefile.am:
* libnautilus-private/egg-screen-help.[ch]:
* libnautilus-private/egg-screen-url.[ch]:
add the multiscreen variants of gnome-help from libegg.
* libnautilus-private/nautilus-multihead-hacks.h: add
gtk_window_get_screen.
* libnautilus-private/nautilus-program-chooser.c:
(help_cb): use egg_screen_help_display_desktop and use
the chooser window as the transient parent for the error
dialog.
* src/nautilus-bookmarks-window.c:
(nautilus_bookmarks_window_response_callback): use
egg_screen_help_display_desktop.
* src/nautilus-preferences-dialog.c: (preferences_show_help):
use egg_screen_help_display_desktop and use the prefs dialog
as the transient parent for the error dialog rather than
the help button.
* src/nautilus-property-browser.c: (help_button_callback):
use egg_screen_help_display_desktop.
* src/nautilus-window-menus.c:
(help_menu_nautilus_manual_callback): use
egg_screen_help_display_desktop and use the NautilusWindow as
the transient parent for the error dialog.
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* libnautilus-private/nautilus-directory-background.c:
(make_root_pixmap), (set_root_pixmap): don't pass
a screen number arg, pass a GdkScreen instead. Also,
fix bogus use of the default root window.
(image_loading_done_callback): update.
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* libnautilus-private/nautilus-icon-dnd.c:
(nautilus_icon_dnd_set_stipple): ref the new stipple
before unrefing the old.
* src/file-manager/fm-desktop-icon-view.c:
(icon_container_set_workarea): fix up sanity check.
2002-10-02 Mark McLoughlin <mark@skynet.ie>
* configure.in: check for gtk with multihead
support and define GTK_MULTIHEAD.
* components/tree/nautilus-tree-view.c:
(got_activation_uri_callback): launch applications on the
correct screen.
* libnautilus-private/Makefile.am: add egg-screen-exec.[ch]
to the build.
* libnautilus-private/nautilus-directory-background.c:
Make sure we're drawing the background on the correct
screen.
* libnautilus-private/nautilus-dnd.[ch]: (nautilus_drag_init),
(nautilus_drag_finalize): move the stipple from here into
icon-dnd, where its actually used.
* libnautilus-private/nautilus-icon-canvas-item.c:
(draw_stretch_handles): create the stipple on the correct
screen.
* libnautilus-private/nautilus-icon-container.c:
(realize): create the stipple here, but use eel_stipple
instead of homebrew.
* libnautilus-private/nautilus-icon-dnd.c:
(nautilus_icon_dnd_set_stipple): impl changing the stipple.
* libnautilus-private/nautilus-multihead-hacks.h: impl
A set of hacks to allow building with gtk+ 2.0.x and
not have loads of #ifdef HAVE_GTK_MULTIHEAD.
* libnautilus-private/nautilus-program-chooser.c:
Launch the mime capplet on the correct screen.
* libnautilus-private/nautilus-program-choosing.c:
Implement launching apps on the correct screen.
* src/file-manager/fm-desktop-icon-view.c:
(icon_container_set_workarea), (net_workarea_changed),
(desktop_icon_view_property_filter),
(fm_desktop_icon_view_finalize), (unrealized_callback),
(realized_callback), (fm_desktop_icon_view_init),
(new_terminal_callback), (new_launcher_callback),
(change_background_callback), (volume_ops_callback):
* src/file-manager/fm-directory-view.c: (edit_launcher),
(edit_launcher_callback), (new_launcher_callback),
(run_script_callback), (create_popup_menu), (activate_callback),
(fm_directory_view_move_copy_items):
* src/file-manager/fm-properties-window.c:
(create_properties_window), (fm_properties_window_present):
* src/nautilus-application.c:
(nautilus_application_create_desktop_windows): create a desktop
window on every screen.
(nautilus_application_create_window): realize the window on
the given screen.
(volume_mounted_callback): open a new window on the default
screen when a new volume is mounted.
* src/nautilus-desktop-window.c:
(nautilus_desktop_window_new): realize on the correct screen
using the dimensions of said screen.
(realize), (unrealize): set and unset NAUTILUS_DESKTOP_WINDOW_ID
on the RootWindow on the correct screen on realize and unrealize.
(set_wmspec_desktop_hint), (set_desktop_window_id): use
gdk_property_change.
* src/nautilus-preferences-dialog.c:
(nautilus_preferences_dialog_show): show the dialog on the correct
screen.
* src/nautilus-property-browser.c:
(nautilus_property_browser_new): realize on the correct screen.
(nautilus_property_browser_show): use a weak pointer instead
of destroy handler crack.
* src/nautilus-shell.c:
(open_window): open on the default screen.
(save_window_states), (restore_one_window_callback): save
and restore screen info across restart.
* src/nautilus-sidebar.c: (nautilus_sidebar_create_context_menu):
Pop the context menu up on the correct screen.
* src/nautilus-window-menus.c: bring everything up on the
correct screen.
* src/nautilus-window.c:
(nautilus_window_size_request): use the dimensions of the screen
upon which the window is realized.
2002-10-01 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-icon-container.c:
......
......@@ -20,3 +20,4 @@
#undef bzopen
#undef bzread
#undef bzwrite
#define HAVE_GTK_MULTIHEAD /* needed for egg-screen-exec functions */
......@@ -236,9 +236,12 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
{
char *uri, *file_uri;
NautilusTreeView *view;
GdkScreen *screen;
view = NAUTILUS_TREE_VIEW (callback_data);
screen = gtk_widget_get_screen (GTK_WIDGET (view->details->tree_widget));
g_assert (file == view->details->activation_file);
/* FIXME: reenable && !eel_uris_match_ignore_fragments (view->details->current_main_view_uri, uri) */
......@@ -248,13 +251,13 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
&& eel_str_has_prefix (uri, NAUTILUS_COMMAND_SPECIFIER)) {
uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
nautilus_launch_application_from_command (NULL, uri, NULL, FALSE);
nautilus_launch_application_from_command (screen, NULL, uri, NULL, FALSE);
} else if (uri != NULL
&& eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
file_uri = nautilus_file_get_uri (file);
nautilus_launch_desktop_file (file_uri, NULL, NULL);
nautilus_launch_desktop_file (screen, file_uri, NULL, NULL);
g_free (file_uri);
} else if (uri != NULL
......@@ -268,7 +271,7 @@ got_activation_uri_callback (NautilusFile *file, gpointer callback_data)
if (file_uri == NULL) {
nautilus_view_open_location_in_this_window (NAUTILUS_VIEW (view), uri);
} else {
nautilus_launch_application_from_command (NULL, file_uri, NULL, FALSE);
nautilus_launch_application_from_command (screen, NULL, file_uri, NULL, FALSE);
g_free (file_uri);
}
......
......@@ -14,7 +14,7 @@ GNOME_DESKTOP_REQUIRED=2.0.3
GNOME_REQUIRED=2.0.1
GNOME_UI_REQUIRED=2.1.0
GNOME_VFS_REQUIRED=1.9
GTK_REQUIRED=2.0.5
GTK_REQUIRED=2.1.0
MEDUSA_REQUIRED=0.5.1
RSVG_REQUIRED=2.0.1
XML_REQUIRED=2.4.7
......
......@@ -35,6 +35,15 @@ marshal_sources = \
nautilus-marshal-guts.c \
$(NULL)
EGGFILES = \
egg-screen-exec.h \
egg-screen-exec.c \
egg-screen-url.h \
egg-screen-url.c \
egg-screen-help.h \
egg-screen-help.c \
$(NULL)
libnautilus_private_la_SOURCES = \
$(nautilus_metafile_server_idl_sources) \
eggtreemultidnd.c \
......@@ -162,6 +171,7 @@ libnautilus_private_la_SOURCES = \
nautilus-view-identifier.h \
nautilus-volume-monitor.c \
nautilus-volume-monitor.h \
$(EGGFILES) \
$(NULL)
fsattributesdir = $(datadir)/nautilus
......@@ -197,6 +207,7 @@ EXTRA_DIST = \
$(fsattributes_DATA) \
nautilus-metafile-server.idl \
nautilus-marshal.list \
update-from-egg.sh \
$(schema_DATA) \
$(NULL)
......@@ -208,3 +219,8 @@ CLEANFILES = \
dist-hook:
cd $(distdir); rm -f $(CLEANFILES)
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;
/**
* 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;
#ifdef HAVE_GTK_MULTIHEAD
int display_index = -1;
g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL);
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;
}
/**
* 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 <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.
*/
/**
* egg_help_display_uri_with_env:
* @help_uri: The URI to display.
* @envp: child's environment, or %NULL to inherit parent's.
* @error: return location for errors.
*
* Description: Like gnome_help_display_uri, except that the help viewer
* application is launched with its environment set to the contents of
* @envp.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
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;
}
/**
* egg_help_display_with_doc_id_with_env:
* @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.
* @envp: child's environment, or %NULL to inherit parent's.
* @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(), except that the help
* viewer application is launched with its environment set to the contents
* of @envp.
*
* Returns: %TRUE on success, %FALSE otherwise (in which case @error will
* contain the actual error).
**/
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 */