Commit 6b579803 authored by Michael Meeks's avatar Michael Meeks Committed by Michael Meeks
Browse files

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.
parent 933e8880
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
......
......@@ -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 =
......
......@@ -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 *
......
......@@ -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,
......
......@@ -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
......
......@@ -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
......
......@@ -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);
}
......@@ -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)
......
......@@ -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 */
......
......@@ -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;
}
......@@ -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 */
......@@ -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);
}
}
......@@ -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
......
......@@ -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
......
......@@ -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));
}
......@@ -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
......
......@@ -60,6 +60,7 @@
#include <libnautilus-private/nautilus-icon-factory.h>