impl. to cope with having a paned with no child2, without doing lots of

2002-03-07  Michael Meeks  <michael@ximian.com>

	* libnautilus-private/nautilus-horizontal-splitter.c
	(nautilus_horizontal_splitter_size_allocate): impl. to
	cope with having a paned with no child2, without doing
	lots of bogus size re-allocation.
	(nautilus_horizontal_splitter_class_init): upd.
	(nautilus_horizontal_splitter_pack2): impl, since
	gtkpaned relies on the re-size to generate an expose
	to re-render it's splitter grabber thing.a

	* src/nautilus-sidebar.c
	(nautilus_sidebar_set_width): impl. moving all sidebar
	preferences here,
	(nautilus_sidebar_init): move auto value setup
	here from class_init to save possible re-enterancy
	issue. Request the size we want for the sidebar,
	the pane will under-allocate if neccessary.
	Set the old_width to the correct size so we don't
	re-render the paned lots as it swiches about.

	* src/nautilus-window.c
	(nautilus_window_constructed): reflow to simplify,
	call sidebar_set_width.
	(nautilus_window_set_content_view_widget): use
	nautilus_..._pack2 instead of gtk_paned to fix rendering.

2002-03-06  Michael Meeks  <michael@ximian.com>

	* components/notes/nautilus-notes.c
	(make_notes_view): upd.

	* components/news/nautilus-news.c
	(rss_read_done_callback): parse the RTF, but don't spew
	warnings everywhere.
	(make_news_view): upd.

	* components/throbber/main.c
	(cb_create_throbber): impl.
	(throbber_object_destroyed, throbber_make_object):
	axe cut & paste.

	* libnautilus/nautilus-view-standard-main.c
	(nautilus_view_create_from_get_type_function):
	widen from NautilusView to BonoboObject, this
	code has a much wider application.
	(make_object): ditto.

	* components/hardware/nautilus-hardware-view.c
	(nautilus_hardware_view_get_nautilus_view): upd.

	* components/throbber/nautilus-throbber.c
	(nautilus_throbber_new): kill.

	* libnautilus/nautilus-view-standard-main.c
	(nautilus_view_standard_main_multi): use gdk_get_display.

	* libnautilus-private/nautilus-bonobo-extensions.c
	(nautilus_bonobo_activation_register_for_display): impl.

	* src/nautilus-application.c
	(nautilus_application_startup): use it.

	* src/nautilus-window-toolbars.c
	(location_change_at_idle_callback),
	(throbber_callback): move from nautilus-window.c
	(nautilus_window_allow_stop): move this here,
	prune redundant sets, simplify property bag
	extraction.

	* src/nautilus-window.c
	(nautilus_window_constructed): move throbber
	location changed code out of here.
	(nautilus_window_unrealize): no explicit removal
	from remote property bag neccessary & upd.

	* libnautilus-private/nautilus-metafile-factory.c
	(corba_open): reduce complexity.
This commit is contained in:
Michael Meeks 2002-03-07 14:02:19 +00:00 committed by Michael Meeks
parent 933e88806a
commit 6b5798037c
27 changed files with 540 additions and 700 deletions

View file

@ -1,3 +1,82 @@
2002-03-07 Michael Meeks <michael@ximian.com>
* libnautilus-private/nautilus-horizontal-splitter.c
(nautilus_horizontal_splitter_size_allocate): impl. to
cope with having a paned with no child2, without doing
lots of bogus size re-allocation.
(nautilus_horizontal_splitter_class_init): upd.
(nautilus_horizontal_splitter_pack2): impl, since
gtkpaned relies on the re-size to generate an expose
to re-render it's splitter grabber thing.a
* src/nautilus-sidebar.c
(nautilus_sidebar_set_width): impl. moving all sidebar
preferences here,
(nautilus_sidebar_init): move auto value setup
here from class_init to save possible re-enterancy
issue. Request the size we want for the sidebar,
the pane will under-allocate if neccessary.
Set the old_width to the correct size so we don't
re-render the paned lots as it swiches about.
* src/nautilus-window.c
(nautilus_window_constructed): reflow to simplify,
call sidebar_set_width.
(nautilus_window_set_content_view_widget): use
nautilus_..._pack2 instead of gtk_paned to fix rendering.
2002-03-06 Michael Meeks <michael@ximian.com>
* components/notes/nautilus-notes.c
(make_notes_view): upd.
* components/news/nautilus-news.c
(rss_read_done_callback): parse the RTF, but don't spew
warnings everywhere.
(make_news_view): upd.
* components/throbber/main.c
(cb_create_throbber): impl.
(throbber_object_destroyed, throbber_make_object):
axe cut & paste.
* libnautilus/nautilus-view-standard-main.c
(nautilus_view_create_from_get_type_function):
widen from NautilusView to BonoboObject, this
code has a much wider application.
(make_object): ditto.
* components/hardware/nautilus-hardware-view.c
(nautilus_hardware_view_get_nautilus_view): upd.
* components/throbber/nautilus-throbber.c
(nautilus_throbber_new): kill.
* libnautilus/nautilus-view-standard-main.c
(nautilus_view_standard_main_multi): use gdk_get_display.
* libnautilus-private/nautilus-bonobo-extensions.c
(nautilus_bonobo_activation_register_for_display): impl.
* src/nautilus-application.c
(nautilus_application_startup): use it.
* src/nautilus-window-toolbars.c
(location_change_at_idle_callback),
(throbber_callback): move from nautilus-window.c
(nautilus_window_allow_stop): move this here,
prune redundant sets, simplify property bag
extraction.
* src/nautilus-window.c
(nautilus_window_constructed): move throbber
location changed code out of here.
(nautilus_window_unrealize): no explicit removal
from remote property bag neccessary & upd.
* libnautilus-private/nautilus-metafile-factory.c
(corba_open): reduce complexity.
2002-03-07 Anders Carlsson <andersca@gnu.org>
* configure.in: Require eel 1.1.7

View file

@ -32,7 +32,7 @@
#include <libnautilus-private/nautilus-global-preferences.h>
#include <eel/eel-debug.h>
static NautilusView *
static BonoboObject *
cb_create_hardware_view (const char *ignore0, void *ignore1)
{
NautilusHardwareView *hardware_view =

View file

@ -205,10 +205,10 @@ nautilus_hardware_view_destroy (GtkObject *object)
}
/* Component embedding support */
NautilusView *
BonoboObject *
nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *hardware_view)
{
return hardware_view->details->nautilus_view;
return BONOBO_OBJECT (hardware_view->details->nautilus_view);
}
static char *

View file

