summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Hertzfeld <andy@src.gnome.org>2001-01-29 07:44:12 +0000
committerAndy Hertzfeld <andy@src.gnome.org>2001-01-29 07:44:12 +0000
commit9427a923fc59f22ce62b2f227060939bed8bf3d7 (patch)
tree405b35fda37c00e7d16114cb591bfe077dbb9e93
parent8f6151ce796133c2d2c105c1b0aa7632e2078ee0 (diff)
downloadnautilus-9427a923fc59f22ce62b2f227060939bed8bf3d7.tar.gz
added better sizing of components by using size_request, and a vcard
added better sizing of components by using size_request, and a vcard component that graphically renders vcards. * components/Makefile.am: added vcard component * components/rss-control/nautilus-rss-control.c: (nautilus_rss_control_initialize_class), (nautilus_rss_control_size_request): added size_request call to rss-control * components/vcard/.cvsignore: * components/vcard/Makefile.am: * components/vcard/main.c: (vcard_object_destroyed), (vcard_make_object), (main): * components/vcard/nautilus-vcard.c: (nautilus_vcard_initialize_class), (get_bonobo_properties), (set_bonobo_properties), (nautilus_vcard_initialize), (nautilus_vcard_destroy), (nautilus_vcard_get_control), (vcard_logo_callback), (vcard_read_done_callback), (load_vcard), (nautilus_vcard_set_uri), (vcard_pixbuf_composite), (draw_vcard_logo_image), (draw_vcard_name_and_title), (draw_vcard_addresses), (nautilus_vcard_draw), (nautilus_vcard_expose), (nautilus_vcard_motion_event), (nautilus_vcard_size_request), (nautilus_vcard_leave_event), (nautilus_vcard_button_press_event): * components/vcard/nautilus-vcard.h: * components/vcard/nautilus-vcard.oaf: * components/vcard/vcard.c: (vcard_full_name), (vcard_title), (vcard_logo), (vcard_postal), (vcard_streetaddress), (vcard_city_state_zip), (vcard_company), (vcard_email), (vcard_fax), (vcard_web), (vcard_address_list): * components/vcard/vcard.h: new vcard component for displaying graphical business cards, not finished yet * configure.in: added vcard component * nautilus-clean.sh: added vcard to nautilus-clean * libnautilus-extensions/nautilus-icon-canvas-item.c: (nautilus_icon_canvas_item_get_icon_width), (nautilus_icon_canvas_item_get_icon_height), (nautilus_icon_canvas_item_update_bounds): better sizing of components
-rw-r--r--ChangeLog49
-rw-r--r--components/Makefile.am1
-rw-r--r--components/rss-control/nautilus-rss-control.c11
-rw-r--r--components/vcard/.cvsignore5
-rw-r--r--components/vcard/Makefile.am48
-rw-r--r--components/vcard/main.c120
-rw-r--r--components/vcard/nautilus-vcard.c578
-rw-r--r--components/vcard/nautilus-vcard.h54
-rw-r--r--components/vcard/nautilus-vcard.oaf20
-rw-r--r--components/vcard/vcard.c276
-rw-r--r--components/vcard/vcard.h15
-rw-r--r--configure.in1
-rw-r--r--libnautilus-extensions/nautilus-icon-canvas-item.c38
-rw-r--r--libnautilus-private/nautilus-icon-canvas-item.c38
-rwxr-xr-xnautilus-clean.sh1
15 files changed, 1237 insertions, 18 deletions
diff --git a/ChangeLog b/ChangeLog
index 8dee29aa5..9f46e74a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,52 @@
+2001-01-28 Andy Hertzfeld <andy@eazel.com>
+
+ added better sizing of components by using size_request
+
+ * components/Makefile.am:
+ added vcard component
+
+ * components/rss-control/nautilus-rss-control.c:
+ (nautilus_rss_control_initialize_class),
+ (nautilus_rss_control_size_request):
+ added size_request call to rss-control
+
+ * components/vcard/.cvsignore:
+ * components/vcard/Makefile.am:
+ * components/vcard/main.c: (vcard_object_destroyed),
+ (vcard_make_object), (main):
+ * components/vcard/nautilus-vcard.c:
+ (nautilus_vcard_initialize_class), (get_bonobo_properties),
+ (set_bonobo_properties), (nautilus_vcard_initialize),
+ (nautilus_vcard_destroy), (nautilus_vcard_get_control),
+ (vcard_logo_callback), (vcard_read_done_callback), (load_vcard),
+ (nautilus_vcard_set_uri), (vcard_pixbuf_composite),
+ (draw_vcard_logo_image), (draw_vcard_name_and_title),
+ (draw_vcard_addresses), (nautilus_vcard_draw),
+ (nautilus_vcard_expose), (nautilus_vcard_motion_event),
+ (nautilus_vcard_size_request), (nautilus_vcard_leave_event),
+ (nautilus_vcard_button_press_event):
+ * components/vcard/nautilus-vcard.h:
+ * components/vcard/nautilus-vcard.oaf:
+ * components/vcard/vcard.c: (vcard_full_name), (vcard_title),
+ (vcard_logo), (vcard_postal), (vcard_streetaddress),
+ (vcard_city_state_zip), (vcard_company), (vcard_email),
+ (vcard_fax), (vcard_web), (vcard_address_list):
+ * components/vcard/vcard.h:
+ new vcard component for displaying graphical business cards, not
+ finished yet
+
+ * configure.in:
+ added vcard component
+
+ * nautilus-clean.sh:
+ added vcard to nautilus-clean
+
+ * libnautilus-extensions/nautilus-icon-canvas-item.c:
+ (nautilus_icon_canvas_item_get_icon_width),
+ (nautilus_icon_canvas_item_get_icon_height),
+ (nautilus_icon_canvas_item_update_bounds):
+ better sizing of components
+
2001-01-24 Andy Hertzfeld <andy@eazel.com>
added missing files to post-1_0_1 branch, plus some more
diff --git a/components/Makefile.am b/components/Makefile.am
index a14067892..182335e86 100644
--- a/components/Makefile.am
+++ b/components/Makefile.am
@@ -26,6 +26,7 @@ SUBDIRS = \
text \
throbber \
tree \
+ vcard \
$(SERVICE_SUBDIRS) \
$(RPMVIEW_COMPONENT_SUBDIRS) \
$(MOZILLA_COMPONENT_SUBDIRS) \
diff --git a/components/rss-control/nautilus-rss-control.c b/components/rss-control/nautilus-rss-control.c
index c5f24b27e..3efa9a85f 100644
--- a/components/rss-control/nautilus-rss-control.c
+++ b/components/rss-control/nautilus-rss-control.c
@@ -91,6 +91,7 @@ static int nautilus_rss_control_expose (GtkWidget *widget, GdkEventExpose *even
static gboolean nautilus_rss_control_button_press_event (GtkWidget *widget, GdkEventButton *event);
static gboolean nautilus_rss_control_motion_event (GtkWidget *widget, GdkEventMotion *event);
static gboolean nautilus_rss_control_leave_event (GtkWidget *widget, GdkEventCrossing *event);
+static void nautilus_rss_control_size_request (GtkWidget *widget, GtkRequisition *request);
static void nautilus_rss_control_set_uri (NautilusRSSControl *rss_control, const char *uri);
@@ -116,6 +117,7 @@ nautilus_rss_control_initialize_class (NautilusRSSControlClass *klass)
widget_class->button_press_event = nautilus_rss_control_button_press_event;
widget_class->motion_notify_event = nautilus_rss_control_motion_event;
widget_class->leave_notify_event = nautilus_rss_control_leave_event;
+ widget_class->size_request = nautilus_rss_control_size_request;
}
@@ -744,6 +746,15 @@ nautilus_rss_control_leave_event (GtkWidget *widget, GdkEventCrossing *event)
return TRUE;
}
+/* handle size requests by requesting a fixed size */
+static void
+nautilus_rss_control_size_request (GtkWidget *widget, GtkRequisition *request)
+{
+ request->width = 240;
+ request->height = 140;
+}
+
+
/* handle button press events */
static gboolean
nautilus_rss_control_button_press_event (GtkWidget *widget, GdkEventButton *event)
diff --git a/components/vcard/.cvsignore b/components/vcard/.cvsignore
new file mode 100644
index 000000000..3c5d6aaee
--- /dev/null
+++ b/components/vcard/.cvsignore
@@ -0,0 +1,5 @@
+.deps
+.libs
+Makefile
+Makefile.in
+nautilus-vcard
diff --git a/components/vcard/Makefile.am b/components/vcard/Makefile.am
new file mode 100644
index 000000000..9f1f47427
--- /dev/null
+++ b/components/vcard/Makefile.am
@@ -0,0 +1,48 @@
+NULL =
+
+SUBDIRS =
+
+INCLUDES = \
+ -DPREFIX=\"$(prefix)\" \
+ -DG_LOG_DOMAIN=\"Nautilus-VCard\" \
+ -DDATADIR=\""$(datadir)"\" \
+ -I$(top_srcdir) \
+ -I$(top_builddir) \
+ -I$(top_builddir)/libnautilus \
+ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
+ $(GNOMEUI_CFLAGS) \
+ $(GCONF_CFLAGS) \
+ $(OAF_CFLAGS) \
+ $(BONOBO_CFLAGS) \
+ $(VFS_CFLAGS)
+
+oafdir = $(datadir)/oaf
+oaf_DATA = \
+ nautilus-vcard.oaf
+
+
+bin_PROGRAMS = \
+ nautilus-vcard
+
+nautilus_vcard_SOURCES = \
+
+ vcard.c \
+ vcard.h \
+ nautilus-vcard.c \
+ nautilus-vcard.h \
+ main.c
+
+nautilus_vcard_LDADD = \
+ $(top_builddir)/libnautilus/libnautilus.la \
+ $(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
+ $(BONOBO_LIBS) \
+ $(GNOMEUI_LIBS) \
+ $(GCONF_LIBS) \
+ $(VFS_LIBS) \
+ $(GNORBA_LIBS)
+
+OBJECT_DIRECTORY_LIBS = $(GNOME_LIBS) $(OAF_LIBS)
+
+EXTRA_DIST = \
+ $(oaf_DATA) \
+ $(NULL)
diff --git a/components/vcard/main.c b/components/vcard/main.c
new file mode 100644
index 000000000..32dff3253
--- /dev/null
+++ b/components/vcard/main.c
@@ -0,0 +1,120 @@
+/* -*- 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 vcard component. */
+
+#include <config.h>
+#include "nautilus-vcard.h"
+
+#include <bonobo.h>
+#include <gnome.h>
+#include <libgnomevfs/gnome-vfs.h>
+#include <libnautilus-extensions/nautilus-debug.h>
+#include <liboaf/liboaf.h>
+
+static int object_count = 0;
+
+static void
+vcard_object_destroyed(GtkObject *obj)
+{
+ object_count--;
+ if (object_count <= 0) {
+ gtk_main_quit ();
+ }
+}
+
+static BonoboObject *
+vcard_make_object (BonoboGenericFactory *factory,
+ const char *iid,
+ void *closure)
+{
+ NautilusVCard *vcard;
+ BonoboObject *bonobo_control;
+
+ if (strcmp (iid, "OAFIID:nautilus_vcard")) {
+ return NULL;
+ }
+
+ vcard = NAUTILUS_VCARD (gtk_object_new (NAUTILUS_TYPE_VCARD, NULL));
+
+ object_count++;
+
+ bonobo_control = nautilus_vcard_get_control (vcard);
+
+ gtk_signal_connect (GTK_OBJECT (bonobo_control), "destroy", vcard_object_destroyed, NULL);
+ return bonobo_control;
+}
+
+int
+main (int argc, char *argv[])
+{
+ BonoboGenericFactory *factory;
+ CORBA_ORB orb;
+ char *registration_id;
+
+ /* Make criticals and warnings stop in the debugger if
+ * NAUTILUS_DEBUG is set. Unfortunately, this has to be done
+ * explicitly for each domain.
+ */
+ if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
+ nautilus_make_warnings_and_criticals_stop_in_debugger
+ (G_LOG_DOMAIN, g_log_domain_glib,
+ "Bonobo",
+ "Gdk",
+ "GnomeUI",
+ "GnomeVFS",
+ "GnomeVFS-CORBA",
+ "GnomeVFS-pthread",
+ "Gtk",
+ "Gdk-Pixbuf",
+ "Nautilus",
+ "Nautilus-Authenticate",
+ "Nautilus-Tree",
+ "ORBit",
+ NULL);
+ }
+
+ gnome_init_with_popt_table("nautilus-vcard", VERSION,
+ argc, argv,
+ oaf_popt_options, 0, NULL);
+
+ orb = oaf_init (argc, argv);
+
+ bonobo_init (orb, CORBA_OBJECT_NIL, CORBA_OBJECT_NIL);
+
+ /* initialize gnome-vfs, etc */
+ g_thread_init (NULL);
+ gnome_vfs_init ();
+
+ registration_id = oaf_make_registration_id ("OAFIID:nautilus_vcard_factory", getenv ("DISPLAY"));
+ factory = bonobo_generic_factory_new_multi (registration_id,
+ vcard_make_object,
+ NULL);
+ g_free (registration_id);
+
+
+ do {
+ bonobo_main ();
+ } while (object_count > 0);
+
+ return 0;
+}
diff --git a/components/vcard/nautilus-vcard.c b/components/vcard/nautilus-vcard.c
new file mode 100644
index 000000000..9b9d45c8d
--- /dev/null
+++ b/components/vcard/nautilus-vcard.c
@@ -0,0 +1,578 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
+
+/*
+ * 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: Andy Hertzfeld <andy@eazel.com>
+ *
+ */
+
+/* this is the implementation of the vcard component, which display a vcard graphically
+ */
+
+#include <config.h>
+#include <gnome.h>
+#include <liboaf/liboaf.h>
+
+#include <bonobo.h>
+
+#include "vcard.h"
+#include "nautilus-vcard.h"
+
+#include <gnome-xml/parser.h>
+#include <gnome-xml/xmlmemory.h>
+
+#include <libgnomevfs/gnome-vfs.h>
+
+#include <libnautilus/nautilus-view.h>
+
+#include <libnautilus-extensions/nautilus-file-utilities.h>
+#include <libnautilus-extensions/nautilus-gdk-extensions.h>
+#include <libnautilus-extensions/nautilus-gdk-pixbuf-extensions.h>
+#include <libnautilus-extensions/nautilus-glib-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-extensions.h>
+#include <libnautilus-extensions/nautilus-gtk-macros.h>
+#include <libnautilus-extensions/nautilus-scalable-font.h>
+#include <libnautilus-extensions/nautilus-string.h>
+#include <libnautilus-extensions/nautilus-xml-extensions.h>
+#include <libnautilus-extensions/nautilus-font-factory.h>
+
+/* private instance variables */
+struct _NautilusVCardDetails {
+ char *vcard_uri;
+ char *vcard_data;
+
+ NautilusReadFileHandle *load_file_handle;
+ NautilusPixbufLoadHandle *load_image_handle;
+
+ BonoboObject *control;
+ NautilusScalableFont *font;
+
+ GdkPixbuf *logo;
+};
+
+static void nautilus_vcard_initialize_class (NautilusVCardClass *klass);
+static void nautilus_vcard_initialize (NautilusVCard *view);
+static void nautilus_vcard_destroy (GtkObject *object);
+
+static void nautilus_vcard_draw (GtkWidget *widget, GdkRectangle *box);
+static int nautilus_vcard_expose (GtkWidget *widget, GdkEventExpose *event);
+static gboolean nautilus_vcard_button_press_event (GtkWidget *widget, GdkEventButton *event);
+static gboolean nautilus_vcard_motion_event (GtkWidget *widget, GdkEventMotion *event);
+static gboolean nautilus_vcard_leave_event (GtkWidget *widget, GdkEventCrossing *event);
+static void nautilus_vcard_size_request (GtkWidget *widget, GtkRequisition *request);
+
+static void nautilus_vcard_set_uri (NautilusVCard *vcard, const char *uri);
+
+
+NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusVCard,
+ nautilus_vcard,
+ GTK_TYPE_EVENT_BOX)
+
+#define MINIMUM_DRAW_SIZE 4
+
+static void
+nautilus_vcard_initialize_class (NautilusVCardClass *klass)
+{
+ GtkObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = GTK_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+
+ object_class->destroy = nautilus_vcard_destroy;
+
+ widget_class->draw = nautilus_vcard_draw;
+ widget_class->expose_event = nautilus_vcard_expose;
+ widget_class->button_press_event = nautilus_vcard_button_press_event;
+ widget_class->motion_notify_event = nautilus_vcard_motion_event;
+ widget_class->leave_notify_event = nautilus_vcard_leave_event;
+ widget_class->size_request = nautilus_vcard_size_request;
+}
+
+/* routines to handle setting and getting the configuration properties of the Bonobo control */
+
+enum {
+ CONFIGURATION
+} MyArgs;
+
+
+static void
+get_bonobo_properties (BonoboPropertyBag *bag,
+ BonoboArg *arg,
+ guint arg_id,
+ CORBA_Environment *ev,
+ gpointer user_data)
+{
+ NautilusVCard *vcard = NAUTILUS_VCARD (user_data);
+
+ switch (arg_id) {
+
+ case CONFIGURATION:
+ {
+ BONOBO_ARG_SET_STRING (arg, vcard->details->vcard_uri);
+ 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)
+{
+ NautilusVCard *vcard = NAUTILUS_VCARD (user_data);
+
+ switch (arg_id) {
+
+ case CONFIGURATION:
+ {
+ char *uri;
+
+ uri = BONOBO_ARG_GET_STRING (arg);
+ nautilus_vcard_set_uri (vcard, uri);
+
+ break;
+ }
+
+ default:
+ g_warning ("Unhandled arg %d", arg_id);
+ break;
+ }
+}
+
+/* initialize ourselves by connecting to the location change signal and allocating our subviews */
+static void
+nautilus_vcard_initialize (NautilusVCard *vcard)
+{
+ GtkWidget *frame;
+ BonoboPropertyBag *property_bag;
+
+ vcard->details = g_new0 (NautilusVCardDetails, 1);
+
+ /* set up the font */
+ vcard->details->font = NAUTILUS_SCALABLE_FONT (nautilus_scalable_font_new ("helvetica", "medium", NULL, NULL));
+
+ /* receive mouse motion events */
+ gtk_widget_add_events (GTK_WIDGET (vcard), GDK_POINTER_MOTION_MASK);
+
+ /* embed it into a frame */
+ frame = gtk_frame_new (NULL);
+ gtk_frame_set_shadow_type(GTK_FRAME (frame), GTK_SHADOW_OUT);
+ gtk_widget_show (frame);
+ gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (vcard));
+
+ /* make the bonobo control */
+ vcard->details->control = (BonoboObject*) bonobo_control_new (GTK_WIDGET (frame));
+
+ /* attach a property bag with the configure property */
+ property_bag = bonobo_property_bag_new (get_bonobo_properties, set_bonobo_properties, vcard);
+ bonobo_control_set_properties (BONOBO_CONTROL(vcard->details->control),property_bag);
+ bonobo_object_unref (BONOBO_OBJECT (property_bag));
+
+ bonobo_property_bag_add (property_bag, "configuration", CONFIGURATION, BONOBO_ARG_STRING, NULL,
+ "VCard Configuration", BONOBO_PROPERTY_WRITEABLE);
+
+ /* show the view itself */
+ gtk_widget_show (GTK_WIDGET (vcard));
+}
+
+
+static void
+nautilus_vcard_destroy (GtkObject *object)
+{
+ NautilusVCard *vcard;
+
+ vcard = NAUTILUS_VCARD (object);
+ g_free (vcard->details->vcard_uri);
+ g_free (vcard->details->vcard_data);
+
+ if (vcard->details->load_file_handle != NULL) {
+ nautilus_read_file_cancel (vcard->details->load_file_handle);
+ }
+
+ if (vcard->details->load_image_handle != NULL) {
+ nautilus_cancel_gdk_pixbuf_load (vcard->details->load_image_handle);
+ }
+
+
+ if (vcard->details->logo != NULL) {
+ gdk_pixbuf_unref (vcard->details->logo);
+ }
+
+ if (vcard->details->font) {
+ gtk_object_unref (GTK_OBJECT (vcard->details->font));
+ }
+
+ g_free (vcard->details);
+
+ NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
+}
+
+/* get associated Bonobo control */
+BonoboObject *
+nautilus_vcard_get_control (NautilusVCard *vcard)
+{
+ return vcard->details->control;
+}
+
+static void
+vcard_logo_callback (GnomeVFSResult error, GdkPixbuf *pixbuf, gpointer callback_data)
+{
+ NautilusVCard *vcard;
+ GdkPixbuf *scaled_pixbuf;
+
+ vcard = NAUTILUS_VCARD (callback_data);
+ vcard->details->load_image_handle = NULL;
+
+ if (vcard->details->logo) {
+ gdk_pixbuf_unref (vcard->details->logo);
+ }
+
+ if (pixbuf != NULL) {
+ gdk_pixbuf_ref (pixbuf);
+
+ scaled_pixbuf = nautilus_gdk_pixbuf_scale_down_to_fit (pixbuf, 128, 80);
+ gdk_pixbuf_unref (pixbuf);
+ vcard->details->logo = scaled_pixbuf;
+ gtk_widget_queue_draw (GTK_WIDGET (vcard));
+ }
+}
+
+/* completion routine invoked when we've loaded the vcard file uri. */
+
+static void
+vcard_read_done_callback (GnomeVFSResult result,
+ GnomeVFSFileSize file_size,
+ char *file_contents,
+ gpointer callback_data)
+{
+ char *logo_uri;
+ NautilusVCard *vcard;
+
+ vcard = NAUTILUS_VCARD (callback_data);
+ vcard->details->load_file_handle = NULL;
+
+ /* make sure the read was successful */
+ if (result != GNOME_VFS_OK) {
+ g_assert (file_contents == NULL);
+ return;
+ }
+
+ /* free old data if any */
+ if (vcard->details->vcard_data) {
+ g_free (vcard->details->vcard_data);
+ }
+
+ /* set up the vcard data */
+ vcard->details->vcard_data = g_realloc (file_contents, file_size + 1);
+ vcard->details->vcard_data[file_size] = '\0';
+
+ /* extract the image uri and, if found, load it asynchronously */
+ logo_uri = vcard_logo (vcard->details->vcard_data);
+ g_message ("logo uri is %s", logo_uri);
+ if (logo_uri != NULL) {
+ vcard->details->load_image_handle = nautilus_gdk_pixbuf_load_async (logo_uri, vcard_logo_callback, vcard);
+ g_free (logo_uri);
+ }
+
+ /* schedule a redraw to reflect the new contents */
+ gtk_widget_queue_draw (GTK_WIDGET (vcard));
+}
+
+/* load the vcard asynchronously */
+static void
+load_vcard (NautilusVCard *vcard)
+{
+ /* load the uri asynchrounously, calling a completion routine when completed */
+ vcard->details->load_file_handle = nautilus_read_entire_file_async (vcard->details->vcard_uri, vcard_read_done_callback, vcard);
+}
+
+/* set the uri and load it */
+static void
+nautilus_vcard_set_uri (NautilusVCard *vcard, const char *uri)
+{
+
+ if (nautilus_strcmp (vcard->details->vcard_uri, uri) == 0) {
+ return;
+ }
+
+ if (vcard->details->vcard_uri != NULL) {
+ g_free (vcard->details->vcard_uri);
+ vcard->details->vcard_uri = NULL;
+ }
+
+ if (uri != NULL) {
+ vcard->details->vcard_uri = g_strdup (uri);
+ load_vcard (vcard);
+ }
+}
+
+/* convenience routine to composite an image with the proper clipping */
+static void
+vcard_pixbuf_composite (GdkPixbuf *source, GdkPixbuf *destination, int x_offset, int y_offset, int alpha)
+{
+ int source_width, source_height, dest_width, dest_height;
+ double float_x_offset, float_y_offset;
+
+ source_width = gdk_pixbuf_get_width (source);
+ source_height = gdk_pixbuf_get_height (source);
+ dest_width = gdk_pixbuf_get_width (destination);
+ dest_height = gdk_pixbuf_get_height (destination);
+
+ float_x_offset = x_offset;
+ float_y_offset = y_offset;
+
+ /* clip to the destination size */
+ if ((x_offset + source_width) > dest_width) {
+ source_width = dest_width - x_offset;
+ }
+ if ((y_offset + source_height) > dest_height) {
+ source_height = dest_height - y_offset;
+ }
+
+ gdk_pixbuf_composite (source, destination, x_offset, y_offset, source_width, source_height,
+ float_x_offset, float_y_offset, 1.0, 1.0, GDK_PIXBUF_ALPHA_BILEVEL, alpha);
+}
+
+
+
+/* draw the logo image */
+static int
+draw_vcard_logo_image (NautilusVCard *vcard, GdkPixbuf *pixbuf, int offset)
+{
+ GtkWidget *widget;
+ int logo_width, logo_height;
+ int v_offset;
+
+ widget = GTK_WIDGET (vcard);
+ v_offset = offset;
+
+ if (vcard->details->logo != NULL) {
+ logo_width = gdk_pixbuf_get_width (vcard->details->logo);
+ logo_height = gdk_pixbuf_get_height (vcard->details->logo);
+
+ vcard_pixbuf_composite (vcard->details->logo, pixbuf, 2, v_offset, 255);
+ v_offset += logo_height + 2;
+ }
+
+ return v_offset;
+}
+
+/* draw the name and title */
+static int
+draw_vcard_name_and_title (NautilusVCard *vcard, GdkPixbuf *pixbuf, int v_offset)
+{
+ int name_width, name_height, title_width, title_height;
+ int name_len, title_len;
+ char *name, *title;
+ GtkWidget *widget;
+
+ if (vcard->details->font == NULL) {
+ return v_offset;
+ }
+
+ widget = GTK_WIDGET (vcard);
+
+ /* extract the name and title */
+ name = vcard_full_name (vcard->details->vcard_data);
+ title = vcard_title (vcard->details->vcard_data);
+
+ /* first, measure the name */
+ if (name != NULL) {
+ name_len = strlen (name);
+ nautilus_scalable_font_measure_text (vcard->details->font,
+ 18, 18,
+ name, name_len,
+ &name_width,
+ &name_height);
+
+ /* draw the name into the pixbuf using anti-aliased text */
+ nautilus_scalable_font_draw_text (vcard->details->font, pixbuf,
+ 4, v_offset,
+ NULL,
+ 18, 18,
+ name, name_len,
+ NAUTILUS_RGB_COLOR_BLACK,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ v_offset += name_height + 4;
+
+ g_free (name);
+
+ if (title != NULL) {
+ title_len = strlen (title);
+ nautilus_scalable_font_measure_text (vcard->details->font,
+ 14, 14,
+ title, title_len,
+ &title_width,
+ &title_height);
+
+ /* draw the name into the pixbuf using anti-aliased text */
+ nautilus_scalable_font_draw_text (vcard->details->font, pixbuf,
+ 4, v_offset,
+ NULL,
+ 14, 14,
+ title, title_len,
+ NAUTILUS_RGB_COLOR_BLACK,
+ NAUTILUS_OPACITY_FULLY_OPAQUE);
+ v_offset += title_height + 4;
+
+ g_free (title);
+ }
+ }
+ return v_offset;
+}
+
+/* draw the addresses and phone numbers associated with the vcard */
+static int
+draw_vcard_addresses (NautilusVCard *vcard, GdkPixbuf *pixbuf, int v_offset)
+{
+ return v_offset;
+}
+
+/* handle drawing the control */
+static void
+nautilus_vcard_draw (GtkWidget *widget, GdkRectangle *box)
+{
+ NautilusVCard *control;
+ GdkPixbuf *temp_pixbuf;
+ int width, height, v_offset;
+
+ /* allocate a pixbuf to draw into */
+ width = widget->allocation.width;
+ height = widget->allocation.height;
+
+
+ temp_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
+
+ g_return_if_fail (widget != NULL);
+ g_return_if_fail (NAUTILUS_IS_VCARD (widget));
+
+ control = NAUTILUS_VCARD (widget);
+
+ /* draw the background */
+ nautilus_gdk_pixbuf_fill_rectangle_with_color (temp_pixbuf, NULL, 0xFFEFEFEF);
+
+ /* draw the logo, if any */
+ v_offset = draw_vcard_logo_image (control, temp_pixbuf, 2);
+
+ /* draw the name and title */
+ v_offset = draw_vcard_name_and_title (control, temp_pixbuf, v_offset);
+
+ v_offset += 6;
+ /* draw the addresses */
+ v_offset = draw_vcard_addresses (control, temp_pixbuf, v_offset);
+
+ /* blit the resultingpixbuf to the drawable, then release it */
+ gdk_pixbuf_render_to_drawable_alpha (temp_pixbuf,
+ widget->window,
+ 0, 0,
+ widget->allocation.x, widget->allocation.y,
+ width, height,
+ GDK_PIXBUF_ALPHA_BILEVEL, 128,
+ GDK_RGB_DITHER_MAX,
+ 0, 0);
+
+ gdk_pixbuf_unref (temp_pixbuf);
+}
+
+/* handle expose events */
+static int
+nautilus_vcard_expose (GtkWidget *widget, GdkEventExpose *event)
+{
+ GdkRectangle box;
+ g_return_val_if_fail (widget != NULL, FALSE);
+ g_return_val_if_fail (NAUTILUS_IS_VCARD (widget), FALSE);
+
+ box.x = 0; box.y = 0;
+ box.width = widget->allocation.width;
+ box.height = widget->allocation.height;
+
+ nautilus_vcard_draw (widget, &box);
+ return FALSE;
+}
+
+
+/* handle mouse motion events by maintaining the prelight state */
+static gboolean
+nautilus_vcard_motion_event (GtkWidget *widget, GdkEventMotion *event)
+{
+ int x, y;
+ int which_item, item_count;
+ NautilusVCard *vcard;
+
+ vcard = NAUTILUS_VCARD (widget);
+
+ gtk_widget_get_pointer (widget, &x, &y);
+ which_item = 0;
+ item_count = 0;
+
+ if (which_item < 0 || which_item >= item_count) {
+ which_item = -1;
+ }
+ return TRUE;
+}
+
+/* handle size requests by requesting a fixed size */
+static void
+nautilus_vcard_size_request (GtkWidget *widget, GtkRequisition *request)
+{
+ request->width = 220;
+ request->height = 140;
+}
+
+/* handle leave events by cancelling any prelighting */
+static gboolean
+nautilus_vcard_leave_event (GtkWidget *widget, GdkEventCrossing *event)
+{
+ NautilusVCard *vcard;
+
+ vcard = NAUTILUS_VCARD (widget);
+ return TRUE;
+}
+
+/* handle button press events */
+static gboolean
+nautilus_vcard_button_press_event (GtkWidget *widget, GdkEventButton *event)
+{
+ GList *selected_item;
+ NautilusVCard *vcard;
+ char *command;
+ int result, which_item;
+
+ vcard = NAUTILUS_VCARD (widget);
+ if (event->y < widget->allocation.y) {
+ command = g_strdup_printf ("nautilus %s", vcard->details->vcard_uri);
+ result = system (command);
+ g_free (command);
+ } else {
+ which_item = (event->y - widget->allocation.y ) / 16;
+ if (which_item < 0) {
+ selected_item = 0;
+
+ }
+ }
+
+ return FALSE;
+}
+
diff --git a/components/vcard/nautilus-vcard.h b/components/vcard/nautilus-vcard.h
new file mode 100644
index 000000000..4a742dd26
--- /dev/null
+++ b/components/vcard/nautilus-vcard.h
@@ -0,0 +1,54 @@
+/* -*- 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 vcard component */
+
+#ifndef NAUTILUS_VCARD_H
+#define NAUTILUS_VCARD_H
+
+#include <bonobo.h>
+#include <gtk/gtkeventbox.h>
+typedef struct _NautilusVCard NautilusVCard;
+typedef struct _NautilusVCardClass NautilusVCardClass;
+
+#define NAUTILUS_TYPE_VCARD (nautilus_vcard_get_type ())
+#define NAUTILUS_VCARD(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_VCARD, NautilusVCard))
+#define NAUTILUS_VCARD_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_VCARD, NautilusVCardClass))
+#define NAUTILUS_IS_VCARD(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_VCARD))
+#define NAUTILUS_IS_VCARD_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_VCARD))
+
+typedef struct _NautilusVCardDetails NautilusVCardDetails;
+
+struct _NautilusVCard {
+ GtkEventBox parent;
+ NautilusVCardDetails *details;
+};
+
+struct _NautilusVCardClass {
+ GtkEventBoxClass parent_class;
+};
+
+/* GtkObject support */
+GtkType nautilus_vcard_get_type (void);
+BonoboObject* nautilus_vcard_get_control (NautilusVCard *vcard);
+
+#endif /* NAUTILUS_VCARD_H */
diff --git a/components/vcard/nautilus-vcard.oaf b/components/vcard/nautilus-vcard.oaf
new file mode 100644
index 000000000..bb6edd1ea
--- /dev/null
+++ b/components/vcard/nautilus-vcard.oaf
@@ -0,0 +1,20 @@
+<oaf_info>
+
+<oaf_server iid="OAFIID:nautilus_vcard_factory" type="exe" location="nautilus-rss-control">
+<oaf_attribute name="repo_ids" type="stringv">
+<item value="IDL:Bonobo/GenericFactory:1.0"/>
+</oaf_attribute>
+<oaf_attribute name="name" type="string" value="vcard factory"/>
+<oaf_attribute name="description" type="string" value="vcard object factory"/>
+</oaf_server>
+
+<oaf_server iid="OAFIID:nautilus_vcard" type="factory" location="OAFIID:nautilus_vcard_factory">
+<oaf_attribute name="repo_ids" type="stringv">
+<item value="IDL:Bonobo/Control:1.0"/>
+<item value="IDL:Bonobo/Unknown:1.0"/>
+</oaf_attribute>
+<oaf_attribute name="name" type="string" value="vcard"/>
+<oaf_attribute name="description" type="string" value="nautilus vcard object"/>
+</oaf_server>
+
+</oaf_info>
diff --git a/components/vcard/vcard.c b/components/vcard/vcard.c
new file mode 100644
index 000000000..58000315e
--- /dev/null
+++ b/components/vcard/vcard.c
@@ -0,0 +1,276 @@
+/* ad hoc vcard parsing routines for prototyping - replace with something better soon
+ *
+ * Copyright (C) 1999 Andy Hertzfeld
+ *
+ * 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
+ */
+
+#include <gnome.h>
+#include <ctype.h>
+
+#include "vcard.h"
+
+char * vcard_full_name (gchar* vcard)
+ {
+ gchar full_name[2048];
+ gchar *temp_str = strstr(vcard, "FN:");
+ if (temp_str)
+ {
+ gint str_len;
+ gchar *end_pos = strchr(temp_str, '\n');
+ if (!end_pos)
+ end_pos = temp_str + strlen(temp_str);
+
+ str_len = end_pos - temp_str - 3;
+ memcpy(full_name, temp_str + 3, str_len);
+ full_name[str_len] = '\0';
+ return g_strdup (full_name);
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_title (gchar* vcard)
+ {
+ gchar title[2048];
+ gchar *temp_str = strstr(vcard, "TITLE:");
+ if (temp_str)
+ {
+ gint str_len;
+ gchar *end_pos = strchr(temp_str, '\n');
+ if (!end_pos)
+ end_pos = temp_str + strlen(temp_str);
+
+ str_len = end_pos - temp_str - 6;
+ memcpy(title, temp_str + 6, str_len);
+ title[str_len] = '\0';
+ return g_strdup (title);
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_logo (gchar* vcard)
+ {
+ gchar logo[2048];
+ gchar *temp_str = strstr(vcard, "LOGO;VALUE=uri:");
+ if (temp_str)
+ {
+ gint str_len;
+ gchar *end_pos = strchr(temp_str, '\n');
+ if (!end_pos)
+ end_pos = temp_str + strlen(temp_str);
+
+ str_len = end_pos - temp_str - 15;
+ memcpy(logo, temp_str + 15, str_len);
+ logo[str_len] = '\0';
+ return g_strdup (logo);
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_postal (gchar* vcard)
+ {
+ gchar postal[2048];
+ gchar *temp_str = strstr(vcard, "ADR;");
+ if (temp_str)
+ {
+ gchar *skip_pos = strchr(temp_str, ':');
+ if (skip_pos)
+ {
+ gint str_len;
+ gchar *end_pos = strchr(skip_pos, '\n');
+ if (!end_pos)
+ end_pos = skip_pos + strlen(skip_pos);
+
+ str_len = end_pos - skip_pos - 1;
+ memcpy(postal, skip_pos + 1, str_len);
+ postal[str_len] = '\0';
+ return g_strdup (postal);
+ }
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_streetaddress(gchar* vcard)
+ {
+ gchar streetaddress[2048];
+ gchar *temp_str = strstr(vcard, "ADR;");
+ if (temp_str)
+ {
+ gchar *skip_pos = strchr(temp_str, ':');
+ if (skip_pos)
+ {
+ gint str_len;
+ gchar *end_pos;
+ gint semi_count = 0;
+
+ /* to extract the street address, count up two semi-colons, then scan until the next one */
+
+ while (*skip_pos && (semi_count < 2))
+ {
+ if (*skip_pos++ == ';')
+ semi_count += 1;
+ }
+
+ end_pos = strchr(skip_pos, ';');
+ if (!end_pos)
+ end_pos = skip_pos + strlen(skip_pos);
+
+ str_len = end_pos - skip_pos;
+
+ memcpy(streetaddress, skip_pos, str_len);
+ streetaddress[str_len] = '\0';
+ return g_strdup (streetaddress);
+ }
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_city_state_zip(gchar* vcard)
+ {
+ gchar city[2048];
+ gchar *temp_str = strstr(vcard, "ADR;");
+ if (temp_str)
+ {
+ gchar *skip_pos = strchr(temp_str, ':');
+ if (skip_pos)
+ {
+ gint str_len;
+ gchar *end_pos;
+ gint semi_count = 0;
+
+ /* to extract the city, state and zip, count up 3 semi-colons */
+
+ while (*skip_pos && (semi_count < 3))
+ {
+ if (*skip_pos++ == ';')
+ semi_count += 1;
+ }
+
+ end_pos = skip_pos + strlen(skip_pos);
+
+ str_len = end_pos - skip_pos;
+ memcpy(city, skip_pos, str_len);
+ city[str_len] = '\0';
+ return g_strdup (city);
+ }
+ else
+ return NULL;
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_company(gchar* vcard)
+ {
+ gchar company[2048];
+ gchar *temp_str = strstr(vcard, "ORG:");
+ if (temp_str)
+ {
+ gint str_len;
+ gchar *end_pos = strchr(temp_str, '\n');
+ if (!end_pos)
+ end_pos = temp_str + strlen(temp_str);
+
+ str_len = end_pos - temp_str - 4;
+ memcpy(company, temp_str + 4, str_len);
+ company[str_len] = '\0';
+ return g_strdup (company);
+ }
+ else
+ return NULL;
+ }
+
+char * vcard_email(gchar* vcard)
+ {
+ return NULL;
+ }
+
+char * vcard_fax(gchar* vcard)
+ {
+ return NULL;
+ }
+
+char * vcard_web(gchar* vcard)
+ {
+ return NULL;
+ }
+
+/* this routine returns a cr-delimited list of all the phone, email and web addresses it can find */
+
+char * vcard_address_list(gchar* vcard)
+ {
+ gchar *next_line, *scan_ptr;
+ gchar temp_card[16384];
+
+ strcpy(temp_card, vcard);
+
+ /* iterate through the vcard text, extracting the fields that we're interested in and building the returned list */
+
+ next_line = strtok(temp_card, "\n");
+ while (next_line != NULL)
+ {
+ /* skip over leading blanks, and find the tag delimiter */
+
+ next_line = g_strchug(next_line);
+ scan_ptr = next_line;
+
+ while (isalpha (*scan_ptr))
+ scan_ptr++;
+
+ if ((*scan_ptr == ';') || (*scan_ptr == ':'))
+ {
+ gchar delimiter = *scan_ptr;
+ *scan_ptr = '\0';
+
+ /* see if it's one of the tags that we collect */
+
+ if (!strcmp(next_line, "TEL") || !strcmp(next_line, "EMAIL") || !strcmp(next_line, "URL"))
+ {
+ gchar temp_address[2048];
+
+ /* it matched, s prepare the output string and append it to the result */
+
+ if (delimiter == ':')
+ sprintf(temp_address, "%s||%s\n", next_line, scan_ptr + 1);
+ else
+ {
+ gchar *sub_type_ptr;
+
+ scan_ptr += 1;
+ sub_type_ptr = scan_ptr;
+ while ((*scan_ptr != ':') && (*scan_ptr != '\0'))
+ scan_ptr += 1;
+ *scan_ptr = '\0';
+ sprintf(temp_address, "%s|%s|%s\n", next_line, sub_type_ptr, scan_ptr + 1);
+ }
+ /*
+ strcat(address_list, temp_address);
+ */
+ }
+ }
+ next_line = strtok(NULL, "\n");
+ }
+
+ return NULL;
+ }
diff --git a/components/vcard/vcard.h b/components/vcard/vcard.h
new file mode 100644
index 000000000..0eeaff8b2
--- /dev/null
+++ b/components/vcard/vcard.h
@@ -0,0 +1,15 @@
+
+/* ad hoc vcard parsing routines - replace with something better sometime */
+
+char * vcard_full_name (gchar* vcard);
+char * vcard_title(gchar* vcard);
+char * vcard_postal(gchar* vcard);
+char * vcard_email(gchar* vcard);
+char * vcard_fax(gchar* vcard);
+char * vcard_web(gchar* vcard);
+char * vcard_logo(gchar* vcard);
+char * vcard_streetaddress(gchar* vcard);
+char * vcard_city_state_zip(gchar* vcard);
+char * vcard_company(gchar* vcard);
+char * vcard_address_list(gchar* vcard);
+
diff --git a/configure.in b/configure.in
index c100c169f..da53bc368 100644
--- a/configure.in
+++ b/configure.in
@@ -847,6 +847,7 @@ components/loser/Makefile
components/loser/content/Makefile
components/loser/sidebar/Makefile
components/tree/Makefile
+components/vcard/Makefile
po/Makefile.in
intl/Makefile
test/Makefile
diff --git a/libnautilus-extensions/nautilus-icon-canvas-item.c b/libnautilus-extensions/nautilus-icon-canvas-item.c
index 081faf2ba..151a9d608 100644
--- a/libnautilus-extensions/nautilus-icon-canvas-item.c
+++ b/libnautilus-extensions/nautilus-icon-canvas-item.c
@@ -356,6 +356,15 @@ nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item)
static int
nautilus_icon_canvas_item_get_icon_width (NautilusIconCanvasItem *item)
{
+ GtkRequisition size_requisition;
+ double scale_factor = GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_size_request (item->details->control, &size_requisition);
+
+ if (item->details->control != NULL) {
+ return size_requisition.width * scale_factor;
+ }
+
if (item->details->pixbuf == NULL) {
return NAUTILUS_ICON_SIZE_STANDARD;
}
@@ -366,6 +375,14 @@ nautilus_icon_canvas_item_get_icon_width (NautilusIconCanvasItem *item)
static int
nautilus_icon_canvas_item_get_icon_height (NautilusIconCanvasItem *item)
{
+ GtkRequisition size_requisition;
+ double scale_factor = GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_size_request (item->details->control, &size_requisition);
+
+ if (item->details->control != NULL) {
+ return size_requisition.height * scale_factor;
+ }
if (item->details->pixbuf == NULL) {
return NAUTILUS_ICON_SIZE_STANDARD;
}
@@ -663,11 +680,14 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item)
}
+
void
nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
{
ArtIRect before, after;
-
+ GtkRequisition size_requisition;
+ int item_width, item_height;
+
/* Compute new bounds. */
nautilus_gnome_canvas_item_get_current_canvas_bounds
(GNOME_CANVAS_ITEM (item), &before);
@@ -680,14 +700,14 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
return;
}
- /* if there is an embedded control, resize it appropriately */
- if (item->details->control) {
- /* for now, size it the same as the underlying image */
- int image_width = nautilus_icon_canvas_item_get_icon_width (item);
- int image_height = nautilus_icon_canvas_item_get_icon_height (item);
-
- gtk_widget_set_usize (item->details->control,
- image_width, image_height);
+ /* if there is an embedded control, make a size request and size accordingly */
+ if (item->details->control) {
+ /* size the control appropriately */
+ gtk_widget_size_request (item->details->control, &size_requisition);
+ item_width = size_requisition.width * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+ item_height = size_requisition.height * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_set_usize (item->details->control, item_width, item_height);
}
/* Send out the bounds_changed signal and queue a redraw. */
diff --git a/libnautilus-private/nautilus-icon-canvas-item.c b/libnautilus-private/nautilus-icon-canvas-item.c
index 081faf2ba..151a9d608 100644
--- a/libnautilus-private/nautilus-icon-canvas-item.c
+++ b/libnautilus-private/nautilus-icon-canvas-item.c
@@ -356,6 +356,15 @@ nautilus_icon_canvas_item_invalidate_label_size (NautilusIconCanvasItem *item)
static int
nautilus_icon_canvas_item_get_icon_width (NautilusIconCanvasItem *item)
{
+ GtkRequisition size_requisition;
+ double scale_factor = GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_size_request (item->details->control, &size_requisition);
+
+ if (item->details->control != NULL) {
+ return size_requisition.width * scale_factor;
+ }
+
if (item->details->pixbuf == NULL) {
return NAUTILUS_ICON_SIZE_STANDARD;
}
@@ -366,6 +375,14 @@ nautilus_icon_canvas_item_get_icon_width (NautilusIconCanvasItem *item)
static int
nautilus_icon_canvas_item_get_icon_height (NautilusIconCanvasItem *item)
{
+ GtkRequisition size_requisition;
+ double scale_factor = GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_size_request (item->details->control, &size_requisition);
+
+ if (item->details->control != NULL) {
+ return size_requisition.height * scale_factor;
+ }
if (item->details->pixbuf == NULL) {
return NAUTILUS_ICON_SIZE_STANDARD;
}
@@ -663,11 +680,14 @@ recompute_bounding_box (NautilusIconCanvasItem *icon_item)
}
+
void
nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
{
ArtIRect before, after;
-
+ GtkRequisition size_requisition;
+ int item_width, item_height;
+
/* Compute new bounds. */
nautilus_gnome_canvas_item_get_current_canvas_bounds
(GNOME_CANVAS_ITEM (item), &before);
@@ -680,14 +700,14 @@ nautilus_icon_canvas_item_update_bounds (NautilusIconCanvasItem *item)
return;
}
- /* if there is an embedded control, resize it appropriately */
- if (item->details->control) {
- /* for now, size it the same as the underlying image */
- int image_width = nautilus_icon_canvas_item_get_icon_width (item);
- int image_height = nautilus_icon_canvas_item_get_icon_height (item);
-
- gtk_widget_set_usize (item->details->control,
- image_width, image_height);
+ /* if there is an embedded control, make a size request and size accordingly */
+ if (item->details->control) {
+ /* size the control appropriately */
+ gtk_widget_size_request (item->details->control, &size_requisition);
+ item_width = size_requisition.width * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+ item_height = size_requisition.height * GNOME_CANVAS_ITEM (item)->canvas->pixels_per_unit;
+
+ gtk_widget_set_usize (item->details->control, item_width, item_height);
}
/* Send out the bounds_changed signal and queue a redraw. */
diff --git a/nautilus-clean.sh b/nautilus-clean.sh
index 43e058e85..260d5473d 100755
--- a/nautilus-clean.sh
+++ b/nautilus-clean.sh
@@ -96,6 +96,7 @@ nautilus-summary-view \
nautilus-text-view \
nautilus-throbber \
nautilus-tree-view \
+nautilus-vcard \
trilobite-eazel-install-service \
trilobite-eazel-time-view \
"