[nautilus] Change NautilusBookmark API.
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [nautilus] Change NautilusBookmark API.
- Date: Thu, 6 May 2010 16:42:14 +0000 (UTC)
commit 856177d1dc13802e6473923d331f8f1ba91f8e51
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Thu May 6 18:13:24 2010 +0200
Change NautilusBookmark API.
Remove _set_has_custom_name() method and use just one _new()
constructor.
Also, emit the CONTENTS_CHANGED signal when we're setting a new name, as
that will trigger a save/reload of .gtk-bookmarks due to saving a new
label.
Finally, don't use gnome-fs-bookmark* icon names anymore, as they're
deprecated. We now use 'folder' as a default icon, and add a 'warning'
emblem when the URI does not exist.
libnautilus-private/nautilus-bookmark.c | 63 ++++++++++++------------------
libnautilus-private/nautilus-bookmark.h | 14 ++----
2 files changed, 30 insertions(+), 47 deletions(-)
---
diff --git a/libnautilus-private/nautilus-bookmark.c b/libnautilus-private/nautilus-bookmark.c
index 8c93ed8..cb2b095 100644
--- a/libnautilus-private/nautilus-bookmark.c
+++ b/libnautilus-private/nautilus-bookmark.c
@@ -34,6 +34,7 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <libnautilus-private/nautilus-file.h>
+#include <libnautilus-private/nautilus-icon-names.h>
enum {
APPEARANCE_CHANGED,
@@ -41,9 +42,6 @@ enum {
LAST_SIGNAL
};
-#define GENERIC_BOOKMARK_ICON_NAME "gnome-fs-bookmark"
-#define MISSING_BOOKMARK_ICON_NAME "gnome-fs-bookmark-missing"
-
#define ELLIPSISED_MENU_ITEM_MIN_CHARS 32
static guint signals[LAST_SIGNAL];
@@ -187,7 +185,7 @@ nautilus_bookmark_copy (NautilusBookmark *bookmark)
{
g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), NULL);
- return nautilus_bookmark_new_with_icon (
+ return nautilus_bookmark_new (
bookmark->details->location,
bookmark->details->name,
bookmark->details->has_custom_name,
@@ -298,6 +296,8 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name)
if (strcmp (new_name, bookmark->details->name) == 0) {
return FALSE;
+ } else if (!bookmark->details->has_custom_name) {
+ bookmark->details->has_custom_name = TRUE;
}
g_free (bookmark->details->name);
@@ -305,13 +305,11 @@ nautilus_bookmark_set_name (NautilusBookmark *bookmark, const char *new_name)
g_signal_emit (bookmark, signals[APPEARANCE_CHANGED], 0);
- return TRUE;
-}
+ if (bookmark->details->has_custom_name) {
+ g_signal_emit (bookmark, signals[CONTENTS_CHANGED], 0);
+ }
-void
-nautilus_bookmark_set_has_custom_name (NautilusBookmark *bookmark, gboolean has_custom_name)
-{
- bookmark->details->has_custom_name = has_custom_name;
+ return TRUE;
}
static gboolean
@@ -438,40 +436,29 @@ bookmark_file_changed_callback (NautilusFile *file, NautilusBookmark *bookmark)
static void
nautilus_bookmark_set_icon_to_default (NautilusBookmark *bookmark)
{
- const char *icon_name;
-
+ GIcon *icon, *emblemed_icon, *folder;
+ GEmblem *emblem;
if (bookmark->details->icon) {
g_object_unref (bookmark->details->icon);
}
+ folder = g_themed_icon_new (NAUTILUS_ICON_FOLDER);
+
if (nautilus_bookmark_uri_known_not_to_exist (bookmark)) {
- icon_name = MISSING_BOOKMARK_ICON_NAME;
- } else {
- icon_name = GENERIC_BOOKMARK_ICON_NAME;
+ icon = g_themed_icon_new (GTK_STOCK_DIALOG_WARNING);
+ emblem = g_emblem_new (icon);
+
+ emblemed_icon = g_emblemed_icon_new (folder, emblem);
+
+ g_object_unref (emblem);
+ g_object_unref (icon);
+ g_object_unref (folder);
+
+ folder = emblemed_icon;
}
-
- bookmark->details->icon = g_themed_icon_new (icon_name);
-}
-/**
- * nautilus_bookmark_new:
- *
- * Create a new NautilusBookmark from a text uri and a display name.
- * The initial icon for the bookmark will be based on the information
- * already available without any explicit action on NautilusBookmark's
- * part.
- *
- * @uri: Any uri, even a malformed or non-existent one.
- * @name: A string to display to the user as the bookmark's name.
- *
- * Return value: A newly allocated NautilusBookmark.
- *
- **/
-NautilusBookmark *
-nautilus_bookmark_new (GFile *location, const char *name)
-{
- return nautilus_bookmark_new_with_icon (location, name, TRUE, NULL);
+ bookmark->details->icon = folder;
}
static void
@@ -535,8 +522,8 @@ nautilus_bookmark_connect_file (NautilusBookmark *bookmark)
}
NautilusBookmark *
-nautilus_bookmark_new_with_icon (GFile *location, const char *name, gboolean has_custom_name,
- GIcon *icon)
+nautilus_bookmark_new (GFile *location, const char *name, gboolean has_custom_name,
+ GIcon *icon)
{
NautilusBookmark *new_bookmark;
diff --git a/libnautilus-private/nautilus-bookmark.h b/libnautilus-private/nautilus-bookmark.h
index e907bf3..cb4b6d3 100644
--- a/libnautilus-private/nautilus-bookmark.h
+++ b/libnautilus-private/nautilus-bookmark.h
@@ -67,12 +67,10 @@ struct NautilusBookmarkClass {
typedef struct NautilusBookmarkClass NautilusBookmarkClass;
GType nautilus_bookmark_get_type (void);
-NautilusBookmark * nautilus_bookmark_new (GFile *location,
- const char *name);
-NautilusBookmark * nautilus_bookmark_new_with_icon (GFile *location,
- const char *name,
- gboolean has_custom_name,
- GIcon *icon);
+NautilusBookmark * nautilus_bookmark_new (GFile *location,
+ const char *name,
+ gboolean has_custom_name,
+ GIcon *icon);
NautilusBookmark * nautilus_bookmark_copy (NautilusBookmark *bookmark);
char * nautilus_bookmark_get_name (NautilusBookmark *bookmark);
GFile * nautilus_bookmark_get_location (NautilusBookmark *bookmark);
@@ -80,9 +78,7 @@ char * nautilus_bookmark_get_uri (NautilusBookmark
GIcon * nautilus_bookmark_get_icon (NautilusBookmark *bookmark);
gboolean nautilus_bookmark_get_has_custom_name (NautilusBookmark *bookmark);
gboolean nautilus_bookmark_set_name (NautilusBookmark *bookmark,
- const char *new_name);
-void nautilus_bookmark_set_has_custom_name (NautilusBookmark *bookmark,
- gboolean has_custom_name);
+ const char *new_name);
gboolean nautilus_bookmark_uri_known_not_to_exist (NautilusBookmark *bookmark);
int nautilus_bookmark_compare_with (gconstpointer a,
gconstpointer b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]