@ -53,7 +53,7 @@ struct _NautilusHardwareViewClass {
GtkType nautilus_hardware_view_get_type (void);
/* Component embedding support */
NautilusView *nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *view);
BonoboObject *nautilus_hardware_view_get_nautilus_view (NautilusHardwareView *view);
/* URI handling */
void nautilus_hardware_view_load_uri (NautilusHardwareView *view,

View file

@ -1081,6 +1081,7 @@ rss_read_done_callback (GnomeVFSResult result,
GList *old_items;
int item_count, changed_count;
RSSChannelData *channel_data;
xmlSAXHandler silent_handler;
char *buffer;
@ -1100,9 +1101,12 @@ rss_read_done_callback (GnomeVFSResult result,
/* Parse the rss file with libxml. The libxml parser requires a zero-terminated array. */
buffer = g_realloc (file_contents, file_size + 1);
buffer[file_size] = '\0';
rss_document = xmlParseMemory (buffer, file_size);
g_free (buffer);
initxmlDefaultSAXHandler (&silent_handler, FALSE);
silent_handler.error = NULL;
silent_handler.fatalError = NULL;
rss_document = xmlSAXParseMemory (&silent_handler, buffer, file_size, 0);
g_free (buffer);
/* make sure there wasn't in error parsing the document */
if (rss_document == NULL) {
@ -2413,8 +2417,8 @@ set_up_main_widgets (News *news, GtkWidget *container)
}
static NautilusView *
make_news_view (const char *iid, gpointer callback_data)
static BonoboObject *
make_news_view (const char *iid, void *callback_data)
{
News *news;
@ -2499,7 +2503,7 @@ make_news_view (const char *iid, gpointer callback_data)
set_views_for_mode (news);
/* return the nautilus view */
return news->view;
return BONOBO_OBJECT (news->view);
}
int

View file

@ -352,8 +352,8 @@ notes_get_indicator_image (const char *notes_text)
return NULL;
}
static NautilusView *
make_notes_view (const char *iid, gpointer callback_data)
static BonoboObject *
make_notes_view (const char *iid, void *callback_data)
{
GtkWidget *vbox;
Notes *notes;
@ -417,7 +417,7 @@ make_notes_view (const char *iid, gpointer callback_data)
nautilus_undo_editable_set_undo_key (GTK_EDITABLE (notes->note_text_field), TRUE);
#endif
return notes->view;
return BONOBO_OBJECT (notes->view);
}
int

View file

@ -26,87 +26,36 @@
#include "nautilus-throbber.h"
#include <eel/eel-debug.h>
#include <libgnomeui/gnome-client.h>
#include <libgnomeui/gnome-ui-init.h>
#include <libgnomevfs/gnome-vfs-init.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <string.h>
#include <libnautilus/nautilus-view-standard-main.h>
static int object_count = 0;
static void
throbber_object_destroyed (GtkObject *obj)
{
object_count--;
if (object_count <= 0) {
gtk_main_quit ();
}
}
#define FACTORY_IID "OAFIID:nautilus_throbber_factory"
#define VIEW_IID "OAFIID:nautilus_throbber"
static BonoboObject *
throbber_make_object (BonoboGenericFactory *factory,
const char *iid,
void *closure)
cb_create_throbber (const char *ignore0, void *ignore1)
{
NautilusThrobber *throbber;
BonoboObject *bonobo_control;
if (strcmp (iid, "OAFIID:nautilus_throbber")) {
return NULL;
}
throbber = NAUTILUS_THROBBER (g_object_new (NAUTILUS_TYPE_THROBBER, NULL));
object_count++;
bonobo_control = nautilus_throbber_get_control (throbber);
g_signal_connect (bonobo_control, "destroy", G_CALLBACK (throbber_object_destroyed), NULL);
return bonobo_control;
NautilusThrobber *throbber =
g_object_new (NAUTILUS_TYPE_THROBBER, NULL);
return nautilus_throbber_get_control (throbber);
}
int
main (int argc, char *argv[])
{
BonoboGenericFactory *factory;
char *registration_id;
if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
eel_make_warnings_and_criticals_stop_in_debugger ();
}
/* Initialize libraries. */
gnome_program_init ("nautilus-throbber",
VERSION,
LIBGNOMEUI_MODULE,
argc, argv,
NULL);
bonobo_ui_init ("nautilus-throbber", VERSION, &argc, argv);
/* Disable session manager connection */
g_object_set (G_OBJECT (gnome_program_get()),
GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, NULL);
nautilus_global_preferences_init ();
registration_id = bonobo_activation_make_registration_id ("OAFIID:nautilus_throbber_factory", g_getenv ("DISPLAY"));
factory = bonobo_generic_factory_new ("OAFIID:nautilus_throbber_factory",
throbber_make_object,
NULL);
g_free (registration_id);
if (factory != NULL) {
bonobo_activate ();
do {
gtk_main ();
} while (object_count > 0);
bonobo_object_unref (factory);
}
gnome_vfs_shutdown ();
return EXIT_SUCCESS;
return nautilus_view_standard_main ("nautilus-throbber",
VERSION,
GETTEXT_PACKAGE,
GNOMELOCALEDIR,
argc,
argv,
FACTORY_IID,
VIEW_IID,
cb_create_throbber,
nautilus_global_preferences_init,
NULL);
}

View file

@ -28,6 +28,7 @@
#include <config.h>
#include "nautilus-throbber.h"
#include <eel/eel-debug.h>
#include <eel/eel-glib-extensions.h>
#include <eel/eel-graphic-effects.h>
#include <eel/eel-gtk-extensions.h>
@ -37,6 +38,7 @@
#include <gtk/gtksignal.h>
#include <libgnome/gnome-macros.h>
#include <libgnome/gnome-util.h>
#include <libnautilus/nautilus-view-standard-main.h>
#include <libnautilus-private/nautilus-file-utilities.h>
#include <libnautilus-private/nautilus-global-preferences.h>
#include <libnautilus-private/nautilus-icon-factory.h>
@ -240,20 +242,13 @@ nautilus_throbber_instance_init (NautilusThrobber *throbber)
nautilus_throbber_load_images (throbber);
gtk_widget_show (widget);
/* add a callback for when the theme changes */
eel_preferences_add_callback (NAUTILUS_PREFERENCES_THEME,
nautilus_throbber_theme_changed,
throbber);
}
/* allocate a new throbber */
GtkWidget *
nautilus_throbber_new (void)
{
return gtk_widget_new (nautilus_throbber_get_type (), NULL);
}
/* handler for handling theme changes */
static void
nautilus_throbber_theme_changed (gpointer user_data)

View file

@ -31,9 +31,7 @@
#include <gtk/gtkeventbox.h>
#include <bonobo.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
#define NAUTILUS_TYPE_THROBBER (nautilus_throbber_get_type ())
#define NAUTILUS_THROBBER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_THROBBER, NautilusThrobber))
@ -54,22 +52,19 @@ struct NautilusThrobberClass {
GtkEventBoxClass parent_class;
/* signals */
void (* location_changed) (NautilusThrobber *throbber,
const char *location);
void (* location_changed) (NautilusThrobber *throbber,
const char *location);
};
GtkType nautilus_throbber_get_type (void);
GtkWidget * nautilus_throbber_new (void);
GtkType nautilus_throbber_get_type (void);
GtkWidget *nautilus_throbber_new (void);
BonoboObject *nautilus_throbber_get_control (NautilusThrobber *throbber);
void nautilus_throbber_start (NautilusThrobber *throbber);
void nautilus_throbber_stop (NautilusThrobber *throbber);
void nautilus_throbber_set_small_mode (NautilusThrobber *throbber,
gboolean new_mode);
BonoboObject* nautilus_throbber_get_control (NautilusThrobber *throbber);
void nautilus_throbber_start (NautilusThrobber *throbber);
void nautilus_throbber_stop (NautilusThrobber *throbber);
void nautilus_throbber_set_small_mode (NautilusThrobber *throbber, gboolean new_mode);
#ifdef __cplusplus
}
#endif /* __cplusplus */
G_END_DECLS
#endif /* NAUTILUS_THROBBER_H */

View file

