Enable startup notification.

2005-02-14  Alexander Larsson  <alexl@redhat.com>

	* data/applications.desktop.in:
	* data/favorites.desktop.in:
	* src/network-scheme.desktop.in:
	* nautilus-computer.desktop.in:
	* nautilus-folder-handler.desktop.in:
	* nautilus-home.desktop.in:
	* nautilus.desktop.in:
	Enable startup notification.

	* src/nautilus-application.c:
	* src/nautilus-application.h:
	* src/nautilus-bookmarks-window.c:
	* src/nautilus-connect-server-dialog-nonmain.c:
	* src/nautilus-location-bar.c:
	* src/nautilus-main.c:
	* src/nautilus-navigation-window-menus.c:
	* src/nautilus-shell-interface.idl:
	* src/nautilus-shell.c:
	* src/nautilus-window-manage-views.c:
	* src/nautilus-window-private.h:
	* src/nautilus-window.c:
	Handle startup notification across corba activation.
	Patch from Elijah Newren <newren@gmail.com>
This commit is contained in:
Alexander Larsson 2005-02-14 10:59:23 +00:00 committed by Alexander Larsson
parent 50d42be08e
commit 00858aa133
20 changed files with 221 additions and 14 deletions

View file

@ -1,3 +1,28 @@
2005-02-14 Alexander Larsson <alexl@redhat.com>
* data/applications.desktop.in:
* data/favorites.desktop.in:
* src/network-scheme.desktop.in:
* nautilus-computer.desktop.in:
* nautilus-folder-handler.desktop.in:
* nautilus-home.desktop.in:
* nautilus.desktop.in:
Enable startup notification.
* src/nautilus-application.c:
* src/nautilus-application.h:
* src/nautilus-bookmarks-window.c:
* src/nautilus-connect-server-dialog-nonmain.c:
* src/nautilus-location-bar.c:
* src/nautilus-main.c:
* src/nautilus-navigation-window-menus.c:
* src/nautilus-shell-interface.idl:
* src/nautilus-shell.c:
* src/nautilus-window-manage-views.c:
* src/nautilus-window-private.h:
* src/nautilus-window.c:
Handle startup notification across corba activation.
2005-02-11 Alexander Larsson <alexl@redhat.com>
* src/file-manager/fm-tree-model.c:

View file

@ -5,4 +5,5 @@ _Comment=Browse available software
URL=applications:///
Icon=gnome-logo-icon-transparent.png
Terminal=false
StartupNotify=true
Type=Link

View file

@ -6,3 +6,4 @@ _Comment=Favorite applications
URL=favorites:
Icon=gnome-favorites.png
Terminal=false
StartupNotify=true

View file

@ -6,6 +6,7 @@ TryExec=nautilus
Exec=nautilus computer:
Icon=gnome-fs-client
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Core;
X-GNOME-Bugzilla-Bugzilla=GNOME

View file

@ -5,6 +5,7 @@ TryExec=nautilus
Exec=nautilus %U
NoDisplay=true
Terminal=false
StartupNotify=true
Type=Application
MimeType=x-directory/gnome-default-handler
X-GNOME-Bugzilla-Bugzilla=GNOME

View file

@ -6,6 +6,7 @@ TryExec=nautilus
Exec=nautilus
Icon=gnome-fs-home
Terminal=false
StartupNotify=true
Type=Application
Categories=Application;Core;
X-GNOME-Bugzilla-Bugzilla=GNOME

View file

@ -6,6 +6,7 @@ TryExec=nautilus
Exec=nautilus --no-desktop --browser %U
Icon=file-manager
Terminal=false
StartupNotify=true
Type=Application
Categories=GNOME;Application;System;Utility;Core;
OnlyShowIn=GNOME;

View file

@ -83,6 +83,8 @@
#include <libnautilus-private/nautilus-desktop-link-monitor.h>
#include <libnautilus-private/nautilus-directory-private.h>
#include <bonobo-activation/bonobo-activation.h>
#define SN_API_NOT_YET_FROZEN Yes_i_know_DO_IT
#include <libsn/sn-launchee.h>
/* Needed for the is_kdesktop_present check */
#include <gdk/gdkx.h>
@ -452,6 +454,7 @@ nautilus_application_startup (NautilusApplication *application,
gboolean no_desktop,
gboolean do_first_time_druid_check,
gboolean browser_window,
const char *startup_id,
const char *geometry,
const char *urls[])
{
@ -461,6 +464,7 @@ nautilus_application_startup (NautilusApplication *application,
const char *message, *detailed_message;
GtkDialog *dialog;
Nautilus_URIList *url_list;
const CORBA_char *corba_startup_id;
const CORBA_char *corba_geometry;
int num_failures;
@ -610,15 +614,16 @@ nautilus_application_startup (NautilusApplication *application,
/* CORBA C mapping doesn't allow NULL to be passed
for string parameters */
corba_geometry = (geometry != NULL) ? geometry : "";
corba_geometry = (geometry != NULL) ? geometry : "";
corba_startup_id = (startup_id != NULL) ? startup_id : "";
/* Create the other windows. */
if (urls != NULL) {
url_list = nautilus_make_uri_list_from_shell_strv (urls);
Nautilus_Shell_open_windows (shell, url_list, corba_geometry, browser_window, &ev);
Nautilus_Shell_open_windows (shell, url_list, corba_startup_id, corba_geometry, browser_window, &ev);
CORBA_free (url_list);
} else if (!no_default_window) {
Nautilus_Shell_open_default_window (shell, corba_geometry, browser_window, &ev);
Nautilus_Shell_open_default_window (shell, corba_startup_id, corba_geometry, browser_window, &ev);
}
/* Add ourselves to the session */
@ -926,6 +931,7 @@ nautilus_window_delete_event_callback (GtkWidget *widget,
static NautilusWindow *
create_window (NautilusApplication *application,
GType window_type,
const char *startup_id,
GdkScreen *screen)
{
NautilusWindow *window;
@ -939,6 +945,10 @@ create_window (NautilusApplication *application,
/* Must be called after construction finished */
nautilus_window_constructed (window);
if (startup_id != NULL) {
window->details->startup_id = g_strdup (startup_id);
}
g_signal_connect_data (window, "delete_event",
G_CALLBACK (nautilus_window_delete_event_callback), NULL, NULL,
G_CONNECT_AFTER);
@ -966,21 +976,135 @@ spatial_window_destroyed_callback (void *user_data, GObject *window)
NautilusWindow *
nautilus_application_present_spatial_window (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
const char *location,
GdkScreen *screen)
{
return nautilus_application_present_spatial_window_with_selection (application,
requesting_window,
startup_id,
location,
NULL,
screen);
}
static void
sn_error_trap_push (SnDisplay *display,
Display *xdisplay)
{
gdk_error_trap_push ();
}
static void
sn_error_trap_pop (SnDisplay *display,
Display *xdisplay)
{
gdk_error_trap_pop ();
}
static gboolean
id_string_has_timestamp (const char *startup_id_string)
{
char * time_str;
time_str = g_strrstr (startup_id_string, "_TIME");
return time_str != NULL;
}
static guint32
get_timestamp_from_id_string (const char *startup_id_string)
{
char *time_str;
gchar *end;
gulong retval;
retval = 0;
time_str = g_strrstr (startup_id_string, "_TIME");
g_assert (time_str != NULL);
errno = 0;
/* Skip past the "_TIME" part */
time_str += 5;
retval = strtoul (time_str, &end, 0);
if (end == time_str || errno != 0) {
g_warning ("startup_id is messed up\n");
}
return retval;
}
static void
end_startup_notification (GtkWidget *widget,
const char *startup_id_to_end,
const char *startup_id_with_timestamp)
{
SnDisplay *sn_display;
SnLauncheeContext *context;
GdkDisplay *display;
GdkScreen *screen;
g_return_if_fail (startup_id_to_end != NULL);
if (!GTK_WIDGET_REALIZED (widget)) {
gtk_widget_realize (widget);
}
context = NULL;
sn_display = NULL;
/* Set up window for launch notification */
/* FIXME In principle all transient children of this
* window should get the same startup_id
*/
screen = gtk_widget_get_screen (widget);
display = gdk_screen_get_display (screen);
sn_display = sn_display_new (gdk_x11_display_get_xdisplay (display),
sn_error_trap_push,
sn_error_trap_pop);
context = sn_launchee_context_new (sn_display,
gdk_screen_get_number (screen),
startup_id_to_end);
if (startup_id_with_timestamp == NULL) {
sn_launchee_context_setup_window (context,
GDK_WINDOW_XWINDOW (widget->window));
startup_id_with_timestamp = startup_id_to_end;
}
/* Now, set the _NET_WM_USER_TIME for the new window to the timestamp
* that caused the window to be launched.
*/
if (id_string_has_timestamp (startup_id_with_timestamp)) {
gulong startup_id_timestamp;
startup_id_timestamp = get_timestamp_from_id_string (startup_id_with_timestamp);
gdk_x11_window_set_user_time (widget->window, startup_id_timestamp);
} else {
/* Comment this out for now, as it warns way to often.
* like when launching nautilus from the terminal.
g_warning ("Launched by a non-compliant or obsolete startup "
"notification launcher. Focus-stealing-prevention "
"may fail.\n");
*/
}
sn_launchee_context_complete (context);
sn_launchee_context_unref (context);
sn_display_unref (sn_display);
}
NautilusWindow *
nautilus_application_present_spatial_window_with_selection (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
const char *location,
GList *new_selection,
GList *new_selection,
GdkScreen *screen)
{
NautilusWindow *window;
@ -1001,6 +1125,9 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
}
if (eel_uris_match (existing_location, location)) {
end_startup_notification (GTK_WIDGET (existing_window),
existing_window->details->startup_id,
startup_id);
gtk_window_present (GTK_WINDOW (existing_window));
if (new_selection) {
nautilus_view_set_selection (existing_window->content_view, new_selection);
@ -1009,7 +1136,10 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
}
}
window = create_window (application, NAUTILUS_TYPE_SPATIAL_WINDOW, screen);
window = create_window (application, NAUTILUS_TYPE_SPATIAL_WINDOW, startup_id, screen);
end_startup_notification (GTK_WIDGET (window),
startup_id,
NULL);
if (requesting_window) {
/* Center the window over the requesting window by default */
int orig_x, orig_y, orig_width, orig_height;
@ -1044,13 +1174,17 @@ nautilus_application_present_spatial_window_with_selection (NautilusApplication
NautilusWindow *
nautilus_application_create_navigation_window (NautilusApplication *application,
const char *startup_id,
GdkScreen *screen)
{
NautilusWindow *window;
g_return_val_if_fail (NAUTILUS_IS_APPLICATION (application), NULL);
window = create_window (application, NAUTILUS_TYPE_NAVIGATION_WINDOW, screen);
window = create_window (application, NAUTILUS_TYPE_NAVIGATION_WINDOW, startup_id, screen);
end_startup_notification (GTK_WIDGET (window),
startup_id,
NULL);
return window;
}

View file

@ -67,6 +67,7 @@ void nautilus_application_startup (NautilusApplication
gboolean no_desktop,
gboolean do_first_time_druid_check,
gboolean browser_window,
const char *startup_id,
const char *default_geometry,
const char *urls[]);
GList * nautilus_application_get_window_list (void);
@ -74,15 +75,18 @@ GList * nautilus_application_get_spatial_window_list (void);
NautilusWindow * nautilus_application_present_spatial_window (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
const char *location,
GdkScreen *screen);
NautilusWindow * nautilus_application_present_spatial_window_with_selection (NautilusApplication *application,
NautilusWindow *requesting_window,
const char *startup_id,
const char *location,
GList *new_selection,
GdkScreen *screen);
NautilusWindow * nautilus_application_create_navigation_window (NautilusApplication *application,
const char *startup_id,
GdkScreen *screen);
void nautilus_application_close_all_navigation_windows (void);

View file

@ -555,6 +555,7 @@ get_bookmark_nautilus_navigation_window_new (GdkScreen *screen)
application = nautilus_application_new ();
window = nautilus_application_create_navigation_window (application,
NULL,
screen);
return window;

View file

@ -39,10 +39,12 @@ nautilus_connect_server_dialog_present_uri (NautilusApplication *application,
if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (application,
NULL,
gtk_widget_get_screen (widget));
nautilus_window_go_to (window, uri);
} else {
nautilus_application_present_spatial_window (application,
NULL,
NULL,
uri,
gtk_widget_get_screen (widget));

View file

@ -189,7 +189,7 @@ drag_data_received_callback (GtkWidget *widget,
screen = gtk_window_get_screen (GTK_WINDOW (window));
for (node = names->next; node != NULL; node = node->next) {
new_window = nautilus_application_create_navigation_window (application, screen);
new_window = nautilus_application_create_navigation_window (application, NULL, screen);
nautilus_window_go_to (new_window, node->data);
}
}

View file

@ -196,6 +196,8 @@ main (int argc, char *argv[])
gboolean no_default_window;
gboolean browser_window;
gboolean no_desktop;
const char *startup_id;
char *startup_id_copy;
char *geometry;
gboolean perform_self_check;
poptContext popt_context;
@ -246,6 +248,17 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
startup_id = g_getenv ("DESKTOP_STARTUP_ID");
startup_id_copy = NULL;
if (startup_id != NULL && *startup_id != '\0') {
/* Clear the DESKTOP_STARTUP_ID, but make sure to copy it first */
startup_id_copy = g_strdup (startup_id);
putenv ("DESKTOP_STARTUP_ID=");
}
/* we'll do it ourselves due to complicated factory setup */
gtk_window_set_auto_startup_notification (FALSE);
/* Get parameters. */
geometry = NULL;
kill_shell = FALSE;
@ -349,6 +362,7 @@ main (int argc, char *argv[])
kill_shell, restart_shell, no_default_window, no_desktop,
!(kill_shell || restart_shell),
browser_window,
startup_id_copy,
geometry,
args);
if (is_event_loop_needed ()) {

View file

@ -520,6 +520,7 @@ action_new_window_callback (GtkAction *action,
current_window = NAUTILUS_WINDOW (user_data);
new_window = nautilus_application_create_navigation_window (
current_window->application,
NULL,
gtk_window_get_screen (GTK_WINDOW (current_window)));
nautilus_window_go_home (new_window);
}

View file

@ -10,8 +10,8 @@ module Nautilus {
typedef sequence<URI> URIList;
interface Shell : ::Bonobo::Unknown {
void open_windows (in URIList uris, in string geometry, in boolean browser_window);
void open_default_window (in string geometry, in boolean browser_window);
void open_windows (in URIList uris, in string startup_id, in string geometry, in boolean browser_window);
void open_default_window (in string startup_id, in string geometry, in boolean browser_window);
void start_desktop ();
void stop_desktop ();
void quit ();

View file

@ -63,10 +63,12 @@ struct NautilusShellDetails {
static void finalize (GObject *shell);
static void corba_open_windows (PortableServer_Servant servant,
const Nautilus_URIList *list,
const CORBA_char *startup_id,
const CORBA_char *geometry,
CORBA_boolean browser_window,
CORBA_Environment *ev);
static void corba_open_default_window (PortableServer_Servant servant,
const CORBA_char *startup_id,
const CORBA_char *geometry,
CORBA_boolean browser_window,
CORBA_Environment *ev);
@ -125,8 +127,8 @@ nautilus_shell_new (NautilusApplication *application)
}
static void
open_window (NautilusShell *shell, const char *uri, const char *geometry,
gboolean browser_window)
open_window (NautilusShell *shell, const char *uri, const char *startup_id,
const char *geometry, gboolean browser_window)
{
char *home_uri;
NautilusWindow *window;
@ -134,6 +136,7 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry,
if (browser_window ||
eel_preferences_get_boolean (NAUTILUS_PREFERENCES_ALWAYS_USE_BROWSER)) {
window = nautilus_application_create_navigation_window (shell->details->application,
startup_id,
gdk_screen_get_default ());
if (uri == NULL) {
nautilus_window_go_home (window);
@ -149,6 +152,7 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry,
window = nautilus_application_present_spatial_window (shell->details->application,
NULL,
startup_id,
uri,
gdk_screen_get_default ());
g_free (home_uri);
@ -166,6 +170,7 @@ open_window (NautilusShell *shell, const char *uri, const char *geometry,
static void
corba_open_windows (PortableServer_Servant servant,
const Nautilus_URIList *list,
const CORBA_char *startup_id,
const CORBA_char *geometry,
CORBA_boolean browser_window,
CORBA_Environment *ev)
@ -178,12 +183,13 @@ corba_open_windows (PortableServer_Servant servant,
/* Open windows at each requested location. */
for (i = 0; i < list->_length; i++) {
g_assert (list->_buffer[i] != NULL);
open_window (shell, list->_buffer[i], geometry, browser_window);
open_window (shell, list->_buffer[i], startup_id, geometry, browser_window);
}
}
static void
corba_open_default_window (PortableServer_Servant servant,
const CORBA_char *startup_id,
const CORBA_char *geometry,
CORBA_boolean browser_window,
CORBA_Environment *ev)
@ -194,7 +200,7 @@ corba_open_default_window (PortableServer_Servant servant,
if (!restore_window_states (shell)) {
/* Open a window pointing at the default location. */
open_window (shell, NULL, geometry, browser_window);
open_window (shell, NULL, startup_id, geometry, browser_window);
}
}
@ -345,10 +351,12 @@ restore_one_window_callback (const char *attributes,
if (eel_strlen (location) > 0) {
window = nautilus_application_present_spatial_window (shell->details->application,
NULL,
NULL, /* FIXME: Need startup_id? */
location,
screen);
} else {
window = nautilus_application_create_navigation_window (shell->details->application,
NULL, /* FIXME: Need startup_id? */
screen);
nautilus_window_go_home (window);
}

View file

@ -451,6 +451,7 @@ nautilus_window_open_location_full (NautilusWindow *window,
if (!NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change) {
target_window = nautilus_application_create_navigation_window
(window->application,
NULL,
gtk_window_get_screen (GTK_WINDOW (window)));
} else {
NAUTILUS_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE;
@ -461,6 +462,7 @@ nautilus_window_open_location_full (NautilusWindow *window,
target_window = nautilus_application_present_spatial_window_with_selection (
window->application,
window,
NULL,
location,
new_selection,
gtk_window_get_screen (GTK_WINDOW (window)));
@ -477,12 +479,14 @@ nautilus_window_open_location_full (NautilusWindow *window,
target_window = nautilus_application_present_spatial_window (
window->application,
window,
NULL,
location,
gtk_window_get_screen (GTK_WINDOW (window)));
break;
case NAUTILUS_WINDOW_OPEN_IN_NAVIGATION :
target_window = nautilus_application_create_navigation_window
(window->application,
NULL,
gtk_window_get_screen (GTK_WINDOW (window)));
break;
default :

View file

@ -56,6 +56,9 @@ struct NautilusWindowDetails
GtkUIManager *ui_manager;
GtkActionGroup *main_action_group; /* owned by ui_manager */
guint help_message_cid;
/* Startup ID; for startup notification shutoff */
char *startup_id;
/* Menus. */
guint extensions_menu_merge_id;

View file

@ -143,6 +143,8 @@ nautilus_window_init (NautilusWindow *window)
window->details->show_hidden_files_mode = NAUTILUS_WINDOW_SHOW_HIDDEN_FILES_DEFAULT;
window->details->startup_id = NULL;
/* Set initial window title */
gtk_window_set_title (GTK_WINDOW (window), _("Nautilus"));
@ -463,7 +465,7 @@ nautilus_window_constructed (NautilusWindow *window)
static void
nautilus_window_set_property (GObject *object,
guint arg_id,
const GValue *value,
const GValue *value,
GParamSpec *pspec)
{
NautilusWindow *window;
@ -551,6 +553,8 @@ nautilus_window_finalize (GObject *object)
g_source_remove (window->details->location_change_at_idle_id);
}
g_free (window->details->startup_id);
g_free (window->details->title);
g_free (window->details);

View file

@ -5,6 +5,7 @@ _Comment=View your network servers in the Nautilus file manager
TryExec=nautilus
Exec=nautilus network:
Terminal=false
StartupNotify=true
Type=Application
Icon=gnome-fs-network
Categories=Application;Core;