GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit b9e12ae6 authored by John Sullivan's avatar John Sullivan

Moved NautilusBookmark from src/ to libnautilus/, in anticipation of using it in

History metaview.
parent ee438780
2000-02-15 John Sullivan <sullivan@eazel.com>
Moved NautilusBookmark to libnautilus, in preparation for
using it in the History metaview.
* src/nautilus-bookmark.c: Removed file.
* src/nautilus-bookmark.h: Removed file.
* src/Makefile.am: Took out these two files.
* libnautilus/nautilus-bookmark.c: Added file.
* libnautilus/nautilus-bookmark.h: Added file.
* libnautilus/Makefile.am: Build the two new files.
* src/nautilus-bookmarklist.h: Updated #include
2000-02-15 John Sullivan <sullivan@eazel.com> 2000-02-15 John Sullivan <sullivan@eazel.com>
Right-click menus from Back and Forward buttons now include Right-click menus from Back and Forward buttons now include
......
...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \ ...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \
nautilus.h \ nautilus.h \
nautilus-alloc.h \ nautilus-alloc.h \
nautilus-background.h \ nautilus-background.h \
nautilus-bookmark.h \
nautilus-debug.h \ nautilus-debug.h \
nautilus-directory.h \ nautilus-directory.h \
nautilus-file-utilities.h \ nautilus-file-utilities.h \
...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkscrollframe.c \ gtkscrollframe.c \
nautilus-background.c \ nautilus-background.c \
nautilus-background-canvas-group.c \ nautilus-background-canvas-group.c \
nautilus-bookmark.c \
nautilus-debug.c \ nautilus-debug.c \
nautilus-default-file-icon.c \ nautilus-default-file-icon.c \
nautilus-default-file-icon.h \ nautilus-default-file-icon.h \
......
...@@ -22,9 +22,8 @@ ...@@ -22,9 +22,8 @@
Authors: John Sullivan <sullivan@eazel.com> Authors: John Sullivan <sullivan@eazel.com>
*/ */
#include "nautilus.h"
#include "nautilus-bookmark.h" #include "nautilus-bookmark.h"
#include <libnautilus/nautilus-icon-factory.h> #include "nautilus-icon-factory.h"
struct _NautilusBookmarkDetails struct _NautilusBookmarkDetails
{ {
......
...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \ ...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \
nautilus.h \ nautilus.h \
nautilus-alloc.h \ nautilus-alloc.h \
nautilus-background.h \ nautilus-background.h \
nautilus-bookmark.h \
nautilus-debug.h \ nautilus-debug.h \
nautilus-directory.h \ nautilus-directory.h \
nautilus-file-utilities.h \ nautilus-file-utilities.h \
...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkscrollframe.c \ gtkscrollframe.c \
nautilus-background.c \ nautilus-background.c \
nautilus-background-canvas-group.c \ nautilus-background-canvas-group.c \
nautilus-bookmark.c \
nautilus-debug.c \ nautilus-debug.c \
nautilus-default-file-icon.c \ nautilus-default-file-icon.c \
nautilus-default-file-icon.h \ nautilus-default-file-icon.h \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmark.c - implementation of individual bookmarks.
Copyright (C) 1999, 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: John Sullivan <sullivan@eazel.com>
*/
#include "nautilus-bookmark.h"
#include "nautilus-icon-factory.h"
struct _NautilusBookmarkDetails
{
gchar *name;
gchar *uri;
};
static GtkWidget *create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark);
static GtkObjectClass *parent_class = NULL;
/* GtkObject methods. */
static void
nautilus_bookmark_destroy (GtkObject *object)
{
NautilusBookmark *bookmark;
g_return_if_fail(NAUTILUS_IS_BOOKMARK (object));
bookmark = NAUTILUS_BOOKMARK(object);
g_free (bookmark->details->name);
g_free (bookmark->details->uri);
g_free (bookmark->details);
/* Chain up */
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
nautilus_bookmark_finalize (GtkObject *object)
{
/* Chain up */
if (GTK_OBJECT_CLASS (parent_class)->finalize != NULL)
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
class_init (NautilusBookmarkClass *class)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
object_class->destroy = nautilus_bookmark_destroy;
object_class->finalize = nautilus_bookmark_finalize;
}
static void
init (NautilusBookmark *bookmark)
{
bookmark->details = g_new0 (NautilusBookmarkDetails, 1);
}
GtkType
nautilus_bookmark_get_type (void)
{
static GtkType type = 0;
if (type == 0) {
static GtkTypeInfo info = {
"NautilusBookmark",
sizeof (NautilusBookmark),
sizeof (NautilusBookmarkClass),
(GtkClassInitFunc) class_init,
(GtkObjectInitFunc) init,
NULL,
NULL,
NULL
};
type = gtk_type_unique (GTK_TYPE_OBJECT, &info);
}
return type;
}
/**
* nautilus_bookmark_compare_with:
*
* Check whether two bookmarks are considered identical.
* @a: first NautilusBookmark*.
* @b: second NautilusBookmark*.
*
* Return value: 0 if @a and @b have same name and uri, 1 otherwise
* (GCompareFunc style)
**/
gint
nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b)
{
NautilusBookmark *bookmark_a;
NautilusBookmark *bookmark_b;
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK(a), 1);
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK(b), 1);
bookmark_a = NAUTILUS_BOOKMARK(a);
bookmark_b = NAUTILUS_BOOKMARK(b);
if (strcmp(nautilus_bookmark_get_name(bookmark_a),
nautilus_bookmark_get_name(bookmark_b)) != 0)
{
return 1;
}
if (strcmp(nautilus_bookmark_get_uri(bookmark_a),
nautilus_bookmark_get_uri(bookmark_b)) != 0)
{
return 1;
}
return 0;
}
NautilusBookmark *
nautilus_bookmark_copy (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
}
const gchar *
nautilus_bookmark_get_name (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->details->name;
}
gboolean
nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark,
guint icon_size,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return)
{
NautilusFile *file;
NautilusScalableIcon *scalable_icon;
GdkPixbuf *pixbuf;
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;
scalable_icon = nautilus_icon_factory_get_icon_for_file (file);
nautilus_file_unref (file);
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
(scalable_icon, icon_size);
nautilus_scalable_icon_unref (scalable_icon);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap_return, mask_return, 100);
gdk_pixbuf_unref (pixbuf);
return TRUE;
}
const gchar *
nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->details->uri;
}
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
{
NautilusBookmark *new_bookmark;
new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK);
new_bookmark->details->name = g_strdup(name);
new_bookmark->details->uri = g_strdup(uri);
return new_bookmark;
}
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);
}
/**
* nautilus_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 *
nautilus_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));
gtk_misc_set_alignment (GTK_MISC (accel_label), 0.0, 0.5);
gtk_container_add (GTK_CONTAINER (menu_item), accel_label);
gtk_accel_label_set_accel_widget (GTK_ACCEL_LABEL (accel_label), menu_item);
gtk_widget_show (accel_label);
return menu_item;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmark.h - interface for individual bookmarks.
Copyright (C) 1999, 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: John Sullivan <sullivan@eazel.com>
*/
#ifndef NAUTILUS_BOOKMARK_H
#define NAUTILUS_BOOKMARK_H 1
#include <gnome.h>
typedef struct _NautilusBookmark NautilusBookmark;
#define NAUTILUS_TYPE_BOOKMARK \
(nautilus_bookmark_get_type ())
#define NAUTILUS_BOOKMARK(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BOOKMARK, NautilusBookmark))
#define NAUTILUS_BOOKMARK_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BOOKMARK, NautilusBookmarkClass))
#define NAUTILUS_IS_BOOKMARK(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BOOKMARK))
#define NAUTILUS_IS_BOOKMARK_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BOOKMARK))
typedef struct _NautilusBookmarkDetails NautilusBookmarkDetails;
struct _NautilusBookmark {
GtkObject object;
NautilusBookmarkDetails *details;
};
struct _NautilusBookmarkClass {
GtkObjectClass parent_class;
};
typedef struct _NautilusBookmarkClass NautilusBookmarkClass;
GtkType nautilus_bookmark_get_type (void);
NautilusBookmark *nautilus_bookmark_new (const gchar *name,
const gchar *uri);
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);
gint nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b);
/* Helper functions for displaying bookmarks */
gboolean nautilus_bookmark_get_pixmap_and_mask
(const NautilusBookmark *bookmark,
guint icon_size,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return);
GtkWidget * nautilus_bookmark_menu_item_new
(const NautilusBookmark *bookmark);
#endif /* NAUTILUS_BOOKMARK_H */
...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \ ...@@ -34,6 +34,7 @@ libnautilusinclude_HEADERS= \
nautilus.h \ nautilus.h \
nautilus-alloc.h \ nautilus-alloc.h \
nautilus-background.h \ nautilus-background.h \
nautilus-bookmark.h \
nautilus-debug.h \ nautilus-debug.h \
nautilus-directory.h \ nautilus-directory.h \
nautilus-file-utilities.h \ nautilus-file-utilities.h \
...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ...@@ -59,6 +60,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \
gtkscrollframe.c \ gtkscrollframe.c \
nautilus-background.c \ nautilus-background.c \
nautilus-background-canvas-group.c \ nautilus-background-canvas-group.c \
nautilus-bookmark.c \
nautilus-debug.c \ nautilus-debug.c \
nautilus-default-file-icon.c \ nautilus-default-file-icon.c \
nautilus-default-file-icon.h \ nautilus-default-file-icon.h \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmark.c - implementation of individual bookmarks.
Copyright (C) 1999, 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: John Sullivan <sullivan@eazel.com>
*/
#include "nautilus-bookmark.h"
#include "nautilus-icon-factory.h"
struct _NautilusBookmarkDetails
{
gchar *name;
gchar *uri;
};
static GtkWidget *create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark);
static GtkObjectClass *parent_class = NULL;
/* GtkObject methods. */
static void
nautilus_bookmark_destroy (GtkObject *object)
{
NautilusBookmark *bookmark;
g_return_if_fail(NAUTILUS_IS_BOOKMARK (object));
bookmark = NAUTILUS_BOOKMARK(object);
g_free (bookmark->details->name);
g_free (bookmark->details->uri);
g_free (bookmark->details);
/* Chain up */
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
nautilus_bookmark_finalize (GtkObject *object)
{
/* Chain up */
if (GTK_OBJECT_CLASS (parent_class)->finalize != NULL)
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
class_init (NautilusBookmarkClass *class)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
object_class->destroy = nautilus_bookmark_destroy;
object_class->finalize = nautilus_bookmark_finalize;
}
static void
init (NautilusBookmark *bookmark)
{
bookmark->details = g_new0 (NautilusBookmarkDetails, 1);
}
GtkType
nautilus_bookmark_get_type (void)
{
static GtkType type = 0;
if (type == 0) {
static GtkTypeInfo info = {
"NautilusBookmark",
sizeof (NautilusBookmark),
sizeof (NautilusBookmarkClass),
(GtkClassInitFunc) class_init,
(GtkObjectInitFunc) init,
NULL,
NULL,
NULL
};
type = gtk_type_unique (GTK_TYPE_OBJECT, &info);
}
return type;
}
/**
* nautilus_bookmark_compare_with:
*
* Check whether two bookmarks are considered identical.
* @a: first NautilusBookmark*.
* @b: second NautilusBookmark*.
*
* Return value: 0 if @a and @b have same name and uri, 1 otherwise
* (GCompareFunc style)
**/
gint
nautilus_bookmark_compare_with (gconstpointer a, gconstpointer b)
{
NautilusBookmark *bookmark_a;
NautilusBookmark *bookmark_b;
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK(a), 1);
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK(b), 1);
bookmark_a = NAUTILUS_BOOKMARK(a);
bookmark_b = NAUTILUS_BOOKMARK(b);
if (strcmp(nautilus_bookmark_get_name(bookmark_a),
nautilus_bookmark_get_name(bookmark_b)) != 0)
{
return 1;
}
if (strcmp(nautilus_bookmark_get_uri(bookmark_a),
nautilus_bookmark_get_uri(bookmark_b)) != 0)
{
return 1;
}
return 0;
}
NautilusBookmark *
nautilus_bookmark_copy (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
}
const gchar *
nautilus_bookmark_get_name (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->details->name;
}
gboolean
nautilus_bookmark_get_pixmap_and_mask (const NautilusBookmark *bookmark,
guint icon_size,
GdkPixmap **pixmap_return,
GdkBitmap **mask_return)
{
NautilusFile *file;
NautilusScalableIcon *scalable_icon;
GdkPixbuf *pixbuf;
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;
scalable_icon = nautilus_icon_factory_get_icon_for_file (file);
nautilus_file_unref (file);
pixbuf = nautilus_icon_factory_get_pixbuf_for_icon
(scalable_icon, icon_size);
nautilus_scalable_icon_unref (scalable_icon);
gdk_pixbuf_render_pixmap_and_mask (pixbuf, pixmap_return, mask_return, 100);
gdk_pixbuf_unref (pixbuf);
return TRUE;
}
const gchar *
nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
{
g_return_val_if_fail(NAUTILUS_IS_BOOKMARK (bookmark), NULL);
return bookmark->details->uri;
}
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
{
NautilusBookmark *new_bookmark;
new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK);
new_bookmark->details->name = g_strdup(name);
new_bookmark->details->uri = g_strdup(uri);
return new_bookmark;
}
static GtkWidget *
create_pixmap_widget_for_bookmark (const NautilusBookmark *bookmark)
{
GdkPixmap *gdk_pixmap;
GdkBitmap *mask;
if (!nautilus_bookmark_get_pixmap_and_mask (bookmark,