@ -613,3 +613,20 @@ nautilus_bonobo_activate_cancel (NautilusBonoboActivationHandle *handle)
activation_cancel (handle);
}
}
Bonobo_RegistrationResult
nautilus_bonobo_activation_register_for_display (const char *iid,
Bonobo_Unknown ref)
{
char *real_iid;
Bonobo_RegistrationResult result;
real_iid = bonobo_activation_make_registration_id (
iid, gdk_get_display ());
result = bonobo_activation_active_server_register (real_iid, ref);
g_free (real_iid);
return result;
}

View file

@ -104,4 +104,7 @@ NautilusBonoboActivationHandle *nautilus_bonobo_activate_from_id
gpointer callback_data);
void nautilus_bonobo_activate_cancel (NautilusBonoboActivationHandle *handle);
Bonobo_RegistrationResult nautilus_bonobo_activation_register_for_display (const char *iid,
Bonobo_Unknown ref);
#endif /* NAUTILUS_BONOBO_EXTENSIONS_H */

View file

@ -224,6 +224,47 @@ nautilus_horizontal_splitter_button_release (GtkWidget *widget, GdkEventButton *
return result;
}
static void
nautilus_horizontal_splitter_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
gint border_width;
GtkPaned *paned;
GtkAllocation child_allocation;
GtkRequisition child_requisition;
paned = GTK_PANED (widget);
border_width = GTK_CONTAINER (paned)->border_width;
widget->allocation = *allocation;
if (paned->child2 != NULL && GTK_WIDGET_VISIBLE (paned->child2)) {
EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate,
(widget, allocation));
} else if (paned->child1 && GTK_WIDGET_VISIBLE (paned->child1)) {
if (GTK_WIDGET_REALIZED (widget)) {
gdk_window_hide (paned->handle);
}
gtk_widget_get_child_requisition (paned->child1,
&child_requisition);
child_allocation.x = widget->allocation.x + border_width;
child_allocation.y = widget->allocation.y + border_width;
child_allocation.width = MIN (child_requisition.width,
allocation->width - 2 * border_width);
child_allocation.height = MIN (child_requisition.height,
allocation->height - 2 * border_width);
gtk_widget_size_allocate (paned->child1, &child_allocation);
} else
if (GTK_WIDGET_REALIZED (widget)) {
gdk_window_hide (paned->handle);
}
}
static void
nautilus_horizontal_splitter_class_init (NautilusHorizontalSplitterClass *class)
{
@ -233,6 +274,43 @@ nautilus_horizontal_splitter_class_init (NautilusHorizontalSplitterClass *class)
G_OBJECT_CLASS (class)->finalize = nautilus_horizontal_splitter_finalize;
widget_class->size_allocate = nautilus_horizontal_splitter_size_allocate;
widget_class->button_press_event = nautilus_horizontal_splitter_button_press;
widget_class->button_release_event = nautilus_horizontal_splitter_button_release;
}
void
nautilus_horizontal_splitter_pack2 (NautilusHorizontalSplitter *splitter,
GtkWidget *child2)
{
gboolean re_expose;
GtkPaned *paned;
g_return_if_fail (GTK_IS_WIDGET (child2));
g_return_if_fail (NAUTILUS_IS_HORIZONTAL_SPLITTER (splitter));
paned = GTK_PANED (splitter);
re_expose = (paned->child2 == NULL ||
!GTK_WIDGET_VISIBLE (paned->child2));
gtk_paned_pack2 (paned, child2, TRUE, TRUE);
if (re_expose) {
/* We have to expose the divider, since the pane relies
* on a resize when you add the 2nd item to get it's
* rendering right */
/* this calculates the handle positon correctly */
gtk_widget_size_allocate (GTK_WIDGET (splitter),
&GTK_WIDGET (splitter)->allocation);
/* and this renders it */
gtk_widget_queue_draw_area (GTK_WIDGET (splitter),
paned->handle_pos.x,
paned->handle_pos.y,
paned->handle_pos.width,
paned->handle_pos.height);
}
}

View file

@ -56,6 +56,8 @@ void nautilus_horizontal_splitter_hide (NautilusHorizontalSplitter *splitter
void nautilus_horizontal_splitter_show (NautilusHorizontalSplitter *splitter);
void nautilus_horizontal_splitter_expand (NautilusHorizontalSplitter *splitter);
void nautilus_horizontal_splitter_toggle_position (NautilusHorizontalSplitter *splitter);
void nautilus_horizontal_splitter_pack2 (NautilusHorizontalSplitter *splitter,
GtkWidget *child2);
G_END_DECLS

View file

@ -51,12 +51,10 @@ corba_open (PortableServer_Servant servant,
CORBA_Environment *ev)
{
NautilusMetafile *metafile;
Nautilus_Metafile objref;
metafile = nautilus_metafile_get (directory);
objref = bonobo_object_dup_ref (BONOBO_OBJREF (metafile), NULL);
bonobo_object_unref (metafile);
return objref;
return CORBA_Object_duplicate (BONOBO_OBJREF (metafile), ev);
}
static void

View file

@ -88,8 +88,8 @@ make_object (BonoboGenericFactory *factory,
const char *iid,
gpointer data)
{
BonoboObject *view;
CallbackData *callback_data;
NautilusView *view;
callback_data = (CallbackData *) data;
@ -215,7 +215,8 @@ nautilus_view_standard_main_multi (const char *executable_name,
callback_data.delayed_quit_timeout_id = 0;
/* Create the factory. */
registration_id = bonobo_activation_make_registration_id (factory_iid, DisplayString (gdk_display));
registration_id = bonobo_activation_make_registration_id (
factory_iid, gdk_get_display ());
factory = bonobo_generic_factory_new (registration_id,
make_object,
&callback_data);
@ -313,8 +314,8 @@ nautilus_view_standard_main (const char *executable_name,
typedef GtkType (* TypeFunc) (void);
NautilusView *
BonoboObject *
nautilus_view_create_from_get_type_function (const char *iid, void *user_data)
{
return NAUTILUS_VIEW (g_object_new (((TypeFunc) (user_data)) (), NULL));
return BONOBO_OBJECT (g_object_new (((TypeFunc) (user_data)) (), NULL));
}

View file

@ -37,36 +37,36 @@
G_BEGIN_DECLS
typedef NautilusView * (*NautilusViewCreateFunction) (const char *iid, void *user_data);
typedef BonoboObject * (*NautilusViewCreateFunction) (const char *iid, void *user_data);
int nautilus_view_standard_main (const char *executable_name,
const char *version,
const char *gettext_package_name,
const char *gettext_locale_directory,
int argc,
char **argv,
const char *factory_iid,
const char *view_iid,
NautilusViewCreateFunction create_function,
GVoidFunc post_initialize_callback,
void *user_data);
int nautilus_view_standard_main (const char *executable_name,
const char *version,
const char *gettext_package_name,
const char *gettext_locale_directory,
int argc,
char **argv,
const char *factory_iid,
const char *view_iid,
NautilusViewCreateFunction create_function,
GVoidFunc post_initialize_callback,
void *user_data);
int nautilus_view_standard_main_multi (const char *executable_name,
const char *version,
const char *gettext_package_name,
const char *gettext_locale_directory,
int argc,
char **argv,
const char *factory_iid,
GList *view_iids, /* GList<const char *> */
NautilusViewCreateFunction create_function,
GVoidFunc post_initialize_callback,
void *user_data);
int nautilus_view_standard_main_multi (const char *executable_name,
const char *version,
const char *gettext_package_name,
const char *gettext_locale_directory,
int argc,
char **argv,
const char *factory_iid,
GList *view_iids, /* GList<const char *> */
NautilusViewCreateFunction create_function,
GVoidFunc post_initialize_callback,
void *user_data);
/* standard handy create function (pass the _get_type function for the
* class as the user_data)
*/
NautilusView * nautilus_view_create_from_get_type_function (const char *iid, void *user_data);
BonoboObject *nautilus_view_create_from_get_type_function (const char *iid, void *user_data);
G_END_DECLS

View file

@ -60,6 +60,7 @@
#include <libnautilus-private/nautilus-icon-factory.h>
#include <libnautilus-private/nautilus-metafile-factory.h>
#include <libnautilus-private/nautilus-sound.h>
#include <libnautilus-private/nautilus-bonobo-extensions.h>
#include <libnautilus-private/nautilus-undo-manager.h>
#include <libnautilus-private/nautilus-volume-monitor.h>
#include <libnautilus-private/nautilus-authn-manager.h>
@ -413,7 +414,7 @@ nautilus_application_startup (NautilusApplication *application,
/* Start up the factory. */
while (TRUE) {
/* Try to register the file manager view factory. */
result = bonobo_activation_active_server_register
result = nautilus_bonobo_activation_register_for_display
(FACTORY_IID, BONOBO_OBJREF (application));
switch (result) {

View file

@ -49,6 +49,7 @@
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkpaned.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
@ -131,6 +132,10 @@ static void background_metadata_changed_callback (NautilusSidebar *sideba
#define SIDEBAR_MINIMUM_WIDTH 1
#define SIDEBAR_MINIMUM_HEIGHT 400
/* Some auto-updated values */
static int sidebar_width_auto_value = SIDEBAR_MINIMUM_WIDTH;
static gboolean confirm_trash_auto_value = TRUE;
enum {
LOCATION_CHANGED,
LAST_SIGNAL
@ -166,9 +171,6 @@ typedef enum {
TABS_PART
} SidebarPart;
static gboolean confirm_trash_auto_value;
EEL_CLASS_BOILERPLATE (NautilusSidebar, nautilus_sidebar, GTK_TYPE_EVENT_BOX)
/* initializing the class object by installing the operations we override */
@ -205,9 +207,6 @@ nautilus_sidebar_class_init (GtkObjectClass *object_klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
&confirm_trash_auto_value);
}
/* utility routine to allocate the box the holds the command buttons */
@ -232,16 +231,30 @@ make_button_box (NautilusSidebar *sidebar)
static void
nautilus_sidebar_init (GtkObject *object)
{
GtkWidget *widget;
static gboolean setup_autos = FALSE;
NautilusSidebar *sidebar;
GtkWidget* widget;
sidebar = NAUTILUS_SIDEBAR (object);
widget = GTK_WIDGET (object);
sidebar->details = g_new0 (NautilusSidebarDetails, 1);
if (!setup_autos) {
setup_autos = TRUE;
eel_preferences_add_auto_integer (
NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
&sidebar_width_auto_value);
eel_preferences_add_auto_boolean (
NAUTILUS_PREFERENCES_CONFIRM_TRASH,
&confirm_trash_auto_value);
}
/* set the minimum size of the sidebar */
gtk_widget_set_size_request (widget, SIDEBAR_MINIMUM_WIDTH, SIDEBAR_MINIMUM_HEIGHT);
/* set the requested size of the sidebar */
gtk_widget_set_size_request (widget, sidebar_width_auto_value,
SIDEBAR_MINIMUM_HEIGHT);
sidebar->details->old_width = sidebar_width_auto_value;
/* load the default background from the current theme */
nautilus_sidebar_read_theme(sidebar);
@ -278,8 +291,6 @@ nautilus_sidebar_init (GtkObject *object)
gtk_box_pack_end (GTK_BOX (sidebar->details->container),
GTK_WIDGET (sidebar->details->sidebar_tabs),
FALSE, FALSE, 0);
sidebar->details->old_width = widget->allocation.width;
/* allocate and install the panel tabs */
sidebar->details->notebook = GTK_NOTEBOOK (gtk_notebook_new ());
@ -1687,10 +1698,25 @@ nautilus_sidebar_size_allocate (GtkWidget *widget,
EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
/* remember the size if it changed */
if (widget->allocation.width != sidebar->details->old_width) {
sidebar->details->old_width = widget->allocation.width;
eel_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
widget->allocation.width);
}
}
void
nautilus_sidebar_setup_width (NautilusSidebar *sidebar)
{
GtkPaned *paned;
g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar));
g_return_if_fail (GTK_WIDGET (sidebar)->parent != NULL);
paned = GTK_PANED (GTK_WIDGET (sidebar)->parent);
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
gtk_paned_set_position (paned, sidebar_width_auto_value);
sidebar->details->old_width = sidebar_width_auto_value;
}

View file

@ -72,5 +72,6 @@ void nautilus_sidebar_set_uri (NautilusSidebar *sidebar,
const char *initial_title);
void nautilus_sidebar_set_title (NautilusSidebar *sidebar,
const char *new_title);
void nautilus_sidebar_setup_width (NautilusSidebar *sidebar);
#endif /* NAUTILUS_SIDEBAR_H */

View file

@ -40,7 +40,6 @@
#include "nautilus-zoom-control.h"
#include <X11/Xatom.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-ui-util.h>
#include <eel/eel-debug.h>
#include <eel/eel-gdk-extensions.h>
@ -81,7 +80,6 @@
#include <libnautilus/nautilus-undo.h>
#include <math.h>
#include <sys/time.h>
#include <unistd.h>
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
@ -519,47 +517,6 @@ set_initial_window_geometry (NautilusWindow *window)
max_height_for_screen));
}
static gboolean
location_change_at_idle_callback (gpointer callback_data)
{
NautilusWindow *window;
char *location;
window = NAUTILUS_WINDOW (callback_data);
location = window->details->location_to_change_to_at_idle;
window->details->location_to_change_to_at_idle = NULL;
window->details->location_change_at_idle_id = 0;
nautilus_window_go_to (window, location);
g_free (location);
return FALSE;
}
/* handle bonobo events from the throbber -- since they can come in at
any time right in the middle of things, defer until idle */
static void
throbber_callback (BonoboListener *listener,
const char *event_name,
const CORBA_any *arg,
CORBA_Environment *ev,
gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
g_free (window->details->location_to_change_to_at_idle);
window->details->location_to_change_to_at_idle = g_strdup (BONOBO_ARG_GET_STRING (arg));
if (window->details->location_change_at_idle_id == 0) {
window->details->location_change_at_idle_id =
gtk_idle_add (location_change_at_idle_callback, window);
}
}
/* Add a dummy menu with a "View as ..." item when we first create the
* view_as_option_menu -- without this the menu draws empty and shrunk,
* once we populate it it grows and forces the toolbar and all the other
@ -585,10 +542,7 @@ nautilus_window_constructed (NautilusWindow *window)
{
GtkWidget *location_bar_box;
GtkWidget *view_as_menu_vbox;
int sidebar_width;
BonoboControl *location_bar_wrapper;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
/* CORBA and Bonobo setup, which must be done before the location bar setup */
window->details->ui_container = bonobo_ui_container_new ();
@ -668,29 +622,21 @@ nautilus_window_constructed (NautilusWindow *window)
set_initial_window_geometry (window);
window->content_hbox = nautilus_horizontal_splitter_new ();
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
sidebar_width = eel_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
gtk_paned_set_position (GTK_PANED (window->content_hbox), sidebar_width);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
* for the desktop window.
*/
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* set up the sidebar */
window->sidebar = nautilus_sidebar_new ();
gtk_widget_show (GTK_WIDGET (window->sidebar));
g_signal_connect (window->sidebar, "location_changed",
G_CALLBACK (go_to_callback), window);
G_CALLBACK (go_to_callback), window);
gtk_paned_pack1 (GTK_PANED (window->content_hbox),
GTK_WIDGET (window->sidebar),
FALSE, TRUE);
nautilus_sidebar_setup_width (window->sidebar);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
@ -724,21 +670,6 @@ nautilus_window_constructed (NautilusWindow *window)
/* We'll do the second part later (bookmarks and go menus) */
window->details->ui_pending_initialize_menus_part_2 = TRUE;
/* watch for throbber location changes, too */
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
window->details->throbber_listener =
bonobo_event_source_client_add_listener_full
(property_bag,
g_cclosure_new (G_CALLBACK (throbber_callback), window, NULL),
"Bonobo/Property:change:location", NULL);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
@ -826,33 +757,17 @@ static void
nautilus_window_unrealize (GtkWidget *widget)
{
NautilusWindow *window;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
window = NAUTILUS_WINDOW (widget);
/* Get rid of the throbber explicitly before it self-destructs
* (which it will do when the control frame goes away.
*/
if (window->details->throbber != CORBA_OBJECT_NIL) {
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
window->details->throbber_property_bag = CORBA_OBJECT_NIL;
}
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_event_source_client_remove_listener
(property_bag, window->details->throbber_listener, &ev);
bonobo_object_release_unref (property_bag, &ev);
}
CORBA_Object_release (window->details->throbber_listener, &ev);
window->details->throbber_listener = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
}
bonobo_object_release_unref (window->details->throbber, NULL);
window->details->throbber = CORBA_OBJECT_NIL;
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_Object_release (window->details->throbber_listener, NULL);
window->details->throbber_listener = CORBA_OBJECT_NIL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
@ -1678,35 +1593,6 @@ nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
nautilus_window_ui_thaw (window);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
nautilus_window_ui_freeze (window);
if (allow)
access ("nautilus-throbber: start", 0);
else
access ("nautilus-throbber: stop", 0);
nautilus_bonobo_set_sensitive (window->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_pbclient_set_boolean (property_bag, "throbbing", allow, &ev);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
nautilus_window_ui_thaw (window);
}
void
nautilus_send_history_list_changed (void)
{
@ -1916,9 +1802,9 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
gtk_container_add (GTK_CONTAINER (window->content_hbox),
GTK_WIDGET (new_view));
} else {
gtk_paned_pack2 (GTK_PANED (window->content_hbox),
GTK_WIDGET (new_view),
TRUE, TRUE);
nautilus_horizontal_splitter_pack2 (
NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
GTK_WIDGET (new_view));
}
}

