Commit fb27d908 authored by Alexander Larsson's avatar Alexander Larsson Committed by Alexander Larsson

Allow to register shortcuts for in-process IIDs so that activation doesn't

2003-11-03  Alexander Larsson  <alexl@redhat.com>

	* libnautilus-private/nautilus-bonobo-extensions.h:
	* libnautilus-private/nautilus-bonobo-extensions.c:
	(nautilus_bonobo_register_activation_shortcut),
	(nautilus_bonobo_unregister_activation_shortcut),
	(nautilus_bonobo_activate_from_id):
	Allow to register shortcuts for in-process IIDs so
	that activation doesn't go through bonobo-activation.

	* src/nautilus-application.c: (create_object_shortcut),
	(nautilus_application_instance_init),
	(nautilus_application_destroy):
	* components/emblem/libmain.c:
	* components/history/libmain.c:
	* components/notes/nautilus-notes.c:
	* components/tree/libmain.c:
	Register activation shortcuts.

	* src/nautilus-navigation-window.c:
	(nautilus_navigation_window_hide_sidebar),
	(nautilus_navigation_window_show_sidebar):
	Avoid gratuitus gconf write.
parent b9ba65cf
2003-11-03 Alexander Larsson <alexl@redhat.com>
* libnautilus-private/nautilus-bonobo-extensions.h:
* libnautilus-private/nautilus-bonobo-extensions.c:
(nautilus_bonobo_register_activation_shortcut),
(nautilus_bonobo_unregister_activation_shortcut),
(nautilus_bonobo_activate_from_id):
Allow to register shortcuts for in-process IIDs so
that activation doesn't go through bonobo-activation.
* src/nautilus-application.c: (create_object_shortcut),
(nautilus_application_instance_init),
(nautilus_application_destroy):
* components/emblem/libmain.c:
* components/history/libmain.c:
* components/notes/nautilus-notes.c:
* components/tree/libmain.c:
Register activation shortcuts.
* src/nautilus-navigation-window.c:
(nautilus_navigation_window_hide_sidebar),
(nautilus_navigation_window_show_sidebar):
Avoid gratuitus gconf write.
2003-11-01 Alexander Larsson <alexl@redhat.com>
* src/nautilus-window.c (nautilus_window_hide_status_bar)
......
......@@ -30,6 +30,24 @@
#include "nautilus-emblem-view.h"
#include <bonobo.h>
#include <bonobo-activation/bonobo-activation.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
static gboolean shortcut_registered = FALSE;
static CORBA_Object
create_object (const char *iid,
gpointer callback_data)
{
NautilusEmblemView *view;
if (strcmp (iid, EMBLEM_VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
view = NAUTILUS_EMBLEM_VIEW (g_object_new (NAUTILUS_TYPE_EMBLEM_VIEW, NULL));
return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
}
static CORBA_Object
emblem_shlib_make_object (PortableServer_POA poa,
......@@ -39,15 +57,21 @@ emblem_shlib_make_object (PortableServer_POA poa,
{
NautilusEmblemView *view;
if (!shortcut_registered) {
nautilus_bonobo_register_activation_shortcut (EMBLEM_VIEW_IID,
create_object, NULL);
shortcut_registered = TRUE;
}
if (strcmp (iid, EMBLEM_VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
view = NAUTILUS_EMBLEM_VIEW (g_object_new (NAUTILUS_TYPE_EMBLEM_VIEW, NULL));
bonobo_activation_plugin_use (poa, impl_ptr);
return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev);
return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
}
static const BonoboActivationPluginObject emblem_plugin_list[] = {
......
......@@ -30,6 +30,24 @@
#include "nautilus-history-view.h"
#include <bonobo.h>
#include <bonobo-activation/bonobo-activation.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
static gboolean shortcut_registered = FALSE;
static CORBA_Object
create_object (const char *iid,
gpointer callback_data)
{
NautilusHistoryView *view;
if (strcmp (iid, VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
view = NAUTILUS_HISTORY_VIEW (g_object_new (NAUTILUS_TYPE_HISTORY_VIEW, NULL));
return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
}
static CORBA_Object
history_shlib_make_object (PortableServer_POA poa,
......@@ -39,6 +57,12 @@ history_shlib_make_object (PortableServer_POA poa,
{
NautilusHistoryView *view;
if (!shortcut_registered) {
nautilus_bonobo_register_activation_shortcut (VIEW_IID,
create_object, NULL);
shortcut_registered = TRUE;
}
if (strcmp (iid, VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
......
......@@ -46,6 +46,7 @@
#include <libnautilus/nautilus-clipboard.h>
#include <libnautilus/nautilus-view.h>
#include <libnautilus/nautilus-view-standard-main.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
/* FIXME bugzilla.gnome.org 44436:
* Undo not working in notes-view.
......@@ -434,6 +435,23 @@ make_notes_view ()
return BONOBO_OBJECT (notes->view);
}
static gboolean shortcut_registered = FALSE;
static CORBA_Object
create_object (const char *iid,
gpointer callback_data)
{
BonoboObject *view;
if (strcmp (iid, VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
view = make_notes_view ();
return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
}
static CORBA_Object
notes_shlib_make_object (PortableServer_POA poa,
......@@ -443,6 +461,12 @@ notes_shlib_make_object (PortableServer_POA poa,
{
BonoboObject *view;
if (!shortcut_registered) {
nautilus_bonobo_register_activation_shortcut (VIEW_IID,
create_object, NULL);
shortcut_registered = TRUE;
}
if (strcmp (iid, VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
......
......@@ -30,6 +30,24 @@
#include "nautilus-tree-view.h"
#include <bonobo.h>
#include <bonobo-activation/bonobo-activation.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
static gboolean shortcut_registered = FALSE;
static CORBA_Object
create_object (const char *iid,
gpointer callback_data)
{
NautilusTreeView *view;
if (strcmp (iid, TREE_VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
view = NAUTILUS_TREE_VIEW (g_object_new (NAUTILUS_TYPE_TREE_VIEW, NULL));
return CORBA_Object_duplicate (BONOBO_OBJREF (view), NULL);
}
static CORBA_Object
tree_shlib_make_object (PortableServer_POA poa,
......@@ -39,6 +57,12 @@ tree_shlib_make_object (PortableServer_POA poa,
{
NautilusTreeView *view;
if (!shortcut_registered) {
nautilus_bonobo_register_activation_shortcut (TREE_VIEW_IID,
create_object, NULL);
shortcut_registered = TRUE;
}
if (strcmp (iid, TREE_VIEW_IID) != 0) {
return CORBA_OBJECT_NIL;
}
......
......@@ -30,6 +30,7 @@
#include <eel/eel-string.h>
#include <eel/eel-gnome-extensions.h>
#include <eel/eel-debug.h>
#include <bonobo/bonobo-ui-util.h>
#include <gtk/gtkmain.h>
#include <libgnomevfs/gnome-vfs-utils.h>
......@@ -507,6 +508,44 @@ activation_handle_free (NautilusBonoboActivationHandle *handle)
g_free (handle);
}
static GHashTable *nautilus_activation_shortcuts = NULL;
struct CreateObjectData {
NautilusBonoboCreateObject create_object;
gpointer callback_data;
};
void
nautilus_bonobo_register_activation_shortcut (const char *iid,
NautilusBonoboCreateObject create_object_callback,
gpointer callback_data)
{
struct CreateObjectData *data;
if (nautilus_activation_shortcuts == NULL) {
nautilus_activation_shortcuts = g_hash_table_new_full
(g_str_hash, g_str_equal, g_free, g_free);
eel_debug_call_at_shutdown_with_data ((GFreeFunc)g_hash_table_destroy,
nautilus_activation_shortcuts);
}
data = g_new (struct CreateObjectData, 1);
data->create_object = create_object_callback;
data->callback_data = callback_data;
g_hash_table_insert (nautilus_activation_shortcuts,
g_strdup (iid), data);
}
void
nautilus_bonobo_unregister_activation_shortcut (const char *iid)
{
if (nautilus_activation_shortcuts == NULL) {
g_assert_not_reached ();
return;
}
g_hash_table_remove (nautilus_activation_shortcuts, iid);
}
static gboolean
activation_idle_callback (gpointer callback_data)
{
......@@ -567,7 +606,9 @@ nautilus_bonobo_activate_from_id (const char *iid,
gpointer callback_data)
{
NautilusBonoboActivationHandle *handle;
struct CreateObjectData *data;
CORBA_Object activated_object;
g_return_val_if_fail (iid != NULL, NULL);
g_return_val_if_fail (callback != NULL, NULL);
......@@ -577,6 +618,23 @@ nautilus_bonobo_activate_from_id (const char *iid,
handle->callback = callback;
handle->callback_data = callback_data;
handle->activated_object = CORBA_OBJECT_NIL;
if (nautilus_activation_shortcuts != NULL) {
data = g_hash_table_lookup (nautilus_activation_shortcuts, iid);
if (data != NULL) {
activated_object = (*data->create_object) (iid, data->callback_data);
if (activated_object != CORBA_OBJECT_NIL) {
handle->activated_object = activated_object;
handle->early_completion_hook = NULL;
handle->idle_id = g_idle_add (activation_idle_callback,
handle);
return handle;
}
}
}
bonobo_activation_activate_from_id_async ((char *) iid, 0,
bonobo_activation_activation_callback,
handle, NULL);
......
......@@ -29,6 +29,7 @@
#include <bonobo/bonobo-ui-component.h>
#include <bonobo/bonobo-xobject.h>
#include <bonobo/bonobo-generic-factory.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
typedef struct NautilusBonoboActivationHandle NautilusBonoboActivationHandle;
......@@ -37,6 +38,9 @@ typedef void (*NautilusBonoboActivationCallback) (NautilusBonoboActivationHandle
Bonobo_Unknown activated_object,
gpointer callback_data);
typedef CORBA_Object (*NautilusBonoboCreateObject) (const char *iid,
gpointer callback_data);
void nautilus_bonobo_set_accelerator (BonoboUIComponent *ui,
const char *path,
const char *accelerator);
......@@ -99,6 +103,10 @@ void nautilus_bonobo_set_icon
const char *path,
const char *icon_relative_path);
void nautilus_bonobo_register_activation_shortcut (const char *iid,
NautilusBonoboCreateObject create_object_callback,
gpointer callback_data);
void nautilus_bonobo_unregister_activation_shortcut (const char *iid);
NautilusBonoboActivationHandle *nautilus_bonobo_activate_from_id (const char *iid,
NautilusBonoboActivationCallback callback,
gpointer callback_data);
......
......@@ -152,6 +152,13 @@ nautilus_application_get_spatial_window_list (void)
return nautilus_application_spatial_window_list;
}
static CORBA_Object
create_object_shortcut (const char *iid,
gpointer callback_data)
{
return create_object (BONOBO_OBJREF (callback_data), iid, NULL);
}
static void
nautilus_application_instance_init (NautilusApplication *application)
{
......@@ -165,6 +172,11 @@ nautilus_application_instance_init (NautilusApplication *application)
/* Watch for volume unmounts so we can close open windows */
g_signal_connect_object (nautilus_volume_monitor_get (), "volume_unmounted",
G_CALLBACK (volume_unmounted_callback), application, 0);
nautilus_bonobo_register_activation_shortcut (NAUTILUS_ICON_VIEW_IID, create_object_shortcut, application);
nautilus_bonobo_register_activation_shortcut (NAUTILUS_DESKTOP_ICON_VIEW_IID, create_object_shortcut, application);
nautilus_bonobo_register_activation_shortcut (NAUTILUS_LIST_VIEW_IID, create_object_shortcut, application);
nautilus_bonobo_register_activation_shortcut (SEARCH_LIST_VIEW_IID, create_object_shortcut, application);
}
NautilusApplication *
......@@ -188,6 +200,11 @@ nautilus_application_destroy (BonoboObject *object)
application = NAUTILUS_APPLICATION (object);
nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_ICON_VIEW_IID);
nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_DESKTOP_ICON_VIEW_IID);
nautilus_bonobo_unregister_activation_shortcut (NAUTILUS_LIST_VIEW_IID);
nautilus_bonobo_unregister_activation_shortcut (SEARCH_LIST_VIEW_IID);
nautilus_bookmarks_exiting ();
bonobo_object_unref (application->undo_manager);
......
......@@ -1364,7 +1364,8 @@ nautilus_navigation_window_hide_sidebar (NautilusNavigationWindow *window)
nautilus_navigation_window_tear_down_sidebar (window);
nautilus_navigation_window_update_show_hide_menu_items (window);
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR) &&
eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, FALSE);
}
}
......@@ -1378,7 +1379,8 @@ nautilus_navigation_window_show_sidebar (NautilusNavigationWindow *window)
nautilus_navigation_window_set_up_sidebar (window);
nautilus_navigation_window_update_show_hide_menu_items (window);
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
if (eel_preferences_key_is_writable (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR) &&
!eel_preferences_get_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR)) {
eel_preferences_set_boolean (NAUTILUS_PREFERENCES_START_WITH_SIDEBAR, TRUE);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment