diff options
author | Alexander Larsson <alexl@redhat.com> | 2004-11-22 15:24:38 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2004-11-22 15:24:38 +0000 |
commit | 67e2a42fea65f2685580b119b98a058c8e81ac4e (patch) | |
tree | 19bc7c578c9f1a47f299d012ac4775010e06661e /components | |
parent | 8dc115c33951754d75b57c67e4d918900a795468 (diff) | |
download | nautilus-67e2a42fea65f2685580b119b98a058c8e81ac4e.tar.gz |
Merge bonobo-slay-branch
2004-11-22 Alexander Larsson <alexl@redhat.com>
* Merge bonobo-slay-branch
Diffstat (limited to 'components')
82 files changed, 0 insertions, 11868 deletions
diff --git a/components/Makefile.am b/components/Makefile.am deleted file mode 100644 index 01670366f..000000000 --- a/components/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -NULL= - -SUBDIRS = \ - adapter \ - history \ - notes \ - text \ - throbber \ - emblem \ - image_properties \ - $(NULL) - -# loser \ -# sample \ -# These should only be built by people that know what they do - -# news \ -# Disable the news-sidebar for now, It has lots of bugs and doesn't -# really fit into a file manager. diff --git a/components/adapter/Makefile.am b/components/adapter/Makefile.am deleted file mode 100644 index 45dc52cd0..000000000 --- a/components/adapter/Makefile.am +++ /dev/null @@ -1,53 +0,0 @@ -NULL = - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Adapter\" \ - -DICON_DIR=\"$(datadir)/pixmaps/nautilus\" \ - -I$(top_srcdir) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -serverdir = $(libdir)/bonobo/servers -server_in_files = Nautilus_ComponentAdapterFactory_std.server.in -server_DATA = $(server_in_files:.server.in=.server) - -$(server_in_files): $(server_in_files).in - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ - -@INTLTOOL_SERVER_RULE@ - -libexec_PROGRAMS=nautilus-adapter - -nautilus_adapter_SOURCES = \ - main.c \ - nautilus-adapter-control-embed-strategy.c \ - nautilus-adapter-control-embed-strategy.h \ - nautilus-adapter-embed-strategy-private.h \ - nautilus-adapter-embed-strategy.c \ - nautilus-adapter-embed-strategy.h \ - nautilus-adapter-control-factory-embed-strategy.c \ - nautilus-adapter-control-factory-embed-strategy.h \ - nautilus-adapter-factory-server.c \ - nautilus-adapter-factory-server.h \ - nautilus-adapter-file-load-strategy.c \ - nautilus-adapter-file-load-strategy.h \ - nautilus-adapter-load-strategy.c \ - nautilus-adapter-load-strategy.h \ - nautilus-adapter-load-strategy.h \ - nautilus-adapter-stream-load-strategy.c \ - nautilus-adapter-stream-load-strategy.h \ - nautilus-zoomable-proxy.c \ - nautilus-zoomable-proxy.h \ - nautilus-adapter.c \ - nautilus-adapter.h \ - $(NULL) - -nautilus_adapter_LDADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-adapter/libnautilus-adapter.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -EXTRA_DIST = $(server_in_files).in -CLEANFILES = $(server_in_files) $(server_DATA) diff --git a/components/adapter/Nautilus_ComponentAdapterFactory_std.server.in.in b/components/adapter/Nautilus_ComponentAdapterFactory_std.server.in.in deleted file mode 100644 index db5151fd8..000000000 --- a/components/adapter/Nautilus_ComponentAdapterFactory_std.server.in.in +++ /dev/null @@ -1,22 +0,0 @@ -<oaf_info> - - -<oaf_server iid="OAFIID:Nautilus_Adapter_Factory_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-adapter"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Factory for Nautilus component adapter factories"/> - <oaf_attribute name="description" type="string" _value="Factory for Nautilus component adapter factories "/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Adapter_Factory" type="factory" location="OAFIID:Nautilus_Adapter_Factory_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Nautilus/ComponentAdapterFactory:1.0"/> - <item value="IDL:Bonobo/Unknown:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus component adapter factory"/> - <oaf_attribute name="description" type="string" _value="Factory for objects that wrap ordinary Bonobo Controls or Embeddables to look like Nautilus Views"/> -</oaf_server> - -</oaf_info> diff --git a/components/adapter/main.c b/components/adapter/main.c deleted file mode 100644 index a496c2d31..000000000 --- a/components/adapter/main.c +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* main.c - Main function and object activation function for component adapter - */ - -#include <config.h> - -#include "nautilus-adapter-factory-server.h" -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo/bonobo-generic-factory.h> -#include <bonobo/bonobo-main.h> -#include <bonobo/bonobo-ui-main.h> -#include <eel/eel-debug.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-init.h> -#include <libgnomeui/gnome-authentication-manager.h> -#include <libgnomeui/gnome-client.h> -#include <libgnomevfs/gnome-vfs-init.h> -#include <eel/eel-gnome-extensions.h> -#include <stdlib.h> -#include <string.h> - -#define META_FACTORY_IID "OAFIID:Nautilus_Adapter_Factory_Factory" -#define FACTORY_OBJECT_IID "OAFIID:Nautilus_Adapter_Factory" - -static int object_count = 0; - -static void -adapter_factory_object_weak_notify (gpointer data, GObject *object) -{ - object_count--; - if (object_count <= 0) { - bonobo_main_quit (); - } -} - -static BonoboObject * -adapter_factory_make_object (BonoboGenericFactory *factory, - const char *iid, - gpointer callback_data) -{ - NautilusAdapterFactoryServer *adapter; - - g_assert (BONOBO_IS_GENERIC_FACTORY (factory)); - g_assert (iid != NULL); - g_assert (callback_data == NULL); - - /* Check that this is the one type of object we know how to - * create. - */ - if (strcmp (iid, FACTORY_OBJECT_IID) != 0) { - return NULL; - } - - adapter = NAUTILUS_ADAPTER_FACTORY_SERVER (g_object_new (NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER, NULL)); - - /* Connect a handler that will get us out of the main loop - * when there are no more objects outstanding. - */ - object_count++; - g_object_weak_ref (G_OBJECT (adapter), - adapter_factory_object_weak_notify, - NULL); - - return BONOBO_OBJECT (adapter); -} - -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 (); - } - - if (!bonobo_ui_init ("nautilus-adapter", VERSION, &argc, argv)) { - g_error (_("bonobo_ui_init() failed.")); - } - - /* Disable session manager connection */ - g_object_set (G_OBJECT (gnome_program_get()), - GNOME_CLIENT_PARAM_SM_CONNECT, FALSE, NULL); - - /* Create the factory. */ - - registration_id = eel_bonobo_make_registration_id (META_FACTORY_IID); - - factory = bonobo_generic_factory_new (registration_id, adapter_factory_make_object, NULL); - - g_free (registration_id); - - gnome_authentication_manager_init (); - - /* Loop until we have no more objects. */ - do { - bonobo_main (); - } while (object_count > 0); - - /* Let the factory go. */ - bonobo_object_unref (factory); - - gnome_vfs_shutdown (); - - return EXIT_SUCCESS; -} diff --git a/components/adapter/nautilus-adapter-control-embed-strategy.c b/components/adapter/nautilus-adapter-control-embed-strategy.c deleted file mode 100644 index 11dfeec72..000000000 --- a/components/adapter/nautilus-adapter-control-embed-strategy.c +++ /dev/null @@ -1,206 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-control-embed-strategy.c - - */ - - -#include <config.h> - -#include "nautilus-adapter-control-embed-strategy.h" -#include "nautilus-adapter-embed-strategy-private.h" -#include "nautilus-zoomable-proxy.h" - -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include <eel/eel-gtk-macros.h> -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-control-frame.h> - - -struct NautilusAdapterControlEmbedStrategyDetails { - BonoboControlFrame *control_frame; - BonoboObject *zoomable; - GtkWidget *widget; -}; - - -static void nautilus_adapter_control_embed_strategy_class_init (NautilusAdapterControlEmbedStrategyClass *klass); -static void nautilus_adapter_control_embed_strategy_init (NautilusAdapterControlEmbedStrategy *strategy); -static void nautilus_adapter_control_embed_strategy_activate (NautilusAdapterEmbedStrategy *object, - gpointer ui_container); -static void nautilus_adapter_control_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object); -static void nautilus_adapter_control_embed_strategy_destroy (GtkObject *object); - -static GtkWidget *nautilus_adapter_control_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy); -static BonoboObject *nautilus_adapter_control_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *strategy); - - -EEL_CLASS_BOILERPLATE (NautilusAdapterControlEmbedStrategy, nautilus_adapter_control_embed_strategy, NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY) - - -static void -nautilus_adapter_control_embed_strategy_class_init (NautilusAdapterControlEmbedStrategyClass *klass) -{ - GtkObjectClass *object_class; - NautilusAdapterEmbedStrategyClass *adapter_embed_strategy_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_adapter_control_embed_strategy_destroy; - - adapter_embed_strategy_class = NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS (klass); - - adapter_embed_strategy_class->get_widget = nautilus_adapter_control_embed_strategy_get_widget; - adapter_embed_strategy_class->get_zoomable = nautilus_adapter_control_embed_strategy_get_zoomable; - adapter_embed_strategy_class->activate = nautilus_adapter_control_embed_strategy_activate; - adapter_embed_strategy_class->deactivate = nautilus_adapter_control_embed_strategy_deactivate; -} - -static void -nautilus_adapter_control_embed_strategy_init (NautilusAdapterControlEmbedStrategy *strategy) -{ - strategy->details = g_new0 (NautilusAdapterControlEmbedStrategyDetails, 1); -} - -static void -nautilus_adapter_control_embed_strategy_destroy (GtkObject *object) -{ - NautilusAdapterControlEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object); - - bonobo_object_unref (strategy->details->control_frame); - g_free (strategy->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -static void -nautilus_adapter_control_embed_strategy_activate (NautilusAdapterEmbedStrategy *object, - gpointer ui_container) -{ - NautilusAdapterControlEmbedStrategy *strategy; - Bonobo_UIContainer corba_container = ui_container; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY (object)); - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object); - - bonobo_control_frame_set_ui_container (strategy->details->control_frame, - corba_container, NULL); - - bonobo_control_frame_control_activate (strategy->details->control_frame); -} - -static void -nautilus_adapter_control_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object) -{ - NautilusAdapterControlEmbedStrategy *strategy; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY (object)); - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (object); - - /* This is not strictly necessary, but it makes sure that the component's menus - * and toolbars are really unmerged even if our component is badly behaving or - * leaking a reference somewhere. */ - bonobo_control_frame_control_deactivate (strategy->details->control_frame); -} - -static void -activate_uri_callback (BonoboControlFrame *frame, - const char *uri, - gboolean relative, - NautilusAdapterControlEmbedStrategy *strategy) -{ - /* FIXME bugzilla.gnome.org 44404: ignoring `relative' parameter as - * the concept is kind of broken. - */ - nautilus_adapter_embed_strategy_emit_open_location (NAUTILUS_ADAPTER_EMBED_STRATEGY (strategy), - uri); -} - -NautilusAdapterEmbedStrategy * -nautilus_adapter_control_embed_strategy_new (Bonobo_Control control, - Bonobo_UIContainer ui_container) -{ - NautilusAdapterControlEmbedStrategy *strategy; - Bonobo_Zoomable corba_zoomable; - CORBA_Environment ev; - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (g_object_new (NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY, NULL)); - g_object_ref (strategy); - gtk_object_sink (GTK_OBJECT (strategy)); - - strategy->details->control_frame = bonobo_control_frame_new (ui_container); - - bonobo_control_frame_bind_to_control (strategy->details->control_frame, control, NULL); - - strategy->details->widget = bonobo_control_frame_get_widget (strategy->details->control_frame); - - g_signal_connect_object (strategy->details->control_frame, "activate_uri", - G_CALLBACK (activate_uri_callback), strategy, 0); - - CORBA_exception_init (&ev); - corba_zoomable = Bonobo_Unknown_queryInterface (control, - "IDL:Bonobo/Zoomable:1.0", - &ev); - if ((ev._major == CORBA_NO_EXCEPTION) && - !CORBA_Object_is_nil (corba_zoomable, &ev)) { - strategy->details->zoomable = nautilus_zoomable_proxy_get - (corba_zoomable); - bonobo_object_release_unref (corba_zoomable, &ev); - } - - CORBA_exception_free (&ev); - - return NAUTILUS_ADAPTER_EMBED_STRATEGY (strategy); -} - -static GtkWidget * -nautilus_adapter_control_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *abstract_strategy) -{ - NautilusAdapterControlEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (abstract_strategy); - - return strategy->details->widget; -} - -static BonoboObject * -nautilus_adapter_control_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *abstract_strategy) -{ - NautilusAdapterControlEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY (abstract_strategy); - - return strategy->details->zoomable; -} - - diff --git a/components/adapter/nautilus-adapter-control-embed-strategy.h b/components/adapter/nautilus-adapter-control-embed-strategy.h deleted file mode 100644 index c0c8de3d1..000000000 --- a/components/adapter/nautilus-adapter-control-embed-strategy.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-control-embed-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY_H -#define NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY_H - -#include "nautilus-adapter-embed-strategy.h" - -#define NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY (nautilus_adapter_control_embed_strategy_get_type ()) -#define NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY, NautilusAdapterControlEmbedStrategy)) -#define NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY, NautilusAdapterControlEmbedStrategyClass)) -#define NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_CONTROL_EMBED_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_CONTROL_EMBED_STRATEGY)) - -typedef struct NautilusAdapterControlEmbedStrategyDetails NautilusAdapterControlEmbedStrategyDetails; - -typedef struct { - NautilusAdapterEmbedStrategy parent; - NautilusAdapterControlEmbedStrategyDetails *details; -} NautilusAdapterControlEmbedStrategy; - -typedef struct { - NautilusAdapterEmbedStrategyClass parent; -} NautilusAdapterControlEmbedStrategyClass; - -/* GObject support */ -GType nautilus_adapter_control_embed_strategy_get_type (void); - -NautilusAdapterEmbedStrategy *nautilus_adapter_control_embed_strategy_new (Bonobo_Control control, - Bonobo_UIContainer ui_container); - - -#endif /* NAUTILUS_ADAPTER_CONTROL_EMBED_STRATEGY_H */ - - - diff --git a/components/adapter/nautilus-adapter-control-factory-embed-strategy.c b/components/adapter/nautilus-adapter-control-factory-embed-strategy.c deleted file mode 100644 index 15c2e59f3..000000000 --- a/components/adapter/nautilus-adapter-control-factory-embed-strategy.c +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-control_factory-embed-strategy.c - - */ - -#include <config.h> -#include "nautilus-adapter-control-factory-embed-strategy.h" - -#include "nautilus-adapter-embed-strategy-private.h" -#include "nautilus-zoomable-proxy.h" - -#include <bonobo/bonobo-control-frame.h> -#include <eel/eel-gtk-macros.h> -#include <libnautilus/nautilus-view.h> - -struct NautilusAdapterControlFactoryEmbedStrategyDetails { - Bonobo_ControlFactory control_factory; - BonoboControlFrame *control_frame; - GtkWidget *client_widget; - BonoboObject *zoomable; -}; - -static void nautilus_adapter_control_factory_embed_strategy_class_init (NautilusAdapterControlFactoryEmbedStrategyClass *klass); -static void nautilus_adapter_control_factory_embed_strategy_init (NautilusAdapterControlFactoryEmbedStrategy *strategy); -static void nautilus_adapter_control_factory_embed_strategy_destroy (GtkObject *object); -static void nautilus_adapter_control_factory_embed_strategy_activate (NautilusAdapterEmbedStrategy *object, - gpointer ui_container); -static void nautilus_adapter_control_factory_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object); - - -static GtkWidget *nautilus_adapter_control_factory_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy); -static BonoboObject *nautilus_adapter_control_factory_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *strategy); - - -EEL_CLASS_BOILERPLATE (NautilusAdapterControlFactoryEmbedStrategy, nautilus_adapter_control_factory_embed_strategy, NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY) - - -static void -nautilus_adapter_control_factory_embed_strategy_class_init (NautilusAdapterControlFactoryEmbedStrategyClass *klass) -{ - GtkObjectClass *object_class; - NautilusAdapterEmbedStrategyClass *adapter_embed_strategy_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_adapter_control_factory_embed_strategy_destroy; - - adapter_embed_strategy_class = NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS (klass); - - adapter_embed_strategy_class->get_widget = nautilus_adapter_control_factory_embed_strategy_get_widget; - adapter_embed_strategy_class->get_zoomable = nautilus_adapter_control_factory_embed_strategy_get_zoomable; - adapter_embed_strategy_class->activate = nautilus_adapter_control_factory_embed_strategy_activate; - adapter_embed_strategy_class->deactivate = nautilus_adapter_control_factory_embed_strategy_deactivate; -} - -static void -nautilus_adapter_control_factory_embed_strategy_init (NautilusAdapterControlFactoryEmbedStrategy *strategy) -{ - strategy->details = g_new0 (NautilusAdapterControlFactoryEmbedStrategyDetails, 1); -} - - -static void -nautilus_adapter_control_factory_embed_strategy_destroy (GtkObject *object) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (object); - - bonobo_object_unref (strategy->details->control_frame); - g_free (strategy->details); - strategy->details = NULL; - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - - -static void -nautilus_adapter_control_factory_embed_strategy_activate (NautilusAdapterEmbedStrategy *object, - gpointer ui_container) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - Bonobo_UIContainer corba_container = ui_container; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (object)); - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (object); - - bonobo_control_frame_set_ui_container (BONOBO_CONTROL_FRAME (strategy->details->control_frame), - corba_container, NULL); - - bonobo_control_frame_control_activate (BONOBO_CONTROL_FRAME (strategy->details->control_frame)); -} - -static void -nautilus_adapter_control_factory_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *object) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (object)); - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (object); - - /* This is not strictly necessary, but it makes sure that the component's menus - * and toolbars are really unmerged even if our component is badly behaving or - * leaking a reference somewhere. */ - bonobo_control_frame_control_deactivate (BONOBO_CONTROL_FRAME (strategy->details->control_frame)); -} - -static void -activate_uri_callback (BonoboControlFrame *frame, - const char *uri, - gboolean relative, - NautilusAdapterControlFactoryEmbedStrategy *strategy) -{ - /* FIXME: ignoring `relative' parameter as the concept is kind - of broken. */ - - nautilus_adapter_embed_strategy_emit_open_location (NAUTILUS_ADAPTER_EMBED_STRATEGY (strategy), - uri); -} - -NautilusAdapterEmbedStrategy * -nautilus_adapter_control_factory_embed_strategy_new (Bonobo_ControlFactory control_factory, - Bonobo_UIContainer ui_container) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - Bonobo_Control control; - CORBA_Environment ev; - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (g_object_new (NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY, NULL)); - g_object_ref (strategy); - gtk_object_sink (GTK_OBJECT (strategy)); - - CORBA_exception_init (&ev); - - strategy->details->control_frame = bonobo_control_frame_new (ui_container); - control = Bonobo_ControlFactory_createControl (control_factory, - BONOBO_OBJREF (strategy->details->control_frame), - ui_container, &ev); - - if ((ev._major == CORBA_NO_EXCEPTION) && - !CORBA_Object_is_nil (control, &ev)) { - Bonobo_Zoomable corba_zoomable; - strategy->details->client_widget = bonobo_control_frame_get_widget - (strategy->details->control_frame); - g_signal_connect_object (strategy->details->control_frame, "activate_uri", - G_CALLBACK (activate_uri_callback), strategy, 0); - - gtk_widget_show (strategy->details->client_widget); - - corba_zoomable = Bonobo_Unknown_queryInterface (control, - "IDL:Bonobo/Zoomable:1.0", - &ev); - - if ((ev._major == CORBA_NO_EXCEPTION) && - !CORBA_Object_is_nil (corba_zoomable, &ev)) { - strategy->details->zoomable = nautilus_zoomable_proxy_get - (corba_zoomable); - } - } else - strategy->details->client_widget = NULL; - - CORBA_exception_free (&ev); - - return NAUTILUS_ADAPTER_EMBED_STRATEGY (strategy); -} - -static GtkWidget * -nautilus_adapter_control_factory_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *abstract_strategy) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (abstract_strategy); - return strategy->details->client_widget; -} - -static BonoboObject * -nautilus_adapter_control_factory_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *abstract_strategy) -{ - NautilusAdapterControlFactoryEmbedStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY (abstract_strategy); - - return strategy->details->zoomable; -} diff --git a/components/adapter/nautilus-adapter-control-factory-embed-strategy.h b/components/adapter/nautilus-adapter-control-factory-embed-strategy.h deleted file mode 100644 index 2ebb05949..000000000 --- a/components/adapter/nautilus-adapter-control-factory-embed-strategy.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-control_factory-embed-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY_H -#define NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY_H - -#include "nautilus-adapter-embed-strategy.h" - -#define NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY \ - (nautilus_adapter_control_factory_embed_strategy_get_type ()) -#define NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY, NautilusAdapterControlFactoryEmbedStrategy)) -#define NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY, NautilusAdapterControlFactoryEmbedStrategyClass)) -#define NAUTILUS_IS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY)) - -typedef struct NautilusAdapterControlFactoryEmbedStrategyDetails NautilusAdapterControlFactoryEmbedStrategyDetails; - -typedef struct { - NautilusAdapterEmbedStrategy parent; - NautilusAdapterControlFactoryEmbedStrategyDetails *details; -} NautilusAdapterControlFactoryEmbedStrategy; - -typedef struct { - NautilusAdapterEmbedStrategyClass parent; -} NautilusAdapterControlFactoryEmbedStrategyClass; - -/* GObject support */ -GType nautilus_adapter_control_factory_embed_strategy_get_type (void); - -NautilusAdapterEmbedStrategy *nautilus_adapter_control_factory_embed_strategy_new (Bonobo_ControlFactory control_factory, - Bonobo_UIContainer ui_container); - -#endif /* NAUTILUS_ADAPTER_CONTROL_FACTORY_EMBED_STRATEGY_H */ diff --git a/components/adapter/nautilus-adapter-embed-strategy-private.h b/components/adapter/nautilus-adapter-embed-strategy-private.h deleted file mode 100644 index 306582803..000000000 --- a/components/adapter/nautilus-adapter-embed-strategy-private.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-embed-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_EMBED_STRATEGY_PRIVATE_H -#define NAUTILUS_ADAPTER_EMBED_STRATEGY_PRIVATE_H - -#include "nautilus-adapter-embed-strategy.h" - -void nautilus_adapter_embed_strategy_emit_open_location (NautilusAdapterEmbedStrategy *strategy, - const char *uri); - - -#endif /* NAUTILUS_ADAPTER_EMBED_STRATEGY_PRIVATE_H */ diff --git a/components/adapter/nautilus-adapter-embed-strategy.c b/components/adapter/nautilus-adapter-embed-strategy.c deleted file mode 100644 index f52b11dcd..000000000 --- a/components/adapter/nautilus-adapter-embed-strategy.c +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-embed-strategy.h - */ - - -#include <config.h> -#include "nautilus-adapter-embed-strategy.h" - -#include "nautilus-adapter-control-embed-strategy.h" -#include "nautilus-adapter-embed-strategy-private.h" -#include "nautilus-adapter-control-factory-embed-strategy.h" - -#include <gtk/gtkobject.h> -#include <gtk/gtksignal.h> -#include <eel/eel-gtk-macros.h> -#include <stdio.h> - -enum { - ACTIVATE, - DEACTIVATE, - OPEN_LOCATION, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - -static void nautilus_adapter_embed_strategy_class_init (NautilusAdapterEmbedStrategyClass *klass); -static void nautilus_adapter_embed_strategy_init (NautilusAdapterEmbedStrategy *strategy); - -EEL_CLASS_BOILERPLATE (NautilusAdapterEmbedStrategy, - nautilus_adapter_embed_strategy, - GTK_TYPE_OBJECT) - -EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_widget) -EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_embed_strategy, get_zoomable) - -static void -nautilus_adapter_embed_strategy_class_init (NautilusAdapterEmbedStrategyClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - signals[ACTIVATE] = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterEmbedStrategyClass, activate), - NULL, NULL, - g_cclosure_marshal_VOID__POINTER, - G_TYPE_NONE, 1, G_TYPE_POINTER); - signals[DEACTIVATE] = - g_signal_new ("deactivate", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterEmbedStrategyClass, deactivate), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[OPEN_LOCATION] = - g_signal_new ("open_location", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterEmbedStrategyClass, open_location), - NULL, NULL, - g_cclosure_marshal_VOID__STRING, - G_TYPE_NONE, 1, G_TYPE_STRING); - - EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_embed_strategy, get_widget); - EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_embed_strategy, get_zoomable); -} - -static void -nautilus_adapter_embed_strategy_init (NautilusAdapterEmbedStrategy *strategy) -{ -} - -NautilusAdapterEmbedStrategy * -nautilus_adapter_embed_strategy_get (Bonobo_Unknown component) -{ - NautilusAdapterEmbedStrategy *strategy; - Bonobo_ControlFactory control_factory; - Bonobo_Control control; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - strategy = NULL; - - control = Bonobo_Unknown_queryInterface - (component, "IDL:Bonobo/Control:1.0", &ev); - if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (control, &ev)) { - strategy = nautilus_adapter_control_embed_strategy_new - (control, CORBA_OBJECT_NIL); - bonobo_object_release_unref (control, NULL); - } - - if (strategy != NULL) { - control_factory = Bonobo_Unknown_queryInterface - (component, "IDL:Bonobo/ControlFactory:1.0", &ev); - if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (control_factory, &ev)) { - strategy = nautilus_adapter_control_factory_embed_strategy_new - (control_factory, CORBA_OBJECT_NIL); - bonobo_object_release_unref (control_factory, NULL); - } - } - - CORBA_exception_free (&ev); - - return strategy; -} - -GtkWidget * -nautilus_adapter_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy) -{ - return EEL_CALL_METHOD_WITH_RETURN_VALUE - (NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS, strategy, - get_widget, (strategy)); -} - -BonoboObject * -nautilus_adapter_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *strategy) -{ - return EEL_CALL_METHOD_WITH_RETURN_VALUE - (NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS, strategy, - get_zoomable, (strategy)); -} - - -void -nautilus_adapter_embed_strategy_activate (NautilusAdapterEmbedStrategy *strategy, - Bonobo_UIContainer ui_container) -{ - g_signal_emit (strategy, - signals[ACTIVATE], 0, - ui_container); -} - -void -nautilus_adapter_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *strategy) -{ - g_signal_emit (strategy, - signals[DEACTIVATE], 0); -} - -void -nautilus_adapter_embed_strategy_emit_open_location (NautilusAdapterEmbedStrategy *strategy, - const char *uri) -{ - g_signal_emit (strategy, - signals[OPEN_LOCATION], 0, - uri); -} diff --git a/components/adapter/nautilus-adapter-embed-strategy.h b/components/adapter/nautilus-adapter-embed-strategy.h deleted file mode 100644 index af97bf37b..000000000 --- a/components/adapter/nautilus-adapter-embed-strategy.h +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-embed-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_EMBED_STRATEGY_H -#define NAUTILUS_ADAPTER_EMBED_STRATEGY_H - -#include <gtk/gtkobject.h> -#include <bonobo/Bonobo.h> -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY (nautilus_adapter_embed_strategy_get_type ()) -#define NAUTILUS_ADAPTER_EMBED_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY, NautilusAdapterEmbedStrategy)) -#define NAUTILUS_ADAPTER_EMBED_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY, NautilusAdapterEmbedStrategyClass)) -#define NAUTILUS_IS_ADAPTER_EMBED_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_EMBED_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_EMBED_STRATEGY)) - -typedef struct NautilusAdapterEmbedStrategyDetails NautilusAdapterEmbedStrategyDetails; - -typedef struct { - GtkObject parent; -} NautilusAdapterEmbedStrategy; - -typedef struct { - GtkObjectClass parent; - - /* signals */ - void (*activate) (NautilusAdapterEmbedStrategy *strategy, - gpointer corba_container); - void (*deactivate) (NautilusAdapterEmbedStrategy *strategy); - void (*open_location) (NautilusAdapterEmbedStrategy *strategy, - const char *uri); - - /* virtual functions */ - GtkWidget *(*get_widget) (NautilusAdapterEmbedStrategy *strategy); - BonoboObject *(*get_zoomable)(NautilusAdapterEmbedStrategy *strategy); - -} NautilusAdapterEmbedStrategyClass; - -/* GObject support */ -GType nautilus_adapter_embed_strategy_get_type (void); - -/* Instantiates the proper concrete subclass */ -NautilusAdapterEmbedStrategy *nautilus_adapter_embed_strategy_get (Bonobo_Unknown component); - -void nautilus_adapter_embed_strategy_activate (NautilusAdapterEmbedStrategy *strategy, - Bonobo_UIContainer ui_container); -void nautilus_adapter_embed_strategy_deactivate (NautilusAdapterEmbedStrategy *strategy); - -GtkWidget *nautilus_adapter_embed_strategy_get_widget (NautilusAdapterEmbedStrategy *strategy); - -BonoboObject *nautilus_adapter_embed_strategy_get_zoomable (NautilusAdapterEmbedStrategy *strategy); - - -#endif /* NAUTILUS_ADAPTER_EMBED_STRATEGY_H */ - - - diff --git a/components/adapter/nautilus-adapter-factory-server.c b/components/adapter/nautilus-adapter-factory-server.c deleted file mode 100644 index 3431c3745..000000000 --- a/components/adapter/nautilus-adapter-factory-server.c +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-factory-server.c - Server object for a factory to - * create NautilusAdapter objects. - */ - -#include <config.h> -#include "nautilus-adapter-factory-server.h" - -#include "nautilus-adapter.h" -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-main.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-stock-icons.h> -#include <libnautilus-adapter/nautilus-adapter-factory.h> -#include <eel/eel-gtk-macros.h> -#include <libnautilus/nautilus-bonobo-ui.h> - -static Nautilus_View -impl_Nautilus_ComponentAdapterFactory_create_adapter (PortableServer_Servant servant, - const Bonobo_Unknown component, - CORBA_Environment *ev); - -static void nautilus_adapter_factory_server_class_init (NautilusAdapterFactoryServerClass *klass); -static void nautilus_adapter_factory_server_init (NautilusAdapterFactoryServer *server); -static void nautilus_adapter_factory_server_finalize (GObject *object); - -static BonoboObjectClass *parent_class; - - -static void -nautilus_adapter_factory_server_class_init (NautilusAdapterFactoryServerClass *klass) -{ - GObjectClass *object_class; - POA_Nautilus_ComponentAdapterFactory__epv *epv = &klass->epv; - - g_assert (NAUTILUS_IS_ADAPTER_FACTORY_SERVER_CLASS (klass)); - - parent_class = g_type_class_peek_parent (klass); - - epv->create_adapter = impl_Nautilus_ComponentAdapterFactory_create_adapter; - - object_class = G_OBJECT_CLASS (klass); - object_class->finalize = nautilus_adapter_factory_server_finalize; -} - -static void -nautilus_adapter_factory_server_init (NautilusAdapterFactoryServer *server) -{ - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - g_assert (NAUTILUS_IS_ADAPTER_FACTORY_SERVER (server)); - - CORBA_exception_free (&ev); -} - -static void -nautilus_adapter_factory_server_finalize (GObject *object) -{ - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -adapter_object_weak_notify (gpointer server, - GObject *adapter) -{ - bonobo_object_unref (server); -} - - -static Nautilus_View -impl_Nautilus_ComponentAdapterFactory_create_adapter (PortableServer_Servant servant, - const Bonobo_Unknown component, - CORBA_Environment *ev) -{ - NautilusAdapterFactoryServer *factory_servant; - NautilusAdapter *adapter; - NautilusView *adapter_view; - - factory_servant = NAUTILUS_ADAPTER_FACTORY_SERVER (bonobo_object (servant)); - adapter = nautilus_adapter_new (component); - - if (adapter == NULL) { - return CORBA_OBJECT_NIL; - } else { - bonobo_object_ref (factory_servant); - - adapter_view = nautilus_adapter_get_nautilus_view (adapter); - g_object_weak_ref (G_OBJECT (adapter_view), - adapter_object_weak_notify, - factory_servant); - - return CORBA_Object_duplicate (BONOBO_OBJREF (adapter_view), - ev); - } -} - -GType -nautilus_adapter_factory_server_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (NautilusAdapterFactoryServerClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc)nautilus_adapter_factory_server_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (NautilusAdapterFactoryServer), - 0, /* n_preallocs */ - (GInstanceInitFunc)nautilus_adapter_factory_server_init - }; - - type = bonobo_type_unique - (BONOBO_OBJECT_TYPE, - POA_Nautilus_ComponentAdapterFactory__init, NULL, - G_STRUCT_OFFSET (NautilusAdapterFactoryServerClass, - epv), - &info, "NautilusAdapterFactoryServer"); - } - - return type; -} - - diff --git a/components/adapter/nautilus-adapter-factory-server.h b/components/adapter/nautilus-adapter-factory-server.h deleted file mode 100644 index 06d8e90a6..000000000 --- a/components/adapter/nautilus-adapter-factory-server.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-factory-server.c - Server object for a factory to - * create NautilusAdapter objects. - */ - -#ifndef NAUTILUS_ADAPTER_FACTORY_SERVER_H -#define NAUTILUS_ADAPTER_FACTORY_SERVER_H - -#include <libnautilus-adapter/nautilus-adapter-factory.h> -#include <gtk/gtklabel.h> -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER (nautilus_adapter_factory_server_get_type ()) -#define NAUTILUS_ADAPTER_FACTORY_SERVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER, NautilusAdapterFactoryServer)) -#define NAUTILUS_ADAPTER_FACTORY_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER, NautilusAdapterFactoryServerClass)) -#define NAUTILUS_IS_ADAPTER_FACTORY_SERVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER)) -#define NAUTILUS_IS_ADAPTER_FACTORY_SERVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_FACTORY_SERVER)) - -typedef struct { - BonoboObject parent; -} NautilusAdapterFactoryServer; - -typedef struct { - BonoboObjectClass parent; - - POA_Nautilus_ComponentAdapterFactory__epv epv; -} NautilusAdapterFactoryServerClass; - -/* GObject support */ -GType nautilus_adapter_factory_server_get_type (void); - - -#endif /* NAUTILUS_ADAPTER_FACTORY_SERVER_H */ diff --git a/components/adapter/nautilus-adapter-file-load-strategy.c b/components/adapter/nautilus-adapter-file-load-strategy.c deleted file mode 100644 index caf43672c..000000000 --- a/components/adapter/nautilus-adapter-file-load-strategy.c +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-file-load-strategy.c - - */ - - -#include <config.h> - -#include <string.h> -#include "nautilus-adapter-file-load-strategy.h" - -#include <gtk/gtkobject.h> -#include <eel/eel-gtk-macros.h> -#include <libgnomevfs/gnome-vfs.h> -#include <libnautilus/nautilus-view.h> - - -struct NautilusAdapterFileLoadStrategyDetails { - Bonobo_PersistFile persist_file; -}; - - -static void nautilus_adapter_file_load_strategy_class_init (NautilusAdapterFileLoadStrategyClass *klass); -static void nautilus_adapter_file_load_strategy_init (NautilusAdapterFileLoadStrategy *strategy); -static void nautilus_adapter_file_load_strategy_destroy (GtkObject *object); - -static void nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy, - const char *uri); - -static void nautilus_adapter_file_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy); - - -EEL_CLASS_BOILERPLATE (NautilusAdapterFileLoadStrategy, nautilus_adapter_file_load_strategy, NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY) - - -static void -nautilus_adapter_file_load_strategy_class_init (NautilusAdapterFileLoadStrategyClass *klass) -{ - GtkObjectClass *object_class; - NautilusAdapterLoadStrategyClass *adapter_load_strategy_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_adapter_file_load_strategy_destroy; - - adapter_load_strategy_class = NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS (klass); - - adapter_load_strategy_class->load_location = nautilus_adapter_file_load_strategy_load_location; - adapter_load_strategy_class->stop_loading = nautilus_adapter_file_load_strategy_stop_loading; -} - -static void -nautilus_adapter_file_load_strategy_init (NautilusAdapterFileLoadStrategy *strategy) -{ - strategy->details = g_new0 (NautilusAdapterFileLoadStrategyDetails, 1); -} - -static void -nautilus_adapter_file_load_strategy_destroy (GtkObject *object) -{ - NautilusAdapterFileLoadStrategy *strategy; - CORBA_Environment ev; - - strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (object); - - if (strategy->details->persist_file != CORBA_OBJECT_NIL) { - CORBA_exception_init (&ev); - bonobo_object_release_unref (strategy->details->persist_file, &ev); - CORBA_exception_free (&ev); - } - - g_free (strategy->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - - - - -NautilusAdapterLoadStrategy * -nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file) -{ - NautilusAdapterFileLoadStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (g_object_new (NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY, NULL)); - g_object_ref (strategy); - gtk_object_sink (GTK_OBJECT (strategy)); - - strategy->details->persist_file = persist_file; - - return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy); -} - -static ORBit_IMethod * -get_file_load_method (void) -{ - guint i; - ORBit_IInterface *iface; - static ORBit_IMethod *method = NULL; - - iface = &Bonobo_PersistFile__iinterface; - if (!method) { - for (i = 0; i < iface->methods._length; i++) { - if (!strcmp ("load", iface->methods._buffer [i].name)) { - method = &iface->methods._buffer [i]; - } - } - } - g_assert (method); - - return method; -} - -static void -nautilus_adapter_file_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy, - const char *uri) - -{ - char *local_path; - gpointer args[1]; - NautilusAdapterFileLoadStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy); - - g_object_ref (strategy); - - local_path = gnome_vfs_get_local_path_from_uri (uri); - - if (local_path == NULL) { - nautilus_adapter_load_strategy_report_load_failed (abstract_strategy); - return; - } - - nautilus_adapter_load_strategy_report_load_underway (abstract_strategy); - - args [0] = &local_path; - - nautilus_adapter_load_strategy_load_async ( - abstract_strategy, - strategy->details->persist_file, - get_file_load_method (), - args, - NULL, NULL); - - g_object_unref (strategy); - - g_free (local_path); -} - -static void -nautilus_adapter_file_load_strategy_stop_loading (NautilusAdapterLoadStrategy *abstract_strategy) -{ - - g_return_if_fail (NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY (abstract_strategy)); - -} - diff --git a/components/adapter/nautilus-adapter-file-load-strategy.h b/components/adapter/nautilus-adapter-file-load-strategy.h deleted file mode 100644 index 646c92360..000000000 --- a/components/adapter/nautilus-adapter-file-load-strategy.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-file-load-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H -#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H - -#include "nautilus-adapter-load-strategy.h" - -#define NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY (nautilus_adapter_file_load_strategy_get_type ()) -#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY, NautilusAdapterFileLoadStrategy)) -#define NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY, NautilusAdapterFileLoadStrategyClass)) -#define NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_FILE_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_FILE_LOAD_STRATEGY)) - -typedef struct NautilusAdapterFileLoadStrategyDetails NautilusAdapterFileLoadStrategyDetails; - -typedef struct { - NautilusAdapterLoadStrategy parent; - NautilusAdapterFileLoadStrategyDetails *details; -} NautilusAdapterFileLoadStrategy; - -typedef struct { - NautilusAdapterLoadStrategyClass parent; -} NautilusAdapterFileLoadStrategyClass; - -/* GObject support */ -GType nautilus_adapter_file_load_strategy_get_type (void); - -NautilusAdapterLoadStrategy *nautilus_adapter_file_load_strategy_new (Bonobo_PersistFile persist_file); - - -#endif /* NAUTILUS_ADAPTER_FILE_LOAD_STRATEGY_H */ - - - diff --git a/components/adapter/nautilus-adapter-load-strategy.c b/components/adapter/nautilus-adapter-load-strategy.c deleted file mode 100644 index 4c1a31961..000000000 --- a/components/adapter/nautilus-adapter-load-strategy.c +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-load-strategy.h - */ - - -#include <config.h> - -#include "nautilus-adapter-load-strategy.h" -#include "nautilus-adapter-stream-load-strategy.h" -#include "nautilus-adapter-file-load-strategy.h" - -#include <gtk/gtkobject.h> -#include <eel/eel-gtk-macros.h> -#include <eel/eel-gtk-extensions.h> -#include <bonobo/bonobo-exception.h> - -enum { - REPORT_LOAD_UNDERWAY, - REPORT_LOAD_PROGRESS, - REPORT_LOAD_COMPLETE, - REPORT_LOAD_FAILED, - LAST_SIGNAL -}; - -static guint signals[LAST_SIGNAL]; - - - -static void nautilus_adapter_load_strategy_class_init (NautilusAdapterLoadStrategyClass *klass); -static void nautilus_adapter_load_strategy_init (NautilusAdapterLoadStrategy *strategy); -static void nautilus_adapter_load_strategy_destroy (GtkObject *object); - -EEL_CLASS_BOILERPLATE (NautilusAdapterLoadStrategy, nautilus_adapter_load_strategy, GTK_TYPE_OBJECT) - -EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_load_strategy, load_location) -EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (nautilus_adapter_load_strategy, stop_loading) - -static void -nautilus_adapter_load_strategy_class_init (NautilusAdapterLoadStrategyClass *klass) -{ - GtkObjectClass *object_class; - - object_class = (GtkObjectClass *) klass; - - object_class->destroy = nautilus_adapter_load_strategy_destroy; - - EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, load_location); - EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, nautilus_adapter_load_strategy, stop_loading); - - - signals[REPORT_LOAD_UNDERWAY] = - g_signal_new ("report_load_underway", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterLoadStrategyClass, report_load_underway), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[REPORT_LOAD_PROGRESS] = - g_signal_new ("report_load_progress", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterLoadStrategyClass, report_load_progress), - NULL, NULL, - g_cclosure_marshal_VOID__DOUBLE, - G_TYPE_NONE, 1, G_TYPE_DOUBLE); - signals[REPORT_LOAD_COMPLETE] = - g_signal_new ("report_load_complete", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterLoadStrategyClass, report_load_complete), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - signals[REPORT_LOAD_FAILED] = - g_signal_new ("report_load_failed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (NautilusAdapterLoadStrategyClass, report_load_failed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); -} - -static void -nautilus_adapter_load_strategy_init (NautilusAdapterLoadStrategy *strategy) -{ - -} - -static void -nautilus_adapter_load_strategy_destroy (GtkObject *object) -{ - NautilusAdapterLoadStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_LOAD_STRATEGY (object); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - - - - -NautilusAdapterLoadStrategy * -nautilus_adapter_load_strategy_get (Bonobo_Unknown component) -{ - Bonobo_PersistStream persist_stream; - Bonobo_PersistFile persist_file; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - persist_stream = Bonobo_Unknown_queryInterface (component, - "IDL:Bonobo/PersistStream:1.0", &ev); - - if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (persist_stream, &ev)) { - CORBA_exception_free (&ev); - - return nautilus_adapter_stream_load_strategy_new (persist_stream); - } - - - persist_file = Bonobo_Unknown_queryInterface (component, - "IDL:Bonobo/PersistFile:1.0", &ev); - - if (ev._major == CORBA_NO_EXCEPTION && !CORBA_Object_is_nil (persist_file, &ev)) { - CORBA_exception_free (&ev); - - return nautilus_adapter_file_load_strategy_new (persist_file); - } - - CORBA_exception_free (&ev); - - return NULL; -} - - -void -nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy, - const char *uri) -{ - g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (strategy)); - - EEL_CALL_METHOD (NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS, strategy, - load_location, (strategy, uri)); -} - -void -nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy) -{ - - g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (strategy)); - - EEL_CALL_METHOD (NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS, strategy, - stop_loading, (strategy)); -} - - -/* "protected" calls, should only be called by subclasses */ - -void -nautilus_adapter_load_strategy_report_load_underway (NautilusAdapterLoadStrategy *strategy) -{ - g_signal_emit (strategy, - signals[REPORT_LOAD_UNDERWAY], 0); -} - -void -nautilus_adapter_load_strategy_report_load_progress (NautilusAdapterLoadStrategy *strategy, - double fraction_done) -{ - g_signal_emit (strategy, - signals[REPORT_LOAD_PROGRESS], 0, - fraction_done); -} - -void -nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy) -{ - g_signal_emit (strategy, signals[REPORT_LOAD_COMPLETE], 0); -} - -void -nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy) -{ - g_signal_emit (strategy, signals[REPORT_LOAD_FAILED], 0); -} - -typedef struct { - gpointer user_data; - GDestroyNotify done_cb; - NautilusAdapterLoadStrategy *strategy; -} AsyncClosure; - -static void -nautilus_adapter_load_strategy_report_async_status (CORBA_Object object, - ORBit_IMethod *m_data, - ORBitAsyncQueueEntry *aqe, - gpointer user_data, - CORBA_Environment *ev) -{ - AsyncClosure *c; - - c = user_data; - g_return_if_fail (NAUTILUS_IS_ADAPTER_LOAD_STRATEGY (c->strategy)); - - if (BONOBO_EX (ev)) { - nautilus_adapter_load_strategy_report_load_failed (c->strategy); - } else { - nautilus_adapter_load_strategy_report_load_complete (c->strategy); - } - - g_object_unref (c->strategy); - - if (c->done_cb) { - c->done_cb (c->user_data); - } - - g_free (c); -} - -void -nautilus_adapter_load_strategy_load_async (NautilusAdapterLoadStrategy *strategy, - CORBA_Object object, - ORBit_IMethod *m_data, - gpointer *args, - GDestroyNotify done_cb, - gpointer user_data) -{ - AsyncClosure *c; - CORBA_Environment ev; - - CORBA_exception_init (&ev); - - c = g_new (AsyncClosure, 1); - c->done_cb = done_cb; - c->strategy = strategy; - c->user_data = user_data; - - g_object_ref (G_OBJECT (strategy)); - - ORBit_small_invoke_async - (object, m_data, - nautilus_adapter_load_strategy_report_async_status, - c, args, NULL, &ev); - - if (BONOBO_EX (&ev)) { - nautilus_adapter_load_strategy_report_async_status ( - object, m_data, NULL, c, &ev); - } - - CORBA_exception_free (&ev); -} diff --git a/components/adapter/nautilus-adapter-load-strategy.h b/components/adapter/nautilus-adapter-load-strategy.h deleted file mode 100644 index c88a73bc5..000000000 --- a/components/adapter/nautilus-adapter-load-strategy.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-load-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_LOAD_STRATEGY_H -#define NAUTILUS_ADAPTER_LOAD_STRATEGY_H - -#include <gtk/gtkobject.h> -#include <bonobo/Bonobo.h> -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY (nautilus_adapter_load_strategy_get_type ()) -#define NAUTILUS_ADAPTER_LOAD_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY, NautilusAdapterLoadStrategy)) -#define NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY, NautilusAdapterLoadStrategyClass)) -#define NAUTILUS_IS_ADAPTER_LOAD_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY)) - -typedef struct NautilusAdapterLoadStrategyDetails NautilusAdapterLoadStrategyDetails; - -typedef struct { - GtkObject parent; -} NautilusAdapterLoadStrategy; - -typedef struct { - GtkObjectClass parent; - - /* signals */ - void (* report_load_underway) (NautilusAdapterLoadStrategy *strategy); - void (* report_load_progress) (NautilusAdapterLoadStrategy *strategy, - double fraction_done); - void (* report_load_complete) (NautilusAdapterLoadStrategy *strategy); - void (* report_load_failed) (NautilusAdapterLoadStrategy *strategy); - - /* virtual methods */ - void (*load_location) (NautilusAdapterLoadStrategy *strategy, - const char *uri); - - void (*stop_loading) (NautilusAdapterLoadStrategy *strategy); -} NautilusAdapterLoadStrategyClass; - -/* GObject support */ -GType nautilus_adapter_load_strategy_get_type (void); - -/* Instantiates the proper concrete subclass */ -NautilusAdapterLoadStrategy *nautilus_adapter_load_strategy_get (Bonobo_Unknown component); - -void nautilus_adapter_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy, - const char *uri); -void nautilus_adapter_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy); - - -/* "protected" calls, should only be called by subclasses */ - -void nautilus_adapter_load_strategy_report_load_underway (NautilusAdapterLoadStrategy *strategy); -void nautilus_adapter_load_strategy_report_load_progress (NautilusAdapterLoadStrategy *strategy, - double fraction_done); -void nautilus_adapter_load_strategy_report_load_complete (NautilusAdapterLoadStrategy *strategy); -void nautilus_adapter_load_strategy_report_load_failed (NautilusAdapterLoadStrategy *strategy); - -void nautilus_adapter_load_strategy_load_async (NautilusAdapterLoadStrategy *strategy, - CORBA_Object object, - ORBit_IMethod *m_data, - gpointer *args, - GDestroyNotify done_cb, - gpointer user_data); - -#endif /* NAUTILUS_ADAPTER_LOAD_STRATEGY_H */ - - - diff --git a/components/adapter/nautilus-adapter-stream-load-strategy.c b/components/adapter/nautilus-adapter-stream-load-strategy.c deleted file mode 100644 index 37cf7552f..000000000 --- a/components/adapter/nautilus-adapter-stream-load-strategy.c +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; see the file COPYING. If not, - * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - - -/* nautilus-adapter-stream-load-strategy.c - - */ - - -#include <config.h> - -#include <string.h> -#include "nautilus-adapter-stream-load-strategy.h" - -#include <bonobo/bonobo-stream.h> -#include <bonobo/bonobo-moniker-util.h> -#include <bonobo/bonobo-exception.h> -#include <gtk/gtkobject.h> -#include <eel/eel-gtk-macros.h> -#include <libnautilus/nautilus-view.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include <libgnomevfs/gnome-vfs-mime-utils.h> - -struct NautilusAdapterStreamLoadStrategyDetails { - Bonobo_PersistStream persist_stream; -}; - - -static void nautilus_adapter_stream_load_strategy_class_init (NautilusAdapterStreamLoadStrategyClass *klass); -static void nautilus_adapter_stream_load_strategy_init (NautilusAdapterStreamLoadStrategy *strategy); -static void nautilus_adapter_stream_load_strategy_destroy (GtkObject *object); - -static void nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy *strategy, - const char *uri); - -static void nautilus_adapter_stream_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy); - - -EEL_CLASS_BOILERPLATE (NautilusAdapterStreamLoadStrategy, nautilus_adapter_stream_load_strategy, NAUTILUS_TYPE_ADAPTER_LOAD_STRATEGY) - - -static void -nautilus_adapter_stream_load_strategy_class_init (NautilusAdapterStreamLoadStrategyClass *klass) -{ - GtkObjectClass *object_class; - NautilusAdapterLoadStrategyClass *adapter_load_strategy_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_adapter_stream_load_strategy_destroy; - - adapter_load_strategy_class = NAUTILUS_ADAPTER_LOAD_STRATEGY_CLASS (klass); - - adapter_load_strategy_class->load_location = nautilus_adapter_stream_load_strategy_load_location; - adapter_load_strategy_class->stop_loading = nautilus_adapter_stream_load_strategy_stop_loading; -} - -static void -nautilus_adapter_stream_load_strategy_init (NautilusAdapterStreamLoadStrategy *strategy) -{ - strategy->details = g_new0 (NautilusAdapterStreamLoadStrategyDetails, 1); -} - -static void -nautilus_adapter_stream_load_strategy_destroy (GtkObject *object) -{ - NautilusAdapterStreamLoadStrategy *strategy; - CORBA_Environment ev; - - strategy = NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY (object); - - if (strategy->details->persist_stream != CORBA_OBJECT_NIL) { - CORBA_exception_init (&ev); - bonobo_object_release_unref (strategy->details->persist_stream, &ev); - CORBA_exception_free (&ev); - } - - g_free (strategy->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - - -NautilusAdapterLoadStrategy * -nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream) -{ - NautilusAdapterStreamLoadStrategy *strategy; - - strategy = NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY (g_object_new (NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY, NULL)); - g_object_ref (strategy); - gtk_object_sink (GTK_OBJECT (strategy)); - - strategy->details->persist_stream = persist_stream; - - return NAUTILUS_ADAPTER_LOAD_STRATEGY (strategy); -} - -static ORBit_IMethod * -get_stream_load_method (void) -{ - guint i; - ORBit_IInterface *iface; - static ORBit_IMethod *method = NULL; - - iface = &Bonobo_PersistStream__iinterface; - if (!method) { - for (i = 0; i < iface->methods._length; i++) { - if (!strcmp ("load", iface->methods._buffer [i].name)) { - method = &iface->methods._buffer [i]; - } - } - } - g_assert (method); - - return method; -} - -static void -unref_stream_cb (gpointer user_data) -{ - bonobo_object_release_unref (user_data, NULL); -} - -static void -nautilus_adapter_stream_load_strategy_load_location (NautilusAdapterLoadStrategy *abstract_strategy, - const char *uri) -{ - NautilusAdapterStreamLoadStrategy *strategy; - Bonobo_Stream stream; - CORBA_Environment ev; - char *moniker_str; - char *escaped_uri; - char *mime_type; - gpointer args[2]; - - strategy = NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY (abstract_strategy); - g_object_ref (strategy); - - CORBA_exception_init (&ev); - - nautilus_adapter_load_strategy_report_load_underway (abstract_strategy); - - /* We must escape the '!' in the URI here, because it is - * used as argument delimiter within monikers. - */ - escaped_uri = gnome_vfs_escape_set (uri, "!"); - moniker_str = g_strconcat ("vfs:", escaped_uri, NULL); - stream = bonobo_get_object (moniker_str, "IDL:Bonobo/Stream:1.0", &ev); - g_free (moniker_str); - g_free (escaped_uri); - - if (BONOBO_EX (&ev) || CORBA_Object_is_nil (stream, &ev)) { - nautilus_adapter_load_strategy_report_load_failed (abstract_strategy); - } else { - /* This adds an extra sniffing, which is a bit of a problem. - * We think this is ok, since it is relatively cheap and - * the adapter isn't used often. When the adapter is - * moved into the nautilus process, this should use the - * mime type from the NautilusFile. */ - mime_type = gnome_vfs_get_mime_type (uri); - args [0] = &stream; - args [1] = &mime_type; - - nautilus_adapter_load_strategy_load_async ( - abstract_strategy, - strategy->details->persist_stream, - get_stream_load_method (), - args, - unref_stream_cb, - stream); - - g_free (mime_type); - } - - g_object_unref (strategy); - - CORBA_exception_free (&ev); -} - -static void -nautilus_adapter_stream_load_strategy_stop_loading (NautilusAdapterLoadStrategy *strategy) -{ - g_return_if_fail (NAUTILUS_IS_ADAPTER_STREAM_LOAD_STRATEGY (strategy)); - - /* FIXME bugzilla.gnome.org 43456: is there anything we can do? */ -} diff --git a/components/adapter/nautilus-adapter-stream-load-strategy.h b/components/adapter/nautilus-adapter-stream-load-strategy.h deleted file mode 100644 index b02666f65..000000000 --- a/components/adapter/nautilus-adapter-stream-load-strategy.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter-stream-load-strategy.h - */ - -#ifndef NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY_H -#define NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY_H - -#include "nautilus-adapter-load-strategy.h" - -#define NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY (nautilus_adapter_stream_load_strategy_get_type ()) -#define NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY, NautilusAdapterStreamLoadStrategy)) -#define NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY, NautilusAdapterStreamLoadStrategyClass)) -#define NAUTILUS_IS_ADAPTER_STREAM_LOAD_STRATEGY(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY)) -#define NAUTILUS_IS_ADAPTER_STREAM_LOAD_STRATEGY_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER_STREAM_LOAD_STRATEGY)) - -typedef struct NautilusAdapterStreamLoadStrategyDetails NautilusAdapterStreamLoadStrategyDetails; - -typedef struct { - NautilusAdapterLoadStrategy parent; - NautilusAdapterStreamLoadStrategyDetails *details; -} NautilusAdapterStreamLoadStrategy; - -typedef struct { - NautilusAdapterLoadStrategyClass parent; -} NautilusAdapterStreamLoadStrategyClass; - -/* GObject support */ -GType nautilus_adapter_stream_load_strategy_get_type (void); - -NautilusAdapterLoadStrategy *nautilus_adapter_stream_load_strategy_new (Bonobo_PersistStream persist_stream); - - -#endif /* NAUTILUS_ADAPTER_STREAM_LOAD_STRATEGY_H */ - - - diff --git a/components/adapter/nautilus-adapter.c b/components/adapter/nautilus-adapter.c deleted file mode 100644 index ba17057f2..000000000 --- a/components/adapter/nautilus-adapter.c +++ /dev/null @@ -1,274 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter.c - Class for adapting bonobo Control/ControlFactory - * to look like Nautilus views. - */ - -#include <config.h> -#include "nautilus-adapter.h" - -#include "nautilus-adapter-embed-strategy-private.h" -#include "nautilus-adapter-embed-strategy.h" -#include "nautilus-adapter-load-strategy.h" -#include <bonobo/bonobo-control.h> -#include <bonobo/bonobo-item-container.h> -#include <eel/eel-gtk-macros.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtkhbox.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-stock-icons.h> -#include <libnautilus-adapter/nautilus-adapter-factory.h> -#include <libnautilus/nautilus-bonobo-ui.h> - -struct NautilusAdapterDetails { - NautilusView *nautilus_view; - NautilusAdapterEmbedStrategy *embed_strategy; - NautilusAdapterLoadStrategy *load_strategy; -}; - - -static void nautilus_adapter_load_location_callback (NautilusView *view, - const char *uri, - NautilusAdapter *adapter); -static void nautilus_adapter_stop_loading_callback (NautilusView *view, - NautilusAdapter *adapter); -static void nautilus_adapter_activate_callback (BonoboControl *control, - gboolean state, - NautilusAdapter *adapter); -static void nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy, - const char *uri, - NautilusAdapter *adapter); -static void nautilus_adapter_load_underway_callback (NautilusAdapter *adapter); -static void nautilus_adapter_load_progress_callback (NautilusAdapter *adapter, - double fraction_complete); -static void nautilus_adapter_load_complete_callback (NautilusAdapter *adapter); -static void nautilus_adapter_load_failed_callback (NautilusAdapter *adapter); -static void nautilus_adapter_class_init (NautilusAdapterClass *klass); -static void nautilus_adapter_init (NautilusAdapter *server); -static void nautilus_adapter_destroy (GtkObject *object); - - -EEL_CLASS_BOILERPLATE (NautilusAdapter, - nautilus_adapter, - GTK_TYPE_OBJECT) - - -static void -nautilus_adapter_class_init (NautilusAdapterClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_adapter_destroy; -} - -static void -nautilus_adapter_init (NautilusAdapter *adapter) -{ - adapter->details = g_new0 (NautilusAdapterDetails, 1); - g_object_ref (adapter); - gtk_object_sink (GTK_OBJECT (adapter)); -} - -static void -nautilus_adapter_destroy (GtkObject *object) -{ - NautilusAdapter *adapter; - - adapter = NAUTILUS_ADAPTER (object); - - if (adapter->details->embed_strategy != NULL) { - nautilus_adapter_embed_strategy_deactivate (adapter->details->embed_strategy); - } - - if (adapter->details->load_strategy != NULL) { - nautilus_adapter_load_strategy_stop_loading (adapter->details->load_strategy); - g_object_unref (adapter->details->load_strategy); - } - - if (adapter->details->embed_strategy != NULL) { - g_object_unref (adapter->details->embed_strategy); - } - - g_free (adapter->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -NautilusAdapter * -nautilus_adapter_new (Bonobo_Unknown component) -{ - NautilusAdapter *adapter; - BonoboControl *control; - GtkWidget *box; - BonoboObject *zoomable; - - /* FIXME bugzilla.gnome.org 44405: should be done with - * construct args - */ - - adapter = NAUTILUS_ADAPTER (g_object_new (NAUTILUS_TYPE_ADAPTER, NULL)); - - /* Set up a few wrapper framework details */ - box = gtk_hbox_new (FALSE, 0); - gtk_widget_show (box); - control = bonobo_control_new (box); - adapter->details->nautilus_view = nautilus_view_new_from_bonobo_control (control); - - g_object_weak_ref (G_OBJECT (adapter->details->nautilus_view), - (GWeakNotify)g_object_unref, adapter); - - /* Get the class to handle embedding this kind of component. */ - adapter->details->embed_strategy = nautilus_adapter_embed_strategy_get (component); - if (adapter->details->embed_strategy == NULL) { - g_object_unref (adapter); - return NULL; - } - - /* Get the NautilusAdapterZoomable proxy object. */ - zoomable = nautilus_adapter_embed_strategy_get_zoomable (adapter->details->embed_strategy); - if (zoomable != NULL) - bonobo_object_add_interface (BONOBO_OBJECT (control), zoomable); - - g_signal_connect_object (control, "activate", - G_CALLBACK (nautilus_adapter_activate_callback), adapter, 0); - g_signal_connect_object (adapter->details->embed_strategy, "open_location", - G_CALLBACK (nautilus_adapter_open_location_callback), adapter, 0); - - /* Get the class to handle loading this kind of component. */ - adapter->details->load_strategy = nautilus_adapter_load_strategy_get (component); - if (adapter->details->load_strategy == NULL) { - g_object_unref (adapter); - return NULL; - } - - /* hook up load strategy signals */ - g_signal_connect_object (adapter->details->load_strategy, "report_load_underway", - G_CALLBACK (nautilus_adapter_load_underway_callback), - adapter, G_CONNECT_SWAPPED); - g_signal_connect_object (adapter->details->load_strategy, "report_load_progress", - G_CALLBACK (nautilus_adapter_load_progress_callback), - adapter, G_CONNECT_SWAPPED); - g_signal_connect_object (adapter->details->load_strategy, "report_load_complete", - G_CALLBACK (nautilus_adapter_load_complete_callback), - adapter, G_CONNECT_SWAPPED); - g_signal_connect_object (adapter->details->load_strategy, "report_load_failed", - G_CALLBACK (nautilus_adapter_load_failed_callback), - adapter, G_CONNECT_SWAPPED); - - /* complete the embedding */ - gtk_container_add (GTK_CONTAINER (box), - nautilus_adapter_embed_strategy_get_widget (adapter->details->embed_strategy)); - - /* hook up view signals. */ - g_signal_connect_object (adapter->details->nautilus_view, "load_location", - G_CALLBACK (nautilus_adapter_load_location_callback), adapter, 0); - g_signal_connect_object (adapter->details->nautilus_view, "stop_loading", - G_CALLBACK (nautilus_adapter_stop_loading_callback), adapter, 0); - - return adapter; -} - -NautilusView * -nautilus_adapter_get_nautilus_view (NautilusAdapter *adapter) -{ - return adapter->details->nautilus_view; -} - -static void -nautilus_adapter_load_location_callback (NautilusView *view, - const char *location, - NautilusAdapter *adapter) -{ - nautilus_adapter_load_strategy_load_location (adapter->details->load_strategy, - location); -} - - -static void -nautilus_adapter_stop_loading_callback (NautilusView *view, - NautilusAdapter *adapter) -{ - nautilus_adapter_load_strategy_stop_loading (adapter->details->load_strategy); -} - - -static void -nautilus_adapter_open_location_callback (NautilusAdapterEmbedStrategy *strategy, - const char *uri, - NautilusAdapter *adapter) -{ - nautilus_view_open_location - (adapter->details->nautilus_view, - uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0, NULL); -} - - -static void -nautilus_adapter_activate_callback (BonoboControl *control, - gboolean state, - NautilusAdapter *adapter) -{ - g_return_if_fail (control != NULL); - g_return_if_fail (BONOBO_IS_CONTROL (control)); - g_return_if_fail (adapter != NULL); - g_return_if_fail (NAUTILUS_IS_ADAPTER (adapter)); - - if (state) { - Bonobo_UIContainer corba_container; - - corba_container = bonobo_control_get_remote_ui_container (control, NULL); - nautilus_adapter_embed_strategy_activate (adapter->details->embed_strategy, - corba_container); - } else - nautilus_adapter_embed_strategy_deactivate (adapter->details->embed_strategy); -} - - -static void -nautilus_adapter_load_underway_callback (NautilusAdapter *adapter) -{ - nautilus_view_report_load_underway (adapter->details->nautilus_view); -} - -static void -nautilus_adapter_load_progress_callback (NautilusAdapter *adapter, - double fraction_complete) -{ - nautilus_view_report_load_progress (adapter->details->nautilus_view, - fraction_complete); -} - -static void -nautilus_adapter_load_complete_callback (NautilusAdapter *adapter) -{ - nautilus_view_report_load_complete (adapter->details->nautilus_view); -} - -static void -nautilus_adapter_load_failed_callback (NautilusAdapter *adapter) -{ - nautilus_view_report_load_failed (adapter->details->nautilus_view); -} diff --git a/components/adapter/nautilus-adapter.h b/components/adapter/nautilus-adapter.h deleted file mode 100644 index dcd14ef01..000000000 --- a/components/adapter/nautilus-adapter.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-adapter.h - Adapter component. - */ - -#ifndef NAUTILUS_ADAPTER_H -#define NAUTILUS_ADAPTER_H - -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_ADAPTER (nautilus_adapter_get_type ()) -#define NAUTILUS_ADAPTER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_ADAPTER, NautilusAdapter)) -#define NAUTILUS_ADAPTER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_ADAPTER, NautilusAdapterClass)) -#define NAUTILUS_IS_ADAPTER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_ADAPTER)) -#define NAUTILUS_IS_ADAPTER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_ADAPTER)) - -typedef struct NautilusAdapterDetails NautilusAdapterDetails; - -typedef struct { - GtkObject parent; - NautilusAdapterDetails *details; -} NautilusAdapter; - -typedef struct { - GtkObjectClass parent; -} NautilusAdapterClass; - -/* GObject support */ -GType nautilus_adapter_get_type (void); - -NautilusAdapter *nautilus_adapter_new (Bonobo_Unknown component); -NautilusView *nautilus_adapter_get_nautilus_view (NautilusAdapter *adapter); - -#endif /* NAUTILUS_ADAPTER_H */ diff --git a/components/adapter/nautilus-zoomable-proxy.c b/components/adapter/nautilus-zoomable-proxy.c deleted file mode 100644 index a57aeb02e..000000000 --- a/components/adapter/nautilus-zoomable-proxy.c +++ /dev/null @@ -1,312 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2000 Eazel, Inc. - * 2000 SuSE GmbH. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Maciej Stachowiak <mjs@eazel.com> - * Martin Baulig <baulig@suse.de> - * - */ - -#include <config.h> -#include "nautilus-zoomable-proxy.h" - -#undef ZOOMABLE_DEBUG - -static BonoboObjectClass *nautilus_zoomable_proxy_parent_class; - -struct _NautilusZoomableProxyPrivate { - Bonobo_Zoomable remote_zoomable; -}; - -static inline NautilusZoomableProxy * -nautilus_zoomable_proxy_from_servant (PortableServer_Servant servant) -{ - g_assert (NAUTILUS_IS_ZOOMABLE_PROXY (bonobo_object_from_servant (servant))); - - return NAUTILUS_ZOOMABLE_PROXY (bonobo_object_from_servant (servant)); -} - -static CORBA_float -impl_Nautilus_ZoomableProxy__get_level (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_level (proxy->priv->remote_zoomable, ev); -} - -static CORBA_float -impl_Nautilus_ZoomableProxy__get_minLevel (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_minLevel (proxy->priv->remote_zoomable, ev); -} - -static CORBA_float -impl_Nautilus_ZoomableProxy__get_maxLevel (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_maxLevel (proxy->priv->remote_zoomable, ev); -} - -static CORBA_boolean -impl_Nautilus_ZoomableProxy__get_hasMinLevel (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_hasMinLevel (proxy->priv->remote_zoomable, ev); -} - -static CORBA_boolean -impl_Nautilus_ZoomableProxy__get_hasMaxLevel (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_hasMaxLevel (proxy->priv->remote_zoomable, ev); -} - -static CORBA_boolean -impl_Nautilus_ZoomableProxy__get_isContinuous (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_isContinuous (proxy->priv->remote_zoomable, ev); -} - -static Bonobo_ZoomLevelList * -impl_Nautilus_ZoomableProxy__get_preferredLevels (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_preferredLevels (proxy->priv->remote_zoomable, ev); -} - -static Bonobo_ZoomLevelNameList * -impl_Nautilus_ZoomableProxy__get_preferredLevelNames (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - return Bonobo_Zoomable__get_preferredLevelNames (proxy->priv->remote_zoomable, ev); -} - -static void -impl_Nautilus_ZoomableProxy_setLevel (PortableServer_Servant servant, - const CORBA_float zoom_level, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_setLevel (proxy->priv->remote_zoomable, zoom_level, ev); -} - -static void -impl_Nautilus_ZoomableProxy_zoomIn (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_zoomIn (proxy->priv->remote_zoomable, ev); -} - -static void -impl_Nautilus_ZoomableProxy_zoomOut (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_zoomOut (proxy->priv->remote_zoomable, ev); -} - -static void -impl_Nautilus_ZoomableProxy_zoomFit (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_zoomFit (proxy->priv->remote_zoomable, ev); -} - -static void -impl_Nautilus_ZoomableProxy_zoomDefault (PortableServer_Servant servant, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_zoomDefault (proxy->priv->remote_zoomable, ev); -} - -static void -impl_Nautilus_ZoomableProxy_setFrame (PortableServer_Servant servant, - Bonobo_ZoomableFrame zoomable_frame, - CORBA_Environment *ev) -{ - NautilusZoomableProxy *proxy; - - proxy = nautilus_zoomable_proxy_from_servant (servant); - Bonobo_Zoomable_setFrame (proxy->priv->remote_zoomable, zoomable_frame, ev); - - Bonobo_ZoomableFrame_onParametersChanged (zoomable_frame, ev); -} - - -static void -nautilus_zoomable_proxy_init_epv (POA_Bonobo_Zoomable__epv *epv) -{ - epv->_get_level = impl_Nautilus_ZoomableProxy__get_level; - epv->_get_minLevel = impl_Nautilus_ZoomableProxy__get_minLevel; - epv->_get_maxLevel = impl_Nautilus_ZoomableProxy__get_maxLevel; - epv->_get_hasMinLevel = impl_Nautilus_ZoomableProxy__get_hasMinLevel; - epv->_get_hasMaxLevel = impl_Nautilus_ZoomableProxy__get_hasMaxLevel; - epv->_get_isContinuous = impl_Nautilus_ZoomableProxy__get_isContinuous; - epv->_get_preferredLevels = impl_Nautilus_ZoomableProxy__get_preferredLevels; - epv->_get_preferredLevelNames = impl_Nautilus_ZoomableProxy__get_preferredLevelNames; - - epv->zoomIn = impl_Nautilus_ZoomableProxy_zoomIn; - epv->zoomOut = impl_Nautilus_ZoomableProxy_zoomOut; - epv->zoomFit = impl_Nautilus_ZoomableProxy_zoomFit; - epv->zoomDefault = impl_Nautilus_ZoomableProxy_zoomDefault; - - epv->setLevel = impl_Nautilus_ZoomableProxy_setLevel; - epv->setFrame = impl_Nautilus_ZoomableProxy_setFrame; -} - -static void -nautilus_zoomable_proxy_destroy (BonoboObject *object) -{ - NautilusZoomableProxy *proxy; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ZOOMABLE_PROXY (object)); - - proxy = NAUTILUS_ZOOMABLE_PROXY (object); - - if (proxy->priv->remote_zoomable != CORBA_OBJECT_NIL) - bonobo_object_release_unref (proxy->priv->remote_zoomable, NULL); - proxy->priv->remote_zoomable = CORBA_OBJECT_NIL; - - BONOBO_OBJECT_CLASS (nautilus_zoomable_proxy_parent_class)->destroy (BONOBO_OBJECT (object)); -} - -static void -nautilus_zoomable_proxy_finalize (GObject *object) -{ - NautilusZoomableProxy *proxy; - - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_ZOOMABLE_PROXY (object)); - - proxy = NAUTILUS_ZOOMABLE_PROXY (object); - - g_free (proxy->priv); - proxy->priv = NULL; - - G_OBJECT_CLASS (nautilus_zoomable_proxy_parent_class)->finalize (object); -} - -static void -nautilus_zoomable_proxy_class_init (NautilusZoomableProxyClass *klass) -{ - GObjectClass *object_class; - BonoboObjectClass *bonobo_object_class; - - object_class = (GObjectClass *) klass; - bonobo_object_class = (BonoboObjectClass *)klass; - - nautilus_zoomable_proxy_parent_class = - g_type_class_peek_parent (klass); - - bonobo_object_class->destroy = nautilus_zoomable_proxy_destroy; - object_class->finalize = nautilus_zoomable_proxy_finalize; - - nautilus_zoomable_proxy_init_epv (&klass->epv); -} - -static void -nautilus_zoomable_proxy_init (NautilusZoomableProxy *proxy) -{ - proxy->priv = g_new0 (NautilusZoomableProxyPrivate, 1); -} - -/** - * nautilus_zoomable_proxy_get_type: - * - * Returns: the GType for a NautilusZoomableProxy object. - */ -GType -nautilus_zoomable_proxy_get_type (void) -{ - static GType type = 0; - - if (!type) { - GTypeInfo info = { - sizeof (NautilusZoomableProxyClass), - (GBaseInitFunc) NULL, - (GBaseFinalizeFunc) NULL, - (GClassInitFunc) nautilus_zoomable_proxy_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (NautilusZoomableProxy), - 0, /* n_preallocs */ - (GInstanceInitFunc) nautilus_zoomable_proxy_init - }; - - type = bonobo_type_unique - (BONOBO_TYPE_OBJECT, - POA_Bonobo_Zoomable__init, NULL, - G_STRUCT_OFFSET (NautilusZoomableProxyClass, epv), - &info, "NautilusZoomableProxy"); - } - - return type; -} - -BonoboObject * -nautilus_zoomable_proxy_get (Bonobo_Zoomable remote_zoomable) -{ - NautilusZoomableProxy *proxy; - - g_return_val_if_fail (remote_zoomable != CORBA_OBJECT_NIL, NULL); - - proxy = g_object_new (nautilus_zoomable_proxy_get_type (), NULL); - - proxy->priv->remote_zoomable = bonobo_object_dup_ref (remote_zoomable, NULL); - - return BONOBO_OBJECT (proxy); -} diff --git a/components/adapter/nautilus-zoomable-proxy.h b/components/adapter/nautilus-zoomable-proxy.h deleted file mode 100644 index b159a7e6e..000000000 --- a/components/adapter/nautilus-zoomable-proxy.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- - * - * Copyright (C) 2000 Eazel, Inc. - * 2000 SuSE GmbH. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Maciej Stachowiak <mjs@eazel.com> - * Martin Baulig <baulig@suse.de> - * - */ - -#ifndef NAUTILUS_ZOOMABLE_PROXY_H -#define NAUTILUS_ZOOMABLE_PROXY_H - -#include <bonobo/bonobo-zoomable.h> - -#define NAUTILUS_ZOOMABLE_PROXY_TYPE (nautilus_zoomable_proxy_get_type ()) -#define NAUTILUS_ZOOMABLE_PROXY(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_ZOOMABLE_PROXY_TYPE, NautilusZoomableProxy)) -#define NAUTILUS_ZOOMABLE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NAUTILUS_ZOOMABLE_PROXY_TYPE, NautilusZoomableProxyClass)) -#define NAUTILUS_IS_ZOOMABLE_PROXY(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_ZOOMABLE_PROXY_TYPE)) -#define NAUTILUS_S_ZOOMABLE_PROXY_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NAUTILUS_ZOOMABLE_PROXY_TYPE)) - -typedef struct _NautilusZoomableProxy NautilusZoomableProxy; -typedef struct _NautilusZoomableProxyPrivate NautilusZoomableProxyPrivate; -typedef struct _NautilusZoomableProxyClass NautilusZoomableProxyClass; - -struct _NautilusZoomableProxy { - BonoboObject parent; - - NautilusZoomableProxyPrivate *priv; -}; - -struct _NautilusZoomableProxyClass { - BonoboObjectClass parent; - - POA_Bonobo_Zoomable__epv epv; -}; - -GType nautilus_zoomable_proxy_get_type (void); - -BonoboObject *nautilus_zoomable_proxy_get (Bonobo_Zoomable corba_zoomable); - -#endif /* NAUTILUS_ZOOMABLE_PROXY_H */ diff --git a/components/emblem/Makefile.am b/components/emblem/Makefile.am deleted file mode 100644 index 4c7874db5..000000000 --- a/components/emblem/Makefile.am +++ /dev/null @@ -1,41 +0,0 @@ -NULL = - -INCLUDES = \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - -DG_LOG_DOMAIN=\"Nautilus-Emblem-Sidebar\" \ - -DDATADIR=\""$(datadir)"\" \ - -I$(top_srcdir) \ - $(EMBLEM_COMPONENT_CFLAGS) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(NULL) - -EMBLEM_VIEW_COMMON_SOURCES = \ - nautilus-emblem-view.c \ - nautilus-emblem-view.h \ - nautilus-emblem-view-iids.h \ - $(NULL) - -bonobodir = $(libdir)/bonobo -bonobo_LTLIBRARIES = libnautilus-emblem-view.la - -libnautilus_emblem_view_la_SOURCES = $(EMBLEM_VIEW_COMMON_SOURCES) \ - libmain.c - -libnautilus_emblem_view_la_LDFLAGS = -module -avoid-version -no-undefined - -libnautilus_emblem_view_la_LIBADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-private/libnautilus-private.la \ - $(EMBLEM_COMPONENT_LIBS) - $(NULL) - -server_in_files = Nautilus_View_emblem.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = $(server_in_files) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/emblem/Nautilus_View_emblem.server.in.in b/components/emblem/Nautilus_View_emblem.server.in.in deleted file mode 100644 index 4a9c825dd..000000000 --- a/components/emblem/Nautilus_View_emblem.server.in.in +++ /dev/null @@ -1,15 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Emblem_View" - type="shlib" location="@BONOBODIR@/libnautilus-emblem-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Emblem view"/> - <oaf_attribute name="description" type="string" _value="Nautilus Emblem side pane"/> - <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="Emblems"/> -</oaf_server> - -</oaf_info> diff --git a/components/emblem/libmain.c b/components/emblem/libmain.c deleted file mode 100644 index 26cf335af..000000000 --- a/components/emblem/libmain.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000, 2001 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak - */ - -/* libmain.c - object activation infrastructure for shared library - version of emblem view. */ - -#include <config.h> -#include <string.h> -#include "nautilus-emblem-view-iids.h" -#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, - const char *iid, - gpointer impl_ptr, - CORBA_Environment *ev) -{ - 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), NULL); -} - -static const BonoboActivationPluginObject emblem_plugin_list[] = { - { EMBLEM_VIEW_IID, emblem_shlib_make_object }, - { NULL } -}; - -const BonoboActivationPlugin Bonobo_Plugin_info = { - emblem_plugin_list, - "Nautilus Emblem Sidebar Panel" -}; diff --git a/components/emblem/nautilus-emblem-view-iids.h b/components/emblem/nautilus-emblem-view-iids.h deleted file mode 100644 index d3eb024fc..000000000 --- a/components/emblem/nautilus-emblem-view-iids.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: James Willcox <jwillcox@gnome.org> - */ - -#ifndef NAUTILUS_EMBLEM_VIEW_IIDS_H -#define NAUTILUS_EMBLEM_VIEW_IIDS_H - -#define EMBLEM_VIEW_IID "OAFIID:Nautilus_Emblem_View" -#define EMBLEM_VIEW_FACTORY_IID "OAFIID:Nautilus_Emblem_View_Factory" - -#endif /* NAUTILUS_EMBLEM_VIEW_IIDS_H */ diff --git a/components/emblem/nautilus-emblem-view.c b/components/emblem/nautilus-emblem-view.c deleted file mode 100644 index e572677a7..000000000 --- a/components/emblem/nautilus-emblem-view.c +++ /dev/null @@ -1,997 +0,0 @@ - /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000, 2001 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: James Willcox <jwillcox@gnome.org> - * - * This is a sidebar displaying emblems which can be dragged onto files to - * set/unset the chosen emblem. - * - */ - -#include <config.h> -#include "nautilus-emblem-view.h" - -#include <stdio.h> -#include <eel/eel-gtk-macros.h> -#include <eel/eel-glib-extensions.h> -#include <eel/eel-string.h> -#include <eel/eel-wrap-table.h> -#include <eel/eel-labeled-image.h> -#include <eel/eel-graphic-effects.h> -#include <eel/eel-gdk-pixbuf-extensions.h> -#include <eel/eel-vfs-extensions.h> -#include <eel/eel-stock-dialogs.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtkdnd.h> -#include <gtk/gtkeventbox.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkhbox.h> -#include <gtk/gtktable.h> -#include <gtk/gtkdialog.h> -#include <gtk/gtklabel.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkimage.h> -#include <gtk/gtkentry.h> -#include <gtk/gtkimagemenuitem.h> -#include <gtk/gtkmenu.h> -#include <gtk/gtkmenushell.h> -#include <librsvg/rsvg.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-uidefs.h> -#include <libgnomeui/gnome-popup-menu.h> -#include <libgnomevfs/gnome-vfs-utils.h> -#include <gconf/gconf-client.h> -#include <libnautilus-private/nautilus-icon-factory.h> -#include <libnautilus-private/nautilus-icon-dnd.h> -#include <libnautilus-private/nautilus-emblem-utils.h> -#include <libnautilus-private/nautilus-file-utilities.h> - -struct NautilusEmblemViewDetails { - GConfClient *client; - GtkWidget *emblems_table; - GtkWidget *popup; - GtkWidget *popup_remove; - GtkWidget *popup_rename; - - char *popup_emblem_keyword; - char *popup_emblem_display_name; - GdkPixbuf *popup_emblem_pixbuf; -}; - -#define ERASE_EMBLEM_KEYWORD "erase" -#define STANDARD_EMBLEM_HEIGHT 52 -#define EMBLEM_LABEL_SPACING 2 - -static void nautilus_emblem_view_class_init (NautilusEmblemViewClass *object_klass); -static void nautilus_emblem_view_instance_init (NautilusEmblemView *object); -static void nautilus_emblem_view_finalize (GObject *object); -static void nautilus_emblem_view_populate (NautilusEmblemView *emblem_view); -static void nautilus_emblem_view_refresh (NautilusEmblemView *emblem_view); - -static GtkTargetEntry drag_types[] = { - {"property/keyword", 0, 0 } -}; - -enum { - TARGET_URI_LIST, - TARGET_URI, - TARGET_NETSCAPE_URL -}; - -static GtkTargetEntry dest_types[] = { - {"text/uri-list", 0, TARGET_URI_LIST}, - {"text/plain", 0, TARGET_URI}, - {"_NETSCAPE_URL", 0, TARGET_NETSCAPE_URL} -}; - -typedef struct _Emblem { - GdkPixbuf *pixbuf; - char *uri; - char *name; - char *keyword; -} Emblem; - -BONOBO_CLASS_BOILERPLATE (NautilusEmblemView, nautilus_emblem_view, - NautilusView, NAUTILUS_TYPE_VIEW) - -static void -nautilus_emblem_view_drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *data, - guint info, - guint time, - NautilusEmblemView *emblem_view) -{ - char *keyword; - - keyword = g_object_get_data (G_OBJECT (widget), "emblem-keyword"); - - g_return_if_fail (keyword != NULL); - - gtk_selection_data_set (data, data->target, 8, - keyword, - strlen (keyword)); -} - -static void -nautilus_emblem_view_enter_notify_cb (GtkWidget *widget, - NautilusEmblemView *emblem_view) -{ - GdkPixbuf *pixbuf; - EelLabeledImage *image; - - pixbuf = g_object_get_data (G_OBJECT (widget), "prelight-pixbuf"); - image = g_object_get_data (G_OBJECT (widget), "labeled-image"); - - eel_labeled_image_set_pixbuf (EEL_LABELED_IMAGE (image), pixbuf); -} - -static void -nautilus_emblem_view_leave_notify_cb (GtkWidget *widget, - NautilusEmblemView *emblem_view) -{ - GdkPixbuf *pixbuf; - EelLabeledImage *image; - - pixbuf = g_object_get_data (G_OBJECT (widget), "original-pixbuf"); - image = g_object_get_data (G_OBJECT (widget), "labeled-image"); - - eel_labeled_image_set_pixbuf (EEL_LABELED_IMAGE (image), pixbuf); -} - -static gboolean -nautilus_emblem_view_button_press_cb (GtkWidget *widget, - GdkEventButton *event, - NautilusEmblemView *emblem_view) -{ - char *keyword, *name; - GdkPixbuf *pixbuf; - - if (event->button == 3) { - keyword = g_object_get_data (G_OBJECT (widget), - "emblem-keyword"); - name = g_object_get_data (G_OBJECT (widget), - "emblem-display-name"); - pixbuf = g_object_get_data (G_OBJECT (widget), - "original-pixbuf"); - - emblem_view->details->popup_emblem_keyword = keyword; - emblem_view->details->popup_emblem_display_name = name; - emblem_view->details->popup_emblem_pixbuf = pixbuf; - - gtk_widget_set_sensitive (emblem_view->details->popup_remove, - nautilus_emblem_can_remove_emblem (keyword)); - gtk_widget_set_sensitive (emblem_view->details->popup_rename, - nautilus_emblem_can_rename_emblem (keyword)); - - - gnome_popup_menu_do_popup_modal (emblem_view->details->popup, - NULL, NULL, event, NULL, - widget); - } - - return TRUE; -} - -static void -nautilus_emblem_view_delete_cb (GtkWidget *menu_item, - NautilusEmblemView *emblem_view) -{ - char *error; - - if (nautilus_emblem_remove_emblem (emblem_view->details->popup_emblem_keyword)) { - nautilus_emblem_view_refresh (emblem_view); - } else { - error = g_strdup_printf (_("Couldn't remove emblem with name '%s'."), emblem_view->details->popup_emblem_display_name); - eel_show_error_dialog (error, _("This is probably because the emblem is a permanent one, and not one you added yourself."), - _("Couldn't Remove Emblem"), - NULL); - g_free (error); - } -} - -static void -rename_dialog_response_cb (GtkWidget *dialog, int response, - NautilusEmblemView *emblem_view) -{ - GtkWidget *entry; - char *keyword, *name, *error; - - keyword = g_object_get_data (G_OBJECT (dialog), "emblem-keyword"); - - if (response == GTK_RESPONSE_CANCEL) { - g_free (keyword); - gtk_widget_destroy (dialog); - return; - } else if (response == GTK_RESPONSE_HELP) { - g_message ("Implement me!"); - return; - } - - - entry = g_object_get_data (G_OBJECT (dialog), "entry"); - - name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry))); - - gtk_widget_destroy (dialog); - - if (nautilus_emblem_rename_emblem (keyword, name)) { - nautilus_emblem_view_refresh (emblem_view); - } else { - error = g_strdup_printf (_("Couldn't rename emblem with name '%s'."), name); - eel_show_error_dialog (error, _("This is probably because the emblem is a permanent one, and not one that you added yourself."), - _("Couldn't Rename Emblem"), - NULL); - g_free (error); - } - - g_free (keyword); - g_free (name); -} - -static GtkWidget * -create_rename_emblem_dialog (NautilusEmblemView *emblem_view, - const char *keyword, const char *orig_name, - GdkPixbuf *pixbuf) -{ - GtkWidget *dialog, *label, *image, *entry, *hbox; - - image = gtk_image_new_from_pixbuf (pixbuf); - entry = gtk_entry_new (); - - dialog = gtk_dialog_new_with_buttons (_("Rename Emblem"), - NULL, - 0, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), - GTK_RESPONSE_OK); - - g_object_set_data (G_OBJECT (dialog), "emblem-keyword", - g_strdup (keyword)); - g_object_set_data (G_OBJECT (dialog), "entry", - entry); - - label = gtk_label_new (_("Enter a new name for the displayed emblem:")); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), label, - FALSE, FALSE, GNOME_PAD); - - - hbox = gtk_hbox_new (FALSE, GNOME_PAD); - gtk_box_pack_start (GTK_BOX (hbox), image, TRUE, TRUE, GNOME_PAD); - - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - - gtk_box_pack_start (GTK_BOX (hbox), entry, TRUE, FALSE, GNOME_PAD); - gtk_widget_show_all (hbox); - - /* it would be nice to have the text selected, ready to be overwritten - * by the user, but that doesn't seem possible. - */ - gtk_widget_grab_focus (entry); - gtk_entry_set_text (GTK_ENTRY (entry), orig_name); - - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), hbox, - TRUE, TRUE, GNOME_PAD); - - - return dialog; -} - -static void -nautilus_emblem_view_rename_cb (GtkWidget *menu_item, - NautilusEmblemView *emblem_view) -{ - GtkWidget *dialog; - - dialog = create_rename_emblem_dialog (emblem_view, - emblem_view->details->popup_emblem_keyword, - emblem_view->details->popup_emblem_display_name, - emblem_view->details->popup_emblem_pixbuf); - g_signal_connect (dialog, "response", - G_CALLBACK (rename_dialog_response_cb), - emblem_view); - gtk_widget_show (dialog); -} - -static void -create_popup_menu (NautilusEmblemView *emblem_view) -{ - GtkWidget *popup, *menu_item, *menu_image; - - popup = gtk_menu_new (); - - /* add the "rename" menu item */ - menu_image = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES, - GTK_ICON_SIZE_MENU); - gtk_widget_show (menu_image); - menu_item = gtk_image_menu_item_new_with_label (_("Rename")); - gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), - menu_image); - - g_signal_connect (menu_item, "activate", - G_CALLBACK (nautilus_emblem_view_rename_cb), - emblem_view); - gtk_widget_show (menu_item); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), menu_item); - emblem_view->details->popup_rename = menu_item; - - /* add "delete" menu item */ - menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, - NULL); - g_signal_connect (menu_item, "activate", - G_CALLBACK (nautilus_emblem_view_delete_cb), - emblem_view); - gtk_widget_show (menu_item); - gtk_menu_shell_append (GTK_MENU_SHELL (popup), menu_item); - emblem_view->details->popup_remove = menu_item; - - emblem_view->details->popup = popup; -} - -static GtkWidget * -create_emblem_widget_with_pixbuf (NautilusEmblemView *emblem_view, - const char *keyword, - const char *display_name, - GdkPixbuf *pixbuf) -{ - GtkWidget *image, *event_box; - GdkPixbuf *prelight_pixbuf; - - - image = eel_labeled_image_new (display_name, pixbuf); - - eel_labeled_image_set_fixed_image_height (EEL_LABELED_IMAGE (image), - STANDARD_EMBLEM_HEIGHT); - eel_labeled_image_set_spacing (EEL_LABELED_IMAGE (image), - EMBLEM_LABEL_SPACING); - event_box = gtk_event_box_new (); - gtk_container_add (GTK_CONTAINER (event_box), image); - - prelight_pixbuf = eel_create_spotlight_pixbuf (pixbuf); - - - gtk_drag_source_set (event_box, GDK_BUTTON1_MASK, drag_types, - G_N_ELEMENTS (drag_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); - - gtk_drag_source_set_icon_pixbuf (event_box, pixbuf); - - - - g_signal_connect (event_box, "button_press_event", - G_CALLBACK (nautilus_emblem_view_button_press_cb), - emblem_view); - g_signal_connect (event_box, "drag-data-get", - G_CALLBACK (nautilus_emblem_view_drag_data_get_cb), - emblem_view); - g_signal_connect (event_box, "enter-notify-event", - G_CALLBACK (nautilus_emblem_view_enter_notify_cb), - emblem_view); - g_signal_connect (event_box, "leave-notify-event", - G_CALLBACK (nautilus_emblem_view_leave_notify_cb), - emblem_view); - - g_object_set_data_full (G_OBJECT (event_box), - "emblem-keyword", - g_strdup (keyword), g_free); - g_object_set_data_full (G_OBJECT (event_box), - "emblem-display-name", - g_strdup (display_name), g_free); - g_object_set_data_full (G_OBJECT (event_box), - "original-pixbuf", - pixbuf, g_object_unref); - g_object_set_data_full (G_OBJECT (event_box), - "prelight-pixbuf", - prelight_pixbuf, g_object_unref); - g_object_set_data (G_OBJECT (event_box), - "labeled-image", image); - - return event_box; - -} - -static GtkWidget * -create_emblem_widget (NautilusEmblemView *emblem_view, - const char *name) -{ - GtkWidget *ret; - char *display_name, *keyword; - GdkPixbuf *pixbuf; - - pixbuf = nautilus_icon_factory_get_pixbuf_from_name (name, NULL, - NAUTILUS_ICON_SIZE_STANDARD, - &display_name); - - keyword = nautilus_emblem_get_keyword_from_icon_name (name); - if (display_name == NULL) { - display_name = g_strdup (keyword); - } - - ret = create_emblem_widget_with_pixbuf (emblem_view, keyword, - display_name, pixbuf); - g_free (keyword); - g_free (display_name); - - return ret; -} - -static void -emblem_name_entry_changed_cb (GtkWidget *entry, Emblem *emblem) -{ - char *text; - - g_free (emblem->name); - - text = gtk_editable_get_chars (GTK_EDITABLE (entry), 0, -1); - - emblem->name = g_strdup (text); -} - - -static void -destroy_emblem (Emblem *emblem, gpointer user_data) -{ - g_return_if_fail (emblem != NULL); - - - if (emblem->pixbuf != NULL) { - g_object_unref (emblem->pixbuf); - emblem->pixbuf = NULL; - } - - if (emblem->name != NULL) { - g_free (emblem->name); - emblem->name = NULL; - } - - if (emblem->uri != NULL) { - g_free (emblem->uri); - emblem->uri = NULL; - } - - if (emblem->keyword != NULL) { - g_free (emblem->keyword); - emblem->keyword = NULL; - } - - g_free (emblem); -} - -static void -destroy_emblem_list (GSList *list) -{ - g_slist_foreach (list, (GFunc)destroy_emblem, NULL); - g_slist_free (list); -} - -static GtkWidget * -create_add_emblems_dialog (NautilusEmblemView *emblem_view, - GSList *emblems) -{ - GtkWidget *dialog, *label, *table, *image; - GtkWidget *first_entry, *entry, *scroller, *hbox; - Emblem *emblem; - GSList *list; - int num_emblems; - - first_entry = NULL; - - dialog = gtk_dialog_new_with_buttons (_("Add Emblems..."), - NULL, - 0, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - GTK_STOCK_OK, - GTK_RESPONSE_OK, - GTK_STOCK_HELP, - GTK_RESPONSE_HELP, - NULL); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), - GTK_RESPONSE_OK); - - /* FIXME: make a better message */ - if (g_slist_length (emblems) > 1) { - label = gtk_label_new (_("Enter a descriptive name next to each emblem. This name will be used in other places to identify the emblem.")); - } else { - label = gtk_label_new (_("Enter a descriptive name next to the emblem. This name will be used in other places to identify the emblem.")); - } - - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - label, FALSE, FALSE, GNOME_PAD); - gtk_widget_show (label); - - scroller = eel_scrolled_wrap_table_new (TRUE, &table); - eel_wrap_table_set_x_spacing (EEL_WRAP_TABLE (table), GNOME_PAD); - eel_wrap_table_set_y_spacing (EEL_WRAP_TABLE (table), GNOME_PAD); - - num_emblems=0; - list = emblems; - while (list != NULL) { - /* walk through the list of emblems, and create an image - * and entry for each one - */ - - emblem = (Emblem *)list->data; - list = list->next; - - image = gtk_image_new_from_pixbuf (emblem->pixbuf); - - hbox = gtk_hbox_new (TRUE, 0); - gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0); - - entry = gtk_entry_new (); - gtk_entry_set_activates_default (GTK_ENTRY (entry), TRUE); - g_signal_connect (entry, "changed", - G_CALLBACK (emblem_name_entry_changed_cb), - emblem); - - gtk_box_pack_start (GTK_BOX (hbox), entry, FALSE, FALSE, 0); - gtk_container_add (GTK_CONTAINER (table), hbox); - - if (num_emblems == 0) { - first_entry = entry; - } - - num_emblems++; - } - - gtk_container_set_border_width (GTK_CONTAINER (dialog), GNOME_PAD); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - scroller, TRUE, TRUE, GNOME_PAD); - gtk_widget_show_all (scroller); - - gtk_widget_grab_focus (first_entry); - - /* we expand the window to hold up to about 4 emblems, but after that - * let the scroller do its thing. Is there a better way to do this? - */ - gtk_window_set_default_size (GTK_WINDOW (dialog), 400, - MIN (120+(60*num_emblems), 350)); - - g_object_set_data_full (G_OBJECT (dialog), "emblems-to-add", - emblems, (GDestroyNotify)destroy_emblem_list); - - return dialog; -} - -static void -remove_widget (GtkWidget *widget, GtkContainer *container) -{ - gtk_container_remove (container, widget); -} - -static void -nautilus_emblem_view_refresh (NautilusEmblemView *emblem_view) -{ - nautilus_emblem_refresh_list (); - - gtk_container_foreach (GTK_CONTAINER (emblem_view->details->emblems_table), - (GtkCallback)remove_widget, - emblem_view->details->emblems_table); - - nautilus_emblem_view_populate (emblem_view); -} - -static void -add_emblems_dialog_response_cb (GtkWidget *dialog, int response, - NautilusEmblemView *emblem_view) -{ - Emblem *emblem; - GSList *emblems; - GSList *l; - - switch (response) { - case GTK_RESPONSE_CANCEL: - gtk_widget_destroy (dialog); - break; - - case GTK_RESPONSE_HELP: - g_message ("Implement me!"); - break; - - case GTK_RESPONSE_OK: - emblems = g_object_get_data (G_OBJECT (dialog), - "emblems-to-add"); - - for (l = emblems; l; l = l->next) { - char *keyword; - - emblem = (Emblem *)l->data; - if (emblem->keyword != NULL) { - /* this one has already been verified */ - continue; - } - - keyword = nautilus_emblem_create_unique_keyword (emblem->name); - if (!nautilus_emblem_verify_keyword - (GTK_WINDOW (dialog), keyword, emblem->name)) { - g_free (keyword); - return; - } else { - emblem->keyword = keyword; - } - - } - - for (l = emblems; l; l = l->next) { - emblem = (Emblem *)l->data; - - nautilus_emblem_install_custom_emblem (emblem->pixbuf, - emblem->keyword, - emblem->name, - GTK_WINDOW (dialog)); - } - - gtk_widget_destroy (dialog); - - nautilus_emblem_view_refresh (emblem_view); - break; - } -} - -static void -show_add_emblems_dialog (NautilusEmblemView *emblem_view, - GSList *emblems) -{ - GtkWidget *dialog; - - g_return_if_fail (emblems != NULL); - - dialog = create_add_emblems_dialog (emblem_view, emblems); - - if (dialog == NULL) { - return; - } - - g_signal_connect (dialog, "response", - G_CALLBACK (add_emblems_dialog_response_cb), - emblem_view); - - gtk_window_present (GTK_WINDOW (dialog)); -} - -static void -nautilus_emblem_view_drag_received_cb (GtkWidget *widget, - GdkDragContext *drag_context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint time, - NautilusEmblemView *emblem_view) -{ - GSList *emblems; - Emblem *emblem; - GdkPixbuf *pixbuf; - char *uri, *error, *uri_utf8; - GList *uris, *l; - gboolean had_failure; - - had_failure = FALSE; - emblems = NULL; - - switch (info) { - case TARGET_URI_LIST: - if (data->format != 8 || - data->length == 0) { - g_message ("URI list had wrong format (%d) or length (%d)\n", - data->format, data->length); - return; - } - - uris = nautilus_icon_dnd_uri_list_extract_uris (data->data); - l = uris; - while (l != NULL) { - uri = eel_make_uri_canonical (l->data); - l = l->next; - - if (uri == NULL) { - had_failure = TRUE; - continue; - } - - pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri); - - if (pixbuf == NULL) { - /* this one apparently isn't an image, or - * at least not one that we know how to read - */ - had_failure = TRUE; - continue; - } - - emblem = g_new (Emblem, 1); - emblem->uri = uri; - emblem->name = NULL; /* created later on by the user */ - emblem->keyword = NULL; - emblem->pixbuf = pixbuf; - - emblems = g_slist_prepend (emblems, emblem); - } - nautilus_icon_dnd_uri_list_free_strings (uris); - - if (had_failure && emblems != NULL) { - eel_show_error_dialog (_("Some of the files could not be added as emblems."), _("The emblems do not appear to be valid images."), _("Couldn't Add Emblems"), NULL); - } else if (had_failure && emblems == NULL) { - eel_show_error_dialog (_("None of the files could be added as emblems."), _("The emblems do not appear to be valid images."), _("Couldn't Add Emblems"), NULL); - - } - - if (emblems != NULL) { - show_add_emblems_dialog (emblem_view, emblems); - } - - break; - - case TARGET_URI: - if (data->format != 8 || - data->length == 0) { - g_warning ("URI had wrong format (%d) or length (%d)\n", - data->format, data->length); - return; - } - - uri = g_strndup (data->data, data->length); - - if (!eel_is_valid_uri (uri)) { - eel_show_error_dialog (_("The emblem cannot be added."), _("The dragged text was not a valid file location."), _("Couldn't Add Emblem"), NULL); - break; - } - - pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri); - - if (pixbuf != NULL) { - emblem = g_new (Emblem, 1); - emblem->uri = uri; - emblem->name = NULL; - emblem->keyword = NULL; - emblem->pixbuf = pixbuf; - - emblems = g_slist_prepend (NULL, emblem); - - show_add_emblems_dialog (emblem_view, emblems); - } else { - uri_utf8 = eel_format_uri_for_display (uri); - - if (uri_utf8) { - error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri_utf8); - g_free (uri_utf8); - } else { - error = g_strdup (_("The dragged file does not appear to be a valid image.")); - } - eel_show_error_dialog (_("The emblem cannot be added."), error, _("Couldn't Add Emblem"), - NULL); - g_free (error); - g_free (uri_utf8); - } - - g_free (uri); - - break; - - case TARGET_NETSCAPE_URL: - if (data->format != 8 || - data->length == 0) { - g_message ("URI had wrong format (%d) or length (%d)\n", - data->format, data->length); - return; - } - - /* apparently, this is a URI/title pair? or just a pair - * of identical URIs? Regardless, this seems to work... - */ - uris = nautilus_icon_dnd_uri_list_extract_uris (data->data); - - if (uris == NULL) { - break; - } - - uri = uris->data; - - if (uri == NULL) { - nautilus_icon_dnd_uri_list_free_strings (uris); - break; - } - - pixbuf = nautilus_emblem_load_pixbuf_for_emblem (uri); - - if (pixbuf != NULL) { - emblem = g_new (Emblem, 1); - emblem->uri = g_strdup (uri); - emblem->name = NULL; - emblem->keyword = NULL; - emblem->pixbuf = pixbuf; - - emblems = g_slist_prepend (NULL, emblem); - - show_add_emblems_dialog (emblem_view, emblems); - } else { - g_warning ("Tried to load '%s', but failed.\n", - uri); - error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri); - eel_show_error_dialog (_("The emblem cannot be added."), error, _("Couldn't Add Emblem"), - NULL); - g_free (error); - } - break; - } -} - -static GtkWidget * -nautilus_emblem_view_create_container (NautilusEmblemView *emblem_view) -{ - GtkWidget *emblems_table, *scroller; - - /* The emblems wrapped table */ - scroller = eel_scrolled_wrap_table_new (TRUE, &emblems_table); - - gtk_container_set_border_width (GTK_CONTAINER (emblems_table), GNOME_PAD); - - /* set up dnd for adding emblems */ - gtk_drag_dest_set (scroller, - GTK_DEST_DEFAULT_ALL, - dest_types, G_N_ELEMENTS (dest_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); - - g_signal_connect (scroller, "drag-data-received", - G_CALLBACK (nautilus_emblem_view_drag_received_cb), - emblem_view); - - gtk_widget_show (scroller); - - emblem_view->details->emblems_table = emblems_table; - - return scroller; -} - -static gint -emblem_widget_sort_func (gconstpointer a, gconstpointer b) -{ - GObject *obj_a, *obj_b; - - obj_a = G_OBJECT (a); - obj_b = G_OBJECT (b); - - return strcmp (g_object_get_data (obj_a, "emblem-display-name"), - g_object_get_data (obj_b, "emblem-display-name")); -} - -static void -nautilus_emblem_view_populate (NautilusEmblemView *emblem_view) -{ - GList *icons, *l, *widgets; - GtkWidget *emblem_widget; - char *name; - char *path; - GdkPixbuf *erase_pixbuf; - - - path = nautilus_pixmap_file ("erase.png"); - erase_pixbuf = gdk_pixbuf_new_from_file (path, NULL); - g_free (path); - - if (erase_pixbuf != NULL) { - emblem_widget = create_emblem_widget_with_pixbuf (emblem_view, - ERASE_EMBLEM_KEYWORD, - _("Erase"), - erase_pixbuf); - gtk_container_add (GTK_CONTAINER - (emblem_view->details->emblems_table), - emblem_widget); - } - - - icons = nautilus_emblem_list_availible (); - - l = icons; - widgets = NULL; - while (l != NULL) { - name = (char *)l->data; - l = l->next; - - if (!nautilus_emblem_should_show_in_list (name)) { - continue; - } - - emblem_widget = create_emblem_widget (emblem_view, name); - - widgets = g_list_prepend (widgets, emblem_widget); - } - eel_g_list_free_deep (icons); - - /* sort the emblems by display name */ - widgets = g_list_sort (widgets, emblem_widget_sort_func); - - l = widgets; - while (l != NULL) { - gtk_container_add - (GTK_CONTAINER (emblem_view->details->emblems_table), - l->data); - l = l->next; - } - g_list_free (widgets); - - gtk_widget_show_all (emblem_view->details->emblems_table); -} - -static void -nautilus_emblem_view_instance_init (NautilusEmblemView *emblem_view) -{ - BonoboControl *control; - GtkWidget *widget; - - emblem_view->details = g_new0 (NautilusEmblemViewDetails, 1); - - emblem_view->details->client = gconf_client_get_default (); - - create_popup_menu (emblem_view); - - widget = nautilus_emblem_view_create_container (emblem_view); - nautilus_emblem_view_populate (emblem_view); - - control = bonobo_control_new (widget); - nautilus_view_construct_from_bonobo_control - (NAUTILUS_VIEW (emblem_view), control); - -} - -static void -nautilus_emblem_view_finalize (GObject *object) -{ - NautilusEmblemView *emblem_view; - - g_return_if_fail (NAUTILUS_IS_EMBLEM_VIEW (object)); - emblem_view = NAUTILUS_EMBLEM_VIEW (object); - - if (emblem_view->details != NULL) { - if (emblem_view->details->client != NULL) { - g_object_unref (emblem_view->details->client); - } - - g_free (emblem_view->details); - } - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_emblem_view_class_init (NautilusEmblemViewClass *object_klass) -{ - GObjectClass *gobject_class; - - NautilusEmblemViewClass *klass; - - klass = NAUTILUS_EMBLEM_VIEW_CLASS (object_klass); - gobject_class = G_OBJECT_CLASS (object_klass); - - gobject_class->finalize = nautilus_emblem_view_finalize; -} - diff --git a/components/emblem/nautilus-emblem-view.h b/components/emblem/nautilus-emblem-view.h deleted file mode 100644 index 9cb9507d6..000000000 --- a/components/emblem/nautilus-emblem-view.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * - * This is the header file for the index panel widget, which displays overview information - * in a vertical panel and hosts the meta-views. - */ - -#ifndef NAUTILUS_EMBLEM_VIEW_H -#define NAUTILUS_EMBLEM_VIEW_H - -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_EMBLEM_VIEW \ - (nautilus_emblem_view_get_type ()) -#define NAUTILUS_EMBLEM_VIEW(obj) \ - (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_EMBLEM_VIEW, NautilusEmblemView)) -#define NAUTILUS_EMBLEM_VIEW_CLASS(klass) \ - (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_EMBLEM_VIEW, NautilusEmblemViewClass)) -#define NAUTILUS_IS_EMBLEM_VIEW(obj) \ - (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_EMBLEM_VIEW)) -#define NAUTILUS_IS_EMBLEM_VIEW_CLASS(klass) \ - (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_EMBLEM_VIEW)) - -typedef struct NautilusEmblemViewDetails NautilusEmblemViewDetails; - -typedef struct { - NautilusView parent_slot; - NautilusEmblemViewDetails *details; -} NautilusEmblemView; - -typedef struct { - NautilusViewClass parent_slot; - -} NautilusEmblemViewClass; - -GType nautilus_emblem_view_get_type (void); - -#endif /* NAUTILUS_EMBLEM_VIEW_H */ diff --git a/components/history/Makefile.am b/components/history/Makefile.am deleted file mode 100644 index 94787112c..000000000 --- a/components/history/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -NULL = - -INCLUDES=\ - -I$(top_srcdir) \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -bonobodir = $(libdir)/bonobo -bonobo_LTLIBRARIES = libnautilus-history-view.la - -libnautilus_history_view_la_SOURCES = \ - libmain.c \ - nautilus-history-view.c \ - nautilus-history-view.h \ - $(NULL) - -libnautilus_history_view_la_LDFLAGS = -module -avoid-version -no-undefined - -libnautilus_history_view_la_LIBADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-private/libnautilus-private.la \ - $(COMPONENT_LIBS) - $(NULL) - -server_in_files = Nautilus_View_history.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST=$(server_in_files) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/history/Nautilus_View_history.server.in.in b/components/history/Nautilus_View_history.server.in.in deleted file mode 100644 index 736c4ab46..000000000 --- a/components/history/Nautilus_View_history.server.in.in +++ /dev/null @@ -1,18 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_History_View" - type="shlib" location="@BONOBODIR@/libnautilus-history-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="description" type="string" _value="History side pane for Nautilus"/> - <oaf_attribute name="name" type="string" _value="History side pane"/> - <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="History"/> - <oaf_attribute name="nautilus:recommended_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> -</oaf_server> - -</oaf_info> diff --git a/components/history/libmain.c b/components/history/libmain.c deleted file mode 100644 index 611ac0c40..000000000 --- a/components/history/libmain.c +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000, 2001 Eazel, Inc - * Copyright (C) 2002 Sean Atkinson - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Sean Atkinson - */ - -/* libmain.c - object activation infrastructure for shared library - version of history view. */ - -#include <config.h> -#include <string.h> -#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, - const char *iid, - gpointer impl_ptr, - CORBA_Environment *ev) -{ - 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; - } - - view = NAUTILUS_HISTORY_VIEW (g_object_new (NAUTILUS_TYPE_HISTORY_VIEW, NULL)); - - bonobo_activation_plugin_use (poa, impl_ptr); - - return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev); -} - -static const BonoboActivationPluginObject history_plugin_list[] = { - { VIEW_IID, history_shlib_make_object }, - { NULL } -}; - -const BonoboActivationPlugin Bonobo_Plugin_info = { - history_plugin_list, - "Nautilus History Sidebar Panel" -}; diff --git a/components/history/nautilus-history-view.c b/components/history/nautilus-history-view.c deleted file mode 100644 index f911de166..000000000 --- a/components/history/nautilus-history-view.c +++ /dev/null @@ -1,311 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ - -#include <config.h> - -#include <bonobo/bonobo-ui-util.h> -#include <eel/eel-debug.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-preferences.h> -#include <gtk/gtkcellrendererpixbuf.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreemodel.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtkscrolledwindow.h> -#include <libgnome/gnome-macros.h> -#include <libnautilus-private/nautilus-bookmark.h> -#include <libnautilus-private/nautilus-global-preferences.h> - -#include "nautilus-history-view.h" - -#define FACTORY_IID "OAFIID:Nautilus_History_View_Factory" - -#define NAUTILUS_HISTORY_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_HISTORY_VIEW, NautilusHistoryViewClass)) -#define NAUTILUS_IS_HISTORY_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_HISTORY_VIEW)) -#define NAUTILUS_IS_HISTORY_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_HISTORY_VIEW)) - -typedef struct { - NautilusViewClass parent; -} NautilusHistoryViewClass; - -enum { - HISTORY_VIEW_COLUMN_ICON, - HISTORY_VIEW_COLUMN_NAME, - HISTORY_VIEW_COLUMN_BOOKMARK, - HISTORY_VIEW_COLUMN_COUNT -}; - -BONOBO_CLASS_BOILERPLATE (NautilusHistoryView, nautilus_history_view, - NautilusView, NAUTILUS_TYPE_VIEW) - -static void -update_history (NautilusHistoryView *view, - const Nautilus_History *history) -{ - GtkListStore *store; - GtkTreeSelection *selection; - NautilusBookmark *bookmark; - Nautilus_HistoryItem *item; - GdkPixbuf *pixbuf; - guint i; - gboolean stop_updating_history; - GtkTreeIter iter; - - /* Set up a local boolean so we can detect that the view has - * been destroyed. We can't ask the view itself because once - * it's destroyed it's pointer is a pointer to freed storage. - */ - /* FIXME: We can't just keep an extra ref to the view as we - * normally would because of a bug in Bonobo that means a - * BonoboControl must not outlast its BonoboControlFrame - * (NautilusHistoryView is a BonoboControl). - */ - if (view->stop_updating_history != NULL) { - *view->stop_updating_history = TRUE; - } - stop_updating_history = FALSE; - view->stop_updating_history = &stop_updating_history; - - store = GTK_LIST_STORE (gtk_tree_view_get_model (view->tree_view)); - - gtk_list_store_clear (store); - - for (i = 0; i < history->_length; i++) { - item = &history->_buffer[i]; - bookmark = nautilus_bookmark_new (item->location, item->title); - - /* Through a long line of calls, nautilus_bookmark_new - * can end up calling through to CORBA, so a remote - * unref can come in at this point. In theory, other - * calls could result in a similar problem, so in - * theory we need this check after any call out, but - * in practice, none of the other calls used here have - * that problem. - */ - if (stop_updating_history) { - return; - } - - pixbuf = nautilus_bookmark_get_pixbuf (bookmark, NAUTILUS_ICON_SIZE_FOR_MENUS, FALSE); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, - HISTORY_VIEW_COLUMN_ICON, pixbuf, - HISTORY_VIEW_COLUMN_NAME, item->title, - HISTORY_VIEW_COLUMN_BOOKMARK, bookmark, - -1); - - if (pixbuf != NULL) { - g_object_unref (pixbuf); - } - } - - selection = GTK_TREE_SELECTION (gtk_tree_view_get_selection (view->tree_view)); - - if (gtk_tree_model_get_iter_root (GTK_TREE_MODEL (store), &iter)) { - gtk_tree_selection_select_iter (selection, &iter); - } - - view->stop_updating_history = NULL; -} - -static void -history_changed_callback (NautilusHistoryView *view, - const Nautilus_History *history, - gpointer callback_data) -{ - g_assert (view == callback_data); - - update_history (view, history); -} - -static void -row_activated_callback (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer user_data) -{ - NautilusHistoryView *view; - GtkTreeModel *model; - GtkTreeIter iter; - NautilusBookmark *bookmark; - char *uri; - - view = NAUTILUS_HISTORY_VIEW (user_data); - model = gtk_tree_view_get_model (tree_view); - - if (!gtk_tree_model_get_iter (model, &iter, path)) { - return; - } - - gtk_tree_model_get - (model, &iter, HISTORY_VIEW_COLUMN_BOOKMARK, &bookmark, -1); - - /* Navigate to the clicked location. */ - uri = nautilus_bookmark_get_uri (NAUTILUS_BOOKMARK (bookmark)); - nautilus_view_open_location - (NAUTILUS_VIEW (view), - uri, Nautilus_ViewFrame_OPEN_ACCORDING_TO_MODE, 0, NULL); - g_free (uri); -} - -static void -update_click_policy (NautilusHistoryView *view) -{ - int policy; - - policy = eel_preferences_get_enum (NAUTILUS_PREFERENCES_CLICK_POLICY); - - eel_gtk_tree_view_set_activate_on_single_click - (view->tree_view, policy == NAUTILUS_CLICK_POLICY_SINGLE); -} - -static void -click_policy_changed_callback (gpointer user_data) -{ - NautilusHistoryView *view; - - view = NAUTILUS_HISTORY_VIEW (user_data); - - update_click_policy (view); -} - -static void -nautilus_history_view_instance_init (NautilusHistoryView *view) -{ - GtkTreeView *tree_view; - GtkTreeViewColumn *col; - GtkCellRenderer *cell; - GtkListStore *store; - GtkTreeSelection *selection; - GtkWidget *window; - - tree_view = GTK_TREE_VIEW (gtk_tree_view_new ()); - gtk_tree_view_set_headers_visible (tree_view, FALSE); - gtk_widget_show (GTK_WIDGET (tree_view)); - - col = GTK_TREE_VIEW_COLUMN (gtk_tree_view_column_new ()); - - cell = gtk_cell_renderer_pixbuf_new (); - gtk_tree_view_column_pack_start (col, cell, FALSE); - gtk_tree_view_column_set_attributes (col, cell, - "pixbuf", HISTORY_VIEW_COLUMN_ICON, - NULL); - - cell = gtk_cell_renderer_text_new (); - gtk_tree_view_column_pack_start (col, cell, TRUE); - gtk_tree_view_column_set_attributes (col, cell, - "text", HISTORY_VIEW_COLUMN_NAME, - NULL); - - gtk_tree_view_column_set_fixed_width (col, NAUTILUS_ICON_SIZE_SMALLER); - gtk_tree_view_append_column (tree_view, col); - - store = gtk_list_store_new (HISTORY_VIEW_COLUMN_COUNT, - GDK_TYPE_PIXBUF, - G_TYPE_STRING, - NAUTILUS_TYPE_BOOKMARK); - - gtk_tree_view_set_model (tree_view, GTK_TREE_MODEL (store)); - - window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (tree_view)); - gtk_widget_show (window); - - nautilus_view_construct (NAUTILUS_VIEW (view), window); - - g_object_ref (tree_view); - view->tree_view = tree_view; - - nautilus_view_set_listener_mask (NAUTILUS_VIEW (view), - NAUTILUS_VIEW_LISTEN_HISTORY); - - selection = gtk_tree_view_get_selection (tree_view); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - - g_signal_connect_object - (tree_view, "row_activated", - G_CALLBACK (row_activated_callback), view, 0); - - g_signal_connect_object (view, "history_changed", - G_CALLBACK (history_changed_callback), view, 0); - - eel_preferences_add_callback (NAUTILUS_PREFERENCES_CLICK_POLICY, - click_policy_changed_callback, - view); - update_click_policy (view); -} - -static void -nautilus_history_view_finalize (GObject *object) -{ - NautilusHistoryView *view; - - view = NAUTILUS_HISTORY_VIEW (object); - - eel_preferences_remove_callback (NAUTILUS_PREFERENCES_CLICK_POLICY, - click_policy_changed_callback, - view); - - if (view->stop_updating_history != NULL) { - *view->stop_updating_history = TRUE; - } - - g_object_unref (view->tree_view); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_history_view_class_init (NautilusHistoryViewClass *class) -{ - G_OBJECT_CLASS (class)->finalize = nautilus_history_view_finalize; -} - -int -main (int argc, char *argv[]) -{ - if (g_getenv ("NAUTILUS_DEBUG") != NULL) { - eel_make_warnings_and_criticals_stop_in_debugger (); - } - - return nautilus_view_standard_main ("nautilus_history-view", - VERSION, - GETTEXT_PACKAGE, - GNOMELOCALEDIR, - argc, - argv, - FACTORY_IID, - VIEW_IID, - nautilus_view_create_from_get_type_function, - NULL, - nautilus_history_view_get_type); -} diff --git a/components/history/nautilus-history-view.h b/components/history/nautilus-history-view.h deleted file mode 100644 index 685665e83..000000000 --- a/components/history/nautilus-history-view.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 1999, 2000 Red Hat, Inc. - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Elliot Lee <sopwith@redhat.com> - * Darin Adler <darin@bentspoon.com> - * - */ -#ifndef _NAUTILUS_HISTORY_VIEW_H -#define _NAUTILUS_HISTORY_VIEW_H - -#include <gtk/gtktreeview.h> -#include <libnautilus/nautilus-view.h> -#include <libnautilus/nautilus-view-standard-main.h> - -#define VIEW_IID "OAFIID:Nautilus_History_View" - -#define NAUTILUS_TYPE_HISTORY_VIEW (nautilus_history_view_get_type ()) -#define NAUTILUS_HISTORY_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_HISTORY_VIEW, NautilusHistoryView)) - -typedef struct { - NautilusView parent; - GtkTreeView *tree_view; - gboolean *stop_updating_history; -} NautilusHistoryView; - -GType nautilus_history_view_get_type (void); - -#endif diff --git a/components/image_properties/Makefile.am b/components/image_properties/Makefile.am deleted file mode 100644 index 6dde6a3b3..000000000 --- a/components/image_properties/Makefile.am +++ /dev/null @@ -1,38 +0,0 @@ -# WHAT YOU NEED TO CHANGE: Change all the filenames to refer to your -# component. Also add whatever libraries, include paths, etc you want, -# and change the G_LOG_DOMAIN. - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Image-Properties\" \ - -DDATADIR=\"$(datadir)\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(COMPONENT_CFLAGS) \ - $(EXIF_CFLAGS) - -bonobodir = $(libdir)/bonobo -bonobo_LTLIBRARIES = libnautilus-image-properties-view.la - -libnautilus_image_properties_view_la_SOURCES = \ - nautilus-image-properties-view.h \ - nautilus-image-properties-view.c \ - libmain.c - -libnautilus_image_properties_view_la_LIBADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(COMPONENT_LIBS) \ - $(EXIF_LIBS) - -libnautilus_image_properties_view_la_LDFLAGS = -module -avoid-version -no-undefined - -server_in_files = Nautilus_View_image_properties.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = $(server_in_files) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/image_properties/Nautilus_View_image_properties.server.in.in b/components/image_properties/Nautilus_View_image_properties.server.in.in deleted file mode 100644 index 5a6052527..000000000 --- a/components/image_properties/Nautilus_View_image_properties.server.in.in +++ /dev/null @@ -1,29 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Image_Properties_View" - type="shlib" location="@BONOBODIR@/libnautilus-image-properties-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Image Properties view"/> - <oaf_attribute name="description" type="string" _value="Image Properties content view component"/> - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="image/x-bmp"/> - <item value="image/x-ico"/> - <item value="image/jpeg"/> - <item value="image/gif"/> - <item value="image/png"/> - <item value="image/pnm"/> - <item value="image/ras"/> - <item value="image/tga"/> - <item value="image/tiff"/> - <item value="image/wbmp"/> - <item value="image/x-xbitmap"/> - <item value="image/x-xpixmap"/> - </oaf_attribute> - <oaf_attribute name="nautilus:property_page_name" type="string" _value="Image"/> - <oaf_attribute name="nautilus:can_handle_multiple_files" type="boolean" value="false"/> -</oaf_server> - -</oaf_info> diff --git a/components/image_properties/libmain.c b/components/image_properties/libmain.c deleted file mode 100644 index 9d2135380..000000000 --- a/components/image_properties/libmain.c +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000, 2001 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak - */ - -/* libmain.c - object activation infrastructure for shared library - version of tree view. */ - -#include <config.h> -#include <string.h> -#include "nautilus-image-properties-view.h" -#include <bonobo.h> -#include <bonobo-activation/bonobo-activation.h> - -#define VIEW_IID "OAFIID:Nautilus_Image_Properties_View" - - -static CORBA_Object -image_shlib_make_object (PortableServer_POA poa, - const char *iid, - gpointer impl_ptr, - CORBA_Environment *ev) -{ - NautilusImagePropertiesView *view; - - if (strcmp (iid, VIEW_IID) != 0) { - return CORBA_OBJECT_NIL; - } - - view = NAUTILUS_IMAGE_PROPERTIES_VIEW (g_object_new (NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW, NULL)); - - bonobo_activation_plugin_use (poa, impl_ptr); - - return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev); -} - -static const BonoboActivationPluginObject image_plugin_list[] = { - { VIEW_IID, image_shlib_make_object }, - { NULL } -}; - -const BonoboActivationPlugin Bonobo_Plugin_info = { - image_plugin_list, - "Nautilus Image Properties Page" -}; diff --git a/components/image_properties/nautilus-image-properties-view.c b/components/image_properties/nautilus-image-properties-view.c deleted file mode 100644 index b2405da0a..000000000 --- a/components/image_properties/nautilus-image-properties-view.c +++ /dev/null @@ -1,447 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2002 James Willcox - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: James Willcox <jwillcox@gnome.org> - */ - -#include <config.h> -#include "nautilus-image-properties-view.h" - -#include <gtk/gtkvbox.h> -#include <gtk/gtklabel.h> -#include <libgnome/gnome-macros.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomevfs/gnome-vfs-async-ops.h> -#include <eel/eel-gnome-extensions.h> -#include <string.h> - -#ifdef HAVE_EXIF - #include <libexif/exif-data.h> - #include <libexif/exif-ifd.h> - #include <libexif/exif-loader.h> - #include <gtk/gtkliststore.h> - #include <gtk/gtktreestore.h> - #include <gtk/gtktreeview.h> - #include <gtk/gtkscrolledwindow.h> - #include <gtk/gtkcellrenderertext.h> - #include <eel/eel-vfs-extensions.h> -#endif - -#define LOAD_BUFFER_SIZE 8192 - -struct NautilusImagePropertiesViewDetails { - char *location; - GtkWidget *vbox; - GtkWidget *resolution; - GnomeVFSAsyncHandle *vfs_handle; - GdkPixbufLoader *loader; - gboolean got_size; - gboolean pixbuf_still_loading; - char buffer[LOAD_BUFFER_SIZE]; - int width; - int height; -#ifdef HAVE_EXIF - ExifLoader *exifldr; -#endif /*HAVE_EXIF*/ -}; - -#ifdef HAVE_EXIF -struct ExifAttribute { - ExifTag tag; - char *value; - gboolean found; -}; -#endif /*HAVE_EXIF*/ - -enum { - PROP_URI -}; - -static GObjectClass *parent_class = NULL; - -static void -nautilus_image_properties_view_finalize (GObject *object) -{ - NautilusImagePropertiesView *view; - - view = NAUTILUS_IMAGE_PROPERTIES_VIEW (object); - - if (view->details->vfs_handle != NULL) { - gnome_vfs_async_cancel (view->details->vfs_handle); - } - - view->details->vfs_handle = NULL; - g_free (view->details->location); - - g_free (view->details); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -file_closed_callback (GnomeVFSAsyncHandle *handle, - GnomeVFSResult result, - gpointer callback_data) -{ -} - -#ifdef HAVE_EXIF -static char * -exif_string_to_utf8 (const char *exif_str) -{ - char *utf8_str; - - if (g_utf8_validate (exif_str, -1, NULL)) { - return g_strdup (exif_str); - } - - utf8_str = g_locale_to_utf8 (exif_str, -1, NULL, NULL, NULL); - if (utf8_str != NULL) { - return utf8_str; - } - - return eel_make_valid_utf8 (exif_str); -} - -static void -exif_content_callback (ExifContent *content, gpointer data) -{ - struct ExifAttribute *attribute; - - attribute = (struct ExifAttribute *)data; - if (attribute->found) { - return; - } - - attribute->value = g_strdup (exif_content_get_value (content, attribute->tag)); - if (attribute->value != NULL) { - attribute->found = TRUE; - } -} - -static char * -exifdata_get_tag_name_utf8 (ExifTag tag) -{ - return exif_string_to_utf8 (exif_tag_get_name (tag)); -} - -static char * -exifdata_get_tag_value_utf8 (ExifData *data, ExifTag tag) -{ - struct ExifAttribute attribute; - char *utf8_value; - - attribute.tag = tag; - attribute.value = NULL; - attribute.found = FALSE; - - exif_data_foreach_content (data, exif_content_callback, &attribute); - - if (attribute.found) { - utf8_value = exif_string_to_utf8 (attribute.value); - g_free (attribute.value); - } else { - utf8_value = NULL; - } - - return utf8_value; -} - -static void -append_tag_value_pair (GString *string, ExifData *data, ExifTag tag, gchar *description) -{ - char *utf_attribute; - char *utf_value; - - utf_attribute = exifdata_get_tag_name_utf8 (tag); - utf_value = exifdata_get_tag_value_utf8 (data, tag); - - if ((utf_attribute == NULL) || (utf_value == NULL)) { - g_free (utf_attribute); - g_free (utf_value); - return; - } - - g_string_append_printf (string, "<b>%s:</b> %s\n", (description != NULL) ? description : utf_attribute, utf_value); - - g_free (utf_attribute); - g_free (utf_value); -} - -static void -append_exifdata_string (ExifData *exifdata, GString *string) -{ - if (exifdata->ifd[0] && exifdata->ifd[0]->count) { - append_tag_value_pair (string, exifdata, EXIF_TAG_MAKE, _("Camera Brand")); - append_tag_value_pair (string, exifdata, EXIF_TAG_MODEL, _("Camera Model")); - append_tag_value_pair (string, exifdata, EXIF_TAG_DATE_TIME, _("Date Taken")); - append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_TIME, _("Exposure Time")); - append_tag_value_pair (string, exifdata, EXIF_TAG_EXPOSURE_PROGRAM, _("Exposure Program")); - append_tag_value_pair (string, exifdata, EXIF_TAG_APERTURE_VALUE, _("Aperture Value")); - append_tag_value_pair (string, exifdata, EXIF_TAG_METERING_MODE, _("Metering Mode")); - append_tag_value_pair (string, exifdata, EXIF_TAG_FLASH,_("Flash Fired")); - append_tag_value_pair (string, exifdata, EXIF_TAG_FOCAL_LENGTH,_("Focal Length")); - append_tag_value_pair (string, exifdata, EXIF_TAG_SHUTTER_SPEED_VALUE, _("Shutter Speed")); - append_tag_value_pair (string, exifdata, EXIF_TAG_ISO_SPEED_RATINGS, _("ISO Speed Rating")); - append_tag_value_pair (string, exifdata, EXIF_TAG_SOFTWARE, _("Software")); - - } -} -#endif /*HAVE_EXIF*/ - -static void -load_finished (NautilusImagePropertiesView *view) -{ - GdkPixbufFormat *format; - char *name, *desc; - GString *str; - - if (view->details->got_size) { - str = g_string_new (NULL); - format = gdk_pixbuf_loader_get_format (view->details->loader); - - name = gdk_pixbuf_format_get_name (format); - desc = gdk_pixbuf_format_get_description (format); - g_string_append_printf (str, ngettext ("<b>Image Type:</b> %s (%s)\n<b>Resolution:</b> %dx%d pixels\n", - "<b>Image Type:</b> %s (%s)\n<b>Resolution:</b> %dx%d pixels\n", - view->details->height), - name, desc, view->details->width, view->details->height); - g_free (name); - g_free (desc); - -#ifdef HAVE_EXIF - append_exifdata_string (exif_loader_get_data (view->details->exifldr), str); -#endif /*HAVE_EXIF*/ - - gtk_label_set_markup (GTK_LABEL (view->details->resolution), str->str); - gtk_label_set_selectable (GTK_LABEL (view->details->resolution), TRUE); - g_string_free (str, TRUE); - } else { - gtk_label_set_text (GTK_LABEL (view->details->resolution), _("Failed to load image information")); - } - - if (view->details->loader != NULL) { - gdk_pixbuf_loader_close (view->details->loader, NULL); - g_object_unref (view->details->loader); - view->details->loader = NULL; - } -#ifdef HAVE_EXIF - if (view->details->exifldr != NULL) { - exif_loader_unref (view->details->exifldr); - view->details->exifldr = NULL; - } -#endif /*HAVE_EXIF*/ - - if (view->details->vfs_handle != NULL) { - gnome_vfs_async_close (view->details->vfs_handle, file_closed_callback, NULL); - view->details->vfs_handle = NULL; - } -} - -static void -file_read_callback (GnomeVFSAsyncHandle *vfs_handle, - GnomeVFSResult result, - gpointer buffer, - GnomeVFSFileSize bytes_requested, - GnomeVFSFileSize bytes_read, - gpointer callback_data) -{ - NautilusImagePropertiesView *view; -#ifdef HAVE_EXIF - int exif_still_loading; -#endif - - view = NAUTILUS_IMAGE_PROPERTIES_VIEW (callback_data); - - if (result == GNOME_VFS_OK && bytes_read != 0) { -#ifdef HAVE_EXIF - exif_still_loading = exif_loader_write (view->details->exifldr, - buffer, - bytes_read); -#endif - if (view->details->pixbuf_still_loading) { - if (!gdk_pixbuf_loader_write (view->details->loader, - buffer, - bytes_read, - NULL)) { - view->details->pixbuf_still_loading = FALSE; - } - } - if (view->details->pixbuf_still_loading -#ifdef HAVE_EXIF - && (exif_still_loading == 1) -#endif - ) { - gnome_vfs_async_read (view->details->vfs_handle, - view->details->buffer, - sizeof (view->details->buffer), - file_read_callback, - view); - return; - } - } - load_finished (view); -} - -static void -size_prepared_callback (GdkPixbufLoader *loader, - int width, - int height, - gpointer callback_data) -{ - NautilusImagePropertiesView *view; - - view = NAUTILUS_IMAGE_PROPERTIES_VIEW (callback_data); - - view->details->height = height; - view->details->width = width; - view->details->got_size = TRUE; - view->details->pixbuf_still_loading = FALSE; -} - -static void -file_opened_callback (GnomeVFSAsyncHandle *vfs_handle, - GnomeVFSResult result, - gpointer callback_data) -{ - NautilusImagePropertiesView *view; - - view = NAUTILUS_IMAGE_PROPERTIES_VIEW (callback_data); - - if (result != GNOME_VFS_OK) { - view->details->vfs_handle = NULL; - return; - } - - view->details->loader = gdk_pixbuf_loader_new (); - view->details->pixbuf_still_loading = TRUE; - view->details->width = 0; - view->details->height = 0; -#ifdef HAVE_EXIF - view->details->exifldr = exif_loader_new (); -#endif /*HAVE_EXIF*/ - - g_signal_connect (view->details->loader, "size_prepared", - G_CALLBACK (size_prepared_callback), view); - - gnome_vfs_async_read (vfs_handle, - view->details->buffer, - sizeof (view->details->buffer), - file_read_callback, - view); -} - - -static void -load_location (NautilusImagePropertiesView *view, - const char *location) -{ - g_assert (NAUTILUS_IS_IMAGE_PROPERTIES_VIEW (view)); - g_assert (location != NULL); - - if (view->details->vfs_handle != NULL) - gnome_vfs_async_cancel (view->details->vfs_handle); - - gnome_vfs_async_open (&view->details->vfs_handle, - location, - GNOME_VFS_OPEN_READ, - -2, - file_opened_callback, - view); -} - -static void -get_property (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusImagePropertiesView *view = user_data; - - if (arg_id == PROP_URI) { - CORBA_sequence_CORBA_string *uris; - - uris = CORBA_sequence_CORBA_string__alloc (); - uris->_maximum = uris->_length = 1; - uris->_buffer = CORBA_sequence_CORBA_string_allocbuf (uris->_length); - uris->_buffer[0] = CORBA_string_dup (view->details->location); - arg->_type = TC_CORBA_sequence_CORBA_string; - arg->_value = uris; - } -} - -static void -set_property (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusImagePropertiesView *view = user_data; - - if (arg_id == PROP_URI) { - CORBA_sequence_CORBA_string *uris; - - uris = arg->_value; - view->details->location = g_strdup (uris->_buffer[0]); - load_location (view, view->details->location); - } -} - -static void -nautilus_image_properties_view_class_init (NautilusImagePropertiesViewClass *class) -{ - parent_class = g_type_class_peek_parent (class); - - G_OBJECT_CLASS (class)->finalize = nautilus_image_properties_view_finalize; -} - -static void -nautilus_image_properties_view_init (NautilusImagePropertiesView *view) -{ - BonoboPropertyBag *pb; - - view->details = g_new0 (NautilusImagePropertiesViewDetails, 1); - - view->details->vbox = gtk_vbox_new (FALSE, 2); - view->details->resolution = gtk_label_new (_("loading...")); - gtk_misc_set_alignment (GTK_MISC (view->details->resolution), - 0, - 0); - - gtk_box_pack_start (GTK_BOX (view->details->vbox), - view->details->resolution, - FALSE, TRUE, 2); - - gtk_widget_show_all (view->details->vbox); - - bonobo_control_construct (BONOBO_CONTROL (view), view->details->vbox); - - pb = bonobo_property_bag_new (get_property, set_property, - view); - bonobo_property_bag_add (pb, "uris", 0, TC_CORBA_sequence_CORBA_string, - NULL, _("URI currently displayed"), 0); - bonobo_control_set_properties (BONOBO_CONTROL (view), - BONOBO_OBJREF (pb), NULL); - bonobo_object_release_unref (BONOBO_OBJREF (pb), NULL); -} - -BONOBO_TYPE_FUNC (NautilusImagePropertiesView, BONOBO_TYPE_CONTROL, nautilus_image_properties_view); diff --git a/components/image_properties/nautilus-image-properties-view.h b/components/image_properties/nautilus-image-properties-view.h deleted file mode 100644 index 4844c537c..000000000 --- a/components/image_properties/nautilus-image-properties-view.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -#ifndef NAUTILUS_IMAGE_PROPERTIES_VIEW_H -#define NAUTILUS_IMAGE_PROPERTIES_VIEW_H - -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW (nautilus_image_properties_view_get_type ()) -#define NAUTILUS_IMAGE_PROPERTIES_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW, NautilusImagePropertiesView)) -#define NAUTILUS_IMAGE_PROPERTIES_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW, NautilusImagePropertiesViewClass)) -#define NAUTILUS_IS_IMAGE_PROPERTIES_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW)) -#define NAUTILUS_IS_IMAGE_PROPERTIES_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_IMAGE_PROPERTIES_VIEW)) - -typedef struct NautilusImagePropertiesViewDetails NautilusImagePropertiesViewDetails; - -typedef struct { - BonoboControl parent; - NautilusImagePropertiesViewDetails *details; -} NautilusImagePropertiesView; - -typedef struct { - BonoboControlClass parent; -} NautilusImagePropertiesViewClass; - -GType nautilus_image_properties_view_get_type (void); - -#endif /* NAUTILUS_IMAGE_PROPERTIES_VIEW_H */ diff --git a/components/loser/Makefile.am b/components/loser/Makefile.am deleted file mode 100644 index a87c44130..000000000 --- a/components/loser/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -NULL= - -SUBDIRS =\ - content sidebar\ - $(NULL) - -EXTRA_DIST=\ - README \ - $(NULL) - diff --git a/components/loser/README b/components/loser/README deleted file mode 100644 index 1cb3ab86f..000000000 --- a/components/loser/README +++ /dev/null @@ -1,30 +0,0 @@ - -To make the content and sidebar "loser" components fail, you must set -some environment variables. - -To pick where the component will fail, set either -NAUTILUS_CONTENT_LOSER_PLACE or NAUTILUS_SIDEBAR_LOSER_PLACE to one of -the following values: - -pre-init -post-init -post-factory-init -pre-make-object -post-make-object -pre-underway -pre-load -pre-done -post-done -pre-merge -post-merge - - -Also set either NAUTILUS_CONTENT_LOSER_MODE or -NAUTILUS_SIDEBAR_LOSER_MODE to one of: - -crash -hang -exit -error-exit - - diff --git a/components/loser/content/Makefile.am b/components/loser/content/Makefile.am deleted file mode 100644 index 13070be69..000000000 --- a/components/loser/content/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -include $(top_srcdir)/Makefile.shared - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Test\" \ - -DDATADIR=\"$(datadir)\" \ - -DICON_DIR=\"$(datadir)/pixmaps/nautilus\" \ - -I$(top_srcdir) \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = nautilus-content-loser-ui.xml - -libexec_PROGRAMS=nautilus-content-loser - -nautilus_content_loser_SOURCES = \ - nautilus-content-loser.h \ - nautilus-content-loser.c \ - main.c - -nautilus_content_loser_LDADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -server_in_files = Nautilus_View_content-loser.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST=$(server_in_files) $(ui_DATA) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/loser/content/Nautilus_View_content-loser.server.in.in b/components/loser/content/Nautilus_View_content-loser.server.in.in deleted file mode 100644 index 9e1a03391..000000000 --- a/components/loser/content/Nautilus_View_content-loser.server.in.in +++ /dev/null @@ -1,32 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Content_Loser_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-content-loser"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus content loser factory"/> - <oaf_attribute name="description" type="string" _value="Nautilus content loser component's factory"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Content_Loser" type="factory" location="OAFIID:Nautilus_Content_Loser_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Content Loser"/> - <oaf_attribute name="description" type="string" _value="Nautilus content view that fails on command"/> - <oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="nautilus:view_as_name" type="string" _value="Content Loser"/> - <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Content Loser"/> - <oaf_attribute name="nautilus:viewer_label" type="string" _value="Content Loser Viewer"/> - <oaf_attribute name="test_only" type="boolean" value="true"/> -</oaf_server> - -</oaf_info> diff --git a/components/loser/content/main.c b/components/loser/content/main.c deleted file mode 100644 index 29c9b5bc4..000000000 --- a/components/loser/content/main.c +++ /dev/null @@ -1,100 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak - */ - -/* main.c - main function and object activation function for loser - content view component that fails on command. */ - -#include <config.h> - -#include "nautilus-content-loser.h" - -#include <gnome.h> -#include <bonobo-activation/bonobo-activation.h> -#include <bonobo.h> -#include <eel/eel-gnome-extensions.h> - -static int object_count = 0; - -static void -loser_object_destroyed(GtkObject *obj) -{ - object_count--; - if (object_count <= 0) { - gtk_main_quit (); - } -} - -static BonoboObject * -loser_make_object (BonoboGenericFactory *factory, - const char *iid, - void *closure) -{ - NautilusContentLoser *view; - NautilusView *nautilus_view; - - nautilus_content_loser_maybe_fail ("pre-make-object"); - - if (strcmp (iid, "OAFIID:Nautilus_Content_Loser")) { - return NULL; - } - - view = NAUTILUS_CONTENT_LOSER (g_object_new (NAUTILUS_TYPE_CONTENT_LOSER, NULL)); - - object_count++; - - nautilus_view = nautilus_content_loser_get_nautilus_view (view); - - g_signal_connect (nautilus_view, "destroy", G_CALLBACK (loser_object_destroyed), NULL); - - nautilus_content_loser_maybe_fail ("post-make-object"); - - return BONOBO_OBJECT (nautilus_view); -} - -int main(int argc, char *argv[]) -{ - BonoboGenericFactory *factory; - char *registration_id; - - nautilus_content_loser_maybe_fail ("pre-init"); - - bonobo_ui_init ("nautilus-content-loser", VERSION, &argc, argv); - - nautilus_content_loser_maybe_fail ("post-init"); - - registration_id = eel_bonobo_make_registration_id - ("OAFIID:Nautilus_Content_Loser_Factory"); - factory = bonobo_generic_factory_new (registration_id, - loser_make_object, - NULL); - g_free (registration_id); - - nautilus_content_loser_maybe_fail ("post-factory-init"); - - if (factory != NULL) { - do { - bonobo_main (); - } while (object_count > 0); - } - - return 0; -} diff --git a/components/loser/content/nautilus-content-loser-ui.xml b/components/loser/content/nautilus-content-loser-ui.xml deleted file mode 100644 index 6c1bf9fab..000000000 --- a/components/loser/content/nautilus-content-loser-ui.xml +++ /dev/null @@ -1,21 +0,0 @@ -<Root> -<menu> - <submenu name="File" _label="_File"> - <placeholder name="File Items Placeholder"> - <menuitem name="Kill Content Loser" - _label="_Kill Content Loser" - _tip="Kill the Loser content view" - verb="Kill Content Loser"/> - </placeholder> - </submenu> -</menu> -<dockitem name="Toolbar"> - <placeholder name="Extra Buttons Placeholder"> - <toolitem name="Kill Content Loser" - _label="Kill Content Loser" - _tip="Kill the Loser content view" - pixtype="stock" pixname="gtk-cut" - verb="Kill Content Loser"/> - </placeholder> -</dockitem> -</Root>
\ No newline at end of file diff --git a/components/loser/content/nautilus-content-loser.c b/components/loser/content/nautilus-content-loser.c deleted file mode 100644 index 59b3b7cb1..000000000 --- a/components/loser/content/nautilus-content-loser.c +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-content-loser.c - loser content view component. This - component fails on demand, either controlled by env variables - during startup, or using toolbar buttons or menu items. */ - -#include <config.h> -#include "nautilus-content-loser.h" - -#include <bonobo/bonobo-control.h> -#include <eel/eel-gtk-macros.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-stock-icons.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <stdio.h> -#include <stdlib.h> - -struct NautilusContentLoserDetails { - char *uri; - NautilusView *nautilus_view; -}; - -static void nautilus_content_loser_class_init (NautilusContentLoserClass *klass); -static void nautilus_content_loser_init (NautilusContentLoser *view); -static void nautilus_content_loser_destroy (GtkObject *object); - -EEL_CLASS_BOILERPLATE (NautilusContentLoser, nautilus_content_loser, GTK_TYPE_LABEL) - -static void loser_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusContentLoser *view); -static void loser_merge_bonobo_items_callback (BonoboObject *control, - gboolean state, - gpointer user_data); -static void nautilus_content_loser_fail (void); -static void ensure_fail_env (void); - -static void -nautilus_content_loser_class_init (NautilusContentLoserClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_content_loser_destroy; -} - -static void -nautilus_content_loser_init (NautilusContentLoser *view) -{ - view->details = g_new0 (NautilusContentLoserDetails, 1); - - gtk_label_set_text (GTK_LABEL (view), g_strdup ("(none)")); - - view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view)); - - g_signal_connect_object (view->details->nautilus_view, "load_location", - G_CALLBACK (loser_load_location_callback), view, 0); - - /* Get notified when our bonobo control is activated so we - * can merge menu & toolbar items into Nautilus's UI. - */ - g_signal_connect_object (nautilus_view_get_bonobo_control (view->details->nautilus_view), - "activate", - G_CALLBACK (loser_merge_bonobo_items_callback), view, 0); - - gtk_widget_show (GTK_WIDGET (view)); -} - -static void -nautilus_content_loser_destroy (GtkObject *object) -{ - NautilusContentLoser *view; - - view = NAUTILUS_CONTENT_LOSER (object); - - g_free (view->details->uri); - g_free (view->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -/** - * nautilus_content_loser_get_nautilus_view: - * - * Return the NautilusView object associated with this view; this - * is needed to export the view via CORBA/Bonobo. - * @view: NautilusContentLoser to get the nautilus_view from.. - * - **/ -NautilusView * -nautilus_content_loser_get_nautilus_view (NautilusContentLoser *view) -{ - return view->details->nautilus_view; -} - -/** - * nautilus_content_loser_load_uri: - * - * Load the resource pointed to by the specified URI. - * @view: NautilusContentLoser to get the nautilus_view from. - * - **/ -void -nautilus_content_loser_load_uri (NautilusContentLoser *view, - const char *uri) -{ - char *label_text; - - g_free (view->details->uri); - view->details->uri = g_strdup (uri); - - label_text = g_strdup_printf (_("%s\n\nThis is a Nautilus content view that fails on demand."), uri); - gtk_label_set_text (GTK_LABEL (view), label_text); - g_free (label_text); -} - -static void -loser_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusContentLoser *view) -{ - g_assert (nautilus_view == view->details->nautilus_view); - - nautilus_content_loser_maybe_fail ("pre-underway"); - - /* It's mandatory to call report_load_underway once the - * component starts loading, otherwise nautilus will assume it - * failed. In a real component, this will probably happen in - * some sort of callback from whatever loading mechanism it is - * using to load the data; this component loads no data, so it - * gives the progress update here. - */ - nautilus_view_report_load_underway (nautilus_view); - - nautilus_content_loser_maybe_fail ("pre-load"); - - /* Do the actual load. */ - nautilus_content_loser_load_uri (view, location); - - nautilus_content_loser_maybe_fail ("pre-done"); - - /* It's mandatory to call report_load_complete once the - * component is done loading successfully, or - * report_load_failed if it completes unsuccessfully. In a - * real component, this will probably happen in some sort of - * callback from whatever loading mechanism it is using to - * load the data; this component loads no data, so it gives - * the progrss upodate here. - */ - nautilus_view_report_load_complete (nautilus_view); - - nautilus_content_loser_maybe_fail ("post-done"); -} - -static void -bonobo_loser_callback (BonoboUIComponent *ui, gpointer user_data, const char *verb) -{ - g_assert (NAUTILUS_IS_CONTENT_LOSER (user_data)); - - nautilus_content_loser_fail (); - gtk_label_set_text (GTK_LABEL (user_data), _("You have tried to kill the Content Loser")); -} - -static void -loser_merge_bonobo_items_callback (BonoboObject *control, gboolean state, gpointer user_data) -{ - NautilusContentLoser *view; - BonoboUIComponent *ui_component; - BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("Kill Content Loser", bonobo_loser_callback), - BONOBO_UI_VERB_END - }; - - nautilus_content_loser_maybe_fail ("pre-merge"); - - g_assert (NAUTILUS_IS_CONTENT_LOSER (user_data)); - - view = NAUTILUS_CONTENT_LOSER (user_data); - - if (state) { - ui_component = nautilus_view_set_up_ui (view->details->nautilus_view, - DATADIR, - "nautilus-content-loser-ui.xml", - "nautilus-content-loser"); - - bonobo_ui_component_add_verb_list_with_data (ui_component, verbs, view); - } else { - /* Do nothing. */ - } - - nautilus_content_loser_maybe_fail ("post-merge"); - - - /* - * Note that we do nothing if state is FALSE. Nautilus content views are activated - * when installed, but never explicitly deactivated. When the view changes to another, - * the content view object is destroyed, which ends up calling bonobo_ui_handler_unset_container, - * which removes its merged menu & toolbar items. - */ -} - -static const char *failure_mode = NULL; -static const char *failure_point = NULL; -static gboolean env_checked = FALSE; - -void -nautilus_content_loser_maybe_fail (const char *location) -{ - ensure_fail_env (); - - if (g_ascii_strcasecmp (location, failure_point) == 0) { - nautilus_content_loser_fail (); - } -} - - - -static void -nautilus_content_loser_fail (void) -{ - ensure_fail_env (); - - if (g_ascii_strcasecmp (failure_mode, "hang") == 0) { - while (1) { - } - } else if (g_ascii_strcasecmp (failure_mode, "exit") == 0) { - exit (0); - } else if (g_ascii_strcasecmp (failure_mode, "error-exit") == 0) { - exit (-1); - } else if (g_ascii_strcasecmp (failure_mode, "crash") == 0) { - abort (); - } else { - puts ("XXX - would fail now, if NAUTILUS_CONTENT_LOSER_MODE were set properly."); - } -} - - -static void -ensure_fail_env (void) -{ - if (!env_checked) { - failure_mode = g_getenv ("NAUTILUS_CONTENT_LOSER_MODE"); - if (failure_mode == NULL) { - failure_mode = ""; - } - - failure_point = g_getenv ("NAUTILUS_CONTENT_LOSER_PLACE"); - if (failure_point == NULL) { - failure_point = ""; - } - - env_checked = TRUE; - } -} diff --git a/components/loser/content/nautilus-content-loser.h b/components/loser/content/nautilus-content-loser.h deleted file mode 100644 index bb2215508..000000000 --- a/components/loser/content/nautilus-content-loser.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-content-loser.h - Nautilus content view component that - fails on command. See the README in the `loser' directory to see - how to control the type of failure. */ - -#ifndef NAUTILUS_CONTENT_LOSER_H -#define NAUTILUS_CONTENT_LOSER_H - -#include <libnautilus/nautilus-view.h> -#include <gtk/gtklabel.h> - -typedef struct NautilusContentLoser NautilusContentLoser; -typedef struct NautilusContentLoserClass NautilusContentLoserClass; - -#define NAUTILUS_TYPE_CONTENT_LOSER (nautilus_content_loser_get_type ()) -#define NAUTILUS_CONTENT_LOSER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_CONTENT_LOSER, NautilusContentLoser)) -#define NAUTILUS_CONTENT_LOSER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CONTENT_LOSER, NautilusContentLoserClass)) -#define NAUTILUS_IS_CONTENT_LOSER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_CONTENT_LOSER)) -#define NAUTILUS_IS_CONTENT_LOSER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CONTENT_LOSER)) - -typedef struct NautilusContentLoserDetails NautilusContentLoserDetails; - -struct NautilusContentLoser { - GtkLabel parent; - NautilusContentLoserDetails *details; -}; - -struct NautilusContentLoserClass { - GtkLabelClass parent_class; -}; - -/* GObject support */ -GType nautilus_content_loser_get_type (void); - -/* Component embedding support */ -NautilusView *nautilus_content_loser_get_nautilus_view (NautilusContentLoser *view); - -/* URI handling */ -void nautilus_content_loser_load_uri (NautilusContentLoser *view, - const char *uri); - -/* Failing on command. */ -void nautilus_content_loser_maybe_fail (const char *location); - -#endif /* NAUTILUS_CONTENT_LOSER_H */ - diff --git a/components/loser/sidebar/Makefile.am b/components/loser/sidebar/Makefile.am deleted file mode 100644 index c22d9f9e8..000000000 --- a/components/loser/sidebar/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -include $(top_srcdir)/Makefile.shared - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Test\" \ - -DDATADIR=\"$(datadir)\" \ - -DICON_DIR=\"$(datadir)/pixmaps/nautilus\" \ - -I$(top_srcdir) \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = nautilus-sidebar-loser-ui.xml - -libexec_PROGRAMS=nautilus-sidebar-loser - -nautilus_sidebar_loser_SOURCES = \ - nautilus-sidebar-loser.h \ - nautilus-sidebar-loser.c \ - main.c - -nautilus_sidebar_loser_LDADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -server_in_files = Nautilus_View_sidebar-loser.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST=$(server_in_files) $(ui_DATA) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/loser/sidebar/Nautilus_View_sidebar-loser.server.in.in b/components/loser/sidebar/Nautilus_View_sidebar-loser.server.in.in deleted file mode 100644 index 09ef0e89f..000000000 --- a/components/loser/sidebar/Nautilus_View_sidebar-loser.server.in.in +++ /dev/null @@ -1,27 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Sidebar_Loser_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-sidebar-loser"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus sidebar loser factory"/> - <oaf_attribute name="description" type="string" _value="Nautilus sidebar loser component's factory"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Sidebar_Loser" type="factory" location="OAFIID:Nautilus_Sidebar_Loser_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Sidebar Loser"/> - <oaf_attribute name="description" type="string" _value="Nautilus sidebar view that fails on command"/> - <oaf_attribute name="bonobo:supported_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="Sidebar Loser"/> - <oaf_attribute name="test_only" type="boolean" value="true"/> -</oaf_server> - -</oaf_info> diff --git a/components/loser/sidebar/main.c b/components/loser/sidebar/main.c deleted file mode 100644 index 28093735d..000000000 --- a/components/loser/sidebar/main.c +++ /dev/null @@ -1,104 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak - */ - -/* main.c - main function and object activation function for loser - sidebar view component that fails on command. */ - -#include <config.h> - -#include "nautilus-sidebar-loser.h" - -#include <gnome.h> -#include <bonobo-activation/bonobo-activation.h> -#include <eel/eel-gnome-extensions.h> -#include <bonobo.h> - -#define FACTORY_IID "OAFIID:Nautilus_Sidebar_Loser_Factory" - -static int object_count = 0; - -static void -loser_object_destroyed(GtkObject *obj) -{ - object_count--; - if (object_count <= 0) { - gtk_main_quit (); - } -} - -static BonoboObject * -loser_make_object (BonoboGenericFactory *factory, - const char *iid, - void *closure) -{ - NautilusSidebarLoser *view; - NautilusView *nautilus_view; - - nautilus_sidebar_loser_maybe_fail ("pre-make-object"); - - if (strcmp (iid, "OAFIID:Nautilus_Sidebar_Loser")) { - return NULL; - } - - view = NAUTILUS_SIDEBAR_LOSER (g_object_new (NAUTILUS_TYPE_SIDEBAR_LOSER, NULL)); - - object_count++; - - nautilus_view = nautilus_sidebar_loser_get_nautilus_view (view); - - g_signal_connect (nautilus_view, "destroy", G_CALLBACK (loser_object_destroyed), NULL); - - nautilus_sidebar_loser_maybe_fail ("post-make-object"); - - return BONOBO_OBJECT (nautilus_view); -} - -int main(int argc, char *argv[]) -{ - BonoboGenericFactory *factory; - CORBA_Environment ev; - char *registration_id; - - CORBA_exception_init (&ev); - - nautilus_sidebar_loser_maybe_fail ("pre-init"); - - bonobo_ui_init ("nautilus-sidebar-loser", VERSION, &argc, argv); - - nautilus_sidebar_loser_maybe_fail ("post-init"); - - registration_id = eel_bonobo_make_registration_id (FACTORY_IID); - factory = bonobo_generic_factory_new (FACTORY_IID, - loser_make_object, - NULL); - g_free (registration_id); - - nautilus_sidebar_loser_maybe_fail ("post-factory-init"); - - if (factory != NULL) { - do { - bonobo_main (); - } while (object_count > 0); - } - - return 0; -} diff --git a/components/loser/sidebar/nautilus-sidebar-loser-ui.xml b/components/loser/sidebar/nautilus-sidebar-loser-ui.xml deleted file mode 100644 index 1a82770c5..000000000 --- a/components/loser/sidebar/nautilus-sidebar-loser-ui.xml +++ /dev/null @@ -1,21 +0,0 @@ -<Root> -<menu> - <submenu name="File" _label="_File"> - <placeholder name="File Items Placeholder"> - <menuitem name="Kill Sidebar Loser" - _label="_Kill Sidebar Loser" - _tip="Kill the Loser sidebar panel" - verb="Kill Sidebar Loser"/> - </placeholder> - </submenu> -</menu> -<dockitem name="Toolbar"> - <placeholder name="Extra Buttons Placeholder"> - <toolitem name="Kill Sidebar Loser" - _label="Kill Sidebar Loser" - _tip="Kill the Loser sidebar panel" - pixtype="stock" pixname="gtk-cut" - verb="Kill Sidebar Loser"/> - </placeholder> -</dockitem> -</Root>
\ No newline at end of file diff --git a/components/loser/sidebar/nautilus-sidebar-loser.c b/components/loser/sidebar/nautilus-sidebar-loser.c deleted file mode 100644 index 49cd00c8f..000000000 --- a/components/loser/sidebar/nautilus-sidebar-loser.c +++ /dev/null @@ -1,280 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-sidebar-loser.c - loser sidebar view component. This - component fails on demand, either controlled by env variables - during startup, or using toolbar buttons or menu items. */ - -#include <config.h> -#include "nautilus-sidebar-loser.h" - -#include <bonobo/bonobo-control.h> -#include <gtk/gtksignal.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <libgnome/gnome-i18n.h> -#include <libgnomeui/gnome-stock-icons.h> -#include <libnautilus/nautilus-bonobo-ui.h> -#include <eel/eel-gtk-macros.h> -#include <stdio.h> -#include <stdlib.h> - - -/* A NautilusSidebarLoser's private information. */ -struct NautilusSidebarLoserDetails { - char *uri; - NautilusView *nautilus_view; -}; - -static void nautilus_sidebar_loser_class_init (NautilusSidebarLoserClass *klass); -static void nautilus_sidebar_loser_init (NautilusSidebarLoser *view); -static void nautilus_sidebar_loser_destroy (GtkObject *object); - -EEL_CLASS_BOILERPLATE (NautilusSidebarLoser, nautilus_sidebar_loser, GTK_TYPE_LABEL) - -static void loser_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusSidebarLoser *view); -static void loser_merge_bonobo_items_callback (BonoboObject *control, - gboolean state, - gpointer user_data); -static void nautilus_sidebar_loser_fail (void); -static void ensure_fail_env (void); - -static void -nautilus_sidebar_loser_class_init (NautilusSidebarLoserClass *klass) -{ - GtkObjectClass *object_class; - - object_class = GTK_OBJECT_CLASS (klass); - - object_class->destroy = nautilus_sidebar_loser_destroy; -} - -static void -nautilus_sidebar_loser_init (NautilusSidebarLoser *view) -{ - view->details = g_new0 (NautilusSidebarLoserDetails, 1); - - gtk_label_set_text (GTK_LABEL (view), g_strdup ("(none)")); - - view->details->nautilus_view = nautilus_view_new (GTK_WIDGET (view)); - - g_signal_connect_object (view->details->nautilus_view, "load_location", - G_CALLBACK (loser_load_location_callback), view, 0); - - /* Get notified when our bonobo control is activated so we - * can merge menu & toolbar items into Nautilus's UI. - */ - g_signal_connect_object (nautilus_view_get_bonobo_control (view->details->nautilus_view), - "activate", - G_CALLBACK (loser_merge_bonobo_items_callback), view, 0); - - gtk_widget_show (GTK_WIDGET (view)); -} - -static void -nautilus_sidebar_loser_destroy (GtkObject *object) -{ - NautilusSidebarLoser *view; - - view = NAUTILUS_SIDEBAR_LOSER (object); - - g_free (view->details->uri); - g_free (view->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - -/** - * nautilus_sidebar_loser_get_nautilus_view: - * - * Return the NautilusView object associated with this view; this - * is needed to export the view via CORBA/Bonobo. - * @view: NautilusSidebarLoser to get the nautilus_view from.. - * - **/ -NautilusView * -nautilus_sidebar_loser_get_nautilus_view (NautilusSidebarLoser *view) -{ - return view->details->nautilus_view; -} - -/** - * nautilus_sidebar_loser_load_uri: - * - * Load the resource pointed to by the specified URI. - * @view: NautilusSidebarLoser to get the nautilus_view from. - * - **/ -void -nautilus_sidebar_loser_load_uri (NautilusSidebarLoser *view, - const char *uri) -{ - char *label_text; - - g_free (view->details->uri); - view->details->uri = g_strdup (uri); - - label_text = g_strdup_printf (_("%s\n\nLoser sidebar."), uri); - gtk_label_set_text (GTK_LABEL (view), label_text); - g_free (label_text); -} - -static void -loser_load_location_callback (NautilusView *nautilus_view, - const char *location, - NautilusSidebarLoser *view) -{ - g_assert (nautilus_view == view->details->nautilus_view); - - nautilus_sidebar_loser_maybe_fail ("pre-underway"); - - /* It's mandatory to send an underway message once the - * component starts loading, otherwise nautilus will assume it - * failed. In a real component, this will probably happen in - * some sort of callback from whatever loading mechanism it is - * using to load the data; this component loads no data, so it - * gives the progress update here. - */ - nautilus_view_report_load_underway (nautilus_view); - - nautilus_sidebar_loser_maybe_fail ("pre-load"); - - /* Do the actual load. */ - nautilus_sidebar_loser_load_uri (view, location); - - nautilus_sidebar_loser_maybe_fail ("pre-done"); - - /* It's mandatory to call report_load_complete once the - * component is done loading successfully, or - * report_load_failed if it completes unsuccessfully. In a - * real component, this will probably happen in some sort of - * callback from whatever loading mechanism it is using to - * load the data; this component loads no data, so it gives - * the progress update here. - */ - nautilus_view_report_load_complete (nautilus_view); - - nautilus_sidebar_loser_maybe_fail ("post-done"); -} - -static void -bonobo_loser_callback (BonoboUIComponent *ui, gpointer user_data, const char *verb) -{ - g_assert (NAUTILUS_IS_SIDEBAR_LOSER (user_data)); - - nautilus_sidebar_loser_fail (); - gtk_label_set_text (GTK_LABEL (user_data), _("You have tried to kill the Sidebar Loser")); -} - -static void -loser_merge_bonobo_items_callback (BonoboObject *control, gboolean state, gpointer user_data) -{ - NautilusSidebarLoser *view; - BonoboUIComponent *ui_component; - BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("Kill Sidebar Loser", bonobo_loser_callback), - BONOBO_UI_VERB_END - }; - - nautilus_sidebar_loser_maybe_fail ("pre-merge"); - - g_assert (NAUTILUS_IS_SIDEBAR_LOSER (user_data)); - - view = NAUTILUS_SIDEBAR_LOSER (user_data); - - if (state) { - ui_component = nautilus_view_set_up_ui (view->details->nautilus_view, - DATADIR, - "nautilus-sidebar-loser-ui.xml", - "nautilus-sidebar-loser"); - - bonobo_ui_component_add_verb_list_with_data (ui_component, verbs, view); - } else { - /* Do nothing. */ - } - - nautilus_sidebar_loser_maybe_fail ("post-merge"); - - - /* - * Note that we do nothing if state is FALSE. Nautilus sidebar views are activated - * when installed, but never explicitly deactivated. When the view changes to another, - * the sidebar view object is destroyed, which ends up calling bonobo_ui_handler_unset_container, - * which removes its merged menu & toolbar items. - */ -} - -static const char *failure_mode = NULL; -static const char *failure_point = NULL; -static gboolean env_checked = FALSE; - -void -nautilus_sidebar_loser_maybe_fail (const char *location) -{ - ensure_fail_env (); - - if (g_ascii_strcasecmp (location, failure_point) == 0) { - nautilus_sidebar_loser_fail (); - } -} - - - -static void -nautilus_sidebar_loser_fail (void) -{ - ensure_fail_env (); - - if (g_ascii_strcasecmp (failure_mode, "hang") == 0) { - while (1) { - } - } else if (g_ascii_strcasecmp (failure_mode, "exit") == 0) { - exit (0); - } else if (g_ascii_strcasecmp (failure_mode, "error-exit") == 0) { - exit (-1); - } else if (g_ascii_strcasecmp (failure_mode, "crash") == 0) { - abort (); - } else { - puts ("XXX - would fail now, if NAUTILUS_SIDEBAR_LOSER_MODE were set properly."); - } -} - - -static void -ensure_fail_env (void) -{ - if (!env_checked) { - failure_mode = g_getenv ("NAUTILUS_SIDEBAR_LOSER_MODE"); - if (failure_mode == NULL) { - failure_mode = ""; - } - - failure_point = g_getenv ("NAUTILUS_SIDEBAR_LOSER_PLACE"); - if (failure_point == NULL) { - failure_point = ""; - } - - env_checked = TRUE; - } -} diff --git a/components/loser/sidebar/nautilus-sidebar-loser.h b/components/loser/sidebar/nautilus-sidebar-loser.h deleted file mode 100644 index 8a8f2c9b1..000000000 --- a/components/loser/sidebar/nautilus-sidebar-loser.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-sidebar-loser.h - Nautilus sidebar view component that - fails on command. See the README in the `loser' directory to see - how to control the type of failure. */ - -#ifndef NAUTILUS_SIDEBAR_LOSER_H -#define NAUTILUS_SIDEBAR_LOSER_H - -#include <libnautilus/nautilus-view.h> -#include <gtk/gtklabel.h> - -typedef struct NautilusSidebarLoser NautilusSidebarLoser; -typedef struct NautilusSidebarLoserClass NautilusSidebarLoserClass; - -#define NAUTILUS_TYPE_SIDEBAR_LOSER (nautilus_sidebar_loser_get_type ()) -#define NAUTILUS_SIDEBAR_LOSER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SIDEBAR_LOSER, NautilusSidebarLoser)) -#define NAUTILUS_SIDEBAR_LOSER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SIDEBAR_LOSER, NautilusSidebarLoserClass)) -#define NAUTILUS_IS_SIDEBAR_LOSER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SIDEBAR_LOSER)) -#define NAUTILUS_IS_SIDEBAR_LOSER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SIDEBAR_LOSER)) - -typedef struct NautilusSidebarLoserDetails NautilusSidebarLoserDetails; - -struct NautilusSidebarLoser { - GtkLabel parent; - NautilusSidebarLoserDetails *details; -}; - -struct NautilusSidebarLoserClass { - GtkLabelClass parent_class; -}; - -/* GObject support */ -GType nautilus_sidebar_loser_get_type (void); - -/* Component embedding support */ -NautilusView *nautilus_sidebar_loser_get_nautilus_view (NautilusSidebarLoser *view); - -/* URI handling */ -void nautilus_sidebar_loser_load_uri (NautilusSidebarLoser *view, - const char *uri); - -/* Failing on command. */ -void nautilus_sidebar_loser_maybe_fail (const char *location); - -#endif /* NAUTILUS_SIDEBAR_LOSER_H */ - diff --git a/components/news/Makefile.am b/components/news/Makefile.am deleted file mode 100644 index 93781a882..000000000 --- a/components/news/Makefile.am +++ /dev/null @@ -1,42 +0,0 @@ -NULL = - -bin_PROGRAMS=nautilus-news - -INCLUDES=\ - -I$(top_srcdir) \ - -DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" \ - -DNAUTILUS_PIXMAPDIR=\""$(datadir)/pixmaps/nautilus"\" \ - -DDATADIR=\""$(datadir)"\" \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -LDADD=\ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-private/libnautilus-private.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -nautilus_news_SOURCES= \ - nautilus-cell-renderer-news.c \ - nautilus-cell-renderer-news.h \ - nautilus-news.c - -nautilusdir = $(datadir)/nautilus -nautilus_DATA = news_channels.xml - -nautiluspixmapdir = $(datadir)/pixmaps/nautilus -nautiluspixmap_DATA = news_bullet.png \ - changed_bullet.png - -serverdir = $(libdir)/bonobo/servers -server_in_files = Nautilus_View_news.server.in -server_DATA = $(server_in_files:.server.in=.server) -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST= \ - $(nautilus_DATA) \ - $(nautiluspixmap_DATA) \ - $(server_DATA)\ - $(server_in_files) \ - $(NULL) diff --git a/components/news/Nautilus_View_news.server.in b/components/news/Nautilus_View_news.server.in deleted file mode 100644 index 04b3277ac..000000000 --- a/components/news/Nautilus_View_news.server.in +++ /dev/null @@ -1,25 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_News_View_Factory" type="exe" location="nautilus-news"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="description" type="string" _value="Factory for news view"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_News_View" type="factory" location="OAFIID:Nautilus_News_View_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - - <oaf_attribute name="description" type="string" _value="News sidebar panel fetches and displays RSS feeds"/> - <oaf_attribute name="name" type="string" _value="News sidebar panel"/> - <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="News"/> - <oaf_attribute name="nautilus:recommended_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> -</oaf_server> - -</oaf_info> diff --git a/components/news/changed_bullet.png b/components/news/changed_bullet.png Binary files differdeleted file mode 100644 index 12c89dd5b..000000000 --- a/components/news/changed_bullet.png +++ /dev/null diff --git a/components/news/nautilus-cell-renderer-news.c b/components/news/nautilus-cell-renderer-news.c deleted file mode 100644 index c14f55a58..000000000 --- a/components/news/nautilus-cell-renderer-news.c +++ /dev/null @@ -1,489 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus News Item Cell Renderer - * - * Copyright (C) 2000 Red Hat, Inc., Ximian Inc., Jonathan Blandford - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Dave Camp <dave@ximian.com> - * based on the text cell renderer by Jonathan Blandford - * <jrb@redhat.com> - * - */ - -#include <config.h> -#include "nautilus-cell-renderer-news.h" - -#include <stdlib.h> -#include <pango/pango-layout.h> -#include <gtk/gtkcellrendererpixbuf.h> -#include <libgnome/gnome-i18n.h> - -struct _NautilusCellRendererNewsPrivate { - char *text; - PangoFontDescription *font; - - PangoAttrList *extra_attrs; - - GdkPixbuf *bullet; - GdkPixbuf *prelit_bullet; - - int wrap_at; -}; - -static void nautilus_cell_renderer_news_init (NautilusCellRendererNews *cellnews); -static void nautilus_cell_renderer_news_class_init (NautilusCellRendererNewsClass *class); -static void nautilus_cell_renderer_news_finalize (GObject *object); - -static void nautilus_cell_renderer_news_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void nautilus_cell_renderer_news_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void nautilus_cell_renderer_news_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - int *x_offset, - int *y_offset, - int *width, - int *height); -static void nautilus_cell_renderer_news_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - guint flags); - -enum { - PROP_0, - - PROP_MARKUP, - PROP_BULLET, - PROP_PRELIT_BULLET, - PROP_WRAP_AT, -}; - -static gpointer parent_class; - -#define PAD 2 - -GType -nautilus_cell_renderer_news_get_type (void) -{ - static GType cell_news_type = 0; - - if (!cell_news_type) { - static const GTypeInfo cell_news_info = { - sizeof (NautilusCellRendererNewsClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) nautilus_cell_renderer_news_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (NautilusCellRendererNews), - 0, /* n_preallocs */ - (GInstanceInitFunc) nautilus_cell_renderer_news_init, - }; - - cell_news_type = g_type_register_static (GTK_TYPE_CELL_RENDERER, "NautilusCellRendererNews", &cell_news_info, 0); - } - - return cell_news_type; -} - -static void -nautilus_cell_renderer_news_init (NautilusCellRendererNews *cellnews) -{ - GTK_CELL_RENDERER (cellnews)->xalign = 0.0; - GTK_CELL_RENDERER (cellnews)->yalign = 0.5; - GTK_CELL_RENDERER (cellnews)->xpad = 2; - GTK_CELL_RENDERER (cellnews)->ypad = 2; - - cellnews->priv = g_new0 (NautilusCellRendererNewsPrivate, 1); - cellnews->priv->wrap_at = -1; - cellnews->priv->font = pango_font_description_new (); -} - -static void -nautilus_cell_renderer_news_class_init (NautilusCellRendererNewsClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (class); - - parent_class = g_type_class_peek_parent (class); - - object_class->finalize = nautilus_cell_renderer_news_finalize; - - object_class->get_property = nautilus_cell_renderer_news_get_property; - object_class->set_property = nautilus_cell_renderer_news_set_property; - - cell_class->get_size = nautilus_cell_renderer_news_get_size; - cell_class->render = nautilus_cell_renderer_news_render; - - g_object_class_install_property (object_class, - PROP_WRAP_AT, - g_param_spec_int ("wrap_at", - _("Wrap at"), - _("Width the cell should wrap to."), - -1, G_MAXINT, - -1, - G_PARAM_READWRITE)); - - - g_object_class_install_property (object_class, - PROP_MARKUP, - g_param_spec_string ("markup", - _("Markup"), - _("Marked up text to display"), - "", - G_PARAM_READWRITE)); - g_object_class_install_property (object_class, - PROP_BULLET, - g_param_spec_pointer ("bullet", - _("Bullet"), - _("Bullet to display"), - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_PRELIT_BULLET, - g_param_spec_pointer ("prelit_bullet", - _("Prelight Bullet"), - _("Bullet to display when prelit"), - G_PARAM_READWRITE)); -} - -static void -nautilus_cell_renderer_news_finalize (GObject *object) -{ - NautilusCellRendererNews *cellnews = NAUTILUS_CELL_RENDERER_NEWS (object); - - pango_font_description_free (cellnews->priv->font); - - if (cellnews->priv->text) { - g_free (cellnews->priv->text); - } - - if (cellnews->priv->extra_attrs) { - pango_attr_list_unref (cellnews->priv->extra_attrs); - } - - if (cellnews->priv->bullet) { - g_object_unref (cellnews->priv->bullet); - } - - if (cellnews->priv->prelit_bullet) { - g_object_unref (cellnews->priv->prelit_bullet); - } - - g_free (cellnews->priv); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_cell_renderer_news_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - NautilusCellRendererNews *cellnews = NAUTILUS_CELL_RENDERER_NEWS (object); - - switch (param_id) { - case PROP_WRAP_AT : - g_value_set_int (value, cellnews->priv->wrap_at); - break; - case PROP_MARKUP : - g_value_set_pointer (value, cellnews->priv->text); - break; - case PROP_BULLET : - g_value_set_pointer (value, cellnews->priv->bullet); - break; - case PROP_PRELIT_BULLET : - g_value_set_pointer (value, cellnews->priv->prelit_bullet); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -nautilus_cell_renderer_news_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - NautilusCellRendererNews *cellnews = NAUTILUS_CELL_RENDERER_NEWS (object); - GdkPixbuf *pixbuf; - const gchar *str; - char *text = NULL; - GError *error = NULL; - PangoAttrList *attrs = NULL; - - - switch (param_id) { - case PROP_WRAP_AT: - cellnews->priv->wrap_at = g_value_get_int (value); - g_object_notify (object, "wrap_at"); - break; - case PROP_BULLET: - pixbuf = g_value_get_pointer (value); - - if (cellnews->priv->bullet) { - g_object_unref (cellnews->priv->bullet); - } - cellnews->priv->bullet = pixbuf; - if (cellnews->priv->bullet) { - g_object_ref (cellnews->priv->bullet); - } - g_object_notify (object, "bullet"); - break; - case PROP_PRELIT_BULLET: - pixbuf = g_value_get_pointer (value); - - if (cellnews->priv->prelit_bullet) { - g_object_unref (cellnews->priv->prelit_bullet); - } - cellnews->priv->prelit_bullet = pixbuf; - if (cellnews->priv->prelit_bullet) { - g_object_ref (cellnews->priv->prelit_bullet); - } - - g_object_notify (object, "prelit_bullet"); - break; - case PROP_MARKUP: - str = g_value_get_string (value); - - if (cellnews->priv->extra_attrs) { - pango_attr_list_unref (cellnews->priv->extra_attrs); - } - - if (str && !pango_parse_markup (str, - -1, - 0, - &attrs, - &text, - NULL, - &error)) { - g_warning ("Failed to set cell news from markup due to error parsing markup: %s", - error->message); - g_error_free (error); - return; - } - - cellnews->priv->text = text; - cellnews->priv->extra_attrs = attrs; - - g_object_notify (object, "markup"); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -/** - * nautilus_cell_renderer_news_new: - * - * Creates a new #NautilusCellRendererNews. Adjust how news is drawn using - * object properties. Object properties can be - * set globally (with g_object_set()). Also, with #GtkTreeViewColumn, - * you can bind a property to a value in a #GtkTreeModel. For example, - * you can bind the "news" property on the cell renderer to a string - * value in the model, thus rendering a different string in each row - * of the #GtkTreeView - * - * Return value: the new cell renderer - **/ -GtkCellRenderer * -nautilus_cell_renderer_news_new (void) -{ - return GTK_CELL_RENDERER (g_object_new (nautilus_cell_renderer_news_get_type (), NULL)); -} - -static void -add_attr (PangoAttrList *attr_list, - PangoAttribute *attr) -{ - attr->start_index = 0; - attr->end_index = G_MAXINT; - - pango_attr_list_insert (attr_list, attr); -} - -static PangoLayout* -get_layout (NautilusCellRendererNews *cellnews, - GtkWidget *widget, - gboolean will_render, - GtkCellRendererState flags) -{ - PangoAttrList *attr_list; - PangoLayout *layout; - int wrap_width; - - layout = gtk_widget_create_pango_layout (widget, cellnews->priv->text); - - if (cellnews->priv->extra_attrs) - attr_list = pango_attr_list_copy (cellnews->priv->extra_attrs); - else - attr_list = pango_attr_list_new (); - - add_attr (attr_list, pango_attr_font_desc_new (cellnews->priv->font)); - - if ((flags & GTK_CELL_RENDERER_PRELIT) != 0) { - add_attr (attr_list, - pango_attr_foreground_new (0, 0, 65535 / 2)); - } - - pango_layout_set_attributes (layout, attr_list); - - if (cellnews->priv->wrap_at != -1) { - wrap_width = cellnews->priv->wrap_at; - if (cellnews->priv->bullet) { - wrap_width -= (gdk_pixbuf_get_width (cellnews->priv->bullet) + PAD); - } - - pango_layout_set_wrap (layout, PANGO_WRAP_WORD); - pango_layout_set_width (layout, - wrap_width * PANGO_SCALE); - } - - pango_attr_list_unref (attr_list); - - return layout; -} - -static void -nautilus_cell_renderer_news_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - int *x_offset, - int *y_offset, - int *width, - int *height) -{ - NautilusCellRendererNews *cellnews = (NautilusCellRendererNews *) cell; - PangoRectangle rect; - PangoLayout *layout; - - layout = get_layout (cellnews, widget, FALSE, 0); - pango_layout_get_pixel_extents (layout, NULL, &rect); - - if (width) { - *width = GTK_CELL_RENDERER (cellnews)->xpad * 2 + rect.width; - if (cellnews->priv->bullet) { - *width += gdk_pixbuf_get_width (cellnews->priv->bullet) + PAD; - } - } - - if (height) { - *height = GTK_CELL_RENDERER (cellnews)->ypad * 2 + rect.height; - if (cellnews->priv->bullet) { - *height = MAX (*height, - gdk_pixbuf_get_height (cellnews->priv->bullet) + GTK_CELL_RENDERER (cellnews)->ypad * 2); - } - } - - if (cell_area) { - if (x_offset) { - *x_offset = cell->xalign * (cell_area->width - rect.width - (2 * cell->xpad)); - *x_offset = MAX (*x_offset, 0); - } - if (y_offset) { - *y_offset = cell->yalign * (cell_area->height - rect.height - (2 * cell->ypad)); - *y_offset = MAX (*y_offset, 0); - } - } - - g_object_unref (layout); -} - -static void -nautilus_cell_renderer_news_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - guint flags) - -{ - NautilusCellRendererNews *cellnews = (NautilusCellRendererNews *) cell; - PangoLayout *layout; - GtkStateType state; - int x_offset; - int y_offset; - int height; - int width; - GdkPixbuf *pixbuf; - - layout = get_layout (cellnews, widget, TRUE, flags); - - nautilus_cell_renderer_news_get_size (cell, widget, cell_area, &x_offset, &y_offset, &height, &width); - - if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) { - if (GTK_WIDGET_HAS_FOCUS (widget)) { - state = GTK_STATE_SELECTED; - } else { - state = GTK_STATE_ACTIVE; - } - } else { - if (GTK_WIDGET_STATE (widget) == GTK_STATE_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - } - - if (cellnews->priv->prelit_bullet - && (flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT) { - pixbuf = cellnews->priv->prelit_bullet; - } else { - pixbuf = cellnews->priv->bullet; - } - - if (pixbuf) { - gdk_pixbuf_render_to_drawable_alpha - (pixbuf, - window, - 0, 0, - cell_area->x + cell->xpad, - cell_area->y + cell->ypad, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_PIXBUF_ALPHA_FULL, - 0, - GDK_RGB_DITHER_NORMAL, - 0, 0); - x_offset += gdk_pixbuf_get_width (pixbuf) + PAD; - } - gtk_paint_layout (widget->style, - window, - state, - TRUE, - cell_area, - widget, - "cellrenderernews", - cell_area->x + x_offset + cell->xpad, - cell_area->y + y_offset + cell->ypad, - layout); - - g_object_unref (layout); -} diff --git a/components/news/nautilus-cell-renderer-news.h b/components/news/nautilus-cell-renderer-news.h deleted file mode 100644 index 6f995fbbd..000000000 --- a/components/news/nautilus-cell-renderer-news.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus News Item Cell Renderer - * - * Copyright (C) 2000 Red Hat, Inc., Ximian Inc., Jonathan Blandford - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Dave Camp <dave@ximian.com> - * based on the text cell renderer by Jonathan Blandford - * <jrb@redhat.com> - * - */ - -#ifndef NAUTILUS_CELL_RENDERER_NEWS_ITEM_H -#define NAUTILUS_CELL_RENDERER_NEWS_ITEM_H - -#include <gtk/gtkcellrenderer.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_CELL_RENDERER_NEWS (nautilus_cell_renderer_news_get_type ()) -#define NAUTILUS_CELL_RENDERER_NEWS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), NAUTILUS_TYPE_CELL_RENDERER_NEWS, NautilusCellRendererNews)) -#define NAUTILUS_CELL_RENDERER_NEWS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_CELL_RENDERER_NEWS, NautilusCellRendererNewsClass)) -#define NAUTILUS_IS_CELL_RENDERER_NEWS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), NAUTILUS_TYPE_CELL_RENDERER_NEWS)) -#define NAUTILUS_IS_CELL_RENDERER_NEWS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_CELL_RENDERER_NEWS)) - -typedef struct _NautilusCellRendererNews NautilusCellRendererNews; -typedef struct _NautilusCellRendererNewsClass NautilusCellRendererNewsClass; -typedef struct _NautilusCellRendererNewsPrivate NautilusCellRendererNewsPrivate; - -struct _NautilusCellRendererNews -{ - GtkCellRenderer parent; - - NautilusCellRendererNewsPrivate *priv; -}; - -struct _NautilusCellRendererNewsClass -{ - GtkCellRendererClass parent_class; -}; - -GType nautilus_cell_renderer_news_get_type (void); -GtkCellRenderer *nautilus_cell_renderer_news_new (void); - -G_END_DECLS - -#endif /* __GTK_CELL_RENDERER_NEWS_H__ */ diff --git a/components/news/nautilus-news.c b/components/news/nautilus-news.c deleted file mode 100644 index 93710e608..000000000 --- a/components/news/nautilus-news.c +++ /dev/null @@ -1,2562 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus News Viewer - * - * Copyright (C) 2001 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - */ - -/* This is the News sidebar panel, which displays current news headlines from - * a variety of web sites, by fetching and displaying RSS files - */ - -#include <config.h> -#include <time.h> - -#include "nautilus-cell-renderer-news.h" - -#include <gtk/gtkcheckbutton.h> -#include <gtk/gtktreeview.h> -#include <gtk/gtktreeselection.h> -#include <gtk/gtkliststore.h> -#include <gtk/gtktreestore.h> -#include <gtk/gtkcellrenderertext.h> -#include <gtk/gtkcellrendererpixbuf.h> -#include <gtk/gtkdrawingarea.h> -#include <gtk/gtkframe.h> -#include <gtk/gtkhbbox.h> -#include <gtk/gtkmain.h> -#include <gtk/gtkscrolledwindow.h> -#include <gtk/gtkstock.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtknotebook.h> - -#include <bonobo/bonobo-property-bag.h> - -#include <libgnome/gnome-i18n.h> -#include <libgnome/gnome-util.h> - -#include <libxml/parser.h> - -#include <libgnomevfs/gnome-vfs-utils.h> - -#include <eel/eel-background.h> -#include <eel/eel-debug.h> -#include <eel/eel-gdk-pixbuf-extensions.h> -#include <eel/eel-glib-extensions.h> -#include <eel/eel-graphic-effects.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-stock-dialogs.h> -#include <eel/eel-string.h> -#include <eel/eel-vfs-extensions.h> -#include <eel/eel-xml-extensions.h> - -#include <libnautilus-private/nautilus-entry.h> -#include <libnautilus-private/nautilus-file-attributes.h> -#include <libnautilus-private/nautilus-file.h> -#include <libnautilus-private/nautilus-file-utilities.h> -#include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus-private/nautilus-metadata.h> -#include <libnautilus-private/nautilus-theme.h> -#include <libnautilus-private/nautilus-undo-signal-handlers.h> - -#include <libnautilus/nautilus-clipboard.h> -#include <libnautilus/nautilus-view.h> -#include <libnautilus/nautilus-view-standard-main.h> - -/* property bag getting and setting routines */ -enum { - TAB_IMAGE, - CLOSE_NOTIFY, -}; - -typedef enum { - PAGE_MAIN, - PAGE_CONFIGURE, - PAGE_ADD_SITE -} NewsPageNum; - -enum { - MAIN_PAGE_DISPLAY, - MAIN_PAGE_EMPTY -}; - -enum { - REMOVE_COL_NAME, - LAST_REMOVE_COL -}; - -enum { - NEWS_COL_DATA, - NEWS_COL_WIDTH, - LAST_NEWS_COL -}; - -typedef struct _RSSNodeData RSSNodeData; -typedef struct _RSSChannelData RSSChannelData; -typedef struct _RSSItemData RSSItemData; - -/* data structure for the news view */ -typedef struct { - NautilusView *view; - BonoboPropertyBag *property_bag; - - GList *channel_list; - - GdkPixbuf *bullet; - GdkPixbuf *prelit_bullet; - GdkPixbuf *changed_bullet; - GdkPixbuf *prelight_changed_bullet; - - GtkWidget *main_container; - GtkWidget *main_box; - GtkWidget *news_notebook; - GtkWidget *news_display; - GtkWidget *news_display_scrolled_window; - GtkWidget *empty_message; - - GtkTreeModel *news_model; - - GtkWidget *configure_box; - GtkWidget *checkbox_list; - - GtkWidget *edit_site_box; - GtkWidget *item_name_field; - GtkWidget *item_location_field; - - GtkWidget *remove_site_list; - GtkWidget *remove_button; - - int max_item_count; - uint update_interval; - int update_timeout; - - gboolean news_changed; - gboolean opened; - - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - - NewsPageNum current_page; - - guint timer_task; - - GHashTable *item_uris; - - RSSItemData *current_item; - - int wrap_idle_handle; - - int last_width; -} News; - -struct _RSSNodeData { - char *title; - char *markup; - char *uri; - - GtkTreePath *path; - - GdkPixbuf *pixbuf; - GdkPixbuf *prelight_pixbuf; -}; - -/* per channel structure for rss channel */ -struct _RSSChannelData { - RSSNodeData node_data; - - char *name; - char *uri; - News *owner; - - gboolean is_showing; - gboolean is_open; - gboolean initial_load_flag; - gboolean channel_changed; - gboolean update_in_progress; - - GList *items; - - EelReadFileHandle *load_file_handle; - EelPixbufLoadHandle *load_image_handle; - - GtkWidget *checkbox; - - time_t last_update; -}; - -/* per item structure for rss items */ -struct _RSSItemData { - RSSNodeData node_data; - - RSSChannelData *owner; - gboolean new_item; -}; - -#define EMPTY_MESSAGE_MARGIN 12 -#define EXPANDER_EXTRA_PADDING 4 - -static char *news_get_indicator_image (News *news_data); -static void nautilus_news_free_channel_list (News *news_data); -static gboolean nautilus_news_save_channel_state (News* news_data); - -static char* get_xml_path (const char *file_name, gboolean force_local); -static int check_for_updates (gpointer callback_data); -static RSSChannelData* get_channel_from_name (News *news_data, const char *channel_name); -static void nautilus_news_clear_changed_flags (News* news_data); -static void clear_channel_changed_flags (RSSChannelData *channel_data); -static void set_views_for_mode (News *news); -static void max_items_changed (gpointer user_data); -static void update_interval_changed (gpointer user_data); - -static void add_channel_entry (News *news_data, const char *channel_name, - int index, gboolean is_showing); -static void update_channels (News *news_data); -static void update_items (RSSChannelData *channel_data, GList *old_items); - -static RSSChannelData* -nautilus_news_make_new_channel (News *news_data, - const char *name, - const char* channel_uri, - gboolean is_open, - gboolean is_showing); - - -static void -update_node (News *news, RSSNodeData *node) -{ - GtkTreeIter iter; - - if (node->path) { - gtk_tree_model_get_iter (news->news_model, &iter, node->path); - gtk_tree_model_row_changed (news->news_model, - node->path, &iter); - } -} - -static char * -get_channel_markup (RSSChannelData *channel_data) -{ - const char *title; - char *markup; - char *escaped; - - title = channel_data->node_data.title ? channel_data->node_data.title : ""; - escaped = g_markup_escape_text (title, -1); - markup = g_strdup_printf ("<span weight=\"bold\" size=\"large\">%s</span>", escaped); - g_free (escaped); - return markup; -} - -static char * -get_item_markup (RSSItemData *item_data) -{ - char *title; - char *markup; - char *escaped; - title = item_data->node_data.title ? item_data->node_data.title : ""; - escaped = g_markup_escape_text (title, strlen (title)); - markup = g_strdup_printf ("<u>%s</u>", escaped); - g_free (escaped); - return markup; -} - -/* property bag property access routines */ -static void -get_bonobo_properties (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer callback_data) -{ - char *indicator_image; - News *news; - - news = (News *) callback_data; - - switch (arg_id) { - case TAB_IMAGE: { - /* if there is a note, return the name of the indicator image, - otherwise, return NULL */ - indicator_image = news_get_indicator_image (news); - BONOBO_ARG_SET_STRING (arg, indicator_image); - g_free (indicator_image); - break; - } - case CLOSE_NOTIFY: { - /* this shouldn't be read, but return it anyway */ - BONOBO_ARG_SET_BOOLEAN (arg, news->opened); - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -static void -set_bonobo_properties (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer callback_data) -{ - News *news; - - news = (News *) callback_data; - - switch (arg_id) { - case TAB_IMAGE: { - g_warning ("cant set tab image in news view"); - break; - } - - /* when closed, clear the changed flags; also, exit configure mode */ - case CLOSE_NOTIFY: { - if (BONOBO_ARG_GET_BOOLEAN (arg)) { - news->opened = FALSE; - nautilus_news_clear_changed_flags (news); - news->current_page = PAGE_MAIN; - set_views_for_mode (news); - } else { - news->opened = TRUE; - } - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -/* do_destroy is invoked when the nautilus view is destroyed to deallocate the resources used - * by the news panel - */ -static void -do_destroy (GtkObject *obj, News *news) -{ - nautilus_news_save_channel_state (news); - - if (news->timer_task != 0) { - gtk_timeout_remove (news->timer_task); - news->timer_task = 0; - } - - if (news->update_timeout > 0) { - gtk_timeout_remove (news->update_timeout); - news->update_timeout = -1; - } - - if (news->bullet != NULL) { - g_object_unref (news->bullet); - } - - if (news->prelit_bullet != NULL) { - g_object_unref (news->prelit_bullet); - } - - if (news->changed_bullet != NULL) { - g_object_unref (news->changed_bullet); - } - - if (news->prelight_changed_bullet != NULL) { - g_object_unref (news->prelight_changed_bullet); - } - - g_hash_table_destroy (news->item_uris); - - /* free all the channel data */ - nautilus_news_free_channel_list (news); - - /* free the property bag */ - bonobo_object_unref (news->property_bag); - - eel_preferences_remove_callback (NAUTILUS_PREFERENCES_NEWS_MAX_ITEMS, - max_items_changed, - news); - eel_preferences_remove_callback (NAUTILUS_PREFERENCES_NEWS_UPDATE_INTERVAL, - update_interval_changed, - news); - - g_free (news); -} - -/* utility routine to tell Nautilus to navigate to the passed-in uri */ -static void -go_to_uri (News* news_data, const char* uri) -{ - if (uri != NULL) { - nautilus_view_open_location_in_this_window (news_data->view, uri); - } -} - -static void -set_row_widths (News *news) -{ - GtkTreeIter iter; - GList *channel_item; - GList *news_item; - RSSNodeData *node_data; - int cell_width; - int expander_size; - int horizontal_separator; - - /* Set the width attribute on all the rows by getting the width - * of the widget and subtracting the depth * expander size */ - - gtk_widget_style_get (news->news_display, - "expander_size", &expander_size, - "horizontal_separator", &horizontal_separator, - NULL); - expander_size += EXPANDER_EXTRA_PADDING; - - channel_item = news->channel_list; - while (channel_item != NULL) { - node_data = (RSSNodeData*) channel_item->data; - channel_item = channel_item->next; - - if (node_data->path == NULL) { - continue; - } - cell_width = news->news_display->allocation.width; - cell_width -= ((gtk_tree_path_get_depth (node_data->path) * expander_size) + horizontal_separator); - if (cell_width > 0) { - gtk_tree_model_get_iter (news->news_model, - &iter, node_data->path); - gtk_tree_store_set (GTK_TREE_STORE (news->news_model), - &iter, - NEWS_COL_WIDTH, cell_width, - -1); - } - - news_item = ((RSSChannelData*)node_data)->items; - while (news_item != NULL) { - node_data = (RSSNodeData*)news_item->data; - news_item = news_item->next; - if (node_data->path == NULL) { - continue; - } - - cell_width = news->news_display->allocation.width; - cell_width -= (gtk_tree_path_get_depth (node_data->path) * expander_size); - if (cell_width > 0) { - gtk_tree_model_get_iter (news->news_model, - &iter, node_data->path); - - gtk_tree_store_set (GTK_TREE_STORE (news->news_model), - &iter, - NEWS_COL_WIDTH, cell_width, - -1); - } - } - } -} - -static gboolean -wrap_idle (gpointer data) -{ - News *news = (News*)data; - - set_row_widths (news); - - news->wrap_idle_handle = -1; - return FALSE; -} - -static void -nautilus_news_size_allocate (GtkWidget *widget, GtkAllocation *alloc, - News *news_data) -{ - if (news_data->last_width != alloc->width) { - if (news_data->wrap_idle_handle == -1) { - news_data->wrap_idle_handle = gtk_idle_add (wrap_idle, - news_data); - } - news_data->last_width = alloc->width; - } -} - -static RSSNodeData * -node_data_for_path (News *news, GtkTreePath *path) -{ - GtkTreeIter iter; - RSSNodeData *node_data = NULL; - - if (gtk_tree_model_get_iter (news->news_model, &iter, path)) { - gtk_tree_model_get (news->news_model, &iter, - NEWS_COL_DATA, - &node_data, - -1); - } - - return node_data; -} - -static void -nautilus_news_activate_path (News *news, - GtkTreePath *path) -{ - RSSNodeData *node_data; - - node_data = node_data_for_path (news, path); - if (node_data) { - go_to_uri (news, node_data->uri); - } -} - -static void -nautilus_news_row_activated (GtkTreeView *tree_view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) -{ - News *news = (News*)data; - - nautilus_news_activate_path (news, path); -} - -/* handle the news display hit-testing */ -static gint -nautilus_news_button_release_event (GtkWidget *widget, GdkEventButton *event, News *news_data ) -{ - GtkTreePath *path; - - /* we only respond to the first button */ - if (event->button != 1) { - return FALSE; - } - - if (gtk_tree_view_get_path_at_pos (GTK_TREE_VIEW (news_data->news_display), - event->x, event->y, - &path, NULL, NULL, NULL)) { - nautilus_news_activate_path (news_data, path); - gtk_tree_path_free (path); - } - - return FALSE; -} - -static void -nautilus_news_set_title (RSSChannelData *channel_data, const char *title) -{ - if (channel_data->node_data.title) { - g_free (channel_data->node_data.title); - channel_data->node_data.title = NULL; - } - - if (channel_data->node_data.markup) { - g_free (channel_data->node_data.markup); - channel_data->node_data.markup = NULL; - } - - channel_data->node_data.title = g_strdup (title ? title : ""); - - if (channel_data->node_data.pixbuf) { - channel_data->node_data.markup = eel_strdup_strftime (_("%I:%M %p"), localtime (&channel_data->last_update)); - } else { - channel_data->node_data.markup = get_channel_markup (channel_data); - } - - update_node (channel_data->owner, (RSSNodeData*)channel_data); -} - -static void -free_rss_data_item (RSSItemData *item) -{ - g_free (item->node_data.title); - g_free (item->node_data.uri); - g_free (item->node_data.markup); - - g_free (item); -} - -static void -free_rss_channel_items (RSSChannelData *channel_data) -{ - eel_g_list_free_deep_custom (channel_data->items, (GFunc) free_rss_data_item, NULL); - channel_data->items = NULL; -} - -/* this frees a single channel object */ -static void -free_channel (RSSChannelData *channel_data) -{ - g_free (channel_data->name); - g_free (channel_data->uri); - - if (channel_data->node_data.uri) { - g_free (channel_data->node_data.uri); - } - - if (channel_data->node_data.title != NULL) { - g_free (channel_data->node_data.title); - } - - if (channel_data->node_data.markup != NULL) { - g_free (channel_data->node_data.markup); - } - - if (channel_data->node_data.pixbuf != NULL) { - g_object_unref (channel_data->node_data.pixbuf); - } - if (channel_data->node_data.prelight_pixbuf != NULL) { - g_object_unref (channel_data->node_data.prelight_pixbuf); - } - - if (channel_data->load_file_handle != NULL) { - eel_read_file_cancel (channel_data->load_file_handle); - } - - if (channel_data->load_image_handle != NULL) { - eel_cancel_gdk_pixbuf_load (channel_data->load_image_handle); - } - - free_rss_channel_items (channel_data); - - g_free (channel_data); -} - -/* free the entire channel list */ -static void -nautilus_news_free_channel_list (News *news_data) -{ - GList *current_item; - - current_item = news_data->channel_list; - while (current_item != NULL) { - free_channel ((RSSChannelData*) current_item->data); - current_item = current_item->next; - } - - g_list_free (news_data->channel_list); - news_data->channel_list = NULL; -} - -/* utilities to deal with the changed flags */ -static void -nautilus_news_set_news_changed (News *news_data, gboolean changed_flag) -{ - char *tab_image; - BonoboArg *tab_image_arg; - - if (news_data->news_changed != changed_flag) { - news_data->news_changed = changed_flag; - - tab_image = news_get_indicator_image (news_data); - - tab_image_arg = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (tab_image_arg, tab_image); - bonobo_event_source_notify_listeners_full (news_data->property_bag->es, - "Bonobo/Property", - "change", - "tab_image", - tab_image_arg, - NULL); - - bonobo_arg_release (tab_image_arg); - g_free (tab_image); - } -} - -static void -clear_channel_changed_flags (RSSChannelData *channel_data) -{ - GList *current_item; - RSSItemData *item_data; - - current_item = channel_data->items; - while (current_item != NULL) { - item_data = (RSSItemData*) current_item->data; - item_data->new_item = FALSE; - - if (item_data->node_data.path) { - update_node (channel_data->owner, - (RSSNodeData*)item_data); - } - - current_item = current_item->next; - } - channel_data->channel_changed = FALSE; - update_node (channel_data->owner, (RSSNodeData*)channel_data); -} - -static void -nautilus_news_clear_changed_flags (News* news_data) -{ - GList *current_channel; - RSSChannelData *channel_data; - - current_channel = news_data->channel_list; - while (current_channel != NULL) { - channel_data = (RSSChannelData*) current_channel->data; - clear_channel_changed_flags (channel_data); - current_channel = current_channel->next; - } - nautilus_news_set_news_changed (news_data, FALSE); -} - -/* utility to express boolean as a string */ -static char * -bool_to_text (gboolean value) -{ - return value ? "true" : "false"; -} - -/* build a channels xml file from the current channels state */ -static xmlDocPtr -nautilus_news_make_channel_document (News* news_data) -{ - xmlDoc *channel_doc; - xmlNode *root_node; - xmlNode *channel_node; - RSSChannelData *channel_data; - GList *next_channel; - gboolean is_open; - - channel_doc = xmlNewDoc ("1.0"); - - /* add the root node to the channel document */ - root_node = xmlNewDocNode (channel_doc, NULL, "rss_news_channels", NULL); - xmlDocSetRootElement (channel_doc, root_node); - - /* loop through the channels, adding a node for each channel */ - next_channel = news_data->channel_list; - while (next_channel != NULL) { - channel_node = xmlNewChild (root_node, NULL, "rss_channel", NULL); - channel_data = (RSSChannelData*) next_channel->data; - - xmlSetProp (channel_node, "name", channel_data->name); - xmlSetProp (channel_node, "uri", channel_data->uri); - xmlSetProp (channel_node, "show", bool_to_text (channel_data->is_showing)); - - is_open = channel_data->is_open; - xmlSetProp (channel_node, "open", bool_to_text (channel_data->is_open)); - - next_channel = next_channel->next; - } - return channel_doc; -} - -/* save the current channel state to disk */ -static gboolean -nautilus_news_save_channel_state (News* news_data) -{ - int result; - char *path; - xmlDoc *channel_doc; - - path = get_xml_path ("news_channels.xml", TRUE); - channel_doc = nautilus_news_make_channel_document (news_data); - - result = xmlSaveFile (path, channel_doc); - - g_free (path); - xmlFreeDoc (channel_doc); - - return result > 0; -} - - -static void -rss_logo_callback (GnomeVFSResult error, GdkPixbuf *pixbuf, gpointer callback_data) -{ - RSSChannelData *channel_data; - - channel_data = (RSSChannelData*) callback_data; - channel_data->load_image_handle = NULL; - - if (channel_data->node_data.pixbuf) { - g_object_unref (channel_data->node_data.pixbuf); - channel_data->node_data.pixbuf = NULL; - } - - if (pixbuf != NULL) { - g_object_ref (pixbuf); - pixbuf = eel_gdk_pixbuf_scale_down_to_fit (pixbuf, 192, 40); - - channel_data->node_data.pixbuf = pixbuf; - channel_data->node_data.prelight_pixbuf = eel_create_spotlight_pixbuf (pixbuf); - - if (channel_data->node_data.markup) { - g_free (channel_data->node_data.markup); - channel_data->node_data.markup = eel_strdup_strftime (_("%I:%M %p"), localtime (&channel_data->last_update)); - } - - update_node (channel_data->owner, (RSSNodeData*)channel_data); - } -} - - -/* utility routine to extract items from a node, returning the count of items found */ -static int -extract_items (RSSChannelData *channel_data, xmlNodePtr container_node) -{ - RSSItemData *item_parameters; - xmlNodePtr current_node, title_node, temp_node; - int item_count; - char *title, *temp_str; - gboolean scripting_news_format; - - current_node = container_node->children; - item_count = 0; - while (current_node != NULL) { - if (eel_strcmp (current_node->name, "item") == 0) { - title_node = eel_xml_get_child_by_name (current_node, "title"); - /* look for "text", too, to support Scripting News format */ - scripting_news_format = FALSE; - if (title_node == NULL) { - title_node = eel_xml_get_child_by_name (current_node, "text"); - scripting_news_format = title_node != NULL; - } - if (title_node != NULL) { - item_parameters = (RSSItemData*) g_new0 (RSSItemData, 1); - item_parameters->owner = channel_data; - title = xmlNodeGetContent (title_node); - item_parameters->node_data.title = g_strdup (title); - xmlFree (title); - - temp_node = eel_xml_get_child_by_name (current_node, "link"); - if (temp_node) { - if (scripting_news_format) { - temp_node = eel_xml_get_child_by_name (temp_node, "url"); - } - temp_str = xmlNodeGetContent (temp_node); - item_parameters->node_data.uri = g_strdup (temp_str); - xmlFree (temp_str); - } - - if (item_parameters->node_data.title != NULL && item_parameters->node_data.uri != NULL) { - channel_data->items = g_list_append (channel_data->items, item_parameters); - item_count += 1; - } else { - free_rss_data_item (item_parameters); - } - } - } - current_node = current_node->next; - } - return item_count; -} - -/* utility routine to search for the passed-in uri in an item list */ -static gboolean -has_matching_uri (GList *items, const char *target_uri, gboolean *old_changed_flag) -{ - GList *current_item; - RSSItemData *item_data; - char *mapped_target_uri, *mapped_item_uri; - gboolean found_match; - - *old_changed_flag = FALSE; - - if (target_uri == NULL) { - return FALSE; - } - - mapped_target_uri = gnome_vfs_make_uri_canonical (target_uri); - - current_item = items; - found_match = FALSE; - while (current_item != NULL && !found_match) { - item_data = (RSSItemData*) current_item->data; - mapped_item_uri = gnome_vfs_make_uri_canonical (item_data->node_data.uri); - if (eel_strcasecmp (mapped_item_uri, target_uri) == 0) { - found_match = TRUE; - *old_changed_flag = item_data->new_item; - } - g_free (mapped_item_uri); - current_item = current_item->next; - } - g_free (mapped_target_uri); - return found_match; -} - -/* take a look at the newly generated items in the passed-in channel, - * comparing them with the old items and marking them as new if necessary. - */ -static int -mark_new_items (RSSChannelData *channel_data, GList *old_items) -{ - GList *current_item; - RSSItemData *item_data; - int changed_count; - gboolean old_changed_flag; - - current_item = channel_data->items; - changed_count = 0; - while (current_item != NULL) { - item_data = (RSSItemData*) current_item->data; - if (!has_matching_uri (old_items, item_data->node_data.uri, &old_changed_flag) && !channel_data->initial_load_flag) { - item_data->new_item = TRUE; - channel_data->channel_changed = TRUE; - nautilus_news_set_news_changed (channel_data->owner, TRUE); - changed_count += 1; - } else { - item_data->new_item = old_changed_flag; - } - - current_item = current_item->next; - } - return changed_count; -} - -/* error handling utility */ -static void -rss_read_error (RSSChannelData *channel_data) -{ - char *error_message; - - channel_data->update_in_progress = FALSE; - error_message = g_strdup_printf (_("Couldn't load %s"), channel_data->name); - nautilus_news_set_title (channel_data, error_message); - g_free (error_message); -} - -/* utility routine to extract the title from a standard rss document. Return TRUE - * if we find a valid title. - */ -static gboolean -extract_rss_title (RSSChannelData *channel_data, xmlDoc *rss_document) -{ - gboolean got_title; - xmlNode *channel_node, *temp_node; - char *title, *temp_str; - - got_title = FALSE; - channel_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "channel"); - if (channel_node != NULL) { - temp_node = eel_xml_get_child_by_name (channel_node, "title"); - if (temp_node != NULL) { - title = xmlNodeGetContent (temp_node); - if (title != NULL) { - nautilus_news_set_title (channel_data, title); - got_title = TRUE; - xmlFree (title); - } - } - - temp_node = eel_xml_get_child_by_name (channel_node, "link"); - if (temp_node != NULL) { - temp_str = xmlNodeGetContent (temp_node); - if (temp_str != NULL) { - g_free (channel_data->node_data.uri); - channel_data->node_data.uri = g_strdup (temp_str); - xmlFree (temp_str); - } - } - - } - return got_title; -} - -/* extract the title for the scripting news variant format */ -static gboolean -extract_scripting_news_title (RSSChannelData *channel_data, xmlDoc *rss_document) -{ - gboolean got_title; - xmlNode *channel_node, *temp_node; - char *title, *temp_str; - - got_title = FALSE; - channel_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "header"); - if (channel_node != NULL) { - temp_node = eel_xml_get_child_by_name (channel_node, "channelTitle"); - if (temp_node != NULL) { - title = xmlNodeGetContent (temp_node); - if (title != NULL) { - nautilus_news_set_title (channel_data, title); - got_title = TRUE; - xmlFree (title); - } - } - temp_node = eel_xml_get_child_by_name (channel_node, "channelLink"); - if (temp_node != NULL) { - temp_str = xmlNodeGetContent (temp_node); - if (temp_str != NULL) { - g_free (channel_data->node_data.uri); - channel_data->node_data.uri = g_strdup (temp_str); - xmlFree (temp_str); - } - } - - } - return got_title; -} - -/* utility routine to extract the logo image from a standard rss file and start loading it; - * return true if we get one - */ -static gboolean -extract_rss_image (RSSChannelData *channel_data, xmlDoc *rss_document) -{ - gboolean got_image; - xmlNode *image_node, *uri_node; - xmlNode *channel_node; - char *image_uri; - - got_image = FALSE; - image_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "image"); - - /* if we can't find it at the top level, look inside the channel */ - if (image_node == NULL) { - channel_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "channel"); - if (channel_node != NULL) { - image_node = eel_xml_get_child_by_name (channel_node, "image"); - } - } - - if (image_node != NULL) { - uri_node = eel_xml_get_child_by_name (image_node, "url"); - if (uri_node != NULL) { - image_uri = xmlNodeGetContent (uri_node); - if (image_uri != NULL) { - channel_data->load_image_handle = eel_gdk_pixbuf_load_async (image_uri, - GNOME_VFS_PRIORITY_DEFAULT, rss_logo_callback, channel_data); - got_image = TRUE; - xmlFree (image_uri); - } - } - } - return got_image; -} - -/* utility routine to extract the logo image from a scripting news format rss file and start loading it; - * return true if we get one - */ -static gboolean -extract_scripting_news_image (RSSChannelData *channel_data, xmlDoc *rss_document) -{ - gboolean got_image; - xmlNode *image_node, *header_node; - char *image_uri; - - got_image = FALSE; - header_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "header"); - if (header_node != NULL) { - image_node = eel_xml_get_child_by_name (header_node, "imageUrl"); - if (image_node != NULL) { - image_uri = xmlNodeGetContent (image_node); - if (image_uri != NULL) { - channel_data->load_image_handle = eel_gdk_pixbuf_load_async (image_uri, - GNOME_VFS_PRIORITY_DEFAULT, rss_logo_callback, channel_data); - got_image = TRUE; - xmlFree (image_uri); - } - - } - } - return got_image; -} - - -/* completion routine invoked when we've loaded the rss file uri. Parse the xml document, and - * then extract the various elements that we require. - */ -static void -rss_read_done_callback (GnomeVFSResult result, - GnomeVFSFileSize file_size, - char *file_contents, - gpointer callback_data) -{ - xmlDocPtr rss_document; - xmlNodePtr channel_node, current_node; - GList *old_items; - int item_count, changed_count; - RSSChannelData *channel_data; - xmlSAXHandler silent_handler; - - char *buffer; - - channel_data = (RSSChannelData*) callback_data; - channel_data->load_file_handle = NULL; - - /* make sure the read was successful */ - if (result != GNOME_VFS_OK) { - g_assert (file_contents == NULL); - rss_read_error (channel_data); - return; - } - - /* flag the update time */ - time (&channel_data->last_update); - - /* 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'; - - 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) { - rss_read_error (channel_data); - return; - } - - /* set the title to the channel name, in case we don't get anything better from the file */ - nautilus_news_set_title (channel_data, channel_data->name); - channel_node = eel_xml_get_child_by_name (xmlDocGetRootElement (rss_document), "channel"); - - if (!extract_rss_title (channel_data, rss_document)) { - extract_scripting_news_title (channel_data, rss_document); - } - - /* extract the image uri and, if found, load it asynchronously; don't refetch if we already have one */ - if (channel_data->node_data.pixbuf == NULL && channel_data->load_image_handle == NULL) { - if (!extract_rss_image (channel_data, rss_document)) { - extract_scripting_news_image (channel_data, rss_document); - } - } - - /* extract the items */ - old_items = channel_data->items; - channel_data->items = NULL; - - current_node = xmlDocGetRootElement (rss_document); - - item_count = extract_items (channel_data, current_node); - - /* if we couldn't find any items at the main level, look inside the channel node */ - if (item_count == 0 && channel_node != NULL) { - item_count = extract_items (channel_data, channel_node); - } - - changed_count = mark_new_items (channel_data, old_items); - - update_items (channel_data, old_items); - set_row_widths (channel_data->owner); - - /* we're done, so free everything up */ - eel_g_list_free_deep_custom (old_items, (GFunc) free_rss_data_item, NULL); - xmlFreeDoc (rss_document); - channel_data->update_in_progress = FALSE; - channel_data->initial_load_flag = FALSE; -} - -static void -nautilus_news_insert_channel (News *news_data, - RSSChannelData *channel_data, - int pos) -{ - GtkTreeIter iter; - GtkTreePath *path; - - g_return_if_fail (channel_data->is_showing); - g_return_if_fail (channel_data->node_data.path == NULL); - - gtk_tree_store_insert (GTK_TREE_STORE (news_data->news_model), - &iter, NULL, pos); - gtk_tree_store_set (GTK_TREE_STORE (news_data->news_model), - &iter, - NEWS_COL_DATA, channel_data, - NEWS_COL_WIDTH, -1, - -1); - - path = gtk_tree_model_get_path (news_data->news_model, - &iter); - channel_data->node_data.path = path; -} - -/* initiate the loading of a channel, by fetching the rss file through gnome-vfs */ -static void -nautilus_news_load_channel (News *news_data, RSSChannelData *channel_data) -{ - char *title; - - /* don't load if it's not showing, or it's already loading */ - if (!channel_data->is_showing || channel_data->update_in_progress || - channel_data->load_file_handle != NULL) { - return; - } - - /* load the uri asynchronously, calling a completion routine when completed */ - channel_data->update_in_progress = TRUE; - channel_data->load_file_handle = eel_read_entire_file_async (channel_data->uri, - GNOME_VFS_PRIORITY_DEFAULT, rss_read_done_callback, channel_data); - - /* put up a title that's displayed while we wait */ - title = g_strdup_printf (_("Loading %s"), channel_data->name); - nautilus_news_set_title (channel_data, title); - g_free (title); -} - -/* detach items from the tree by clearing their path and taking them out - of the uri hash table */ -static void -detach_items (News *news, GList *items) -{ - GList *item; - RSSItemData *item_data; - - item = items; - while (item) { - item_data = (RSSItemData *)item->data; - - if (item_data->node_data.path) { - gtk_tree_path_free (item_data->node_data.path); - item_data->node_data.path = NULL; - } - - if (item_data->node_data.uri) { - g_hash_table_remove (news->item_uris, - item_data->node_data.uri); - } - - item = item->next; - } -} - - -static void -remove_items (RSSChannelData *channel_data, GList *items) -{ - int num_children; - GtkTreeIter parent_iter; - GtkTreeIter iter; - - detach_items (channel_data->owner, items); - - gtk_tree_model_get_iter (channel_data->owner->news_model, - &parent_iter, channel_data->node_data.path); - - num_children = gtk_tree_model_iter_n_children (channel_data->owner->news_model, - &parent_iter); - gtk_tree_model_iter_children (channel_data->owner->news_model, - &iter, &parent_iter); - - while (num_children != 0) { - gtk_tree_store_remove (GTK_TREE_STORE (channel_data->owner->news_model), - &iter); - num_children--; - } - - -} - -static void -update_channels (News *news_data) -{ - GList *channel_item; - RSSChannelData *channel_data; - gboolean was_showing; - - gtk_tree_store_clear (GTK_TREE_STORE (news_data->news_model)); - - channel_item = news_data->channel_list; - while (channel_item != NULL) { - channel_data = (RSSChannelData*) channel_item->data; - - if (channel_data->node_data.path) { - gtk_tree_path_free (channel_data->node_data.path); - channel_data->node_data.path = NULL; - - detach_items (news_data, channel_data->items); - - was_showing = TRUE; - } else { - was_showing = FALSE; - } - - if (channel_data->is_showing) { - nautilus_news_insert_channel (news_data, - channel_data, -1); - if (was_showing) { - update_items (channel_data, NULL); - } else { - nautilus_news_load_channel (news_data, - channel_data); - } - } - - channel_item = channel_item->next; - } - set_row_widths (news_data); -} - -static void -update_items (RSSChannelData *channel_data, GList *old_items) -{ - GtkTreeIter parent_iter; - GtkTreeIter iter; - GtkTreePath *path; - GList *item; - RSSItemData *item_data; - int pos; - - g_return_if_fail (channel_data->node_data.path != NULL); - - remove_items (channel_data, old_items); - - gtk_tree_model_get_iter (channel_data->owner->news_model, - &parent_iter, channel_data->node_data.path); - - pos = 0; - item = channel_data->items; - while (item && pos < channel_data->owner->max_item_count) { - item_data = (RSSItemData *)item->data; - item_data->node_data.markup = get_item_markup (item_data); - - if (item_data->new_item && (channel_data->owner->changed_bullet != NULL)) { - item_data->node_data.pixbuf = channel_data->owner->changed_bullet; - item_data->node_data.prelight_pixbuf = channel_data->owner->prelight_changed_bullet; - } else { - item_data->node_data.pixbuf = channel_data->owner->bullet; - item_data->node_data.prelight_pixbuf = channel_data->owner->prelit_bullet; - } - - gtk_tree_store_insert (GTK_TREE_STORE (channel_data->owner->news_model), - &iter, &parent_iter, pos++); - gtk_tree_store_set (GTK_TREE_STORE (channel_data->owner->news_model), - &iter, - NEWS_COL_DATA, - item_data, - NEWS_COL_WIDTH, - -1, - -1); - path = gtk_tree_model_get_path (channel_data->owner->news_model, - &iter); - item_data->node_data.path = path; - - g_hash_table_insert (channel_data->owner->item_uris, - item_data->node_data.uri, - item_data); - - item = item->next; - } - - if (channel_data->is_open) { - gtk_tree_view_expand_row (GTK_TREE_VIEW (channel_data->owner->news_display), - channel_data->node_data.path, - TRUE); - } -} - -/* create a new channel object and initialize it, and start loading the content */ -static RSSChannelData* -nautilus_news_make_new_channel (News *news_data, - const char *name, - const char* channel_uri, - gboolean is_open, - gboolean is_showing) -{ - RSSChannelData *channel_data; - - channel_data = g_new0 (RSSChannelData, 1); - channel_data->name = g_strdup (name); - channel_data->uri = g_strdup (channel_uri); - channel_data->owner = news_data; - channel_data->is_open = is_open; - channel_data->is_showing = is_showing; - channel_data->initial_load_flag = TRUE; - - return channel_data; -} - -/* comparison routine to put channels in alphabetical order */ -static gint -compare_channel_names (RSSChannelData *channel_1, RSSChannelData *channel_2) -{ - return strcmp (channel_1->name, channel_2->name); -} - -/* add the channels defined in the passed in xml document to the channel list, - * and start fetching the actual channel data - */ -static void -nautilus_news_add_channels (News *news_data, xmlDocPtr channels) -{ - xmlNodePtr current_channel; - RSSChannelData *channel_data; - char *uri, *name; - char *open_str, *show_str; - gboolean is_open, is_showing; - - /* walk through the children of the root object, generating new channel - * objects and adding them to the channel list - */ - current_channel = xmlDocGetRootElement (channels)->children; - while (current_channel != NULL) { - if (eel_strcmp (current_channel->name, "rss_channel") == 0) { - name = xmlGetProp (current_channel, "name"); - uri = xmlGetProp (current_channel, "uri"); - open_str = xmlGetProp (current_channel, "open"); - show_str = xmlGetProp (current_channel, "show"); - - if (uri != NULL) { - is_open = eel_strcasecmp (open_str, "true") == 0; - is_showing = eel_strcasecmp (show_str, "true") == 0; - - channel_data = nautilus_news_make_new_channel (news_data, name, uri, is_open, is_showing); - xmlFree (uri); - if (channel_data != NULL) { - news_data->channel_list = g_list_insert_sorted (news_data->channel_list, - channel_data, - (GCompareFunc) compare_channel_names); - } - } - xmlFree (open_str); - xmlFree (show_str); - xmlFree (name); - } - current_channel = current_channel->next; - } -} - -static char* -get_xml_path (const char *file_name, gboolean force_local) -{ - char *xml_path; - char *user_directory; - - user_directory = nautilus_get_user_directory (); - - /* first try the user's home directory */ - xml_path = g_build_filename (user_directory, - file_name, - NULL); - g_free (user_directory); - if (force_local || g_file_test (xml_path, G_FILE_TEST_EXISTS)) { - return xml_path; - } - g_free (xml_path); - - /* next try the shared directory */ - xml_path = g_build_filename (NAUTILUS_DATADIR, - file_name, - NULL); - if (g_file_test (xml_path, G_FILE_TEST_EXISTS)) { - return xml_path; - } - g_free (xml_path); - - return NULL; -} - -/* read the channel definition xml file and load the channels */ -static void -read_channel_list (News *news_data) -{ - char *path; - xmlDocPtr channel_doc; - - /* free the old channel data, if any */ - nautilus_news_free_channel_list (news_data); - - /* get the path to the local copy of the channels file */ - path = get_xml_path ("news_channels.xml", FALSE); - if (path != NULL) { - channel_doc = xmlParseFile (path); - - if (channel_doc) { - nautilus_news_add_channels (news_data, channel_doc); - xmlFreeDoc (channel_doc); - } - g_free (path); - } -} - -/* handle periodically updating the channels if necessary */ -static int -check_for_updates (gpointer callback_data) -{ - News *news_data; - guint current_time, next_update_time; - GList *current_item; - RSSChannelData *channel_data; - - news_data = (News*) callback_data; - current_time = time (NULL); - - /* loop through the channel list, checking to see if any need updating */ - current_item = news_data->channel_list; - while (current_item != NULL) { - channel_data = (RSSChannelData*) current_item->data; - next_update_time = channel_data->last_update + channel_data->owner->update_interval; - - if (current_time > next_update_time && !channel_data->update_in_progress && channel_data->is_showing) { - nautilus_news_load_channel (news_data, channel_data); - } - current_item = current_item->next; - } - - return TRUE; -} - -/* return an image if there is a new article since last viewing, otherwise return NULL */ -static char * -news_get_indicator_image (News *news_data) -{ - if (news_data->news_changed) { - return g_strdup ("changed_bullet.png"); - } - return NULL; -} - -/* utility routine to load images needed by the news view */ -static void -nautilus_news_load_images (News *news_data) -{ - char *news_bullet_path; - - if (news_data->bullet != NULL) { - g_object_unref (news_data->bullet); - } - if (news_data->prelit_bullet != NULL) { - g_object_unref (news_data->prelit_bullet); - } - - news_bullet_path = nautilus_theme_get_image_path ("news_bullet.png"); - if (news_bullet_path != NULL) { - news_data->bullet = gdk_pixbuf_new_from_file (news_bullet_path, NULL); - news_data->prelit_bullet = eel_create_spotlight_pixbuf (news_data->bullet); - g_free (news_bullet_path); - } - - if (news_data->changed_bullet != NULL) { - g_object_unref (news_data->changed_bullet); - } - if (news_data->prelight_changed_bullet != NULL) { - g_object_unref (news_data->prelight_changed_bullet); - } - - news_bullet_path = nautilus_theme_get_image_path ("changed_bullet.png"); - if (news_bullet_path != NULL) { - news_data->changed_bullet = gdk_pixbuf_new_from_file (news_bullet_path, NULL); - news_data->prelight_changed_bullet = eel_create_spotlight_pixbuf (news_data->changed_bullet); - g_free (news_bullet_path); - } -} - -static void -nautilus_news_cell_data_func (GtkTreeViewColumn *column, - GtkCellRenderer *cell, - GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - RSSNodeData *node_data; - int cell_width; - - gtk_tree_model_get (model, iter, - NEWS_COL_DATA, &node_data, - NEWS_COL_WIDTH, &cell_width, - -1); - - if (node_data) { - g_object_set (GTK_CELL_RENDERER (cell), "bullet", - node_data->pixbuf, NULL); - g_object_set (GTK_CELL_RENDERER (cell), "prelit_bullet", - node_data->prelight_pixbuf, NULL); - g_object_set (GTK_CELL_RENDERER (cell), "markup", node_data->markup); - g_object_set (GTK_CELL_RENDERER (cell), "wrap_at", - cell_width, NULL); - } -} - -static void -nautilus_news_row_expanded (GtkTreeView *tree_view, - GtkTreeIter *iter, - GtkTreePath *path, - gpointer data) -{ - News *news = (News*)data; - RSSChannelData *channel_data; - g_return_if_fail (gtk_tree_path_get_depth (path) == 1); - - gtk_tree_model_get (news->news_model, iter, - NEWS_COL_DATA, &channel_data, - -1); - - channel_data->is_open = TRUE; -} - -static void -nautilus_news_row_collapsed (GtkTreeView *tree_view, - GtkTreeIter *iter, - GtkTreePath *path, - gpointer data) -{ - News *news = (News*)data; - RSSChannelData *channel_data; - g_return_if_fail (gtk_tree_path_get_depth (path) == 1); - - gtk_tree_model_get (news->news_model, iter, - NEWS_COL_DATA, &channel_data, - -1); - - channel_data->is_open = FALSE; -} - -/* handle preference changes */ -static void -max_items_changed (gpointer user_data) -{ - News *news; - - news = (News*) user_data; - - news->max_item_count = eel_preferences_get_integer (NAUTILUS_PREFERENCES_NEWS_MAX_ITEMS); - if (news->max_item_count <= 0) { - news->max_item_count = 2; - } -} - -static void -update_interval_changed (gpointer user_data) -{ - News *news; - - news = (News*) user_data; - - news->update_interval = 60 * eel_preferences_get_integer (NAUTILUS_PREFERENCES_NEWS_UPDATE_INTERVAL); - if (news->update_interval < 60) { - news->update_interval = 60; - } -} - -/* utility to count the visible channels */ -static int -count_visible_channels (News *news) -{ - GList *current_item; - RSSChannelData *current_channel; - int visible_count; - - visible_count = 0; - current_item = news->channel_list; - while (current_item != NULL) { - current_channel = (RSSChannelData *) current_item->data; - if (current_channel->is_showing) { - visible_count += 1; - } - current_item = current_item->next; - } - return visible_count; -} - -/* utility to show and hide the views based on the mode */ -static void -set_views_for_mode (News *news) -{ - gtk_notebook_set_current_page (GTK_NOTEBOOK (news->main_container), - news->current_page); - - if (news->current_page == PAGE_MAIN) { - if (count_visible_channels (news) == 0) { - gtk_notebook_set_current_page (GTK_NOTEBOOK (news->news_notebook), MAIN_PAGE_EMPTY); - } else { - gtk_notebook_set_current_page (GTK_NOTEBOOK (news->news_notebook), MAIN_PAGE_DISPLAY); - } - } -} - -static void -switch_page (News *news, NewsPageNum page) -{ - if (news->current_page == PAGE_CONFIGURE) { - nautilus_news_save_channel_state (news); - } - - news->current_page = page; - set_views_for_mode (news); - - if (page == PAGE_MAIN) { - update_channels (news); - check_for_updates (news); - } -} - -/* here's the button callback routine that toggles between display modes */ -static void -configure_button_clicked (GtkWidget *widget, News *news) -{ - if (news->current_page == PAGE_CONFIGURE) { - switch_page (news, PAGE_MAIN); - } else { - switch_page (news, PAGE_CONFIGURE); - } -} - -/* here's the button callback routine that handles the add new site button - * by showing the relevant widgets. - */ -static void -add_site_button_clicked (GtkWidget *widget, News *news) -{ - switch_page (news, PAGE_ADD_SITE); -} - - -/* utility to add an entry to the remove channel clist */ -static void -add_channel_to_remove_list (News *news_data, const char *channel_name) -{ - GtkTreeIter iter; - GtkListStore *store; - store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (news_data->remove_site_list))); - - gtk_list_store_append (store, &iter); - gtk_list_store_set (store, &iter, REMOVE_COL_NAME, channel_name, -1); -} - -static void -update_remove_button (News *news) -{ - GtkTreeSelection *selection; - GtkTreeIter iter; - gboolean sensitive; - - sensitive = FALSE; - if (news->channel_list != NULL) { - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (news->remove_site_list)); - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { - sensitive = TRUE; - } - } - - gtk_widget_set_sensitive (news->remove_button, sensitive); -} - -/* handle adding a new site from the data in the "add site" fields */ -static void -add_site_from_fields (GtkWidget *widget, News *news) -{ - char *site_name, *site_location; - char *site_uri, *buffer; - RSSChannelData *channel_data; - GnomeVFSResult result; - int channel_count, byte_count; - gboolean got_xml_file; - - site_name = (char *) gtk_entry_get_text (GTK_ENTRY (news->item_name_field)); - site_location = (char *)gtk_entry_get_text (GTK_ENTRY (news->item_location_field)); - - /* make sure there's something in the fields */ - if (site_name == NULL || strlen (site_name) == 0) { - eel_show_error_dialog (_("Sorry, but you have not specified a name for the site."), - _("Please specify a name and try again."), _("Missing Site Name Error"), NULL); - return; - } - if (site_location == NULL || strlen (site_location) == 0) { - eel_show_error_dialog (_("Sorry, but you have not specified a URL for the site."), - _("Please specify a URL and try again."), _("Missing URL Error"), NULL); - return; - } - - /* if there isn't a protocol specified for the location, use http */ - if (strchr (site_location, ':') == NULL) { - site_uri = g_strconcat ("http://", site_location, NULL); - } else { - site_uri = g_strdup (site_location); - } - - /* verify that we can read the specified location and that it's an xml file */ - result = eel_read_entire_file (site_uri, &byte_count, &buffer); - got_xml_file = (result == GNOME_VFS_OK) && eel_istr_has_prefix (buffer, "<?xml"); - g_free (buffer); - if (!got_xml_file) { - g_free (site_uri); - eel_show_error_dialog (_("Sorry, but the specified url doesn't seem to be a valid RSS file."), - _("Please check the spelling of the url."), _("Invalid RSS URL"), NULL); - return; - } - - /* make the new channel */ - channel_data = nautilus_news_make_new_channel (news, site_name, site_uri, TRUE, TRUE); - g_free (site_uri); - - if (channel_data != NULL) { - news->channel_list = g_list_insert_sorted (news->channel_list, - channel_data, - (GCompareFunc) compare_channel_names); - channel_count = g_list_length (news->channel_list); - add_channel_entry (news, site_name, channel_count, TRUE); - add_channel_to_remove_list (news, site_name); - } - /* clear fields for next time */ - gtk_editable_delete_text (GTK_EDITABLE (news->item_name_field), 0, -1); - gtk_editable_delete_text (GTK_EDITABLE (news->item_location_field), 0, -1); - - update_remove_button (news); - - /* back to configure mode */ - switch_page (news, PAGE_CONFIGURE); -} - -/* handle the remove command */ -static void -remove_selected_site (GtkWidget *widget, News *news) -{ - GtkTreeSelection *selection; - GtkTreeIter iter; - RSSChannelData *channel_data; - GList *channel_item; - const char *channel_name; - GValue channel_name_value = { 0, }; - - GtkTreeModel *model; - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (news->remove_site_list)); - model = gtk_tree_view_get_model (GTK_TREE_VIEW (news->remove_site_list)); - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) { - gtk_tree_model_get_value (model, - &iter, - REMOVE_COL_NAME, - &channel_name_value); - - channel_name = g_value_get_string (&channel_name_value); - - /* remove the channel from the channel linked list */ - channel_data = get_channel_from_name (news, channel_name); - - channel_item = g_list_find (news->channel_list, channel_data); - if (channel_item != NULL) { - news->channel_list = g_list_remove_link (news->channel_list, channel_item); - } - - /* remove the channel from the add list and release it */ - if (channel_data != NULL) { - gtk_widget_destroy (channel_data->checkbox); - free_channel (channel_data); - } - - gtk_list_store_remove (GTK_LIST_STORE (model), - &iter); - update_remove_button (news); - switch_page (news, PAGE_CONFIGURE); - } -} - -/* utility routine to create the button box and constituent buttons */ -static GtkWidget * -add_command_buttons (News *news_data, const char* label, gboolean from_configure) -{ - GtkWidget *frame; - GtkWidget *button_box; - GtkWidget *button; - - frame = gtk_frame_new (NULL); - gtk_frame_set_shadow_type( GTK_FRAME (frame), GTK_SHADOW_OUT); - - button_box = gtk_hbutton_box_new (); - - gtk_container_set_border_width (GTK_CONTAINER (button_box), 2); - gtk_widget_show (button_box); - gtk_container_add (GTK_CONTAINER (frame), button_box); - - /* Set the appearance of the Button Box */ - gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (button_box), 4); - - if (from_configure) { - button = gtk_button_new_with_mnemonic (_("Edi_t")); - gtk_widget_show (button); - gtk_container_add (GTK_CONTAINER (button_box), button); - - g_signal_connect (button, "clicked", - G_CALLBACK (add_site_button_clicked), news_data); - } - - button = gtk_button_new_from_stock (label); - gtk_widget_show (button); - gtk_container_add (GTK_CONTAINER (button_box), button); - - g_signal_connect (button, "clicked", - G_CALLBACK (configure_button_clicked), news_data); - - return frame; -} - -/* utility routine to look up a channel from it's name */ -static RSSChannelData* -get_channel_from_name (News *news_data, const char *channel_name) -{ - GList *channel_item; - RSSChannelData *channel_data; - - channel_item = news_data->channel_list; - while (channel_item != NULL) { - channel_data = (RSSChannelData*) channel_item->data; - if (eel_strcasecmp (channel_data->name, channel_name) == 0) { - return channel_data; - } - channel_item = channel_item->next; - } - return NULL; -} - -/* here's the handler for handling clicks in channel check boxes */ -static void -check_button_toggled_callback (GtkToggleButton *toggle_button, gpointer user_data) -{ - News *news_data; - char *channel_name; - RSSChannelData *channel_data; - - news_data = (News*) user_data; - channel_name = g_object_get_data (G_OBJECT (toggle_button), "channel_name"); - - channel_data = get_channel_from_name (news_data, channel_name); - if (channel_data != NULL) { - channel_data->is_showing = !channel_data->is_showing; - if (channel_data->is_showing) { - channel_data->is_open = TRUE; - } - } -} - -static gboolean -check_button_focus_in_callback (GtkWidget *widget, - GdkEventFocus *event, - gpointer data) -{ - g_return_val_if_fail (widget->parent && widget->parent->parent, FALSE); - g_return_val_if_fail (GTK_IS_VIEWPORT (widget->parent->parent), FALSE); - - eel_gtk_viewport_scroll_to_rect (GTK_VIEWPORT (widget->parent->parent), - &widget->allocation); - - return FALSE; -} - - -/* callback to maintain the current location */ -static void -nautilus_news_load_location (NautilusView *view, const char *location, News *news) -{ - RSSItemData *item; - char *markup; - char *bold; - - if (news->current_item) { - if (news->current_item->node_data.markup) { - g_free (news->current_item->node_data.markup); - } - news->current_item->node_data.markup = - get_item_markup (news->current_item); - update_node (news, (RSSNodeData*)news->current_item); - - news->current_item = NULL; - } - - item = g_hash_table_lookup (news->item_uris, location); - if (item) { - markup = get_item_markup (item); - if (markup) { - bold = g_strdup_printf ("<b>%s</b>", markup); - g_free (markup); - - } else { - bold = NULL; - } - - if (item->node_data.markup) { - g_free (item->node_data.markup); - } - item->node_data.markup = bold; - - update_node (news, (RSSNodeData *)item); - - news->current_item = item; - } -} - -/* utility routine to determine the sort position of a checkbox */ -static int -determine_sort_position (GtkWidget *container, const char *name) -{ - GList *checkboxes, *current_item; - char *current_name; - int index; - - checkboxes = gtk_container_get_children (GTK_CONTAINER (container)); - index = 0; - current_item = checkboxes; - while (current_item != NULL) { - current_name = g_object_get_data (G_OBJECT (current_item->data), "channel_name"); - - if (eel_strcasecmp (current_name, name) > 0) { - g_list_free (checkboxes); - return index; - } - - index += 1; - current_item = current_item->next; - } - g_list_free (checkboxes); - return index; -} - -/* utility routine to add a check-box entry to the channel list */ -static void -add_channel_entry (News *news_data, const char *channel_name, int index, gboolean is_showing) -{ - GtkWidget *check_button; - RSSChannelData *channel_data; - int sort_position; - - check_button = gtk_check_button_new_with_label (channel_name); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (check_button), is_showing); - gtk_widget_show (check_button); - gtk_box_pack_start (GTK_BOX (news_data->checkbox_list), check_button, FALSE, FALSE, 0); - - g_signal_connect (check_button, "toggled", - G_CALLBACK (check_button_toggled_callback), - news_data); - g_signal_connect (check_button, "focus_in_event", - G_CALLBACK (check_button_focus_in_callback), - news_data); - - /* reorder newly added button so it's sorted by it's name */ - sort_position = determine_sort_position (news_data->checkbox_list, channel_name); - gtk_box_reorder_child (GTK_BOX (news_data->checkbox_list), check_button, sort_position); - - /* set up pointer in channel object to checkbox, so we can delete it */ - channel_data = get_channel_from_name (news_data, channel_name); - if (channel_data != NULL) { - channel_data->checkbox = check_button; - } - - /* set up user data to use in toggle handler */ - g_object_set_data (G_OBJECT (check_button), "user_data", news_data); - g_object_set_data_full (G_OBJECT(check_button), - "channel_name", - g_strdup (channel_name), - g_free); -} - -/* here's the routine that loads and parses the xml file, then iterates through it - * to add channels to the enable/disable lists - */ -static void -add_channels_to_lists (News* news_data) -{ - char *path; - char *channel_name, *show_str; - xmlDocPtr channel_doc; - xmlNodePtr current_channel; - int channel_index; - gboolean is_shown; - - /* read the xml file and parse it */ - path = get_xml_path ("news_channels.xml", FALSE); - if (path == NULL) { - return; - } - - channel_doc = xmlParseFile (path); - g_free (path); - if (channel_doc == NULL) { - return; - } - - /* loop through the channel entries, adding an entry to the configure - * list for each entry in the file - */ - current_channel = xmlDocGetRootElement (channel_doc)->children; - channel_index = 0; - while (current_channel != NULL) { - if (eel_strcmp (current_channel->name, "rss_channel") == 0) { - channel_name = xmlGetProp (current_channel, "name"); - show_str = xmlGetProp (current_channel, "show"); - is_shown = eel_strcasecmp (show_str, "true") == 0; - - /* add an entry to the channel list */ - if (channel_name != NULL) { - add_channel_entry (news_data, channel_name, channel_index, is_shown); - add_channel_to_remove_list (news_data, channel_name); - - channel_index += 1; - } - - xmlFree (show_str); - xmlFree (channel_name); - } - current_channel = current_channel->next; - } - - xmlFreeDoc (channel_doc); -} - -/* code-saving utility to allocate a left-justified anti-aliased label */ -static GtkWidget * -news_label_new (const char *label_text, gboolean title_mode) -{ - GtkWidget *label; - - label = gtk_label_new_with_mnemonic (label_text); - if (title_mode) { - eel_gtk_label_make_bold (GTK_LABEL (label)); - } - - gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - - return label; -} - -static void -remove_list_selection_changed (GObject *obj, News *news) -{ - update_remove_button (news); -} - -/* generate the remove widgets */ -static void -make_remove_widgets (News *news, GtkWidget *container) -{ - GtkWidget *button_box; - GtkScrolledWindow *scrolled_window; - GtkListStore *store; - GtkCellRenderer *renderer; - GtkTreeViewColumn *column; - GtkTreeSelection *selection; - - store = gtk_list_store_new (LAST_REMOVE_COL, G_TYPE_STRING); - - news->remove_site_list = - gtk_tree_view_new_with_model (GTK_TREE_MODEL (store)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (news->remove_site_list), FALSE); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (news->remove_site_list)); - gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); - g_signal_connect (selection, "changed", - G_CALLBACK (remove_list_selection_changed), news); - - renderer = gtk_cell_renderer_text_new (); - column = gtk_tree_view_column_new_with_attributes (_("Site Name"), - renderer, - "text", - REMOVE_COL_NAME, - NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (news->remove_site_list), - column); - g_object_unref (store); - - gtk_widget_show (news->remove_site_list); - - scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); - gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (scrolled_window, - GTK_SHADOW_IN); - gtk_widget_show (GTK_WIDGET (scrolled_window)); - gtk_container_add (GTK_CONTAINER (scrolled_window), news->remove_site_list); - gtk_box_pack_start (GTK_BOX (container), GTK_WIDGET (scrolled_window), TRUE, TRUE, 0); - - /* install the remove button */ - button_box = gtk_hbutton_box_new (); - gtk_box_pack_start (GTK_BOX (container), button_box, FALSE, FALSE, 4); - - gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (button_box), 4); - - news->remove_button = gtk_button_new_with_mnemonic (_("_Remove Site")); - gtk_widget_show (news->remove_button); - - gtk_container_add (GTK_CONTAINER (button_box), news->remove_button); - - gtk_widget_show (button_box); - - g_signal_connect (news->remove_button, "clicked", - (GtkSignalFunc) remove_selected_site, news); -} - -/* generate the add new site widgets */ -static void -make_add_widgets (News *news, GtkWidget *container) -{ - GtkWidget *label; - GtkWidget *temp_vbox; - GtkWidget *button_box; - GtkWidget *button; - - temp_vbox = gtk_vbox_new (FALSE, 0); - gtk_widget_show (temp_vbox); - - gtk_box_pack_start (GTK_BOX (container), temp_vbox, FALSE, FALSE, 0); - - /* allocate the name field */ - label = news_label_new (_("Site _Name:"), FALSE); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (temp_vbox), label, FALSE, FALSE, 0); - - news->item_name_field = nautilus_entry_new (); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), - news->item_name_field); - - gtk_widget_show (news->item_name_field); - gtk_box_pack_start (GTK_BOX (temp_vbox), news->item_name_field, FALSE, FALSE, 0); - nautilus_undo_editable_set_undo_key (GTK_EDITABLE (news->item_name_field), TRUE); - - /* allocate the location field */ - temp_vbox = gtk_vbox_new (FALSE, 0); - gtk_widget_show (temp_vbox); - - gtk_box_pack_start (GTK_BOX (container), temp_vbox, FALSE, FALSE, 0); - - label = news_label_new (_("Site _RSS URL:"), FALSE); - gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (temp_vbox), label, FALSE, FALSE, 0); - - news->item_location_field = nautilus_entry_new (); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), - news->item_location_field); - gtk_widget_show (news->item_location_field); - gtk_box_pack_start (GTK_BOX (temp_vbox), news->item_location_field, FALSE, FALSE, 0); - nautilus_undo_editable_set_undo_key (GTK_EDITABLE (news->item_location_field), TRUE); - - /* install the add buttons */ - button_box = gtk_hbutton_box_new (); - gtk_widget_show (button_box); - - gtk_box_pack_start (GTK_BOX (container), button_box, FALSE, FALSE, 4); - - gtk_button_box_set_layout (GTK_BUTTON_BOX (button_box), GTK_BUTTONBOX_END); - gtk_box_set_spacing (GTK_BOX (button_box), 4); - - button = gtk_button_new_with_mnemonic (_("_Add New Site")); - gtk_widget_show (button); - - gtk_container_add (GTK_CONTAINER (button_box), button); - g_signal_connect (button, "clicked", - G_CALLBACK (add_site_from_fields), news); -} - -/* allocate the add/remove location widgets */ -static void -set_up_edit_widgets (News *news, GtkWidget *container) -{ - GtkWidget *label; - GtkWidget *expand_box; - GtkWidget *button_box; - GtkWidget *temp_vbox; - - news->edit_site_box = gtk_vbox_new (FALSE, 0); - gtk_widget_show (news->edit_site_box); - - gtk_notebook_insert_page (GTK_NOTEBOOK (container), - news->edit_site_box, NULL, PAGE_ADD_SITE); - - expand_box = gtk_vbox_new (FALSE, 0); - gtk_widget_show (expand_box); - - gtk_box_pack_start (GTK_BOX (news->edit_site_box), expand_box, TRUE, TRUE, 0); - gtk_container_set_border_width (GTK_CONTAINER (expand_box), 4); - - /* make the add new site label */ - label = news_label_new (_("Add a New Site:"), TRUE); - gtk_widget_show (label); - - gtk_box_pack_start (GTK_BOX (expand_box), label, FALSE, FALSE, 0); - - /* allocate the add new site widgets */ - make_add_widgets (news, expand_box); - - /* allocate the remove label */ - temp_vbox = gtk_vbox_new (FALSE, 0); - - label = news_label_new (_("Remove a _Site:"), TRUE); - gtk_widget_show (label); - - gtk_box_pack_start (GTK_BOX (temp_vbox), label, FALSE, FALSE, 0); - gtk_widget_show (temp_vbox); - - /* allocate the remove widgets */ - make_remove_widgets (news, temp_vbox); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), - news->remove_site_list); - - gtk_box_pack_start (GTK_BOX (expand_box), temp_vbox, TRUE, TRUE, 0); - - /* add the button box at the bottom with a cancel button */ - button_box = add_command_buttons (news, GTK_STOCK_CANCEL, FALSE); - gtk_widget_show (button_box); - gtk_box_pack_start (GTK_BOX (news->edit_site_box), button_box, FALSE, FALSE, 0); -} - -static gboolean -site_list_mnemonic_activate (GtkWidget *widget, gboolean group_cycling, - gpointer data) -{ - News *news; - RSSChannelData *channel_data; - - news = (News*)data; - channel_data = (RSSChannelData*)news->channel_list->data; - - gtk_widget_grab_focus (channel_data->checkbox); - - return TRUE; -} - -/* allocate the widgets for the configure mode */ -static void -set_up_configure_widgets (News *news, GtkWidget *container) -{ - GtkWidget *button_box; - GtkWidget *viewport; - GtkScrolledWindow *scrolled_window; - GtkWidget *label; - - news->configure_box = gtk_vbox_new (FALSE, 0); - gtk_widget_show (news->configure_box); - - gtk_notebook_insert_page (GTK_NOTEBOOK (container), - news->configure_box, NULL, PAGE_CONFIGURE); - - /* add a descriptive label */ - label = news_label_new (_("_Select Sites:"), TRUE); - - gtk_widget_show (label); - - gtk_box_pack_start (GTK_BOX (news->configure_box), label, FALSE, FALSE, 0); - - /* allocate a table to hold the check boxes */ - news->checkbox_list = gtk_vbox_new (FALSE, 0); - g_signal_connect (GTK_WIDGET (news->checkbox_list), - "mnemonic_activate", - G_CALLBACK (site_list_mnemonic_activate), news); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), news->checkbox_list); - - gtk_widget_show (news->checkbox_list); - - scrolled_window = GTK_SCROLLED_WINDOW (gtk_scrolled_window_new (NULL, NULL)); - gtk_scrolled_window_set_policy (scrolled_window, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); - gtk_widget_show (GTK_WIDGET (scrolled_window)); - - viewport = gtk_viewport_new (gtk_scrolled_window_get_hadjustment (scrolled_window), - gtk_scrolled_window_get_vadjustment (scrolled_window)); - gtk_widget_show (viewport); - - gtk_container_add (GTK_CONTAINER (scrolled_window), viewport); - gtk_container_add (GTK_CONTAINER (viewport), news->checkbox_list); - - gtk_box_pack_start (GTK_BOX (news->configure_box), GTK_WIDGET (scrolled_window), TRUE, TRUE, 0); - - /* allocate the button box for the done button */ - button_box = add_command_buttons (news, _("_Done"), TRUE); - gtk_widget_show (button_box); - gtk_box_pack_start (GTK_BOX (news->configure_box), button_box, FALSE, FALSE, 0); -} - -/* allocate the widgets for the main display mode */ -static void -set_up_main_widgets (News *news, GtkWidget *container) -{ - GtkWidget *button_box; - GtkWidget *scrolled_window; - - /* allocate a vbox to hold all of the main UI elements elements */ - news->main_box = gtk_vbox_new (FALSE, 0); - gtk_widget_show (news->main_box); - - gtk_notebook_insert_page (GTK_NOTEBOOK (container), - news->main_box, NULL, PAGE_MAIN); - - news->news_notebook = gtk_notebook_new (); - gtk_widget_show (news->news_notebook); - - gtk_notebook_set_show_border (GTK_NOTEBOOK (news->news_notebook), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (news->news_notebook), - FALSE); - - gtk_widget_show (news->news_notebook); - gtk_box_pack_start (GTK_BOX (news->main_box), news->news_notebook, - TRUE, TRUE, 0); - - /* create and install the display area */ - news->news_model = GTK_TREE_MODEL (gtk_tree_store_new (LAST_NEWS_COL, - G_TYPE_POINTER, - G_TYPE_INT)); - - news->news_display = gtk_tree_view_new_with_model (GTK_TREE_MODEL (news->news_model)); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (news->news_display), - FALSE); - gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW (news->news_display)), - GTK_SELECTION_NONE); - - news->column = gtk_tree_view_column_new (); - - news->renderer = nautilus_cell_renderer_news_new (); - gtk_tree_view_column_pack_start (news->column, news->renderer, FALSE); - gtk_tree_view_column_set_cell_data_func (news->column, - news->renderer, - nautilus_news_cell_data_func, - news, NULL); - - gtk_tree_view_append_column (GTK_TREE_VIEW (news->news_display), - news->column); - - gtk_widget_show (news->news_display); - /* put the display in a scrolled window so it can scroll */ - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (scrolled_window), - news->news_display); - gtk_widget_show (scrolled_window); - - gtk_notebook_append_page (GTK_NOTEBOOK (news->news_notebook), - scrolled_window, NULL); - news->news_display_scrolled_window = scrolled_window; - - /* add the empty message */ - news->empty_message = gtk_label_new (_("The News panel displays current headlines from your favorite websites. Click the \'Select Sites\' button to select the sites to display.")); - eel_gtk_label_set_scale (GTK_LABEL (news->empty_message), PANGO_SCALE_LARGE); - gtk_label_set_line_wrap (GTK_LABEL (news->empty_message), TRUE); - gtk_widget_show (news->empty_message); - - gtk_notebook_append_page (GTK_NOTEBOOK (news->news_notebook), - news->empty_message, NULL); - - g_signal_connect (news->news_display, "size_allocate", - G_CALLBACK (nautilus_news_size_allocate), news); - g_signal_connect (news->news_display, "row_activated", - G_CALLBACK (nautilus_news_row_activated), news); - g_signal_connect (news->news_display, "row_expanded", - G_CALLBACK (nautilus_news_row_expanded), news); - g_signal_connect (news->news_display, "row_collapsed", - G_CALLBACK (nautilus_news_row_collapsed), news); - - g_signal_connect_after (news->news_display, "button_release_event", - G_CALLBACK (nautilus_news_button_release_event), news); - - /* create a button box to hold the command buttons */ - button_box = add_command_buttons (news, _("_Select Sites"), FALSE); - gtk_widget_show (button_box); - gtk_box_pack_start (GTK_BOX (news->main_box), button_box, FALSE, FALSE, 0); -} - - -static BonoboObject * -make_news_view (const char *iid, void *callback_data) -{ - News *news; - - /* create the private data for the news view */ - news = g_new0 (News, 1); - - - /* allocate the main container */ - news->main_container = gtk_notebook_new (); - gtk_notebook_set_show_border (GTK_NOTEBOOK (news->main_container), - FALSE); - gtk_notebook_set_show_tabs (GTK_NOTEBOOK (news->main_container), - FALSE); - - /* set up the widgets for the main,configure and add modes */ - set_up_main_widgets (news, news->main_container); - set_up_configure_widgets (news, news->main_container); - set_up_edit_widgets (news, news->main_container); - - gtk_widget_show (news->main_container); - - /* get preferences and sanity check them */ - news->max_item_count = eel_preferences_get_integer (NAUTILUS_PREFERENCES_NEWS_MAX_ITEMS); - news->update_interval = 60 * eel_preferences_get_integer (NAUTILUS_PREFERENCES_NEWS_UPDATE_INTERVAL); - news->update_timeout = -1; - - if (news->max_item_count <= 0) { - news->max_item_count = 2; - } - - if (news->update_interval < 60) { - news->update_interval = 60; - } - - news->wrap_idle_handle = -1; - - eel_preferences_add_callback (NAUTILUS_PREFERENCES_NEWS_MAX_ITEMS, max_items_changed, news); - eel_preferences_add_callback (NAUTILUS_PREFERENCES_NEWS_UPDATE_INTERVAL, update_interval_changed, news); - - /* load some images */ - nautilus_news_load_images (news); - - /* set up the update timeout */ - news->timer_task = gtk_timeout_add (10000, check_for_updates, news); - - gtk_widget_show_all (news->main_container); - - /* Create the nautilus view CORBA object. */ - news->view = nautilus_view_new (news->main_container); - g_signal_connect (news->view, "destroy", G_CALLBACK (do_destroy), news); - - g_signal_connect (news->view, "load_location", - G_CALLBACK (nautilus_news_load_location), news); - - /* allocate a property bag to reflect the TAB_IMAGE property */ - news->property_bag = bonobo_property_bag_new (get_bonobo_properties, set_bonobo_properties, news); - - bonobo_control_set_properties (nautilus_view_get_bonobo_control (news->view), BONOBO_OBJREF (news->property_bag), NULL); - bonobo_property_bag_add (news->property_bag, "tab_image", TAB_IMAGE, BONOBO_ARG_STRING, NULL, - _("image indicating that the news has changed"), 0); - bonobo_property_bag_add (news->property_bag, "close", CLOSE_NOTIFY, - BONOBO_ARG_BOOLEAN, NULL, "close notification", 0); - - nautilus_news_clear_changed_flags (news); - - news->item_uris = g_hash_table_new (g_str_hash, g_str_equal); - - /* read the channel definition file and start loading the channels */ - read_channel_list (news); - update_channels (news); - - /* populate the configuration list */ - add_channels_to_lists (news); - update_remove_button (news); - - /* default to the main mode */ - news->current_page = PAGE_MAIN; - set_views_for_mode (news); - - /* return the nautilus view */ - return BONOBO_OBJECT (news->view); -} - -int -main(int argc, char *argv[]) -{ - if (g_getenv ("NAUTILUS_DEBUG") != NULL) { - eel_make_warnings_and_criticals_stop_in_debugger (); - } - - return nautilus_view_standard_main ("nautilus-news", - VERSION, - GETTEXT_PACKAGE, - GNOMELOCALEDIR, - argc, - argv, - "OAFIID:Nautilus_News_View_Factory", - "OAFIID:Nautilus_News_View", - make_news_view, - nautilus_global_preferences_init, - NULL); -} diff --git a/components/news/news_bullet.png b/components/news/news_bullet.png Binary files differdeleted file mode 100644 index c9e9fa03b..000000000 --- a/components/news/news_bullet.png +++ /dev/null diff --git a/components/news/news_channels.xml b/components/news/news_channels.xml deleted file mode 100644 index 8c4a3dd94..000000000 --- a/components/news/news_channels.xml +++ /dev/null @@ -1,46 +0,0 @@ -<?xml version="1.0"?> -<rss_news_channels> - <rss_channel name="Advogato" uri="http://advogato.org/rss/articles.xml" show="false" open="false"/> - <rss_channel name="AppWatch" uri="http://www.appwatch.com/appwatch.rdf" show="false" open="false"/> - <rss_channel name="Barrapunto" uri="http://barrapunto.com/barrapunto.rdf" show="false" open="false"/> - <rss_channel name="Barrapunto Gnome" uri="http://barrapunto.com/gnome.rdf" show="false" open="false"/> - <rss_channel name="BSD Today" uri="http://www.bsdtoday.com/backend/bt.rdf" show="false" open="false"/> - <rss_channel name="Beyond 2000" uri="http://beyond2000.com/b2k.rdf" show="false" open="false"/> - <rss_channel name="CNet" uri="http://www.newsisfree.com/export.php3?_f=rss91&_w=f&_i=1443" show="false" open="false"/> - <rss_channel name="CNN" uri="http://www.cnn.com/cnn.rss" show="false" open="false"/> - <rss_channel name="Dictionary.com" uri="http://www.dictionary.com/wordoftheday/wotd.rss" show="false" open="false"/> - <rss_channel name="DVD Review" uri="http://www.dvdreview.com/rss/newschannel.rss" show="false" open="false"/> - <rss_channel name="Freshmeat" uri="http://freshmeat.net/backend/fm.rdf" show="false" open="false"/> - <rss_channel name="GNOME News" uri="http://news.gnome.org/gnome-news/rdf" show="false" open="false"/> - <rss_channel name="Internet.com" uri="http://headlines.internet.com/internetnews/prod-news/news.rss" show="false" open="false"/> - <rss_channel name="KDE News" uri="http://www.kde.org/dotkdeorg.rdf" show="false" open="false"/> - <rss_channel name="Kuro5hin" uri="http://www.kuro5hin.org/backend.rdf" show="false" open="false"/> - <rss_channel name="Linux Games" uri="http://linuxgames.com/bin/mynetscape.pl" show="false" open="false"/> - <rss_channel name="Linux Jobs" uri="http://linux.com/mrn/jobs/latest_jobs.rss" show="false" open="false"/> - <rss_channel name="Linux Planet" uri="http://www.linuxplanet.com/rss" show="false" open="false"/> - <rss_channel name="Linux Today" uri="http://linuxtoday.com/backend/my-netscape.rdf" show="false" open="false"/> - <rss_channel name="Linux Weekly News" uri="http://lwn.net/headlines/rss" show="false" open="false"/> - <rss_channel name="Linux.com" uri="http://www.linux.com/mrn/front_page.rss" show="false" open="false"/> - <rss_channel name="Morons" uri="http://morons.org/morons.rss" show="false" open="false"/> - <rss_channel name="Mozilla" uri="http://www.mozilla.org/news.rdf" show="false" open="false"/> - <rss_channel name="Mozilla Zine" uri="http://www.mozillazine.org/contents.rdf" show="false" open="false"/> - <rss_channel name="The Motley Fool" uri="http://www.fool.com/about/headlines/rss_headlines.asp" show="false" open="false"/> - <rss_channel name="Newsforge" uri="http://www.newsforge.com/newsforge.rss" show="false" open="false"/> - <rss_channel name="Nanotech News" uri="http://www.nanotechnews.com/nano/rdf" show="false" open="false"/> - <rss_channel name="Perl.com" uri="http://www.perl.com/pace/news.rss" show="false" open="false"/> - <rss_channel name="Pigdog" uri="http://www.pigdog.org/pigdog.rdf" show="false" open="false"/> - <rss_channel name="Python.org" uri="http://www.python.org/channews.rdf" show="false" open="false"/> - <rss_channel name="Quotes of the Day" uri="http://www.quotationspage.com/data/mqotd.rss" show="false" open="false"/> - <rss_channel name="Salon" uri="http://www.salon.com/feed/RDF/salon_use.rdf" show="false" open="false"/> - <rss_channel name="Scripting News" uri="http://scriptingnews.userland.com/xml/scriptingnews2.xml" show="false" open="false"/> - <rss_channel name="Security Focus" uri="http://www.securityfocus.com/topnews-rss.html" show="false" open="false"/> - <rss_channel name="Segfault" uri="http://www.segfault.org/stories.xml" show="false" open="false"/> - <rss_channel name="Slashdot" uri="http://www.slashdot.org/slashdot.rdf" show="false" open="false"/> - <rss_channel name="The Register" uri="http://www.theregister.co.uk/tonys/slashdot.rdf" show="false" open="false"/> - <rss_channel name="Think Geek" uri="http://www.thinkgeek.com/thinkgeek.rdf" show="false" open="false"/> - <rss_channel name="Tomalak's Realm" uri="http://www.tomalak.org/recentTodaysLinks.xml" show="false" open="false"/> - <rss_channel name="Web Reference" uri="http://www.webreference.com/webreference.rdf" show="false" open="false"/> - <rss_channel name="Wired" uri="http://www.wired.com/news_drop/netcenter/netcenter.rdf" show="false" open="false"/> - <rss_channel name="XML.com" uri="http://xml.com/xml/xmlnews.rdf" show="false" open="false"/> - <rss_channel name="Zope" uri="http://www.zope.org/SiteIndex/news.rss" show="false" open="false"/> -</rss_news_channels> diff --git a/components/notes/Makefile.am b/components/notes/Makefile.am deleted file mode 100644 index 35ffee771..000000000 --- a/components/notes/Makefile.am +++ /dev/null @@ -1,33 +0,0 @@ -NULL = - -INCLUDES=\ - -DG_LOG_DOMAIN=\"Nautilus-Notes\" \ - -I$(top_srcdir) \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - $(COMPONENT_CFLAGS) \ - $(NULL) \ - -DGTK_ENABLE_BROKEN - -bonobodir = $(libdir)/bonobo -bonobo_LTLIBRARIES = libnautilus-notes-view.la - -libnautilus_notes_view_la_SOURCES = nautilus-notes.c - -libnautilus_notes_view_la_LIBADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-private/libnautilus-private.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -libnautilus_notes_view_la_LDFLAGS = -module -avoid-version -no-undefined - -server_in_files = Nautilus_View_notes.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@BONOBODIR\@|$(bonobodir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST= $(server_in_files) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/notes/Nautilus_View_notes.server.in.in b/components/notes/Nautilus_View_notes.server.in.in deleted file mode 100644 index f87fff972..000000000 --- a/components/notes/Nautilus_View_notes.server.in.in +++ /dev/null @@ -1,23 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Notes_View" - type="shlib" location="@BONOBODIR@/libnautilus-notes-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="description" type="string" _value="Notes side pane for Nautilus"/> - <oaf_attribute name="name" type="string" _value="Notes side pane"/> - <oaf_attribute name="nautilus:sidebar_panel_name" type="string" _value="Notes"/> - <oaf_attribute name="nautilus:recommended_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="*/*"/> - </oaf_attribute> - <oaf_attribute name="nautilus:property_page_name" type="string" _value="Notes"/> - <oaf_attribute name="nautilus:can_handle_multiple_files" type="boolean" value="false"/> -</oaf_server> - -</oaf_info> diff --git a/components/notes/nautilus-notes.c b/components/notes/nautilus-notes.c deleted file mode 100644 index 16c558318..000000000 --- a/components/notes/nautilus-notes.c +++ /dev/null @@ -1,489 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000, 2001 Eazel, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - */ - -/* notes sidebar panel -- allows editing per-directory notes */ - -#define VIEW_IID "OAFIID:Nautilus_Notes_View" - -#include <config.h> - -#include <eel/eel-debug.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-string.h> -#include <gtk/gtkmain.h> -#include <gtk/gtksignal.h> -#include <gtk/gtktextbuffer.h> -#include <gtk/gtktextview.h> -#include <gtk/gtkvbox.h> -#include <gtk/gtkscrolledwindow.h> -#include <bonobo/bonobo-property-bag.h> -#include <libnautilus-private/nautilus-file-attributes.h> -#include <libnautilus-private/nautilus-file.h> -#include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus-private/nautilus-metadata.h> -#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. - */ -#if 0 -#include <libnautilus-private/nautilus-undo-signal-handlers.h> -#endif - -#define SAVE_TIMEOUT (3 * 1000) - -/* property bag getting and setting routines */ -enum { - TAB_IMAGE, - NOTES_URI -}; - -typedef struct { - NautilusView *view; - BonoboPropertyBag *property_bag; - GtkWidget *note_text_field; - GtkTextBuffer *text_buffer; - char *uri; - NautilusFile *file; - guint save_timeout_id; - char *previous_saved_text; -} Notes; - -static void notes_save_metainfo (Notes *notes); -static char *notes_get_indicator_image (const char *notes_text); -static void notify_listeners_if_changed (Notes *notes, - char *new_notes); -static void notes_load_location (NautilusView *view, - const char *location, - Notes *notes); - -static void -get_bonobo_properties (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer callback_data) -{ - char *indicator_image; - Notes *notes; - - notes = (Notes *) callback_data; - - switch (arg_id) { - case TAB_IMAGE: { - /* if there is a note, return the name of the indicator image, - otherwise, return NULL */ - indicator_image = notes_get_indicator_image (notes->previous_saved_text); - BONOBO_ARG_SET_STRING (arg, indicator_image); - g_free (indicator_image); - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -static void -set_bonobo_properties (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer callback_data) -{ - if (arg_id == NOTES_URI) { - CORBA_sequence_CORBA_string *uris; - - uris = arg->_value; - notes_load_location (NULL, - uris->_buffer[0], - (Notes *)callback_data); - } -} - -static gboolean -schedule_save_callback (gpointer data) -{ - Notes *notes; - - notes = data; - - /* Zero out save_timeout_id so no one will try to cancel our - * in-progress timeout callback. - */ - notes->save_timeout_id = 0; - - notes_save_metainfo (notes); - - return FALSE; -} - -static void -cancel_pending_save (Notes *notes) -{ - if (notes->save_timeout_id != 0) { - gtk_timeout_remove (notes->save_timeout_id); - notes->save_timeout_id = 0; - } -} - -static void -schedule_save (Notes *notes) -{ - cancel_pending_save (notes); - - notes->save_timeout_id = gtk_timeout_add (SAVE_TIMEOUT, schedule_save_callback, notes); -} - -static void -load_note_text_from_metadata (NautilusFile *file, - Notes *notes) -{ - char *saved_text; - - g_assert (NAUTILUS_IS_FILE (file)); - g_assert (notes->file == file); - - saved_text = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_ANNOTATION, ""); - - /* This fn is called for any change signal on the file, so make sure that the - * metadata has actually changed. - */ - if (eel_strcmp (saved_text, notes->previous_saved_text) != 0) { - notify_listeners_if_changed (notes, saved_text); - - g_free (notes->previous_saved_text); - notes->previous_saved_text = saved_text; - cancel_pending_save (notes); - - gtk_text_buffer_set_text (notes->text_buffer, saved_text, -1); - } else { - g_free (saved_text); - } - -/* FIXME bugzilla.gnome.org 44436: - * Undo not working in notes-view. - */ -#if 0 - nautilus_undo_set_up_editable_for_undo (GTK_EDITABLE (notes->note_text_field)); -#endif -} - -static void -done_with_file (Notes *notes) -{ - cancel_pending_save (notes); - - if (notes->file != NULL) { - nautilus_file_monitor_remove (notes->file, notes); - g_signal_handlers_disconnect_matched (notes->file, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (load_note_text_from_metadata), - notes); - nautilus_file_unref (notes->file); - } -} - -static void -notes_load_metainfo (Notes *notes) -{ - NautilusFileAttributes attributes; - - done_with_file (notes); - notes->file = nautilus_file_get (notes->uri); - - gtk_text_buffer_set_text (notes->text_buffer, "", -1); - - if (notes->file == NULL) { - return; - } - - attributes = NAUTILUS_FILE_ATTRIBUTE_METADATA; - nautilus_file_monitor_add (notes->file, notes, attributes); - - if (nautilus_file_check_if_ready (notes->file, attributes)) { - load_note_text_from_metadata (notes->file, notes); - } - - g_signal_connect (notes->file, "changed", - G_CALLBACK (load_note_text_from_metadata), notes); -} - -/* utility to notify event listeners if the notes data actually changed */ -static void -notify_listeners_if_changed (Notes *notes, char *new_notes) -{ - char *tab_image; - BonoboArg *tab_image_arg; - - if (eel_strcmp (notes->previous_saved_text, new_notes) != 0) { - /* notify listeners that the notes text has changed */ - tab_image = notes_get_indicator_image (new_notes); - - tab_image_arg = bonobo_arg_new (BONOBO_ARG_STRING); - BONOBO_ARG_SET_STRING (tab_image_arg, tab_image); - - bonobo_event_source_notify_listeners_full (notes->property_bag->es, - "Bonobo/Property", - "change", - "tab_image", - tab_image_arg, - NULL); - bonobo_arg_release (tab_image_arg); - g_free (tab_image); - } -} - -/* save the metainfo corresponding to the current uri, if any, into the text field */ -static void -notes_save_metainfo (Notes *notes) -{ - char *notes_text; - GtkTextIter start_iter; - GtkTextIter end_iter; - - if (notes->file == NULL) { - return; - } - - cancel_pending_save (notes); - - /* Block the handler, so we don't respond to our own change. - */ - g_signal_handlers_block_matched (notes->file, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (load_note_text_from_metadata), - notes); - - gtk_text_buffer_get_start_iter (notes->text_buffer, &start_iter); - gtk_text_buffer_get_end_iter (notes->text_buffer, &end_iter); - notes_text = gtk_text_buffer_get_text (notes->text_buffer, - &start_iter, - &end_iter, - FALSE); - - nautilus_file_set_metadata (notes->file, - NAUTILUS_METADATA_KEY_ANNOTATION, - NULL, notes_text); - - g_signal_handlers_unblock_matched (notes->file, - G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA, - 0, 0, NULL, - G_CALLBACK (load_note_text_from_metadata), - notes); - - notify_listeners_if_changed (notes, notes_text); - - g_free (notes->previous_saved_text); - notes->previous_saved_text = notes_text; -} - -static void -notes_load_location (NautilusView *view, - const char *location, - Notes *notes) -{ - if (strcmp (notes->uri, location) != 0) { -/* FIXME bugzilla.gnome.org 44436: - * Undo not working in notes-view. - */ -#if 0 - nautilus_undo_tear_down_editable_for_undo (GTK_EDITABLE (notes->note_text_field)); -#endif - notes_save_metainfo (notes); - g_free (notes->uri); - notes->uri = g_strdup (location); - notes_load_metainfo (notes); - } -} - -static gboolean -on_text_field_focus_out_event (GtkWidget *widget, - GdkEventFocus *event, - gpointer callback_data) -{ - Notes *notes; - - notes = callback_data; - notes_save_metainfo (notes); - return FALSE; -} - -static void -on_changed (GtkEditable *editable, Notes *notes) -{ - schedule_save (notes); -} - -static void -do_destroy (GtkObject *obj, Notes *notes) -{ - done_with_file (notes); - g_free (notes->uri); - g_free (notes->previous_saved_text); - g_free (notes); -} - -static char * -notes_get_indicator_image (const char *notes_text) -{ - if (notes_text != NULL && notes_text[0] != '\0') { - return g_strdup ("note-indicator.png"); - } - return NULL; -} - -static BonoboObject * -make_notes_view () -{ - GtkWidget *vbox, *scroll; - Notes *notes; - notes = g_new0 (Notes, 1); - notes->uri = g_strdup (""); - - /* allocate a vbox to hold all of the UI elements */ - vbox = gtk_vbox_new (FALSE, 0); - - /* create the text container */ - notes->text_buffer = gtk_text_buffer_new (NULL); - notes->note_text_field = gtk_text_view_new_with_buffer (notes->text_buffer); - -#ifdef GNOME2_CONVERSION_COMPLETE - font = nautilus_font_factory_get_font_from_preferences (14); - eel_gtk_widget_set_font (notes->note_text_field, font); - gdk_font_unref (font); -#endif - gtk_text_view_set_editable (GTK_TEXT_VIEW (notes->note_text_field), TRUE); - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (notes->note_text_field), - GTK_WRAP_WORD); - scroll = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scroll), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), - GTK_SHADOW_IN); - gtk_container_add (GTK_CONTAINER (scroll), notes->note_text_field); - gtk_box_pack_start (GTK_BOX (vbox), scroll, TRUE, TRUE, 0); - - g_signal_connect (notes->note_text_field, "focus_out_event", - G_CALLBACK (on_text_field_focus_out_event), notes); - g_signal_connect (notes->text_buffer, "changed", - G_CALLBACK (on_changed), notes); - - gtk_widget_show_all (vbox); - - /* Create CORBA object. */ - notes->view = nautilus_view_new (vbox); - g_signal_connect (notes->view, "destroy", G_CALLBACK (do_destroy), notes); - - /* allocate a property bag to reflect the TAB_IMAGE property */ - notes->property_bag = bonobo_property_bag_new (get_bonobo_properties, set_bonobo_properties, notes); - bonobo_control_set_properties (nautilus_view_get_bonobo_control (notes->view), BONOBO_OBJREF (notes->property_bag), NULL); - bonobo_property_bag_add (notes->property_bag, "tab_image", TAB_IMAGE, BONOBO_ARG_STRING, NULL, - "image indicating that a note is present", 0); - bonobo_property_bag_add (notes->property_bag, "uris", - NOTES_URI, TC_CORBA_sequence_CORBA_string, - NULL, "URI of selected file", 0); - /* handle events */ - g_signal_connect (notes->view, "load_location", - G_CALLBACK (notes_load_location), notes); - - /* handle selections */ -#ifdef GNOME2_CONVERSION_COMPLETE - nautilus_clipboard_set_up_editable_in_control - (GTK_EDITABLE (notes->note_text_field), - nautilus_view_get_bonobo_control (notes->view), - FALSE); -#endif - -/* FIXME bugzilla.gnome.org 44436: - * Undo not working in notes-view. - */ -#if 0 - nautilus_undo_set_up_editable_for_undo (GTK_EDITABLE (notes->note_text_field)); - nautilus_undo_editable_set_undo_key (GTK_EDITABLE (notes->note_text_field), TRUE); -#endif - - 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, - const char *iid, - gpointer impl_ptr, - CORBA_Environment *ev) -{ - 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; - } - - view = make_notes_view (); - - bonobo_activation_plugin_use (poa, impl_ptr); - - return CORBA_Object_duplicate (BONOBO_OBJREF (view), ev); -} - -static const BonoboActivationPluginObject notes_plugin_list[] = { - { VIEW_IID, notes_shlib_make_object }, - { NULL } -}; - -const BonoboActivationPlugin Bonobo_Plugin_info = { - notes_plugin_list, - "Nautilus Notes Sidebar Panel" -}; diff --git a/components/sample/Makefile.am b/components/sample/Makefile.am deleted file mode 100644 index 051f41b82..000000000 --- a/components/sample/Makefile.am +++ /dev/null @@ -1,36 +0,0 @@ -# WHAT YOU NEED TO CHANGE: Change all the filenames to refer to your -# component. Also add whatever libraries, include paths, etc you want, -# and change the G_LOG_DOMAIN. - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Sample\" \ - -DDATADIR=\"$(datadir)\" \ - -I$(top_srcdir) \ - -I$(top_builddir) \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(COMPONENT_CFLAGS) - -libexec_PROGRAMS=nautilus-sample-content-view - -nautilus_sample_content_view_SOURCES = \ - nautilus-sample-content-view.h \ - nautilus-sample-content-view.c \ - main.c - -nautilus_sample_content_view_LDADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(COMPONENT_LIBS) - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = nautilus-sample-content-view-ui.xml - -server_in_files = Nautilus_View_sample.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = $(server_in_files) $(ui_DATA) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/sample/Nautilus_View_sample.server.in.in b/components/sample/Nautilus_View_sample.server.in.in deleted file mode 100644 index 3749cac20..000000000 --- a/components/sample/Nautilus_View_sample.server.in.in +++ /dev/null @@ -1,46 +0,0 @@ -<oaf_info> - -<!-- WHAT YOU NEED TO CHANGE: - - a) Replace all the OAFIID strings to do this you need to register - your namespace, and then generate some unique names inside - it. See bonobo/doc/FAQ 'How should I create unique OAFIIDs for - components ?'. - - b) Alter the repo_ids to the interfaces you support. - - c) Point the 'location' at the executable that your project installs - - d) And finally, make sure to remove the test_only attribute. - --> - -<oaf_server iid="OAFIID:Nautilus_Sample_Content_View_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-sample-content-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Sample view factory"/> - <oaf_attribute name="description" type="string" _value="Sample content view component's factory"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Sample_Content_View" type="factory" location="OAFIID:Nautilus_Sample_Content_View_Factory"> - <oaf_attribute name="test_only" type="boolean" value="true"/> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Nautilus Sample view"/> - <oaf_attribute name="description" type="string" _value="Sample content view component"/> - <oaf_attribute name="bonobo:additional_uri_schemes" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="*"/> - </oaf_attribute> - <oaf_attribute name="nautilus:view_as_name" type="string" _value="Sample"/> - <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Sample"/> - <oaf_attribute name="nautilus:viewer_label" type="string" _value="Sample Viewer"/> -</oaf_server> - -</oaf_info> diff --git a/components/sample/README b/components/sample/README deleted file mode 100644 index 573e17423..000000000 --- a/components/sample/README +++ /dev/null @@ -1,6 +0,0 @@ - -This is a sample Nautilus component. Each file has a WHAT YOU NEED TO -CHANGE comment near the top, telling you what you need to change when -you copy this component as a starting point for your own. Some also -have CHANGE comments sprinkled throughout pointing out other things you -may want or need to change. diff --git a/components/sample/main.c b/components/sample/main.c deleted file mode 100644 index 5c3f83989..000000000 --- a/components/sample/main.c +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* main.c - Main function and object activation function for sample - * view component. - */ - -/* WHAT YOU NEED TO CHANGE: You need to change include - * component-specific header below the include of config.h. Then look - * for the CHANGE comments below and change the #defines. - */ - -#include <config.h> - -#include "nautilus-sample-content-view.h" -#include <libnautilus/nautilus-view-standard-main.h> - -/* CHANGE: Replace these OAFIIDs with the new ones you put in the - * .server file. - */ -#define FACTORY_IID "OAFIID:Nautilus_Sample_Content_View_Factory" -#define VIEW_IID "OAFIID:Nautilus_Sample_Content_View" - -/* CHANGE: Change to your executable name */ -#define EXECUTABLE_NAME "nautilus-sample-content-view" - -/* CHANGE: Change to the get_type function for your view class */ -#define GET_TYPE_FUNCTION nautilus_sample_content_view_get_type - -int -main (int argc, char *argv[]) -{ - return nautilus_view_standard_main (EXECUTABLE_NAME, - VERSION, - NULL, /* Could be PACKAGE */ - NULL, /* Could be GNOMELOCALEDIR */ - argc, - argv, - FACTORY_IID, - VIEW_IID, - nautilus_view_create_from_get_type_function, - NULL, - GET_TYPE_FUNCTION); -} diff --git a/components/sample/nautilus-sample-content-view-ui.xml b/components/sample/nautilus-sample-content-view-ui.xml deleted file mode 100644 index ccfeae0e4..000000000 --- a/components/sample/nautilus-sample-content-view-ui.xml +++ /dev/null @@ -1,22 +0,0 @@ -<Root> -<menu> - <submenu name="File" _label="_File"> - <placeholder name="File Items Placeholder"> - <menuitem name="Sample Menu Item" - _label="_Sample" - _tip="This is a sample merged menu item" - pixtype="stock" pixname="gtk-new" - verb="Sample Menu Item"/> - </placeholder> - </submenu> -</menu> -<dockitem name="Toolbar"> - <placeholder name="Extra Buttons Placeholder"> - <toolitem name="Sample Dock Item" - _label="Sample" - _tip="This is a sample merged toolbar button" - pixtype="stock" pixname="gtk-new" - verb="Sample Dock Item"/> - </placeholder> -</dockitem> -</Root>
\ No newline at end of file diff --git a/components/sample/nautilus-sample-content-view.c b/components/sample/nautilus-sample-content-view.c deleted file mode 100644 index 7eae6e682..000000000 --- a/components/sample/nautilus-sample-content-view.c +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-sample-content-view.c - sample content view - component. This component displays a simple label of the URI - and demonstrates merging menu items & toolbar buttons. - It should be a good basis for writing out-of-proc content views. - */ - -/* WHAT YOU NEED TO CHANGE: You need to rename everything. Then look - * for the individual CHANGE comments to see some things you could - * change to make your view do what you want. - */ - -#include <config.h> -#include "nautilus-sample-content-view.h" - -#include <bonobo/bonobo-i18n.h> -#include <gtk/gtklabel.h> -#include <libgnome/gnome-macros.h> -#include <string.h> - -/* CHANGE: You probably want some different widget than a label to be - * your main view contents. - */ -struct NautilusSampleContentViewDetails { - char *location; - GtkWidget *label; -}; - -BONOBO_CLASS_BOILERPLATE (NautilusSampleContentView, nautilus_sample_content_view, - NautilusView, NAUTILUS_TYPE_VIEW) - -static void -nautilus_sample_content_view_finalize (GObject *object) -{ - NautilusSampleContentView *view; - - view = NAUTILUS_SAMPLE_CONTENT_VIEW (object); - - g_free (view->details->location); - g_free (view->details); - - G_OBJECT_CLASS (object)->finalize (object); -} - -static void -load_location (NautilusSampleContentView *view, - const char *location) -{ - char *label_text; - - g_assert (NAUTILUS_IS_SAMPLE_CONTENT_VIEW (view)); - g_assert (location != NULL); - - g_free (view->details->location); - view->details->location = g_strdup (location); - - label_text = g_strdup_printf (_("%s\n\nThis is a sample Nautilus content view component."), location); - gtk_label_set_text (GTK_LABEL (view->details->label), label_text); - g_free (label_text); -} - -/* CHANGE: Do your own loading here. If loading can be a long-running - * operation, you should consider doing it async, in which case you - * should only call load_complete when the load is actually done. - */ - -static void -sample_load_location_callback (NautilusView *nautilus_view, - const char *location, - gpointer user_data) -{ - NautilusSampleContentView *view; - - g_assert (NAUTILUS_IS_VIEW (nautilus_view)); - g_assert (location != NULL); - - view = NAUTILUS_SAMPLE_CONTENT_VIEW (nautilus_view); - - /* It's mandatory to send an underway message once the - * component starts loading, otherwise nautilus will assume it - * failed. In a real component, this will probably happen in - * some sort of callback from whatever loading mechanism it is - * using to load the data; this component loads no data, so it - * gives the progress update here. - */ - nautilus_view_report_load_underway (nautilus_view); - - /* Do the actual load. */ - load_location (view, location); - - /* It's mandatory to call report_load_complete once the - * component is done loading successfully, or - * report_load_failed if it completes unsuccessfully. In a - * real component, this will probably happen in some sort of - * callback from whatever loading mechanism it is using to - * load the data; this component loads no data, so it gives - * the progress update here. - */ - nautilus_view_report_load_complete (nautilus_view); -} - -static void -bonobo_sample_callback (BonoboUIComponent *ui, - gpointer user_data, - const char *verb) -{ - NautilusSampleContentView *view; - char *label_text; - - g_assert (BONOBO_IS_UI_COMPONENT (ui)); - g_assert (verb != NULL); - - view = NAUTILUS_SAMPLE_CONTENT_VIEW (user_data); - - if (strcmp (verb, "Sample Menu Item") == 0) { - label_text = g_strdup_printf (_("%s\n\nYou selected the Sample menu item."), - view->details->location); - } else { - g_assert (strcmp (verb, "Sample Dock Item") == 0); - label_text = g_strdup_printf (_("%s\n\nYou clicked the Sample toolbar button."), - view->details->location); - } - - gtk_label_set_text (GTK_LABEL (view->details->label), label_text); - g_free (label_text); -} - -/* CHANGE: Do your own menu/toolbar merging here. */ -static void -sample_merge_bonobo_items_callback (BonoboControl *control, - gboolean state, - gpointer user_data) -{ - NautilusSampleContentView *view; - BonoboUIComponent *ui_component; - BonoboUIVerb verbs [] = { - BONOBO_UI_VERB ("Sample Menu Item", bonobo_sample_callback), - BONOBO_UI_VERB ("Sample Dock Item", bonobo_sample_callback), - BONOBO_UI_VERB_END - }; - - g_assert (BONOBO_IS_CONTROL (control)); - - view = NAUTILUS_SAMPLE_CONTENT_VIEW (user_data); - - if (state) { - ui_component = nautilus_view_set_up_ui (NAUTILUS_VIEW (view), - DATADIR, - "nautilus-sample-content-view-ui.xml", - "nautilus-sample-content-view"); - - bonobo_ui_component_add_verb_list_with_data (ui_component, verbs, view); - } - - /* Note that we do nothing if state is FALSE. Nautilus content - * views are activated when installed, but never explicitly - * deactivated. When the view changes to another, the content - * view object is destroyed, which ends up calling - * bonobo_ui_handler_unset_container, which removes its merged - * menu & toolbar items. - */ -} - -static void -nautilus_sample_content_view_class_init (NautilusSampleContentViewClass *class) -{ - G_OBJECT_CLASS (class)->finalize = nautilus_sample_content_view_finalize; -} - -static void -nautilus_sample_content_view_instance_init (NautilusSampleContentView *view) -{ - view->details = g_new0 (NautilusSampleContentViewDetails, 1); - - view->details->label = gtk_label_new (_("(none)")); - gtk_widget_show (view->details->label); - - nautilus_view_construct (NAUTILUS_VIEW (view), view->details->label); - - g_signal_connect (view, "load_location", - G_CALLBACK (sample_load_location_callback), NULL); - - /* Get notified when our bonobo control is activated so we can - * merge menu & toolbar items into the shell's UI. - */ - g_signal_connect_object (nautilus_view_get_bonobo_control (NAUTILUS_VIEW (view)), "activate", - G_CALLBACK (sample_merge_bonobo_items_callback), view, 0); -} diff --git a/components/sample/nautilus-sample-content-view.h b/components/sample/nautilus-sample-content-view.h deleted file mode 100644 index e57d1796c..000000000 --- a/components/sample/nautilus-sample-content-view.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* nautilus-sample-content-view.h - Sample view component. This - * component just displays a simple message and includes a menu item - * and a toolbar button else. It should be a good basis for writing - * Nautilus view components. - */ - -/* WHAT YOU NEED TO CHANGE: You should be able to leave this header - * pretty much unchanged except for renaming everything to match your - * component. - */ - -#ifndef NAUTILUS_SAMPLE_CONTENT_VIEW_H -#define NAUTILUS_SAMPLE_CONTENT_VIEW_H - -#include <libnautilus/nautilus-view.h> - -#define NAUTILUS_TYPE_SAMPLE_CONTENT_VIEW (nautilus_sample_content_view_get_type ()) -#define NAUTILUS_SAMPLE_CONTENT_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_SAMPLE_CONTENT_VIEW, NautilusSampleContentView)) -#define NAUTILUS_SAMPLE_CONTENT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_SAMPLE_CONTENT_VIEW, NautilusSampleContentViewClass)) -#define NAUTILUS_IS_SAMPLE_CONTENT_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_SAMPLE_CONTENT_VIEW)) -#define NAUTILUS_IS_SAMPLE_CONTENT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_SAMPLE_CONTENT_VIEW)) - -typedef struct NautilusSampleContentViewDetails NautilusSampleContentViewDetails; - -typedef struct { - NautilusView parent; - NautilusSampleContentViewDetails *details; -} NautilusSampleContentView; - -typedef struct { - NautilusViewClass parent; -} NautilusSampleContentViewClass; - -GType nautilus_sample_content_view_get_type (void); - -#endif /* NAUTILUS_SAMPLE_CONTENT_VIEW_H */ diff --git a/components/text/Makefile.am b/components/text/Makefile.am deleted file mode 100644 index 3e0262933..000000000 --- a/components/text/Makefile.am +++ /dev/null @@ -1,35 +0,0 @@ -NULL = - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Text\" \ - -DDATADIR=\""$(datadir)"\" \ - -I$(top_srcdir) \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(COMPONENT_CFLAGS) \ - -DGTK_ENABLE_BROKEN \ - $(NULL) - -libexec_PROGRAMS=nautilus-text-view - -nautilus_text_view_SOURCES = \ - nautilus-text-view.c - -nautilus_text_view_LDADD = \ - ../../libnautilus/libnautilus.la \ - $(COMPONENT_LIBS) \ - $(NULL) - -uidir = $(datadir)/gnome-2.0/ui -ui_DATA = nautilus-text-view-ui.xml - -server_in_files = Nautilus_View_text.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = $(server_in_files) $(nautilus_text_view_SOURCES) $(ui_DATA) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/text/Nautilus_View_text.server.in.in b/components/text/Nautilus_View_text.server.in.in deleted file mode 100644 index b9fc3462e..000000000 --- a/components/text/Nautilus_View_text.server.in.in +++ /dev/null @@ -1,30 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Text_View_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-text-view"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Text view factory"/> - <oaf_attribute name="description" type="string" _value="Factory for text view"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Text_View" type="factory" location="OAFIID:Nautilus_Text_View_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - <item value="IDL:Nautilus/View:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="Text view"/> - <oaf_attribute name="description" type="string" _value="Text view"/> - <oaf_attribute name="bonobo:editable" type="boolean" value="true"/> - <oaf_attribute name="bonobo:supported_mime_types" type="stringv"> - <item value="text/plain"/> - <item value="text/*"/> - </oaf_attribute> - <oaf_attribute name="nautilus:view_as_name" type="string" _value="Text"/> - <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Text"/> - <oaf_attribute name="nautilus:viewer_label" type="string" _value="Text Viewer"/> -</oaf_server> - -</oaf_info> diff --git a/components/text/main.c b/components/text/main.c deleted file mode 100644 index ab374f47c..000000000 --- a/components/text/main.c +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Maciej Stachowiak <mjs@eazel.com> - */ - -/* main.c - Main function and object activation function for text - * view component. - */ - -#include <config.h> - -#include "nautilus-text-view.h" -#include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus/nautilus-view-standard-main.h> -#include <eel/eel-debug.h> - -#define FACTORY_IID "OAFIID:Nautilus_Text_View_Factory" -#define VIEW_IID "OAFIID:Nautilus_Text_View" - -int -main (int argc, char *argv[]) -{ - if (g_getenv ("NAUTILUS_DEBUG") != NULL) { - eel_make_warnings_and_criticals_stop_in_debugger (); - } - - return nautilus_view_standard_main ("nautilus-text-view", - VERSION, - GETTEXT_PACKAGE, - GNOMELOCALEDIR, - argc, - argv, - FACTORY_IID, - VIEW_IID, - nautilus_view_create_from_get_type_function, - nautilus_global_preferences_init, - nautilus_text_view_get_type); -} diff --git a/components/text/nautilus-text-view-ui.xml b/components/text/nautilus-text-view-ui.xml deleted file mode 100644 index 901ae0fe8..000000000 --- a/components/text/nautilus-text-view-ui.xml +++ /dev/null @@ -1,11 +0,0 @@ -<Root> -<commands> - <cmd name="Copy Text" - accel="*Control*c" sensitive="1"/> -</commands> -<menu> - <submenu name="Edit"> - <menuitem name="Copy" _label="_Copy Text" _tip="Copy the selected text to the clipboard" pixtype="stock" pixname="gtk-copy" verb="Copy Text"/> - </submenu> -</menu> -</Root> diff --git a/components/text/nautilus-text-view.c b/components/text/nautilus-text-view.c deleted file mode 100644 index bd9429990..000000000 --- a/components/text/nautilus-text-view.c +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */ - -/* - * Copyright (C) 2000 Eazel, Inc. - * Copyright (C) 2002 Sun Microsystems Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this library; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - * - * Authors: Dave Camp <dave@ximian.com> - * based on component by Andy Hertzfeld <andy@eazel.com> - * - * - */ - -/* text view - display a text file */ - -#include <config.h> - -#include <string.h> -#include <eel/eel-debug.h> -#include <eel/eel-vfs-extensions.h> -#include <gconf/gconf-client.h> -#include <gtk/gtktextview.h> -#include <gtk/gtkscrolledwindow.h> -#include <libnautilus/nautilus-view.h> -#include <libnautilus/nautilus-view-standard-main.h> - -#define VIEW_IID "OAFIID:Nautilus_Text_View" -#define FACTORY_IID "OAFIID:Nautilus_Text_View_Factory" - -#define NAUTILUS_TEXT_VIEW_PATH_COPY "/commands/Copy Text" - -typedef struct { - NautilusView base; - - GtkTextView *view; - GtkTextBuffer *buffer; - BonoboUIComponent *ui; - - EelReadFileHandle *read_handle; -} NautilusTextView; - -typedef struct { - NautilusViewClass base; -} NautilusTextViewClass; - -static const char *encodings_to_try[2]; -static int n_encodings_to_try; - -static GType nautilus_text_view_get_type (void); - -BONOBO_CLASS_BOILERPLATE (NautilusTextView, nautilus_text_view, - NautilusView, NAUTILUS_TYPE_VIEW); - -static void -unload_contents (NautilusTextView *view) -{ - GtkTextIter start; - GtkTextIter end; - - gtk_text_buffer_get_start_iter (view->buffer, &start); - gtk_text_buffer_get_end_iter (view->buffer, &end); - - gtk_text_buffer_delete (view->buffer, &start, &end); -} - -static void -cancel_load (NautilusTextView *view) -{ - if (view->read_handle) { - eel_read_file_cancel (view->read_handle); - view->read_handle = NULL; - } -} - -static GnomeVFSFileSize -my_strnlen(char *str, GnomeVFSFileSize file_size) -{ - GnomeVFSFileSize len; - - len = 0; - while (*str != 0 && len < file_size) { - str++; - len++; - } - return len; -} - -static void -read_file_callback (GnomeVFSResult result, - GnomeVFSFileSize file_size, - char *file_contents, - gpointer callback_data) -{ - NautilusView *view; - NautilusTextView *text_view; - GnomeVFSFileSize length; - gsize converted_length; - char *utf8_contents; - GError *conversion_error; - GtkTextIter iter; - int i; - - view = callback_data; - text_view = callback_data; - - text_view->read_handle = NULL; - - if (result != GNOME_VFS_OK) { - nautilus_view_report_load_failed (view); - return; - } - - /* If the file has zero size file_contents will be NULL, so we just - report loading is complete and return. */ - if (file_size == 0) { - nautilus_view_report_load_complete (view); - return; - } - - /* Find first embedded zero, if any */ - length = my_strnlen (file_contents, file_size); - - utf8_contents = NULL; - if (!g_utf8_validate (file_contents, length, NULL)) { - for (i = 0; i < n_encodings_to_try; i++) { - conversion_error = NULL; - utf8_contents = g_convert (file_contents, length, - "UTF-8", encodings_to_try[i], - NULL, &converted_length, &conversion_error); - if (utf8_contents != NULL) { - length = converted_length; - break; - } - g_error_free (conversion_error); - } - - if (utf8_contents == NULL) { - nautilus_view_report_load_failed (view); - return; - } - file_contents = utf8_contents; - } - - gtk_text_buffer_get_start_iter (text_view->buffer, &iter); - - gtk_text_buffer_insert (text_view->buffer, &iter, - file_contents, length); - - if (utf8_contents) { - g_free (utf8_contents); - } - - nautilus_view_report_load_complete (view); -} - -static void -load_location (NautilusView *view, const char *location_uri) -{ - NautilusTextView *text_view; - - text_view = (NautilusTextView *)view; - - cancel_load (text_view); - unload_contents (text_view); - - nautilus_view_report_load_underway (view); - - text_view->read_handle = - eel_read_entire_file_async (location_uri, 0, - read_file_callback, view); -} - -static void -copy_callback (BonoboUIComponent *component, - gpointer callback_data, - const char *verb) -{ - NautilusTextView *text_view; - GdkDisplay *display; - - text_view = (NautilusTextView*)callback_data; - - display = gtk_widget_get_display (GTK_WIDGET (text_view->view)); - - gtk_text_buffer_copy_clipboard - (text_view->buffer, - gtk_clipboard_get_for_display (display, GDK_NONE)); -} - -static void -bonobo_control_activate_callback (BonoboObject *control, - gboolean state, - gpointer callback_data) -{ - NautilusTextView *text_view; - BonoboUIVerb verbs[] = { - BONOBO_UI_VERB ("Copy Text", copy_callback), - BONOBO_UI_VERB_END - }; - - text_view = (NautilusTextView *)callback_data; - - if (state) { - text_view->ui = nautilus_view_set_up_ui - (NAUTILUS_VIEW (text_view), - DATADIR, - "nautilus-text-view-ui.xml", - "nautilus-text-view"); - bonobo_ui_component_add_verb_list_with_data (text_view->ui, - verbs, - text_view); - } -} - -static void -nautilus_text_view_instance_init (NautilusTextView *view) -{ - GtkWidget *text_view; - GtkWidget *scrolled_window; - PangoFontDescription *monospace_font_desc; - GConfClient *conf_client; - char *monospace_font; - - text_view = gtk_text_view_new (); - view->view = GTK_TEXT_VIEW (text_view); - - gtk_text_view_set_editable (GTK_TEXT_VIEW (text_view), FALSE); - gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (text_view), GTK_WRAP_WORD); - gtk_text_view_set_left_margin (GTK_TEXT_VIEW (text_view), 3); - gtk_text_view_set_right_margin (GTK_TEXT_VIEW (text_view), 3); - - /* Pick up the monospace font from desktop preferences */ - conf_client = gconf_client_get_default (); - monospace_font = gconf_client_get_string (conf_client, "/desktop/gnome/interface/monospace_font_name", NULL); - if (monospace_font) { - monospace_font_desc = pango_font_description_from_string (monospace_font); - gtk_widget_modify_font (text_view, monospace_font_desc); - pango_font_description_free (monospace_font_desc); - } - g_object_unref (conf_client); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_window), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - - gtk_container_add (GTK_CONTAINER (scrolled_window), text_view); - - gtk_widget_show (text_view); - gtk_widget_show (scrolled_window); - - view->buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); - - nautilus_view_construct (NAUTILUS_VIEW (view), scrolled_window); - - g_signal_connect_object ( - nautilus_view_get_bonobo_control (NAUTILUS_VIEW (view)), - "activate", G_CALLBACK (bonobo_control_activate_callback), - view, 0); -} - -static void -nautilus_text_view_finalize (GObject *object) -{ - NautilusTextView *view; - - view = (NautilusTextView*)object; - - cancel_load (view); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_text_view_class_init (NautilusTextViewClass *class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (class); - NautilusViewClass *view_class = NAUTILUS_VIEW_CLASS (class); - const char *charset; - gboolean utf8; - - view_class->load_location = load_location; - - object_class->finalize = nautilus_text_view_finalize; - - n_encodings_to_try = 0; - utf8 = g_get_charset (&charset); - - if (!utf8) { - encodings_to_try[n_encodings_to_try++] = charset; - } - - if (g_ascii_strcasecmp (charset, "ISO-8859-1") != 0) { - encodings_to_try[n_encodings_to_try++] = "ISO-8859-1"; - } -} - -int -main (int argc, char *argv[]) -{ - if (g_getenv ("NAUTILUS_DEBUG") != NULL) { - eel_make_warnings_and_criticals_stop_in_debugger (); - } - - return nautilus_view_standard_main ("nautilus-text-view", - VERSION, - GETTEXT_PACKAGE, - GNOMELOCALEDIR, - argc, - argv, - FACTORY_IID, - VIEW_IID, - nautilus_view_create_from_get_type_function, - NULL, - nautilus_text_view_get_type); -} diff --git a/components/text/nautilus-text-view.h b/components/text/nautilus-text-view.h deleted file mode 100644 index 498977c41..000000000 --- a/components/text/nautilus-text-view.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Andy Hertzfeld - */ - -/* header file for the text view component */ - -#ifndef NAUTILUS_TEXT_VIEW_H -#define NAUTILUS_TEXT_VIEW_H - -#include <libnautilus/nautilus-view.h> - - -typedef struct NautilusTextView NautilusTextView; -typedef struct NautilusTextViewClass NautilusTextViewClass; - -#define NAUTILUS_TYPE_TEXT_VIEW (nautilus_text_view_get_type ()) -#define NAUTILUS_TEXT_VIEW(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_TEXT_VIEW, NautilusTextView)) -#define NAUTILUS_TEXT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_TEXT_VIEW, NautilusTextViewClass)) -#define NAUTILUS_IS_TEXT_VIEW(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_TEXT_VIEW)) -#define NAUTILUS_IS_TEXT_VIEW_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_TEXT_VIEW)) - -typedef struct NautilusTextViewDetails NautilusTextViewDetails; - -struct NautilusTextView { - NautilusView base; - NautilusTextViewDetails *details; -}; - -struct NautilusTextViewClass { - NautilusViewClass base; -}; - - - -/* GObject support */ -GType nautilus_text_view_get_type (void); - - -#endif /* NAUTILUS_TEXT_VIEW_H */ diff --git a/components/throbber/Makefile.am b/components/throbber/Makefile.am deleted file mode 100644 index 3405b68a8..000000000 --- a/components/throbber/Makefile.am +++ /dev/null @@ -1,34 +0,0 @@ -NULL = - -INCLUDES = \ - -DG_LOG_DOMAIN=\"Nautilus-Throbber\" \ - -DDATADIR=\""$(datadir)"\" \ - -I$(top_srcdir) \ - -DGNOMELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - $(DISABLE_DEPRECATED_CFLAGS) \ - $(COMPONENT_CFLAGS) \ - $(NULL) - -libexec_PROGRAMS=nautilus-throbber - -nautilus_throbber_SOURCES = \ - nautilus-throbber.c \ - nautilus-throbber.h \ - main.c - -nautilus_throbber_LDADD = \ - $(top_builddir)/libnautilus/libnautilus.la \ - $(top_builddir)/libnautilus-private/libnautilus-private.la \ - $(COMPONENT_LIBS) - $(NULL) - -server_in_files = Nautilus_Control_throbber.server.in.in - -serverdir = $(libdir)/bonobo/servers -server_DATA = $(server_in_files:.server.in.in=.server) -$(server_in_files:.server.in.in=.server.in): $(server_in_files) - sed -e "s|\@LIBEXECDIR\@|$(libexecdir)|" $< > $@ -@INTLTOOL_SERVER_RULE@ - -EXTRA_DIST = $(server_in_files) -CLEANFILES = $(server_DATA) $(server_DATA).in diff --git a/components/throbber/Nautilus_Control_throbber.server.in.in b/components/throbber/Nautilus_Control_throbber.server.in.in deleted file mode 100644 index 14d780103..000000000 --- a/components/throbber/Nautilus_Control_throbber.server.in.in +++ /dev/null @@ -1,21 +0,0 @@ -<oaf_info> - -<oaf_server iid="OAFIID:Nautilus_Throbber_Factory" - type="exe" location="@LIBEXECDIR@/nautilus-throbber"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:GNOME/ObjectFactory:1.0"/> - </oaf_attribute> - <oaf_attribute name="name" type="string" _value="throbber factory"/> - <oaf_attribute name="description" type="string" _value="throbber object factory"/> -</oaf_server> - -<oaf_server iid="OAFIID:Nautilus_Throbber" type="factory" location="OAFIID:Nautilus_Throbber_Factory"> - <oaf_attribute name="repo_ids" type="stringv"> - <item value="IDL:Bonobo/Unknown:1.0"/> - <item value="IDL:Bonobo/Control:1.0"/> - </oaf_attribute> -<oaf_attribute name="name" type="string" _value="throbber"/> -<oaf_attribute name="description" type="string" _value="animation to indicate on-going activity"/> -</oaf_server> - -</oaf_info> diff --git a/components/throbber/main.c b/components/throbber/main.c deleted file mode 100644 index 7edd840b4..000000000 --- a/components/throbber/main.c +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* - * Copyright (C) 2000 Eazel, Inc - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Author: Andy Hertzfeld - */ - -/* main.c - main function and object activation function for the throbber component. */ - -#include <config.h> -#include "nautilus-throbber.h" - -#include <eel/eel-debug.h> -#include <libnautilus-private/nautilus-global-preferences.h> -#include <libnautilus/nautilus-view-standard-main.h> - -#define FACTORY_IID "OAFIID:Nautilus_Throbber_Factory" -#define VIEW_IID "OAFIID:Nautilus_Throbber" - -static BonoboObject * -cb_create_throbber (const char *ignore0, void *ignore1) -{ - NautilusThrobber *throbber = - g_object_new (NAUTILUS_TYPE_THROBBER, NULL); - return nautilus_throbber_get_control (throbber); -} - -int -main (int argc, char *argv[]) -{ - if (g_getenv ("NAUTILUS_DEBUG") != NULL) { - eel_make_warnings_and_criticals_stop_in_debugger (); - } - - 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); -} diff --git a/components/throbber/nautilus-throbber.c b/components/throbber/nautilus-throbber.c deleted file mode 100644 index 540d4236b..000000000 --- a/components/throbber/nautilus-throbber.c +++ /dev/null @@ -1,662 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the throbber (for busy feedback) for the location bar - * - */ - -#include <config.h> -#include <math.h> - -#include "nautilus-throbber.h" - -#include <eel/eel-debug.h> -#include <eel/eel-glib-extensions.h> -#include <eel/eel-gtk-extensions.h> -#include <eel/eel-accessibility.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtksignal.h> -#include <libgnome/gnome-macros.h> -#include <libgnome/gnome-util.h> -#include <libgnomeui/gnome-icon-theme.h> - -#define THROBBER_DEFAULT_TIMEOUT 100 /* Milliseconds Per Frame */ - -struct NautilusThrobberDetails { - BonoboObject *control; - BonoboPropertyBag *property_bag; - GList *image_list; - GnomeIconTheme *icon_theme; - - GdkPixbuf *quiescent_pixbuf; - - int max_frame; - int delay; - int current_frame; - guint timer_task; - - gboolean ready; - gboolean small_mode; -}; - - -static void nautilus_throbber_load_images (NautilusThrobber *throbber); -static void nautilus_throbber_unload_images (NautilusThrobber *throbber); -static void nautilus_throbber_theme_changed (GnomeIconTheme *icon_theme, - NautilusThrobber *throbber); -static void nautilus_throbber_remove_update_callback (NautilusThrobber *throbber); -static AtkObject *nautilus_throbber_get_accessible (GtkWidget *widget); - -GNOME_CLASS_BOILERPLATE (NautilusThrobber, nautilus_throbber, - GtkEventBox, GTK_TYPE_EVENT_BOX) - - - -/* routines to handle setting and getting the configuration properties of the Bonobo control */ - -enum { - STYLE, - THROBBING, - LOCATION -} MyArgs; - - -static gboolean -is_throbbing (NautilusThrobber *throbber) -{ - return throbber->details->timer_task != 0; -} - -static void -get_bonobo_properties (BonoboPropertyBag *bag, - BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusThrobber *throbber = NAUTILUS_THROBBER (user_data); - - switch (arg_id) { - case THROBBING: - { - BONOBO_ARG_SET_BOOLEAN (arg, throbber->details->timer_task != 0); - break; - } - - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -static void -set_bonobo_properties (BonoboPropertyBag *bag, - const BonoboArg *arg, - guint arg_id, - CORBA_Environment *ev, - gpointer user_data) -{ - NautilusThrobber *throbber = NAUTILUS_THROBBER (user_data); - switch (arg_id) { - case THROBBING: - { - gboolean throbbing; - - throbbing = BONOBO_ARG_GET_BOOLEAN (arg); - - if (throbbing != is_throbbing (throbber)) { - if (throbbing) { - nautilus_throbber_start (throbber); - } else { - nautilus_throbber_stop (throbber); - } - } - - break; - } - case STYLE: - { - nautilus_throbber_set_small_mode (throbber, BONOBO_ARG_GET_INT (arg) != - BONOBO_UI_TOOLBAR_ITEM_STYLE_ICON_AND_TEXT_VERTICAL); - break; - } - default: - g_warning ("Unhandled arg %d", arg_id); - break; - } -} - -BonoboObject * -nautilus_throbber_get_control (NautilusThrobber *throbber) -{ - return throbber->details->control; -} - -/* loop through all the images taking their union to compute the width and height of the throbber */ -static void -get_throbber_dimensions (NautilusThrobber *throbber, int *throbber_width, int* throbber_height) -{ - int current_width, current_height; - int pixbuf_width, pixbuf_height; - GList *image_list; - GdkPixbuf *pixbuf; - - current_width = 0; - current_height = 0; - - if (throbber->details->quiescent_pixbuf != NULL) { - /* start with the quiescent image */ - current_width = gdk_pixbuf_get_width (throbber->details->quiescent_pixbuf); - current_height = gdk_pixbuf_get_height (throbber->details->quiescent_pixbuf); - } - - /* union with the animation image */ - image_list = throbber->details->image_list; - if (image_list != NULL) { - pixbuf = GDK_PIXBUF (image_list->data); - pixbuf_width = gdk_pixbuf_get_width (pixbuf); - pixbuf_height = gdk_pixbuf_get_height (pixbuf); - - if (pixbuf_width > current_width) { - current_width = pixbuf_width; - } - - if (pixbuf_height > current_height) { - current_height = pixbuf_height; - } - } - - /* return the result */ - *throbber_width = current_width; - *throbber_height = current_height; -} - -static void -nautilus_throbber_instance_init (NautilusThrobber *throbber) -{ - GtkWidget *widget = GTK_WIDGET (throbber); - - - GTK_WIDGET_UNSET_FLAGS (throbber, GTK_NO_WINDOW); - - gtk_widget_set_events (widget, - gtk_widget_get_events (widget) - | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK - | GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); - - throbber->details = g_new0 (NautilusThrobberDetails, 1); - - throbber->details->delay = THROBBER_DEFAULT_TIMEOUT; - - throbber->details->icon_theme = gnome_icon_theme_new (); - g_signal_connect (throbber->details->icon_theme, - "changed", - G_CALLBACK (nautilus_throbber_theme_changed), - throbber); - - /* make the bonobo control */ - throbber->details->control = BONOBO_OBJECT (bonobo_control_new (widget)); - eel_add_weak_pointer (&throbber->details->control); - - /* attach a property bag with the configure property */ - throbber->details->property_bag = bonobo_property_bag_new (get_bonobo_properties, - set_bonobo_properties, throbber); - bonobo_control_set_properties (BONOBO_CONTROL (throbber->details->control), - BONOBO_OBJREF (throbber->details->property_bag), NULL); - - bonobo_property_bag_add (throbber->details->property_bag, "throbbing", THROBBING, BONOBO_ARG_BOOLEAN, NULL, - "Throbber active", 0); - bonobo_property_bag_add (throbber->details->property_bag, "style", STYLE, BONOBO_ARG_INT, NULL, NULL, - Bonobo_PROPERTY_WRITEABLE); - nautilus_throbber_load_images (throbber); - gtk_widget_show (widget); -} - -/* handler for handling theme changes */ -static void -nautilus_throbber_theme_changed (GnomeIconTheme *icon_theme, NautilusThrobber *throbber) -{ - gtk_widget_hide (GTK_WIDGET (throbber)); - nautilus_throbber_load_images (throbber); - gtk_widget_show (GTK_WIDGET (throbber)); - gtk_widget_queue_resize ( GTK_WIDGET (throbber)); -} - -/* here's the routine that selects the image to draw, based on the throbber's state */ - -static GdkPixbuf * -select_throbber_image (NautilusThrobber *throbber) -{ - GList *element; - - if (throbber->details->timer_task == 0) { - if (throbber->details->quiescent_pixbuf == NULL) { - return NULL; - } else { - return g_object_ref (throbber->details->quiescent_pixbuf); - } - } - - if (throbber->details->image_list == NULL) { - return NULL; - } - - element = g_list_nth (throbber->details->image_list, throbber->details->current_frame); - - return g_object_ref (element->data); -} - -/* handle expose events */ - -static int -nautilus_throbber_expose (GtkWidget *widget, GdkEventExpose *event) -{ - NautilusThrobber *throbber; - GdkPixbuf *pixbuf; - int x_offset, y_offset, width, height; - GdkRectangle pix_area, dest; - - g_return_val_if_fail (NAUTILUS_IS_THROBBER (widget), FALSE); - - throbber = NAUTILUS_THROBBER (widget); - if (!throbber->details->ready) { - return FALSE; - } - - pixbuf = select_throbber_image (throbber); - if (pixbuf == NULL) { - return FALSE; - } - - width = gdk_pixbuf_get_width (pixbuf); - height = gdk_pixbuf_get_height (pixbuf); - - /* Compute the offsets for the image centered on our allocation */ - x_offset = widget->allocation.x + (widget->allocation.width - width) / 2; - y_offset = widget->allocation.y + (widget->allocation.height - height) / 2; - - pix_area.x = x_offset; - pix_area.y = y_offset; - pix_area.width = width; - pix_area.height = height; - - if (!gdk_rectangle_intersect (&event->area, &pix_area, &dest)) { - g_object_unref (pixbuf); - return FALSE; - } - - gdk_draw_pixbuf (widget->window, NULL, pixbuf, - dest.x - x_offset, dest.y - y_offset, - dest.x, dest.y, - dest.width, dest.height, - GDK_RGB_DITHER_MAX, 0, 0); - - g_object_unref (pixbuf); - - return FALSE; -} - -static void -nautilus_throbber_map (GtkWidget *widget) -{ - NautilusThrobber *throbber; - - throbber = NAUTILUS_THROBBER (widget); - - GNOME_CALL_PARENT (GTK_WIDGET_CLASS, map, (widget)); - throbber->details->ready = TRUE; -} - -/* here's the actual timeout task to bump the frame and schedule a redraw */ - -static gboolean -bump_throbber_frame (gpointer callback_data) -{ - NautilusThrobber *throbber; - - throbber = NAUTILUS_THROBBER (callback_data); - if (!throbber->details->ready) { - return TRUE; - } - - throbber->details->current_frame += 1; - if (throbber->details->current_frame > throbber->details->max_frame - 1) { - throbber->details->current_frame = 0; - } - - gtk_widget_queue_draw (GTK_WIDGET (throbber)); - return TRUE; -} - - -/* routines to start and stop the throbber */ - -void -nautilus_throbber_start (NautilusThrobber *throbber) -{ - if (is_throbbing (throbber)) { - return; - } - - if (throbber->details->timer_task != 0) { - g_source_remove (throbber->details->timer_task); - } - - /* reset the frame count */ - throbber->details->current_frame = 0; - throbber->details->timer_task = g_timeout_add (throbber->details->delay, - bump_throbber_frame, - throbber); -} - -static void -nautilus_throbber_remove_update_callback (NautilusThrobber *throbber) -{ - if (throbber->details->timer_task != 0) { - g_source_remove (throbber->details->timer_task); - } - - throbber->details->timer_task = 0; -} - -void -nautilus_throbber_stop (NautilusThrobber *throbber) -{ - if (!is_throbbing (throbber)) { - return; - } - - nautilus_throbber_remove_update_callback (throbber); - gtk_widget_queue_draw (GTK_WIDGET (throbber)); - -} - -/* routines to load the images used to draw the throbber */ - -/* unload all the images, and the list itself */ - -static void -nautilus_throbber_unload_images (NautilusThrobber *throbber) -{ - GList *current_entry; - - if (throbber->details->quiescent_pixbuf != NULL) { - g_object_unref (throbber->details->quiescent_pixbuf); - throbber->details->quiescent_pixbuf = NULL; - } - - /* unref all the images in the list, and then let go of the list itself */ - current_entry = throbber->details->image_list; - while (current_entry != NULL) { - g_object_unref (current_entry->data); - current_entry = current_entry->next; - } - - g_list_free (throbber->details->image_list); - throbber->details->image_list = NULL; -} - -static GdkPixbuf * -scale_to_real_size (NautilusThrobber *throbber, GdkPixbuf *pixbuf) -{ - GdkPixbuf *result; - int size; - - size = gdk_pixbuf_get_height (pixbuf); - - if (throbber->details->small_mode) { - result = gdk_pixbuf_scale_simple (pixbuf, - size * 2 / 3, - size * 2 / 3, - GDK_INTERP_BILINEAR); - } else { - result = g_object_ref (pixbuf); - } - - return result; -} - -static GdkPixbuf * -extract_frame (NautilusThrobber *throbber, GdkPixbuf *grid_pixbuf, int x, int y, int size) -{ - GdkPixbuf *pixbuf, *result; - - if (x + size > gdk_pixbuf_get_width (grid_pixbuf) || - y + size > gdk_pixbuf_get_height (grid_pixbuf)) { - return NULL; - } - - pixbuf = gdk_pixbuf_new_subpixbuf (grid_pixbuf, - x, y, - size, size); - g_return_val_if_fail (pixbuf != NULL, NULL); - - result = scale_to_real_size (throbber, pixbuf); - g_object_unref (pixbuf); - - return result; -} - -/* load all of the images of the throbber sequentially */ -static void -nautilus_throbber_load_images (NautilusThrobber *throbber) -{ - int grid_width, grid_height, x, y, size; - char *icon; - GdkPixbuf *icon_pixbuf, *pixbuf; - GList *image_list; - - nautilus_throbber_unload_images (throbber); - - /* Load the animation */ - icon = gnome_icon_theme_lookup_icon (throbber->details->icon_theme, - "gnome-spinner", -1, NULL, &size); - if (icon == NULL) { - g_warning ("Throbber animation not found"); - return; - } - - icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL); - grid_width = gdk_pixbuf_get_width (icon_pixbuf); - grid_height = gdk_pixbuf_get_height (icon_pixbuf); - - image_list = NULL; - for (y = 0; y < grid_height; y += size) { - for (x = 0; x < grid_width ; x += size) { - pixbuf = extract_frame (throbber, icon_pixbuf, x, y, size); - - if (pixbuf) - { - image_list = g_list_prepend (image_list, pixbuf); - } - else - { - g_warning ("Cannot extract frame from the grid"); - } - } - } - throbber->details->image_list = g_list_reverse (image_list); - throbber->details->max_frame = g_list_length (throbber->details->image_list); - - g_free (icon); - g_object_unref (icon_pixbuf); - - /* Load the rest icon */ - icon = gnome_icon_theme_lookup_icon (throbber->details->icon_theme, - "gnome-spinner-rest", -1, NULL, &size); - if (icon == NULL) { - g_warning ("Throbber rest icon not found"); - return; - } - - icon_pixbuf = gdk_pixbuf_new_from_file (icon, NULL); - throbber->details->quiescent_pixbuf = scale_to_real_size (throbber, icon_pixbuf); - - g_object_unref (icon_pixbuf); - g_free (icon); -} - -void -nautilus_throbber_set_small_mode (NautilusThrobber *throbber, gboolean new_mode) -{ - if (new_mode != throbber->details->small_mode) { - throbber->details->small_mode = new_mode; - nautilus_throbber_load_images (throbber); - - gtk_widget_queue_resize (GTK_WIDGET (throbber)); - } -} - -/* handle setting the size */ - -static void -nautilus_throbber_size_request (GtkWidget *widget, GtkRequisition *requisition) -{ - int throbber_width, throbber_height; - NautilusThrobber *throbber = NAUTILUS_THROBBER (widget); - - get_throbber_dimensions (throbber, &throbber_width, &throbber_height); - - /* allocate some extra margin so we don't butt up against toolbar edges */ - requisition->width = throbber_width + 8; - requisition->height = throbber_height; -} - -static void -nautilus_throbber_finalize (GObject *object) -{ - NautilusThrobber *throbber; - - throbber = NAUTILUS_THROBBER (object); - - nautilus_throbber_remove_update_callback (throbber); - nautilus_throbber_unload_images (throbber); - - bonobo_object_unref (throbber->details->property_bag); - - eel_remove_weak_pointer (&throbber->details->control); - - g_object_unref (throbber->details->icon_theme); - - g_free (throbber->details); - - G_OBJECT_CLASS (parent_class)->finalize (object); -} - -static void -nautilus_throbber_class_init (NautilusThrobberClass *class) -{ - GtkWidgetClass *widget_class; - - widget_class = GTK_WIDGET_CLASS (class); - - G_OBJECT_CLASS (class)->finalize = nautilus_throbber_finalize; - - widget_class->expose_event = nautilus_throbber_expose; - widget_class->size_request = nautilus_throbber_size_request; - widget_class->map = nautilus_throbber_map; - widget_class->get_accessible = nautilus_throbber_get_accessible; -} - -static AtkObjectClass *a11y_parent_class = NULL; - -static void -nautilus_throbber_accessible_initialize (AtkObject *accessible, - gpointer widget) -{ - atk_object_set_name (accessible, _("throbber")); - atk_object_set_description (accessible, _("provides visual status")); - - a11y_parent_class->initialize (accessible, widget); -} - -static void -nautilus_throbber_accessible_class_init (AtkObjectClass *klass) -{ - a11y_parent_class = g_type_class_peek_parent (klass); - - klass->initialize = nautilus_throbber_accessible_initialize; -} - -static void -nautilus_throbber_accessible_image_get_size (AtkImage *image, - gint *width, - gint *height) -{ - GtkWidget *widget; - - widget = GTK_ACCESSIBLE (image)->widget; - if (!widget) { - *width = *height = 0; - } else { - *width = widget->allocation.width; - *height = widget->allocation.height; - } -} - -static void -nautilus_throbber_accessible_image_interface_init (AtkImageIface *iface) -{ - iface->get_image_size = nautilus_throbber_accessible_image_get_size; -} - -static GType -nautilus_throbber_accessible_get_type (void) -{ - static GType type = 0; - - /* Action interface - Name etc. ... */ - if (!type) { - static const GInterfaceInfo atk_image_info = { - (GInterfaceInitFunc) nautilus_throbber_accessible_image_interface_init, - (GInterfaceFinalizeFunc) NULL, - NULL - }; - - type = eel_accessibility_create_derived_type - ("NautilusThrobberAccessible", - GTK_TYPE_IMAGE, - nautilus_throbber_accessible_class_init); - - g_type_add_interface_static (type, ATK_TYPE_IMAGE, - &atk_image_info); - } - - return type; -} - -static AtkObject * -nautilus_throbber_get_accessible (GtkWidget *widget) -{ - AtkObject *accessible; - - if ((accessible = eel_accessibility_get_atk_object (widget))) { - return accessible; - } - - accessible = g_object_new - (nautilus_throbber_accessible_get_type (), NULL); - - return eel_accessibility_set_atk_object_return (widget, accessible); -} diff --git a/components/throbber/nautilus-throbber.h b/components/throbber/nautilus-throbber.h deleted file mode 100644 index 0961749fc..000000000 --- a/components/throbber/nautilus-throbber.h +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* - * Nautilus - * - * Copyright (C) 2000 Eazel, Inc. - * - * Nautilus is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Nautilus is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - * Author: Andy Hertzfeld <andy@eazel.com> - * - * This is the header file for the throbber on the location bar - * - */ - -#ifndef NAUTILUS_THROBBER_H -#define NAUTILUS_THROBBER_H - -#include <gtk/gtkeventbox.h> -#include <bonobo.h> - -G_BEGIN_DECLS - -#define NAUTILUS_TYPE_THROBBER (nautilus_throbber_get_type ()) -#define NAUTILUS_THROBBER(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_THROBBER, NautilusThrobber)) -#define NAUTILUS_THROBBER_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_THROBBER, NautilusThrobberClass)) -#define NAUTILUS_IS_THROBBER(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_THROBBER)) -#define NAUTILUS_IS_THROBBER_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_THROBBER)) - -typedef struct NautilusThrobber NautilusThrobber; -typedef struct NautilusThrobberClass NautilusThrobberClass; -typedef struct NautilusThrobberDetails NautilusThrobberDetails; - -struct NautilusThrobber { - GtkEventBox parent; - NautilusThrobberDetails *details; -}; - -struct NautilusThrobberClass { - GtkEventBoxClass parent_class; - - /* signals */ - void (* location_changed) (NautilusThrobber *throbber, - const char *location); -}; - -GType 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); - -G_END_DECLS - -#endif /* NAUTILUS_THROBBER_H */ - - |