View file

@ -40,7 +40,6 @@
#include "nautilus-zoom-control.h"
#include <X11/Xatom.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-ui-util.h>
#include <eel/eel-debug.h>
#include <eel/eel-gdk-extensions.h>
@ -81,7 +80,6 @@
#include <libnautilus/nautilus-undo.h>
#include <math.h>
#include <sys/time.h>
#include <unistd.h>
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
@ -519,47 +517,6 @@ set_initial_window_geometry (NautilusWindow *window)
max_height_for_screen));
}
static gboolean
location_change_at_idle_callback (gpointer callback_data)
{
NautilusWindow *window;
char *location;
window = NAUTILUS_WINDOW (callback_data);
location = window->details->location_to_change_to_at_idle;
window->details->location_to_change_to_at_idle = NULL;
window->details->location_change_at_idle_id = 0;
nautilus_window_go_to (window, location);
g_free (location);
return FALSE;
}
/* handle bonobo events from the throbber -- since they can come in at
any time right in the middle of things, defer until idle */
static void
throbber_callback (BonoboListener *listener,
const char *event_name,
const CORBA_any *arg,
CORBA_Environment *ev,
gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
g_free (window->details->location_to_change_to_at_idle);
window->details->location_to_change_to_at_idle = g_strdup (BONOBO_ARG_GET_STRING (arg));
if (window->details->location_change_at_idle_id == 0) {
window->details->location_change_at_idle_id =
gtk_idle_add (location_change_at_idle_callback, window);
}
}
/* Add a dummy menu with a "View as ..." item when we first create the
* view_as_option_menu -- without this the menu draws empty and shrunk,
* once we populate it it grows and forces the toolbar and all the other
@ -585,10 +542,7 @@ nautilus_window_constructed (NautilusWindow *window)
{
GtkWidget *location_bar_box;
GtkWidget *view_as_menu_vbox;
int sidebar_width;
BonoboControl *location_bar_wrapper;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
/* CORBA and Bonobo setup, which must be done before the location bar setup */
window->details->ui_container = bonobo_ui_container_new ();
@ -668,29 +622,21 @@ nautilus_window_constructed (NautilusWindow *window)
set_initial_window_geometry (window);
window->content_hbox = nautilus_horizontal_splitter_new ();
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
sidebar_width = eel_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
gtk_paned_set_position (GTK_PANED (window->content_hbox), sidebar_width);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
* for the desktop window.
*/
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* set up the sidebar */
window->sidebar = nautilus_sidebar_new ();
gtk_widget_show (GTK_WIDGET (window->sidebar));
g_signal_connect (window->sidebar, "location_changed",
G_CALLBACK (go_to_callback), window);
G_CALLBACK (go_to_callback), window);
gtk_paned_pack1 (GTK_PANED (window->content_hbox),
GTK_WIDGET (window->sidebar),
FALSE, TRUE);
nautilus_sidebar_setup_width (window->sidebar);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
@ -724,21 +670,6 @@ nautilus_window_constructed (NautilusWindow *window)
/* We'll do the second part later (bookmarks and go menus) */
window->details->ui_pending_initialize_menus_part_2 = TRUE;
/* watch for throbber location changes, too */
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
window->details->throbber_listener =
bonobo_event_source_client_add_listener_full
(property_bag,
g_cclosure_new (G_CALLBACK (throbber_callback), window, NULL),
"Bonobo/Property:change:location", NULL);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
@ -826,33 +757,17 @@ static void
nautilus_window_unrealize (GtkWidget *widget)
{
NautilusWindow *window;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
window = NAUTILUS_WINDOW (widget);
/* Get rid of the throbber explicitly before it self-destructs
* (which it will do when the control frame goes away.
*/
if (window->details->throbber != CORBA_OBJECT_NIL) {
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
window->details->throbber_property_bag = CORBA_OBJECT_NIL;
}
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_event_source_client_remove_listener
(property_bag, window->details->throbber_listener, &ev);
bonobo_object_release_unref (property_bag, &ev);
}
CORBA_Object_release (window->details->throbber_listener, &ev);
window->details->throbber_listener = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
}
bonobo_object_release_unref (window->details->throbber, NULL);
window->details->throbber = CORBA_OBJECT_NIL;
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_Object_release (window->details->throbber_listener, NULL);
window->details->throbber_listener = CORBA_OBJECT_NIL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
@ -1678,35 +1593,6 @@ nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
nautilus_window_ui_thaw (window);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
nautilus_window_ui_freeze (window);
if (allow)
access ("nautilus-throbber: start", 0);
else
access ("nautilus-throbber: stop", 0);
nautilus_bonobo_set_sensitive (window->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_pbclient_set_boolean (property_bag, "throbbing", allow, &ev);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
nautilus_window_ui_thaw (window);
}
void
nautilus_send_history_list_changed (void)
{
@ -1916,9 +1802,9 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
gtk_container_add (GTK_CONTAINER (window->content_hbox),
GTK_WIDGET (new_view));
} else {
gtk_paned_pack2 (GTK_PANED (window->content_hbox),
GTK_WIDGET (new_view),
TRUE, TRUE);
nautilus_horizontal_splitter_pack2 (
NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
GTK_WIDGET (new_view));
}
}

