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.
This commit is contained in:
Mark McLoughlin 2002-10-02 05:36:58 +00:00 committed by Mark McLoughlin
parent 3fa3cfe91a
commit 3e6bfd6af6
44 changed files with 1875 additions and 307 deletions

172
ChangeLog
View file

@ -1,3 +1,175 @@
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:

View file

@ -20,3 +20,4 @@
#undef bzopen
#undef bzread
#undef bzwrite
#define HAVE_GTK_MULTIHEAD /* needed for egg-screen-exec functions */

View file

@ -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);
}

View file

@ -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

View file

@ -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

View file

@ -0,0 +1,260 @@
/* 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
}

View file

@ -0,0 +1,46 @@
/* 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__ */

View file

@ -0,0 +1,487 @@
/* 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 */
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;
}
/**
* egg_help_display_desktop_with_env:
* @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.
* @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_desktop(), 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_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;
for (li = ret_locations; li != NULL; li = li->next) {
char *path = li->data;
file = locate_help_file (path, file_name);
if (file != NULL)
break;
}
g_slist_foreach (ret_locations, (GFunc)g_free, NULL);
g_slist_free (ret_locations);
if (file == NULL) {
g_set_error (error,
GNOME_HELP_ERROR,
GNOME_HELP_ERROR_NOT_FOUND,
_("Help document %s/%s not found"),
doc_id,
file_name);
return FALSE;
}
if (link_id != NULL) {
url = g_strconcat ("ghelp://", file, "?", link_id, NULL);
} else {
url = g_strconcat ("ghelp://", file, NULL);
}
g_free (file);
retval = egg_help_display_uri_with_env (url, envp, error);
return retval;
}
/******* END COPIED + PASTED CODE TO GO AWAY ******/
/**
* egg_screen_help_display:
* @screen: a #GdkScreen.
* @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.
* @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_screen_help_display (GdkScreen *screen,
const char *file_name,
const char *link_id,
GError **error)
{
return egg_screen_help_display_with_doc_id (
screen, NULL, NULL, file_name, link_id, error);
}
/**
* egg_screen_help_display_with_doc_id
* @screen: a #GdkScreen.
* @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.
* @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_screen_help_display_with_doc_id (GdkScreen *screen,
GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = egg_help_display_with_doc_id_with_env (
program, doc_id, file_name, link_id, env, error);
g_strfreev (env);
return retval;
}
/**
* egg_screen_help_display_desktop
* @screen: a #GdkScreen.
* @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.
* @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_screen_help_display_desktop (GdkScreen *screen,
GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = egg_help_display_desktop_with_env (
program, doc_id, file_name, link_id, env, error);
g_strfreev (env);
return retval;
}
/**
* egg_screen_help_display_uri
* @screen: a #GdkScreen.
* @help_uri: The URI to display.
* @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_screen_help_display_uri (GdkScreen *screen,
const char *help_uri,
GError **error)
{
gboolean retval;
char **env;
env = egg_screen_exec_environment (screen);
retval = egg_help_display_uri_with_env (help_uri, env, error);
g_strfreev (env);
return retval;
}

View file

@ -0,0 +1,75 @@
/* 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 libgnome.
*/
gboolean egg_help_display_uri_with_env (const char *help_uri,
char **envp,
GError **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);
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);
/* Destined for libgnomeui.
*/
gboolean egg_screen_help_display (GdkScreen *screen,
const char *file_name,
const char *link_id,
GError **error);
gboolean egg_screen_help_display_with_doc_id (GdkScreen *screen,
GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GError **error);
gboolean egg_screen_help_display_desktop (GdkScreen *screen,
GnomeProgram *program,
const char *doc_id,
const char *file_name,
const char *link_id,
GError **error);
gboolean egg_screen_help_display_uri (GdkScreen *screen,
const char *help_uri,
GError **error);
G_END_DECLS
#endif /* __EGG_SCREEN_HELP_H__ */

View file

@ -0,0 +1,183 @@
/* 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.
*
* 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-url.h"
#include <string.h>
#include <glib.h>
#include <glib-object.h>
#include <gconf/gconf-client.h>
#include <libgnome/gnome-url.h>
#include "egg-screen-exec.h"
/******* START COPIED + PASTED CODE TO GO AWAY ******/
#define URL_HANDLER_DIR "/desktop/gnome/url-handlers/"
#define DEFAULT_HANDLER_PATH "/desktop/gnome/url-handlers/unknown/command"
/* This needs to be exposed from libgnome and
* removed from here.
*/
/**
* egg_url_show_with_env:
* @url: The url to display. Should begin with the protocol to use (e.g.
* "http:", "ghelp:", etc)
* @envp: child's environment, or %NULL to inherit parent's.
* @error: Used to store any errors that result from trying to display the @url.
*
* Description: Like gnome_url_show(), except that the viewer application
* is launched with its environment set to the contents of @envp.
*
* Returns: %TRUE if everything went fine, %FALSE otherwise (in which case
* @error will contain the actual error).
**/
gboolean
egg_url_show_with_env (const char *url,
char **envp,
GError **error)
{
GConfClient *client;
gint i;
gchar *pos, *template;
int argc;
char **argv;
gboolean ret;
g_return_val_if_fail (url != NULL, FALSE);
pos = strchr (url, ':');
client = gconf_client_get_default ();
if (pos != NULL) {
gchar *protocol, *path;
g_return_val_if_fail (pos >= url, FALSE);
protocol = g_new (gchar, pos - url + 1);
strncpy (protocol, url, pos - url);
protocol[pos - url] = '\0';
g_ascii_strdown (protocol, -1);
path = g_strconcat (URL_HANDLER_DIR, protocol, "/command", NULL);
template = gconf_client_get_string (client, path, NULL);
if (template == NULL) {
gchar* template_temp;
template_temp = gconf_client_get_string (client,
DEFAULT_HANDLER_PATH,
NULL);
/* Retry to get the right url handler */
template = gconf_client_get_string (client, path, NULL);
if (template == NULL)
template = template_temp;
else
g_free (template_temp);
}
g_free (path);
g_free (protocol);
} else {
/* no ':' ? this shouldn't happen. Use default handler */
template = gconf_client_get_string (client,
DEFAULT_HANDLER_PATH,
NULL);
}
g_object_unref (G_OBJECT (client));
if (!g_shell_parse_argv (template,
&argc,
&argv,
error)) {
g_free (template);
return FALSE;
}
g_free (template);
for (i = 0; i < argc; i++) {
char *arg;
if (strcmp (argv[i], "%s") != 0)
continue;
arg = argv[i];
argv[i] = g_strdup (url);
g_free (arg);
}
/* This can return some errors */
ret = g_spawn_async (NULL /* working directory */,
argv,
envp,
G_SPAWN_SEARCH_PATH /* flags */,
NULL /* child_setup */,
NULL /* data */,
NULL /* child_pid */,
error);
g_strfreev (argv);
return ret;
}
/******* END COPIED + PASTED CODE TO GO AWAY ******/
/**
* egg_screen_url_show:
* @screen: a #GdkScreen.
* @url: The url to display. Should begin with the protocol to use (e.g.
* "http:", "ghelp:", etc)
* @error: Used to store any errors that result from trying to display the @url.
*
* Description: Like gnome_url_show(), but ensures that the viewer application
* appears on @screen.
*
* Returns: %TRUE if everything went fine, %FALSE otherwise (in which case
* @error will contain the actual error).
**/
gboolean
egg_screen_url_show (GdkScreen *screen,
const char *url,
GError **error)
{
char **env;
gboolean retval;
env = egg_screen_exec_environment (screen);
retval = egg_url_show_with_env (url, env, error);
g_strfreev (env);
return retval;
}

View file

@ -0,0 +1,44 @@
/* egg-screen-url.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_URL_H__
#define __EGG_SCREEN_URL_H__
#include <gdk/gdk.h>
G_BEGIN_DECLS
/* Destined for libgnome.
*/
gboolean egg_url_show_with_env (const char *url,
char **envp,
GError **error);
/* Destined for libgnomeui.
*/
gboolean egg_screen_url_show (GdkScreen *screen,
const char *url,
GError **error);
G_END_DECLS
#endif /* __EGG_SCREEN_URL_H__ */

View file

