Commit 27cef034 authored by John Sullivan's avatar John Sullivan

The bookmarks menu is now limping along. Add Bookmark works, and the items that

are added work properly. But Edit Bookmarks is still insensitive, so there's no
way to remove items (except by quitting, because the items aren't yet saved and
restored across sessions).
parent d0cfc25e
1999-12-20 John Sullivan <sullivan@eazel.com>
* src/nautilus-bookmark.h,c: new files
* src/nautilus-bookmarklist.h,c: new files
* src/nautilus-bookmarks-menu.h,c: new files
* src/Makefile.am: added these six new files to nautilus_SOURCES
* src/ntl-window.c: now #includes nautilus-bookmarks-menu.h
(bookmarks_menu_info[]): removed all items except GNOMEUIINFO_END;
subtree is added dynamically later.
(nautilus-window-constructed): insert bookmarks menu
(nautilus-window-constructed): add padding to status bar so text
isn't jammed against frame.
The bookmark menu is now limping along. The Add Bookmark item works,
and the items that get added do the right thing. Edit Bookmarks is
still insensitive, so there's no way to remove items. Except by
quitting, because they aren't yet being saved/restored across sessions.
1999-12-20 Havoc Pennington <hp@redhat.com> 1999-12-20 Havoc Pennington <hp@redhat.com>
* src/file-manager/fm-icon-cache.c: Add inline RGB data for * src/file-manager/fm-icon-cache.c: Add inline RGB data for
......
...@@ -17,7 +17,13 @@ LDADD= file-manager/libntl-file-manager.la \ ...@@ -17,7 +17,13 @@ LDADD= file-manager/libntl-file-manager.la \
$(GDK_PIXBUF_LIBS) \ $(GDK_PIXBUF_LIBS) \
$(VFS_LIBS) $(VFS_LIBS)
nautilus_SOURCES= \ nautilus_SOURCES= \
nautilus-bookmark.h \
nautilus-bookmark.c \
nautilus-bookmarklist.h \
nautilus-bookmarklist.c \
nautilus-bookmarks-menu.h \
nautilus-bookmarks-menu.c \
ntl-app.h \ ntl-app.h \
ntl-app.c \ ntl-app.c \
ntl-content-view.h \ ntl-content-view.h \
......
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmark.c - implementation of individual bookmarks.
Copyright (C) 1999 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.h"
#include "nautilus-bookmark.h"
static GtkObjectClass *parent_class = NULL;
/* GtkObject methods. */
static void
nautilus_bookmark_destroy (GtkObject *object)
{
NautilusBookmark *bookmark;
g_return_if_fail(object != NULL);
g_return_if_fail(NAUTILUS_IS_BOOKMARK (object));
bookmark = NAUTILUS_BOOKMARK(object);
g_string_free(bookmark->name, TRUE);
g_string_free(bookmark->uri, TRUE);
/* 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)
{
g_assert(bookmark->name == NULL);
g_assert(bookmark->uri == NULL);
bookmark->name = g_string_new(NULL);
bookmark->uri = g_string_new(NULL);
}
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;
}
NautilusBookmark *
nautilus_bookmark_new (const gchar *name, const gchar *uri)
{
NautilusBookmark *new_bookmark;
new_bookmark = gtk_type_new (NAUTILUS_TYPE_BOOKMARK);
g_string_assign(new_bookmark->name, name);
g_string_assign(new_bookmark->uri, uri);
return new_bookmark;
}
const gchar *
nautilus_bookmark_get_name (const NautilusBookmark *bookmark)
{
return bookmark->name->str;
}
const gchar *
nautilus_bookmark_get_uri (const NautilusBookmark *bookmark)
{
return bookmark->uri->str;
}
\ No newline at end of file
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmark.h - interface for individual bookmarks.
Copyright (C) 1999 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))
struct _NautilusBookmark {
GtkObject object;
GString *name;
GString *uri;
};
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);
const gchar *nautilus_bookmark_get_name (const NautilusBookmark *);
const gchar *nautilus_bookmark_get_uri (const NautilusBookmark *);
#endif /* NAUTILUS_BOOKMARK_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmarklist.c - implementation of centralized list of bookmarks.
Copyright (C) 1999 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.h"
#include "nautilus-bookmarklist.h"
enum {
CONTENTS_CHANGED,
LAST_SIGNAL
};
static GtkObjectClass *parent_class = NULL;
static guint bookmarklist_signals[LAST_SIGNAL] = { 0 };
/* GtkObject methods. */
static void
nautilus_bookmarklist_destroy (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
nautilus_bookmarklist_finalize (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->finalize != NULL)
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
class_init (NautilusBookmarklistClass *class)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_OBJECT);
bookmarklist_signals[CONTENTS_CHANGED] =
gtk_signal_new ("contents_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusBookmarklistClass,
contents_changed),
gtk_marshal_NONE__NONE,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, bookmarklist_signals, LAST_SIGNAL);
object_class->destroy = nautilus_bookmarklist_destroy;
object_class->finalize = nautilus_bookmarklist_finalize;
}
static void
init (NautilusBookmarklist *bookmarks)
{
bookmarks->list = NULL;
}
GtkType
nautilus_bookmarklist_get_type (void)
{
static GtkType type = 0;
if (type == 0) {
static GtkTypeInfo info = {
"NautilusBookmarklist",
sizeof (NautilusBookmarklist),
sizeof (NautilusBookmarklistClass),
(GtkClassInitFunc) class_init,
(GtkObjectInitFunc) init,
NULL,
NULL,
NULL
};
type = gtk_type_unique (GTK_TYPE_OBJECT, &info);
}
return type;
}
/**
* nautilus_bookmarklist_append:
*
* Append a bookmark to a bookmarklist.
* @list: NautilusBookmarklist to append to.
* @bookmark: Bookmark to append a copy of.
**/
void
nautilus_bookmarklist_append (NautilusBookmarklist *bookmarks,
const NautilusBookmark *bookmark)
{
NautilusBookmark *new_bookmark;
new_bookmark = nautilus_bookmark_new(
nautilus_bookmark_get_name(bookmark),
nautilus_bookmark_get_uri(bookmark));
bookmarks->list = g_list_append(bookmarks->list, new_bookmark);
nautilus_bookmarklist_contents_changed(bookmarks);
}
/**
* nautilus_bookmarklist_contents_changed:
*
* Emit the contents_changed signal.
* @bookmarks: NautilusBookmarklist whose contents have been modified.
**/
void
nautilus_bookmarklist_contents_changed(NautilusBookmarklist *bookmarks)
{
g_return_if_fail (bookmarks != NULL);
g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks));
gtk_signal_emit(GTK_OBJECT (bookmarks),
bookmarklist_signals[CONTENTS_CHANGED]);
}
/**
* nautilus_bookmarklist_item_at:
*
* Get the bookmark at the specified position.
* @bookmarks: the list of bookmarks.
* @index: index, must be less than length of list.
*
* Return value: the bookmark at position @index in @bookmarks.
**/
const NautilusBookmark *
nautilus_bookmarklist_item_at (NautilusBookmarklist *bookmarks, guint index)
{
g_return_val_if_fail(bookmarks != NULL, NULL);
g_return_val_if_fail(NAUTILUS_IS_BOOKMARKLIST(bookmarks), NULL);
g_return_val_if_fail(index < g_list_length(bookmarks->list), NULL);
return NAUTILUS_BOOKMARK(g_list_nth_data(bookmarks->list, index));
}
/**
* nautilus_bookmarklist_length:
*
* Get the number of bookmarks in the list.
* @bookmarks: the list of bookmarks.
*
* Return value: the length of the bookmark list.
**/
guint
nautilus_bookmarklist_length (NautilusBookmarklist *bookmarks)
{
g_return_val_if_fail(bookmarks != NULL, 0);
g_return_val_if_fail(NAUTILUS_IS_BOOKMARKLIST(bookmarks), 0);
return g_list_length(bookmarks->list);
}
/**
* nautilus_bookmarklist_new:
*
* Create a new bookmarklist, initially empty.
* FIXME: needs to read initial contents from disk
*
* Return value: A pointer to the new widget.
**/
NautilusBookmarklist *
nautilus_bookmarklist_new ()
{
NautilusBookmarklist *new;
new = gtk_type_new (NAUTILUS_TYPE_BOOKMARKLIST);
return new;
}
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmarklist.h - interface for centralized list of bookmarks.
Copyright (C) 1999 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_BOOKMARKLIST_H
#define NAUTILUS_BOOKMARKLIST_H 1
#include <gnome.h>
#include "nautilus-bookmark.h"
typedef struct _NautilusBookmarklist NautilusBookmarklist;
#define NAUTILUS_TYPE_BOOKMARKLIST \
(nautilus_bookmarklist_get_type ())
#define NAUTILUS_BOOKMARKLIST(obj) \
(GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BOOKMARKLIST, NautilusBookmarklist))
#define NAUTILUS_BOOKMARKLIST_CLASS(klass) \
(GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BOOKMARKLIST, NautilusBookmarklistClass))
#define NAUTILUS_IS_BOOKMARKLIST(obj) \
(GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BOOKMARKLIST))
#define NAUTILUS_IS_BOOKMARKLIST_CLASS(klass) \
(GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BOOKMARKLIST))
struct _NautilusBookmarklist {
GtkObject object;
GList *list;
};
struct _NautilusBookmarklistClass {
GtkObjectClass parent_class;
void (* contents_changed) (NautilusBookmarklist *);
};
typedef struct _NautilusBookmarklistClass NautilusBookmarklistClass;
GtkType nautilus_bookmarklist_get_type (void);
NautilusBookmarklist *nautilus_bookmarklist_new (void);
void nautilus_bookmarklist_append (NautilusBookmarklist*,
const NautilusBookmark*);
void nautilus_bookmarklist_contents_changed
(NautilusBookmarklist *);
guint nautilus_bookmarklist_length (NautilusBookmarklist*);
const NautilusBookmark *nautilus_bookmarklist_item_at (NautilusBookmarklist*, guint);
#endif /* NAUTILUS_BOOKMARKLIST_H */
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
/* nautilus-bookmarks-menu.c - implementation of Bookmarks menu.
Copyright (C) 1999 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.h"
#include "nautilus-bookmarks-menu.h"
#include "nautilus-bookmarklist.h"
/* object data strings */
#define LAST_STATIC_ITEM "last static item"
#define WINDOW_TO_UPDATE "window to update"
/* forward declarations for static functions */
static void add_bookmark_cb (GtkMenuItem *, gpointer);
static void bookmark_activated_cb (GtkMenuItem *, gpointer);
static void list_changed_cb (NautilusBookmarklist *,
gpointer);
static void nautilus_bookmarks_menu_append (NautilusBookmarksMenu *,
GtkWidget *);
static void nautilus_bookmarks_menu_clear_bookmarks (NautilusBookmarksMenu *);
static void nautilus_bookmarks_menu_repopulate (NautilusBookmarksMenu *);
/* static variables */
static GtkMenuClass *parent_class = NULL;
static NautilusBookmarklist *bookmarks = NULL;
/* GtkObject methods. */
static void
destroy (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->destroy != NULL)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
finalize (GtkObject *object)
{
if (GTK_OBJECT_CLASS (parent_class)->finalize != NULL)
(* GTK_OBJECT_CLASS (parent_class)->finalize) (object);
}
/* Initialization. */
static void
class_init (NautilusBookmarksMenuClass *class)
{
GtkObjectClass *object_class;
object_class = GTK_OBJECT_CLASS (class);
parent_class = gtk_type_class (GTK_TYPE_MENU);
bookmarks = nautilus_bookmarklist_new();
object_class->destroy = destroy;
object_class->finalize = finalize;
}
static void
init (NautilusBookmarksMenu *bookmarks_menu)
{
GtkWidget *item;
if (gnome_preferences_get_menus_have_tearoff())
{
nautilus_bookmarks_menu_append(bookmarks_menu,
gtk_tearoff_menu_item_new());
}
item = gtk_menu_item_new_with_label(_("Add Bookmark"));
gtk_signal_connect(GTK_OBJECT (item), "activate",
GTK_SIGNAL_FUNC (add_bookmark_cb),
bookmarks_menu);
nautilus_bookmarks_menu_append(bookmarks_menu, item);
item = gtk_menu_item_new_with_label(_("Edit Bookmarks..."));
/* FIXME: Implement this, currently marked insensitive until implemented.
* I will do this soon, but wanted to get in first cut at other bookmark
* stuff before leaving for holidays.
*/
gtk_widget_set_sensitive(GTK_WIDGET(item), FALSE);
nautilus_bookmarks_menu_append(bookmarks_menu, item);
item = gtk_menu_item_new();
/* mark this menu item specially so we can recognize it later */
gtk_object_set_data(GTK_OBJECT(item),
LAST_STATIC_ITEM,
GINT_TO_POINTER(TRUE));
nautilus_bookmarks_menu_append(bookmarks_menu, item);
gtk_signal_connect(GTK_OBJECT(bookmarks),
"contents_changed",
GTK_SIGNAL_FUNC(list_changed_cb),
bookmarks_menu);
nautilus_bookmarks_menu_repopulate(bookmarks_menu);
}
static void
add_bookmark_cb(GtkMenuItem* item, gpointer func_data)
{
NautilusBookmarksMenu *bookmarks_menu;
NautilusBookmark *bookmark;
const char* current_uri;
g_return_if_fail(func_data != NULL);
g_return_if_fail(NAUTILUS_IS_BOOKMARKS_MENU (func_data));
bookmarks_menu = NAUTILUS_BOOKMARKS_MENU (func_data);