View file

@ -49,6 +49,7 @@
#include <gtk/gtkcheckmenuitem.h>
#include <gtk/gtkdnd.h>
#include <gtk/gtkhbox.h>
#include <gtk/gtkpaned.h>
#include <gtk/gtknotebook.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
@ -131,6 +132,10 @@ static void background_metadata_changed_callback (NautilusSidebar *sideba
#define SIDEBAR_MINIMUM_WIDTH 1
#define SIDEBAR_MINIMUM_HEIGHT 400
/* Some auto-updated values */
static int sidebar_width_auto_value = SIDEBAR_MINIMUM_WIDTH;
static gboolean confirm_trash_auto_value = TRUE;
enum {
LOCATION_CHANGED,
LAST_SIGNAL
@ -166,9 +171,6 @@ typedef enum {
TABS_PART
} SidebarPart;
static gboolean confirm_trash_auto_value;
EEL_CLASS_BOILERPLATE (NautilusSidebar, nautilus_sidebar, GTK_TYPE_EVENT_BOX)
/* initializing the class object by installing the operations we override */
@ -205,9 +207,6 @@ nautilus_sidebar_class_init (GtkObjectClass *object_klass)
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1, G_TYPE_STRING);
eel_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
&confirm_trash_auto_value);
}
/* utility routine to allocate the box the holds the command buttons */
@ -232,16 +231,30 @@ make_button_box (NautilusSidebar *sidebar)
static void
nautilus_sidebar_init (GtkObject *object)
{
GtkWidget *widget;
static gboolean setup_autos = FALSE;
NautilusSidebar *sidebar;
GtkWidget* widget;
sidebar = NAUTILUS_SIDEBAR (object);
widget = GTK_WIDGET (object);
sidebar->details = g_new0 (NautilusSidebarDetails, 1);
if (!setup_autos) {
setup_autos = TRUE;
eel_preferences_add_auto_integer (
NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
&sidebar_width_auto_value);
eel_preferences_add_auto_boolean (
NAUTILUS_PREFERENCES_CONFIRM_TRASH,
&confirm_trash_auto_value);
}
/* set the minimum size of the sidebar */
gtk_widget_set_size_request (widget, SIDEBAR_MINIMUM_WIDTH, SIDEBAR_MINIMUM_HEIGHT);
/* set the requested size of the sidebar */
gtk_widget_set_size_request (widget, sidebar_width_auto_value,
SIDEBAR_MINIMUM_HEIGHT);
sidebar->details->old_width = sidebar_width_auto_value;
/* load the default background from the current theme */
nautilus_sidebar_read_theme(sidebar);
@ -278,8 +291,6 @@ nautilus_sidebar_init (GtkObject *object)
gtk_box_pack_end (GTK_BOX (sidebar->details->container),
GTK_WIDGET (sidebar->details->sidebar_tabs),
FALSE, FALSE, 0);
sidebar->details->old_width = widget->allocation.width;
/* allocate and install the panel tabs */
sidebar->details->notebook = GTK_NOTEBOOK (gtk_notebook_new ());
@ -1687,10 +1698,25 @@ nautilus_sidebar_size_allocate (GtkWidget *widget,
EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation));
/* remember the size if it changed */
if (widget->allocation.width != sidebar->details->old_width) {
sidebar->details->old_width = widget->allocation.width;
eel_preferences_set_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH,
widget->allocation.width);
}
}
void
nautilus_sidebar_setup_width (NautilusSidebar *sidebar)
{
GtkPaned *paned;
g_return_if_fail (NAUTILUS_IS_SIDEBAR (sidebar));
g_return_if_fail (GTK_WIDGET (sidebar)->parent != NULL);
paned = GTK_PANED (GTK_WIDGET (sidebar)->parent);
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
gtk_paned_set_position (paned, sidebar_width_auto_value);
sidebar->details->old_width = sidebar_width_auto_value;
}

View file

@ -72,5 +72,6 @@ void nautilus_sidebar_set_uri (NautilusSidebar *sidebar,
const char *initial_title);
void nautilus_sidebar_set_title (NautilusSidebar *sidebar,
const char *new_title);
void nautilus_sidebar_setup_width (NautilusSidebar *sidebar);
#endif /* NAUTILUS_SIDEBAR_H */

View file

@ -40,7 +40,6 @@
#include "nautilus-zoom-control.h"
#include <X11/Xatom.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-ui-util.h>
#include <eel/eel-debug.h>
#include <eel/eel-gdk-extensions.h>
@ -81,7 +80,6 @@
#include <libnautilus/nautilus-undo.h>
#include <math.h>
#include <sys/time.h>
#include <unistd.h>
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
@ -519,47 +517,6 @@ set_initial_window_geometry (NautilusWindow *window)
max_height_for_screen));
}
static gboolean
location_change_at_idle_callback (gpointer callback_data)
{
NautilusWindow *window;
char *location;
window = NAUTILUS_WINDOW (callback_data);
location = window->details->location_to_change_to_at_idle;
window->details->location_to_change_to_at_idle = NULL;
window->details->location_change_at_idle_id = 0;
nautilus_window_go_to (window, location);
g_free (location);
return FALSE;
}
/* handle bonobo events from the throbber -- since they can come in at
any time right in the middle of things, defer until idle */
static void
throbber_callback (BonoboListener *listener,
const char *event_name,
const CORBA_any *arg,
CORBA_Environment *ev,
gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
g_free (window->details->location_to_change_to_at_idle);
window->details->location_to_change_to_at_idle = g_strdup (BONOBO_ARG_GET_STRING (arg));
if (window->details->location_change_at_idle_id == 0) {
window->details->location_change_at_idle_id =
gtk_idle_add (location_change_at_idle_callback, window);
}
}
/* Add a dummy menu with a "View as ..." item when we first create the
* view_as_option_menu -- without this the menu draws empty and shrunk,
* once we populate it it grows and forces the toolbar and all the other
@ -585,10 +542,7 @@ nautilus_window_constructed (NautilusWindow *window)
{
GtkWidget *location_bar_box;
GtkWidget *view_as_menu_vbox;
int sidebar_width;
BonoboControl *location_bar_wrapper;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
/* CORBA and Bonobo setup, which must be done before the location bar setup */
window->details->ui_container = bonobo_ui_container_new ();
@ -668,29 +622,21 @@ nautilus_window_constructed (NautilusWindow *window)
set_initial_window_geometry (window);
window->content_hbox = nautilus_horizontal_splitter_new ();
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
sidebar_width = eel_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
gtk_paned_set_position (GTK_PANED (window->content_hbox), sidebar_width);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
* for the desktop window.
*/
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* set up the sidebar */
window->sidebar = nautilus_sidebar_new ();
gtk_widget_show (GTK_WIDGET (window->sidebar));
g_signal_connect (window->sidebar, "location_changed",
G_CALLBACK (go_to_callback), window);
G_CALLBACK (go_to_callback), window);
gtk_paned_pack1 (GTK_PANED (window->content_hbox),
GTK_WIDGET (window->sidebar),
FALSE, TRUE);
nautilus_sidebar_setup_width (window->sidebar);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
@ -724,21 +670,6 @@ nautilus_window_constructed (NautilusWindow *window)
/* We'll do the second part later (bookmarks and go menus) */
window->details->ui_pending_initialize_menus_part_2 = TRUE;
/* watch for throbber location changes, too */
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
window->details->throbber_listener =
bonobo_event_source_client_add_listener_full
(property_bag,
g_cclosure_new (G_CALLBACK (throbber_callback), window, NULL),
"Bonobo/Property:change:location", NULL);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
@ -826,33 +757,17 @@ static void
nautilus_window_unrealize (GtkWidget *widget)
{
NautilusWindow *window;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
window = NAUTILUS_WINDOW (widget);
/* Get rid of the throbber explicitly before it self-destructs
* (which it will do when the control frame goes away.
*/
if (window->details->throbber != CORBA_OBJECT_NIL) {
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
window->details->throbber_property_bag = CORBA_OBJECT_NIL;
}
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_event_source_client_remove_listener
(property_bag, window->details->throbber_listener, &ev);
bonobo_object_release_unref (property_bag, &ev);
}
CORBA_Object_release (window->details->throbber_listener, &ev);
window->details->throbber_listener = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
}
bonobo_object_release_unref (window->details->throbber, NULL);
window->details->throbber = CORBA_OBJECT_NIL;
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_Object_release (window->details->throbber_listener, NULL);
window->details->throbber_listener = CORBA_OBJECT_NIL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
@ -1678,35 +1593,6 @@ nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
nautilus_window_ui_thaw (window);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
nautilus_window_ui_freeze (window);
if (allow)
access ("nautilus-throbber: start", 0);
else
access ("nautilus-throbber: stop", 0);
nautilus_bonobo_set_sensitive (window->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_pbclient_set_boolean (property_bag, "throbbing", allow, &ev);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
nautilus_window_ui_thaw (window);
}
void
nautilus_send_history_list_changed (void)
{
@ -1916,9 +1802,9 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
gtk_container_add (GTK_CONTAINER (window->content_hbox),
GTK_WIDGET (new_view));
} else {
gtk_paned_pack2 (GTK_PANED (window->content_hbox),
GTK_WIDGET (new_view),
TRUE, TRUE);
nautilus_horizontal_splitter_pack2 (
NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
GTK_WIDGET (new_view));
}
}

