diff options
-rw-r--r-- | ChangeLog | 17 | ||||
-rwxr-xr-x | check-headers-in-Makefile.pl | 79 | ||||
-rw-r--r-- | components/html/main.c | 569 | ||||
-rw-r--r-- | components/services/time/command-line/Makefile.am | 1 | ||||
-rw-r--r-- | components/services/time/nautilus-view/Makefile.am | 1 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-icon-grid.c | 658 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-icon-grid.h | 47 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-grid.c | 658 | ||||
-rw-r--r-- | libnautilus-private/nautilus-icon-grid.h | 47 | ||||
-rw-r--r-- | nautilus-installer/src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.am | 49 | ||||
-rw-r--r-- | src/file-manager/fm-directory-list.h | 118 |
12 files changed, 122 insertions, 2124 deletions
@@ -1,3 +1,20 @@ +2000-07-05 Darin Adler <darin@eazel.com> + + * check-headers-in-Makefile.pl: Wrote a script to check that the + Makefile.am file matches what's actually in the directories. + + * components/html/main.c: Obsolete file. + * components/services/time/command-line/Makefile.am: Removed + mention of nonexistent trilobite-eazel-sample-service-common.c. + * components/services/time/nautilus-view/Makefile.am: Removed + mention of nonexistent trilobite-eazel-sample-service-common.c. + * libnautilus-extensions/nautilus-icon-grid.c: Obsolete file. + * libnautilus-extensions/nautilus-icon-grid.h: Obsolete file. + * nautilus-installer/src/Makefile.am: Fixed typo; it said + "installer h" instead of "installer.h". + * src/Makefile.am: Added nautilus-search-bar-private.h. + * src/file-manager/fm-directory-list.h: Obsolete file. + 2000-07-05 Andy Hertzfeld <andy@eazel.com> * src/nautilus-first-time-druid.c: (druid_finished), diff --git a/check-headers-in-Makefile.pl b/check-headers-in-Makefile.pl new file mode 100755 index 000000000..447e48768 --- /dev/null +++ b/check-headers-in-Makefile.pl @@ -0,0 +1,79 @@ +#!/usr/bin/perl -w +# -*- Mode: perl; indent-tabs-mode: nil -*- + +# +# Nautilus +# +# Copyright (C) 2000 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: Darin Adler <darin@eazel.com>, +# + +# check-config-h.pl: Search for .c files where someone forgot to +# put an include for <config.h> in. + +use diagnostics; +use strict; + +# default to all the files starting from the current directory +if (!@ARGV) + { + @ARGV = `find . -name 'Makefile\.am' -print`; + } + +foreach my $file (@ARGV) + { + chomp $file; + my $directory = $file; + $directory =~ s|/Makefile\.am||; + + open FILE, $file or die "can't open $file"; + my %headers; + while (<FILE>) + { + while (s/([-_a-zA-Z0-9]+\.[ch])\W//) + { + $headers{$1} = $1; + } + } + close FILE; + + if ($directory eq ".") + { + $headers{"acconfig.h"} = "acconfig.h"; + $headers{"config.h"} = "config.h"; + } + + opendir DIRECTORY, $directory or die "can't open $directory"; + foreach my $header (grep /.*\.[ch]$/, readdir DIRECTORY) + { + if (defined $headers{$header}) + { + delete $headers{$header}; + } + else + { + print "$directory/$header in directory but not Makefile.am\n"; + } + } + closedir DIRECTORY; + + foreach my $header (keys %headers) + { + print "$directory/$header in Makefile.am but not directory\n"; + } + } diff --git a/components/html/main.c b/components/html/main.c deleted file mode 100644 index 5a817a3fe..000000000 --- a/components/html/main.c +++ /dev/null @@ -1,569 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* main.c - * - * Copyright (C) 1999, 2000 Free Software Foundaton - * - * 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: Ettore Perazzoli - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <gnome.h> -#include <bonobo.h> - -#include <gtkhtml/gtkhtml.h> -#include <libnautilus/gnome-progressive-loader.h> - - -/* Per-BonoboEmbeddable data. */ -struct _EmbeddableData { - /* The embeddable object. */ - BonoboEmbeddable *embeddable; - - /* The HTML widget. */ - GtkHTML *html; - - /* The scrolled window containing the HTML widget */ - GtkWidget *scrolled_window; - - /* The progressive data sink object used to feed our baby with juicy - HTML. */ - BonoboProgressiveDataSink *pdsink; - - /* The GtkHTML stream associated with the HTML widget. Data is passed - to it through the ProgressiveDataSink interface. */ - GtkHTMLStreamHandle html_stream; - - /* Total number of open views. */ - guint view_count; -}; -typedef struct _EmbeddableData EmbeddableData; - -/* Per-BonoboView data. */ -struct _ViewData { - /* The BonoboView itself. */ - BonoboView *view; - - /* Data for the corresponding BonoboEmbeddable. */ - EmbeddableData *embeddable_data; -}; -typedef struct _ViewData ViewData; - - -/* Number of running objects. */ -static guint num_running_objects = 0; - -/* Our embeddable factory object. */ -static BonoboEmbeddableFactory *embeddable_factory_object = NULL; - - -/* ProgressiveDataSink callbacks for the main HTML widget. */ - -static gint -pdsink_start (BonoboProgressiveDataSink *pdsink, - gpointer data) -{ - EmbeddableData *embeddable_data; - - printf ("*** PSINK START\n"); - - embeddable_data = (EmbeddableData *) data; - - if (embeddable_data->html_stream != NULL) - gtk_html_end (embeddable_data->html, - embeddable_data->html_stream, - GTK_HTML_STREAM_OK); - - /* FIXME bugzilla.eazel.com 718: Need the URL here. */ - embeddable_data->html_stream = gtk_html_begin (embeddable_data->html, - "Unknown name"); - gtk_html_parse (embeddable_data->html); - - return 0; -} - -static gint -pdsink_end (BonoboProgressiveDataSink *pdsink, - - gpointer data) -{ - EmbeddableData *embeddable_data; - - printf ("*** PSINK END\n"); - - embeddable_data = (EmbeddableData *) data; - gtk_html_end (embeddable_data->html, - embeddable_data->html_stream, - GTK_HTML_STREAM_OK); - - embeddable_data->html_stream = NULL; - - return 0; -} - -static gint -pdsink_add_data (BonoboProgressiveDataSink *pdsink, - const Bonobo_ProgressiveDataSink_iobuf *iobuf, - gpointer data) -{ - EmbeddableData *embeddable_data; - gchar *p; - - embeddable_data = (EmbeddableData *) data; - if (embeddable_data->html_stream == NULL) - return 0; - - p = g_strndup (iobuf->_buffer, iobuf->_length); - printf ("*** DATA: %s\n", p); - g_free (p); - - gtk_html_write (embeddable_data->html, - embeddable_data->html_stream, - iobuf->_buffer, - iobuf->_length); - - printf ("*** DATA END\n"); - - return 0; -} - -static gint -pdsink_set_size (BonoboProgressiveDataSink *pdsink, - const CORBA_long count, - gpointer data) -{ - EmbeddableData *embeddable_data; - - embeddable_data = (EmbeddableData *) data; - - /* Not useful. */ - - return 0; -} - - -/* ProgressiveDataSink callbacks for the streams generated on the - "url_requested" signal. */ - -struct _ReqPDSinkData { - GtkHTML *html; - GtkHTMLStreamHandle stream; - BonoboProgressiveDataSink *pdsink; -}; -typedef struct _ReqPDSinkData ReqPDSinkData; - -static gint -req_pdsink_start (BonoboProgressiveDataSink *pdsink, - gpointer data) -{ - ReqPDSinkData *pdsink_data; - - printf ("*** REQ PDSink START\n"); - - pdsink_data = (ReqPDSinkData *) data; - - if (pdsink_data->stream != NULL) - gtk_html_end (pdsink_data->html, - pdsink_data->stream, - GTK_HTML_STREAM_OK); - - return 0; -} - -static gint -req_pdsink_end (BonoboProgressiveDataSink *pdsink, - gpointer data) -{ - ReqPDSinkData *pdsink_data; - - printf ("*** REQ PDSink END\n"); - - pdsink_data = (ReqPDSinkData *) data; - gtk_html_end (pdsink_data->html, - pdsink_data->stream, - GTK_HTML_STREAM_OK); - - bonobo_object_unref (BONOBO_OBJECT (pdsink_data->pdsink)); - g_free (pdsink_data); - - return 0; -} - -static gint -req_pdsink_add_data (BonoboProgressiveDataSink *pdsink, - const Bonobo_ProgressiveDataSink_iobuf *iobuf, - gpointer data) -{ - ReqPDSinkData *pdsink_data; - - pdsink_data = (ReqPDSinkData *) data; - if (pdsink_data->stream == NULL) - return 0; - - printf ("*** REQ PDSink DATA: length %u\n", iobuf->_length); - - gtk_html_write (pdsink_data->html, - pdsink_data->stream, - iobuf->_buffer, - iobuf->_length); - - printf ("*** REQ PDSink DATA END\n"); - - return 0; -} - -static gint -req_pdsink_set_size (BonoboProgressiveDataSink *pdsink, - const CORBA_long count, - gpointer data) -{ - /* Not useful. */ - return 0; -} - - -/* GtkHTML signals. */ - -static void -title_changed_cb (GtkHTML *html, - gpointer data) -{ -} - -static void -url_requested_cb (GtkHTML *html, - const char *url, - GtkHTMLStreamHandle stream, - gpointer data) -{ - EmbeddableData *embeddable_data; - Bonobo_ClientSite client_site; - Bonobo_ProgressiveLoader loader; - BonoboProgressiveDataSink *pdsink; - ReqPDSinkData *req_pdsink_data; - Bonobo_ProgressiveDataSink corba_pdsink; - CORBA_Environment ev; - - /* We are requested an extra URL. So we request a - BonoboProgressiveDataSink interface to our container and feed data - from it. */ - - embeddable_data = (EmbeddableData *) data; - client_site = embeddable_data->embeddable->client_site; - - CORBA_exception_init (&ev); - - /* FIXME bugzilla.eazel.com 716: cache the result. */ - - g_warning ("query_interface on the ClientSite."); - loader = Bonobo_Unknown_query_interface - (client_site, "IDL:Bonobo/ProgressiveLoader:1.0", &ev); - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("Cannot query Bonobo::ProgressiveLoader on the Bonobo::ClientSite."); - CORBA_exception_free (&ev); - return; - } - if (CORBA_Object_is_nil (loader, &ev)) { - g_warning ("Our client site does not support Bonobo::ProgressiveLoader!"); - CORBA_exception_free (&ev); - return; - } - - req_pdsink_data = g_new (ReqPDSinkData, 1); - - pdsink = bonobo_progressive_data_sink_new (req_pdsink_start, - req_pdsink_end, - req_pdsink_add_data, - req_pdsink_set_size, - req_pdsink_data); - if (pdsink == NULL) { - g_warning ("Cannot create Bonobo::ProgressiveDataSink interface for extra requested URL."); - g_free (req_pdsink_data); - CORBA_exception_free (&ev); - return; - } - - corba_pdsink = BONOBO_OBJECT (pdsink)->corba_objref; - - /* Please send mail to sopwith@redhat.com for this evil cast. :-) */ - Bonobo_ProgressiveLoader_load (loader, (CORBA_char *) url, corba_pdsink, &ev); - - if (ev._major != CORBA_NO_EXCEPTION) { - g_warning ("Cannot start client site progressive loading on the Bonobo::ProgressiveDatasink interface."); - g_free (req_pdsink_data); - CORBA_exception_free (&ev); - return; - } - - req_pdsink_data->html = embeddable_data->html; - req_pdsink_data->stream = stream; - req_pdsink_data->pdsink = pdsink; - - CORBA_exception_free (&ev); -} - -static void -load_done_cb (GtkHTML *html, - gpointer data) -{ -} - -static void -link_followed_cb (GtkHTML *html, - const char *url, - gpointer data) -{ -} - -static void -connect_gtk_html_signals (GtkHTML *html, - EmbeddableData *embeddable_data) -{ - gtk_signal_connect (GTK_OBJECT (html), "title_changed", - GTK_SIGNAL_FUNC (title_changed_cb), - embeddable_data); - gtk_signal_connect (GTK_OBJECT (html), "url_requested", - GTK_SIGNAL_FUNC (url_requested_cb), - embeddable_data); - gtk_signal_connect (GTK_OBJECT (html), "load_done", - GTK_SIGNAL_FUNC (load_done_cb), - embeddable_data); - gtk_signal_connect (GTK_OBJECT (html), "link_followed", - GTK_SIGNAL_FUNC (link_followed_cb), - embeddable_data); -} - - -/* BonoboView callbacks. */ - -static void -view_size_query_cb (BonoboView *view, - int *desired_width, - int *desired_height, - ViewData *view_data) -{ - GtkHTML *html; - - html = view_data->embeddable_data->html; - - /* FIXME bugzilla.eazel.com 717: this is *bogus*! */ - *desired_width = html->engine->width; - *desired_height = html->engine->height; -} - -static void -view_activate_cb (BonoboView *view, - gboolean activate, - ViewData *data) -{ - bonobo_view_activate_notify (view, activate); -} - -static void -view_system_exception_cb (BonoboView *view, - CORBA_Object corba_object, - CORBA_Environment *ev, - gpointer data) -{ - bonobo_object_destroy (BONOBO_OBJECT (view)); -} - -static void -view_destroy_cb (BonoboView *view, - ViewData *view_data) -{ - view_data->embeddable_data->view_count--; - g_free (view_data); -} - - -/* BonoboView factory. */ - -static BonoboView * -view_factory (BonoboEmbeddable *embeddable, - const Bonobo_ViewFrame view_frame, - EmbeddableData *embeddable_data) -{ - ViewData *view_data; - BonoboView *view; - - view_data = g_new0 (ViewData, 1); - - /* Create the BonoboView object. */ - view = bonobo_view_new (embeddable_data->scrolled_window); - gtk_object_set_data (GTK_OBJECT (view), "view_data", view_data); - - bonobo_view_set_view_frame (view, view_frame); - - gtk_signal_connect (GTK_OBJECT (view), "size_query", - GTK_SIGNAL_FUNC (view_size_query_cb), view_data); - - gtk_signal_connect (GTK_OBJECT (view), "activate", - GTK_SIGNAL_FUNC (view_activate_cb), view_data); - - gtk_signal_connect (GTK_OBJECT (view), "system_exception", - GTK_SIGNAL_FUNC (view_system_exception_cb), - view_data); - gtk_signal_connect (GTK_OBJECT (view), "destroy", - GTK_SIGNAL_FUNC (view_destroy_cb), view_data); - - view_data->embeddable_data = embeddable_data; - view_data->view = view; - - embeddable_data->view_count++; - - return view; -} - - -/* BonoboEmbeddable callbacks. */ - -static void -embeddable_destroy_cb (BonoboEmbeddable *embeddable, - EmbeddableData *embeddable_data) -{ - num_running_objects--; - if (num_running_objects > 0) - return; - - if (embeddable_data->pdsink != NULL) - bonobo_object_unref (BONOBO_OBJECT (embeddable_data->pdsink)); - - if (embeddable_data->html != NULL) - gtk_widget_destroy (GTK_WIDGET (embeddable_data->html)); - - bonobo_object_unref (BONOBO_OBJECT (embeddable_factory_object)); - - g_free (embeddable_data); - - gtk_main_quit (); -} - -static void -embeddable_system_exception_cb (BonoboEmbeddable *embeddable, - CORBA_Object corba_object, - CORBA_Environment *ev, - gpointer data) -{ - bonobo_object_destroy (BONOBO_OBJECT (embeddable)); -} - - -/* BonoboEmbeddable factory. */ - -static BonoboObject * -embeddable_factory (BonoboEmbeddableFactory *this, - void *data) -{ - BonoboEmbeddable *embeddable; - BonoboProgressiveDataSink *pdsink; - EmbeddableData *embeddable_data; - GtkWidget *html; - GtkWidget *scrolled_window; - - embeddable_data = g_new (EmbeddableData, 1); - - scrolled_window = gtk_scrolled_window_new (NULL, NULL); - - html = gtk_html_new (); - connect_gtk_html_signals (GTK_HTML (html), embeddable_data); - - gtk_container_add (GTK_CONTAINER (scrolled_window), html); - gtk_widget_show (html); - gtk_widget_show (scrolled_window); - - embeddable = bonobo_embeddable_new (BONOBO_VIEW_FACTORY (view_factory), - embeddable_data); - - pdsink = bonobo_progressive_data_sink_new (pdsink_start, - pdsink_end, - pdsink_add_data, - pdsink_set_size, - embeddable_data); - - bonobo_object_add_interface (BONOBO_OBJECT (embeddable), - BONOBO_OBJECT (pdsink)); - - num_running_objects++; - - gtk_signal_connect (GTK_OBJECT (embeddable), "system_exception", - GTK_SIGNAL_FUNC (embeddable_system_exception_cb), - embeddable_data); - - gtk_signal_connect (GTK_OBJECT (embeddable), "destroy", - GTK_SIGNAL_FUNC (embeddable_destroy_cb), - embeddable_data); - - embeddable_data->embeddable = embeddable; - embeddable_data->pdsink = pdsink; - embeddable_data->scrolled_window = scrolled_window; - embeddable_data->html = GTK_HTML (html); - embeddable_data->html_stream = NULL; - embeddable_data->view_count = 0; - - return BONOBO_OBJECT (embeddable); -} - - -/* Main. */ - -static BonoboEmbeddableFactory * -init_html_factory (void) -{ - return bonobo_embeddable_factory_new - ("embeddable-factory:explorer-html-component", - embeddable_factory, NULL); -} - -static void -init_server_factory (int argc, char **argv) -{ - CORBA_Environment ev; - CORBA_ORB orb; - - CORBA_exception_init (&ev); - - gnome_CORBA_init_with_popt_table - ("explorer-html-component", VERSION, - &argc, argv, NULL, 0, NULL, GNORBA_INIT_SERVER_FUNC, &ev); - - CORBA_exception_free (&ev); - - orb = gnome_CORBA_ORB (); - if (bonobo_init (orb, NULL, NULL) == FALSE) - g_error (_("Could not initialize Bonobo!")); -} - -int -main (int argc, char **argv) -{ - /* Setup the factory. */ - init_server_factory (argc, argv); - embeddable_factory_object = init_html_factory (); - - gdk_rgb_init (); - gtk_widget_set_default_colormap (gdk_rgb_get_cmap ()); - gtk_widget_set_default_visual (gdk_rgb_get_visual ()); - - /* Start processing. */ - bonobo_main (); - - return 0; -} diff --git a/components/services/time/command-line/Makefile.am b/components/services/time/command-line/Makefile.am index 123963f6d..73e666985 100644 --- a/components/services/time/command-line/Makefile.am +++ b/components/services/time/command-line/Makefile.am @@ -21,7 +21,6 @@ oafdir = $(datadir)/oaf CORBA_GENERATED = \ trilobite-eazel-time-service.h \ - trilobite-eazel-sample-service-common.c \ trilobite-eazel-time-service-skels.c \ trilobite-eazel-time-service-stubs.c \ trilobite-eazel-time-service-common.c \ diff --git a/components/services/time/nautilus-view/Makefile.am b/components/services/time/nautilus-view/Makefile.am index d26c152ba..9e9c475bb 100644 --- a/components/services/time/nautilus-view/Makefile.am +++ b/components/services/time/nautilus-view/Makefile.am @@ -25,7 +25,6 @@ IDL = $(IDLDIR)/trilobite-eazel-time-service.idl CORBA_GENERATED = \ trilobite-eazel-time-service.h \ - trilobite-eazel-sample-service-common.c \ trilobite-eazel-time-service-skels.c \ trilobite-eazel-time-service-stubs.c \ trilobite-eazel-time-service-common.c \ diff --git a/libnautilus-extensions/nautilus-icon-grid.c b/libnautilus-extensions/nautilus-icon-grid.c deleted file mode 100644 index a224cf7fc..000000000 --- a/libnautilus-extensions/nautilus-icon-grid.c +++ /dev/null @@ -1,658 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-icon-container-grid.c - Grid used by icon container. - - Copyright (C) 1999, 2000 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli <ettore@gnu.org>, - Darin Adler <darin@eazel.com> -*/ - -#include <config.h> -#include "nautilus-icon-grid.h" - -#include <string.h> -#include <math.h> -#include "nautilus-gnome-extensions.h" - -#define INITIAL_GRID_WIDTH 64 -#define INITIAL_GRID_HEIGHT 64 - -#define BASE_CELL_WIDTH 12 -#define BASE_CELL_HEIGHT 12 - -#define START_GRID_POWER 2 /* typical icon size */ - -#define FIRST_FREE_NONE G_MININT - -/* This is a single grid at one grid resolution. - * The icon grid as a whole is a set of these for each size. - */ -typedef struct { - /* Grid resolution 2^<power>. */ - int power; - - /* This is the number or grid positions that we actually use - * for finding positions for new icons. - */ - int visible_width; - - /* The grid. This is automatically sized to fit all the - * icons, so it doesn't need to be explicitly allocated. - */ - ArtIRect bounds; - GList **elements; - - /* Position of the first free cell (used to speed up get_position). - * Set first_free_x to FIRST_FREE_NONE to indicate no free cell. - */ - int first_free_x, first_free_y; -} Subgrid; - -struct NautilusIconGrid { - GPtrArray *subgrids; - - double world_visible_width; -}; - -static Subgrid * -subgrid_new (int power) -{ - Subgrid *subgrid; - - subgrid = g_new0 (Subgrid, 1); - subgrid->power = power; - return subgrid; -} - -static void -subgrid_free (Subgrid *subgrid) -{ - int i, num_elements; - - if (subgrid == NULL) { - return; - } - - num_elements = (subgrid->bounds.x1 - subgrid->bounds.x0) - * (subgrid->bounds.y1 - subgrid->bounds.y0); - for (i = 0; i < num_elements; i++) { - g_list_free (subgrid->elements[i]); - } - g_free (subgrid->elements); - g_free (subgrid); -} - -static GList ** -get_element_ptr (GList **elements, - const ArtIRect *bounds, - int x, int y) -{ - g_assert (x >= bounds->x0); - g_assert (y >= bounds->y0); - g_assert (x < bounds->x1); - g_assert (y < bounds->y1); - - return &elements[(y - bounds->y0) - * (bounds->x1 - bounds->x0) - + (x - bounds->x0)]; -} - -static GList ** -subgrid_get_element_ptr (Subgrid *subgrid, - int x, int y) -{ - return get_element_ptr (subgrid->elements, &subgrid->bounds, x, y); -} - -static void -resize (Subgrid *subgrid, - const ArtIRect *new_bounds) -{ - int new_size; - GList **new_elements; - int x, y; - - g_assert (nautilus_art_irect_contains_irect (new_bounds, &subgrid->bounds)); - g_assert (new_bounds->x1 >= subgrid->visible_width); - - new_size = (new_bounds->x1 - new_bounds->x0) * (new_bounds->y1 - new_bounds->y0); - new_elements = g_new0 (GList *, new_size); - - for (x = subgrid->bounds.x0; x < subgrid->bounds.x1; x++) { - for (y = subgrid->bounds.y0; y < subgrid->bounds.y1; y++) { - *get_element_ptr (new_elements, new_bounds, x, y) = - *subgrid_get_element_ptr (subgrid, x, y); - } - } - - g_free (subgrid->elements); - subgrid->elements = new_elements; - - /* We might have a newly-free position if we are making the grid taller. */ - if (new_bounds->y1 > subgrid->bounds.y1 - && subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid->first_free_x = 0; - subgrid->first_free_y = subgrid->bounds.y1; - } - - subgrid->bounds = *new_bounds; -} - -static void -update_first_free_forward (Subgrid *subgrid) -{ - int x, y; - - if (subgrid->first_free_x == FIRST_FREE_NONE) { - x = 0; - y = 0; - } else { - x = subgrid->first_free_x; - y = subgrid->first_free_y; - } - - while (y < subgrid->bounds.y1) { - if (*subgrid_get_element_ptr (subgrid, x, y) == NULL) { - subgrid->first_free_x = x; - subgrid->first_free_y = y; - return; - } - - x++; - if (x >= subgrid->visible_width) { - x = 0; - y++; - } - } - - /* No free cell found. */ - subgrid->first_free_x = FIRST_FREE_NONE; -} - -static void -subgrid_set_visible_width (Subgrid *subgrid, - double world_visible_width) -{ - int visible_width; - ArtIRect bounds; - - if (subgrid == NULL) { - return; - } - - visible_width = MAX (floor (world_visible_width - / (BASE_CELL_WIDTH * (1 << subgrid->power))), - 1); - - if (visible_width > subgrid->bounds.x1) { - bounds = subgrid->bounds; - bounds.x1 = visible_width; - resize (subgrid, &bounds); - } - - /* Check and see if there are newly-free positions because - * the layout part of the grid is getting wider. - */ - if (visible_width > subgrid->visible_width - && subgrid->bounds.y1 > 0 - && subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid->first_free_x = visible_width; - subgrid->first_free_y = 0; - } - - subgrid->visible_width = visible_width; - - /* Check and see if the old first-free position is illegal - * because the layout part of the grid is getting narrower. - */ - if (subgrid->first_free_x >= visible_width) { - g_assert (subgrid->first_free_x != FIRST_FREE_NONE); - if (subgrid->first_free_y == subgrid->bounds.y1 - 1) { - subgrid->first_free_x = FIRST_FREE_NONE; - } else { - subgrid->first_free_x = 0; - subgrid->first_free_y++; - update_first_free_forward (subgrid); - } - } -} - -static void -maybe_resize (Subgrid *subgrid, - int x, int y) -{ - ArtIRect new_bounds; - - new_bounds = subgrid->bounds; - - if (new_bounds.x0 == new_bounds.x1) { - if (subgrid->visible_width != 0) { - new_bounds.x1 = subgrid->visible_width; - } else { - new_bounds.x1 = INITIAL_GRID_WIDTH; - } - } - - if (new_bounds.y0 == new_bounds.y1) { - new_bounds.y1 = INITIAL_GRID_HEIGHT; - } - - while (x < new_bounds.x0) { - new_bounds.x0 -= new_bounds.x1 - new_bounds.x0; - } - while (x >= new_bounds.x1) { - new_bounds.x1 += new_bounds.x1 - new_bounds.x0; - } - while (y < new_bounds.y0) { - new_bounds.y0 -= new_bounds.y1 - new_bounds.y0; - } - while (y >= new_bounds.y1) { - new_bounds.y1 += new_bounds.y1 - new_bounds.y0; - } - - if (!nautilus_art_irect_equal (&new_bounds, &subgrid->bounds)) { - resize (subgrid, &new_bounds); - } -} - -static void -subgrid_add_one (Subgrid *subgrid, - NautilusIcon *icon, - int x, int y) -{ - GList **elem_ptr; - - maybe_resize (subgrid, x, y); - - elem_ptr = subgrid_get_element_ptr (subgrid, x, y); - g_assert (g_list_find (*elem_ptr, icon) == NULL); - *elem_ptr = g_list_prepend (*elem_ptr, icon); - - if (x == subgrid->first_free_x && y == subgrid->first_free_y) { - update_first_free_forward (subgrid); - } -} - -static void -subgrid_remove_one (Subgrid *subgrid, - NautilusIcon *icon, - int x, int y) -{ - GList **elem_ptr; - - elem_ptr = subgrid_get_element_ptr (subgrid, x, y); - g_assert (g_list_find (*elem_ptr, icon) != NULL); - *elem_ptr = g_list_remove (*elem_ptr, icon); - - if (*elem_ptr == NULL) { - if (subgrid->first_free_x == FIRST_FREE_NONE - || subgrid->first_free_y > y - || (subgrid->first_free_y == y && subgrid->first_free_x > x)) { - subgrid->first_free_x = x; - subgrid->first_free_y = y; - } - } -} - -static void -subgrid_add_or_remove (Subgrid *subgrid, - NautilusIcon *icon, - gboolean add) -{ - int x, y; - - if (subgrid == NULL) { - return; - } - - /* Add/remove to all the overlapped grid squares. */ - for (x = (icon->grid_rectangle.x0 >> subgrid->power); - x < ((icon->grid_rectangle.x1 + ((1 << subgrid->power) - 1)) >> subgrid->power); - x++) { - for (y = (icon->grid_rectangle.y0 >> subgrid->power); - y < ((icon->grid_rectangle.y1 + ((1 << subgrid->power) - 1)) >> subgrid->power); - y++) { - if (add) { - subgrid_add_one (subgrid, icon, x, y); - } else { - subgrid_remove_one (subgrid, icon, x, y); - } - } - } -} - -static void -subgrid_get_position (Subgrid *subgrid, - NautilusIcon *icon, - ArtPoint *position) -{ - int subgrid_x, subgrid_y; - - if (subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid_x = 0; - subgrid_y = subgrid->bounds.y1; - } else { - subgrid_x = subgrid->first_free_x; - subgrid_y = subgrid->first_free_y; - } - - position->x = (double) subgrid_x * (BASE_CELL_WIDTH << subgrid->power); - position->y = (double) subgrid_y * (BASE_CELL_HEIGHT << subgrid->power); -} - -static int -nautilus_compare_pointers_as_integers (gconstpointer a, gconstpointer b) -{ - int ai, bi; - - ai = GPOINTER_TO_INT (a); - bi = GPOINTER_TO_INT (b); - if (ai < bi) { - return -1; - } - if (ai > bi) { - return 1; - } - return 0; -} - -static GList * -nautilus_g_list_remove_duplicates (GList *list) -{ - GList *p, *next; - gpointer previous_data; - - list = g_list_sort (list, nautilus_compare_pointers_as_integers); - - previous_data = NULL; - for (p = list; p != NULL; p = next) { - next = p->next; - - g_assert (p->data != NULL); - if (previous_data != p->data) { - previous_data = p->data; - } else { - list = g_list_remove_link (list, p); - g_list_free_1 (p); - } - } - return list; -} - -static GList * -subgrid_get_intersecting_icons (Subgrid *subgrid, - const ArtDRect *world_rect) -{ - ArtIRect test_rect; - int x, y; - GList *list; - GList *cell_list; - - if (subgrid == NULL) { - return NULL; - } - - if (world_rect == NULL) { - test_rect = subgrid->bounds; - } else { - test_rect.x0 = floor (world_rect->x0 / (BASE_CELL_WIDTH << subgrid->power)); - test_rect.y0 = floor (world_rect->y0 / (BASE_CELL_HEIGHT << subgrid->power)); - test_rect.x1 = ceil (world_rect->x1 / (BASE_CELL_WIDTH << subgrid->power)); - test_rect.y1 = ceil (world_rect->y1 / (BASE_CELL_HEIGHT << subgrid->power)); - - art_irect_intersect (&test_rect, &test_rect, &subgrid->bounds); - } - - list = NULL; - for (x = test_rect.x0; x < test_rect.x1; x++) { - for (y = test_rect.y0; y < test_rect.y1; y++) { - cell_list = *subgrid_get_element_ptr (subgrid, x, y); - list = g_list_concat (list, g_list_copy (cell_list)); - } - } - return nautilus_g_list_remove_duplicates (list); -} - -/* Get the smallest subgrid. */ -static Subgrid * -get_smallest_subgrid (NautilusIconGrid *grid) -{ - int i; - Subgrid *subgrid; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid = g_ptr_array_index (grid->subgrids, i); - if (subgrid != NULL) { - return subgrid; - } - } - - return NULL; -} - -/* Get the smallest subgrid. */ -static Subgrid * -get_largest_subgrid (NautilusIconGrid *grid) -{ - int i; - Subgrid *subgrid; - - for (i = grid->subgrids->len; i != 0; i--) { - subgrid = g_ptr_array_index (grid->subgrids, i-1); - if (subgrid != NULL) { - return subgrid; - } - } - - return NULL; -} - -/* Create a subgrid if we have to. */ -static Subgrid * -create_subgrid (NautilusIconGrid *grid, int power) -{ - Subgrid *subgrid; - GList *icons, *p; - - /* Make space for the new subgrid in the array. */ - if (grid->subgrids->len <= power) { - g_ptr_array_set_size (grid->subgrids, power + 1); - } - - /* If it was already there, return it. */ - subgrid = g_ptr_array_index (grid->subgrids, power); - if (subgrid != NULL) { - return subgrid; - } - - /* Create the new subgrid. */ - subgrid = subgrid_new (power); - subgrid_set_visible_width (subgrid, grid->world_visible_width); - - /* Add the icons to it. */ - icons = subgrid_get_intersecting_icons - (get_largest_subgrid (grid), NULL); - for (p = icons; p != NULL; p = p->next) { - subgrid_add_or_remove (subgrid, p->data, TRUE); - } - g_list_free (icons); - - /* Put it in the array and return. */ - g_ptr_array_index (grid->subgrids, power) = subgrid; - return subgrid; -} - -NautilusIconGrid * -nautilus_icon_grid_new (void) -{ - NautilusIconGrid *grid; - - grid = g_new0 (NautilusIconGrid, 1); - grid->subgrids = g_ptr_array_new (); - return grid; -} - -void -nautilus_icon_grid_clear (NautilusIconGrid *grid) -{ - int i; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_free (g_ptr_array_index (grid->subgrids, i)); - } - - /* Would just set size to 0 here, but that leaves around - * non-NULL entries in the array. - */ - g_ptr_array_free (grid->subgrids, TRUE); - grid->subgrids = g_ptr_array_new (); -} - -void -nautilus_icon_grid_destroy (NautilusIconGrid *grid) -{ - nautilus_icon_grid_clear (grid); - g_ptr_array_free (grid->subgrids, TRUE); - g_free (grid); -} - -void -nautilus_icon_grid_set_visible_width (NautilusIconGrid *grid, - double world_visible_width) -{ - int i; - - if (grid->world_visible_width == world_visible_width) { - return; - } - - grid->world_visible_width = world_visible_width; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_set_visible_width - (g_ptr_array_index (grid->subgrids, i), - world_visible_width); - } -} - -/* Get the size of the icon as a power of two. - * Size 0 means it fits in 1x1 grid cells. - * Size 1 means it fits in 2x2 grid cells. - */ -static int -get_icon_size_power_from_bounds (const ArtDRect *world_bounds) -{ - int cell_count, power; - - cell_count = MAX (ceil ((world_bounds->x1 - world_bounds->x0) / BASE_CELL_WIDTH) - + BASE_CELL_WIDTH / 2, - ceil ((world_bounds->y1 - world_bounds->y0) / BASE_CELL_HEIGHT) - + BASE_CELL_HEIGHT / 2); - - for (power = 0; cell_count > 1; power++) { - cell_count /= 2; - } - return power; -} - -static int -get_icon_size_power (NautilusIcon *icon) -{ - ArtDRect world_bounds; - - nautilus_gnome_canvas_item_get_world_bounds - (GNOME_CANVAS_ITEM (icon->item), &world_bounds); - return get_icon_size_power_from_bounds (&world_bounds); -} - -void -nautilus_icon_grid_add (NautilusIconGrid *grid, - NautilusIcon *icon) -{ - ArtDRect world_bounds; - int power, i; - - /* Figure out how big the icon is. */ - nautilus_gnome_canvas_item_get_world_bounds - (GNOME_CANVAS_ITEM (icon->item), &world_bounds); - power = get_icon_size_power_from_bounds (&world_bounds); - - /* Compute grid bounds for the icon. */ - icon->grid_rectangle.x0 = (int) floor (world_bounds.x0 / (BASE_CELL_WIDTH << power)) << power; - icon->grid_rectangle.y0 = (int) floor (world_bounds.y0 / (BASE_CELL_HEIGHT << power)) << power; - icon->grid_rectangle.x1 = (int) ceil (world_bounds.x1 / (BASE_CELL_WIDTH << power)) << power; - icon->grid_rectangle.y1 = (int) ceil (world_bounds.y1 / (BASE_CELL_HEIGHT << power)) << power; - - if (grid->subgrids->len == 0) { - create_subgrid (grid, power); - } - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_add_or_remove - (g_ptr_array_index (grid->subgrids, i), - icon, TRUE); - } -} - -void -nautilus_icon_grid_remove (NautilusIconGrid *grid, - NautilusIcon *icon) -{ - int i; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_add_or_remove - (g_ptr_array_index (grid->subgrids, i), - icon, FALSE); - } -} - -void -nautilus_icon_grid_get_position (NautilusIconGrid *grid, - NautilusIcon *icon, - ArtPoint *position) -{ - ArtDRect icon_rect; - int power; - - g_return_if_fail (grid != NULL); - g_return_if_fail (position != NULL); - - power = get_icon_size_power (icon); - subgrid_get_position - (create_subgrid (grid, power), - icon, position); - - /* Position the icon centered in the X space - * and at the top of the Y space. - */ - nautilus_icon_canvas_item_get_icon_rectangle - (icon->item, &icon_rect); - position->x += ((BASE_CELL_WIDTH << power) - - (icon_rect.x1 - icon_rect.x0)) / 2; -} - -GList * -nautilus_icon_grid_get_intersecting_icons (NautilusIconGrid *grid, - const ArtDRect *world_rect) -{ - return subgrid_get_intersecting_icons - (get_smallest_subgrid (grid), world_rect); -} diff --git a/libnautilus-extensions/nautilus-icon-grid.h b/libnautilus-extensions/nautilus-icon-grid.h deleted file mode 100644 index 6b6d7ee8f..000000000 --- a/libnautilus-extensions/nautilus-icon-grid.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-icon-grid.h - Grid used by icon container. - - Copyright (C) 1999, 2000 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli <ettore@gnu.org>, - Darin Adler <darin@eazel.com> -*/ - -#include "nautilus-icon-private.h" - -/* setting up the grid */ -NautilusIconGrid * nautilus_icon_grid_new (void); -void nautilus_icon_grid_destroy (NautilusIconGrid *grid); -void nautilus_icon_grid_clear (NautilusIconGrid *grid); -void nautilus_icon_grid_set_visible_width (NautilusIconGrid *grid, - double world_visible_width); - -/* getting icons in and out of the grid */ -void nautilus_icon_grid_add (NautilusIconGrid *grid, - NautilusIcon *icon); -void nautilus_icon_grid_remove (NautilusIconGrid *grid, - NautilusIcon *icon); -void nautilus_icon_grid_get_position (NautilusIconGrid *grid, - NautilusIcon *icon, - ArtPoint *world_point); - -/* getting groups of icons in parts of the grid */ -GList *nautilus_icon_grid_get_intersecting_icons (NautilusIconGrid *grid, - const ArtDRect *world_rectangle); diff --git a/libnautilus-private/nautilus-icon-grid.c b/libnautilus-private/nautilus-icon-grid.c deleted file mode 100644 index a224cf7fc..000000000 --- a/libnautilus-private/nautilus-icon-grid.c +++ /dev/null @@ -1,658 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-icon-container-grid.c - Grid used by icon container. - - Copyright (C) 1999, 2000 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli <ettore@gnu.org>, - Darin Adler <darin@eazel.com> -*/ - -#include <config.h> -#include "nautilus-icon-grid.h" - -#include <string.h> -#include <math.h> -#include "nautilus-gnome-extensions.h" - -#define INITIAL_GRID_WIDTH 64 -#define INITIAL_GRID_HEIGHT 64 - -#define BASE_CELL_WIDTH 12 -#define BASE_CELL_HEIGHT 12 - -#define START_GRID_POWER 2 /* typical icon size */ - -#define FIRST_FREE_NONE G_MININT - -/* This is a single grid at one grid resolution. - * The icon grid as a whole is a set of these for each size. - */ -typedef struct { - /* Grid resolution 2^<power>. */ - int power; - - /* This is the number or grid positions that we actually use - * for finding positions for new icons. - */ - int visible_width; - - /* The grid. This is automatically sized to fit all the - * icons, so it doesn't need to be explicitly allocated. - */ - ArtIRect bounds; - GList **elements; - - /* Position of the first free cell (used to speed up get_position). - * Set first_free_x to FIRST_FREE_NONE to indicate no free cell. - */ - int first_free_x, first_free_y; -} Subgrid; - -struct NautilusIconGrid { - GPtrArray *subgrids; - - double world_visible_width; -}; - -static Subgrid * -subgrid_new (int power) -{ - Subgrid *subgrid; - - subgrid = g_new0 (Subgrid, 1); - subgrid->power = power; - return subgrid; -} - -static void -subgrid_free (Subgrid *subgrid) -{ - int i, num_elements; - - if (subgrid == NULL) { - return; - } - - num_elements = (subgrid->bounds.x1 - subgrid->bounds.x0) - * (subgrid->bounds.y1 - subgrid->bounds.y0); - for (i = 0; i < num_elements; i++) { - g_list_free (subgrid->elements[i]); - } - g_free (subgrid->elements); - g_free (subgrid); -} - -static GList ** -get_element_ptr (GList **elements, - const ArtIRect *bounds, - int x, int y) -{ - g_assert (x >= bounds->x0); - g_assert (y >= bounds->y0); - g_assert (x < bounds->x1); - g_assert (y < bounds->y1); - - return &elements[(y - bounds->y0) - * (bounds->x1 - bounds->x0) - + (x - bounds->x0)]; -} - -static GList ** -subgrid_get_element_ptr (Subgrid *subgrid, - int x, int y) -{ - return get_element_ptr (subgrid->elements, &subgrid->bounds, x, y); -} - -static void -resize (Subgrid *subgrid, - const ArtIRect *new_bounds) -{ - int new_size; - GList **new_elements; - int x, y; - - g_assert (nautilus_art_irect_contains_irect (new_bounds, &subgrid->bounds)); - g_assert (new_bounds->x1 >= subgrid->visible_width); - - new_size = (new_bounds->x1 - new_bounds->x0) * (new_bounds->y1 - new_bounds->y0); - new_elements = g_new0 (GList *, new_size); - - for (x = subgrid->bounds.x0; x < subgrid->bounds.x1; x++) { - for (y = subgrid->bounds.y0; y < subgrid->bounds.y1; y++) { - *get_element_ptr (new_elements, new_bounds, x, y) = - *subgrid_get_element_ptr (subgrid, x, y); - } - } - - g_free (subgrid->elements); - subgrid->elements = new_elements; - - /* We might have a newly-free position if we are making the grid taller. */ - if (new_bounds->y1 > subgrid->bounds.y1 - && subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid->first_free_x = 0; - subgrid->first_free_y = subgrid->bounds.y1; - } - - subgrid->bounds = *new_bounds; -} - -static void -update_first_free_forward (Subgrid *subgrid) -{ - int x, y; - - if (subgrid->first_free_x == FIRST_FREE_NONE) { - x = 0; - y = 0; - } else { - x = subgrid->first_free_x; - y = subgrid->first_free_y; - } - - while (y < subgrid->bounds.y1) { - if (*subgrid_get_element_ptr (subgrid, x, y) == NULL) { - subgrid->first_free_x = x; - subgrid->first_free_y = y; - return; - } - - x++; - if (x >= subgrid->visible_width) { - x = 0; - y++; - } - } - - /* No free cell found. */ - subgrid->first_free_x = FIRST_FREE_NONE; -} - -static void -subgrid_set_visible_width (Subgrid *subgrid, - double world_visible_width) -{ - int visible_width; - ArtIRect bounds; - - if (subgrid == NULL) { - return; - } - - visible_width = MAX (floor (world_visible_width - / (BASE_CELL_WIDTH * (1 << subgrid->power))), - 1); - - if (visible_width > subgrid->bounds.x1) { - bounds = subgrid->bounds; - bounds.x1 = visible_width; - resize (subgrid, &bounds); - } - - /* Check and see if there are newly-free positions because - * the layout part of the grid is getting wider. - */ - if (visible_width > subgrid->visible_width - && subgrid->bounds.y1 > 0 - && subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid->first_free_x = visible_width; - subgrid->first_free_y = 0; - } - - subgrid->visible_width = visible_width; - - /* Check and see if the old first-free position is illegal - * because the layout part of the grid is getting narrower. - */ - if (subgrid->first_free_x >= visible_width) { - g_assert (subgrid->first_free_x != FIRST_FREE_NONE); - if (subgrid->first_free_y == subgrid->bounds.y1 - 1) { - subgrid->first_free_x = FIRST_FREE_NONE; - } else { - subgrid->first_free_x = 0; - subgrid->first_free_y++; - update_first_free_forward (subgrid); - } - } -} - -static void -maybe_resize (Subgrid *subgrid, - int x, int y) -{ - ArtIRect new_bounds; - - new_bounds = subgrid->bounds; - - if (new_bounds.x0 == new_bounds.x1) { - if (subgrid->visible_width != 0) { - new_bounds.x1 = subgrid->visible_width; - } else { - new_bounds.x1 = INITIAL_GRID_WIDTH; - } - } - - if (new_bounds.y0 == new_bounds.y1) { - new_bounds.y1 = INITIAL_GRID_HEIGHT; - } - - while (x < new_bounds.x0) { - new_bounds.x0 -= new_bounds.x1 - new_bounds.x0; - } - while (x >= new_bounds.x1) { - new_bounds.x1 += new_bounds.x1 - new_bounds.x0; - } - while (y < new_bounds.y0) { - new_bounds.y0 -= new_bounds.y1 - new_bounds.y0; - } - while (y >= new_bounds.y1) { - new_bounds.y1 += new_bounds.y1 - new_bounds.y0; - } - - if (!nautilus_art_irect_equal (&new_bounds, &subgrid->bounds)) { - resize (subgrid, &new_bounds); - } -} - -static void -subgrid_add_one (Subgrid *subgrid, - NautilusIcon *icon, - int x, int y) -{ - GList **elem_ptr; - - maybe_resize (subgrid, x, y); - - elem_ptr = subgrid_get_element_ptr (subgrid, x, y); - g_assert (g_list_find (*elem_ptr, icon) == NULL); - *elem_ptr = g_list_prepend (*elem_ptr, icon); - - if (x == subgrid->first_free_x && y == subgrid->first_free_y) { - update_first_free_forward (subgrid); - } -} - -static void -subgrid_remove_one (Subgrid *subgrid, - NautilusIcon *icon, - int x, int y) -{ - GList **elem_ptr; - - elem_ptr = subgrid_get_element_ptr (subgrid, x, y); - g_assert (g_list_find (*elem_ptr, icon) != NULL); - *elem_ptr = g_list_remove (*elem_ptr, icon); - - if (*elem_ptr == NULL) { - if (subgrid->first_free_x == FIRST_FREE_NONE - || subgrid->first_free_y > y - || (subgrid->first_free_y == y && subgrid->first_free_x > x)) { - subgrid->first_free_x = x; - subgrid->first_free_y = y; - } - } -} - -static void -subgrid_add_or_remove (Subgrid *subgrid, - NautilusIcon *icon, - gboolean add) -{ - int x, y; - - if (subgrid == NULL) { - return; - } - - /* Add/remove to all the overlapped grid squares. */ - for (x = (icon->grid_rectangle.x0 >> subgrid->power); - x < ((icon->grid_rectangle.x1 + ((1 << subgrid->power) - 1)) >> subgrid->power); - x++) { - for (y = (icon->grid_rectangle.y0 >> subgrid->power); - y < ((icon->grid_rectangle.y1 + ((1 << subgrid->power) - 1)) >> subgrid->power); - y++) { - if (add) { - subgrid_add_one (subgrid, icon, x, y); - } else { - subgrid_remove_one (subgrid, icon, x, y); - } - } - } -} - -static void -subgrid_get_position (Subgrid *subgrid, - NautilusIcon *icon, - ArtPoint *position) -{ - int subgrid_x, subgrid_y; - - if (subgrid->first_free_x == FIRST_FREE_NONE) { - subgrid_x = 0; - subgrid_y = subgrid->bounds.y1; - } else { - subgrid_x = subgrid->first_free_x; - subgrid_y = subgrid->first_free_y; - } - - position->x = (double) subgrid_x * (BASE_CELL_WIDTH << subgrid->power); - position->y = (double) subgrid_y * (BASE_CELL_HEIGHT << subgrid->power); -} - -static int -nautilus_compare_pointers_as_integers (gconstpointer a, gconstpointer b) -{ - int ai, bi; - - ai = GPOINTER_TO_INT (a); - bi = GPOINTER_TO_INT (b); - if (ai < bi) { - return -1; - } - if (ai > bi) { - return 1; - } - return 0; -} - -static GList * -nautilus_g_list_remove_duplicates (GList *list) -{ - GList *p, *next; - gpointer previous_data; - - list = g_list_sort (list, nautilus_compare_pointers_as_integers); - - previous_data = NULL; - for (p = list; p != NULL; p = next) { - next = p->next; - - g_assert (p->data != NULL); - if (previous_data != p->data) { - previous_data = p->data; - } else { - list = g_list_remove_link (list, p); - g_list_free_1 (p); - } - } - return list; -} - -static GList * -subgrid_get_intersecting_icons (Subgrid *subgrid, - const ArtDRect *world_rect) -{ - ArtIRect test_rect; - int x, y; - GList *list; - GList *cell_list; - - if (subgrid == NULL) { - return NULL; - } - - if (world_rect == NULL) { - test_rect = subgrid->bounds; - } else { - test_rect.x0 = floor (world_rect->x0 / (BASE_CELL_WIDTH << subgrid->power)); - test_rect.y0 = floor (world_rect->y0 / (BASE_CELL_HEIGHT << subgrid->power)); - test_rect.x1 = ceil (world_rect->x1 / (BASE_CELL_WIDTH << subgrid->power)); - test_rect.y1 = ceil (world_rect->y1 / (BASE_CELL_HEIGHT << subgrid->power)); - - art_irect_intersect (&test_rect, &test_rect, &subgrid->bounds); - } - - list = NULL; - for (x = test_rect.x0; x < test_rect.x1; x++) { - for (y = test_rect.y0; y < test_rect.y1; y++) { - cell_list = *subgrid_get_element_ptr (subgrid, x, y); - list = g_list_concat (list, g_list_copy (cell_list)); - } - } - return nautilus_g_list_remove_duplicates (list); -} - -/* Get the smallest subgrid. */ -static Subgrid * -get_smallest_subgrid (NautilusIconGrid *grid) -{ - int i; - Subgrid *subgrid; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid = g_ptr_array_index (grid->subgrids, i); - if (subgrid != NULL) { - return subgrid; - } - } - - return NULL; -} - -/* Get the smallest subgrid. */ -static Subgrid * -get_largest_subgrid (NautilusIconGrid *grid) -{ - int i; - Subgrid *subgrid; - - for (i = grid->subgrids->len; i != 0; i--) { - subgrid = g_ptr_array_index (grid->subgrids, i-1); - if (subgrid != NULL) { - return subgrid; - } - } - - return NULL; -} - -/* Create a subgrid if we have to. */ -static Subgrid * -create_subgrid (NautilusIconGrid *grid, int power) -{ - Subgrid *subgrid; - GList *icons, *p; - - /* Make space for the new subgrid in the array. */ - if (grid->subgrids->len <= power) { - g_ptr_array_set_size (grid->subgrids, power + 1); - } - - /* If it was already there, return it. */ - subgrid = g_ptr_array_index (grid->subgrids, power); - if (subgrid != NULL) { - return subgrid; - } - - /* Create the new subgrid. */ - subgrid = subgrid_new (power); - subgrid_set_visible_width (subgrid, grid->world_visible_width); - - /* Add the icons to it. */ - icons = subgrid_get_intersecting_icons - (get_largest_subgrid (grid), NULL); - for (p = icons; p != NULL; p = p->next) { - subgrid_add_or_remove (subgrid, p->data, TRUE); - } - g_list_free (icons); - - /* Put it in the array and return. */ - g_ptr_array_index (grid->subgrids, power) = subgrid; - return subgrid; -} - -NautilusIconGrid * -nautilus_icon_grid_new (void) -{ - NautilusIconGrid *grid; - - grid = g_new0 (NautilusIconGrid, 1); - grid->subgrids = g_ptr_array_new (); - return grid; -} - -void -nautilus_icon_grid_clear (NautilusIconGrid *grid) -{ - int i; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_free (g_ptr_array_index (grid->subgrids, i)); - } - - /* Would just set size to 0 here, but that leaves around - * non-NULL entries in the array. - */ - g_ptr_array_free (grid->subgrids, TRUE); - grid->subgrids = g_ptr_array_new (); -} - -void -nautilus_icon_grid_destroy (NautilusIconGrid *grid) -{ - nautilus_icon_grid_clear (grid); - g_ptr_array_free (grid->subgrids, TRUE); - g_free (grid); -} - -void -nautilus_icon_grid_set_visible_width (NautilusIconGrid *grid, - double world_visible_width) -{ - int i; - - if (grid->world_visible_width == world_visible_width) { - return; - } - - grid->world_visible_width = world_visible_width; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_set_visible_width - (g_ptr_array_index (grid->subgrids, i), - world_visible_width); - } -} - -/* Get the size of the icon as a power of two. - * Size 0 means it fits in 1x1 grid cells. - * Size 1 means it fits in 2x2 grid cells. - */ -static int -get_icon_size_power_from_bounds (const ArtDRect *world_bounds) -{ - int cell_count, power; - - cell_count = MAX (ceil ((world_bounds->x1 - world_bounds->x0) / BASE_CELL_WIDTH) - + BASE_CELL_WIDTH / 2, - ceil ((world_bounds->y1 - world_bounds->y0) / BASE_CELL_HEIGHT) - + BASE_CELL_HEIGHT / 2); - - for (power = 0; cell_count > 1; power++) { - cell_count /= 2; - } - return power; -} - -static int -get_icon_size_power (NautilusIcon *icon) -{ - ArtDRect world_bounds; - - nautilus_gnome_canvas_item_get_world_bounds - (GNOME_CANVAS_ITEM (icon->item), &world_bounds); - return get_icon_size_power_from_bounds (&world_bounds); -} - -void -nautilus_icon_grid_add (NautilusIconGrid *grid, - NautilusIcon *icon) -{ - ArtDRect world_bounds; - int power, i; - - /* Figure out how big the icon is. */ - nautilus_gnome_canvas_item_get_world_bounds - (GNOME_CANVAS_ITEM (icon->item), &world_bounds); - power = get_icon_size_power_from_bounds (&world_bounds); - - /* Compute grid bounds for the icon. */ - icon->grid_rectangle.x0 = (int) floor (world_bounds.x0 / (BASE_CELL_WIDTH << power)) << power; - icon->grid_rectangle.y0 = (int) floor (world_bounds.y0 / (BASE_CELL_HEIGHT << power)) << power; - icon->grid_rectangle.x1 = (int) ceil (world_bounds.x1 / (BASE_CELL_WIDTH << power)) << power; - icon->grid_rectangle.y1 = (int) ceil (world_bounds.y1 / (BASE_CELL_HEIGHT << power)) << power; - - if (grid->subgrids->len == 0) { - create_subgrid (grid, power); - } - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_add_or_remove - (g_ptr_array_index (grid->subgrids, i), - icon, TRUE); - } -} - -void -nautilus_icon_grid_remove (NautilusIconGrid *grid, - NautilusIcon *icon) -{ - int i; - - for (i = 0; i < grid->subgrids->len; i++) { - subgrid_add_or_remove - (g_ptr_array_index (grid->subgrids, i), - icon, FALSE); - } -} - -void -nautilus_icon_grid_get_position (NautilusIconGrid *grid, - NautilusIcon *icon, - ArtPoint *position) -{ - ArtDRect icon_rect; - int power; - - g_return_if_fail (grid != NULL); - g_return_if_fail (position != NULL); - - power = get_icon_size_power (icon); - subgrid_get_position - (create_subgrid (grid, power), - icon, position); - - /* Position the icon centered in the X space - * and at the top of the Y space. - */ - nautilus_icon_canvas_item_get_icon_rectangle - (icon->item, &icon_rect); - position->x += ((BASE_CELL_WIDTH << power) - - (icon_rect.x1 - icon_rect.x0)) / 2; -} - -GList * -nautilus_icon_grid_get_intersecting_icons (NautilusIconGrid *grid, - const ArtDRect *world_rect) -{ - return subgrid_get_intersecting_icons - (get_smallest_subgrid (grid), world_rect); -} diff --git a/libnautilus-private/nautilus-icon-grid.h b/libnautilus-private/nautilus-icon-grid.h deleted file mode 100644 index 6b6d7ee8f..000000000 --- a/libnautilus-private/nautilus-icon-grid.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-icon-grid.h - Grid used by icon container. - - Copyright (C) 1999, 2000 Free Software Foundation - Copyright (C) 2000 Eazel, Inc. - - The Gnome Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Gnome 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Gnome Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Authors: Ettore Perazzoli <ettore@gnu.org>, - Darin Adler <darin@eazel.com> -*/ - -#include "nautilus-icon-private.h" - -/* setting up the grid */ -NautilusIconGrid * nautilus_icon_grid_new (void); -void nautilus_icon_grid_destroy (NautilusIconGrid *grid); -void nautilus_icon_grid_clear (NautilusIconGrid *grid); -void nautilus_icon_grid_set_visible_width (NautilusIconGrid *grid, - double world_visible_width); - -/* getting icons in and out of the grid */ -void nautilus_icon_grid_add (NautilusIconGrid *grid, - NautilusIcon *icon); -void nautilus_icon_grid_remove (NautilusIconGrid *grid, - NautilusIcon *icon); -void nautilus_icon_grid_get_position (NautilusIconGrid *grid, - NautilusIcon *icon, - ArtPoint *world_point); - -/* getting groups of icons in parts of the grid */ -GList *nautilus_icon_grid_get_intersecting_icons (NautilusIconGrid *grid, - const ArtDRect *world_rectangle); diff --git a/nautilus-installer/src/Makefile.am b/nautilus-installer/src/Makefile.am index cd6ce835d..8ffe712c3 100644 --- a/nautilus-installer/src/Makefile.am +++ b/nautilus-installer/src/Makefile.am @@ -26,7 +26,7 @@ nautilus_installer_SOURCES = \ support.c support.h \ interface.c interface.h \ callbacks.c callbacks.h \ - installer.c installer h + installer.c installer.h nautilus_installer_LDFLAGS = -static diff --git a/src/Makefile.am b/src/Makefile.am index 3b7c5bf36..f8db362c7 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -38,69 +38,70 @@ LDADD =\ $(NULL) noinst_HEADERS = \ - nautilus-application.h \ nautilus-applicable-views.h \ + nautilus-application.h \ nautilus-bookmark-list.h \ nautilus-bookmarks-window.h \ + nautilus-complex-search-bar.h \ nautilus-desktop-window.h \ nautilus-first-time-druid.h \ nautilus-link-set-window.h \ nautilus-location-bar.h \ - nautilus-search-bar.h \ - nautilus-search-bar-criterion.h \ - nautilus-switchable-search-bar.h \ - nautilus-simple-search-bar.h \ - nautilus-complex-search-bar.h \ nautilus-navigation-bar.h \ nautilus-property-browser.h \ + nautilus-search-bar-criterion.h \ + nautilus-search-bar-private.h \ + nautilus-search-bar.h \ nautilus-self-check-functions.h \ - nautilus-signaller.h \ - nautilus-zoom-control.h \ - nautilus-switchable-navigation-bar.h \ - nautilus-sidebar.h \ nautilus-sidebar-tabs.h \ nautilus-sidebar-title.h \ + nautilus-sidebar.h \ + nautilus-signaller.h \ + nautilus-simple-search-bar.h \ + nautilus-switchable-navigation-bar.h \ + nautilus-switchable-search-bar.h \ nautilus-view-frame-private.h \ nautilus-view-frame.h \ nautilus-window-manage-views.h \ nautilus-window-private.h \ nautilus-window.h \ + nautilus-zoom-control.h \ $(NULL) nautilus_SOURCES =\ + nautilus-applicable-views.c \ + nautilus-application.c \ nautilus-bookmark-list.c \ nautilus-bookmarks-window.c \ + nautilus-complex-search-bar.c \ nautilus-desktop-window.c \ nautilus-first-time-druid.c \ nautilus-link-set-window.c \ nautilus-location-bar.c \ - nautilus-search-bar.c \ - nautilus-switchable-search-bar.c \ - nautilus-search-bar-criterion.c \ - nautilus-simple-search-bar.c \ - nautilus-complex-search-bar.c \ + nautilus-main.c \ nautilus-navigation-bar.c \ nautilus-property-browser.c \ + nautilus-search-bar-criterion.c \ + nautilus-search-bar.c \ nautilus-self-check-functions.c \ - nautilus-signaller.c \ - nautilus-window-menus.c \ - nautilus-window-toolbars.c \ - nautilus-zoom-control.c \ - nautilus-zoomable-frame-corba.c \ - nautilus-application.c \ - nautilus-sidebar.c \ nautilus-sidebar-tabs.c \ nautilus-sidebar-title.c \ + nautilus-sidebar.c \ + nautilus-signaller.c \ + nautilus-simple-search-bar.c \ nautilus-switchable-navigation-bar.c \ - nautilus-main.c \ - nautilus-applicable-views.c \ + nautilus-switchable-search-bar.c \ nautilus-view-frame-bonobo-control.c \ nautilus-view-frame-bonobo-embeddable.c \ nautilus-view-frame-corba.c \ nautilus-view-frame-nautilus-view.c \ nautilus-view-frame.c \ nautilus-window-manage-views.c \ + nautilus-window-menus.c \ + nautilus-window-toolbars.c \ nautilus-window.c \ + nautilus-zoom-control.c \ + nautilus-zoomable-frame-corba.c \ $(NULL) TESTS=check-nautilus diff --git a/src/file-manager/fm-directory-list.h b/src/file-manager/fm-directory-list.h deleted file mode 100644 index 4db7841bb..000000000 --- a/src/file-manager/fm-directory-list.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C; c-set-style: linux; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * GNOME File Manager (Directory list object) - * - * Copyright (C) 1999, 2000 Red Hat 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 - * - * Developed by: Havoc Pennington - */ -#ifndef __FM_DIRECTORY_LIST_H__ -#define __FM_DIRECTORY_LIST_H__ - -#include <libgnome/gnome-defs.h> -#include <libgnomevfs/gnome-vfs.h> -#include <gdk-pixbuf/gdk-pixbuf.h> -#include <gtk/gtk.h> - -BEGIN_GNOME_DECLS - -/* An entry in the directory list */ - -typedef struct _FMDirectoryListEntry FMDirectoryListEntry; - -void fm_directory_list_entry_ref (FMDirectoryListEntry *entry); -void fm_directory_list_entry_unref (FMDirectoryListEntry *entry); -GnomeVFSFileInfo* fm_directory_list_entry_get_file_info (FMDirectoryListEntry *entry); -GdkPixbuf* fm_directory_list_entry_get_icon (FMDirectoryListEntry *entry); -const gchar* fm_directory_list_entry_get_name (FMDirectoryListEntry *entry); - - - -/* FMDirectoryList represents the non-graphical part of a - directory listing; two different kinds of view - currently exist, the FMDirectoryView and the - DesktopCanvas -*/ - -typedef struct _FMDirectoryList FMDirectoryList; -typedef struct _FMDirectoryListClass FMDirectoryListClass; - -#define FM_TYPE_DIRECTORY_LIST (fm_directory_list_get_type ()) -#define FM_DIRECTORY_LIST(obj) (GTK_CHECK_CAST ((obj), FM_TYPE_DIRECTORY_LIST, FMDirectoryList)) -#define FM_DIRECTORY_LIST_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), FM_TYPE_DIRECTORY_LIST, FMDirectoryListClass)) -#define FM_IS_DIRECTORY_LIST(obj) (GTK_CHECK_TYPE ((obj), FM_TYPE_DIRECTORY_LIST)) -#define FM_IS_DIRECTORY_LIST_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((obj), FM_TYPE_DIRECTORY_LIST)) - -struct _FMDirectoryList { - GtkObject object; - - GnomeVFSDirectoryList *directory_list; - - GnomeVFSAsyncHandle *vfs_async_handle; - GnomeVFSURI *uri; - - GSList *entries; - GSList *entries_tail; -}; - -struct _FMDirectoryListClass { - GtkObjectClass object_class; - - /* Eventually we might want signals like file_deleted, - file_added, blah blah; for now there's just the - stuff for loading a directory. */ - - /* You must add a refcount to these FMDirectoryListEntry - objects if you want to keep hold of them outside of the - signal handler. */ - - /* Each entry loaded after calling - fm_directory_list_load_uri() will be passed out via this - signal exactly ONE time; there is no guarantee about how - many each time, you may get all the entries in one signal - or one entry at a time. */ - void (* entries_loaded) (FMDirectoryList *list, - GSList *entries); - - /* Emitted when all entries have been loaded; icon/name - changed signals can come after this, but no more - entries_loaded signals */ - void (* finished_load) (FMDirectoryList *list); - - /* These are called if the icon or name for a directory - changes. In particular, icon_changed will be used if we - are doing slow MIME magic in an idle handler, and need to - update the icons to the more accurate ones. */ - void (* entry_icon_changed) (FMDirectoryList *list, - FMDirectoryListEntry *entry); - - void (* entry_name_changed) (FMDirectoryList *list, - FMDirectoryListEntry *entry); -}; - - - -GtkType fm_directory_list_get_type (void); -FMDirectoryList *fm_directory_list_new (void); -void fm_directory_list_load_uri (FMDirectoryList *dlist, - const gchar *uri); - - -END_GNOME_DECLS - -#endif - |