Commit ecc10811 authored by John Sullivan's avatar John Sullivan

Added icons to bookmarks menu & window; cleaned up some zoom code; fixed a few

storage leaks.
parent 6abbef77
2000-01-28 John Sullivan <sullivan@eazel.com>
A little zoom cleanup:
* libnautilus/gnome-icon-container-private.h: #include
nautilus-icon-factory.h and remove copy of NautilusZoomLevel enum.
* libnautilus/gnome-icon-container.c:
(gnome_icon_container_set_zoom_level): Now uses ratios of standard
NAUTILUS_ICON_SIZEs to compute canvas pixels/unit instead of locally
storing ratios.
* libnautilus/nautilus-icon-factory.h:
Changed pixel sizes of some NAUTILUS_ICON_SIZE #defines to match
the ratios formerly used in gnome-icon-container.c
Added icons to bookmarks menu and window:
* libnautilus/nautilus-directory.c: (nautilus_file_get): Changed
options passed to gnome_vfs_get_file_info to match those used in
directory view; this causes the mime type to be read so the custom
image icon can appear.
* src/nautilus-bookmark.c:
* src/nautilus-bookmark.h:
Now uses details structure to hold implementation details.
(nautilus_bookmark_get_pixmap_and_mask): New utility function to
get image suitable for use in a GtkMenuItem or GtkCList
(nautilus_bookmark_destroy): Free details structure
(init): Alloc details structure
* src/nautilus-bookmarks-menu.c:
(create_pixmap_widget_for_bookmark): New utility function to create
the kind of pixmap widget that a menu item likes.
(bookmark_menu_item_new): New utility function that returns a menu
item with bookmark's icon & name installed.
(nautilus_bookmarks_menu_repopulate): Uses bookmark_menu_item_new.
* src/nautilus-bookmarks-window.c:
Now uses #defines for the list columns (icon & name)
(create_bookmarks_window): Create one more column to hold icon;
set column width & row height taking new icon column into account.
(install_bookmark_icon): New function, installs pixmap & mask for
bookmark into GtkCList cell.
(repopulate): Fill in icon column as well as name column.
Fixed storage leaks:
* src/file-manager/fm-directory-view-icons.c:
(fm_directory_view_destroy): free details structure
* src/file-manager/fm-directory-view-list.c:
(fm_directory_view_list_destroy): free details structure
* src/file-manager/fm-directory-view.c:
(fm_directory_view_icons_destroy): free details structure; also,
don't bother setting details->icons_not_positioned to NULL since
details is about to be freed.
2000-01-28 Andy Hertzfeld <andy@eazel.com>
* libnautilus/nautilus_icons_view_icon_item.c,h:
......@@ -18,7 +71,7 @@
* src/file-manager/fm-default-file-icon.h: Removed file
* src/file-manager/fm-icon-cache.c: Removed file
* src/file-manager/fm-icon-cache.h: Removed file
* src/file-manager/Makefile.am: Took out mentions of remove files.
* src/file-manager/Makefile.am: Took out mentions of removed files.
* libnautilus/nautilus-default-file-icon.c: New file
* libnautilus/nautilus-default-file-icon.h: New file
......
......@@ -27,6 +27,7 @@
#include "gnome-icon-container.h"
#include "gnome-icon-container-dnd.h"
#include "nautilus-icon-factory.h"
#include <libgnomeui/gnome-icon-item.h>
/* An Icon. */
......@@ -168,19 +169,6 @@ struct _GnomeIconContainerDetails {
GdkFont *label_font;
};
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants.
These will change based on the zoom level eventually, so they
should probably become function calls instead of macros.
......@@ -191,8 +179,8 @@ typedef enum {
#define GNOME_ICON_CONTAINER_CELL_SPACING(container) 4
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) 48
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) 48
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) NAUTILUS_ICON_LEVEL_STANDARD
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) NAUTILUS_ICON_LEVEL_STANDARD
GnomeIconContainerIcon *gnome_icon_container_get_icon_by_uri (GnomeIconContainer *container,
const char *uri);
......
......@@ -2351,19 +2351,22 @@ void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
{
double pixels_per_unit;
container->details->zoom_level = pinned_level;
pixels_per_unit = (float)(nautilus_icon_size_for_zoom_level (pinned_level)) /
NAUTILUS_ICON_SIZE_STANDARD;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), pixels_per_unit);
}
}
......
......@@ -795,7 +795,9 @@ nautilus_file_get (const char *uri)
/* Get info on the file. */
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (uri, file_info,
GNOME_VFS_FILE_INFO_FASTMIMETYPE, NULL);
GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FASTMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS, NULL);
if (result != GNOME_VFS_OK)
return NULL;
......
......@@ -29,6 +29,19 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-directory.h>
/* NautilusIconFactory is a class that knows how to hand out icons to be
* used for representing files and some other objects. It was designed
* specifically to be useful for the Nautilus file browser, but could be
* used by any program that wants to display the standard icon for a
* file.
*
* The most common usage is to get a NautilusIconFactory object with
* nautilus_get_current_icon_factory, then ask for an icon for a specific
* file with nautilus_icon_factory_get_icon_for_file. The caller can ask
* for any size icon, but normally will use one of the defined
* NAUTILUS_ICON_SIZE macros.
*/
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
......@@ -46,13 +59,13 @@ typedef enum {
* be square. Since individual icons can be stretched,
* each icon is not constrained to this nominal size.
*/
#define NAUTILUS_ICON_SIZE_SMALLEST 16
#define NAUTILUS_ICON_SIZE_SMALLEST 12
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 32
#define NAUTILUS_ICON_SIZE_SMALL 36
#define NAUTILUS_ICON_SIZE_STANDARD 48
#define NAUTILUS_ICON_SIZE_LARGE 64
#define NAUTILUS_ICON_SIZE_LARGE 72
#define NAUTILUS_ICON_SIZE_LARGER 96
#define NAUTILUS_ICON_SIZE_LARGEST 144
#define NAUTILUS_ICON_SIZE_LARGEST 192
typedef struct _NautilusIconFactory NautilusIconFactory;
......
......@@ -27,6 +27,7 @@
#include "gnome-icon-container.h"
#include "gnome-icon-container-dnd.h"
#include "nautilus-icon-factory.h"
#include <libgnomeui/gnome-icon-item.h>
/* An Icon. */
......@@ -168,19 +169,6 @@ struct _GnomeIconContainerDetails {
GdkFont *label_font;
};
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants.
These will change based on the zoom level eventually, so they
should probably become function calls instead of macros.
......@@ -191,8 +179,8 @@ typedef enum {
#define GNOME_ICON_CONTAINER_CELL_SPACING(container) 4
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) 48
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) 48
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) NAUTILUS_ICON_LEVEL_STANDARD
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) NAUTILUS_ICON_LEVEL_STANDARD
GnomeIconContainerIcon *gnome_icon_container_get_icon_by_uri (GnomeIconContainer *container,
const char *uri);
......
......@@ -2351,19 +2351,22 @@ void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
{
double pixels_per_unit;
container->details->zoom_level = pinned_level;
pixels_per_unit = (float)(nautilus_icon_size_for_zoom_level (pinned_level)) /
NAUTILUS_ICON_SIZE_STANDARD;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), pixels_per_unit);
}
}
......
......@@ -795,7 +795,9 @@ nautilus_file_get (const char *uri)
/* Get info on the file. */
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (uri, file_info,
GNOME_VFS_FILE_INFO_FASTMIMETYPE, NULL);
GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FASTMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS, NULL);
if (result != GNOME_VFS_OK)
return NULL;
......
......@@ -29,6 +29,19 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-directory.h>
/* NautilusIconFactory is a class that knows how to hand out icons to be
* used for representing files and some other objects. It was designed
* specifically to be useful for the Nautilus file browser, but could be
* used by any program that wants to display the standard icon for a
* file.
*
* The most common usage is to get a NautilusIconFactory object with
* nautilus_get_current_icon_factory, then ask for an icon for a specific
* file with nautilus_icon_factory_get_icon_for_file. The caller can ask
* for any size icon, but normally will use one of the defined
* NAUTILUS_ICON_SIZE macros.
*/
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
......@@ -46,13 +59,13 @@ typedef enum {
* be square. Since individual icons can be stretched,
* each icon is not constrained to this nominal size.
*/
#define NAUTILUS_ICON_SIZE_SMALLEST 16
#define NAUTILUS_ICON_SIZE_SMALLEST 12
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 32
#define NAUTILUS_ICON_SIZE_SMALL 36
#define NAUTILUS_ICON_SIZE_STANDARD 48
#define NAUTILUS_ICON_SIZE_LARGE 64
#define NAUTILUS_ICON_SIZE_LARGE 72
#define NAUTILUS_ICON_SIZE_LARGER 96
#define NAUTILUS_ICON_SIZE_LARGEST 144
#define NAUTILUS_ICON_SIZE_LARGEST 192
typedef struct _NautilusIconFactory NautilusIconFactory;
......
......@@ -27,6 +27,7 @@
#include "gnome-icon-container.h"
#include "gnome-icon-container-dnd.h"
#include "nautilus-icon-factory.h"
#include <libgnomeui/gnome-icon-item.h>
/* An Icon. */
......@@ -168,19 +169,6 @@ struct _GnomeIconContainerDetails {
GdkFont *label_font;
};
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
/* FIXME: These are also defined in fm-icon-cache.h and shouldn't be in both places */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
NAUTILUS_ZOOM_LEVEL_SMALLER,
NAUTILUS_ZOOM_LEVEL_SMALL,
NAUTILUS_ZOOM_LEVEL_STANDARD,
NAUTILUS_ZOOM_LEVEL_LARGE,
NAUTILUS_ZOOM_LEVEL_LARGER,
NAUTILUS_ZOOM_LEVEL_LARGEST
} NautilusZoomLevel;
/* Layout and icon size constants.
These will change based on the zoom level eventually, so they
should probably become function calls instead of macros.
......@@ -191,8 +179,8 @@ typedef enum {
#define GNOME_ICON_CONTAINER_CELL_SPACING(container) 4
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) 48
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) 48
#define GNOME_ICON_CONTAINER_ICON_WIDTH(container) NAUTILUS_ICON_LEVEL_STANDARD
#define GNOME_ICON_CONTAINER_ICON_HEIGHT(container) NAUTILUS_ICON_LEVEL_STANDARD
GnomeIconContainerIcon *gnome_icon_container_get_icon_by_uri (GnomeIconContainer *container,
const char *uri);
......
......@@ -2351,19 +2351,22 @@ void
gnome_icon_container_set_zoom_level(GnomeIconContainer *container, gint new_level)
{
gint pinned_level = new_level;
double zoom_levels[7] = { 0.25, 0.50, 0.75, 1.0, 1.5, 2.0, 4.0 };
if (pinned_level < NAUTILUS_ZOOM_LEVEL_SMALLEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_SMALLEST;
else if (pinned_level > NAUTILUS_ZOOM_LEVEL_LARGEST)
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
pinned_level = NAUTILUS_ZOOM_LEVEL_LARGEST;
if (pinned_level != container->details->zoom_level)
{
container->details->zoom_level = pinned_level;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), zoom_levels[pinned_level]);
}
{
double pixels_per_unit;
container->details->zoom_level = pinned_level;
pixels_per_unit = (float)(nautilus_icon_size_for_zoom_level (pinned_level)) /
NAUTILUS_ICON_SIZE_STANDARD;
gnome_canvas_set_pixels_per_unit(GNOME_CANVAS(container), pixels_per_unit);
}
}
......
......@@ -795,7 +795,9 @@ nautilus_file_get (const char *uri)
/* Get info on the file. */
file_info = gnome_vfs_file_info_new ();
result = gnome_vfs_get_file_info (uri, file_info,
GNOME_VFS_FILE_INFO_FASTMIMETYPE, NULL);
GNOME_VFS_FILE_INFO_GETMIMETYPE
| GNOME_VFS_FILE_INFO_FASTMIMETYPE
| GNOME_VFS_FILE_INFO_FOLLOWLINKS, NULL);
if (result != GNOME_VFS_OK)
return NULL;
......
......@@ -29,6 +29,19 @@
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <libnautilus/nautilus-directory.h>
/* NautilusIconFactory is a class that knows how to hand out icons to be
* used for representing files and some other objects. It was designed
* specifically to be useful for the Nautilus file browser, but could be
* used by any program that wants to display the standard icon for a
* file.
*
* The most common usage is to get a NautilusIconFactory object with
* nautilus_get_current_icon_factory, then ask for an icon for a specific
* file with nautilus_icon_factory_get_icon_for_file. The caller can ask
* for any size icon, but normally will use one of the defined
* NAUTILUS_ICON_SIZE macros.
*/
/* Names for Nautilus's different zoom levels, from tiniest items to largest items */
typedef enum {
NAUTILUS_ZOOM_LEVEL_SMALLEST,
......@@ -46,13 +59,13 @@ typedef enum {
* be square. Since individual icons can be stretched,
* each icon is not constrained to this nominal size.
*/
#define NAUTILUS_ICON_SIZE_SMALLEST 16
#define NAUTILUS_ICON_SIZE_SMALLEST 12
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 32
#define NAUTILUS_ICON_SIZE_SMALL 36
#define NAUTILUS_ICON_SIZE_STANDARD 48
#define NAUTILUS_ICON_SIZE_LARGE 64
#define NAUTILUS_ICON_SIZE_LARGE 72
#define NAUTILUS_ICON_SIZE_LARGER 96
#define NAUTILUS_ICON_SIZE_LARGEST 144
#define NAUTILUS_ICON_SIZE_LARGEST 192
typedef struct _NautilusIconFactory NautilusIconFactory;
......
......@@ -140,7 +140,7 @@ fm_directory_view_icons_destroy (GtkObject *object)
icon_view = FM_DIRECTORY_VIEW_ICONS (object);
g_list_free (icon_view->details->icons_not_positioned);
icon_view->details->icons_not_positioned = NULL;
g_free (icon_view->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
......
......@@ -187,6 +187,9 @@ fm_directory_view_list_initialize (gpointer object, gpointer klass)
static void
fm_directory_view_list_destroy (GtkObject *object)
{
g_return_if_fail (FM_IS_DIRECTORY_VIEW_LIST (object));
g_free (FM_DIRECTORY_VIEW_LIST (object)->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
......
......@@ -219,6 +219,8 @@ fm_directory_view_destroy (GtkObject *object)
if (view->details->background_context_menu != NULL)
gtk_object_unref(GTK_OBJECT(view->details->background_context_menu));
g_free (view->details);
NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object));
}
......
......@@ -24,6 +24,14 @@
#include "nautilus.h"
#include "nautilus-bookmark.h"
#include <libnautilus/nautilus-icon-factory.h>
struct _NautilusBookmarkDetails
{
gchar *name;
gchar *uri;
};
static GtkObjectClass *parent_class = NULL;
......@@ -38,8 +46,10 @@ nautilus_bookmark_destroy (GtkObject *object)
g_return_if_fail(NAUTILUS_IS_BOOKMARK (object));
bookmark = NAUTILUS_BOOKMARK(object);
g_free(bookmark->name);
g_free(bookmark->uri);
g_free (bookmark->details->name);
g_free (bookmark->details->uri);
g_free (bookmark->details);
/* Chain up */
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
......@@ -72,8 +82,7 @@ class_init (NautilusBookmarkClass *class)
static void
init (NautilusBookmark *bookmark)
{
g_assert(bookmark->name == NULL);
g_assert(bookmark->uri == NULL);
bookmark->details = g_new0 (NautilusBookmarkDetails, 1);
}
......@@ -153,7 +162,40 @@ nautilus_bookmark_get_name (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->name;
return bookmark->details->name;
}
gboolean
nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark,
guint icon_size,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return)
{
GdkPixbuf *pixbuf;
NautilusFile *file;
file = nautilus_file_get (nautilus_bookmark_get_uri (bookmark));
/* FIXME: This might be a bookmark that points to nothing, or
* maybe its uri cannot be converted to a NautilusFile for some
* other reason. It should get some sort of generic icon, but for
* now it gets none.
*/
if (file == NULL)
return FALSE;
pixbuf = nautilus_icon_factory_get_icon_for_file (
nautilus_get_current_icon_factory(),
file,
icon_size);
nautilus_file_unref (file);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap_return, mask_return, 100);
gdk_pixbuf_unref (pixbuf);
return TRUE;
}
const gchar *
......@@ -161,7 +203,7 @@ nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->uri;
return bookmark->details->uri;
}
NautilusBookmark *
......@@ -171,8 +213,8 @@ nautilus_bookmark_new (const gchar *name, const gchar *uri)
new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK);
new_bookmark->name = g_strdup(name);
new_bookmark->uri = g_strdup(uri);
new_bookmark->details->name = g_strdup(name);
new_bookmark->details->uri = g_strdup(uri);
return new_bookmark;
}
......
......@@ -40,10 +40,11 @@ typedef struct _NautilusBookmark NautilusBookmark;
#define NAUTILUS_IS_BOOKMARK_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BOOKMARK))
typedef struct _NautilusBookmarkDetails NautilusBookmarkDetails;
struct _NautilusBookmark {
GtkObject object;
gchar *name;
gchar *uri;
NautilusBookmarkDetails *details;
};
struct _NautilusBookmarkClass {
......@@ -60,6 +61,13 @@ NautilusBookmark *nautilus_bookmark_copy (const NautilusBookmark *bookmark)
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *bookmark);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *bookmark);
gboolean nautilus_bookmark_get_pixmap_and_mask
(const NautilusBookmark *bookmark,
guint icon_size,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return);
gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b);
#endif /* NAUTILUS_BOOKMARK_H */
......@@ -28,6 +28,7 @@
#include "nautilus-bookmarklist.h"
#include "nautilus-bookmarks-window.h"
#include <libnautilus/nautilus-gtk-extensions.h>
#include <libnautilus/nautilus-icon-factory.h>
/* object data strings */
#define LAST_STATIC_ITEM "last static item"
......@@ -38,6 +39,8 @@
static void add_bookmark_cb (GtkMenuItem *, gpointer);
static void bookmark_activated_cb (GtkMenuItem *, gpointer);
GtkWidget * bookmark_menu_item_new (const NautilusBookmark *bookmark);
static GtkWidget *create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark);
static void edit_bookmarks_cb (GtkMenuItem *, gpointer);
static void list_changed_cb (NautilusBookmarklist *,
gpointer);
......@@ -137,6 +140,61 @@ bookmark_activated_cb(GtkMenuItem* item, gpointer func_data)
nautilus_bookmarklist_item_at(bookmarks, item_index)));
}
static GtkWidget *
create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
{
GdkPixmap *gdk_pixmap;
GdkBitmap *mask;
if (!nautilus_bookmark_get_pixmap_and_mask (bookmark,
NAUTILUS_ICON_SIZE_SMALLER,
&gdk_pixmap,
&mask))
{
return NULL;
}
return gtk_pixmap_new (gdk_pixmap, mask);
}
/**
* bookmark_menu_item_new:
*
* Return a menu item representing a bookmark.
* @bookmark: The bookmark the menu item represents.
* Return value: A newly-created bookmark.
**/
GtkWidget *
bookmark_menu_item_new (const NautilusBookmark *bookmark)
{
GtkWidget *menu_item;
GtkWidget *pixmap_widget;
GtkWidget *accel_label;
/* Could check gnome_preferences_get_menus_have_icons here, but these
* are more important than stock menu icons, since they're connected to
* user data. For now let's not let them be turn-offable and see if
* anyone objects strenuously.
*/
menu_item = gtk_pixmap_menu_item_new ();
pixmap_widget = create_pixmap_widget_for_bookmark (bookmark);
if (pixmap_widget != NULL)
{
gtk_widget_show (pixmap_widget);
gtk_pixmap_menu_item_set_pixmap (GTK_PIXMAP_MENU_ITEM (menu_item), pixmap_widget);
}
accel_label = gtk_accel_label_new (nautilus_bookmark_get_name (bookmark));