View file

@ -82,8 +82,9 @@ struct NautilusWindowDetails
NautilusViewIdentifier *extra_viewer;
/* Throbber. */
Bonobo_Control throbber;
Bonobo_Listener throbber_listener;
gboolean throbber_active;
Bonobo_PropertyBag throbber_property_bag;
Bonobo_Listener throbber_listener;
/* Deferred location change. */
char *location_to_change_to_at_idle;

View file

@ -28,12 +28,14 @@
#include <config.h>
#include <unistd.h>
#include "nautilus-application.h"
#include "nautilus-window-manage-views.h"
#include "nautilus-window-private.h"
#include "nautilus-window.h"
#include <bonobo/bonobo-control.h>
#include <bonobo/bonobo-property-bag.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-moniker-util.h>
#include <bonobo/bonobo-ui-util.h>
@ -403,6 +405,128 @@ create_back_or_forward_toolbar_item (NautilusWindow *window,
return item;
}
static gboolean
location_change_at_idle_callback (gpointer callback_data)
{
NautilusWindow *window;
char *location;
window = NAUTILUS_WINDOW (callback_data);
location = window->details->location_to_change_to_at_idle;
window->details->location_to_change_to_at_idle = NULL;
window->details->location_change_at_idle_id = 0;
nautilus_window_go_to (window, location);
g_free (location);
return FALSE;
}
/* handle bonobo events from the throbber -- since they can come in at
any time right in the middle of things, defer until idle */
static void
throbber_callback (BonoboListener *listener,
const char *event_name,
const CORBA_any *arg,
CORBA_Environment *ev,
gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
g_free (window->details->location_to_change_to_at_idle);
window->details->location_to_change_to_at_idle = g_strdup (
BONOBO_ARG_GET_STRING (arg));
if (window->details->location_change_at_idle_id == 0) {
window->details->location_change_at_idle_id =
gtk_idle_add (location_change_at_idle_callback, window);
}
}
static void
throbber_created_callback (Bonobo_Unknown throbber,
CORBA_Environment *ev,
gpointer user_data)
{
char *exception_as_text;
NautilusWindow *window;
if (BONOBO_EX (ev)) {
exception_as_text = bonobo_exception_get_text (ev);
g_warning ("Throbber activation exception '%s'", exception_as_text);
g_free (exception_as_text);
return;
}
g_return_if_fail (NAUTILUS_IS_WINDOW (user_data));
window = NAUTILUS_WINDOW (user_data);
bonobo_ui_component_object_set (window->details->shell_ui,
"/Toolbar/ThrobberWrapper",
throbber, ev);
CORBA_exception_free (ev);
window->details->throbber_property_bag =
Bonobo_Control_getProperties (throbber, ev);
if (BONOBO_EX (ev)) {
window->details->throbber_property_bag = CORBA_OBJECT_NIL;
CORBA_exception_free (ev);
} else {
bonobo_pbclient_set_boolean (window->details->throbber_property_bag,
"throbbing",
window->details->throbber_active,
ev);
}
window->details->throbber_listener =
bonobo_event_source_client_add_listener_full
(window->details->throbber_property_bag,
g_cclosure_new (G_CALLBACK (throbber_callback), window, NULL),
"Bonobo/Property:change:location", ev);
bonobo_object_release_unref (throbber, ev);
g_object_unref (window);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
CORBA_Environment ev;
if (( window->details->throbber_active && allow) ||
(!window->details->throbber_active && !allow)) {
return;
}
if (allow)
access ("nautilus-throbber: start", 0);
else
access ("nautilus-throbber: stop", 0);
window->details->throbber_active = allow;
nautilus_window_ui_freeze (window);
nautilus_bonobo_set_sensitive (window->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
bonobo_pbclient_set_boolean (window->details->throbber_property_bag,
"throbbing", allow, &ev);
CORBA_exception_free (&ev);
}
nautilus_window_ui_thaw (window);
}
void
nautilus_window_initialize_toolbars (NautilusWindow *window)
{
@ -415,25 +539,20 @@ nautilus_window_initialize_toolbars (NautilusWindow *window)
* We should use inheritance instead of these special cases
* for the desktop window.
*/
/* It's important not to create a throbber that will never get
* an X window, because the code to make the throbber go away
* when Nautilus crashes or is killed relies on the X
* window. One way to do this would be to create the throbber
* at realize time, but another way is to special-case the
* desktop window.
*/
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
CORBA_exception_init (&ev);
window->details->throbber = bonobo_get_object ("OAFIID:nautilus_throbber", "IDL:Bonobo/Control:1.0", &ev);
g_object_ref (window);
bonobo_get_object_async ("OAFIID:nautilus_throbber",
"IDL:Bonobo/Control:1.0",
&ev,
throbber_created_callback,
window);
if (BONOBO_EX (&ev)) {
exception_as_text = bonobo_exception_get_text (&ev);
g_warning ("Throbber activation exception '%s'", exception_as_text);
g_free (exception_as_text);
window->details->throbber = CORBA_OBJECT_NIL;
} else if (window->details->throbber != CORBA_OBJECT_NIL) {
bonobo_ui_component_object_set (window->details->shell_ui, "/Toolbar/ThrobberWrapper",
window->details->throbber, NULL);
}
CORBA_exception_free (&ev);
}

