Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
GNOME
Files
Commits
ecc10811
Commit
ecc10811
authored
Jan 28, 2000
by
John Sullivan
Browse files
Added icons to bookmarks menu & window; cleaned up some zoom code; fixed a few
storage leaks.
parent
6abbef77
Changes
20
Hide whitespace changes
Inline
Side-by-side
ChangeLog-20000414
View file @
ecc10811
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 remove
d
files.
* libnautilus/nautilus-default-file-icon.c: New file
* libnautilus/nautilus-default-file-icon.h: New file
...
...
libnautilus-extensions/gnome-icon-container-private.h
View file @
ecc10811
...
...
@@ -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
);
...
...
libnautilus-extensions/gnome-icon-container.c
View file @
ecc10811
...
...
@@ -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
);
}
}
...
...
libnautilus-extensions/nautilus-directory.c
View file @
ecc10811
...
...
@@ -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
;
...
...
libnautilus-extensions/nautilus-icon-factory.h
View file @
ecc10811
...
...
@@ -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 1
6
#define NAUTILUS_ICON_SIZE_SMALLEST 1
2
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 3
2
#define NAUTILUS_ICON_SIZE_SMALL 3
6
#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 1
44
#define NAUTILUS_ICON_SIZE_LARGEST 1
92
typedef
struct
_NautilusIconFactory
NautilusIconFactory
;
...
...
libnautilus-private/gnome-icon-container-private.h
View file @
ecc10811
...
...
@@ -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
);
...
...
libnautilus-private/gnome-icon-container.c
View file @
ecc10811
...
...
@@ -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
);
}
}
...
...
libnautilus-private/nautilus-directory.c
View file @
ecc10811
...
...
@@ -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
;
...
...
libnautilus-private/nautilus-icon-factory.h
View file @
ecc10811
...
...
@@ -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 1
6
#define NAUTILUS_ICON_SIZE_SMALLEST 1
2
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 3
2
#define NAUTILUS_ICON_SIZE_SMALL 3
6
#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 1
44
#define NAUTILUS_ICON_SIZE_LARGEST 1
92
typedef
struct
_NautilusIconFactory
NautilusIconFactory
;
...
...
libnautilus/gnome-icon-container-private.h
View file @
ecc10811
...
...
@@ -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
);
...
...
libnautilus/gnome-icon-container.c
View file @
ecc10811
...
...
@@ -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
);
}
}
...
...
libnautilus/nautilus-directory.c
View file @
ecc10811
...
...
@@ -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
;
...
...
libnautilus/nautilus-icon-factory.h
View file @
ecc10811
...
...
@@ -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 1
6
#define NAUTILUS_ICON_SIZE_SMALLEST 1
2
#define NAUTILUS_ICON_SIZE_SMALLER 24
#define NAUTILUS_ICON_SIZE_SMALL 3
2
#define NAUTILUS_ICON_SIZE_SMALL 3
6
#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 1
44
#define NAUTILUS_ICON_SIZE_LARGEST 1
92
typedef
struct
_NautilusIconFactory
NautilusIconFactory
;
...
...
src/file-manager/fm-directory-view-icons.c
View file @
ecc10811
...
...
@@ -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
));
}
...
...
src/file-manager/fm-directory-view-list.c
View file @
ecc10811
...
...
@@ -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
));
}
...
...
src/file-manager/fm-directory-view.c
View file @
ecc10811
...
...
@@ -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
));
}
...
...
src/nautilus-bookmark.c
View file @
ecc10811
...
...
@@ -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
;
}
...
...
src/nautilus-bookmark.h
View file @
ecc10811
...
...
@@ -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 */
src/nautilus-bookmarks-menu.c
View file @
ecc10811
...
...
@@ -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
);
}