@ -81,6 +81,9 @@ desktop_background_realized (NautilusIconContainer *icon_container, void *discon
g_object_set_data (G_OBJECT (background), "icon_container", (gpointer) icon_container);
g_object_set_data (G_OBJECT (background), "screen",
gtk_widget_get_screen (GTK_WIDGET (icon_container)));
nautilus_file_update_desktop_pixmaps (background);
}
@ -422,16 +425,19 @@ nautilus_file_background_receive_gconf_changes (EelBackground *background)
* (copied from gnome-source/control-panels/capplets/background-properties/render-background.c)
*/
static GdkPixmap *
make_root_pixmap (gint width, gint height)
make_root_pixmap (GdkScreen *screen, gint width, gint height)
{
Display *display;
char *display_name;
const char *display_name;
Pixmap result;
GdkPixmap *gdk_pixmap;
int screen_num;
screen_num = gdk_screen_get_number (screen);
gdk_flush ();
display_name = DisplayString (GDK_DISPLAY ());
display_name = gdk_display_get_name (gdk_screen_get_display (screen));
display = XOpenDisplay (display_name);
if (display == NULL) {
@ -443,15 +449,15 @@ make_root_pixmap (gint width, gint height)
XSetCloseDownMode (display, RetainPermanent);
result = XCreatePixmap (display,
DefaultRootWindow (display),
RootWindow (display, screen_num),
width, height,
DefaultDepthOfScreen (DefaultScreenOfDisplay (GDK_DISPLAY())));
DefaultDepth (display, screen_num));
XCloseDisplay (display);
gdk_pixmap = gdk_pixmap_foreign_new (result);
gdk_drawable_set_colormap (GDK_DRAWABLE (gdk_pixmap),
gdk_drawable_get_colormap (gdk_get_default_root_window ()));
gdk_drawable_get_colormap (gdk_screen_get_root_window (screen)));
return gdk_pixmap;
}
@ -464,21 +470,26 @@ make_root_pixmap (gint width, gint height)
* (copied from gnome-source/control-panels/capplets/background-properties/render-background.c)
*/
static void
set_root_pixmap (GdkPixmap *pixmap)
set_root_pixmap (GdkPixmap *pixmap, GdkScreen *screen)
{
int result;
gint format;
gulong nitems;
gulong bytes_after;
guchar *data_esetroot;
Pixmap pixmap_id;
Atom type;
int result;
gint format;
gulong nitems;
gulong bytes_after;
guchar *data_esetroot;
Pixmap pixmap_id;
Atom type;
Display *display;
int screen_num;
screen_num = gdk_screen_get_number (screen);
data_esetroot = NULL;
display = GDK_DISPLAY_XDISPLAY (gdk_screen_get_display (screen));
XGrabServer (GDK_DISPLAY());
XGrabServer (display);
result = XGetWindowProperty (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
result = XGetWindowProperty (display, RootWindow (display, screen_num),
gdk_x11_get_xatom_by_name ("ESETROOT_PMAP_ID"),
0L, 1L, False, XA_PIXMAP,
&type, &format, &nitems, &bytes_after,
@ -487,7 +498,7 @@ set_root_pixmap (GdkPixmap *pixmap)
if (data_esetroot != NULL) {
if (result == Success && type == XA_PIXMAP && format == 32 && nitems == 1) {
gdk_error_trap_push ();
XKillClient(GDK_DISPLAY(), *(Pixmap *)data_esetroot);
XKillClient (display, *(Pixmap *)data_esetroot);
gdk_flush ();
gdk_error_trap_pop ();
}
@ -496,21 +507,21 @@ set_root_pixmap (GdkPixmap *pixmap)
pixmap_id = GDK_WINDOW_XWINDOW (pixmap);
XChangeProperty (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
XChangeProperty (display, RootWindow (display, screen_num),
gdk_x11_get_xatom_by_name ("ESETROOT_PMAP_ID"), XA_PIXMAP,
32, PropModeReplace,
(guchar *) &pixmap_id, 1);
XChangeProperty (GDK_DISPLAY(), GDK_ROOT_WINDOW(),
XChangeProperty (display, RootWindow (display, screen_num),
gdk_x11_get_xatom_by_name ("_XROOTPMAP_ID"), XA_PIXMAP,
32, PropModeReplace,
(guchar *) &pixmap_id, 1);
XSetWindowBackgroundPixmap (GDK_DISPLAY (), GDK_ROOT_WINDOW (), pixmap_id);
XClearWindow (GDK_DISPLAY (), GDK_ROOT_WINDOW ());
XSetWindowBackgroundPixmap (display, RootWindow (display, screen_num), pixmap_id);
XClearWindow (display, RootWindow (display, screen_num));
XUngrabServer (GDK_DISPLAY());
XUngrabServer (display);
XFlush(GDK_DISPLAY());
XFlush (display);
}
static void
@ -521,6 +532,7 @@ image_loading_done_callback (EelBackground *background, gboolean successful_load
GdkGC *gc;
GdkPixmap *pixmap;
GdkWindow *background_window;
GdkScreen *screen;
if (GPOINTER_TO_INT (disconnect_signal)) {
g_signal_handlers_disconnect_by_func
@ -529,10 +541,13 @@ image_loading_done_callback (EelBackground *background, gboolean successful_load
disconnect_signal);
}
width = gdk_screen_width ();
height = gdk_screen_height ();
screen = g_object_get_data (G_OBJECT (background), "screen");
if (screen == NULL)
return;
width = gdk_screen_get_width (screen);
height = gdk_screen_get_height (screen);
pixmap = make_root_pixmap (width, height);
pixmap = make_root_pixmap (screen, width, height);
if (pixmap == NULL) {
return;
}
@ -541,7 +556,7 @@ image_loading_done_callback (EelBackground *background, gboolean successful_load
eel_background_draw_to_drawable (background, pixmap, gc, 0, 0, width, height, width, height);
g_object_unref (gc);
set_root_pixmap (pixmap);
set_root_pixmap (pixmap, screen);
background_window = background_get_desktop_background_window (background);
if (background_window != NULL &&

View file

@ -69,16 +69,11 @@
void
nautilus_drag_init (NautilusDragInfo *drag_info,
const GtkTargetEntry *drag_types,
int drag_type_count,
GdkBitmap *stipple)
int drag_type_count)
{
drag_info->target_list = gtk_target_list_new (drag_types,
drag_type_count);
if (stipple != NULL) {
drag_info->stipple = g_object_ref (stipple);
}
drag_info->drop_occured = FALSE;
drag_info->need_to_destroy = FALSE;
}
@ -89,10 +84,6 @@ nautilus_drag_finalize (NautilusDragInfo *drag_info)
gtk_target_list_unref (drag_info->target_list);
nautilus_drag_destroy_selection_list (drag_info->selection_list);
if (drag_info->stipple != NULL) {
g_object_unref (drag_info->stipple);
}
g_free (drag_info);
}

View file

@ -81,9 +81,6 @@ typedef struct {
*/
GList *selection_list;
/* Stipple for drawing icon shadows during DnD. */
GdkBitmap *stipple;
/* has the drop occured ? */
gboolean drop_occured;
@ -106,8 +103,7 @@ typedef void (* NautilusDragEachSelectedItemIterator) (NautilusDragEachSelecte
void nautilus_drag_init (NautilusDragInfo *drag_info,
const GtkTargetEntry *drag_types,
int drag_type_count,
GdkBitmap *stipple);
int drag_type_count);
void nautilus_drag_finalize (NautilusDragInfo *drag_info);
NautilusDragSelectionItem *nautilus_drag_selection_item_new (void);
void nautilus_drag_destroy_selection_list (GList *selection_list);

View file

@ -912,6 +912,7 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
GdkGC *gc;
char *knob_filename;
GdkPixbuf *knob_pixbuf;
GdkBitmap *stipple;
int knob_width, knob_height;
if (!item->details->show_stretch_handles) {
@ -924,9 +925,12 @@ draw_stretch_handles (NautilusIconCanvasItem *item, GdkDrawable *drawable,
knob_pixbuf = gdk_pixbuf_new_from_file (knob_filename, NULL);
knob_width = gdk_pixbuf_get_width (knob_pixbuf);
knob_height = gdk_pixbuf_get_height (knob_pixbuf);
stipple = eel_stipple_bitmap_for_screen (
gdk_drawable_get_screen (GDK_DRAWABLE (drawable)));
/* first draw the box */
gdk_gc_set_stipple (gc, eel_stipple_bitmap ());
gdk_gc_set_stipple (gc, stipple);
gdk_gc_set_fill (gc, GDK_STIPPLED);
gdk_draw_rectangle
(drawable, gc, FALSE,

View file

@ -206,10 +206,6 @@ enum {
};
static guint signals[LAST_SIGNAL];
/* Bitmap for stippled selection rectangles. */
static GdkBitmap *stipple;
static char stipple_bits[] = { 0x02, 0x01 };
/* Functions dealing with NautilusIcons. */
static void
@ -2482,6 +2478,7 @@ static void
realize (GtkWidget *widget)
{
GtkWindow *window;
GdkBitmap *stipple;
GTK_WIDGET_CLASS (parent_class)->realize (widget);
@ -2491,6 +2488,11 @@ realize (GtkWidget *widget)
g_assert (GTK_IS_WINDOW (gtk_widget_get_toplevel (widget)));
window = GTK_WINDOW (gtk_widget_get_toplevel (widget));
gtk_window_set_focus (window, widget);
stipple = eel_stipple_bitmap_for_screen (
gdk_drawable_get_screen (GDK_DRAWABLE (widget->window)));
nautilus_icon_dnd_set_stipple (NAUTILUS_ICON_CONTAINER (widget), stipple);
}
static void
@ -3471,10 +3473,6 @@ nautilus_icon_container_class_init (NautilusIconContainerClass *class)
widget_class->style_set = style_set;
widget_class->expose_event = expose_event;
/* Initialize the stipple bitmap. */
stipple = gdk_bitmap_create_from_data (NULL, stipple_bits, 2, 2);
eel_preferences_add_auto_enum (NAUTILUS_PREFERENCES_CLICK_POLICY,
&click_policy_auto_value);
@ -3518,7 +3516,7 @@ nautilus_icon_container_instance_init (NautilusIconContainer *container)
container->details = details;
/* Set up DnD. */
nautilus_icon_dnd_init (container, stipple);
nautilus_icon_dnd_init (container, NULL);
/* Make sure that we find out if the icons change. */
g_signal_connect_object

View file

@ -98,7 +98,7 @@ create_selection_shadow (NautilusIconContainer *container,
return NULL;
}
stipple = container->details->dnd_info->drag_info.stipple;
stipple = container->details->dnd_info->stipple;
g_return_val_if_fail (stipple != NULL, NULL);
canvas = EEL_CANVAS (container);
@ -1384,6 +1384,21 @@ drag_data_received_callback (GtkWidget *widget,
}
void
nautilus_icon_dnd_set_stipple (NautilusIconContainer *container,
GdkBitmap *stipple)
{
if (stipple != NULL) {
g_object_ref (stipple);
}
if (container->details->dnd_info->stipple != NULL) {
g_object_unref (container->details->dnd_info->stipple);
}
container->details->dnd_info->stipple = stipple;
}
void
nautilus_icon_dnd_init (NautilusIconContainer *container,
GdkBitmap *stipple)
@ -1394,7 +1409,7 @@ nautilus_icon_dnd_init (NautilusIconContainer *container,
container->details->dnd_info = g_new0 (NautilusIconDndInfo, 1);
nautilus_drag_init (&container->details->dnd_info->drag_info,
drag_types, G_N_ELEMENTS (drag_types), stipple);
drag_types, G_N_ELEMENTS (drag_types));
/* Set up the widget as a drag destination.
* (But not a source, as drags starting from this widget will be
@ -1421,6 +1436,9 @@ nautilus_icon_dnd_init (NautilusIconContainer *container,
g_signal_connect (container, "drag_leave",
G_CALLBACK (drag_leave_callback), NULL);
if (stipple != NULL) {
container->details->dnd_info->stipple = g_object_ref (stipple);
}
}
void
@ -1431,6 +1449,10 @@ nautilus_icon_dnd_fini (NautilusIconContainer *container)
if (container->details->dnd_info != NULL) {
stop_auto_scroll (container);
if (container->details->dnd_info->stipple != NULL) {
g_object_unref (container->details->dnd_info->stipple);
}
nautilus_drag_finalize (&container->details->dnd_info->drag_info);
container->details->dnd_info = NULL;
}

View file

@ -36,6 +36,9 @@ typedef struct {
/* inherited drag info context */
NautilusDragInfo drag_info;
/* Stipple for drawing icon shadows during DnD. */
GdkBitmap *stipple;
/* Shadow for the icons being dragged. */
EelCanvasItem *shadow;
} NautilusIconDndInfo;
@ -44,6 +47,8 @@ typedef struct {
void nautilus_icon_dnd_init (NautilusIconContainer *container,
GdkBitmap *stipple);
void nautilus_icon_dnd_fini (NautilusIconContainer *container);
void nautilus_icon_dnd_set_stipple (NautilusIconContainer *container,
GdkBitmap *stipple);
void nautilus_icon_dnd_begin_drag (NautilusIconContainer *container,
GdkDragAction actions,
gint button,

View file

@ -32,6 +32,7 @@
#include "nautilus-mime-actions.h"
#include "nautilus-program-choosing.h"
#include "nautilus-view-identifier.h"
#include "egg-screen-help.h"
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-gtk-macros.h>
@ -180,15 +181,13 @@ help_cb (GtkWidget *button, NautilusProgramChooser *program_chooser)
break;
}
gnome_help_display_desktop (NULL,
"user-guide",
"wgosnautilus.xml",
section,
&error);
egg_screen_help_display_desktop (
gtk_window_get_screen (GTK_WINDOW (program_chooser)),
NULL, "user-guide", "wgosnautilus.xml", section, &error);
if (error) {
GtkWidget *err_dialog;
err_dialog = gtk_message_dialog_new (GTK_WINDOW (gtk_widget_get_toplevel (button)),
err_dialog = gtk_message_dialog_new (GTK_WINDOW (program_chooser),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
@ -961,10 +960,14 @@ set_default_for_item (ProgramFilePair *pair)
}
static void
launch_mime_capplet (NautilusFile *file)
launch_mime_capplet (NautilusFile *file,
GtkDialog *parent_dialog)
{
GdkScreen *screen;
char *command, *tmp, *mime_type, *file_name;
screen = gtk_window_get_screen (GTK_WINDOW (parent_dialog));
tmp = nautilus_file_get_mime_type (file);
mime_type = g_shell_quote (tmp);
g_free (tmp);
@ -973,7 +976,8 @@ launch_mime_capplet (NautilusFile *file)
g_free (tmp);
command = g_strconcat (FILE_TYPES_CAPPLET_NAME, " ", mime_type, " ", file_name, NULL);
nautilus_launch_application_from_command (FILE_TYPES_CAPPLET_NAME, command, NULL, FALSE);
nautilus_launch_application_from_command (screen, FILE_TYPES_CAPPLET_NAME, command, NULL, FALSE);
g_free (command);
g_free (file_name);
g_free (mime_type);
@ -985,7 +989,7 @@ launch_mime_capplet_on_ok (GtkDialog *dialog, int response, gpointer callback_da
g_assert (GTK_IS_DIALOG (dialog));
if (response == GTK_RESPONSE_YES) {
launch_mime_capplet (callback_data);
launch_mime_capplet (callback_data, dialog);
}
gtk_object_destroy (GTK_OBJECT (dialog));
}
@ -998,7 +1002,7 @@ launch_mime_capplet_and_close_dialog (GtkButton *button, gpointer callback_data)
g_assert (GTK_IS_BUTTON (button));
file_pair = get_selected_program_file_pair (NAUTILUS_PROGRAM_CHOOSER (callback_data));
launch_mime_capplet (file_pair->file);
launch_mime_capplet (file_pair->file, GTK_DIALOG (callback_data));
gtk_dialog_response (GTK_DIALOG (callback_data),
GTK_RESPONSE_DELETE_EVENT);
}

View file

@ -29,6 +29,7 @@
#include "nautilus-mime-actions.h"
#include "nautilus-program-chooser.h"
#include "nautilus-global-preferences.h"
#include "egg-screen-exec.h"
#include <eel/eel-glib-extensions.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-vfs-extensions.h>
@ -539,8 +540,9 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
NautilusFile *file,
GtkWindow *parent_window)
{
char *parameter;
char *uri_scheme, *uri;
GdkScreen *screen;
char *parameter;
char *uri_scheme, *uri;
uri_scheme = nautilus_file_get_uri_scheme (file);
@ -586,7 +588,10 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
}
g_free (uri_scheme);
nautilus_launch_application_from_command (application->name,
screen = gtk_window_get_screen (parent_window);
nautilus_launch_application_from_command (screen,
application->name,
application->command,
parameter,
application->requires_terminal);
@ -607,7 +612,8 @@ nautilus_launch_application (GnomeVFSMimeApplication *application,
* @parameter: Passed as a parameter to the application as is.
*/
void
nautilus_launch_application_from_command (const char *name,
nautilus_launch_application_from_command (GdkScreen *screen,
const char *name,
const char *command_string,
const char *parameter,
gboolean use_terminal)
@ -624,18 +630,19 @@ nautilus_launch_application_from_command (const char *name,
}
if (use_terminal) {
eel_gnome_open_terminal (full_command);
eel_gnome_open_terminal_on_screen (full_command, screen);
} else {
eel_gnome_shell_execute (full_command);
eel_gnome_shell_execute_on_screen (full_command, screen);
}
g_free (full_command);
}
void
nautilus_launch_desktop_file (const char *desktop_file_uri,
const GList *parameter_uris,
GtkWindow *parent_window)
nautilus_launch_desktop_file (GdkScreen *screen,
const char *desktop_file_uri,
const GList *parameter_uris,
GtkWindow *parent_window)
{
GError *error;
GnomeDesktopItem *ditem;
@ -644,6 +651,7 @@ nautilus_launch_desktop_file (const char *desktop_file_uri,
char *local_path, *message;
const GList *p;
int total, count;
char **envp;
/* strip the leading command specifier */
if (eel_str_has_prefix (desktop_file_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
@ -721,6 +729,8 @@ nautilus_launch_desktop_file (const char *desktop_file_uri,
parent_window);
}
}
envp = egg_screen_exec_environment (screen);
/* we append local paths only if all parameters are local */
if (count == total) {
@ -730,10 +740,9 @@ nautilus_launch_desktop_file (const char *desktop_file_uri,
}
error = NULL;
gnome_desktop_item_launch (ditem, (GList *) parameter_uris,
flags,
&error);
gnome_desktop_item_launch_with_env (ditem, (GList *) parameter_uris,
flags, envp,
&error);
if (error != NULL) {
message = g_strconcat (_("There was an error launching the application.\n\n"
"Details: "), error->message, NULL);
@ -747,4 +756,5 @@ nautilus_launch_desktop_file (const char *desktop_file_uri,
}
gnome_desktop_item_unref (ditem);
g_strfreev (envp);
}

View file

@ -56,12 +56,14 @@ void nautilus_cancel_choose_component_for_file (NautilusFile
void nautilus_launch_application (GnomeVFSMimeApplication *application,
NautilusFile *file,
GtkWindow *parent_window);
void nautilus_launch_application_from_command (const char *name,
void nautilus_launch_application_from_command (GdkScreen *screen,
const char *name,
const char *command_string,
const char *parameter,
gboolean use_terminal);
void nautilus_launch_desktop_file (const char *desktop_file_uri,
const GList *parameter_uris,
GtkWindow *parent_window);
void nautilus_launch_desktop_file (GdkScreen *screen,
const char *desktop_file_uri,
const GList *parameter_uris,
GtkWindow *parent_window);
#endif /* NAUTILUS_PROGRAM_CHOOSING_H */

View file

@ -0,0 +1,25 @@
#!/bin/sh
function die() {
echo $*
exit 1
}
if test -z "$EGGDIR"; then
echo "Must set EGGDIR"
exit 1
fi
if test -z "$EGGFILES"; then
echo "Must set EGGFILES"
exit 1
fi
for FILE in $EGGFILES; do
if cmp -s $EGGDIR/$FILE $FILE; then
echo "File $FILE is unchanged"
else
cp $EGGDIR/$FILE $FILE || die "Could not move $EGGDIR/$FILE to $FILE"
echo "Updated $FILE"
fi
done

View file

@ -45,6 +45,7 @@
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-util.h>
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-private/egg-screen-exec.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
#include <libnautilus-private/nautilus-directory-background.h>
#include <libnautilus-private/nautilus-directory-notify.h>
@ -85,6 +86,7 @@ struct FMDesktopIconViewDetails
{
BonoboUIComponent *ui;
GList *mount_black_list;
GdkWindow *root_window;
/* For the desktop rescanning
*/
@ -153,6 +155,7 @@ get_icon_container (FMDesktopIconView *icon_view)
static void
icon_container_set_workarea (NautilusIconContainer *icon_container,
GdkScreen *screen,
long *workareas,
int n_items)
{
@ -162,8 +165,8 @@ icon_container_set_workarea (NautilusIconContainer *icon_container,
left = right = top = bottom = 0;
screen_width = gdk_screen_width ();
screen_height = gdk_screen_height ();
screen_width = gdk_screen_get_width (screen);
screen_height = gdk_screen_get_height (screen);
for (i = 0; i < n_items; i += 4) {
int x = workareas [i];
@ -171,6 +174,9 @@ icon_container_set_workarea (NautilusIconContainer *icon_container,
int width = workareas [i + 2];
int height = workareas [i + 3];
if ((x + width) > screen_width || (y + height) > screen_height)
continue;
left = MAX (left, x);
right = MAX (right, screen_width - width - x);
top = MAX (top, y);
@ -182,49 +188,48 @@ icon_container_set_workarea (NautilusIconContainer *icon_container,
}
static void
net_workarea_changed (FMDesktopIconView *icon_view)
net_workarea_changed (FMDesktopIconView *icon_view,
GdkWindow *window)
{
long *workareas = NULL;
Atom type_returned;
GdkAtom type_returned;
int format_returned;
unsigned long items_returned;
unsigned long bytes_after_return;
int length_returned;
NautilusIconContainer *icon_container;
GdkScreen *screen;
g_return_if_fail (FM_IS_DESKTOP_ICON_VIEW (icon_view));
icon_container = get_icon_container (icon_view);
gdk_error_trap_push ();
if (XGetWindowProperty (GDK_DISPLAY (),
GDK_ROOT_WINDOW (),
gdk_x11_get_xatom_by_name ("_NET_WORKAREA"),
0, G_MAXLONG, False,
XA_CARDINAL,
&type_returned,
&format_returned,
&items_returned,
&bytes_after_return,
(unsigned char **)&workareas) != Success) {
if (workareas != NULL)
XFree (workareas);
if (!gdk_property_get (window,
gdk_atom_intern ("_NET_WORKAREA", FALSE),
gdk_x11_xatom_to_atom (XA_CARDINAL),
0, G_MAXLONG, FALSE,
&type_returned,
&format_returned,
&length_returned,
(guchar **) &workareas)) {
workareas = NULL;
}
if (gdk_error_trap_pop ()
|| workareas == NULL
|| type_returned != XA_CARDINAL
|| (items_returned % 4) != 0
|| type_returned != gdk_x11_xatom_to_atom (XA_CARDINAL)
|| (length_returned % 4) != 0
|| format_returned != 32) {
nautilus_icon_container_set_margins (icon_container,
0, 0, 0, 0);
} else {
screen = gdk_drawable_get_screen (GDK_DRAWABLE (window));
icon_container_set_workarea (
icon_container, workareas, items_returned);
icon_container, screen, workareas, length_returned / sizeof (long));
}
if (workareas != NULL)
XFree (workareas);
g_free (workareas);
}
static GdkFilterReturn
@ -240,7 +245,7 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent,
switch (xevent->type) {
case PropertyNotify:
if (xevent->xproperty.atom == gdk_x11_get_xatom_by_name ("_NET_WORKAREA"))
net_workarea_changed (icon_view);
net_workarea_changed (icon_view, event->any.window);
break;
default:
break;
@ -256,11 +261,6 @@ fm_desktop_icon_view_finalize (GObject *object)
icon_view = FM_DESKTOP_ICON_VIEW (object);
/* Remove the property filter */
gdk_window_remove_filter (gdk_get_default_root_window (),
desktop_icon_view_property_filter,
icon_view);
/* Remove desktop rescan timeout. */
if (icon_view->details->reload_desktop_timeout != 0) {
gtk_timeout_remove (icon_view->details->reload_desktop_timeout);
@ -496,6 +496,38 @@ event_callback (GtkWidget *widget, GdkEvent *event, FMDesktopIconView *desktop_i
{
}
static void
unrealized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
{
g_return_if_fail (desktop_icon_view->details->root_window != NULL);
/* Remove the property filter */
gdk_window_remove_filter (desktop_icon_view->details->root_window,
desktop_icon_view_property_filter,
desktop_icon_view);
desktop_icon_view->details->root_window = NULL;
}
static void
realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
{
GdkWindow *root_window;
g_return_if_fail (desktop_icon_view->details->root_window == NULL);
root_window = gdk_screen_get_root_window (gtk_widget_get_screen (widget));
desktop_icon_view->details->root_window = root_window;
/* Read out the workarea geometry and update the icon container accordingly */
net_workarea_changed (desktop_icon_view, root_window);
/* Setup the property filter */
gdk_window_set_events (root_window, GDK_PROPERTY_NOTIFY);
gdk_window_add_filter (root_window,
desktop_icon_view_property_filter,
desktop_icon_view);
}
static NautilusZoomLevel
get_default_zoom_level (void)
@ -694,6 +726,10 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
G_CALLBACK (volume_mounted_callback), desktop_icon_view, 0);
g_signal_connect_object (nautilus_volume_monitor_get (), "volume_unmounted",
G_CALLBACK (volume_unmounted_callback), desktop_icon_view, 0);
g_signal_connect_object (desktop_icon_view, "realize",
G_CALLBACK (realized_callback), desktop_icon_view, 0);
g_signal_connect_object (desktop_icon_view, "unrealize",
G_CALLBACK (unrealized_callback), desktop_icon_view, 0);
eel_preferences_add_callback (NAUTILUS_PREFERENCES_HOME_URI,
home_uri_changed,
@ -709,32 +745,27 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
default_zoom_level_changed (desktop_icon_view);
fm_desktop_icon_view_update_icon_container_fonts (desktop_icon_view);
/* Read out the workarea geometry and update the icon container accordingly */
net_workarea_changed (desktop_icon_view);
/* Setup the property filter */
XSelectInput (GDK_DISPLAY (), GDK_ROOT_WINDOW (), PropertyChangeMask);
gdk_window_add_filter (gdk_get_default_root_window (),
desktop_icon_view_property_filter,
desktop_icon_view);
}
static void
new_terminal_callback (BonoboUIComponent *component, gpointer data, const char *verb)
{
eel_gnome_open_terminal (NULL);
g_assert (FM_DIRECTORY_VIEW (data));
eel_gnome_open_terminal_on_screen (NULL, gtk_widget_get_screen (GTK_WIDGET (data)));
}
static void
new_launcher_callback (BonoboUIComponent *component, gpointer data, const char *verb)
{
char *desktop_directory;
g_assert (FM_DIRECTORY_VIEW (data));
desktop_directory = nautilus_get_desktop_directory ();
nautilus_launch_application_from_command ("gnome-desktop-item-edit",
nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
"gnome-desktop-item-edit",
"gnome-desktop-item-edit --create-new",
desktop_directory,
FALSE);
@ -747,9 +778,13 @@ change_background_callback (BonoboUIComponent *component,
gpointer data,
const char *verb)
{
nautilus_launch_application_from_command
(_("Background"),
"gnome-background-properties", NULL, FALSE);
g_assert (FM_DIRECTORY_VIEW (data));
nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (data)),
_("Background"),
"gnome-background-properties",
NULL,
FALSE);
}
static void
@ -856,7 +891,7 @@ volume_ops_callback (BonoboUIComponent *component, gpointer data, const char *ve
gboolean status;
GError *error;
GtkWidget *dialog;
GdkScreen *screen;
g_assert (FM_IS_DIRECTORY_VIEW (data));
@ -940,13 +975,17 @@ volume_ops_callback (BonoboUIComponent *component, gpointer data, const char *ve
if (command) {
error = NULL;
status = g_spawn_command_line_async (command, &error);
screen = gtk_widget_get_screen (GTK_WIDGET (view));
status = egg_screen_execute_command_line_async (screen, command, &error);
if (!status) {
dialog = gtk_message_dialog_new (NULL, 0,
GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE,
_("Error executing utility program '%s': %s"), command, error->message);
g_signal_connect (G_OBJECT (dialog), "response",
G_CALLBACK (gtk_widget_destroy), NULL);
gtk_window_set_screen (GTK_WINDOW (dialog), screen);
gtk_widget_show (dialog);
g_error_free (error);
}

View file

@ -61,6 +61,7 @@
#include <libgnomevfs/gnome-vfs-result.h>
#include <libgnomevfs/gnome-vfs-uri.h>
#include <libgnomevfs/gnome-vfs-utils.h>
#include <libnautilus-private/egg-screen-exec.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
#include <libnautilus-private/nautilus-directory-background.h>
#include <libnautilus-private/nautilus-directory.h>
@ -747,13 +748,15 @@ other_viewer_callback (BonoboUIComponent *component, gpointer callback_data, con
}
static void
edit_launcher (NautilusFile *file)
edit_launcher (FMDirectoryView *view,
NautilusFile *file)
{
char *uri;
uri = nautilus_file_get_uri (file);
nautilus_launch_application_from_command ("gnome-desktop-item-edit",
nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (view)),
"gnome-desktop-item-edit",
"gnome-desktop-item-edit",
uri,
FALSE);
@ -773,7 +776,7 @@ edit_launcher_callback (BonoboUIComponent *component, gpointer callback_data, co
selection = fm_directory_view_get_selection (view);
if (selection_contains_one_item_in_menu_callback (view, selection)) {
edit_launcher (NAUTILUS_FILE (selection->data));
edit_launcher (view, NAUTILUS_FILE (selection->data));
}
nautilus_file_list_free (selection);
@ -968,7 +971,8 @@ new_launcher_callback (BonoboUIComponent *component, gpointer callback_data, con
parent_uri = fm_directory_view_get_uri (view);
nautilus_launch_application_from_command ("gnome-desktop-item-edit",
nautilus_launch_application_from_command (gtk_widget_get_screen (GTK_WIDGET (view)),
"gnome-desktop-item-edit",
"gnome-desktop-item-edit --create-new",
parent_uri,
FALSE);
@ -3607,6 +3611,7 @@ static void
run_script_callback (BonoboUIComponent *component, gpointer callback_data, const char *path)
{
ScriptLaunchParameters *launch_parameters;
GdkScreen *screen;
GList *selected_files;
char *file_uri;
char *local_file_path;
@ -3645,9 +3650,11 @@ run_script_callback (BonoboUIComponent *component, gpointer callback_data, const
command = g_strdup (quoted_path);
}
screen = gtk_widget_get_screen (GTK_WIDGET (launch_parameters->directory_view));
name = nautilus_file_get_name (launch_parameters->file);
/* FIXME: handle errors with dialog? Or leave up to each script? */
nautilus_launch_application_from_command (name, command, NULL, FALSE);
nautilus_launch_application_from_command (screen, name, command, NULL, FALSE);
g_free (name);
g_free (command);
@ -3923,6 +3930,7 @@ create_popup_menu (FMDirectoryView *view, const char *popup_path)
GtkMenu *menu;
menu = GTK_MENU (gtk_menu_new ());
gtk_menu_set_screen (menu, gtk_widget_get_screen (GTK_WIDGET (view)));
gtk_widget_show (GTK_WIDGET (menu));
bonobo_window_add_popup (get_bonobo_window (view), menu, popup_path);
@ -4676,6 +4684,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
char *executable_path, *quoted_path, *name;
GnomeVFSMimeApplication *application;
ActivationAction action;
GdkScreen *screen;
parameters = callback_data;
@ -4687,6 +4696,8 @@ activate_callback (NautilusFile *file, gpointer callback_data)
action = ACTIVATION_ACTION_DISPLAY;
screen = gtk_widget_get_screen (GTK_WIDGET (view));
/* Note that we check for FILE_TYPE_SYMBOLIC_LINK only here,
* not specifically for broken-ness, because the file type
* will be the target's file type in the non-broken case.
@ -4696,14 +4707,14 @@ activate_callback (NautilusFile *file, gpointer callback_data)
action = ACTIVATION_ACTION_DO_NOTHING;
} else if (eel_str_has_prefix (uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
file_uri = nautilus_file_get_uri (file);
nautilus_launch_desktop_file
(file_uri, NULL,
fm_directory_view_get_containing_window (view));
nautilus_launch_desktop_file (
screen, file_uri, NULL,
fm_directory_view_get_containing_window (view));
g_free (file_uri);
action = ACTIVATION_ACTION_DO_NOTHING;
} else if (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);
action = ACTIVATION_ACTION_DO_NOTHING;
}
@ -4736,7 +4747,7 @@ activate_callback (NautilusFile *file, gpointer callback_data)
quoted_path = g_shell_quote (executable_path);
name = nautilus_file_get_name (file);
nautilus_launch_application_from_command
(name, quoted_path, NULL,
(screen, name, quoted_path, NULL,
(action == ACTIVATION_ACTION_LAUNCH_IN_TERMINAL) /* use terminal */ );
g_free (name);
g_free (quoted_path);
@ -5533,9 +5544,10 @@ fm_directory_view_move_copy_items (const GList *item_uris,
/* special-case "command:" here instead of starting a move/copy */
if (eel_str_has_prefix (target_uri, NAUTILUS_DESKTOP_COMMAND_SPECIFIER)) {
nautilus_launch_desktop_file
(target_uri, item_uris,
fm_directory_view_get_containing_window (view));
nautilus_launch_desktop_file (
gtk_widget_get_screen (GTK_WIDGET (view)),
target_uri, item_uris,
fm_directory_view_get_containing_window (view));
return;
} else if (eel_str_has_prefix (target_uri, NAUTILUS_COMMAND_SPECIFIER)) {
parameters = NULL;
@ -5548,7 +5560,10 @@ fm_directory_view_move_copy_items (const GList *item_uris,
}
target_uri += strlen (NAUTILUS_COMMAND_SPECIFIER);
nautilus_launch_application_from_command (NULL, target_uri, parameters, FALSE);
nautilus_launch_application_from_command (
gtk_widget_get_screen (GTK_WIDGET (view)),
NULL, target_uri, parameters, FALSE);
g_free (parameters);
return;

View file

@ -2166,6 +2166,8 @@ create_properties_window (StartupData *startup_data)
gtk_container_set_border_width (GTK_CONTAINER (window), GNOME_PAD);
gtk_window_set_wmclass (GTK_WINDOW (window), "file_properties", "Nautilus");
gtk_window_set_screen (GTK_WINDOW (window),
gtk_widget_get_screen (GTK_WIDGET (startup_data->directory_view)));
/* Set initial window title */
update_properties_window_title (GTK_WINDOW (window), window->details->target_file);
@ -2369,6 +2371,8 @@ fm_properties_window_present (NautilusFile *original_file, FMDirectoryView *dire
/* Look to see if there's already a window for this file. */
existing_window = g_hash_table_lookup (windows, original_file);
if (existing_window != NULL) {
gtk_window_set_screen (existing_window,
gtk_widget_get_screen (GTK_WIDGET (directory_view)));
gtk_window_present (existing_window);
return;
}

View file

@ -76,8 +76,8 @@
#define SEARCH_LIST_VIEW_IID "OAFIID:Nautilus_File_Manager_Search_List_View"
#define SHELL_IID "OAFIID:Nautilus_Shell"
/* Keeps track of the one and only desktop window. */
static NautilusDesktopWindow *nautilus_application_desktop_window;
/* Keeps track of all the desktop windows. */
static GList *nautilus_application_desktop_windows;
/* Keeps track of all the nautilus windows. */
static GList *nautilus_application_window_list;
@ -577,11 +577,14 @@ nautilus_application_startup (NautilusApplication *application,
}
static void
nautilus_application_create_desktop_window (NautilusApplication *application)
nautilus_application_create_desktop_windows (NautilusApplication *application)
{
static gboolean create_in_progress = FALSE;
GdkDisplay *display;
NautilusDesktopWindow *window;
int screens, i;
g_return_if_fail (nautilus_application_desktop_window == NULL);
g_return_if_fail (nautilus_application_desktop_windows == NULL);
g_return_if_fail (NAUTILUS_IS_APPLICATION (application));
if (create_in_progress) {
@ -590,12 +593,21 @@ nautilus_application_create_desktop_window (NautilusApplication *application)
create_in_progress = TRUE;
nautilus_application_desktop_window = nautilus_desktop_window_new (application);
/* We realize it immediately so that the NAUTILUS_DESKTOP_WINDOW_ID
property is set so gnome-settings-daemon doesn't try to set the
background. And we do a gdk_flush() to be sure X gets it. */
gtk_widget_realize (GTK_WIDGET (nautilus_application_desktop_window));
gdk_flush ();
display = gdk_display_get_default ();
screens = gdk_display_get_n_screens (display);
for (i = 0; i < screens; i++) {
window = nautilus_desktop_window_new (application,
gdk_display_get_screen (display, i));
/* We realize it immediately so that the NAUTILUS_DESKTOP_WINDOW_ID
property is set so gnome-settings-daemon doesn't try to set the
background. And we do a gdk_flush() to be sure X gets it. */
gtk_widget_realize (GTK_WIDGET (window));
gdk_flush ();
nautilus_application_desktop_windows =
g_list_prepend (nautilus_application_desktop_windows, window);
}
create_in_progress = FALSE;
}
@ -603,17 +615,19 @@ nautilus_application_create_desktop_window (NautilusApplication *application)
void
nautilus_application_open_desktop (NautilusApplication *application)
{
if (nautilus_application_desktop_window == NULL) {
nautilus_application_create_desktop_window (application);
if (nautilus_application_desktop_windows == NULL) {
nautilus_application_create_desktop_windows (application);
}
}
void
nautilus_application_close_desktop (void)
{
if (nautilus_application_desktop_window != NULL) {
gtk_widget_destroy (GTK_WIDGET (nautilus_application_desktop_window));
nautilus_application_desktop_window = NULL;
if (nautilus_application_desktop_windows != NULL) {
g_list_foreach (nautilus_application_desktop_windows,
(GFunc) gtk_widget_destroy, NULL);
g_list_free (nautilus_application_desktop_windows);
nautilus_application_desktop_windows = NULL;
}
}
@ -721,7 +735,8 @@ nautilus_window_unrealize_event_callback (GtkWidget *widget,
}
NautilusWindow *
nautilus_application_create_window (NautilusApplication *application)
nautilus_application_create_window (NautilusApplication *application,
GdkScreen *screen)
{
NautilusWindow *window;
@ -729,8 +744,10 @@ nautilus_application_create_window (NautilusApplication *application)
window = NAUTILUS_WINDOW (gtk_widget_new (nautilus_window_get_type (),
"app", application,
"app_id", "nautilus", NULL));
"app_id", "nautilus",
"screen", screen,
NULL));
g_signal_connect (window, "delete_event",
G_CALLBACK (nautilus_window_delete_event_callback), NULL);
@ -757,9 +774,9 @@ nautilus_application_create_window (NautilusApplication *application)
static void
desktop_location_changed_callback (gpointer user_data)
{
if (nautilus_application_desktop_window != NULL) {
nautilus_desktop_window_update_directory
(nautilus_application_desktop_window);
if (nautilus_application_desktop_windows != NULL) {
g_list_foreach (nautilus_application_desktop_windows,
(GFunc) nautilus_desktop_window_update_directory, NULL);
}
}
@ -857,7 +874,7 @@ volume_mounted_callback (NautilusVolumeMonitor *monitor, NautilusVolume *volume,
if (nautilus_volume_get_device_type (volume) == NAUTILUS_DEVICE_CDROM_DRIVE
&& eel_gconf_get_boolean( "/apps/magicdev/do_fileman_window")
&& !check_mount_window_disabled ()) {
window = nautilus_application_create_window (application);
window = nautilus_application_create_window (application, gdk_screen_get_default ());
uri = gnome_vfs_get_uri_from_local_path (nautilus_volume_get_mount_path (volume));
nautilus_window_go_to (window, uri);
g_free (uri);
@ -1004,7 +1021,7 @@ update_session (gpointer callback_data)
* if we have a desktop window. Prevents the
* session thrashing that's seen otherwise
*/
&& nautilus_application_desktop_window != NULL);
&& nautilus_application_desktop_windows != NULL);
}
static void

View file

@ -27,6 +27,7 @@
#ifndef NAUTILUS_APPLICATION_H
#define NAUTILUS_APPLICATION_H
#include <gdk/gdk.h>
#include <bonobo/bonobo-generic-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
@ -63,7 +64,8 @@ void nautilus_application_startup (NautilusApplication
const char *default_geometry,
const char *urls[]);
GList * nautilus_application_get_window_list (void);
NautilusWindow * nautilus_application_create_window (NautilusApplication *application);
NautilusWindow * nautilus_application_create_window (NautilusApplication *application,
GdkScreen *screen);
void nautilus_application_close_all_windows (void);
void nautilus_application_open_desktop (NautilusApplication *application);
void nautilus_application_close_desktop (void);

View file

@ -33,6 +33,7 @@
#include <eel/eel-gnome-extensions.h>
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-signal-handlers.h>
#include <libnautilus-private/egg-screen-help.h>
#include <gtk/gtkhbbox.h>
#include <gnome.h>
#include <glade/glade.h>
@ -124,10 +125,10 @@ nautilus_bookmarks_window_response_callback (GtkDialog *dialog,
if (response_id == GTK_RESPONSE_HELP) {
GError *error = NULL;
gnome_help_display_desktop (NULL,
"user-guide",
"wgosnautilus.xml", "gosnautilus-36",
&error);
egg_screen_help_display_desktop (
gtk_window_get_screen (GTK_WINDOW (dialog)),
NULL, "user-guide", "wgosnautilus.xml", "gosnautilus-36", &error);
if (error) {
GtkWidget *err_dialog;
err_dialog = gtk_message_dialog_new (GTK_WINDOW (dialog),

View file

@ -46,10 +46,6 @@ nautilus_desktop_window_instance_init (NautilusDesktopWindow *window)
{
window->details = g_new0 (NautilusDesktopWindowDetails, 1);
gtk_widget_set_size_request (GTK_WIDGET (window),
gdk_screen_width (),
gdk_screen_height ());
gtk_window_move (GTK_WINDOW (window), 0, 0);
/* shouldn't really be needed given our semantic type
@ -59,18 +55,6 @@ nautilus_desktop_window_instance_init (NautilusDesktopWindow *window)
FALSE);
}
static void
nautilus_desktop_window_realized (NautilusDesktopWindow *window)
{
/* Tuck the desktop windows xid in the root to indicate we own the desktop.
*/
Window window_xid;
window_xid = GDK_WINDOW_XWINDOW (GTK_WIDGET (window)->window);
gdk_property_change (NULL, gdk_atom_intern ("NAUTILUS_DESKTOP_WINDOW_ID", FALSE),
gdk_x11_xatom_to_atom (XA_WINDOW), 32,
PropModeReplace, (guchar *) &window_xid, 1);
}
static gint
nautilus_desktop_window_delete_event (NautilusDesktopWindow *window)
{
@ -96,20 +80,27 @@ nautilus_desktop_window_update_directory (NautilusDesktopWindow *window)
}
NautilusDesktopWindow *
nautilus_desktop_window_new (NautilusApplication *application)
nautilus_desktop_window_new (NautilusApplication *application,
GdkScreen *screen)
{
NautilusDesktopWindow *window;
int width_request, height_request;
width_request = gdk_screen_get_width (screen);
height_request = gdk_screen_get_height (screen);
window = NAUTILUS_DESKTOP_WINDOW
(gtk_widget_new (nautilus_desktop_window_get_type(),
"app", application,
"app_id", "nautilus",
"width_request", width_request,
"height_request", height_request,
"screen", screen,
NULL));
/* Special sawmill setting*/
gtk_window_set_wmclass (GTK_WINDOW (window), "desktop_window", "Nautilus");
g_signal_connect (window, "realize", G_CALLBACK (nautilus_desktop_window_realized), NULL);
g_signal_connect (window, "delete_event", G_CALLBACK (nautilus_desktop_window_delete_event), NULL);
/* Point window at the desktop folder.
@ -127,7 +118,6 @@ finalize (GObject *object)
window = NAUTILUS_DESKTOP_WINDOW (object);
gdk_property_delete (NULL, gdk_atom_intern ("NAUTILUS_DESKTOP_WINDOW_ID", TRUE));
g_free (window->details);
G_OBJECT_CLASS (parent_class)->finalize (object);
@ -262,23 +252,54 @@ map (GtkWidget *widget)
static void
set_wmspec_desktop_hint (GdkWindow *window)
unrealize (GtkWidget *widget)
{
Atom atom;
atom = XInternAtom (gdk_display,
"_NET_WM_WINDOW_TYPE_DESKTOP",
False);
NautilusDesktopWindow *window;
GdkWindow *root_window;
XChangeProperty (GDK_WINDOW_XDISPLAY (window),
GDK_WINDOW_XWINDOW (window),
XInternAtom (gdk_display,
"_NET_WM_WINDOW_TYPE",
False),
XA_ATOM, 32, PropModeReplace,
(guchar *) &atom, 1);
window = NAUTILUS_DESKTOP_WINDOW (widget);
root_window = gdk_screen_get_root_window (
gtk_window_get_screen (GTK_WINDOW (window)));
gdk_property_delete (root_window,
gdk_atom_intern ("NAUTILUS_DESKTOP_WINDOW_ID", TRUE));
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
}
static void
set_wmspec_desktop_hint (GdkWindow *window)
{
GdkAtom atom;
atom = gdk_atom_intern ("_NET_WM_WINDOW_TYPE_DESKTOP", FALSE);
gdk_property_change (window,
gdk_atom_intern ("_NET_WM_WINDOW_TYPE", FALSE),
gdk_x11_xatom_to_atom (XA_ATOM), 32,
GDK_PROP_MODE_REPLACE, (guchar *) &atom, 1);
}
static void
set_desktop_window_id (NautilusDesktopWindow *window,
GdkWindow *gdkwindow)
{
/* Tuck the desktop windows xid in the root to indicate we own the desktop.
*/
Window window_xid;
GdkWindow *root_window;
root_window = gdk_screen_get_root_window (
gtk_window_get_screen (GTK_WINDOW (window)));
window_xid = GDK_WINDOW_XWINDOW (gdkwindow);
gdk_property_change (root_window,
gdk_atom_intern ("NAUTILUS_DESKTOP_WINDOW_ID", FALSE),
gdk_x11_xatom_to_atom (XA_WINDOW), 32,
GDK_PROP_MODE_REPLACE, (guchar *) &window_xid, 1);
}
static void
realize (GtkWidget *widget)
@ -296,6 +317,8 @@ realize (GtkWidget *widget)
/* This is the new way to set up the desktop window */
set_wmspec_desktop_hint (widget->window);
set_desktop_window_id (window, widget->window);
}
static void
@ -311,6 +334,7 @@ nautilus_desktop_window_class_init (NautilusDesktopWindowClass *class)
{
G_OBJECT_CLASS (class)->finalize = finalize;
GTK_WIDGET_CLASS (class)->realize = realize;
GTK_WIDGET_CLASS (class)->unrealize = unrealize;
GTK_WIDGET_CLASS (class)->map = map;

View file

@ -50,7 +50,8 @@ typedef struct {
} NautilusDesktopWindowClass;
GtkType nautilus_desktop_window_get_type (void);
NautilusDesktopWindow *nautilus_desktop_window_new (NautilusApplication *application);
NautilusDesktopWindow *nautilus_desktop_window_new (NautilusApplication *application,
GdkScreen *screen);
void nautilus_desktop_window_update_directory (NautilusDesktopWindow *window);
#endif /* NAUTILUS_DESKTOP_WINDOW_H */

View file

@ -322,6 +322,8 @@ nautilus_information_panel_create_context_menu (NautilusInformationPanel *inform
has_background = background && !information_panel->details->is_default_background;
menu = gtk_menu_new ();
gtk_menu_set_screen (GTK_MENU (menu),
gtk_widget_get_screen (GTK_WIDGET (information_panel)));
/* add the reset background item, possibly disabled */
menu_item = gtk_menu_item_new_with_mnemonic (_("Use _Default Background"));

View file

@ -126,6 +126,8 @@ drag_data_received_callback (GtkWidget *widget,
NautilusApplication *application;
int name_count;
NautilusWindow *new_window;
NautilusWindow *window;
GdkScreen *screen;
gboolean new_windows_for_extras;
char *prompt;
@ -141,6 +143,7 @@ drag_data_received_callback (GtkWidget *widget,
return;
}
window = nautilus_location_bar_get_window (widget);
new_windows_for_extras = FALSE;
/* Ask user if they really want to open multiple windows
* for multiple dropped URIs. This is likely to have been
@ -154,7 +157,7 @@ drag_data_received_callback (GtkWidget *widget,
/* eel_run_simple_dialog should really take in pairs
* like gtk_dialog_new_with_buttons() does. */
new_windows_for_extras = eel_run_simple_dialog
(GTK_WIDGET (nautilus_location_bar_get_window (widget)),
(GTK_WIDGET (window),
TRUE,
prompt,
_("View in Multiple Windows?"),
@ -174,9 +177,11 @@ drag_data_received_callback (GtkWidget *widget,
nautilus_navigation_bar_location_changed (NAUTILUS_NAVIGATION_BAR (widget));
if (new_windows_for_extras) {
application = nautilus_location_bar_get_window (widget)->application;
application = window->application;
screen = gtk_window_get_screen (GTK_WINDOW (window));
for (node = names->next; node != NULL; node = node->next) {
new_window = nautilus_application_create_window (application);
new_window = nautilus_application_create_window (application, screen);
nautilus_window_go_to (new_window, node->data);
}
}

View file

@ -62,6 +62,7 @@
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/egg-screen-help.h>
#include <libnautilus/nautilus-bonobo-ui.h>
@ -186,7 +187,9 @@ file_menu_new_window_callback (BonoboUIComponent *component,
NautilusWindow *new_window;
current_window = NAUTILUS_WINDOW (user_data);
new_window = nautilus_application_create_window (current_window->application);
new_window = nautilus_application_create_window (
current_window->application,
gtk_window_get_screen (GTK_WINDOW (current_window)));
nautilus_window_go_home (new_window);
}
@ -565,18 +568,26 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
static void
preferences_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
gpointer user_data,
const char *verb)
{
nautilus_preferences_dialog_show ();
GtkWindow *window;
window = GTK_WINDOW (user_data);
nautilus_preferences_dialog_show (gtk_window_get_screen (window));
}
static void
backgrounds_and_emblems_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
gpointer user_data,
const char *verb)
{
nautilus_property_browser_show ();
GtkWindow *window;
window = GTK_WINDOW (user_data);
nautilus_property_browser_show (gtk_window_get_screen (window));
}
static void
@ -672,16 +683,19 @@ help_menu_nautilus_manual_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
NautilusWindow *window;
GError *error;
GtkWidget *dialog;
error = NULL;
gnome_help_display_desktop (NULL,
"user-guide",
"wgosnautilus.xml",
"gosnautilus-21", &error);
window = NAUTILUS_WINDOW (user_data);
egg_screen_help_display_desktop (
gtk_window_get_screen (GTK_WINDOW (window)),
NULL, "user-guide", "wgosnautilus.xml", "gosnautilus-21", &error);
if (error) {
dialog = gtk_message_dialog_new (NULL,
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
@ -1041,8 +1055,13 @@ add_bookmark_for_current_location (NautilusWindow *window)
static void
edit_bookmarks (NautilusWindow *window)
{
gtk_window_present
(get_or_create_bookmarks_window (G_OBJECT (window)));
GtkWindow *dialog;
dialog = get_or_create_bookmarks_window (G_OBJECT (window));
gtk_window_set_screen (
dialog, gtk_window_get_screen (GTK_WINDOW (window)));
gtk_window_present (dialog);
}
void

View file

@ -464,25 +464,28 @@ nautilus_window_zoom_to_fit (NautilusWindow *window)
* (The user can still stretch the window taller if desired).
*/
static guint
get_max_forced_height (void)
get_max_forced_height (GdkScreen *screen)
{
return (gdk_screen_height () * 90) / 100;
return (gdk_screen_get_height (screen) * 90) / 100;
}
/* Code should never force the window wider than this size.
* (The user can still stretch the window wider if desired).
*/
static guint
get_max_forced_width (void)
get_max_forced_width (GdkScreen *screen)
{
return (gdk_screen_width () * 90) / 100;
return (gdk_screen_get_width (screen) * 90) / 100;
}
static void
set_initial_window_geometry (NautilusWindow *window)
{
GdkScreen *screen;
guint max_width_for_screen, max_height_for_screen;
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* Don't let GTK determine the minimum size
* automatically. It will insist that the window be
* really wide based on some misguided notion about
@ -498,9 +501,9 @@ set_initial_window_geometry (NautilusWindow *window)
* probably remove this broken set_size_request() here.
* - hp@redhat.com
*/
max_width_for_screen = get_max_forced_width ();
max_height_for_screen = get_max_forced_height ();
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
gtk_widget_set_size_request (GTK_WIDGET (window),
MIN (NAUTILUS_WINDOW_MIN_WIDTH,
@ -1025,6 +1028,7 @@ static void
nautilus_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GdkScreen *screen;
guint max_width;
guint max_height;
@ -1033,6 +1037,8 @@ nautilus_window_size_request (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
screen = gtk_window_get_screen (GTK_WINDOW (widget));
/* Limit the requisition to be within 90% of the available screen
* real state.
*
@ -1046,8 +1052,8 @@ nautilus_window_size_request (GtkWidget *widget,
* to be requested, should still be fixed. This code is here only to
* prevent the extremely frustrating consequence of such bugs.
*/
max_width = get_max_forced_width ();
max_height = get_max_forced_height ();
max_width = get_max_forced_width (screen);
max_height = get_max_forced_height (screen);
if (requisition->width > (int) max_width) {
requisition->width = max_width;

View file

@ -464,25 +464,28 @@ nautilus_window_zoom_to_fit (NautilusWindow *window)
* (The user can still stretch the window taller if desired).
*/
static guint
get_max_forced_height (void)
get_max_forced_height (GdkScreen *screen)
{
return (gdk_screen_height () * 90) / 100;
return (gdk_screen_get_height (screen) * 90) / 100;
}
/* Code should never force the window wider than this size.
* (The user can still stretch the window wider if desired).
*/
static guint
get_max_forced_width (void)
get_max_forced_width (GdkScreen *screen)
{
return (gdk_screen_width () * 90) / 100;
return (gdk_screen_get_width (screen) * 90) / 100;
}
static void
set_initial_window_geometry (NautilusWindow *window)
{
GdkScreen *screen;
guint max_width_for_screen, max_height_for_screen;
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* Don't let GTK determine the minimum size
* automatically. It will insist that the window be
* really wide based on some misguided notion about
@ -498,9 +501,9 @@ set_initial_window_geometry (NautilusWindow *window)
* probably remove this broken set_size_request() here.
* - hp@redhat.com
*/
max_width_for_screen = get_max_forced_width ();
max_height_for_screen = get_max_forced_height ();
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
gtk_widget_set_size_request (GTK_WIDGET (window),
MIN (NAUTILUS_WINDOW_MIN_WIDTH,
@ -1025,6 +1028,7 @@ static void
nautilus_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GdkScreen *screen;
guint max_width;
guint max_height;
@ -1033,6 +1037,8 @@ nautilus_window_size_request (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
screen = gtk_window_get_screen (GTK_WINDOW (widget));
/* Limit the requisition to be within 90% of the available screen
* real state.
*
@ -1046,8 +1052,8 @@ nautilus_window_size_request (GtkWidget *widget,
* to be requested, should still be fixed. This code is here only to
* prevent the extremely frustrating consequence of such bugs.
*/
max_width = get_max_forced_width ();
max_height = get_max_forced_height ();
max_width = get_max_forced_width (screen);
max_height = get_max_forced_height (screen);
if (requisition->width > (int) max_width) {
requisition->width = max_width;

View file

@ -25,9 +25,10 @@
#include <config.h>
#include "nautilus-preferences-dialog.h"
#include "libnautilus-private/nautilus-global-preferences.h"
#include "libnautilus-private/nautilus-sidebar-functions.h"
#include "nautilus-theme-selector.h"
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-sidebar-functions.h>
#include <libnautilus-private/egg-screen-help.h>
#include <eel/eel-debug.h>
#include <eel/eel-gtk-extensions.h>
#include <eel/eel-preferences-box.h>
@ -415,9 +416,9 @@ preferences_show_help (GtkWindow *parent,
g_return_if_fail (helpfile != NULL);
g_return_if_fail (sect_id != NULL);
gnome_help_display_desktop (NULL,
"user-guide",
helpfile, sect_id, &error);
egg_screen_help_display_desktop (
gtk_window_get_screen (parent),
NULL, "user-guide", helpfile, sect_id, &error);
if (error) {
dialog = gtk_message_dialog_new (GTK_WINDOW (parent),
@ -627,7 +628,12 @@ global_preferences_get_dialog (void)
}
void
nautilus_preferences_dialog_show (void)
nautilus_preferences_dialog_show (GdkScreen *screen)
{
gtk_window_present (GTK_WINDOW (global_preferences_get_dialog ()));
GtkWindow *dialog;
dialog = GTK_WINDOW (global_preferences_get_dialog ());
gtk_window_set_screen (dialog, screen);
gtk_window_present (dialog);
}

View file

@ -25,11 +25,12 @@
#ifndef NAUTILUS_PREFERENCES_DIALOG_H
#define NAUTILUS_PREFERENCES_DIALOG_H
#include <gdk/gdk.h>
#include <libnautilus-private/nautilus-global-preferences.h>
G_BEGIN_DECLS
void nautilus_preferences_dialog_show (void);
void nautilus_preferences_dialog_show (GdkScreen *screen);
G_END_DECLS

View file

@ -82,6 +82,7 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-metadata.h>
#include <libnautilus-private/nautilus-theme.h>
#include <libnautilus-private/egg-screen-help.h>
#include <math.h>
#include <atk/atkrelationset.h>
@ -214,7 +215,6 @@ static GtkTargetEntry drag_types[] = {
{ "text/uri-list", 0, PROPERTY_TYPE }
};
static NautilusPropertyBrowser *main_browser = NULL;
EEL_CLASS_BOILERPLATE (NautilusPropertyBrowser,
nautilus_property_browser,
@ -490,15 +490,13 @@ nautilus_property_browser_destroy (GtkObject *object)
eel_preferences_remove_callback (NAUTILUS_PREFERENCES_THEME,
nautilus_property_browser_theme_changed,
property_browser);
if (object == GTK_OBJECT (main_browser))
main_browser = NULL;
EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object));
}
/* create a new instance */
NautilusPropertyBrowser *
nautilus_property_browser_new (void)
nautilus_property_browser_new (GdkScreen *screen)
{
NautilusPropertyBrowser *browser;
@ -506,6 +504,7 @@ nautilus_property_browser_new (void)
(gtk_widget_new (nautilus_property_browser_get_type (), NULL));
gtk_container_set_border_width (GTK_CONTAINER (browser), 0);
gtk_window_set_screen (GTK_WINDOW (browser), screen);
gtk_widget_show (GTK_WIDGET(browser));
return browser;
@ -514,12 +513,17 @@ nautilus_property_browser_new (void)
/* show the main property browser */
void
nautilus_property_browser_show (void)
nautilus_property_browser_show (GdkScreen *screen)
{
if (main_browser == NULL) {
main_browser = nautilus_property_browser_new ();
static GtkWindow *browser = NULL;
if (browser == NULL) {
browser = GTK_WINDOW (nautilus_property_browser_new (screen));
g_object_add_weak_pointer (G_OBJECT (browser),
(gpointer *) &browser);
} else {
gtk_window_present (GTK_WINDOW (main_browser));
gtk_window_set_screen (browser, screen);
gtk_window_present (browser);
}
}
@ -1486,12 +1490,12 @@ help_button_callback (GtkWidget *widget, GtkWidget *property_browser)
GError *error = NULL;
GtkWidget *dialog;
gnome_help_display_desktop (NULL,
"user-guide",
"wgosnautilus.xml", "gosnautilus-50",
&error);
egg_screen_help_display_desktop (
gtk_window_get_screen (GTK_WINDOW (property_browser)),
NULL, "user-guide", "wgosnautilus.xml", "gosnautilus-50", &error);
if (error) {
dialog = gtk_message_dialog_new (GTK_WINDOW (widget),
dialog = gtk_message_dialog_new (GTK_WINDOW (property_browser),
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,

View file

@ -31,6 +31,7 @@
#ifndef NAUTILUS_PROPERTY_BROWSER_H
#define NAUTILUS_PROPERTY_BROWSER_H
#include <gdk/gdk.h>
#include <gtk/gtkwindow.h>
typedef struct NautilusPropertyBrowser NautilusPropertyBrowser;
@ -60,10 +61,10 @@ struct NautilusPropertyBrowserClass
GtkWindowClass parent_class;
};
GtkType nautilus_property_browser_get_type (void);
NautilusPropertyBrowser *nautilus_property_browser_new (void);
void nautilus_property_browser_show (void);
void nautilus_property_browser_set_path (NautilusPropertyBrowser *panel,
const char *new_path);
GtkType nautilus_property_browser_get_type (void);
NautilusPropertyBrowser *nautilus_property_browser_new (GdkScreen *screen);
void nautilus_property_browser_show (GdkScreen *screen);
void nautilus_property_browser_set_path (NautilusPropertyBrowser *panel,
const char *new_path);
#endif /* NAUTILUS_PROPERTY_BROWSER_H */

View file

@ -124,7 +124,8 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry)
{
NautilusWindow *window;
window = nautilus_application_create_window (shell->details->application);
window = nautilus_application_create_window (shell->details->application,
gdk_screen_get_default ());
if (geometry != NULL) {
eel_gtk_window_set_initial_geometry_from_string (GTK_WINDOW (window),
@ -219,6 +220,7 @@ corba_quit (PortableServer_Servant servant,
#define WINDOW_STATE_ATTRIBUTE_X 2
#define WINDOW_STATE_ATTRIBUTE_Y 3
#define WINDOW_STATE_ATTRIBUTE_LOCATION 4
#define WINDOW_STATE_ATTRIBUTE_SCREEN 5
static void
save_window_states (void)
@ -231,6 +233,7 @@ save_window_states (void)
int x, y, width, height;
char *location;
EelStringList *states;
int screen_num = -1;
states = NULL;
windows = nautilus_application_get_window_list ();
@ -247,10 +250,14 @@ save_window_states (void)
location = nautilus_window_get_location (window);
window_attributes = g_strdup_printf ("%d,%d,%d,%d,%s",
screen_num = gdk_screen_get_number (
gtk_window_get_screen (GTK_WINDOW (window)));
window_attributes = g_strdup_printf ("%d,%d,%d,%d,%s,%d",
width, height,
x, y,
location);
location,
screen_num);
g_free (location);
if (states == NULL) {
@ -277,6 +284,9 @@ restore_one_window_callback (const char *attributes,
int height;
char *location;
NautilusWindow *window;
GdkScreen *screen = NULL;
int screen_num;
int list_length;
g_return_if_fail (eel_strlen (attributes) > 0);
g_return_if_fail (NAUTILUS_IS_SHELL (callback_data));
@ -285,13 +295,26 @@ restore_one_window_callback (const char *attributes,
attribute_list = eel_string_list_new_from_tokens (attributes, ",", TRUE);
list_length = eel_string_list_get_length (attribute_list);
eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_WIDTH, &width);
eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_HEIGHT, &height);
eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_X, &x);
eel_string_list_nth_as_integer (attribute_list, WINDOW_STATE_ATTRIBUTE_Y, &y);
location = eel_string_list_nth (attribute_list, WINDOW_STATE_ATTRIBUTE_LOCATION);
window = nautilus_application_create_window (shell->details->application);
/* Support sessions with no screen number for backwards compat.
*/
if (list_length >= WINDOW_STATE_ATTRIBUTE_SCREEN + 1) {
eel_string_list_nth_as_integer (
attribute_list, WINDOW_STATE_ATTRIBUTE_SCREEN, &screen_num);
screen = gdk_display_get_screen (gdk_display_get_default (), screen_num);
} else {
screen = gdk_screen_get_default ();
}
window = nautilus_application_create_window (shell->details->application, screen);
if (eel_strlen (location) > 0) {
nautilus_window_go_to (window, location);

View file

@ -464,25 +464,28 @@ nautilus_window_zoom_to_fit (NautilusWindow *window)
* (The user can still stretch the window taller if desired).
*/
static guint
get_max_forced_height (void)
get_max_forced_height (GdkScreen *screen)
{
return (gdk_screen_height () * 90) / 100;
return (gdk_screen_get_height (screen) * 90) / 100;
}
/* Code should never force the window wider than this size.
* (The user can still stretch the window wider if desired).
*/
static guint
get_max_forced_width (void)
get_max_forced_width (GdkScreen *screen)
{
return (gdk_screen_width () * 90) / 100;
return (gdk_screen_get_width (screen) * 90) / 100;
}
static void
set_initial_window_geometry (NautilusWindow *window)
{
GdkScreen *screen;
guint max_width_for_screen, max_height_for_screen;
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* Don't let GTK determine the minimum size
* automatically. It will insist that the window be
* really wide based on some misguided notion about
@ -498,9 +501,9 @@ set_initial_window_geometry (NautilusWindow *window)
* probably remove this broken set_size_request() here.
* - hp@redhat.com
*/
max_width_for_screen = get_max_forced_width ();
max_height_for_screen = get_max_forced_height ();
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
gtk_widget_set_size_request (GTK_WIDGET (window),
MIN (NAUTILUS_WINDOW_MIN_WIDTH,
@ -1025,6 +1028,7 @@ static void
nautilus_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GdkScreen *screen;
guint max_width;
guint max_height;
@ -1033,6 +1037,8 @@ nautilus_window_size_request (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
screen = gtk_window_get_screen (GTK_WINDOW (widget));
/* Limit the requisition to be within 90% of the available screen
* real state.
*
@ -1046,8 +1052,8 @@ nautilus_window_size_request (GtkWidget *widget,
* to be requested, should still be fixed. This code is here only to
* prevent the extremely frustrating consequence of such bugs.
*/
max_width = get_max_forced_width ();
max_height = get_max_forced_height ();
max_width = get_max_forced_width (screen);
max_height = get_max_forced_height (screen);
if (requisition->width > (int) max_width) {
requisition->width = max_width;

View file

@ -697,8 +697,10 @@ open_location (NautilusWindow *window,
}
if (create_new_window) {
target_window = nautilus_application_create_window (window->application);
}
target_window = nautilus_application_create_window (
window->application,
gtk_window_get_screen (GTK_WINDOW (window)));
}
eel_g_list_free_deep (target_window->details->pending_selection);
target_window->details->pending_selection = eel_g_str_list_copy (new_selection);

View file

@ -62,6 +62,7 @@
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/egg-screen-help.h>
#include <libnautilus/nautilus-bonobo-ui.h>
@ -186,7 +187,9 @@ file_menu_new_window_callback (BonoboUIComponent *component,
NautilusWindow *new_window;
current_window = NAUTILUS_WINDOW (user_data);
new_window = nautilus_application_create_window (current_window->application);
new_window = nautilus_application_create_window (
current_window->application,
gtk_window_get_screen (GTK_WINDOW (current_window)));
nautilus_window_go_home (new_window);
}
@ -565,18 +568,26 @@ bookmarks_menu_edit_bookmarks_callback (BonoboUIComponent *component,
static void
preferences_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
gpointer user_data,
const char *verb)
{
nautilus_preferences_dialog_show ();
GtkWindow *window;
window = GTK_WINDOW (user_data);
nautilus_preferences_dialog_show (gtk_window_get_screen (window));
}
static void
backgrounds_and_emblems_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
gpointer user_data,
const char *verb)
{
nautilus_property_browser_show ();
GtkWindow *window;
window = GTK_WINDOW (user_data);
nautilus_property_browser_show (gtk_window_get_screen (window));
}
static void
@ -672,16 +683,19 @@ help_menu_nautilus_manual_callback (BonoboUIComponent *component,
gpointer user_data,
const char *verb)
{
NautilusWindow *window;
GError *error;
GtkWidget *dialog;
error = NULL;
gnome_help_display_desktop (NULL,
"user-guide",
"wgosnautilus.xml",
"gosnautilus-21", &error);
window = NAUTILUS_WINDOW (user_data);
egg_screen_help_display_desktop (
gtk_window_get_screen (GTK_WINDOW (window)),
NULL, "user-guide", "wgosnautilus.xml", "gosnautilus-21", &error);
if (error) {
dialog = gtk_message_dialog_new (NULL,
dialog = gtk_message_dialog_new (GTK_WINDOW (window),
GTK_DIALOG_MODAL,
GTK_MESSAGE_ERROR,
GTK_BUTTONS_CLOSE,
@ -1041,8 +1055,13 @@ add_bookmark_for_current_location (NautilusWindow *window)
static void
edit_bookmarks (NautilusWindow *window)
{
gtk_window_present
(get_or_create_bookmarks_window (G_OBJECT (window)));
GtkWindow *dialog;
dialog = get_or_create_bookmarks_window (G_OBJECT (window));
gtk_window_set_screen (
dialog, gtk_window_get_screen (GTK_WINDOW (window)));
gtk_window_present (dialog);
}
void

View file

@ -464,25 +464,28 @@ nautilus_window_zoom_to_fit (NautilusWindow *window)
* (The user can still stretch the window taller if desired).
*/
static guint
get_max_forced_height (void)
get_max_forced_height (GdkScreen *screen)
{
return (gdk_screen_height () * 90) / 100;
return (gdk_screen_get_height (screen) * 90) / 100;
}
/* Code should never force the window wider than this size.
* (The user can still stretch the window wider if desired).
*/
static guint
get_max_forced_width (void)
get_max_forced_width (GdkScreen *screen)
{
return (gdk_screen_width () * 90) / 100;
return (gdk_screen_get_width (screen) * 90) / 100;
}
static void
set_initial_window_geometry (NautilusWindow *window)
{
GdkScreen *screen;
guint max_width_for_screen, max_height_for_screen;
screen = gtk_window_get_screen (GTK_WINDOW (window));
/* Don't let GTK determine the minimum size
* automatically. It will insist that the window be
* really wide based on some misguided notion about
@ -498,9 +501,9 @@ set_initial_window_geometry (NautilusWindow *window)
* probably remove this broken set_size_request() here.
* - hp@redhat.com
*/
max_width_for_screen = get_max_forced_width ();
max_height_for_screen = get_max_forced_height ();
max_width_for_screen = get_max_forced_width (screen);
max_height_for_screen = get_max_forced_height (screen);
gtk_widget_set_size_request (GTK_WIDGET (window),
MIN (NAUTILUS_WINDOW_MIN_WIDTH,
@ -1025,6 +1028,7 @@ static void
nautilus_window_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
GdkScreen *screen;
guint max_width;
guint max_height;
@ -1033,6 +1037,8 @@ nautilus_window_size_request (GtkWidget *widget,
GTK_WIDGET_CLASS (parent_class)->size_request (widget, requisition);
screen = gtk_window_get_screen (GTK_WINDOW (widget));
/* Limit the requisition to be within 90% of the available screen
* real state.
*
@ -1046,8 +1052,8 @@ nautilus_window_size_request (GtkWidget *widget,
* to be requested, should still be fixed. This code is here only to
* prevent the extremely frustrating consequence of such bugs.
*/
max_width = get_max_forced_width ();
max_height = get_max_forced_height ();
max_width = get_max_forced_width (screen);
max_height = get_max_forced_height (screen);
if (requisition->width > (int) max_width) {
requisition->width = max_width;