View file

@ -40,7 +40,6 @@
#include "nautilus-zoom-control.h"
#include <X11/Xatom.h>
#include <bonobo/bonobo-exception.h>
#include <bonobo/bonobo-property-bag-client.h>
#include <bonobo/bonobo-ui-util.h>
#include <eel/eel-debug.h>
#include <eel/eel-gdk-extensions.h>
@ -81,7 +80,6 @@
#include <libnautilus/nautilus-undo.h>
#include <math.h>
#include <sys/time.h>
#include <unistd.h>
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
@ -519,47 +517,6 @@ set_initial_window_geometry (NautilusWindow *window)
max_height_for_screen));
}
static gboolean
location_change_at_idle_callback (gpointer callback_data)
{
NautilusWindow *window;
char *location;
window = NAUTILUS_WINDOW (callback_data);
location = window->details->location_to_change_to_at_idle;
window->details->location_to_change_to_at_idle = NULL;
window->details->location_change_at_idle_id = 0;
nautilus_window_go_to (window, location);
g_free (location);
return FALSE;
}
/* handle bonobo events from the throbber -- since they can come in at
any time right in the middle of things, defer until idle */
static void
throbber_callback (BonoboListener *listener,
const char *event_name,
const CORBA_any *arg,
CORBA_Environment *ev,
gpointer callback_data)
{
NautilusWindow *window;
window = NAUTILUS_WINDOW (callback_data);
g_free (window->details->location_to_change_to_at_idle);
window->details->location_to_change_to_at_idle = g_strdup (BONOBO_ARG_GET_STRING (arg));
if (window->details->location_change_at_idle_id == 0) {
window->details->location_change_at_idle_id =
gtk_idle_add (location_change_at_idle_callback, window);
}
}
/* Add a dummy menu with a "View as ..." item when we first create the
* view_as_option_menu -- without this the menu draws empty and shrunk,
* once we populate it it grows and forces the toolbar and all the other
@ -585,10 +542,7 @@ nautilus_window_constructed (NautilusWindow *window)
{
GtkWidget *location_bar_box;
GtkWidget *view_as_menu_vbox;
int sidebar_width;
BonoboControl *location_bar_wrapper;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
/* CORBA and Bonobo setup, which must be done before the location bar setup */
window->details->ui_container = bonobo_ui_container_new ();
@ -668,29 +622,21 @@ nautilus_window_constructed (NautilusWindow *window)
set_initial_window_geometry (window);
window->content_hbox = nautilus_horizontal_splitter_new ();
/* FIXME bugzilla.gnome.org 41245: Saved in pixels instead of in %? */
/* FIXME bugzilla.gnome.org 41245: No reality check on the value? */
sidebar_width = eel_preferences_get_integer (NAUTILUS_PREFERENCES_SIDEBAR_WIDTH);
gtk_paned_set_position (GTK_PANED (window->content_hbox), sidebar_width);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
/* FIXME bugzilla.gnome.org 41243:
* We should use inheritance instead of these special cases
* for the desktop window.
*/
if (!NAUTILUS_IS_DESKTOP_WINDOW (window)) {
/* set up the sidebar */
window->sidebar = nautilus_sidebar_new ();
gtk_widget_show (GTK_WIDGET (window->sidebar));
g_signal_connect (window->sidebar, "location_changed",
G_CALLBACK (go_to_callback), window);
G_CALLBACK (go_to_callback), window);
gtk_paned_pack1 (GTK_PANED (window->content_hbox),
GTK_WIDGET (window->sidebar),
FALSE, TRUE);
nautilus_sidebar_setup_width (window->sidebar);
}
gtk_widget_show (window->content_hbox);
bonobo_window_set_contents (BONOBO_WINDOW (window), window->content_hbox);
bonobo_ui_component_freeze (window->details->shell_ui, NULL);
@ -724,21 +670,6 @@ nautilus_window_constructed (NautilusWindow *window)
/* We'll do the second part later (bookmarks and go menus) */
window->details->ui_pending_initialize_menus_part_2 = TRUE;
/* watch for throbber location changes, too */
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
window->details->throbber_listener =
bonobo_event_source_client_add_listener_full
(property_bag,
g_cclosure_new (G_CALLBACK (throbber_callback), window, NULL),
"Bonobo/Property:change:location", NULL);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
/* Set initial sensitivity of some buttons & menu items
* now that they're all created.
@ -826,33 +757,17 @@ static void
nautilus_window_unrealize (GtkWidget *widget)
{
NautilusWindow *window;
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
window = NAUTILUS_WINDOW (widget);
/* Get rid of the throbber explicitly before it self-destructs
* (which it will do when the control frame goes away.
*/
if (window->details->throbber != CORBA_OBJECT_NIL) {
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
if (window->details->throbber_property_bag != CORBA_OBJECT_NIL) {
bonobo_object_release_unref (window->details->throbber_property_bag, NULL);
window->details->throbber_property_bag = CORBA_OBJECT_NIL;
}
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_event_source_client_remove_listener
(property_bag, window->details->throbber_listener, &ev);
bonobo_object_release_unref (property_bag, &ev);
}
CORBA_Object_release (window->details->throbber_listener, &ev);
window->details->throbber_listener = CORBA_OBJECT_NIL;
CORBA_exception_free (&ev);
}
bonobo_object_release_unref (window->details->throbber, NULL);
window->details->throbber = CORBA_OBJECT_NIL;
if (window->details->throbber_listener != CORBA_OBJECT_NIL) {
CORBA_Object_release (window->details->throbber_listener, NULL);
window->details->throbber_listener = CORBA_OBJECT_NIL;
}
GTK_WIDGET_CLASS (parent_class)->unrealize (widget);
@ -1678,35 +1593,6 @@ nautilus_window_allow_reload (NautilusWindow *window, gboolean allow)
nautilus_window_ui_thaw (window);
}
void
nautilus_window_allow_stop (NautilusWindow *window, gboolean allow)
{
CORBA_Environment ev;
Bonobo_PropertyBag property_bag;
nautilus_window_ui_freeze (window);
if (allow)
access ("nautilus-throbber: start", 0);
else
access ("nautilus-throbber: stop", 0);
nautilus_bonobo_set_sensitive (window->details->shell_ui,
NAUTILUS_COMMAND_STOP, allow);
if (window->details->throbber != CORBA_OBJECT_NIL) {
CORBA_exception_init (&ev);
property_bag = Bonobo_Control_getProperties (window->details->throbber, &ev);
if (!BONOBO_EX (&ev) && property_bag != CORBA_OBJECT_NIL) {
bonobo_pbclient_set_boolean (property_bag, "throbbing", allow, &ev);
bonobo_object_release_unref (property_bag, NULL);
}
CORBA_exception_free (&ev);
}
nautilus_window_ui_thaw (window);
}
void
nautilus_send_history_list_changed (void)
{
@ -1916,9 +1802,9 @@ nautilus_window_set_content_view_widget (NautilusWindow *window,
gtk_container_add (GTK_CONTAINER (window->content_hbox),
GTK_WIDGET (new_view));
} else {
gtk_paned_pack2 (GTK_PANED (window->content_hbox),
GTK_WIDGET (new_view),
TRUE, TRUE);
nautilus_horizontal_splitter_pack2 (
NAUTILUS_HORIZONTAL_SPLITTER (window->content_hbox),
GTK_WIDGET (new_view));
}
}