diff options
57 files changed, 1616 insertions, 1735 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index fff1c0df4..4220eb6b5 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,3 +1,48 @@ +2000-03-16 Darin Adler <darin@eazel.com> + + Did some of the renamings that were queued in RENAMING. + + * libnautilus/Makefile.am: + * libnautilus/gdk-extensions.c: + * libnautilus/gdk-extensions.h: + * libnautilus/nautilus-gdk-extensions.c: + * libnautilus/nautilus-gdk-extensions.h: + * libnautilus/gnome-icon-container.c: + * libnautilus/nautilus-background.c: + * libnautilus/nautilus-icons-view-icon-item.c: + Renamed gdk-extensions to add the nautilus- prefix and changed + all includers. + + * src/Makefile.am: + * src/explorer-location-bar.c: + * src/explorer-location-bar.h: + * src/nautilus-location-bar.c: + * src/nautilus-location-bar.h: + * src/ntl-window-msgs.c: + * src/ntl-window.c: + Renamed ExplorerLocationBar to NautilusLocationBar. + + * src/Makefile.am: + * src/nautilus-bookmarklist.c: + * src/nautilus-bookmarklist.h: + * src/nautilus-bookmark-list.c: + * src/nautilus-bookmark-list.h: + * src/nautilus-bookmarks-window.c: + * src/nautilus-bookmarks-window.h: + * src/nautilus-window-menus.c: + Renamed NautilusBookmarklist to NautilusBookmarkList. + + * RENAMING: Marked items done and added some new ones. + + * nautilus-widgets/nautilus-preferences-item.c: + * nautilus-widgets/nautilus-preferences.c: + * nautilus-widgets/test-nautilus-widgets.c: + * libnautilus/nautilus-icon-factory.c: + * src/file-manager/fm-directory-view-icons.c: + * src/file-manager/fm-directory-view.c: + * src/file-manager/fm-icon-text-window.c: + Cleaned up the interface to NautilusPreferences a bit. + 2000-03-16 John Sullivan <sullivan@eazel.com> Fixes for a couple of preferences bugs Darin and I ran into @@ -1,23 +1,17 @@ We put plans for renaming in here so we can think about them for a while. +Note that when we rename a class, it usually involves renaming some files too. +--- -gdk-extensions.[ch] -> nautilus-gdk-extensions.[ch] ntl* -> nautilus* (1) - -ExplorerLocationBar -> NautilusLocationBar - -GnomeIconContainer -> NautilusIconContainer -NautilusIconsViewIconItem -> NautilusIconContainerItem -GtkFList -> NautilusList +NautilusViewFrame <--> NautilusView (2) +ntl-view-bonobo-subdoc -> ntl-view-bonobo-embeddable (see also 1, 2) FMDirectoryViewIcons -> FMDirectoryIconView FMDirectoryViewList -> FMDirectoryListView -NautilusBookmarklist -> NautilusBookmarkList -nautilus-bookmarklist* -> nautilus-bookmark-list* - -NautilusViewFrame <--> NautilusView (2) - -nautilus_has_prefix -> nautilus_str_has_prefix -nautilus_has_suffix -> nautilus_str_has_suffix +GnomeIconContainer -> NautilusIconContainer +GnomeIconContainerIcon -> NautilusIcon +NautilusIconsViewIconItem -> NautilusIconCanvasItem -ntl-view-bonobo-subdoc -> ntl-view-bonobo-embeddable (see also 1, 2) +GtkFList -> NautilusList +GtkScrollFrame -> NautilusScrollFrame diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index 864c52219..3d87d4b2d 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -28,7 +28,6 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ bonobo-stream-vfs.h \ - gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ @@ -41,6 +40,7 @@ libnautilusinclude_HEADERS= \ nautilus-directory.h \ nautilus-file-utilities.h \ nautilus-file.h \ + nautilus-gdk-extensions.h \ nautilus-glib-extensions.h \ nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ @@ -62,7 +62,6 @@ libnautilusinclude_HEADERS= \ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ - gdk-extensions.c \ gnome-icon-container.c \ gnome-icon-container-dnd.c \ gnome-icon-container-grid.c \ @@ -78,6 +77,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ nautilus-directory.c \ nautilus-file-utilities.c \ nautilus-file.c \ + nautilus-gdk-extensions.c \ nautilus-glib-extensions.c \ nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ diff --git a/libnautilus-extensions/gnome-icon-container.c b/libnautilus-extensions/gnome-icon-container.c index f81f62fa8..bb69377e1 100644 --- a/libnautilus-extensions/gnome-icon-container.c +++ b/libnautilus-extensions/gnome-icon-container.c @@ -34,8 +34,8 @@ #include <libgnomeui/gnome-canvas-rect-ellipse.h> #include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "gdk-extensions.h" #include "nautilus-glib-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus-extensions/nautilus-background.c b/libnautilus-extensions/nautilus-background.c index 8491ba340..faaccb958 100644 --- a/libnautilus-extensions/nautilus-background.c +++ b/libnautilus-extensions/nautilus-background.c @@ -26,7 +26,7 @@ #include "nautilus-background.h" #include <gtk/gtksignal.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-background-canvas-group.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-gtk-macros.h" diff --git a/libnautilus-extensions/gdk-extensions.c b/libnautilus-extensions/nautilus-gdk-extensions.c index a080d4fba..79a74d60a 100644 --- a/libnautilus-extensions/gdk-extensions.c +++ b/libnautilus-extensions/nautilus-gdk-extensions.c @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.c: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.c: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -23,7 +23,7 @@ */ #include <config.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus/gdk-extensions.h b/libnautilus-extensions/nautilus-gdk-extensions.h index 01d2770ab..594f740fd 100644 --- a/libnautilus/gdk-extensions.h +++ b/libnautilus-extensions/nautilus-gdk-extensions.h @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.h: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.h: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -22,10 +22,10 @@ Authors: Darin Adler <darin@eazel.com> */ -#ifndef GDK_EXTENSIONS_H -#define GDK_EXTENSIONS_H +#ifndef NAUTILUS_GDK_EXTENSIONS_H +#define NAUTILUS_GDK_EXTENSIONS_H -#include <gdk/gdk.h> +#include <gdk/gdktypes.h> /* A gradient spec. is a string that contains a specifier for either a color or a gradient. If the string has a "-" in it, then it's a gradient. @@ -89,4 +89,4 @@ void nautilus_gdk_pixbuf_list_ref (GList *pixbuf void nautilus_gdk_pixbuf_list_unref (GList *pixbuf_list); void nautilus_gdk_pixbuf_list_free (GList *pixbuf_list); -#endif /* GDK_EXTENSIONS_H */ +#endif /* NAUTILUS_GDK_EXTENSIONS_H */ diff --git a/libnautilus-extensions/nautilus-icon-factory.c b/libnautilus-extensions/nautilus-icon-factory.c index 3115e99d7..913063076 100644 --- a/libnautilus-extensions/nautilus-icon-factory.c +++ b/libnautilus-extensions/nautilus-icon-factory.c @@ -139,7 +139,6 @@ typedef struct { /* id of timeout task for making thumbnails */ int timeout_task_id; - } NautilusIconFactory; typedef struct { @@ -180,18 +179,18 @@ typedef struct { /* forward declarations */ -static void icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data); +static void icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); static GtkType nautilus_icon_factory_get_type (void); static void nautilus_icon_factory_initialize_class (NautilusIconFactoryClass *class); static void nautilus_icon_factory_initialize (NautilusIconFactory *factory); static NautilusIconFactory * nautilus_get_current_icon_factory (void); static char * nautilus_icon_factory_get_thumbnail_uri (NautilusFile *file); static NautilusIconFactory * nautilus_icon_factory_new (const char *theme_name); -void nautilus_icon_factory_set_theme (const char *theme_name); +static void nautilus_icon_factory_set_theme (const char *theme_name); static NautilusScalableIcon *nautilus_scalable_icon_get (const char *uri, const char *name); static guint nautilus_scalable_icon_hash (gconstpointer p); @@ -235,7 +234,7 @@ nautilus_get_current_icon_factory (void) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) global_icon_factory); + NULL); } return global_icon_factory; @@ -326,7 +325,7 @@ nautilus_icon_factory_destroy (NautilusIconFactory *factory) nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) factory); + NULL); nautilus_icon_factory_clear (); g_hash_table_destroy (factory->icon_cache); @@ -584,21 +583,19 @@ get_icon_file_path (const char *name, guint size_in_pixels, ArtIRect *text_rect) } static void -icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + GtkFundamentalType type, + gconstpointer value, gpointer user_data) { - NautilusIconFactory *icon_factory; - - g_assert (user_data != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); - - icon_factory = (NautilusIconFactory *)user_data; + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_ICON_THEME) == 0); + g_assert (type == NAUTILUS_PREFERENCE_STRING); + g_assert (value != NULL); + g_assert (user_data == NULL); - nautilus_icon_factory_set_theme ((char *)pref_value); + nautilus_icon_factory_set_theme ((char *) value); } /* Get or create a scalable icon. */ diff --git a/libnautilus-extensions/nautilus-icons-view-icon-item.c b/libnautilus-extensions/nautilus-icons-view-icon-item.c index 851a5668f..b56c4a41c 100644 --- a/libnautilus-extensions/nautilus-icons-view-icon-item.c +++ b/libnautilus-extensions/nautilus-icons-view-icon-item.c @@ -35,7 +35,7 @@ #include "gnome-icon-container-private.h" #include "nautilus-string.h" #include "nautilus-glib-extensions.h" -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-gnome-extensions.h" diff --git a/libnautilus-extensions/nautilus-preferences-item.c b/libnautilus-extensions/nautilus-preferences-item.c index dc382f788..6d58cfc0d 100644 --- a/libnautilus-extensions/nautilus-preferences-item.c +++ b/libnautilus-extensions/nautilus-preferences-item.c @@ -246,7 +246,7 @@ preferences_item_construct (NautilusPreferencesItem *item, item->details->prefs = prefs; item->details->pref_name = g_strdup (pref_name); - pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFS (item->details->prefs), + pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); g_assert (pref_info != NULL); @@ -297,11 +297,11 @@ preferences_item_create_enum (NautilusPreferencesItem *item, item->details->child = nautilus_radio_button_group_new (); - enum_info = (NautilusPreferencesEnumData *) pref_info->type_data; + enum_info = (NautilusPreferencesEnumData *) pref_info->data; g_assert (enum_info != NULL); - value = nautilus_preferences_get_enum (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); for (i = 0; i < enum_info->num_entries; i++) @@ -334,11 +334,11 @@ preferences_item_create_boolean (NautilusPreferencesItem *item, g_assert (item->details->prefs != NULL); g_assert (item->details->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->description != NULL); - item->details->child = gtk_check_button_new_with_label (pref_info->pref_description); + item->details->child = gtk_check_button_new_with_label (pref_info->description); - value = nautilus_preferences_get_boolean (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->details->child), value); @@ -381,7 +381,7 @@ enum_radio_group_changed_cb (GtkWidget *buttons, GtkWidget * button, gpointer us i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons)); - nautilus_preferences_set_enum (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, i); } @@ -396,7 +396,7 @@ boolean_button_toggled_cb (GtkWidget *button, gpointer user_data) active_state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - nautilus_preferences_set_boolean (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, active_state); } diff --git a/libnautilus-extensions/nautilus-preferences.c b/libnautilus-extensions/nautilus-preferences.c index 48da6c7dd..47fba7515 100644 --- a/libnautilus-extensions/nautilus-preferences.c +++ b/libnautilus-extensions/nautilus-preferences.c @@ -1,4 +1,4 @@ - /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* nautilus-prefs.h - Preference peek/poke/notify object implementation. @@ -22,11 +22,13 @@ Authors: Ramiro Estrugo <ramiro@eazel.com> */ +#include <config.h> +#include "nautilus-preferences.h" -#include <nautilus-widgets/nautilus-preferences.h> +#include <libgnome/gnome-config.h> #include <libnautilus/nautilus-gtk-macros.h> -static const char * PREFERENCES_GLOBAL_DOMAIN = "Nautilus::Global"; +static const char PREFERENCES_GLOBAL_DOMAIN[] = "Nautilus::Global"; enum { ACTIVATE, @@ -45,53 +47,53 @@ typedef struct { const PrefHashInfo *hash_info; } PrefCallbackInfo; -struct _NautilusPreferencesDetails { +struct NautilusPreferencesDetails { char *domain; GHashTable *prefs_hash_table; }; /* NautilusPreferencesClass methods */ -static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); -static void nautilus_preferences_initialize (NautilusPreferences *prefs); +static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); +static void nautilus_preferences_initialize (NautilusPreferences *prefs); /* GtkObjectClass methods */ -static void prefs_destroy (GtkObject *object); +static void prefs_destroy (GtkObject *object); /* PrefHashInfo functions */ -static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); -static void pref_hash_info_free (PrefHashInfo *pref_hash_info); -static void pref_hash_info_free_func (gpointer key, - gpointer value, - gpointer user_data); +static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); +static void pref_hash_info_free (PrefHashInfo *pref_hash_info); +static void pref_hash_info_free_func (gpointer key, + gpointer value, + gpointer user_data); /* PrefCallbackInfo functions */ -static PrefCallbackInfo * pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, - gpointer user_data, - const PrefHashInfo *hash_info); -static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); -static void pref_callback_info_free_func (gpointer data, - gpointer user_data); -static void pref_callback_info_invoke_func (gpointer data, - gpointer user_data); -static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); -static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); +static PrefCallbackInfo *pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, + gpointer user_data, + const PrefHashInfo *hash_info); +static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); +static void pref_callback_info_free_func (gpointer data, + gpointer user_data); +static void pref_callback_info_invoke_func (gpointer data, + gpointer user_data); +static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); +static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); /* Private stuff */ -static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type); -static gboolean prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value); -static gboolean prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out); -PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name); -static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); +static gboolean prefs_check_supported_type (NautilusPreferencesType type); +static void prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer value); +static gboolean prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *pref_value_out); +PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, + const char *name); +static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferences, nautilus_preferences, GTK_TYPE_OBJECT) @@ -130,17 +132,14 @@ prefs_destroy (GtkObject *object) { NautilusPreferences * prefs; - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (object)); - - prefs = NAUTILUS_PREFS (object); + prefs = NAUTILUS_PREFERENCES (object); g_free (prefs->details->domain); if (prefs->details->prefs_hash_table != NULL) { g_hash_table_foreach (prefs->details->prefs_hash_table, pref_hash_info_free_func, - (gpointer) NULL); + NULL); g_hash_table_destroy (prefs->details->prefs_hash_table); @@ -163,18 +162,18 @@ pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - g_assert (pref_info->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->name != NULL); + g_assert (pref_info->description != NULL); pref_hash_info = g_new (PrefHashInfo, 1); - pref_hash_info->pref_info.pref_name = g_strdup (pref_info->pref_name); - pref_hash_info->pref_info.pref_description = g_strdup (pref_info->pref_description); - pref_hash_info->pref_info.pref_type = pref_info->pref_type; - pref_hash_info->pref_info.pref_default_value = pref_info->pref_default_value; - pref_hash_info->pref_info.type_data = pref_info->type_data; + pref_hash_info->pref_info.name = g_strdup (pref_info->name); + pref_hash_info->pref_info.description = g_strdup (pref_info->description); + pref_hash_info->pref_info.type = pref_info->type; + pref_hash_info->pref_info.default_value = pref_info->default_value; + pref_hash_info->pref_info.data = pref_info->data; - pref_hash_info->pref_value = (gpointer) pref_info->pref_default_value; + pref_hash_info->pref_value = (gpointer) pref_info->default_value; pref_hash_info->callback_list = NULL; return pref_hash_info; @@ -185,20 +184,20 @@ pref_hash_info_free (PrefHashInfo *pref_hash_info) { g_assert (pref_hash_info != NULL); - g_assert (pref_hash_info->pref_info.pref_name != NULL); - g_assert (pref_hash_info->pref_info.pref_description != NULL); + g_assert (pref_hash_info->pref_info.name != NULL); + g_assert (pref_hash_info->pref_info.description != NULL); g_list_foreach (pref_hash_info->callback_list, pref_callback_info_free_func, NULL); - g_free (pref_hash_info->pref_info.pref_name); - g_free (pref_hash_info->pref_info.pref_description); + g_free (pref_hash_info->pref_info.name); + g_free (pref_hash_info->pref_info.description); - pref_hash_info->pref_info.pref_name = NULL; - pref_hash_info->pref_info.pref_type = GTK_TYPE_INVALID; - pref_hash_info->pref_info.pref_default_value = NULL; - pref_hash_info->pref_info.type_data = NULL; + pref_hash_info->pref_info.name = NULL; + pref_hash_info->pref_info.type = GTK_TYPE_INVALID; + pref_hash_info->pref_info.default_value = NULL; + pref_hash_info->pref_info.data = NULL; pref_hash_info->callback_list = NULL; pref_hash_info->pref_value = NULL; @@ -324,7 +323,7 @@ static void pref_callback_info_invoke_func (gpointer data, gpointer user_data) { - const NautilusPreferences *prefs; + NautilusPreferences *prefs; PrefCallbackInfo *pref_callback_info; pref_callback_info = (PrefCallbackInfo *) data; @@ -333,11 +332,11 @@ pref_callback_info_invoke_func (gpointer data, g_assert (pref_callback_info->callback_proc != NULL); - prefs = (const NautilusPreferences *) user_data; + prefs = (NautilusPreferences *) user_data; - (* pref_callback_info->callback_proc) (GTK_OBJECT (prefs), - pref_callback_info->hash_info->pref_info.pref_name, - pref_callback_info->hash_info->pref_info.pref_type, + (* pref_callback_info->callback_proc) (prefs, + pref_callback_info->hash_info->pref_info.name, + pref_callback_info->hash_info->pref_info.type, pref_callback_info->hash_info->pref_value, pref_callback_info->user_data); } @@ -345,47 +344,47 @@ pref_callback_info_invoke_func (gpointer data, /* * Private stuff */ -static NautilusPreferencesType -prefs_check_supported_type (NautilusPreferencesType pref_type) +static gboolean +prefs_check_supported_type (NautilusPreferencesType type) { - return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) || - (pref_type == NAUTILUS_PREFERENCE_ENUM) || - (pref_type == NAUTILUS_PREFERENCE_STRING)); + return type == NAUTILUS_PREFERENCE_BOOLEAN + || type == NAUTILUS_PREFERENCE_ENUM + || type == NAUTILUS_PREFERENCE_STRING; } -static gboolean -prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value) +static void +prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer pref_value) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_assert (NAUTILUS_IS_PREFERENCES (prefs)); + g_assert (name != NULL); + pref_hash_info = prefs_hash_lookup (prefs, name); if (!pref_hash_info) { - return FALSE; + g_warning ("tried to set an unregistered preference '%s'", name); + return; } /* gnome-config for now ; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: - pref_hash_info->pref_value = pref_value; - gnome_config_set_bool (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_bool (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_ENUM: - pref_hash_info->pref_value = pref_value; - gnome_config_set_int (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_int (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_STRING: pref_hash_info->pref_value = g_strdup (pref_value); - gnome_config_set_string (pref_name, pref_hash_info->pref_value); + gnome_config_set_string (name, pref_hash_info->pref_value); + break; } /* Sync all the damn time. Yes it sucks. it will be better with gconf */ @@ -396,31 +395,28 @@ prefs_set_pref (NautilusPreferences *prefs, pref_callback_info_invoke_func, (gpointer) prefs); } - - return TRUE; } static gboolean -prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out) +prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *value_out) { - PrefHashInfo * pref_hash_info; - - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_type_out != NULL, FALSE); - g_return_val_if_fail (pref_value_out != NULL, FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + PrefHashInfo *pref_hash_info; - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (type_out != NULL, FALSE); + g_return_val_if_fail (value_out != NULL, FALSE); + pref_hash_info = prefs_hash_lookup (prefs, name); if (pref_hash_info == NULL) { return FALSE; } - *pref_type_out = pref_hash_info->pref_info.pref_type; - *pref_value_out = pref_hash_info->pref_value; + *type_out = pref_hash_info->pref_info.type; + *value_out = pref_hash_info->pref_value; return TRUE; } @@ -441,31 +437,30 @@ nautilus_preferences_new (const char *domain) } void -nautilus_preferences_register_from_info (NautilusPreferences *prefs, +nautilus_preferences_register_from_info (NautilusPreferences *prefs, const NautilusPreferencesInfo *pref_info) { - char *gnome_config_string = NULL; + char *gnome_config_string; PrefHashInfo *pref_hash_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); g_return_if_fail (pref_info != NULL); - g_return_if_fail (pref_info->pref_name != NULL); - g_return_if_fail (prefs_check_supported_type (pref_info->pref_type)); + g_return_if_fail (pref_info->name != NULL); + g_return_if_fail (prefs_check_supported_type (pref_info->type)); - pref_hash_info = prefs_hash_lookup (prefs, pref_info->pref_name); + pref_hash_info = prefs_hash_lookup (prefs, pref_info->name); if (pref_hash_info) { - g_warning ("the '%s' preference is already registered.\n", pref_info->pref_name); + g_warning ("the '%s' preference is already registered", pref_info->name); return; } pref_hash_info = pref_hash_info_alloc (pref_info); g_hash_table_insert (prefs->details->prefs_hash_table, - (gpointer) pref_info->pref_name, + (gpointer) pref_info->name, (gpointer) pref_hash_info); gnome_config_string = make_gnome_config_string (pref_info); @@ -473,7 +468,7 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs, g_assert (gnome_config_string != NULL); /* gnome-config for now; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: pref_hash_info->pref_value = GINT_TO_POINTER (gnome_config_get_bool (gnome_config_string)); @@ -502,14 +497,14 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - tmp = g_string_new (pref_info->pref_name); + tmp = g_string_new (pref_info->name); g_string_append (tmp, "="); - switch (pref_info->pref_type) { + switch (pref_info->type) { case NAUTILUS_PREFERENCE_BOOLEAN: - if (GPOINTER_TO_INT (pref_info->pref_default_value)) { + if (GPOINTER_TO_INT (pref_info->default_value)) { g_string_append (tmp, "true"); } else { g_string_append (tmp, "false"); @@ -517,11 +512,11 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) break; case NAUTILUS_PREFERENCE_ENUM: - g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->pref_default_value)); + g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->default_value)); break; case NAUTILUS_PREFERENCE_STRING: - g_string_append (tmp, pref_info->pref_default_value); + g_string_append (tmp, pref_info->default_value); break; } @@ -536,42 +531,40 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) } void -nautilus_preferences_register_from_values (NautilusPreferences *prefs, - char *pref_name, - char *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data) +nautilus_preferences_register_from_values (NautilusPreferences *prefs, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data) { NautilusPreferencesInfo pref_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); - g_return_if_fail (pref_name != NULL); - g_return_if_fail (pref_description != NULL); - g_return_if_fail (prefs_check_supported_type (pref_type)); + g_return_if_fail (name != NULL); + g_return_if_fail (description != NULL); + g_return_if_fail (prefs_check_supported_type (type)); - pref_info.pref_name = pref_name; - pref_info.pref_description = pref_description; - pref_info.pref_type = pref_type; - pref_info.pref_default_value = pref_default_value; - pref_info.type_data = type_data; + pref_info.name = name; + pref_info.description = description; + pref_info.type = type; + pref_info.default_value = default_value; + pref_info.data = data; nautilus_preferences_register_from_info (prefs, &pref_info); } const NautilusPreferencesInfo * nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), NULL); - g_return_val_if_fail (pref_name != NULL, NULL); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), NULL); + g_return_val_if_fail (name != NULL, NULL); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + pref_hash_info = prefs_hash_lookup (prefs, name); g_assert (pref_hash_info != NULL); @@ -580,36 +573,34 @@ nautilus_preferences_get_pref_info (NautilusPreferences *prefs, PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gpointer hash_value; g_assert (prefs != NULL); - g_assert (pref_name != NULL); + g_assert (name != NULL); hash_value = g_hash_table_lookup (prefs->details->prefs_hash_table, - (gconstpointer) pref_name); + (gconstpointer) name); return (PrefHashInfo *) hash_value; } gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to add a callback to an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to add a callback for an unregistered preference"); return FALSE; } @@ -622,21 +613,19 @@ nautilus_preferences_add_callback (NautilusPreferences *prefs, gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to remove a callback from an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to remove a callback for an unregistered preference"); return FALSE; } @@ -649,121 +638,100 @@ nautilus_preferences_remove_callback (NautilusPreferences *prefs, void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const char *pref_name, + const char *name, gboolean boolean_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (boolean_value)); - - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (boolean_value)); } gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get boolean preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered boolean preference '%s'", name); return FALSE; } - g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN); + g_assert (type == NAUTILUS_PREFERENCE_BOOLEAN); return GPOINTER_TO_INT (value); } void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const char *pref_name, + const char *name, int enum_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); - - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (enum_value)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (enum_value)); } int nautilus_preferences_get_enum (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); - + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get enum preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered enum preference '%s'", name); return 0; } - g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM); + g_assert (type == NAUTILUS_PREFERENCE_ENUM); return GPOINTER_TO_INT (value); } void -nautilus_preferences_set_string (NautilusPreferences *prefs, - const char *pref_name, - const char *string_value) +nautilus_preferences_set_string (NautilusPreferences *prefs, + const char *name, + const char *value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); + g_return_if_fail (value != NULL); - /* Must cast away const on good faith that prefs_set_pref will make copy */ - rv = prefs_set_pref (prefs, pref_name, (char *)string_value); - - g_assert (rv); + prefs_set_pref (prefs, name, value); } char * -nautilus_preferences_get_string (NautilusPreferences *prefs, - const char *pref_name) +nautilus_preferences_get_string (NautilusPreferences *prefs, + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get string preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered string preference '%s'", name); return NULL; } - g_assert (pref_type == NAUTILUS_PREFERENCE_STRING); + g_assert (type == NAUTILUS_PREFERENCE_STRING); return g_strdup (value); } @@ -777,5 +745,5 @@ nautilus_preferences_get_global_preferences (void) global_preferences = nautilus_preferences_new (PREFERENCES_GLOBAL_DOMAIN); } - return NAUTILUS_PREFS (global_preferences); + return NAUTILUS_PREFERENCES (global_preferences); } diff --git a/libnautilus-extensions/nautilus-preferences.h b/libnautilus-extensions/nautilus-preferences.h index 2a57924ef..779db6e95 100644 --- a/libnautilus-extensions/nautilus-preferences.h +++ b/libnautilus-extensions/nautilus-preferences.h @@ -25,28 +25,25 @@ #ifndef NAUTILUS_PREFERENCES_H #define NAUTILUS_PREFERENCES_H -#include <gtk/gtkhbox.h> -#include <nautilus-widgets/nautilus-preferences-pane.h> +#include <gtk/gtkobject.h> +#include <libgnome/gnome-defs.h> BEGIN_GNOME_DECLS -#define NAUTILUS_TYPE_PREFS (nautilus_preferences_get_type ()) -#define NAUTILUS_PREFS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFS, NautilusPreferences)) -#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFS, NautilusPreferencesClass)) -#define NAUTILUS_IS_PREFS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFS)) -#define NAUTILUS_IS_PREFS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFS)) +#define NAUTILUS_TYPE_PREFERENCES (nautilus_preferences_get_type ()) +#define NAUTILUS_PREFERENCES(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFERENCES, NautilusPreferences)) +#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFERENCES, NautilusPreferencesClass)) +#define NAUTILUS_IS_PREFERENCES(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCES)) +#define NAUTILUS_IS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCES)) -typedef struct _NautilusPreferences NautilusPreferences; -typedef struct _NautilusPreferencesClass NautilusPreferencesClass; -typedef struct _NautilusPreferencesDetails NautilusPreferencesDetails; +typedef struct NautilusPreferences NautilusPreferences; +typedef struct NautilusPreferencesClass NautilusPreferencesClass; +typedef struct NautilusPreferencesDetails NautilusPreferencesDetails; -struct _NautilusPreferences +struct NautilusPreferences { - /* Super Class */ - GtkObject object; - - /* Private stuff */ - NautilusPreferencesDetails *details; + GtkObject object; + NautilusPreferencesDetails *details; }; /* @@ -63,74 +60,71 @@ typedef enum * A callback which you can register to to be notified when a particular * preference changes. */ -typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs, - const gchar *pref_name, - NautilusPreferencesType pref_type, - gconstpointer pref_value, - gpointer user_data); +typedef void (*NautilusPreferencesCallback) (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); -struct _NautilusPreferencesClass +struct NautilusPreferencesClass { - GtkObjectClass object_class; + GtkObjectClass object_class; }; typedef struct { - gchar *pref_name; - gchar *pref_description; - NautilusPreferencesType pref_type; - gconstpointer pref_default_value; - gpointer type_data; + char *name; + char *description; + NautilusPreferencesType type; + gconstpointer default_value; + gpointer data; } NautilusPreferencesInfo; typedef struct { - const gchar **enum_names; - const gchar **enum_descriptions; - const gint *enum_values; - guint num_entries; + const char **enum_names; + const char **enum_descriptions; + const int *enum_values; + guint num_entries; } NautilusPreferencesEnumData; GtkType nautilus_preferences_get_type (void); -GtkObject* nautilus_preferences_new (const gchar *domain); -void nautilus_preferences_register_from_info (NautilusPreferences *prefs, +GtkObject * nautilus_preferences_new (const char *domain); +void nautilus_preferences_register_from_info (NautilusPreferences *preferences, const NautilusPreferencesInfo *pref_info); -void nautilus_preferences_register_from_values (NautilusPreferences *prefs, - gchar *pref_name, - gchar *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data); -const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const gchar *pref_name); -gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const gchar *pref_name, +void nautilus_preferences_register_from_values (NautilusPreferences *preferences, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data); +const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences, + const char *name); +gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const gchar *pref_name, +gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const gchar *pref_name, - gboolean boolean_value); -gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const gchar *pref_name, - gint enum_value); -gint nautilus_preferences_get_enum (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_string (NautilusPreferences *prefs, - const gchar *pref_name, - const char *string_value); -char * nautilus_preferences_get_string (NautilusPreferences *prefs, - const gchar *pref_name); +void nautilus_preferences_set_boolean (NautilusPreferences *preferences, + const char *name, + gboolean value); +gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_enum (NautilusPreferences *preferences, + const char *name, + int value); +int nautilus_preferences_get_enum (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_string (NautilusPreferences *preferences, + const char *name, + const char *value); +char * nautilus_preferences_get_string (NautilusPreferences *preferences, + const char *name); NautilusPreferences * nautilus_preferences_get_global_preferences (void); - BEGIN_GNOME_DECLS #endif /* NAUTILUS_PREFERENCES_H */ - - diff --git a/libnautilus-extensions/test-nautilus-widgets.c b/libnautilus-extensions/test-nautilus-widgets.c index 5dbe8de8b..d09acd1e5 100644 --- a/libnautilus-extensions/test-nautilus-widgets.c +++ b/libnautilus-extensions/test-nautilus-widgets.c @@ -212,16 +212,15 @@ create_dummy_prefs (void) dummy_prefs = nautilus_preferences_new ("dummy"); /* Register the static prefs */ - for (i = 0; i < 3; i++) - { - nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs), - &prefs_global_static_pref_info[i]); + for (i = 0; i < 3; i++) { + nautilus_preferences_register_from_info (NAUTILUS_PREFERENCES (dummy_prefs), + &prefs_global_static_pref_info[i]); } - nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs), - "user_level", - 2); + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (dummy_prefs), + "user_level", + 2); return dummy_prefs; } diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 864c52219..3d87d4b2d 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -28,7 +28,6 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ bonobo-stream-vfs.h \ - gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ @@ -41,6 +40,7 @@ libnautilusinclude_HEADERS= \ nautilus-directory.h \ nautilus-file-utilities.h \ nautilus-file.h \ + nautilus-gdk-extensions.h \ nautilus-glib-extensions.h \ nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ @@ -62,7 +62,6 @@ libnautilusinclude_HEADERS= \ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ - gdk-extensions.c \ gnome-icon-container.c \ gnome-icon-container-dnd.c \ gnome-icon-container-grid.c \ @@ -78,6 +77,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ nautilus-directory.c \ nautilus-file-utilities.c \ nautilus-file.c \ + nautilus-gdk-extensions.c \ nautilus-glib-extensions.c \ nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ diff --git a/libnautilus-private/gnome-icon-container.c b/libnautilus-private/gnome-icon-container.c index f81f62fa8..bb69377e1 100644 --- a/libnautilus-private/gnome-icon-container.c +++ b/libnautilus-private/gnome-icon-container.c @@ -34,8 +34,8 @@ #include <libgnomeui/gnome-canvas-rect-ellipse.h> #include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "gdk-extensions.h" #include "nautilus-glib-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus-private/nautilus-background.c b/libnautilus-private/nautilus-background.c index 8491ba340..faaccb958 100644 --- a/libnautilus-private/nautilus-background.c +++ b/libnautilus-private/nautilus-background.c @@ -26,7 +26,7 @@ #include "nautilus-background.h" #include <gtk/gtksignal.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-background-canvas-group.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-gtk-macros.h" diff --git a/libnautilus/gdk-extensions.c b/libnautilus-private/nautilus-gdk-extensions.c index a080d4fba..79a74d60a 100644 --- a/libnautilus/gdk-extensions.c +++ b/libnautilus-private/nautilus-gdk-extensions.c @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.c: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.c: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -23,7 +23,7 @@ */ #include <config.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus-extensions/gdk-extensions.h b/libnautilus-private/nautilus-gdk-extensions.h index 01d2770ab..594f740fd 100644 --- a/libnautilus-extensions/gdk-extensions.h +++ b/libnautilus-private/nautilus-gdk-extensions.h @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.h: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.h: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -22,10 +22,10 @@ Authors: Darin Adler <darin@eazel.com> */ -#ifndef GDK_EXTENSIONS_H -#define GDK_EXTENSIONS_H +#ifndef NAUTILUS_GDK_EXTENSIONS_H +#define NAUTILUS_GDK_EXTENSIONS_H -#include <gdk/gdk.h> +#include <gdk/gdktypes.h> /* A gradient spec. is a string that contains a specifier for either a color or a gradient. If the string has a "-" in it, then it's a gradient. @@ -89,4 +89,4 @@ void nautilus_gdk_pixbuf_list_ref (GList *pixbuf void nautilus_gdk_pixbuf_list_unref (GList *pixbuf_list); void nautilus_gdk_pixbuf_list_free (GList *pixbuf_list); -#endif /* GDK_EXTENSIONS_H */ +#endif /* NAUTILUS_GDK_EXTENSIONS_H */ diff --git a/libnautilus-private/nautilus-icon-factory.c b/libnautilus-private/nautilus-icon-factory.c index 3115e99d7..913063076 100644 --- a/libnautilus-private/nautilus-icon-factory.c +++ b/libnautilus-private/nautilus-icon-factory.c @@ -139,7 +139,6 @@ typedef struct { /* id of timeout task for making thumbnails */ int timeout_task_id; - } NautilusIconFactory; typedef struct { @@ -180,18 +179,18 @@ typedef struct { /* forward declarations */ -static void icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data); +static void icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); static GtkType nautilus_icon_factory_get_type (void); static void nautilus_icon_factory_initialize_class (NautilusIconFactoryClass *class); static void nautilus_icon_factory_initialize (NautilusIconFactory *factory); static NautilusIconFactory * nautilus_get_current_icon_factory (void); static char * nautilus_icon_factory_get_thumbnail_uri (NautilusFile *file); static NautilusIconFactory * nautilus_icon_factory_new (const char *theme_name); -void nautilus_icon_factory_set_theme (const char *theme_name); +static void nautilus_icon_factory_set_theme (const char *theme_name); static NautilusScalableIcon *nautilus_scalable_icon_get (const char *uri, const char *name); static guint nautilus_scalable_icon_hash (gconstpointer p); @@ -235,7 +234,7 @@ nautilus_get_current_icon_factory (void) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) global_icon_factory); + NULL); } return global_icon_factory; @@ -326,7 +325,7 @@ nautilus_icon_factory_destroy (NautilusIconFactory *factory) nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) factory); + NULL); nautilus_icon_factory_clear (); g_hash_table_destroy (factory->icon_cache); @@ -584,21 +583,19 @@ get_icon_file_path (const char *name, guint size_in_pixels, ArtIRect *text_rect) } static void -icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + GtkFundamentalType type, + gconstpointer value, gpointer user_data) { - NautilusIconFactory *icon_factory; - - g_assert (user_data != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); - - icon_factory = (NautilusIconFactory *)user_data; + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_ICON_THEME) == 0); + g_assert (type == NAUTILUS_PREFERENCE_STRING); + g_assert (value != NULL); + g_assert (user_data == NULL); - nautilus_icon_factory_set_theme ((char *)pref_value); + nautilus_icon_factory_set_theme ((char *) value); } /* Get or create a scalable icon. */ diff --git a/libnautilus-private/nautilus-icons-view-icon-item.c b/libnautilus-private/nautilus-icons-view-icon-item.c index 851a5668f..b56c4a41c 100644 --- a/libnautilus-private/nautilus-icons-view-icon-item.c +++ b/libnautilus-private/nautilus-icons-view-icon-item.c @@ -35,7 +35,7 @@ #include "gnome-icon-container-private.h" #include "nautilus-string.h" #include "nautilus-glib-extensions.h" -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-gnome-extensions.h" diff --git a/libnautilus-private/nautilus-preferences-item.c b/libnautilus-private/nautilus-preferences-item.c index dc382f788..6d58cfc0d 100644 --- a/libnautilus-private/nautilus-preferences-item.c +++ b/libnautilus-private/nautilus-preferences-item.c @@ -246,7 +246,7 @@ preferences_item_construct (NautilusPreferencesItem *item, item->details->prefs = prefs; item->details->pref_name = g_strdup (pref_name); - pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFS (item->details->prefs), + pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); g_assert (pref_info != NULL); @@ -297,11 +297,11 @@ preferences_item_create_enum (NautilusPreferencesItem *item, item->details->child = nautilus_radio_button_group_new (); - enum_info = (NautilusPreferencesEnumData *) pref_info->type_data; + enum_info = (NautilusPreferencesEnumData *) pref_info->data; g_assert (enum_info != NULL); - value = nautilus_preferences_get_enum (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); for (i = 0; i < enum_info->num_entries; i++) @@ -334,11 +334,11 @@ preferences_item_create_boolean (NautilusPreferencesItem *item, g_assert (item->details->prefs != NULL); g_assert (item->details->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->description != NULL); - item->details->child = gtk_check_button_new_with_label (pref_info->pref_description); + item->details->child = gtk_check_button_new_with_label (pref_info->description); - value = nautilus_preferences_get_boolean (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->details->child), value); @@ -381,7 +381,7 @@ enum_radio_group_changed_cb (GtkWidget *buttons, GtkWidget * button, gpointer us i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons)); - nautilus_preferences_set_enum (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, i); } @@ -396,7 +396,7 @@ boolean_button_toggled_cb (GtkWidget *button, gpointer user_data) active_state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - nautilus_preferences_set_boolean (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, active_state); } diff --git a/libnautilus-private/nautilus-preferences.c b/libnautilus-private/nautilus-preferences.c index 48da6c7dd..47fba7515 100644 --- a/libnautilus-private/nautilus-preferences.c +++ b/libnautilus-private/nautilus-preferences.c @@ -1,4 +1,4 @@ - /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* nautilus-prefs.h - Preference peek/poke/notify object implementation. @@ -22,11 +22,13 @@ Authors: Ramiro Estrugo <ramiro@eazel.com> */ +#include <config.h> +#include "nautilus-preferences.h" -#include <nautilus-widgets/nautilus-preferences.h> +#include <libgnome/gnome-config.h> #include <libnautilus/nautilus-gtk-macros.h> -static const char * PREFERENCES_GLOBAL_DOMAIN = "Nautilus::Global"; +static const char PREFERENCES_GLOBAL_DOMAIN[] = "Nautilus::Global"; enum { ACTIVATE, @@ -45,53 +47,53 @@ typedef struct { const PrefHashInfo *hash_info; } PrefCallbackInfo; -struct _NautilusPreferencesDetails { +struct NautilusPreferencesDetails { char *domain; GHashTable *prefs_hash_table; }; /* NautilusPreferencesClass methods */ -static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); -static void nautilus_preferences_initialize (NautilusPreferences *prefs); +static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); +static void nautilus_preferences_initialize (NautilusPreferences *prefs); /* GtkObjectClass methods */ -static void prefs_destroy (GtkObject *object); +static void prefs_destroy (GtkObject *object); /* PrefHashInfo functions */ -static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); -static void pref_hash_info_free (PrefHashInfo *pref_hash_info); -static void pref_hash_info_free_func (gpointer key, - gpointer value, - gpointer user_data); +static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); +static void pref_hash_info_free (PrefHashInfo *pref_hash_info); +static void pref_hash_info_free_func (gpointer key, + gpointer value, + gpointer user_data); /* PrefCallbackInfo functions */ -static PrefCallbackInfo * pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, - gpointer user_data, - const PrefHashInfo *hash_info); -static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); -static void pref_callback_info_free_func (gpointer data, - gpointer user_data); -static void pref_callback_info_invoke_func (gpointer data, - gpointer user_data); -static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); -static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); +static PrefCallbackInfo *pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, + gpointer user_data, + const PrefHashInfo *hash_info); +static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); +static void pref_callback_info_free_func (gpointer data, + gpointer user_data); +static void pref_callback_info_invoke_func (gpointer data, + gpointer user_data); +static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); +static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); /* Private stuff */ -static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type); -static gboolean prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value); -static gboolean prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out); -PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name); -static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); +static gboolean prefs_check_supported_type (NautilusPreferencesType type); +static void prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer value); +static gboolean prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *pref_value_out); +PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, + const char *name); +static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferences, nautilus_preferences, GTK_TYPE_OBJECT) @@ -130,17 +132,14 @@ prefs_destroy (GtkObject *object) { NautilusPreferences * prefs; - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (object)); - - prefs = NAUTILUS_PREFS (object); + prefs = NAUTILUS_PREFERENCES (object); g_free (prefs->details->domain); if (prefs->details->prefs_hash_table != NULL) { g_hash_table_foreach (prefs->details->prefs_hash_table, pref_hash_info_free_func, - (gpointer) NULL); + NULL); g_hash_table_destroy (prefs->details->prefs_hash_table); @@ -163,18 +162,18 @@ pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - g_assert (pref_info->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->name != NULL); + g_assert (pref_info->description != NULL); pref_hash_info = g_new (PrefHashInfo, 1); - pref_hash_info->pref_info.pref_name = g_strdup (pref_info->pref_name); - pref_hash_info->pref_info.pref_description = g_strdup (pref_info->pref_description); - pref_hash_info->pref_info.pref_type = pref_info->pref_type; - pref_hash_info->pref_info.pref_default_value = pref_info->pref_default_value; - pref_hash_info->pref_info.type_data = pref_info->type_data; + pref_hash_info->pref_info.name = g_strdup (pref_info->name); + pref_hash_info->pref_info.description = g_strdup (pref_info->description); + pref_hash_info->pref_info.type = pref_info->type; + pref_hash_info->pref_info.default_value = pref_info->default_value; + pref_hash_info->pref_info.data = pref_info->data; - pref_hash_info->pref_value = (gpointer) pref_info->pref_default_value; + pref_hash_info->pref_value = (gpointer) pref_info->default_value; pref_hash_info->callback_list = NULL; return pref_hash_info; @@ -185,20 +184,20 @@ pref_hash_info_free (PrefHashInfo *pref_hash_info) { g_assert (pref_hash_info != NULL); - g_assert (pref_hash_info->pref_info.pref_name != NULL); - g_assert (pref_hash_info->pref_info.pref_description != NULL); + g_assert (pref_hash_info->pref_info.name != NULL); + g_assert (pref_hash_info->pref_info.description != NULL); g_list_foreach (pref_hash_info->callback_list, pref_callback_info_free_func, NULL); - g_free (pref_hash_info->pref_info.pref_name); - g_free (pref_hash_info->pref_info.pref_description); + g_free (pref_hash_info->pref_info.name); + g_free (pref_hash_info->pref_info.description); - pref_hash_info->pref_info.pref_name = NULL; - pref_hash_info->pref_info.pref_type = GTK_TYPE_INVALID; - pref_hash_info->pref_info.pref_default_value = NULL; - pref_hash_info->pref_info.type_data = NULL; + pref_hash_info->pref_info.name = NULL; + pref_hash_info->pref_info.type = GTK_TYPE_INVALID; + pref_hash_info->pref_info.default_value = NULL; + pref_hash_info->pref_info.data = NULL; pref_hash_info->callback_list = NULL; pref_hash_info->pref_value = NULL; @@ -324,7 +323,7 @@ static void pref_callback_info_invoke_func (gpointer data, gpointer user_data) { - const NautilusPreferences *prefs; + NautilusPreferences *prefs; PrefCallbackInfo *pref_callback_info; pref_callback_info = (PrefCallbackInfo *) data; @@ -333,11 +332,11 @@ pref_callback_info_invoke_func (gpointer data, g_assert (pref_callback_info->callback_proc != NULL); - prefs = (const NautilusPreferences *) user_data; + prefs = (NautilusPreferences *) user_data; - (* pref_callback_info->callback_proc) (GTK_OBJECT (prefs), - pref_callback_info->hash_info->pref_info.pref_name, - pref_callback_info->hash_info->pref_info.pref_type, + (* pref_callback_info->callback_proc) (prefs, + pref_callback_info->hash_info->pref_info.name, + pref_callback_info->hash_info->pref_info.type, pref_callback_info->hash_info->pref_value, pref_callback_info->user_data); } @@ -345,47 +344,47 @@ pref_callback_info_invoke_func (gpointer data, /* * Private stuff */ -static NautilusPreferencesType -prefs_check_supported_type (NautilusPreferencesType pref_type) +static gboolean +prefs_check_supported_type (NautilusPreferencesType type) { - return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) || - (pref_type == NAUTILUS_PREFERENCE_ENUM) || - (pref_type == NAUTILUS_PREFERENCE_STRING)); + return type == NAUTILUS_PREFERENCE_BOOLEAN + || type == NAUTILUS_PREFERENCE_ENUM + || type == NAUTILUS_PREFERENCE_STRING; } -static gboolean -prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value) +static void +prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer pref_value) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_assert (NAUTILUS_IS_PREFERENCES (prefs)); + g_assert (name != NULL); + pref_hash_info = prefs_hash_lookup (prefs, name); if (!pref_hash_info) { - return FALSE; + g_warning ("tried to set an unregistered preference '%s'", name); + return; } /* gnome-config for now ; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: - pref_hash_info->pref_value = pref_value; - gnome_config_set_bool (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_bool (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_ENUM: - pref_hash_info->pref_value = pref_value; - gnome_config_set_int (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_int (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_STRING: pref_hash_info->pref_value = g_strdup (pref_value); - gnome_config_set_string (pref_name, pref_hash_info->pref_value); + gnome_config_set_string (name, pref_hash_info->pref_value); + break; } /* Sync all the damn time. Yes it sucks. it will be better with gconf */ @@ -396,31 +395,28 @@ prefs_set_pref (NautilusPreferences *prefs, pref_callback_info_invoke_func, (gpointer) prefs); } - - return TRUE; } static gboolean -prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out) +prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *value_out) { - PrefHashInfo * pref_hash_info; - - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_type_out != NULL, FALSE); - g_return_val_if_fail (pref_value_out != NULL, FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + PrefHashInfo *pref_hash_info; - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (type_out != NULL, FALSE); + g_return_val_if_fail (value_out != NULL, FALSE); + pref_hash_info = prefs_hash_lookup (prefs, name); if (pref_hash_info == NULL) { return FALSE; } - *pref_type_out = pref_hash_info->pref_info.pref_type; - *pref_value_out = pref_hash_info->pref_value; + *type_out = pref_hash_info->pref_info.type; + *value_out = pref_hash_info->pref_value; return TRUE; } @@ -441,31 +437,30 @@ nautilus_preferences_new (const char *domain) } void -nautilus_preferences_register_from_info (NautilusPreferences *prefs, +nautilus_preferences_register_from_info (NautilusPreferences *prefs, const NautilusPreferencesInfo *pref_info) { - char *gnome_config_string = NULL; + char *gnome_config_string; PrefHashInfo *pref_hash_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); g_return_if_fail (pref_info != NULL); - g_return_if_fail (pref_info->pref_name != NULL); - g_return_if_fail (prefs_check_supported_type (pref_info->pref_type)); + g_return_if_fail (pref_info->name != NULL); + g_return_if_fail (prefs_check_supported_type (pref_info->type)); - pref_hash_info = prefs_hash_lookup (prefs, pref_info->pref_name); + pref_hash_info = prefs_hash_lookup (prefs, pref_info->name); if (pref_hash_info) { - g_warning ("the '%s' preference is already registered.\n", pref_info->pref_name); + g_warning ("the '%s' preference is already registered", pref_info->name); return; } pref_hash_info = pref_hash_info_alloc (pref_info); g_hash_table_insert (prefs->details->prefs_hash_table, - (gpointer) pref_info->pref_name, + (gpointer) pref_info->name, (gpointer) pref_hash_info); gnome_config_string = make_gnome_config_string (pref_info); @@ -473,7 +468,7 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs, g_assert (gnome_config_string != NULL); /* gnome-config for now; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: pref_hash_info->pref_value = GINT_TO_POINTER (gnome_config_get_bool (gnome_config_string)); @@ -502,14 +497,14 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - tmp = g_string_new (pref_info->pref_name); + tmp = g_string_new (pref_info->name); g_string_append (tmp, "="); - switch (pref_info->pref_type) { + switch (pref_info->type) { case NAUTILUS_PREFERENCE_BOOLEAN: - if (GPOINTER_TO_INT (pref_info->pref_default_value)) { + if (GPOINTER_TO_INT (pref_info->default_value)) { g_string_append (tmp, "true"); } else { g_string_append (tmp, "false"); @@ -517,11 +512,11 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) break; case NAUTILUS_PREFERENCE_ENUM: - g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->pref_default_value)); + g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->default_value)); break; case NAUTILUS_PREFERENCE_STRING: - g_string_append (tmp, pref_info->pref_default_value); + g_string_append (tmp, pref_info->default_value); break; } @@ -536,42 +531,40 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) } void -nautilus_preferences_register_from_values (NautilusPreferences *prefs, - char *pref_name, - char *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data) +nautilus_preferences_register_from_values (NautilusPreferences *prefs, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data) { NautilusPreferencesInfo pref_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); - g_return_if_fail (pref_name != NULL); - g_return_if_fail (pref_description != NULL); - g_return_if_fail (prefs_check_supported_type (pref_type)); + g_return_if_fail (name != NULL); + g_return_if_fail (description != NULL); + g_return_if_fail (prefs_check_supported_type (type)); - pref_info.pref_name = pref_name; - pref_info.pref_description = pref_description; - pref_info.pref_type = pref_type; - pref_info.pref_default_value = pref_default_value; - pref_info.type_data = type_data; + pref_info.name = name; + pref_info.description = description; + pref_info.type = type; + pref_info.default_value = default_value; + pref_info.data = data; nautilus_preferences_register_from_info (prefs, &pref_info); } const NautilusPreferencesInfo * nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), NULL); - g_return_val_if_fail (pref_name != NULL, NULL); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), NULL); + g_return_val_if_fail (name != NULL, NULL); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + pref_hash_info = prefs_hash_lookup (prefs, name); g_assert (pref_hash_info != NULL); @@ -580,36 +573,34 @@ nautilus_preferences_get_pref_info (NautilusPreferences *prefs, PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gpointer hash_value; g_assert (prefs != NULL); - g_assert (pref_name != NULL); + g_assert (name != NULL); hash_value = g_hash_table_lookup (prefs->details->prefs_hash_table, - (gconstpointer) pref_name); + (gconstpointer) name); return (PrefHashInfo *) hash_value; } gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to add a callback to an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to add a callback for an unregistered preference"); return FALSE; } @@ -622,21 +613,19 @@ nautilus_preferences_add_callback (NautilusPreferences *prefs, gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to remove a callback from an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to remove a callback for an unregistered preference"); return FALSE; } @@ -649,121 +638,100 @@ nautilus_preferences_remove_callback (NautilusPreferences *prefs, void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const char *pref_name, + const char *name, gboolean boolean_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (boolean_value)); - - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (boolean_value)); } gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get boolean preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered boolean preference '%s'", name); return FALSE; } - g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN); + g_assert (type == NAUTILUS_PREFERENCE_BOOLEAN); return GPOINTER_TO_INT (value); } void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const char *pref_name, + const char *name, int enum_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); - - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (enum_value)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (enum_value)); } int nautilus_preferences_get_enum (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); - + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get enum preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered enum preference '%s'", name); return 0; } - g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM); + g_assert (type == NAUTILUS_PREFERENCE_ENUM); return GPOINTER_TO_INT (value); } void -nautilus_preferences_set_string (NautilusPreferences *prefs, - const char *pref_name, - const char *string_value) +nautilus_preferences_set_string (NautilusPreferences *prefs, + const char *name, + const char *value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); + g_return_if_fail (value != NULL); - /* Must cast away const on good faith that prefs_set_pref will make copy */ - rv = prefs_set_pref (prefs, pref_name, (char *)string_value); - - g_assert (rv); + prefs_set_pref (prefs, name, value); } char * -nautilus_preferences_get_string (NautilusPreferences *prefs, - const char *pref_name) +nautilus_preferences_get_string (NautilusPreferences *prefs, + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get string preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered string preference '%s'", name); return NULL; } - g_assert (pref_type == NAUTILUS_PREFERENCE_STRING); + g_assert (type == NAUTILUS_PREFERENCE_STRING); return g_strdup (value); } @@ -777,5 +745,5 @@ nautilus_preferences_get_global_preferences (void) global_preferences = nautilus_preferences_new (PREFERENCES_GLOBAL_DOMAIN); } - return NAUTILUS_PREFS (global_preferences); + return NAUTILUS_PREFERENCES (global_preferences); } diff --git a/libnautilus-private/nautilus-preferences.h b/libnautilus-private/nautilus-preferences.h index 2a57924ef..779db6e95 100644 --- a/libnautilus-private/nautilus-preferences.h +++ b/libnautilus-private/nautilus-preferences.h @@ -25,28 +25,25 @@ #ifndef NAUTILUS_PREFERENCES_H #define NAUTILUS_PREFERENCES_H -#include <gtk/gtkhbox.h> -#include <nautilus-widgets/nautilus-preferences-pane.h> +#include <gtk/gtkobject.h> +#include <libgnome/gnome-defs.h> BEGIN_GNOME_DECLS -#define NAUTILUS_TYPE_PREFS (nautilus_preferences_get_type ()) -#define NAUTILUS_PREFS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFS, NautilusPreferences)) -#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFS, NautilusPreferencesClass)) -#define NAUTILUS_IS_PREFS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFS)) -#define NAUTILUS_IS_PREFS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFS)) +#define NAUTILUS_TYPE_PREFERENCES (nautilus_preferences_get_type ()) +#define NAUTILUS_PREFERENCES(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFERENCES, NautilusPreferences)) +#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFERENCES, NautilusPreferencesClass)) +#define NAUTILUS_IS_PREFERENCES(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCES)) +#define NAUTILUS_IS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCES)) -typedef struct _NautilusPreferences NautilusPreferences; -typedef struct _NautilusPreferencesClass NautilusPreferencesClass; -typedef struct _NautilusPreferencesDetails NautilusPreferencesDetails; +typedef struct NautilusPreferences NautilusPreferences; +typedef struct NautilusPreferencesClass NautilusPreferencesClass; +typedef struct NautilusPreferencesDetails NautilusPreferencesDetails; -struct _NautilusPreferences +struct NautilusPreferences { - /* Super Class */ - GtkObject object; - - /* Private stuff */ - NautilusPreferencesDetails *details; + GtkObject object; + NautilusPreferencesDetails *details; }; /* @@ -63,74 +60,71 @@ typedef enum * A callback which you can register to to be notified when a particular * preference changes. */ -typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs, - const gchar *pref_name, - NautilusPreferencesType pref_type, - gconstpointer pref_value, - gpointer user_data); +typedef void (*NautilusPreferencesCallback) (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); -struct _NautilusPreferencesClass +struct NautilusPreferencesClass { - GtkObjectClass object_class; + GtkObjectClass object_class; }; typedef struct { - gchar *pref_name; - gchar *pref_description; - NautilusPreferencesType pref_type; - gconstpointer pref_default_value; - gpointer type_data; + char *name; + char *description; + NautilusPreferencesType type; + gconstpointer default_value; + gpointer data; } NautilusPreferencesInfo; typedef struct { - const gchar **enum_names; - const gchar **enum_descriptions; - const gint *enum_values; - guint num_entries; + const char **enum_names; + const char **enum_descriptions; + const int *enum_values; + guint num_entries; } NautilusPreferencesEnumData; GtkType nautilus_preferences_get_type (void); -GtkObject* nautilus_preferences_new (const gchar *domain); -void nautilus_preferences_register_from_info (NautilusPreferences *prefs, +GtkObject * nautilus_preferences_new (const char *domain); +void nautilus_preferences_register_from_info (NautilusPreferences *preferences, const NautilusPreferencesInfo *pref_info); -void nautilus_preferences_register_from_values (NautilusPreferences *prefs, - gchar *pref_name, - gchar *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data); -const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const gchar *pref_name); -gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const gchar *pref_name, +void nautilus_preferences_register_from_values (NautilusPreferences *preferences, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data); +const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences, + const char *name); +gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const gchar *pref_name, +gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const gchar *pref_name, - gboolean boolean_value); -gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const gchar *pref_name, - gint enum_value); -gint nautilus_preferences_get_enum (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_string (NautilusPreferences *prefs, - const gchar *pref_name, - const char *string_value); -char * nautilus_preferences_get_string (NautilusPreferences *prefs, - const gchar *pref_name); +void nautilus_preferences_set_boolean (NautilusPreferences *preferences, + const char *name, + gboolean value); +gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_enum (NautilusPreferences *preferences, + const char *name, + int value); +int nautilus_preferences_get_enum (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_string (NautilusPreferences *preferences, + const char *name, + const char *value); +char * nautilus_preferences_get_string (NautilusPreferences *preferences, + const char *name); NautilusPreferences * nautilus_preferences_get_global_preferences (void); - BEGIN_GNOME_DECLS #endif /* NAUTILUS_PREFERENCES_H */ - - diff --git a/libnautilus-private/test-nautilus-widgets.c b/libnautilus-private/test-nautilus-widgets.c index 5dbe8de8b..d09acd1e5 100644 --- a/libnautilus-private/test-nautilus-widgets.c +++ b/libnautilus-private/test-nautilus-widgets.c @@ -212,16 +212,15 @@ create_dummy_prefs (void) dummy_prefs = nautilus_preferences_new ("dummy"); /* Register the static prefs */ - for (i = 0; i < 3; i++) - { - nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs), - &prefs_global_static_pref_info[i]); + for (i = 0; i < 3; i++) { + nautilus_preferences_register_from_info (NAUTILUS_PREFERENCES (dummy_prefs), + &prefs_global_static_pref_info[i]); } - nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs), - "user_level", - 2); + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (dummy_prefs), + "user_level", + 2); return dummy_prefs; } diff --git a/libnautilus/Makefile.am b/libnautilus/Makefile.am index 864c52219..3d87d4b2d 100644 --- a/libnautilus/Makefile.am +++ b/libnautilus/Makefile.am @@ -28,7 +28,6 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ bonobo-stream-vfs.h \ - gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ @@ -41,6 +40,7 @@ libnautilusinclude_HEADERS= \ nautilus-directory.h \ nautilus-file-utilities.h \ nautilus-file.h \ + nautilus-gdk-extensions.h \ nautilus-glib-extensions.h \ nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ @@ -62,7 +62,6 @@ libnautilusinclude_HEADERS= \ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ - gdk-extensions.c \ gnome-icon-container.c \ gnome-icon-container-dnd.c \ gnome-icon-container-grid.c \ @@ -78,6 +77,7 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ nautilus-directory.c \ nautilus-file-utilities.c \ nautilus-file.c \ + nautilus-gdk-extensions.c \ nautilus-glib-extensions.c \ nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ diff --git a/libnautilus/gnome-icon-container.c b/libnautilus/gnome-icon-container.c index f81f62fa8..bb69377e1 100644 --- a/libnautilus/gnome-icon-container.c +++ b/libnautilus/gnome-icon-container.c @@ -34,8 +34,8 @@ #include <libgnomeui/gnome-canvas-rect-ellipse.h> #include <gdk-pixbuf/gnome-canvas-pixbuf.h> -#include "gdk-extensions.h" #include "nautilus-glib-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus/nautilus-background.c b/libnautilus/nautilus-background.c index 8491ba340..faaccb958 100644 --- a/libnautilus/nautilus-background.c +++ b/libnautilus/nautilus-background.c @@ -26,7 +26,7 @@ #include "nautilus-background.h" #include <gtk/gtksignal.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-background-canvas-group.h" #include "nautilus-lib-self-check-functions.h" #include "nautilus-gtk-macros.h" diff --git a/libnautilus-private/gdk-extensions.c b/libnautilus/nautilus-gdk-extensions.c index a080d4fba..79a74d60a 100644 --- a/libnautilus-private/gdk-extensions.c +++ b/libnautilus/nautilus-gdk-extensions.c @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.c: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.c: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -23,7 +23,7 @@ */ #include <config.h> -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include "nautilus-lib-self-check-functions.h" diff --git a/libnautilus-private/gdk-extensions.h b/libnautilus/nautilus-gdk-extensions.h index 01d2770ab..594f740fd 100644 --- a/libnautilus-private/gdk-extensions.h +++ b/libnautilus/nautilus-gdk-extensions.h @@ -1,6 +1,6 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - gdk-extensions.h: Graphics routines to augment what's in gdk. +/* nautilus-gdk-extensions.h: Graphics routines to augment what's in gdk. Copyright (C) 1999, 2000 Eazel, Inc. @@ -22,10 +22,10 @@ Authors: Darin Adler <darin@eazel.com> */ -#ifndef GDK_EXTENSIONS_H -#define GDK_EXTENSIONS_H +#ifndef NAUTILUS_GDK_EXTENSIONS_H +#define NAUTILUS_GDK_EXTENSIONS_H -#include <gdk/gdk.h> +#include <gdk/gdktypes.h> /* A gradient spec. is a string that contains a specifier for either a color or a gradient. If the string has a "-" in it, then it's a gradient. @@ -89,4 +89,4 @@ void nautilus_gdk_pixbuf_list_ref (GList *pixbuf void nautilus_gdk_pixbuf_list_unref (GList *pixbuf_list); void nautilus_gdk_pixbuf_list_free (GList *pixbuf_list); -#endif /* GDK_EXTENSIONS_H */ +#endif /* NAUTILUS_GDK_EXTENSIONS_H */ diff --git a/libnautilus/nautilus-icon-factory.c b/libnautilus/nautilus-icon-factory.c index 3115e99d7..913063076 100644 --- a/libnautilus/nautilus-icon-factory.c +++ b/libnautilus/nautilus-icon-factory.c @@ -139,7 +139,6 @@ typedef struct { /* id of timeout task for making thumbnails */ int timeout_task_id; - } NautilusIconFactory; typedef struct { @@ -180,18 +179,18 @@ typedef struct { /* forward declarations */ -static void icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data); +static void icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); static GtkType nautilus_icon_factory_get_type (void); static void nautilus_icon_factory_initialize_class (NautilusIconFactoryClass *class); static void nautilus_icon_factory_initialize (NautilusIconFactory *factory); static NautilusIconFactory * nautilus_get_current_icon_factory (void); static char * nautilus_icon_factory_get_thumbnail_uri (NautilusFile *file); static NautilusIconFactory * nautilus_icon_factory_new (const char *theme_name); -void nautilus_icon_factory_set_theme (const char *theme_name); +static void nautilus_icon_factory_set_theme (const char *theme_name); static NautilusScalableIcon *nautilus_scalable_icon_get (const char *uri, const char *name); static guint nautilus_scalable_icon_hash (gconstpointer p); @@ -235,7 +234,7 @@ nautilus_get_current_icon_factory (void) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) global_icon_factory); + NULL); } return global_icon_factory; @@ -326,7 +325,7 @@ nautilus_icon_factory_destroy (NautilusIconFactory *factory) nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_THEME, icon_theme_changed_callback, - (gpointer) factory); + NULL); nautilus_icon_factory_clear (); g_hash_table_destroy (factory->icon_cache); @@ -584,21 +583,19 @@ get_icon_file_path (const char *name, guint size_in_pixels, ArtIRect *text_rect) } static void -icon_theme_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +icon_theme_changed_callback (NautilusPreferences *preferences, + const char *name, + GtkFundamentalType type, + gconstpointer value, gpointer user_data) { - NautilusIconFactory *icon_factory; - - g_assert (user_data != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); - - icon_factory = (NautilusIconFactory *)user_data; + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_ICON_THEME) == 0); + g_assert (type == NAUTILUS_PREFERENCE_STRING); + g_assert (value != NULL); + g_assert (user_data == NULL); - nautilus_icon_factory_set_theme ((char *)pref_value); + nautilus_icon_factory_set_theme ((char *) value); } /* Get or create a scalable icon. */ diff --git a/libnautilus/nautilus-icons-view-icon-item.c b/libnautilus/nautilus-icons-view-icon-item.c index 851a5668f..b56c4a41c 100644 --- a/libnautilus/nautilus-icons-view-icon-item.c +++ b/libnautilus/nautilus-icons-view-icon-item.c @@ -35,7 +35,7 @@ #include "gnome-icon-container-private.h" #include "nautilus-string.h" #include "nautilus-glib-extensions.h" -#include "gdk-extensions.h" +#include "nautilus-gdk-extensions.h" #include "nautilus-gtk-macros.h" #include "nautilus-gnome-extensions.h" diff --git a/nautilus-widgets/nautilus-preferences-item.c b/nautilus-widgets/nautilus-preferences-item.c index dc382f788..6d58cfc0d 100644 --- a/nautilus-widgets/nautilus-preferences-item.c +++ b/nautilus-widgets/nautilus-preferences-item.c @@ -246,7 +246,7 @@ preferences_item_construct (NautilusPreferencesItem *item, item->details->prefs = prefs; item->details->pref_name = g_strdup (pref_name); - pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFS (item->details->prefs), + pref_info = nautilus_preferences_get_pref_info (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); g_assert (pref_info != NULL); @@ -297,11 +297,11 @@ preferences_item_create_enum (NautilusPreferencesItem *item, item->details->child = nautilus_radio_button_group_new (); - enum_info = (NautilusPreferencesEnumData *) pref_info->type_data; + enum_info = (NautilusPreferencesEnumData *) pref_info->data; g_assert (enum_info != NULL); - value = nautilus_preferences_get_enum (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); for (i = 0; i < enum_info->num_entries; i++) @@ -334,11 +334,11 @@ preferences_item_create_boolean (NautilusPreferencesItem *item, g_assert (item->details->prefs != NULL); g_assert (item->details->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->description != NULL); - item->details->child = gtk_check_button_new_with_label (pref_info->pref_description); + item->details->child = gtk_check_button_new_with_label (pref_info->description); - value = nautilus_preferences_get_boolean (NAUTILUS_PREFS (item->details->prefs), + value = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (item->details->child), value); @@ -381,7 +381,7 @@ enum_radio_group_changed_cb (GtkWidget *buttons, GtkWidget * button, gpointer us i = nautilus_radio_button_group_get_active_index (NAUTILUS_RADIO_BUTTON_GROUP (buttons)); - nautilus_preferences_set_enum (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, i); } @@ -396,7 +396,7 @@ boolean_button_toggled_cb (GtkWidget *button, gpointer user_data) active_state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); - nautilus_preferences_set_boolean (NAUTILUS_PREFS (item->details->prefs), + nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES (item->details->prefs), item->details->pref_name, active_state); } diff --git a/nautilus-widgets/nautilus-preferences.c b/nautilus-widgets/nautilus-preferences.c index 48da6c7dd..47fba7515 100644 --- a/nautilus-widgets/nautilus-preferences.c +++ b/nautilus-widgets/nautilus-preferences.c @@ -1,4 +1,4 @@ - /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* nautilus-prefs.h - Preference peek/poke/notify object implementation. @@ -22,11 +22,13 @@ Authors: Ramiro Estrugo <ramiro@eazel.com> */ +#include <config.h> +#include "nautilus-preferences.h" -#include <nautilus-widgets/nautilus-preferences.h> +#include <libgnome/gnome-config.h> #include <libnautilus/nautilus-gtk-macros.h> -static const char * PREFERENCES_GLOBAL_DOMAIN = "Nautilus::Global"; +static const char PREFERENCES_GLOBAL_DOMAIN[] = "Nautilus::Global"; enum { ACTIVATE, @@ -45,53 +47,53 @@ typedef struct { const PrefHashInfo *hash_info; } PrefCallbackInfo; -struct _NautilusPreferencesDetails { +struct NautilusPreferencesDetails { char *domain; GHashTable *prefs_hash_table; }; /* NautilusPreferencesClass methods */ -static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); -static void nautilus_preferences_initialize (NautilusPreferences *prefs); +static void nautilus_preferences_initialize_class (NautilusPreferencesClass *klass); +static void nautilus_preferences_initialize (NautilusPreferences *prefs); /* GtkObjectClass methods */ -static void prefs_destroy (GtkObject *object); +static void prefs_destroy (GtkObject *object); /* PrefHashInfo functions */ -static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); -static void pref_hash_info_free (PrefHashInfo *pref_hash_info); -static void pref_hash_info_free_func (gpointer key, - gpointer value, - gpointer user_data); +static PrefHashInfo * pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info); +static void pref_hash_info_free (PrefHashInfo *pref_hash_info); +static void pref_hash_info_free_func (gpointer key, + gpointer value, + gpointer user_data); /* PrefCallbackInfo functions */ -static PrefCallbackInfo * pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, - gpointer user_data, - const PrefHashInfo *hash_info); -static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); -static void pref_callback_info_free_func (gpointer data, - gpointer user_data); -static void pref_callback_info_invoke_func (gpointer data, - gpointer user_data); -static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); -static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, - NautilusPreferencesCallback callback_proc, - gpointer user_data); +static PrefCallbackInfo *pref_callback_info_alloc (NautilusPreferencesCallback callback_proc, + gpointer user_data, + const PrefHashInfo *hash_info); +static void pref_callback_info_free (PrefCallbackInfo *pref_hash_info); +static void pref_callback_info_free_func (gpointer data, + gpointer user_data); +static void pref_callback_info_invoke_func (gpointer data, + gpointer user_data); +static void pref_hash_info_add_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); +static void pref_hash_info_remove_callback (PrefHashInfo *pref_hash_info, + NautilusPreferencesCallback callback_proc, + gpointer user_data); /* Private stuff */ -static NautilusPreferencesType prefs_check_supported_type (NautilusPreferencesType pref_type); -static gboolean prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value); -static gboolean prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out); -PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name); -static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); +static gboolean prefs_check_supported_type (NautilusPreferencesType type); +static void prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer value); +static gboolean prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *pref_value_out); +PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, + const char *name); +static char * make_gnome_config_string (const NautilusPreferencesInfo *pref_info); NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusPreferences, nautilus_preferences, GTK_TYPE_OBJECT) @@ -130,17 +132,14 @@ prefs_destroy (GtkObject *object) { NautilusPreferences * prefs; - g_return_if_fail (object != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (object)); - - prefs = NAUTILUS_PREFS (object); + prefs = NAUTILUS_PREFERENCES (object); g_free (prefs->details->domain); if (prefs->details->prefs_hash_table != NULL) { g_hash_table_foreach (prefs->details->prefs_hash_table, pref_hash_info_free_func, - (gpointer) NULL); + NULL); g_hash_table_destroy (prefs->details->prefs_hash_table); @@ -163,18 +162,18 @@ pref_hash_info_alloc (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - g_assert (pref_info->pref_name != NULL); - g_assert (pref_info->pref_description != NULL); + g_assert (pref_info->name != NULL); + g_assert (pref_info->description != NULL); pref_hash_info = g_new (PrefHashInfo, 1); - pref_hash_info->pref_info.pref_name = g_strdup (pref_info->pref_name); - pref_hash_info->pref_info.pref_description = g_strdup (pref_info->pref_description); - pref_hash_info->pref_info.pref_type = pref_info->pref_type; - pref_hash_info->pref_info.pref_default_value = pref_info->pref_default_value; - pref_hash_info->pref_info.type_data = pref_info->type_data; + pref_hash_info->pref_info.name = g_strdup (pref_info->name); + pref_hash_info->pref_info.description = g_strdup (pref_info->description); + pref_hash_info->pref_info.type = pref_info->type; + pref_hash_info->pref_info.default_value = pref_info->default_value; + pref_hash_info->pref_info.data = pref_info->data; - pref_hash_info->pref_value = (gpointer) pref_info->pref_default_value; + pref_hash_info->pref_value = (gpointer) pref_info->default_value; pref_hash_info->callback_list = NULL; return pref_hash_info; @@ -185,20 +184,20 @@ pref_hash_info_free (PrefHashInfo *pref_hash_info) { g_assert (pref_hash_info != NULL); - g_assert (pref_hash_info->pref_info.pref_name != NULL); - g_assert (pref_hash_info->pref_info.pref_description != NULL); + g_assert (pref_hash_info->pref_info.name != NULL); + g_assert (pref_hash_info->pref_info.description != NULL); g_list_foreach (pref_hash_info->callback_list, pref_callback_info_free_func, NULL); - g_free (pref_hash_info->pref_info.pref_name); - g_free (pref_hash_info->pref_info.pref_description); + g_free (pref_hash_info->pref_info.name); + g_free (pref_hash_info->pref_info.description); - pref_hash_info->pref_info.pref_name = NULL; - pref_hash_info->pref_info.pref_type = GTK_TYPE_INVALID; - pref_hash_info->pref_info.pref_default_value = NULL; - pref_hash_info->pref_info.type_data = NULL; + pref_hash_info->pref_info.name = NULL; + pref_hash_info->pref_info.type = GTK_TYPE_INVALID; + pref_hash_info->pref_info.default_value = NULL; + pref_hash_info->pref_info.data = NULL; pref_hash_info->callback_list = NULL; pref_hash_info->pref_value = NULL; @@ -324,7 +323,7 @@ static void pref_callback_info_invoke_func (gpointer data, gpointer user_data) { - const NautilusPreferences *prefs; + NautilusPreferences *prefs; PrefCallbackInfo *pref_callback_info; pref_callback_info = (PrefCallbackInfo *) data; @@ -333,11 +332,11 @@ pref_callback_info_invoke_func (gpointer data, g_assert (pref_callback_info->callback_proc != NULL); - prefs = (const NautilusPreferences *) user_data; + prefs = (NautilusPreferences *) user_data; - (* pref_callback_info->callback_proc) (GTK_OBJECT (prefs), - pref_callback_info->hash_info->pref_info.pref_name, - pref_callback_info->hash_info->pref_info.pref_type, + (* pref_callback_info->callback_proc) (prefs, + pref_callback_info->hash_info->pref_info.name, + pref_callback_info->hash_info->pref_info.type, pref_callback_info->hash_info->pref_value, pref_callback_info->user_data); } @@ -345,47 +344,47 @@ pref_callback_info_invoke_func (gpointer data, /* * Private stuff */ -static NautilusPreferencesType -prefs_check_supported_type (NautilusPreferencesType pref_type) +static gboolean +prefs_check_supported_type (NautilusPreferencesType type) { - return ((pref_type == NAUTILUS_PREFERENCE_BOOLEAN) || - (pref_type == NAUTILUS_PREFERENCE_ENUM) || - (pref_type == NAUTILUS_PREFERENCE_STRING)); + return type == NAUTILUS_PREFERENCE_BOOLEAN + || type == NAUTILUS_PREFERENCE_ENUM + || type == NAUTILUS_PREFERENCE_STRING; } -static gboolean -prefs_set_pref (NautilusPreferences *prefs, - const char *pref_name, - gpointer pref_value) +static void +prefs_set_pref (NautilusPreferences *prefs, + const char *name, + gconstpointer pref_value) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_assert (NAUTILUS_IS_PREFERENCES (prefs)); + g_assert (name != NULL); + pref_hash_info = prefs_hash_lookup (prefs, name); if (!pref_hash_info) { - return FALSE; + g_warning ("tried to set an unregistered preference '%s'", name); + return; } /* gnome-config for now ; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: - pref_hash_info->pref_value = pref_value; - gnome_config_set_bool (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_bool (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_ENUM: - pref_hash_info->pref_value = pref_value; - gnome_config_set_int (pref_name, GPOINTER_TO_INT (pref_hash_info->pref_value)); + pref_hash_info->pref_value = (gpointer) pref_value; + gnome_config_set_int (name, GPOINTER_TO_INT (pref_value)); break; case NAUTILUS_PREFERENCE_STRING: pref_hash_info->pref_value = g_strdup (pref_value); - gnome_config_set_string (pref_name, pref_hash_info->pref_value); + gnome_config_set_string (name, pref_hash_info->pref_value); + break; } /* Sync all the damn time. Yes it sucks. it will be better with gconf */ @@ -396,31 +395,28 @@ prefs_set_pref (NautilusPreferences *prefs, pref_callback_info_invoke_func, (gpointer) prefs); } - - return TRUE; } static gboolean -prefs_get_pref (NautilusPreferences *prefs, - const char *pref_name, - NautilusPreferencesType *pref_type_out, - gconstpointer *pref_value_out) +prefs_get_pref (NautilusPreferences *prefs, + const char *name, + NautilusPreferencesType *type_out, + gconstpointer *value_out) { - PrefHashInfo * pref_hash_info; - - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_type_out != NULL, FALSE); - g_return_val_if_fail (pref_value_out != NULL, FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + PrefHashInfo *pref_hash_info; - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + g_return_val_if_fail (type_out != NULL, FALSE); + g_return_val_if_fail (value_out != NULL, FALSE); + pref_hash_info = prefs_hash_lookup (prefs, name); if (pref_hash_info == NULL) { return FALSE; } - *pref_type_out = pref_hash_info->pref_info.pref_type; - *pref_value_out = pref_hash_info->pref_value; + *type_out = pref_hash_info->pref_info.type; + *value_out = pref_hash_info->pref_value; return TRUE; } @@ -441,31 +437,30 @@ nautilus_preferences_new (const char *domain) } void -nautilus_preferences_register_from_info (NautilusPreferences *prefs, +nautilus_preferences_register_from_info (NautilusPreferences *prefs, const NautilusPreferencesInfo *pref_info) { - char *gnome_config_string = NULL; + char *gnome_config_string; PrefHashInfo *pref_hash_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); g_return_if_fail (pref_info != NULL); - g_return_if_fail (pref_info->pref_name != NULL); - g_return_if_fail (prefs_check_supported_type (pref_info->pref_type)); + g_return_if_fail (pref_info->name != NULL); + g_return_if_fail (prefs_check_supported_type (pref_info->type)); - pref_hash_info = prefs_hash_lookup (prefs, pref_info->pref_name); + pref_hash_info = prefs_hash_lookup (prefs, pref_info->name); if (pref_hash_info) { - g_warning ("the '%s' preference is already registered.\n", pref_info->pref_name); + g_warning ("the '%s' preference is already registered", pref_info->name); return; } pref_hash_info = pref_hash_info_alloc (pref_info); g_hash_table_insert (prefs->details->prefs_hash_table, - (gpointer) pref_info->pref_name, + (gpointer) pref_info->name, (gpointer) pref_hash_info); gnome_config_string = make_gnome_config_string (pref_info); @@ -473,7 +468,7 @@ nautilus_preferences_register_from_info (NautilusPreferences *prefs, g_assert (gnome_config_string != NULL); /* gnome-config for now; in the future gconf */ - switch (pref_hash_info->pref_info.pref_type) { + switch (pref_hash_info->pref_info.type) { case NAUTILUS_PREFERENCE_BOOLEAN: pref_hash_info->pref_value = GINT_TO_POINTER (gnome_config_get_bool (gnome_config_string)); @@ -502,14 +497,14 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) g_assert (pref_info != NULL); - tmp = g_string_new (pref_info->pref_name); + tmp = g_string_new (pref_info->name); g_string_append (tmp, "="); - switch (pref_info->pref_type) { + switch (pref_info->type) { case NAUTILUS_PREFERENCE_BOOLEAN: - if (GPOINTER_TO_INT (pref_info->pref_default_value)) { + if (GPOINTER_TO_INT (pref_info->default_value)) { g_string_append (tmp, "true"); } else { g_string_append (tmp, "false"); @@ -517,11 +512,11 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) break; case NAUTILUS_PREFERENCE_ENUM: - g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->pref_default_value)); + g_string_sprintfa (tmp, "%d", GPOINTER_TO_INT (pref_info->default_value)); break; case NAUTILUS_PREFERENCE_STRING: - g_string_append (tmp, pref_info->pref_default_value); + g_string_append (tmp, pref_info->default_value); break; } @@ -536,42 +531,40 @@ make_gnome_config_string (const NautilusPreferencesInfo *pref_info) } void -nautilus_preferences_register_from_values (NautilusPreferences *prefs, - char *pref_name, - char *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data) +nautilus_preferences_register_from_values (NautilusPreferences *prefs, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data) { NautilusPreferencesInfo pref_info; - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); - g_return_if_fail (pref_name != NULL); - g_return_if_fail (pref_description != NULL); - g_return_if_fail (prefs_check_supported_type (pref_type)); + g_return_if_fail (name != NULL); + g_return_if_fail (description != NULL); + g_return_if_fail (prefs_check_supported_type (type)); - pref_info.pref_name = pref_name; - pref_info.pref_description = pref_description; - pref_info.pref_type = pref_type; - pref_info.pref_default_value = pref_default_value; - pref_info.type_data = type_data; + pref_info.name = name; + pref_info.description = description; + pref_info.type = type; + pref_info.default_value = default_value; + pref_info.data = data; nautilus_preferences_register_from_info (prefs, &pref_info); } const NautilusPreferencesInfo * nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { PrefHashInfo * pref_hash_info; - g_return_val_if_fail (prefs != NULL, NULL); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), NULL); - g_return_val_if_fail (pref_name != NULL, NULL); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), NULL); + g_return_val_if_fail (name != NULL, NULL); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); + pref_hash_info = prefs_hash_lookup (prefs, name); g_assert (pref_hash_info != NULL); @@ -580,36 +573,34 @@ nautilus_preferences_get_pref_info (NautilusPreferences *prefs, PrefHashInfo * prefs_hash_lookup (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gpointer hash_value; g_assert (prefs != NULL); - g_assert (pref_name != NULL); + g_assert (name != NULL); hash_value = g_hash_table_lookup (prefs->details->prefs_hash_table, - (gconstpointer) pref_name); + (gconstpointer) name); return (PrefHashInfo *) hash_value; } gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to add a callback to an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to add a callback for an unregistered preference"); return FALSE; } @@ -622,21 +613,19 @@ nautilus_preferences_add_callback (NautilusPreferences *prefs, gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const char *pref_name, + const char *name, NautilusPreferencesCallback callback_proc, gpointer user_data) { - PrefHashInfo * pref_hash_info; + PrefHashInfo *pref_hash_info; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); g_return_val_if_fail (callback_proc != NULL, FALSE); - pref_hash_info = prefs_hash_lookup (prefs, pref_name); - - if (!pref_hash_info) { - g_warning ("trying to remove a callback from an unregistered preference.\n"); + pref_hash_info = prefs_hash_lookup (prefs, name); + if (pref_hash_info == NULL) { + g_warning ("trying to remove a callback for an unregistered preference"); return FALSE; } @@ -649,121 +638,100 @@ nautilus_preferences_remove_callback (NautilusPreferences *prefs, void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const char *pref_name, + const char *name, gboolean boolean_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (boolean_value)); - - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (boolean_value)); } gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get boolean preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered boolean preference '%s'", name); return FALSE; } - g_assert (pref_type == NAUTILUS_PREFERENCE_BOOLEAN); + g_assert (type == NAUTILUS_PREFERENCE_BOOLEAN); return GPOINTER_TO_INT (value); } void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const char *pref_name, + const char *name, int enum_value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); - - rv = prefs_set_pref (prefs, pref_name, GINT_TO_POINTER (enum_value)); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); - g_assert (rv); + prefs_set_pref (prefs, name, GINT_TO_POINTER (enum_value)); } int nautilus_preferences_get_enum (NautilusPreferences *prefs, - const char *pref_name) + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); - + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get enum preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered enum preference '%s'", name); return 0; } - g_assert (pref_type == NAUTILUS_PREFERENCE_ENUM); + g_assert (type == NAUTILUS_PREFERENCE_ENUM); return GPOINTER_TO_INT (value); } void -nautilus_preferences_set_string (NautilusPreferences *prefs, - const char *pref_name, - const char *string_value) +nautilus_preferences_set_string (NautilusPreferences *prefs, + const char *name, + const char *value) { - gboolean rv; - - g_return_if_fail (prefs != NULL); - g_return_if_fail (NAUTILUS_IS_PREFS (prefs)); - g_return_if_fail (pref_name != NULL); + g_return_if_fail (NAUTILUS_IS_PREFERENCES (prefs)); + g_return_if_fail (name != NULL); + g_return_if_fail (value != NULL); - /* Must cast away const on good faith that prefs_set_pref will make copy */ - rv = prefs_set_pref (prefs, pref_name, (char *)string_value); - - g_assert (rv); + prefs_set_pref (prefs, name, value); } char * -nautilus_preferences_get_string (NautilusPreferences *prefs, - const char *pref_name) +nautilus_preferences_get_string (NautilusPreferences *prefs, + const char *name) { gboolean rv; - NautilusPreferencesType pref_type; + NautilusPreferencesType type; gconstpointer value; - g_return_val_if_fail (prefs != NULL, FALSE); - g_return_val_if_fail (NAUTILUS_IS_PREFS (prefs), FALSE); - g_return_val_if_fail (pref_name != NULL, FALSE); - - rv = prefs_get_pref (prefs, pref_name, &pref_type, &value); + g_return_val_if_fail (NAUTILUS_IS_PREFERENCES (prefs), FALSE); + g_return_val_if_fail (name != NULL, FALSE); + rv = prefs_get_pref (prefs, name, &type, &value); if (!rv) { - g_warning ("could not get string preference '%s'\n", pref_name); + g_warning ("tried to get an unregistered string preference '%s'", name); return NULL; } - g_assert (pref_type == NAUTILUS_PREFERENCE_STRING); + g_assert (type == NAUTILUS_PREFERENCE_STRING); return g_strdup (value); } @@ -777,5 +745,5 @@ nautilus_preferences_get_global_preferences (void) global_preferences = nautilus_preferences_new (PREFERENCES_GLOBAL_DOMAIN); } - return NAUTILUS_PREFS (global_preferences); + return NAUTILUS_PREFERENCES (global_preferences); } diff --git a/nautilus-widgets/nautilus-preferences.h b/nautilus-widgets/nautilus-preferences.h index 2a57924ef..779db6e95 100644 --- a/nautilus-widgets/nautilus-preferences.h +++ b/nautilus-widgets/nautilus-preferences.h @@ -25,28 +25,25 @@ #ifndef NAUTILUS_PREFERENCES_H #define NAUTILUS_PREFERENCES_H -#include <gtk/gtkhbox.h> -#include <nautilus-widgets/nautilus-preferences-pane.h> +#include <gtk/gtkobject.h> +#include <libgnome/gnome-defs.h> BEGIN_GNOME_DECLS -#define NAUTILUS_TYPE_PREFS (nautilus_preferences_get_type ()) -#define NAUTILUS_PREFS(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFS, NautilusPreferences)) -#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFS, NautilusPreferencesClass)) -#define NAUTILUS_IS_PREFS(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFS)) -#define NAUTILUS_IS_PREFS_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFS)) +#define NAUTILUS_TYPE_PREFERENCES (nautilus_preferences_get_type ()) +#define NAUTILUS_PREFERENCES(obj) (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_PREFERENCES, NautilusPreferences)) +#define NAUTILUS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_PREFERENCES, NautilusPreferencesClass)) +#define NAUTILUS_IS_PREFERENCES(obj) (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_PREFERENCES)) +#define NAUTILUS_IS_PREFERENCES_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_PREFERENCES)) -typedef struct _NautilusPreferences NautilusPreferences; -typedef struct _NautilusPreferencesClass NautilusPreferencesClass; -typedef struct _NautilusPreferencesDetails NautilusPreferencesDetails; +typedef struct NautilusPreferences NautilusPreferences; +typedef struct NautilusPreferencesClass NautilusPreferencesClass; +typedef struct NautilusPreferencesDetails NautilusPreferencesDetails; -struct _NautilusPreferences +struct NautilusPreferences { - /* Super Class */ - GtkObject object; - - /* Private stuff */ - NautilusPreferencesDetails *details; + GtkObject object; + NautilusPreferencesDetails *details; }; /* @@ -63,74 +60,71 @@ typedef enum * A callback which you can register to to be notified when a particular * preference changes. */ -typedef void (*NautilusPreferencesCallback) (const GtkObject *prefs, - const gchar *pref_name, - NautilusPreferencesType pref_type, - gconstpointer pref_value, - gpointer user_data); +typedef void (*NautilusPreferencesCallback) (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data); -struct _NautilusPreferencesClass +struct NautilusPreferencesClass { - GtkObjectClass object_class; + GtkObjectClass object_class; }; typedef struct { - gchar *pref_name; - gchar *pref_description; - NautilusPreferencesType pref_type; - gconstpointer pref_default_value; - gpointer type_data; + char *name; + char *description; + NautilusPreferencesType type; + gconstpointer default_value; + gpointer data; } NautilusPreferencesInfo; typedef struct { - const gchar **enum_names; - const gchar **enum_descriptions; - const gint *enum_values; - guint num_entries; + const char **enum_names; + const char **enum_descriptions; + const int *enum_values; + guint num_entries; } NautilusPreferencesEnumData; GtkType nautilus_preferences_get_type (void); -GtkObject* nautilus_preferences_new (const gchar *domain); -void nautilus_preferences_register_from_info (NautilusPreferences *prefs, +GtkObject * nautilus_preferences_new (const char *domain); +void nautilus_preferences_register_from_info (NautilusPreferences *preferences, const NautilusPreferencesInfo *pref_info); -void nautilus_preferences_register_from_values (NautilusPreferences *prefs, - gchar *pref_name, - gchar *pref_description, - NautilusPreferencesType pref_type, - gconstpointer pref_default_value, - gpointer type_data); -const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *prefs, - const gchar *pref_name); -gboolean nautilus_preferences_add_callback (NautilusPreferences *prefs, - const gchar *pref_name, +void nautilus_preferences_register_from_values (NautilusPreferences *preferences, + char *name, + char *description, + NautilusPreferencesType type, + gconstpointer default_value, + gpointer data); +const NautilusPreferencesInfo *nautilus_preferences_get_pref_info (NautilusPreferences *preferences, + const char *name); +gboolean nautilus_preferences_add_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -gboolean nautilus_preferences_remove_callback (NautilusPreferences *prefs, - const gchar *pref_name, +gboolean nautilus_preferences_remove_callback (NautilusPreferences *preferences, + const char *name, NautilusPreferencesCallback callback, gpointer user_data); -void nautilus_preferences_set_boolean (NautilusPreferences *prefs, - const gchar *pref_name, - gboolean boolean_value); -gboolean nautilus_preferences_get_boolean (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_enum (NautilusPreferences *prefs, - const gchar *pref_name, - gint enum_value); -gint nautilus_preferences_get_enum (NautilusPreferences *prefs, - const gchar *pref_name); -void nautilus_preferences_set_string (NautilusPreferences *prefs, - const gchar *pref_name, - const char *string_value); -char * nautilus_preferences_get_string (NautilusPreferences *prefs, - const gchar *pref_name); +void nautilus_preferences_set_boolean (NautilusPreferences *preferences, + const char *name, + gboolean value); +gboolean nautilus_preferences_get_boolean (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_enum (NautilusPreferences *preferences, + const char *name, + int value); +int nautilus_preferences_get_enum (NautilusPreferences *preferences, + const char *name); +void nautilus_preferences_set_string (NautilusPreferences *preferences, + const char *name, + const char *value); +char * nautilus_preferences_get_string (NautilusPreferences *preferences, + const char *name); NautilusPreferences * nautilus_preferences_get_global_preferences (void); - BEGIN_GNOME_DECLS #endif /* NAUTILUS_PREFERENCES_H */ - - diff --git a/nautilus-widgets/test-nautilus-widgets.c b/nautilus-widgets/test-nautilus-widgets.c index 5dbe8de8b..d09acd1e5 100644 --- a/nautilus-widgets/test-nautilus-widgets.c +++ b/nautilus-widgets/test-nautilus-widgets.c @@ -212,16 +212,15 @@ create_dummy_prefs (void) dummy_prefs = nautilus_preferences_new ("dummy"); /* Register the static prefs */ - for (i = 0; i < 3; i++) - { - nautilus_preferences_register_from_info (NAUTILUS_PREFS (dummy_prefs), - &prefs_global_static_pref_info[i]); + for (i = 0; i < 3; i++) { + nautilus_preferences_register_from_info (NAUTILUS_PREFERENCES (dummy_prefs), + &prefs_global_static_pref_info[i]); } - nautilus_preferences_set_enum (NAUTILUS_PREFS (dummy_prefs), - "user_level", - 2); + nautilus_preferences_set_enum (NAUTILUS_PREFERENCES (dummy_prefs), + "user_level", + 2); return dummy_prefs; } diff --git a/src/Makefile.am b/src/Makefile.am index e60b6311e..71eb84019 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -27,12 +27,12 @@ LDADD =\ $(NULL) nautilus_SOURCES =\ - explorer-location-bar.c \ - explorer-location-bar.h \ - nautilus-bookmarklist.c \ - nautilus-bookmarklist.h \ + nautilus-bookmark-list.c \ + nautilus-bookmark-list.h \ nautilus-bookmarks-window.c \ nautilus-bookmarks-window.h \ + nautilus-location-bar.c \ + nautilus-location-bar.h \ nautilus-signaller.c \ nautilus-signaller.h \ nautilus-zoom-control.c \ diff --git a/src/explorer-location-bar.c b/src/explorer-location-bar.c deleted file mode 100644 index 2f171f8ce..000000000 --- a/src/explorer-location-bar.c +++ /dev/null @@ -1,282 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* explorer-location-bar.c - Location bar for the GNOME Explorer. - - Copyright (C) 1999, 2000 Free Software Foundation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program 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 - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Ettore Perazzoli <ettore@gnu.org> - DnD code added by Michael Meeks <michael@nuclecu.unam.mx> -*/ - -#include <config.h> -#include "explorer-location-bar.h" - -#include <gnome.h> -#include <string.h> - -#include <libnautilus/nautilus-glib-extensions.h> - -#define EXPLORER_DND_URI_LIST_TYPE "text/uri-list" -#define EXPLORER_DND_TEXT_PLAIN_TYPE "text/plain" -#define EXPLORER_DND_URL_TYPE "_NETSCAPE_URL" - -typedef enum { - EXPLORER_DND_MC_DESKTOP_ICON, - EXPLORER_DND_URI_LIST, - EXPLORER_DND_TEXT_PLAIN, - EXPLORER_DND_URL, - EXPLORER_DND_NTARGETS -} ExplorerDndTargetType; - -static GtkHBoxClass *parent_class; -enum { - LOCATION_CHANGED, - LAST_SIGNAL -}; -static guint signals[LAST_SIGNAL] = { 0 }; - -static GtkTargetEntry drag_types [] = { - { EXPLORER_DND_URI_LIST_TYPE, 0, EXPLORER_DND_URI_LIST }, - { EXPLORER_DND_TEXT_PLAIN_TYPE, 0, EXPLORER_DND_TEXT_PLAIN }, - { EXPLORER_DND_URL_TYPE, 0, EXPLORER_DND_URL } -}; - -static GtkTargetEntry drop_types [] = { - { EXPLORER_DND_URI_LIST_TYPE, 0, EXPLORER_DND_URI_LIST }, - { EXPLORER_DND_TEXT_PLAIN_TYPE, 0, EXPLORER_DND_TEXT_PLAIN }, - { EXPLORER_DND_URL_TYPE, 0, EXPLORER_DND_URL } -}; - - -static void -drag_data_received_cb (GtkWidget *widget, - GdkDragContext *context, - gint x, - gint y, - GtkSelectionData *data, - guint info, - guint32 time, - ExplorerLocationBar *location_bar) -{ - GList *names; - - g_return_if_fail (data != NULL); - - names = gnome_uri_list_extract_uris (data->data); - - if (!names) { - g_warning ("No D&D URI's"); - gtk_drag_finish (context, FALSE, FALSE, time); - return; - } - - if (g_list_length (names) > 1) - g_warning ("FIXME: should we clone ourselfs ?"); - - explorer_location_bar_set_uri_string (location_bar, - names->data); - gtk_signal_emit (GTK_OBJECT (location_bar), - signals[LOCATION_CHANGED], names->data); - - gnome_uri_list_free_strings (names); - - gtk_drag_finish (context, TRUE, FALSE, time); -} - -static void -drag_data_get_cb (GtkWidget *widget, - GdkDragContext *context, - GtkSelectionData *selection_data, - guint info, - guint32 time, - ExplorerLocationBar *location_bar) -{ - gchar *entry_txt; - - g_return_if_fail (location_bar != NULL); - g_return_if_fail (selection_data != NULL); - - entry_txt = gtk_entry_get_text (GTK_ENTRY (location_bar->entry)); - g_return_if_fail (entry_txt != NULL); - - switch (info) { - case EXPLORER_DND_URI_LIST: - case EXPLORER_DND_TEXT_PLAIN: - case EXPLORER_DND_URL: - gtk_selection_data_set (selection_data, - selection_data->target, - 8, (guchar *)entry_txt, - strlen (entry_txt)); - break; - default: - g_assert_not_reached (); - } - - g_free (entry_txt); -} - -static void -location_changed (ExplorerLocationBar *location_bar, const char *uri_string) -{ - g_return_if_fail (location_bar != NULL); - g_return_if_fail (EXPLORER_IS_LOCATION_BAR - (location_bar)); - - gtk_entry_set_text(GTK_ENTRY(location_bar->entry), uri_string); -} - -static void -editable_activated_cb (GtkEditable *editable, - ExplorerLocationBar *location_bar) -{ - g_return_if_fail (location_bar != NULL); - g_return_if_fail (editable != NULL); - g_return_if_fail (EXPLORER_IS_LOCATION_BAR - (location_bar)); - - gtk_signal_emit (GTK_OBJECT (location_bar), - signals[LOCATION_CHANGED], - gtk_entry_get_text(GTK_ENTRY(editable))); -} - - -static void -destroy (GtkObject *object) -{ - ExplorerLocationBar *location_bar; - - location_bar = EXPLORER_LOCATION_BAR (object); - - gtk_widget_destroy (location_bar->label); - gtk_widget_destroy (location_bar->entry); - - (* GTK_OBJECT_CLASS (parent_class)->destroy) (object); -} - - -static void -class_init (ExplorerLocationBarClass *class) -{ - GtkObjectClass *object_class; - - parent_class = gtk_type_class (gtk_hbox_get_type ()); - - object_class = GTK_OBJECT_CLASS (class); - - object_class->destroy = destroy; - - signals[LOCATION_CHANGED] - = gtk_signal_new ("location_changed", - GTK_RUN_FIRST, - object_class->type, - GTK_SIGNAL_OFFSET (ExplorerLocationBarClass, - location_changed), - gtk_marshal_NONE__STRING, - GTK_TYPE_NONE, 1, GTK_TYPE_STRING); - - gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); - - class->location_changed = location_changed; -} - -static void -init (ExplorerLocationBar *location_bar) -{ - GtkWidget *label; - GtkWidget *entry; - GtkWidget *eventbox; - - eventbox = gtk_event_box_new (); - gtk_container_set_border_width (GTK_CONTAINER (eventbox), - GNOME_PAD_SMALL); - label = gtk_label_new (_("Location:")); - gtk_container_add (GTK_CONTAINER (eventbox), label); - gtk_box_pack_start (GTK_BOX (location_bar), eventbox, FALSE, TRUE, - GNOME_PAD_SMALL); - - entry = gtk_entry_new (); - gtk_signal_connect (GTK_OBJECT (entry), "activate", - editable_activated_cb, location_bar); - gtk_box_pack_start (GTK_BOX (location_bar), entry, TRUE, TRUE, 0); - - /* Drag source */ - gtk_drag_source_set (GTK_WIDGET (eventbox), - GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, - drag_types, NAUTILUS_N_ELEMENTS (drag_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (eventbox), "drag_data_get", - GTK_SIGNAL_FUNC (drag_data_get_cb), - location_bar); - - /* Drag dest. */ - gtk_drag_dest_set (GTK_WIDGET (location_bar), - GTK_DEST_DEFAULT_ALL, - drop_types, NAUTILUS_N_ELEMENTS (drop_types), - GDK_ACTION_COPY | GDK_ACTION_MOVE); - gtk_signal_connect (GTK_OBJECT (location_bar), "drag_data_received", - GTK_SIGNAL_FUNC (drag_data_received_cb), - location_bar); - - gtk_widget_show (entry); - gtk_widget_show_all (eventbox); - - location_bar->label = label; - location_bar->entry = entry; -} - - -GtkType -explorer_location_bar_get_type (void) -{ - static GtkType type = 0; - - if (type == 0) { - GtkTypeInfo info = { - "ExplorerLocationBar", - sizeof (ExplorerLocationBar), - sizeof (ExplorerLocationBarClass), - (GtkClassInitFunc) class_init, - (GtkObjectInitFunc) init, - NULL, - NULL, - NULL - }; - - type = gtk_type_unique (gtk_hbox_get_type (), &info); - } - - return type; -} - -GtkWidget * -explorer_location_bar_new (void) -{ - return gtk_widget_new (explorer_location_bar_get_type (), NULL); -} - -void -explorer_location_bar_set_uri_string (ExplorerLocationBar *bar, - const gchar *uri_string) -{ - g_return_if_fail (bar != NULL); - g_return_if_fail (EXPLORER_IS_LOCATION_BAR (bar)); - - if (uri_string == NULL) - uri_string = ""; - - gtk_entry_set_text (GTK_ENTRY (bar->entry), uri_string); -} diff --git a/src/explorer-location-bar.h b/src/explorer-location-bar.h deleted file mode 100644 index 83c738c66..000000000 --- a/src/explorer-location-bar.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* explorer-location-bar.h - Location bar for the GNOME Explorer. - - Copyright (C) 1999, 2000 Free Software Foundation - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program 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 - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; see the file COPYING. If not, - write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - - Author: Ettore Perazzoli <ettore@gnu.org> -*/ - -#ifndef EXPLORER_LOCATION_BAR_H -#define EXPLORER_LOCATION_BAR_H - -#include <gtk/gtkhbox.h> - -#define EXPLORER_LOCATION_BAR(obj) \ - GTK_CHECK_CAST (obj, explorer_location_bar_get_type (), ExplorerLocationBar) -#define EXPLORER_LOCATION_BAR_CLASS(klass) \ - GTK_CHECK_CLASS_CAST (klass, explorer_location_bar_get_type (), ExplorerLocationBarClass) -#define EXPLORER_IS_LOCATION_BAR(obj) \ - GTK_CHECK_TYPE (obj, explorer_location_bar_get_type ()) - -struct _ExplorerLocationBar { - GtkHBox hbox; - - GtkWidget *label; - GtkWidget *entry; -}; -typedef struct _ExplorerLocationBar ExplorerLocationBar; - -struct _ExplorerLocationBarClass { - GtkHBoxClass parent_class; - void (*location_changed) (ExplorerLocationBar *location_bar, - const char *uri_string); -}; -typedef struct _ExplorerLocationBarClass ExplorerLocationBarClass; - - -GtkType explorer_location_bar_get_type (void); -GtkWidget *explorer_location_bar_new (void); -void explorer_location_bar_set_uri_string - (ExplorerLocationBar *bar, - const gchar *uri_string); - -#endif /* EXPLORER_LOCATION_BAR_H */ diff --git a/src/file-manager/fm-directory-view-icons.c b/src/file-manager/fm-directory-view-icons.c index 35fa83fb3..89289f59d 100644 --- a/src/file-manager/fm-directory-view-icons.c +++ b/src/file-manager/fm-directory-view-icons.c @@ -125,10 +125,10 @@ static char * get_icon_property_cb NautilusFile *icon_data, const char *property_name, FMDirectoryViewIcons *icon_view); -static void text_attribute_names_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +static void text_attribute_names_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, gpointer user_data); NAUTILUS_DEFINE_CLASS_BOILERPLATE (FMDirectoryViewIcons, fm_directory_view_icons, FM_TYPE_DIRECTORY_VIEW); @@ -190,7 +190,7 @@ fm_directory_view_icons_initialize (FMDirectoryViewIcons *icon_view) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES, text_attribute_names_changed_callback, - (gpointer) icon_view); + icon_view); icon_container = create_icon_container (icon_view); } @@ -205,7 +205,7 @@ fm_directory_view_icons_destroy (GtkObject *object) nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES, text_attribute_names_changed_callback, - (gpointer) icon_view); + icon_view); if (icon_view->details->react_to_icon_change_idle_id != 0) { gtk_idle_remove (icon_view->details->react_to_icon_change_idle_id); @@ -1085,23 +1085,25 @@ get_icon_property_cb (GnomeIconContainer *container, } static void -text_attribute_names_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data) +text_attribute_names_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data) { - FMDirectoryViewIcons * icon_view; + FMDirectoryViewIcons *icon_view; + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES) == 0); + g_assert (type == NAUTILUS_PREFERENCE_STRING); + g_assert (value != NULL); g_assert (FM_IS_DIRECTORY_VIEW_ICONS (user_data)); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); icon_view = FM_DIRECTORY_VIEW_ICONS (user_data); g_free (icon_view->details->text_attribute_names); - icon_view->details->text_attribute_names = g_strdup ((char *)pref_value); + icon_view->details->text_attribute_names = g_strdup ((char *) value); gnome_icon_container_request_update_all (get_icon_container (icon_view)); -}
\ No newline at end of file +} diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 8969143fe..83332d513 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -154,15 +154,15 @@ static void schedule_timeout_display_of_pending_files static void unschedule_timeout_display_of_pending_files (FMDirectoryView *view); static void unschedule_display_of_pending_files (FMDirectoryView *view); static void disconnect_model_handlers (FMDirectoryView *view); -static void user_level_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +static void user_level_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, gpointer user_data); -static void use_new_window_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, +static void use_new_window_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, gpointer user_data); @@ -419,7 +419,7 @@ fm_directory_view_initialize (FMDirectoryView *directory_view) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_USER_LEVEL, user_level_changed_callback, - (gpointer) directory_view); + directory_view); directory_view->details->use_new_window = nautilus_preferences_get_boolean (nautilus_preferences_get_global_preferences (), @@ -428,7 +428,7 @@ fm_directory_view_initialize (FMDirectoryView *directory_view) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, use_new_window_changed_callback, - (gpointer) directory_view); + directory_view); } static void @@ -441,11 +441,11 @@ fm_directory_view_destroy (GtkObject *object) nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_USER_LEVEL, user_level_changed_callback, - (gpointer) view); + view); nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW, use_new_window_changed_callback, - (gpointer) view); + view); if (view->details->model != NULL) { disconnect_model_handlers (view); @@ -1849,47 +1849,46 @@ fm_directory_view_update_menus (FMDirectoryView *view) } static void -use_new_window_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data) -{ - FMDirectoryView * directory_view = FM_DIRECTORY_VIEW (user_data); - - g_assert (directory_view != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); +use_new_window_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data) +{ + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW) == 0); + g_assert (type == NAUTILUS_PREFERENCE_BOOLEAN); + g_assert (GPOINTER_TO_INT (value) == FALSE || GPOINTER_TO_INT (value) == TRUE); + g_assert (FM_IS_DIRECTORY_VIEW (user_data)); - directory_view->details->use_new_window = GPOINTER_TO_INT (pref_value); + FM_DIRECTORY_VIEW (user_data)->details->use_new_window = GPOINTER_TO_INT (value); } static void -user_level_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data) +user_level_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data) { - FMDirectoryView * directory_view = FM_DIRECTORY_VIEW (user_data); + FMDirectoryView *directory_view; + char *same_uri; - g_assert (directory_view != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_USER_LEVEL) == 0); + g_assert (type == NAUTILUS_PREFERENCE_BOOLEAN); + g_assert (GPOINTER_TO_INT (value) == FALSE || GPOINTER_TO_INT (value) == TRUE); + g_assert (FM_IS_DIRECTORY_VIEW (user_data)); - directory_view->details->user_level = GPOINTER_TO_INT (pref_value); + directory_view = FM_DIRECTORY_VIEW (user_data); - /* Reload the current uri so that the filtering changes take place */ - if (directory_view->details->model != NULL) - { - char * same_uri; + directory_view->details->user_level = GPOINTER_TO_INT (value); + /* Reload the current uri so that the filtering changes take place. */ + if (directory_view->details->model != NULL) { same_uri = nautilus_directory_get_uri (directory_view->details->model); - g_assert (same_uri != NULL); - fm_directory_view_load_uri (directory_view, same_uri); - g_free (same_uri); } } diff --git a/src/file-manager/fm-icon-text-window.c b/src/file-manager/fm-icon-text-window.c index 4eb86c489..4650f7d1a 100644 --- a/src/file-manager/fm-icon-text-window.c +++ b/src/file-manager/fm-icon-text-window.c @@ -96,7 +96,7 @@ set_preference_string (char *new_value) { } static void -synch_menus_with_preference () +synch_menus_with_preference (void) { int menu_index; char **text_array; @@ -125,18 +125,20 @@ synch_menus_with_preference () } static void -preference_changed_callback (const GtkObject *prefs, - const gchar *pref_name, - GtkFundamentalType pref_type, - gconstpointer pref_value, - gpointer user_data) +preference_changed_callback (NautilusPreferences *preferences, + const char *name, + NautilusPreferencesType type, + gconstpointer value, + gpointer user_data) { - g_assert (user_data != NULL); - g_assert (prefs != NULL); - g_assert (pref_name != NULL); + g_assert (NAUTILUS_IS_PREFERENCES (preferences)); + g_assert (strcmp (name, NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES) == 0); + g_assert (type == NAUTILUS_PREFERENCE_STRING); + g_assert (value != NULL); + g_assert (user_data == NULL); - set_preference_string (g_strdup ((char *)pref_value)); + set_preference_string (g_strdup ((char *) value)); synch_menus_with_preference (); } @@ -282,7 +284,7 @@ create_icon_text_window (void) nautilus_preferences_add_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES, preference_changed_callback, - (gpointer) window); + NULL); gtk_signal_connect (GTK_OBJECT (window), "delete_event", @@ -351,12 +353,12 @@ fm_icon_text_window_delete_event_cb (GtkWidget *widget, static void fm_icon_text_window_destroy_cb (GtkObject *object, - gpointer user_data) + gpointer user_data) { nautilus_preferences_remove_callback (nautilus_preferences_get_global_preferences (), NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ATTRIBUTE_NAMES, preference_changed_callback, - user_data); + NULL); } /** diff --git a/src/nautilus-bookmarklist.c b/src/nautilus-bookmark-list.c index 534824fac..f96988dc1 100644 --- a/src/nautilus-bookmarklist.c +++ b/src/nautilus-bookmark-list.c @@ -1,6 +1,6 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* nautilus-bookmarklist.c - implementation of centralized list of bookmarks. +/* nautilus-bookmark-list.c - implementation of centralized list of bookmarks. Copyright (C) 1999, 2000 Eazel, Inc. @@ -23,7 +23,11 @@ */ #include <config.h> -#include "nautilus-bookmarklist.h" +#include "nautilus-bookmark-list.h" + +#include <stdlib.h> + +#include <gtk/gtksignal.h> #include <libnautilus/nautilus-file-utilities.h> #include <libnautilus/nautilus-gtk-macros.h> @@ -38,26 +42,23 @@ enum { LAST_SIGNAL }; - /* forward declarations */ -static void append_bookmark_node (gpointer list_element, - gpointer user_data); -static void destroy_bookmark (gpointer list_element, - gpointer user_data); -static const char *nautilus_bookmarklist_get_file_path (NautilusBookmarklist *bookmarks); -static void nautilus_bookmarklist_load_file (NautilusBookmarklist *bookmarks); -static void nautilus_bookmarklist_save_file (NautilusBookmarklist *bookmarks); -static void set_window_geometry_internal (const char *string); +static void append_bookmark_node (gpointer list_element, + gpointer user_data); +static void destroy_bookmark (gpointer list_element, + gpointer user_data); +static const char *nautilus_bookmark_list_get_file_path (NautilusBookmarkList *bookmarks); +static void nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks); +static void nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks); +static void set_window_geometry_internal (const char *string); - static guint signals[LAST_SIGNAL]; static char *window_geometry; - /* Initialization. */ static void -nautilus_bookmarklist_initialize_class (NautilusBookmarklistClass *class) +nautilus_bookmark_list_initialize_class (NautilusBookmarkListClass *class) { GtkObjectClass *object_class; @@ -67,7 +68,7 @@ nautilus_bookmarklist_initialize_class (NautilusBookmarklistClass *class) gtk_signal_new ("contents_changed", GTK_RUN_FIRST, object_class->type, - GTK_SIGNAL_OFFSET (NautilusBookmarklistClass, + GTK_SIGNAL_OFFSET (NautilusBookmarkListClass, contents_changed), gtk_marshal_NONE__NONE, GTK_TYPE_NONE, 0); @@ -78,12 +79,12 @@ nautilus_bookmarklist_initialize_class (NautilusBookmarklistClass *class) } static void -nautilus_bookmarklist_initialize (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_initialize (NautilusBookmarkList *bookmarks) { - nautilus_bookmarklist_load_file (bookmarks); + nautilus_bookmark_list_load_file (bookmarks); } -NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusBookmarklist, nautilus_bookmarklist, GTK_TYPE_OBJECT) +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusBookmarkList, nautilus_bookmark_list, GTK_TYPE_OBJECT) /** @@ -125,38 +126,38 @@ destroy_bookmark (gpointer data, gpointer user_data) } /** - * nautilus_bookmarklist_append: + * nautilus_bookmark_list_append: * - * Append a bookmark to a bookmarklist. - * @bookmarks: NautilusBookmarklist to append to. + * Append a bookmark to a bookmark list. + * @bookmarks: NautilusBookmarkList to append to. * @bookmark: Bookmark to append a copy of. **/ void -nautilus_bookmarklist_append (NautilusBookmarklist *bookmarks, +nautilus_bookmark_list_append (NautilusBookmarkList *bookmarks, const NautilusBookmark *bookmark) { - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); g_return_if_fail (NAUTILUS_IS_BOOKMARK (bookmark)); bookmarks->list = g_list_append (bookmarks->list, nautilus_bookmark_copy (bookmark)); - nautilus_bookmarklist_contents_changed (bookmarks); + nautilus_bookmark_list_contents_changed (bookmarks); } /** - * nautilus_bookmarklist_contains: + * nautilus_bookmark_list_contains: * * Check whether a bookmark with matching name and url is already in the list. - * @bookmarks: NautilusBookmarklist to check contents of. + * @bookmarks: NautilusBookmarkList to check contents of. * @bookmark: NautilusBookmark to match against. * * Return value: TRUE if matching bookmark is in list, FALSE otherwise **/ gboolean -nautilus_bookmarklist_contains (NautilusBookmarklist *bookmarks, +nautilus_bookmark_list_contains (NautilusBookmarkList *bookmarks, const NautilusBookmark *bookmark) { - g_return_val_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks), FALSE); + g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks), FALSE); g_return_val_if_fail (NAUTILUS_IS_BOOKMARK (bookmark), FALSE); return g_list_find_custom (bookmarks->list, @@ -166,35 +167,35 @@ nautilus_bookmarklist_contains (NautilusBookmarklist *bookmarks, } /** - * nautilus_bookmarklist_contents_changed: + * nautilus_bookmark_list_contents_changed: * - * Save the bookmarklist to disk, and emit the contents_changed signal. - * @bookmarks: NautilusBookmarklist whose contents have been modified. + * Save the bookmark list to disk, and emit the contents_changed signal. + * @bookmarks: NautilusBookmarkList whose contents have been modified. **/ void -nautilus_bookmarklist_contents_changed (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_contents_changed (NautilusBookmarkList *bookmarks) { - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); - nautilus_bookmarklist_save_file (bookmarks); + nautilus_bookmark_list_save_file (bookmarks); gtk_signal_emit (GTK_OBJECT (bookmarks), signals[CONTENTS_CHANGED]); } /** - * nautilus_bookmarklist_delete_item_at: + * nautilus_bookmark_list_delete_item_at: * * Delete the bookmark at the specified position. * @bookmarks: the list of bookmarks. * @index: index, must be less than length of list. **/ void -nautilus_bookmarklist_delete_item_at (NautilusBookmarklist *bookmarks, +nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks, guint index) { GList *doomed; - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); g_return_if_fail (index < g_list_length (bookmarks->list)); doomed = g_list_nth (bookmarks->list, index); @@ -205,11 +206,11 @@ nautilus_bookmarklist_delete_item_at (NautilusBookmarklist *bookmarks, g_list_free (doomed); - nautilus_bookmarklist_contents_changed (bookmarks); + nautilus_bookmark_list_contents_changed (bookmarks); } static const char * -nautilus_bookmarklist_get_file_path (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_get_file_path (NautilusBookmarkList *bookmarks) { /* currently hardwired */ @@ -223,23 +224,23 @@ nautilus_bookmarklist_get_file_path (NautilusBookmarklist *bookmarks) } /** - * nautilus_bookmarklist_get_window_geometry: + * nautilus_bookmark_list_get_window_geometry: * - * Get a string representing the bookmarklist's window's geometry. - * This is the value set earlier by nautilus_bookmarklist_set_window_geometry. + * Get a string representing the bookmark_list's window's geometry. + * This is the value set earlier by nautilus_bookmark_list_set_window_geometry. * @bookmarks: the list of bookmarks associated with the window. * Return value: string representation of window's geometry, suitable for * passing to gnome_parse_geometry(), or NULL if - * no window geometry has yet been saved for this bookmarklist. + * no window geometry has yet been saved for this bookmark list. **/ const char * -nautilus_bookmarklist_get_window_geometry (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_get_window_geometry (NautilusBookmarkList *bookmarks) { return window_geometry; } /** - * nautilus_bookmarklist_insert_item: + * nautilus_bookmark_list_insert_item: * * Insert a bookmark at a specified position. * @bookmarks: the list of bookmarks. @@ -247,22 +248,22 @@ nautilus_bookmarklist_get_window_geometry (NautilusBookmarklist *bookmarks) * @new_bookmark: the bookmark to insert a copy of. **/ void -nautilus_bookmarklist_insert_item (NautilusBookmarklist *bookmarks, - const NautilusBookmark* new_bookmark, - guint index) +nautilus_bookmark_list_insert_item (NautilusBookmarkList *bookmarks, + const NautilusBookmark* new_bookmark, + guint index) { - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); g_return_if_fail (index <= g_list_length (bookmarks->list)); bookmarks->list = g_list_insert (bookmarks->list, nautilus_bookmark_copy (new_bookmark), index); - nautilus_bookmarklist_contents_changed (bookmarks); + nautilus_bookmark_list_contents_changed (bookmarks); } /** - * nautilus_bookmarklist_item_at: + * nautilus_bookmark_list_item_at: * * Get the bookmark at the specified position. * @bookmarks: the list of bookmarks. @@ -271,16 +272,16 @@ nautilus_bookmarklist_insert_item (NautilusBookmarklist *bookmarks, * Return value: the bookmark at position @index in @bookmarks. **/ const NautilusBookmark * -nautilus_bookmarklist_item_at (NautilusBookmarklist *bookmarks, guint index) +nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks, guint index) { - g_return_val_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks), NULL); + g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST (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: + * nautilus_bookmark_list_length: * * Get the number of bookmarks in the list. * @bookmarks: the list of bookmarks. @@ -288,21 +289,21 @@ nautilus_bookmarklist_item_at (NautilusBookmarklist *bookmarks, guint index) * Return value: the length of the bookmark list. **/ guint -nautilus_bookmarklist_length (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks) { - g_return_val_if_fail (NAUTILUS_IS_BOOKMARKLIST(bookmarks), 0); + g_return_val_if_fail (NAUTILUS_IS_BOOKMARK_LIST(bookmarks), 0); return g_list_length (bookmarks->list); } /** - * nautilus_bookmarklist_load_file: + * nautilus_bookmark_list_load_file: * * Reads bookmarks from file, clobbering contents in memory. * @bookmarks: the list of bookmarks to fill with file contents. **/ static void -nautilus_bookmarklist_load_file (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_load_file (NautilusBookmarkList *bookmarks) { xmlDocPtr doc; xmlNodePtr node; @@ -313,7 +314,7 @@ nautilus_bookmarklist_load_file (NautilusBookmarklist *bookmarks) bookmarks->list = NULL; /* Read new list from file */ - doc = xmlParseFile (nautilus_bookmarklist_get_file_path (bookmarks)); + doc = xmlParseFile (nautilus_bookmark_list_get_file_path (bookmarks)); for (node = nautilus_xml_get_root_children (doc); node != NULL; node = node->next) { @@ -345,26 +346,26 @@ nautilus_bookmarklist_load_file (NautilusBookmarklist *bookmarks) } /** - * nautilus_bookmarklist_new: + * nautilus_bookmark_list_new: * - * Create a new bookmarklist, with contents read from disk. + * Create a new bookmark_list, with contents read from disk. * * Return value: A pointer to the new widget. **/ -NautilusBookmarklist * -nautilus_bookmarklist_new (void) +NautilusBookmarkList * +nautilus_bookmark_list_new (void) { - return gtk_type_new (NAUTILUS_TYPE_BOOKMARKLIST); + return gtk_type_new (NAUTILUS_TYPE_BOOKMARK_LIST); } /** - * nautilus_bookmarklist_save_file: + * nautilus_bookmark_list_save_file: * * Save bookmarks to disk. * @bookmarks: the list of bookmarks to save. **/ static void -nautilus_bookmarklist_save_file (NautilusBookmarklist *bookmarks) +nautilus_bookmark_list_save_file (NautilusBookmarkList *bookmarks) { xmlDocPtr doc; xmlNodePtr root, node; @@ -382,12 +383,12 @@ nautilus_bookmarklist_save_file (NautilusBookmarklist *bookmarks) /* save bookmarks */ g_list_foreach (bookmarks->list, append_bookmark_node, root); - xmlSaveFile (nautilus_bookmarklist_get_file_path (bookmarks), doc); + xmlSaveFile (nautilus_bookmark_list_get_file_path (bookmarks), doc); xmlFreeDoc (doc); } /** - * nautilus_bookmarklist_set_window_geometry: + * nautilus_bookmark_list_set_window_geometry: * * Set a bookmarks window's geometry (position & size), in string form. This is * stored to disk by this class, and can be retrieved later in @@ -396,15 +397,15 @@ nautilus_bookmarklist_save_file (NautilusBookmarklist *bookmarks) * @geometry: the new window geometry string. **/ void -nautilus_bookmarklist_set_window_geometry (NautilusBookmarklist *bookmarks, - const char *geometry) +nautilus_bookmark_list_set_window_geometry (NautilusBookmarkList *bookmarks, + const char *geometry) { - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); g_return_if_fail (geometry != NULL); set_window_geometry_internal (geometry); - nautilus_bookmarklist_save_file(bookmarks); + nautilus_bookmark_list_save_file(bookmarks); } static void diff --git a/src/nautilus-bookmark-list.h b/src/nautilus-bookmark-list.h new file mode 100644 index 000000000..de0b234f2 --- /dev/null +++ b/src/nautilus-bookmark-list.h @@ -0,0 +1,73 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-bookmark-list.h - interface for centralized list of 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_LIST_H +#define NAUTILUS_BOOKMARK_LIST_H + +#include <libnautilus/nautilus-bookmark.h> + +typedef struct NautilusBookmarkList NautilusBookmarkList; +typedef struct NautilusBookmarkListClass NautilusBookmarkListClass; + +#define NAUTILUS_TYPE_BOOKMARK_LIST \ + (nautilus_bookmark_list_get_type ()) +#define NAUTILUS_BOOKMARK_LIST(obj) \ + (GTK_CHECK_CAST ((obj), NAUTILUS_TYPE_BOOKMARK_LIST, NautilusBookmarkList)) +#define NAUTILUS_BOOKMARK_LIST_CLASS(klass) \ + (GTK_CHECK_CLASS_CAST ((klass), NAUTILUS_TYPE_BOOKMARK_LIST, NautilusBookmarkListClass)) +#define NAUTILUS_IS_BOOKMARK_LIST(obj) \ + (GTK_CHECK_TYPE ((obj), NAUTILUS_TYPE_BOOKMARK_LIST)) +#define NAUTILUS_IS_BOOKMARK_LIST_CLASS(klass) \ + (GTK_CHECK_CLASS_TYPE ((klass), NAUTILUS_TYPE_BOOKMARK_LIST)) + +struct NautilusBookmarkList { + GtkObject object; + GList *list; +}; + +struct NautilusBookmarkListClass { + GtkObjectClass parent_class; + void (* contents_changed) (NautilusBookmarkList *bookmarks); +}; + +GtkType nautilus_bookmark_list_get_type (void); +NautilusBookmarkList * nautilus_bookmark_list_new (void); +void nautilus_bookmark_list_append (NautilusBookmarkList *bookmarks, + const NautilusBookmark *bookmark); +gboolean nautilus_bookmark_list_contains (NautilusBookmarkList *bookmarks, + const NautilusBookmark *bookmark); +void nautilus_bookmark_list_contents_changed (NautilusBookmarkList *bookmarks); +void nautilus_bookmark_list_delete_item_at (NautilusBookmarkList *bookmarks, + guint index); +void nautilus_bookmark_list_insert_item (NautilusBookmarkList *bookmarks, + const NautilusBookmark *bookmark, + guint index); +guint nautilus_bookmark_list_length (NautilusBookmarkList *bookmarks); +const NautilusBookmark *nautilus_bookmark_list_item_at (NautilusBookmarkList *bookmarks, + guint index); +void nautilus_bookmark_list_set_window_geometry (NautilusBookmarkList *bookmarks, + const char *geometry); +const char * nautilus_bookmark_list_get_window_geometry (NautilusBookmarkList *bookmarks); + +#endif /* NAUTILUS_BOOKMARK_LIST_H */ diff --git a/src/nautilus-bookmarklist.h b/src/nautilus-bookmarklist.h deleted file mode 100644 index f884f46b3..000000000 --- a/src/nautilus-bookmarklist.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- 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, 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_BOOKMARKLIST_H -#define NAUTILUS_BOOKMARKLIST_H 1 - -#include <gnome.h> -#include <libnautilus/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 *bookmarks); -}; - -typedef struct _NautilusBookmarklistClass NautilusBookmarklistClass; - - - -GtkType nautilus_bookmarklist_get_type (void); -NautilusBookmarklist *nautilus_bookmarklist_new (void); -void nautilus_bookmarklist_append (NautilusBookmarklist *bookmarks, - const NautilusBookmark *bookmark); -gboolean nautilus_bookmarklist_contains (NautilusBookmarklist *bookmarks, - const NautilusBookmark *bookmark); -void nautilus_bookmarklist_contents_changed - (NautilusBookmarklist *bookmarks); -void nautilus_bookmarklist_delete_item_at - (NautilusBookmarklist *bookmarks, - guint index); -void nautilus_bookmarklist_insert_item - (NautilusBookmarklist *bookmarks, - const NautilusBookmark *bookmark, - guint index); -guint nautilus_bookmarklist_length (NautilusBookmarklist *bookmarks); -const NautilusBookmark *nautilus_bookmarklist_item_at (NautilusBookmarklist *bookmarks, - guint index); - -void nautilus_bookmarklist_set_window_geometry - (NautilusBookmarklist *bookmarks, - const gchar *geometry); -const gchar *nautilus_bookmarklist_get_window_geometry - (NautilusBookmarklist *bookmarks); - -#endif /* NAUTILUS_BOOKMARKLIST_H */ diff --git a/src/nautilus-bookmarks-window.c b/src/nautilus-bookmarks-window.c index 95e423760..5a0b7c18d 100644 --- a/src/nautilus-bookmarks-window.c +++ b/src/nautilus-bookmarks-window.c @@ -29,15 +29,15 @@ * more than one bookmark-editing window, these would be struct or * class fields. */ -static gint bookmarklist_changed_signalID; -static NautilusBookmarklist *bookmarks = NULL; -static GtkWidget *bookmark_list_widget = NULL; /* awkward name to distinguish from NautilusBookmarklist */ +static int bookmark_list_changed_signalID; +static NautilusBookmarkList *bookmarks = NULL; +static GtkWidget *bookmark_list_widget = NULL; /* awkward name to distinguish from NautilusBookmarkList */ static GtkWidget *name_field = NULL; -static gint name_field_changed_signalID; +static int name_field_changed_signalID; static GtkWidget *remove_button = NULL; static gboolean text_changed = FALSE; static GtkWidget *uri_field = NULL; -static gint uri_field_changed_signalID; +static int uri_field_changed_signalID; /* forward declarations */ @@ -46,17 +46,17 @@ static guint get_selected_row (void); static gboolean get_selection_exists (void); static void nautilus_bookmarks_window_restore_geometry (GtkWidget *window); -static void on_bookmarklist_changed (NautilusBookmarklist *, +static void on_bookmark_list_changed (NautilusBookmarkList *, gpointer user_data); static void on_name_field_changed (GtkEditable *, gpointer user_data); static void on_remove_button_clicked (GtkButton *, gpointer user_data); static void on_row_move (GtkCList *, - gint old_row, - gint new_row, + int old_row, + int new_row, gpointer user_data); static void on_select_row (GtkCList *, - gint row, - gint column, + int row, + int column, GdkEventButton *, gpointer user_data); static gboolean on_text_field_focus_out_event (GtkWidget *, @@ -96,12 +96,12 @@ static void repopulate (void); * create_bookmarks_window: * * Create a new bookmark-editing window. - * @list: The NautilusBookmarklist that this window will edit. + * @list: The NautilusBookmarkList that this window will edit. * * Return value: A pointer to the new window. **/ GtkWidget * -create_bookmarks_window(NautilusBookmarklist *list) +create_bookmarks_window(NautilusBookmarkList *list) { GtkWidget *window; GtkWidget *content_area; @@ -198,9 +198,9 @@ create_bookmarks_window(NautilusBookmarklist *list) /* Wire up all the signals. */ - bookmarklist_changed_signalID = + bookmark_list_changed_signalID = gtk_signal_connect (GTK_OBJECT(bookmarks), "contents_changed", - GTK_SIGNAL_FUNC(on_bookmarklist_changed), + GTK_SIGNAL_FUNC(on_bookmark_list_changed), NULL); gtk_signal_connect (GTK_OBJECT(bookmark_list_widget), "row_move", @@ -257,9 +257,9 @@ create_bookmarks_window(NautilusBookmarklist *list) static const NautilusBookmark * get_selected_bookmark () { - g_return_val_if_fail(NAUTILUS_IS_BOOKMARKLIST(bookmarks), NULL); + g_return_val_if_fail(NAUTILUS_IS_BOOKMARK_LIST(bookmarks), NULL); - return nautilus_bookmarklist_item_at(bookmarks, get_selected_row()); + return nautilus_bookmark_list_item_at(bookmarks, get_selected_row()); } static guint @@ -279,7 +279,7 @@ get_selection_exists () } static void -install_bookmark_icon (const NautilusBookmark *bookmark, gint row) +install_bookmark_icon (const NautilusBookmark *bookmark, int row) { GdkPixmap *pixmap; GdkBitmap *bitmap; @@ -302,16 +302,16 @@ install_bookmark_icon (const NautilusBookmark *bookmark, gint row) static void nautilus_bookmarks_window_restore_geometry (GtkWidget *window) { - const gchar *window_geometry; + const char *window_geometry; g_return_if_fail (GTK_IS_WINDOW (window)); - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); - window_geometry = nautilus_bookmarklist_get_window_geometry(bookmarks); + window_geometry = nautilus_bookmark_list_get_window_geometry(bookmarks); if (window_geometry != NULL) { - gint left, top, width, height; + int left, top, width, height; if (gnome_parse_geometry (window_geometry, &left, &top, &width, &height)) { @@ -358,26 +358,26 @@ void nautilus_bookmarks_window_save_geometry (GtkWidget *window) { g_return_if_fail (GTK_IS_WINDOW (window)); - g_return_if_fail (NAUTILUS_IS_BOOKMARKLIST (bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); /* Don't bother if window is already closed */ if (GTK_WIDGET_VISIBLE (window)) { - gchar *geometry_string; + char *geometry_string; geometry_string = gnome_geometry_string(window->window); - nautilus_bookmarklist_set_window_geometry (bookmarks, geometry_string); + nautilus_bookmark_list_set_window_geometry (bookmarks, geometry_string); g_free (geometry_string); } } static void -on_bookmarklist_changed(NautilusBookmarklist *bookmarks, gpointer data) +on_bookmark_list_changed (NautilusBookmarkList *bookmarks, gpointer data) { - g_return_if_fail(NAUTILUS_IS_BOOKMARKLIST(bookmarks)); + g_return_if_fail (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); /* maybe add logic here or in repopulate to save/restore selection */ - repopulate(); + repopulate (); } static void @@ -409,10 +409,10 @@ on_remove_button_clicked (GtkButton *button, * back to the top. */ gtk_signal_handler_block(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); - nautilus_bookmarklist_delete_item_at(bookmarks, get_selected_row()); + bookmark_list_changed_signalID); + nautilus_bookmark_list_delete_item_at(bookmarks, get_selected_row()); gtk_signal_handler_unblock(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); + bookmark_list_changed_signalID); gtk_clist_remove(GTK_CLIST(bookmark_list_widget), get_selected_row()); } @@ -420,32 +420,32 @@ on_remove_button_clicked (GtkButton *button, static void on_row_move (GtkCList *clist, - gint old_row, - gint new_row, + int old_row, + int new_row, gpointer user_data) { NautilusBookmark *bookmark; bookmark = nautilus_bookmark_copy( - nautilus_bookmarklist_item_at(bookmarks, old_row)); + nautilus_bookmark_list_item_at(bookmarks, old_row)); /* turn off list updating 'cuz otherwise the list-reordering code runs * after repopulate(), thus reordering the correctly-ordered list. */ gtk_signal_handler_block(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); - nautilus_bookmarklist_delete_item_at(bookmarks, old_row); - nautilus_bookmarklist_insert_item(bookmarks, bookmark, new_row); + bookmark_list_changed_signalID); + nautilus_bookmark_list_delete_item_at(bookmarks, old_row); + nautilus_bookmark_list_insert_item(bookmarks, bookmark, new_row); gtk_signal_handler_unblock(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); + bookmark_list_changed_signalID); gtk_object_destroy(GTK_OBJECT(bookmark)); } static void on_select_row (GtkCList *clist, - gint row, - gint column, + int row, + int column, GdkEventButton *event, gpointer user_data) { @@ -463,34 +463,33 @@ on_select_row (GtkCList *clist, static gboolean -on_text_field_focus_out_event (GtkWidget *widget, - GdkEventFocus *event, - gpointer user_data) +on_text_field_focus_out_event (GtkWidget *widget, + GdkEventFocus *event, + gpointer user_data) { - if (text_changed) - { + if (text_changed) { NautilusBookmark *bookmark; - guint selected_row; + guint selected_row; - g_assert(GTK_IS_ENTRY(name_field)); - g_assert(GTK_IS_ENTRY(uri_field)); + g_assert (GTK_IS_ENTRY (name_field)); + g_assert (GTK_IS_ENTRY (uri_field)); - bookmark = nautilus_bookmark_new_with_name ( - gtk_entry_get_text(GTK_ENTRY(uri_field)), - gtk_entry_get_text(GTK_ENTRY(name_field))); - selected_row = get_selected_row(); + bookmark = nautilus_bookmark_new_with_name + (gtk_entry_get_text (GTK_ENTRY (uri_field)), + gtk_entry_get_text (GTK_ENTRY (name_field))); + selected_row = get_selected_row (); /* turn off list updating 'cuz otherwise the list-reordering code runs * after repopulate(), thus reordering the correctly-ordered list. */ - gtk_signal_handler_block(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); - nautilus_bookmarklist_delete_item_at(bookmarks, selected_row); - nautilus_bookmarklist_insert_item(bookmarks, bookmark, selected_row); - gtk_signal_handler_unblock(GTK_OBJECT(bookmarks), - bookmarklist_changed_signalID); - - gtk_object_destroy(GTK_OBJECT(bookmark)); + gtk_signal_handler_block (GTK_OBJECT (bookmarks), + bookmark_list_changed_signalID); + nautilus_bookmark_list_delete_item_at (bookmarks, selected_row); + nautilus_bookmark_list_insert_item (bookmarks, bookmark, selected_row); + gtk_signal_handler_unblock (GTK_OBJECT (bookmarks), + bookmark_list_changed_signalID); + + gtk_object_destroy (GTK_OBJECT (bookmark)); } return FALSE; @@ -499,7 +498,7 @@ on_text_field_focus_out_event (GtkWidget *widget, static void on_uri_field_changed (GtkEditable *editable, - gpointer user_data) + gpointer user_data) { /* Remember that user has changed text so we * update real bookmark later. @@ -510,13 +509,13 @@ on_uri_field_changed (GtkEditable *editable, static gboolean on_window_delete_event (GtkWidget *widget, - GdkEvent *event, - gpointer user_data) + GdkEvent *event, + gpointer user_data) { nautilus_bookmarks_window_save_geometry (widget); /* Hide but don't destroy */ - gtk_widget_hide(widget); + gtk_widget_hide (widget); /* Seems odd to restore the geometry just after saving it, * and when the window is hidden, but this insures that @@ -529,60 +528,57 @@ on_window_delete_event (GtkWidget *widget, } static void -repopulate () +repopulate (void) { GtkCList *clist; - guint index; - gboolean selection_exists; + guint index; + gboolean selection_exists; - g_assert(GTK_IS_CLIST(bookmark_list_widget)); - g_assert(NAUTILUS_IS_BOOKMARKLIST(bookmarks)); + g_assert (GTK_IS_CLIST (bookmark_list_widget)); + g_assert (NAUTILUS_IS_BOOKMARK_LIST (bookmarks)); - clist = GTK_CLIST(bookmark_list_widget); + clist = GTK_CLIST (bookmark_list_widget); /* Freeze while mucking with content so it's not flashy */ - gtk_clist_freeze(clist); + gtk_clist_freeze (clist); /* Empty the list. */ - gtk_clist_clear(clist); + gtk_clist_clear (clist); /* Fill the list in with the bookmark names. */ - for (index = 0; index < nautilus_bookmarklist_length(bookmarks); ++index) - { - gchar *text[BOOKMARK_LIST_COLUMN_COUNT]; + for (index = 0; index < nautilus_bookmark_list_length(bookmarks); ++index) { + char *text[BOOKMARK_LIST_COLUMN_COUNT]; const NautilusBookmark *bookmark; - gint new_row; + int new_row; - bookmark = nautilus_bookmarklist_item_at(bookmarks, index); + bookmark = nautilus_bookmark_list_item_at(bookmarks, index); text[BOOKMARK_LIST_COLUMN_ICON] = NULL; text[BOOKMARK_LIST_COLUMN_NAME] = - (gchar *)nautilus_bookmark_get_name(bookmark); - new_row = gtk_clist_append(clist, text); + (char *)nautilus_bookmark_get_name (bookmark); + new_row = gtk_clist_append (clist, text); install_bookmark_icon (bookmark, new_row); } - + /* Set the sensitivity of widgets that require a selection */ selection_exists = get_selection_exists(); - gtk_widget_set_sensitive(remove_button, selection_exists); - gtk_widget_set_sensitive(name_field, selection_exists); - gtk_widget_set_sensitive(uri_field, selection_exists); + gtk_widget_set_sensitive (remove_button, selection_exists); + gtk_widget_set_sensitive (name_field, selection_exists); + gtk_widget_set_sensitive (uri_field, selection_exists); - if (!selection_exists) - { + if (!selection_exists) { /* Block signals to avoid modifying non-existent selected item. */ - gtk_signal_handler_block(GTK_OBJECT(name_field), - name_field_changed_signalID); - gtk_entry_set_text(GTK_ENTRY(name_field), ""); - gtk_signal_handler_unblock(GTK_OBJECT(name_field), - name_field_changed_signalID); - - gtk_signal_handler_block(GTK_OBJECT(uri_field), - uri_field_changed_signalID); - gtk_entry_set_text(GTK_ENTRY(uri_field), ""); - gtk_signal_handler_unblock(GTK_OBJECT(uri_field), - uri_field_changed_signalID); + gtk_signal_handler_block (GTK_OBJECT (name_field), + name_field_changed_signalID); + gtk_entry_set_text (GTK_ENTRY (name_field), ""); + gtk_signal_handler_unblock (GTK_OBJECT (name_field), + name_field_changed_signalID); + + gtk_signal_handler_block (GTK_OBJECT (uri_field), + uri_field_changed_signalID); + gtk_entry_set_text (GTK_ENTRY (uri_field), ""); + gtk_signal_handler_unblock (GTK_OBJECT (uri_field), + uri_field_changed_signalID); } - gtk_clist_thaw(GTK_CLIST(bookmark_list_widget)); + gtk_clist_thaw (GTK_CLIST (bookmark_list_widget)); } - diff --git a/src/nautilus-bookmarks-window.h b/src/nautilus-bookmarks-window.h index ac7f4d61b..d8d64098c 100644 --- a/src/nautilus-bookmarks-window.h +++ b/src/nautilus-bookmarks-window.h @@ -23,12 +23,12 @@ */ #ifndef NAUTILUS_BOOKMARKS_WINDOW_H -#define NAUTILUS_BOOKMARKS_WINDOW_H 1 +#define NAUTILUS_BOOKMARKS_WINDOW_H #include <gnome.h> -#include "nautilus-bookmarklist.h" +#include "nautilus-bookmark-list.h" -GtkWidget *create_bookmarks_window (NautilusBookmarklist *bookmarks); -void nautilus_bookmarks_window_save_geometry (GtkWidget *window); +GtkWidget *create_bookmarks_window (NautilusBookmarkList *bookmarks); +void nautilus_bookmarks_window_save_geometry (GtkWidget *window); #endif /* NAUTILUS_BOOKMARKS_WINDOW_H */ diff --git a/src/nautilus-location-bar.c b/src/nautilus-location-bar.c new file mode 100644 index 000000000..3f271db0b --- /dev/null +++ b/src/nautilus-location-bar.c @@ -0,0 +1,259 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-location-bar.c - Location bar for Nautilus + + Copyright (C) 1999, 2000 Free Software Foundation + Copyright (C) 2000 Eazel, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; see the file COPYING. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Author: Ettore Perazzoli <ettore@gnu.org> + DnD code added by Michael Meeks <michael@nuclecu.unam.mx> +*/ + +#include <config.h> +#include "nautilus-location-bar.h" + +#include <string.h> + +#include <gtk/gtksignal.h> +#include <gtk/gtkdnd.h> +#include <gtk/gtkeventbox.h> + +#include <libgnome/gnome-defs.h> +#include <libgnome/gnome-mime.h> +#include <libgnome/gnome-i18n.h> + +#include <libgnomeui/gnome-uidefs.h> + +#include <libnautilus/nautilus-string.h> +#include <libnautilus/nautilus-glib-extensions.h> +#include <libnautilus/nautilus-gtk-macros.h> + +#define NAUTILUS_DND_URI_LIST_TYPE "text/uri-list" +#define NAUTILUS_DND_TEXT_PLAIN_TYPE "text/plain" +#define NAUTILUS_DND_URL_TYPE "_NETSCAPE_URL" + +enum { + NAUTILUS_DND_MC_DESKTOP_ICON, + NAUTILUS_DND_URI_LIST, + NAUTILUS_DND_TEXT_PLAIN, + NAUTILUS_DND_URL, + NAUTILUS_DND_NTARGETS +}; + +enum { + LOCATION_CHANGED, + LAST_SIGNAL +}; +static guint signals[LAST_SIGNAL]; + +static GtkTargetEntry drag_types [] = { + { NAUTILUS_DND_URI_LIST_TYPE, 0, NAUTILUS_DND_URI_LIST }, + { NAUTILUS_DND_TEXT_PLAIN_TYPE, 0, NAUTILUS_DND_TEXT_PLAIN }, + { NAUTILUS_DND_URL_TYPE, 0, NAUTILUS_DND_URL } +}; + +static GtkTargetEntry drop_types [] = { + { NAUTILUS_DND_URI_LIST_TYPE, 0, NAUTILUS_DND_URI_LIST }, + { NAUTILUS_DND_TEXT_PLAIN_TYPE, 0, NAUTILUS_DND_TEXT_PLAIN }, + { NAUTILUS_DND_URL_TYPE, 0, NAUTILUS_DND_URL } +}; + +static void nautilus_location_bar_initialize_class (NautilusLocationBarClass *class); +static void nautilus_location_bar_initialize (NautilusLocationBar *bar); + +NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusLocationBar, nautilus_location_bar, GTK_TYPE_HBOX) + + +static void +drag_data_received_cb (GtkWidget *widget, + GdkDragContext *context, + int x, + int y, + GtkSelectionData *data, + guint info, + guint32 time) +{ + GList *names; + + g_assert (NAUTILUS_IS_LOCATION_BAR (widget)); + g_assert (data != NULL); + + names = gnome_uri_list_extract_uris (data->data); + + if (names == NULL) { + g_warning ("No D&D URI's"); + gtk_drag_finish (context, FALSE, FALSE, time); + return; + } + + /* FIXME: When more than one URI is dragged here, should we make windows? */ + if (g_list_length (names) > 1) { + g_warning ("FIXME: Should we make more windows?"); + } + + nautilus_location_bar_set_location (NAUTILUS_LOCATION_BAR (widget), + names->data); + + gnome_uri_list_free_strings (names); + + gtk_drag_finish (context, TRUE, FALSE, time); +} + +static void +drag_data_get_cb (GtkWidget *widget, + GdkDragContext *context, + GtkSelectionData *selection_data, + guint info, + guint32 time) +{ + char *entry_text; + + g_assert (NAUTILUS_IS_LOCATION_BAR (widget)); + g_assert (selection_data != NULL); + + entry_text = gtk_entry_get_text (NAUTILUS_LOCATION_BAR (widget)->entry); + + switch (info) { + case NAUTILUS_DND_URI_LIST: + case NAUTILUS_DND_TEXT_PLAIN: + case NAUTILUS_DND_URL: + gtk_selection_data_set (selection_data, + selection_data->target, + 8, (guchar *) entry_text, + nautilus_strlen (entry_text)); + break; + default: + g_assert_not_reached (); + } + + g_free (entry_text); +} + +static void +editable_activated_cb (GtkEditable *editable, + NautilusLocationBar *bar) +{ + g_assert (GTK_IS_EDITABLE (editable)); + g_assert (NAUTILUS_IS_LOCATION_BAR (bar)); + + gtk_signal_emit (GTK_OBJECT (bar), + signals[LOCATION_CHANGED], + gtk_entry_get_text (GTK_ENTRY (editable))); +} + + +static void +destroy (GtkObject *object) +{ + NautilusLocationBar *bar; + + bar = NAUTILUS_LOCATION_BAR (object); + + gtk_widget_destroy (GTK_WIDGET (bar->label)); + gtk_widget_destroy (GTK_WIDGET (bar->entry)); + + NAUTILUS_CALL_PARENT_CLASS (GTK_OBJECT_CLASS, destroy, (object)); +} + + +static void +nautilus_location_bar_initialize_class (NautilusLocationBarClass *class) +{ + GtkObjectClass *object_class; + + object_class = GTK_OBJECT_CLASS (class); + + object_class->destroy = destroy; + + signals[LOCATION_CHANGED] + = gtk_signal_new ("location_changed", + GTK_RUN_FIRST, + object_class->type, + GTK_SIGNAL_OFFSET (NautilusLocationBarClass, + location_changed), + gtk_marshal_NONE__STRING, + GTK_TYPE_NONE, 1, GTK_TYPE_STRING); + + gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL); +} + +static void +nautilus_location_bar_initialize (NautilusLocationBar *bar) +{ + GtkWidget *label; + GtkWidget *entry; + GtkWidget *event_box; + + event_box = gtk_event_box_new (); + gtk_container_set_border_width (GTK_CONTAINER (event_box), + GNOME_PAD_SMALL); + label = gtk_label_new (_("Location:")); + gtk_container_add (GTK_CONTAINER (event_box), label); + gtk_box_pack_start (GTK_BOX (bar), event_box, FALSE, TRUE, + GNOME_PAD_SMALL); + + entry = gtk_entry_new (); + gtk_signal_connect (GTK_OBJECT (entry), "activate", + editable_activated_cb, bar); + gtk_box_pack_start (GTK_BOX (bar), entry, TRUE, TRUE, 0); + + /* Drag source */ + gtk_drag_source_set (GTK_WIDGET (event_box), + GDK_BUTTON1_MASK | GDK_BUTTON3_MASK, + drag_types, NAUTILUS_N_ELEMENTS (drag_types), + GDK_ACTION_COPY | GDK_ACTION_MOVE); + gtk_signal_connect (GTK_OBJECT (event_box), "drag_data_get", + GTK_SIGNAL_FUNC (drag_data_get_cb), + bar); + + /* Drag dest. */ + gtk_drag_dest_set (GTK_WIDGET (bar), + GTK_DEST_DEFAULT_ALL, + drop_types, NAUTILUS_N_ELEMENTS (drop_types), + GDK_ACTION_COPY | GDK_ACTION_MOVE); + gtk_signal_connect (GTK_OBJECT (bar), "drag_data_received", + GTK_SIGNAL_FUNC (drag_data_received_cb), + NULL); + + gtk_widget_show (entry); + gtk_widget_show_all (event_box); + + bar->label = GTK_LABEL (label); + bar->entry = GTK_ENTRY (entry); +} + + +GtkWidget * +nautilus_location_bar_new (void) +{ + return gtk_widget_new (nautilus_location_bar_get_type (), NULL); +} + +void +nautilus_location_bar_set_location (NautilusLocationBar *bar, + const char *location) +{ + g_return_if_fail (NAUTILUS_IS_LOCATION_BAR (bar)); + + gtk_entry_set_text (bar->entry, + location == NULL ? "" : location); + + gtk_signal_emit (GTK_OBJECT (bar), + signals[LOCATION_CHANGED], + location); +} diff --git a/src/nautilus-location-bar.h b/src/nautilus-location-bar.h new file mode 100644 index 000000000..0496a2d9d --- /dev/null +++ b/src/nautilus-location-bar.h @@ -0,0 +1,59 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-location-bar.h - Location bar for Nautilus + + Copyright (C) 1999, 2000 Free Software Foundation + Copyright (C) 2000 Eazel, Inc. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2 of the + License, or (at your option) any later version. + + This program 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 + General Public License for more details. + + You should have received a copy of the GNU General Public + License along with this program; see the file COPYING. If not, + write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. + + Author: Ettore Perazzoli <ettore@gnu.org> +*/ + +#ifndef NAUTILUS_LOCATION_BAR_H +#define NAUTILUS_LOCATION_BAR_H + +#include <gtk/gtkhbox.h> +#include <gtk/gtklabel.h> +#include <gtk/gtkentry.h> + +#define NAUTILUS_LOCATION_BAR(obj) \ + GTK_CHECK_CAST (obj, nautilus_location_bar_get_type (), NautilusLocationBar) +#define NAUTILUS_LOCATION_BAR_CLASS(klass) \ + GTK_CHECK_CLASS_CAST (klass, nautilus_location_bar_get_type (), NautilusLocationBarClass) +#define NAUTILUS_IS_LOCATION_BAR(obj) \ + GTK_CHECK_TYPE (obj, nautilus_location_bar_get_type ()) + +typedef struct NautilusLocationBar { + GtkHBox hbox; + + GtkLabel *label; + GtkEntry *entry; +} NautilusLocationBar; + +typedef struct { + GtkHBoxClass parent_class; + + void (*location_changed) (NautilusLocationBar *location_bar, + const char *location); +} NautilusLocationBarClass; + +GtkType nautilus_location_bar_get_type (void); +GtkWidget* nautilus_location_bar_new (void); +void nautilus_location_bar_set_location (NautilusLocationBar *bar, + const char *location); + +#endif /* NAUTILUS_LOCATION_BAR_H */ diff --git a/src/nautilus-navigation-window-menus.c b/src/nautilus-navigation-window-menus.c index 90bc09137..692e9954c 100644 --- a/src/nautilus-navigation-window-menus.c +++ b/src/nautilus-navigation-window-menus.c @@ -23,7 +23,7 @@ Author: John Sullivan <sullivan@eazel.com> */ -#include "nautilus-bookmarklist.h" +#include "nautilus-bookmark-list.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "ntl-app.h" @@ -47,8 +47,8 @@ static void append_separator_to_menu (NautilusWindow static void clear_appended_bookmark_items (NautilusWindow *window, const char *menu_path, const char *last_static_item_path); -static NautilusBookmarklist *get_bookmark_list (); -static GtkWidget *get_bookmarks_window (); +static NautilusBookmarkList *get_bookmark_list (void); +static GtkWidget *get_bookmarks_window (void); static void nautilus_window_about_cb (GtkWidget *widget, NautilusWindow *window); static void debug_menu_show_color_picker_cb (GtkWidget *widget, @@ -98,7 +98,7 @@ static void file_menu_exit_cb (GtkWidget *widget, gpointer data) { - gtk_main_quit(); + gtk_main_quit (); } static void @@ -398,20 +398,20 @@ clear_appended_bookmark_items (NautilusWindow *window, g_list_free (children); } -static NautilusBookmarklist * -get_bookmark_list () +static NautilusBookmarkList * +get_bookmark_list (void) { - static NautilusBookmarklist *bookmarks = NULL; + static NautilusBookmarkList *bookmarks = NULL; if (bookmarks == NULL) { - bookmarks = nautilus_bookmarklist_new (); + bookmarks = nautilus_bookmark_list_new (); } return bookmarks; } static GtkWidget * -get_bookmarks_window () +get_bookmarks_window (void) { static GtkWidget *bookmarks_window = NULL; if (bookmarks_window == NULL) @@ -429,7 +429,7 @@ get_bookmarks_window () * Called when application exits; don't call from anywhere else. **/ void -nautilus_bookmarks_exiting () +nautilus_bookmarks_exiting (void) { nautilus_bookmarks_window_save_geometry (get_bookmarks_window ()); } @@ -489,9 +489,8 @@ nautilus_window_add_bookmark_for_current_location (NautilusWindow *window) bookmark = nautilus_bookmark_new (nautilus_window_get_requested_uri(window)); - if (!nautilus_bookmarklist_contains (get_bookmark_list (), bookmark)) - { - nautilus_bookmarklist_append (get_bookmark_list (), bookmark); + if (!nautilus_bookmark_list_contains (get_bookmark_list (), bookmark)) { + nautilus_bookmark_list_append (get_bookmark_list (), bookmark); } gtk_object_destroy(GTK_OBJECT(bookmark)); } @@ -610,7 +609,7 @@ nautilus_window_initialize_menus (NautilusWindow *window) static void refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) { - NautilusBookmarklist *bookmarks; + NautilusBookmarkList *bookmarks; guint bookmark_count; guint index; @@ -621,7 +620,7 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) /* Remove old set of bookmarks. */ clear_appended_bookmark_items (window, "/Bookmarks", "/Bookmarks/Edit Bookmarks..."); - bookmark_count = nautilus_bookmarklist_length (bookmarks); + bookmark_count = nautilus_bookmark_list_length (bookmarks); /* Add separator before bookmarks, unless there are no bookmarks. */ if (bookmark_count > 0) { @@ -635,7 +634,7 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) path = g_strdup_printf ("/Bookmarks/Bookmark%d", index); append_bookmark_to_menu (window, - nautilus_bookmarklist_item_at (bookmarks, index), + nautilus_bookmark_list_item_at (bookmarks, index), path); g_free (path); } @@ -690,4 +689,3 @@ update_eazel_theme_menu_item (NautilusWindow *window) NAUTILUS_PREFERENCES_ICON_THEME), "eazel") == 0); } - diff --git a/src/nautilus-navigation-window.c b/src/nautilus-navigation-window.c index c6996d84f..751626e09 100644 --- a/src/nautilus-navigation-window.c +++ b/src/nautilus-navigation-window.c @@ -26,15 +26,16 @@ */ /* ntl-window.c: Implementation of the main window object */ -#include "config.h" +#include <config.h> +#include "ntl-window-private.h" + #include <gnome.h> #include <math.h> #include "nautilus.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include "ntl-index-panel.h" -#include "ntl-window-private.h" #include "ntl-miniicon.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include <libnautilus/nautilus-gtk-extensions.h> @@ -504,7 +505,7 @@ nautilus_window_constructed(NautilusWindow *window) location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - window->ent_uri = explorer_location_bar_new(); + window->ent_uri = nautilus_location_bar_new(); gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", nautilus_window_goto_uri_cb, window); gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); diff --git a/src/nautilus-object-window.c b/src/nautilus-object-window.c index c6996d84f..751626e09 100644 --- a/src/nautilus-object-window.c +++ b/src/nautilus-object-window.c @@ -26,15 +26,16 @@ */ /* ntl-window.c: Implementation of the main window object */ -#include "config.h" +#include <config.h> +#include "ntl-window-private.h" + #include <gnome.h> #include <math.h> #include "nautilus.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include "ntl-index-panel.h" -#include "ntl-window-private.h" #include "ntl-miniicon.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include <libnautilus/nautilus-gtk-extensions.h> @@ -504,7 +505,7 @@ nautilus_window_constructed(NautilusWindow *window) location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - window->ent_uri = explorer_location_bar_new(); + window->ent_uri = nautilus_location_bar_new(); gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", nautilus_window_goto_uri_cb, window); gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); diff --git a/src/nautilus-spatial-window.c b/src/nautilus-spatial-window.c index c6996d84f..751626e09 100644 --- a/src/nautilus-spatial-window.c +++ b/src/nautilus-spatial-window.c @@ -26,15 +26,16 @@ */ /* ntl-window.c: Implementation of the main window object */ -#include "config.h" +#include <config.h> +#include "ntl-window-private.h" + #include <gnome.h> #include <math.h> #include "nautilus.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include "ntl-index-panel.h" -#include "ntl-window-private.h" #include "ntl-miniicon.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include <libnautilus/nautilus-gtk-extensions.h> @@ -504,7 +505,7 @@ nautilus_window_constructed(NautilusWindow *window) location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - window->ent_uri = explorer_location_bar_new(); + window->ent_uri = nautilus_location_bar_new(); gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", nautilus_window_goto_uri_cb, window); gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); diff --git a/src/nautilus-window-manage-views.c b/src/nautilus-window-manage-views.c index 37feeeda1..1a76fb0d1 100644 --- a/src/nautilus-window-manage-views.c +++ b/src/nautilus-window-manage-views.c @@ -34,7 +34,7 @@ #include "nautilus.h" #include "ntl-window-private.h" #include "ntl-index-panel.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include <libnautilus/nautilus-bookmark.h> #include <libnautilus/nautilus-gtk-extensions.h> #include <libnautilus/nautilus-metadata.h> @@ -64,7 +64,7 @@ nautilus_window_progress_indicate(NautilusWindow *window, ProgressType type, dou /* If it was an error loading a URI that had been dragged to the location bar, we might need to reset the URI */ the_uri = window->ni?window->ni->requested_uri:""; - explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), + nautilus_location_bar_set_location(NAUTILUS_LOCATION_BAR(window->ent_uri), the_uri); } } @@ -285,8 +285,8 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo nautilus_window_allow_back(window, window->back_list != NULL); nautilus_window_allow_forward(window, window->forward_list != NULL); - explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), - window->ni->requested_uri); + nautilus_location_bar_set_location(NAUTILUS_LOCATION_BAR(window->ent_uri), + window->ni->requested_uri); nautilus_index_panel_set_uri (NAUTILUS_INDEX_PANEL (window->index_panel), window->ni->requested_uri); nautilus_window_refresh_title (window); diff --git a/src/nautilus-window-menus.c b/src/nautilus-window-menus.c index 90bc09137..692e9954c 100644 --- a/src/nautilus-window-menus.c +++ b/src/nautilus-window-menus.c @@ -23,7 +23,7 @@ Author: John Sullivan <sullivan@eazel.com> */ -#include "nautilus-bookmarklist.h" +#include "nautilus-bookmark-list.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" #include "ntl-app.h" @@ -47,8 +47,8 @@ static void append_separator_to_menu (NautilusWindow static void clear_appended_bookmark_items (NautilusWindow *window, const char *menu_path, const char *last_static_item_path); -static NautilusBookmarklist *get_bookmark_list (); -static GtkWidget *get_bookmarks_window (); +static NautilusBookmarkList *get_bookmark_list (void); +static GtkWidget *get_bookmarks_window (void); static void nautilus_window_about_cb (GtkWidget *widget, NautilusWindow *window); static void debug_menu_show_color_picker_cb (GtkWidget *widget, @@ -98,7 +98,7 @@ static void file_menu_exit_cb (GtkWidget *widget, gpointer data) { - gtk_main_quit(); + gtk_main_quit (); } static void @@ -398,20 +398,20 @@ clear_appended_bookmark_items (NautilusWindow *window, g_list_free (children); } -static NautilusBookmarklist * -get_bookmark_list () +static NautilusBookmarkList * +get_bookmark_list (void) { - static NautilusBookmarklist *bookmarks = NULL; + static NautilusBookmarkList *bookmarks = NULL; if (bookmarks == NULL) { - bookmarks = nautilus_bookmarklist_new (); + bookmarks = nautilus_bookmark_list_new (); } return bookmarks; } static GtkWidget * -get_bookmarks_window () +get_bookmarks_window (void) { static GtkWidget *bookmarks_window = NULL; if (bookmarks_window == NULL) @@ -429,7 +429,7 @@ get_bookmarks_window () * Called when application exits; don't call from anywhere else. **/ void -nautilus_bookmarks_exiting () +nautilus_bookmarks_exiting (void) { nautilus_bookmarks_window_save_geometry (get_bookmarks_window ()); } @@ -489,9 +489,8 @@ nautilus_window_add_bookmark_for_current_location (NautilusWindow *window) bookmark = nautilus_bookmark_new (nautilus_window_get_requested_uri(window)); - if (!nautilus_bookmarklist_contains (get_bookmark_list (), bookmark)) - { - nautilus_bookmarklist_append (get_bookmark_list (), bookmark); + if (!nautilus_bookmark_list_contains (get_bookmark_list (), bookmark)) { + nautilus_bookmark_list_append (get_bookmark_list (), bookmark); } gtk_object_destroy(GTK_OBJECT(bookmark)); } @@ -610,7 +609,7 @@ nautilus_window_initialize_menus (NautilusWindow *window) static void refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) { - NautilusBookmarklist *bookmarks; + NautilusBookmarkList *bookmarks; guint bookmark_count; guint index; @@ -621,7 +620,7 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) /* Remove old set of bookmarks. */ clear_appended_bookmark_items (window, "/Bookmarks", "/Bookmarks/Edit Bookmarks..."); - bookmark_count = nautilus_bookmarklist_length (bookmarks); + bookmark_count = nautilus_bookmark_list_length (bookmarks); /* Add separator before bookmarks, unless there are no bookmarks. */ if (bookmark_count > 0) { @@ -635,7 +634,7 @@ refresh_bookmarks_in_bookmarks_menu (NautilusWindow *window) path = g_strdup_printf ("/Bookmarks/Bookmark%d", index); append_bookmark_to_menu (window, - nautilus_bookmarklist_item_at (bookmarks, index), + nautilus_bookmark_list_item_at (bookmarks, index), path); g_free (path); } @@ -690,4 +689,3 @@ update_eazel_theme_menu_item (NautilusWindow *window) NAUTILUS_PREFERENCES_ICON_THEME), "eazel") == 0); } - diff --git a/src/nautilus-window.c b/src/nautilus-window.c index c6996d84f..751626e09 100644 --- a/src/nautilus-window.c +++ b/src/nautilus-window.c @@ -26,15 +26,16 @@ */ /* ntl-window.c: Implementation of the main window object */ -#include "config.h" +#include <config.h> +#include "ntl-window-private.h" + #include <gnome.h> #include <math.h> #include "nautilus.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include "ntl-index-panel.h" -#include "ntl-window-private.h" #include "ntl-miniicon.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include <libnautilus/nautilus-gtk-extensions.h> @@ -504,7 +505,7 @@ nautilus_window_constructed(NautilusWindow *window) location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - window->ent_uri = explorer_location_bar_new(); + window->ent_uri = nautilus_location_bar_new(); gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", nautilus_window_goto_uri_cb, window); gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); diff --git a/src/ntl-window-msgs.c b/src/ntl-window-msgs.c index 37feeeda1..1a76fb0d1 100644 --- a/src/ntl-window-msgs.c +++ b/src/ntl-window-msgs.c @@ -34,7 +34,7 @@ #include "nautilus.h" #include "ntl-window-private.h" #include "ntl-index-panel.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include <libnautilus/nautilus-bookmark.h> #include <libnautilus/nautilus-gtk-extensions.h> #include <libnautilus/nautilus-metadata.h> @@ -64,7 +64,7 @@ nautilus_window_progress_indicate(NautilusWindow *window, ProgressType type, dou /* If it was an error loading a URI that had been dragged to the location bar, we might need to reset the URI */ the_uri = window->ni?window->ni->requested_uri:""; - explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), + nautilus_location_bar_set_location(NAUTILUS_LOCATION_BAR(window->ent_uri), the_uri); } } @@ -285,8 +285,8 @@ nautilus_window_update_internals(NautilusWindow *window, NautilusNavigationInfo nautilus_window_allow_back(window, window->back_list != NULL); nautilus_window_allow_forward(window, window->forward_list != NULL); - explorer_location_bar_set_uri_string(EXPLORER_LOCATION_BAR(window->ent_uri), - window->ni->requested_uri); + nautilus_location_bar_set_location(NAUTILUS_LOCATION_BAR(window->ent_uri), + window->ni->requested_uri); nautilus_index_panel_set_uri (NAUTILUS_INDEX_PANEL (window->index_panel), window->ni->requested_uri); nautilus_window_refresh_title (window); diff --git a/src/ntl-window.c b/src/ntl-window.c index c6996d84f..751626e09 100644 --- a/src/ntl-window.c +++ b/src/ntl-window.c @@ -26,15 +26,16 @@ */ /* ntl-window.c: Implementation of the main window object */ -#include "config.h" +#include <config.h> +#include "ntl-window-private.h" + #include <gnome.h> #include <math.h> #include "nautilus.h" #include "nautilus-bookmarks-window.h" #include "nautilus-signaller.h" -#include "explorer-location-bar.h" +#include "nautilus-location-bar.h" #include "ntl-index-panel.h" -#include "ntl-window-private.h" #include "ntl-miniicon.h" #include <gdk-pixbuf/gdk-pixbuf.h> #include <libnautilus/nautilus-gtk-extensions.h> @@ -504,7 +505,7 @@ nautilus_window_constructed(NautilusWindow *window) location_bar_box = gtk_hbox_new(FALSE, GNOME_PAD); gtk_container_set_border_width(GTK_CONTAINER(location_bar_box), GNOME_PAD_SMALL); - window->ent_uri = explorer_location_bar_new(); + window->ent_uri = nautilus_location_bar_new(); gtk_signal_connect(GTK_OBJECT(window->ent_uri), "location_changed", nautilus_window_goto_uri_cb, window); gtk_box_pack_start(GTK_BOX(location_bar_box), window->ent_uri, TRUE, TRUE, GNOME_PAD_SMALL); |