diff options
author | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-03-12 12:58:20 +0000 |
---|---|---|
committer | Ramiro Estrugo <ramiro@src.gnome.org> | 2000-03-12 12:58:20 +0000 |
commit | 63c6d54af8f166fa74f16d8efcaad6b443930c9d (patch) | |
tree | 2fa6ebb176e54ff0823ce2bf8dc2177577ca9a38 | |
parent | 374870d5ab79de33a3c2b60faf7f76553ade028d (diff) | |
download | nautilus-63c6d54af8f166fa74f16d8efcaad6b443930c9d.tar.gz |
Moved global preferences to libnautilus.
-rw-r--r-- | ChangeLog-20000414 | 12 | ||||
-rw-r--r-- | libnautilus-extensions/Makefile.am | 20 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.c | 368 | ||||
-rw-r--r-- | libnautilus-extensions/nautilus-global-preferences.h (renamed from src/nautilus-global-preferences.h) | 22 | ||||
-rw-r--r-- | libnautilus-private/Makefile.am | 20 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.c | 368 | ||||
-rw-r--r-- | libnautilus-private/nautilus-global-preferences.h | 63 | ||||
-rw-r--r-- | libnautilus/Makefile.am | 20 | ||||
-rw-r--r-- | libnautilus/nautilus-global-preferences.c | 368 | ||||
-rw-r--r-- | libnautilus/nautilus-global-preferences.h | 63 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/nautilus-global-preferences.c | 393 |
12 files changed, 1297 insertions, 422 deletions
diff --git a/ChangeLog-20000414 b/ChangeLog-20000414 index 4fafb9927..d3c58fdcc 100644 --- a/ChangeLog-20000414 +++ b/ChangeLog-20000414 @@ -1,3 +1,15 @@ +2000-03-12 Ramiro Estrugo <ramiro@eazel.com> + + * libnautilus/Makefile.am, + libnautilus/nautilus-global-preferences.c: New file + libnautilus/nautilus-global-preferences.h: New file + + * src/Makefile.am, + src/nautilus-global-preferences.c: Removed + src/nautilus-global-preferences.h: Removed + + Moved global preferences to libnautilus. + 2000-03-10 Darin Adler <darin@eazel.com> * libnautilus/nautilus-icons-view-icon-item.c diff --git a/libnautilus-extensions/Makefile.am b/libnautilus-extensions/Makefile.am index 635806220..d30ef7e69 100644 --- a/libnautilus-extensions/Makefile.am +++ b/libnautilus-extensions/Makefile.am @@ -1,3 +1,5 @@ +NULL= + lib_LTLIBRARIES=libnautilus.la INCLUDES=-I$(top_srcdir) -I$(top_builddir) \ @@ -25,21 +27,21 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ - libnautilus.h \ bonobo-stream-vfs.h \ gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ - nautilus.h \ + libnautilus.h \ nautilus-alloc.h \ nautilus-background.h \ nautilus-bookmark.h \ nautilus-debug.h \ nautilus-directory.h \ - nautilus-file.h \ nautilus-file-utilities.h \ + nautilus-file.h \ nautilus-glib-extensions.h \ + nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ nautilus-gtk-extensions.h \ nautilus-icon-factory.h \ @@ -49,9 +51,11 @@ libnautilusinclude_HEADERS= \ nautilus-self-checks.h \ nautilus-string.h \ nautilus-zoomable.h \ + nautilus.h \ ntl-content-view-frame.h \ ntl-meta-view-frame.h \ - ntl-view-frame.h + ntl-view-frame.h \ + $(NULL) libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ @@ -60,16 +64,17 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ gnome-icon-container.c \ gtkflist.c \ gtkscrollframe.c \ - nautilus-background.c \ nautilus-background-canvas-group.c \ + nautilus-background.c \ nautilus-bookmark.c \ nautilus-debug.c \ nautilus-default-file-icon.c \ nautilus-default-file-icon.h \ nautilus-directory.c \ - nautilus-file.c \ nautilus-file-utilities.c \ + nautilus-file.c \ nautilus-glib-extensions.c \ + nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ nautilus-gtk-extensions.c \ nautilus-icon-factory.c \ @@ -82,7 +87,8 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ntl-content-view-frame.c \ ntl-meta-view-frame.c \ ntl-view-frame.c \ - $(fsextension_idl_sources) + $(fsextension_idl_sources) \ + $(NULL) $(nautilus_idl_sources): nautilus_idl_stamp $(fsextension_idl_sources): fsextension_idl_stamp diff --git a/libnautilus-extensions/nautilus-global-preferences.c b/libnautilus-extensions/nautilus-global-preferences.c new file mode 100644 index 000000000..0849c7e01 --- /dev/null +++ b/libnautilus-extensions/nautilus-global-preferences.c @@ -0,0 +1,368 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-prefs-dialog.c - Implementation for preferences dialog. + + 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: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include "nautilus-global-preferences.h" +#include <nautilus-widgets/nautilus-preferences-group.h> +#include <nautilus-widgets/nautilus-preferences-item.h> +#include <nautilus-widgets/nautilus-preferences-dialog.h> + +#include <gnome.h> + +BEGIN_GNOME_DECLS + + +#include <libnautilus/nautilus-glib-extensions.h> + + +/* + * Constants + */ +#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences") + +/* Private stuff */ +static GtkWidget *global_preferences_create_dialog (void); +static GtkWidget *global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name); +static GtkWidget *global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs); +static GtkWidget *global_preferences_get_dialog (void); +static void global_preferences_register_static (NautilusPreferences *prefs); +static void global_preferences_register_dynamic (NautilusPreferences *prefs); + + +// static GtkWidget *global_preferences_dialog = NULL; +// static GtkObject *global_preferences = NULL; + +static GtkWidget *panes[3]; + +static const gchar *global_preferences_window_option_pref_names[] = +{ + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING +}; + +static const gchar *global_preferences_meta_view_names[] = +{ + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH +}; + +static const gchar * global_preferences_user_level_names[] = +{ + "novice", + "intermediate", + "hacker", + "ettore" +}; + +static const gchar * global_preferences_user_level_descriptions[] = +{ + "Novice", + "Intermediate", + "Hacker", + "Ettore" +}; + +static const gint global_preferences_user_level_values[] = +{ + NAUTILUS_USER_LEVEL_NOVICE, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + NAUTILUS_USER_LEVEL_HACKER, + NAUTILUS_USER_LEVEL_ETTORE +}; + +static NautilusPreferencesEnumData global_preferences_user_level_data = +{ + global_preferences_user_level_names, + global_preferences_user_level_descriptions, + global_preferences_user_level_values, + NAUTILUS_N_ELEMENTS (global_preferences_user_level_names) +}; + +static NautilusPreferencesInfo global_preferences_static_info[] = +{ + { + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL, + "User Level", + GTK_TYPE_ENUM, + FALSE, + (gpointer) &global_preferences_user_level_data + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + "Create new window for each new page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING, + "Do not open more than one window with the same page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, +}; + +/* + * Private stuff + */ +static GtkWidget * +global_preferences_create_dialog (void) +{ + GtkWidget *prefs_dialog; + NautilusPreferencesBox *prefs_box; + GtkWidget *user_level_group; + + prefs_dialog = nautilus_preferences_dialog_new (GLOBAL_PREFERENCES_DIALOG_TITLE); + + prefs_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box (NAUTILUS_PREFERENCES_DIALOG (prefs_dialog))); + + panes[0] = nautilus_preferences_box_add_pane (prefs_box, + "User Level", + "User Level Something"); + + user_level_group = global_prefernces_create_enum_group (panes[0], + "User Level", + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL); + + panes[1] = nautilus_preferences_box_add_pane (prefs_box, + "Window Options", + "Window Options Something"); + + global_preferences_create_check_group (panes[1], + "Basic window options", + global_preferences_window_option_pref_names, + NAUTILUS_N_ELEMENTS (global_preferences_window_option_pref_names)); + + panes[2] = nautilus_preferences_box_add_pane (prefs_box, + "Meta Views", + "Meta Views Something"); + + global_preferences_create_check_group (panes[2], + "Meta Views", + global_preferences_meta_view_names, + NAUTILUS_N_ELEMENTS (global_preferences_meta_view_names)); + + return prefs_dialog; +} + +static GtkWidget * +global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs) +{ + GtkWidget *group; + guint i; + + group = nautilus_preferences_group_new (group_title); + + for (i = 0; i < num_prefs; i++) + { + GtkWidget *item; + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_names[i], + NAUTILUS_PREFERENCES_ITEM_BOOL); + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), + item); + + gtk_widget_show (item); + } + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static GtkWidget * +global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name) +{ + GtkWidget *group; + GtkWidget *item; + + group = nautilus_preferences_group_new (group_title); + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_name, + NAUTILUS_PREFERENCES_ITEM_ENUM); + + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), item); + + gtk_widget_show (item); + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static void +global_preferences_register_static (NautilusPreferences *prefs) +{ + guint i; + + g_assert (prefs != NULL); + + /* Register the static prefs */ + for (i = 0; i < NAUTILUS_N_ELEMENTS (global_preferences_static_info); i++) + { + nautilus_preferences_register_from_info (prefs, &global_preferences_static_info[i]); + } +} + +static void +global_preferences_register_dynamic (NautilusPreferences *prefs) +{ + g_assert (prefs != NULL); + + /* + * Presummably, the following would be registered + * only if the component was present. Once we + * have smarter activation, that will be case. + * + * For now turn onall the ones we know off. + */ + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + "History View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH, + "Web Search View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + "Annotations", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + "Help Contents", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + "Help Index", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + "Help Search", + GTK_TYPE_BOOL, + FALSE, + NULL); +} + +static GtkWidget * +global_preferences_get_dialog (void) +{ + static GtkWidget * global_prefs_dialog = NULL; + + NautilusPreferences * global_prefs = nautilus_preferences_get_global_preferences (); + + if (!global_prefs) + { + g_warning ("something went terribly wrong with implicit prefs initialization\n"); + + return NULL; + } + + if (!global_prefs_dialog) + { + global_prefs_dialog = global_preferences_create_dialog (); + } + + return global_prefs_dialog; +} + +/* + * Public functions + */ +void +nautilus_global_preferences_show_dialog (void) +{ + GtkWidget * global_prefs_dialog = global_preferences_get_dialog (); + + gtk_widget_show (global_prefs_dialog); +} + +void +nautilus_global_preferences_shutdown (void) +{ + GtkWidget * global_prefs_dialog; + GtkObject * global_prefs; + + return; + + global_prefs_dialog = global_preferences_get_dialog (); + + global_prefs = GTK_OBJECT (nautilus_preferences_get_global_preferences ()); + + gtk_widget_unref (global_prefs_dialog); + + gtk_object_unref (global_prefs); +} + +void +nautilus_global_preferences_initialize (void) +{ + static gboolean initialized = FALSE; + + if (!initialized) + { + initialized = TRUE; + + global_preferences_register_static (nautilus_preferences_get_global_preferences ()); + global_preferences_register_dynamic (nautilus_preferences_get_global_preferences ()); + } +} diff --git a/src/nautilus-global-preferences.h b/libnautilus-extensions/nautilus-global-preferences.h index c3a1efde6..3bd653aaa 100644 --- a/src/nautilus-global-preferences.h +++ b/libnautilus-extensions/nautilus-global-preferences.h @@ -30,9 +30,19 @@ BEGIN_GNOME_DECLS -#define NAUTILUS_PREFS_WINDOW_ALWAYS_NEW "/nautilus/prefs/window_always_new" -#define NAUTILUS_PREFS_WINDOW_SEARCH_EXISTING "/nautilus/prefs/window_search_existing" -#define NAUTILUS_PREFS_USER_LEVEL "/nautilus/prefs/user_level" +/* User level */ +#define NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL "/nautilus/prefs/user_level" + +/* Window options */ +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/prefs/window_always_new" +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING "/nautilus/prefs/window_search_existing" + +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS "/nautilus/prefs/metaviews::ntl_notes_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS "/nautilus/prefs/metaviews::hyperbola_navigation_tree" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX "/nautilus/prefs/metaviews::hyperbola_navigation_index" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH "/nautilus/prefs/metaviews::hyperbola_navigation_search" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY "/nautilus/prefs/metaviews::ntl_history_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH "/nautilus/prefs/metaviews::ntl_websearch_view" enum { @@ -42,9 +52,9 @@ enum NAUTILUS_USER_LEVEL_ETTORE }; -void nautilus_prefs_global_shutdown (void); -void nautilus_prefs_global_show_dialog (void); -NautilusPrefs *nautilus_prefs_global_get_prefs (void); +void nautilus_global_preferences_shutdown (void); +void nautilus_global_preferences_initialize (void); +void nautilus_global_preferences_show_dialog (void); BEGIN_GNOME_DECLS diff --git a/libnautilus-private/Makefile.am b/libnautilus-private/Makefile.am index 635806220..d30ef7e69 100644 --- a/libnautilus-private/Makefile.am +++ b/libnautilus-private/Makefile.am @@ -1,3 +1,5 @@ +NULL= + lib_LTLIBRARIES=libnautilus.la INCLUDES=-I$(top_srcdir) -I$(top_builddir) \ @@ -25,21 +27,21 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ - libnautilus.h \ bonobo-stream-vfs.h \ gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ - nautilus.h \ + libnautilus.h \ nautilus-alloc.h \ nautilus-background.h \ nautilus-bookmark.h \ nautilus-debug.h \ nautilus-directory.h \ - nautilus-file.h \ nautilus-file-utilities.h \ + nautilus-file.h \ nautilus-glib-extensions.h \ + nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ nautilus-gtk-extensions.h \ nautilus-icon-factory.h \ @@ -49,9 +51,11 @@ libnautilusinclude_HEADERS= \ nautilus-self-checks.h \ nautilus-string.h \ nautilus-zoomable.h \ + nautilus.h \ ntl-content-view-frame.h \ ntl-meta-view-frame.h \ - ntl-view-frame.h + ntl-view-frame.h \ + $(NULL) libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ @@ -60,16 +64,17 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ gnome-icon-container.c \ gtkflist.c \ gtkscrollframe.c \ - nautilus-background.c \ nautilus-background-canvas-group.c \ + nautilus-background.c \ nautilus-bookmark.c \ nautilus-debug.c \ nautilus-default-file-icon.c \ nautilus-default-file-icon.h \ nautilus-directory.c \ - nautilus-file.c \ nautilus-file-utilities.c \ + nautilus-file.c \ nautilus-glib-extensions.c \ + nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ nautilus-gtk-extensions.c \ nautilus-icon-factory.c \ @@ -82,7 +87,8 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ntl-content-view-frame.c \ ntl-meta-view-frame.c \ ntl-view-frame.c \ - $(fsextension_idl_sources) + $(fsextension_idl_sources) \ + $(NULL) $(nautilus_idl_sources): nautilus_idl_stamp $(fsextension_idl_sources): fsextension_idl_stamp diff --git a/libnautilus-private/nautilus-global-preferences.c b/libnautilus-private/nautilus-global-preferences.c new file mode 100644 index 000000000..0849c7e01 --- /dev/null +++ b/libnautilus-private/nautilus-global-preferences.c @@ -0,0 +1,368 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-prefs-dialog.c - Implementation for preferences dialog. + + 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: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include "nautilus-global-preferences.h" +#include <nautilus-widgets/nautilus-preferences-group.h> +#include <nautilus-widgets/nautilus-preferences-item.h> +#include <nautilus-widgets/nautilus-preferences-dialog.h> + +#include <gnome.h> + +BEGIN_GNOME_DECLS + + +#include <libnautilus/nautilus-glib-extensions.h> + + +/* + * Constants + */ +#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences") + +/* Private stuff */ +static GtkWidget *global_preferences_create_dialog (void); +static GtkWidget *global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name); +static GtkWidget *global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs); +static GtkWidget *global_preferences_get_dialog (void); +static void global_preferences_register_static (NautilusPreferences *prefs); +static void global_preferences_register_dynamic (NautilusPreferences *prefs); + + +// static GtkWidget *global_preferences_dialog = NULL; +// static GtkObject *global_preferences = NULL; + +static GtkWidget *panes[3]; + +static const gchar *global_preferences_window_option_pref_names[] = +{ + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING +}; + +static const gchar *global_preferences_meta_view_names[] = +{ + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH +}; + +static const gchar * global_preferences_user_level_names[] = +{ + "novice", + "intermediate", + "hacker", + "ettore" +}; + +static const gchar * global_preferences_user_level_descriptions[] = +{ + "Novice", + "Intermediate", + "Hacker", + "Ettore" +}; + +static const gint global_preferences_user_level_values[] = +{ + NAUTILUS_USER_LEVEL_NOVICE, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + NAUTILUS_USER_LEVEL_HACKER, + NAUTILUS_USER_LEVEL_ETTORE +}; + +static NautilusPreferencesEnumData global_preferences_user_level_data = +{ + global_preferences_user_level_names, + global_preferences_user_level_descriptions, + global_preferences_user_level_values, + NAUTILUS_N_ELEMENTS (global_preferences_user_level_names) +}; + +static NautilusPreferencesInfo global_preferences_static_info[] = +{ + { + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL, + "User Level", + GTK_TYPE_ENUM, + FALSE, + (gpointer) &global_preferences_user_level_data + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + "Create new window for each new page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING, + "Do not open more than one window with the same page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, +}; + +/* + * Private stuff + */ +static GtkWidget * +global_preferences_create_dialog (void) +{ + GtkWidget *prefs_dialog; + NautilusPreferencesBox *prefs_box; + GtkWidget *user_level_group; + + prefs_dialog = nautilus_preferences_dialog_new (GLOBAL_PREFERENCES_DIALOG_TITLE); + + prefs_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box (NAUTILUS_PREFERENCES_DIALOG (prefs_dialog))); + + panes[0] = nautilus_preferences_box_add_pane (prefs_box, + "User Level", + "User Level Something"); + + user_level_group = global_prefernces_create_enum_group (panes[0], + "User Level", + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL); + + panes[1] = nautilus_preferences_box_add_pane (prefs_box, + "Window Options", + "Window Options Something"); + + global_preferences_create_check_group (panes[1], + "Basic window options", + global_preferences_window_option_pref_names, + NAUTILUS_N_ELEMENTS (global_preferences_window_option_pref_names)); + + panes[2] = nautilus_preferences_box_add_pane (prefs_box, + "Meta Views", + "Meta Views Something"); + + global_preferences_create_check_group (panes[2], + "Meta Views", + global_preferences_meta_view_names, + NAUTILUS_N_ELEMENTS (global_preferences_meta_view_names)); + + return prefs_dialog; +} + +static GtkWidget * +global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs) +{ + GtkWidget *group; + guint i; + + group = nautilus_preferences_group_new (group_title); + + for (i = 0; i < num_prefs; i++) + { + GtkWidget *item; + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_names[i], + NAUTILUS_PREFERENCES_ITEM_BOOL); + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), + item); + + gtk_widget_show (item); + } + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static GtkWidget * +global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name) +{ + GtkWidget *group; + GtkWidget *item; + + group = nautilus_preferences_group_new (group_title); + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_name, + NAUTILUS_PREFERENCES_ITEM_ENUM); + + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), item); + + gtk_widget_show (item); + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static void +global_preferences_register_static (NautilusPreferences *prefs) +{ + guint i; + + g_assert (prefs != NULL); + + /* Register the static prefs */ + for (i = 0; i < NAUTILUS_N_ELEMENTS (global_preferences_static_info); i++) + { + nautilus_preferences_register_from_info (prefs, &global_preferences_static_info[i]); + } +} + +static void +global_preferences_register_dynamic (NautilusPreferences *prefs) +{ + g_assert (prefs != NULL); + + /* + * Presummably, the following would be registered + * only if the component was present. Once we + * have smarter activation, that will be case. + * + * For now turn onall the ones we know off. + */ + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + "History View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH, + "Web Search View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + "Annotations", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + "Help Contents", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + "Help Index", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + "Help Search", + GTK_TYPE_BOOL, + FALSE, + NULL); +} + +static GtkWidget * +global_preferences_get_dialog (void) +{ + static GtkWidget * global_prefs_dialog = NULL; + + NautilusPreferences * global_prefs = nautilus_preferences_get_global_preferences (); + + if (!global_prefs) + { + g_warning ("something went terribly wrong with implicit prefs initialization\n"); + + return NULL; + } + + if (!global_prefs_dialog) + { + global_prefs_dialog = global_preferences_create_dialog (); + } + + return global_prefs_dialog; +} + +/* + * Public functions + */ +void +nautilus_global_preferences_show_dialog (void) +{ + GtkWidget * global_prefs_dialog = global_preferences_get_dialog (); + + gtk_widget_show (global_prefs_dialog); +} + +void +nautilus_global_preferences_shutdown (void) +{ + GtkWidget * global_prefs_dialog; + GtkObject * global_prefs; + + return; + + global_prefs_dialog = global_preferences_get_dialog (); + + global_prefs = GTK_OBJECT (nautilus_preferences_get_global_preferences ()); + + gtk_widget_unref (global_prefs_dialog); + + gtk_object_unref (global_prefs); +} + +void +nautilus_global_preferences_initialize (void) +{ + static gboolean initialized = FALSE; + + if (!initialized) + { + initialized = TRUE; + + global_preferences_register_static (nautilus_preferences_get_global_preferences ()); + global_preferences_register_dynamic (nautilus_preferences_get_global_preferences ()); + } +} diff --git a/libnautilus-private/nautilus-global-preferences.h b/libnautilus-private/nautilus-global-preferences.h new file mode 100644 index 000000000..3bd653aaa --- /dev/null +++ b/libnautilus-private/nautilus-global-preferences.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-global-prefs.h - Nautilus main preferences api. + + 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: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef NAUTILUS_PREFS_GLOBAL_H +#define NAUTILUS_PREFS_GLOBAL_H + +#include <gnome.h> +#include <nautilus-widgets/nautilus-preferences.h> + +BEGIN_GNOME_DECLS + +/* User level */ +#define NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL "/nautilus/prefs/user_level" + +/* Window options */ +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/prefs/window_always_new" +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING "/nautilus/prefs/window_search_existing" + +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS "/nautilus/prefs/metaviews::ntl_notes_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS "/nautilus/prefs/metaviews::hyperbola_navigation_tree" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX "/nautilus/prefs/metaviews::hyperbola_navigation_index" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH "/nautilus/prefs/metaviews::hyperbola_navigation_search" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY "/nautilus/prefs/metaviews::ntl_history_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH "/nautilus/prefs/metaviews::ntl_websearch_view" + +enum +{ + NAUTILUS_USER_LEVEL_NOVICE, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + NAUTILUS_USER_LEVEL_HACKER, + NAUTILUS_USER_LEVEL_ETTORE +}; + +void nautilus_global_preferences_shutdown (void); +void nautilus_global_preferences_initialize (void); +void nautilus_global_preferences_show_dialog (void); + +BEGIN_GNOME_DECLS + +#endif /* NAUTILUS_PREFS_GLOBAL_H */ + + diff --git a/libnautilus/Makefile.am b/libnautilus/Makefile.am index 635806220..d30ef7e69 100644 --- a/libnautilus/Makefile.am +++ b/libnautilus/Makefile.am @@ -1,3 +1,5 @@ +NULL= + lib_LTLIBRARIES=libnautilus.la INCLUDES=-I$(top_srcdir) -I$(top_builddir) \ @@ -25,21 +27,21 @@ BUILT_SOURCES=$(nautilus_idl_sources) libnautilusincludedir=$(includedir)/libnautilus libnautilusinclude_HEADERS= \ - libnautilus.h \ bonobo-stream-vfs.h \ gdk-extensions.h \ gnome-icon-container.h \ gtkflist.h \ gtkscrollframe.h \ - nautilus.h \ + libnautilus.h \ nautilus-alloc.h \ nautilus-background.h \ nautilus-bookmark.h \ nautilus-debug.h \ nautilus-directory.h \ - nautilus-file.h \ nautilus-file-utilities.h \ + nautilus-file.h \ nautilus-glib-extensions.h \ + nautilus-global-preferences.h \ nautilus-gnome-extensions.h \ nautilus-gtk-extensions.h \ nautilus-icon-factory.h \ @@ -49,9 +51,11 @@ libnautilusinclude_HEADERS= \ nautilus-self-checks.h \ nautilus-string.h \ nautilus-zoomable.h \ + nautilus.h \ ntl-content-view-frame.h \ ntl-meta-view-frame.h \ - ntl-view-frame.h + ntl-view-frame.h \ + $(NULL) libnautilus_la_SOURCES=$(nautilus_idl_sources) \ bonobo-stream-vfs.c \ @@ -60,16 +64,17 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ gnome-icon-container.c \ gtkflist.c \ gtkscrollframe.c \ - nautilus-background.c \ nautilus-background-canvas-group.c \ + nautilus-background.c \ nautilus-bookmark.c \ nautilus-debug.c \ nautilus-default-file-icon.c \ nautilus-default-file-icon.h \ nautilus-directory.c \ - nautilus-file.c \ nautilus-file-utilities.c \ + nautilus-file.c \ nautilus-glib-extensions.c \ + nautilus-global-preferences.c \ nautilus-gnome-extensions.c \ nautilus-gtk-extensions.c \ nautilus-icon-factory.c \ @@ -82,7 +87,8 @@ libnautilus_la_SOURCES=$(nautilus_idl_sources) \ ntl-content-view-frame.c \ ntl-meta-view-frame.c \ ntl-view-frame.c \ - $(fsextension_idl_sources) + $(fsextension_idl_sources) \ + $(NULL) $(nautilus_idl_sources): nautilus_idl_stamp $(fsextension_idl_sources): fsextension_idl_stamp diff --git a/libnautilus/nautilus-global-preferences.c b/libnautilus/nautilus-global-preferences.c new file mode 100644 index 000000000..0849c7e01 --- /dev/null +++ b/libnautilus/nautilus-global-preferences.c @@ -0,0 +1,368 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-prefs-dialog.c - Implementation for preferences dialog. + + 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: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#include "nautilus-global-preferences.h" +#include <nautilus-widgets/nautilus-preferences-group.h> +#include <nautilus-widgets/nautilus-preferences-item.h> +#include <nautilus-widgets/nautilus-preferences-dialog.h> + +#include <gnome.h> + +BEGIN_GNOME_DECLS + + +#include <libnautilus/nautilus-glib-extensions.h> + + +/* + * Constants + */ +#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences") + +/* Private stuff */ +static GtkWidget *global_preferences_create_dialog (void); +static GtkWidget *global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name); +static GtkWidget *global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs); +static GtkWidget *global_preferences_get_dialog (void); +static void global_preferences_register_static (NautilusPreferences *prefs); +static void global_preferences_register_dynamic (NautilusPreferences *prefs); + + +// static GtkWidget *global_preferences_dialog = NULL; +// static GtkObject *global_preferences = NULL; + +static GtkWidget *panes[3]; + +static const gchar *global_preferences_window_option_pref_names[] = +{ + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING +}; + +static const gchar *global_preferences_meta_view_names[] = +{ + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH +}; + +static const gchar * global_preferences_user_level_names[] = +{ + "novice", + "intermediate", + "hacker", + "ettore" +}; + +static const gchar * global_preferences_user_level_descriptions[] = +{ + "Novice", + "Intermediate", + "Hacker", + "Ettore" +}; + +static const gint global_preferences_user_level_values[] = +{ + NAUTILUS_USER_LEVEL_NOVICE, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + NAUTILUS_USER_LEVEL_HACKER, + NAUTILUS_USER_LEVEL_ETTORE +}; + +static NautilusPreferencesEnumData global_preferences_user_level_data = +{ + global_preferences_user_level_names, + global_preferences_user_level_descriptions, + global_preferences_user_level_values, + NAUTILUS_N_ELEMENTS (global_preferences_user_level_names) +}; + +static NautilusPreferencesInfo global_preferences_static_info[] = +{ + { + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL, + "User Level", + GTK_TYPE_ENUM, + FALSE, + (gpointer) &global_preferences_user_level_data + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW, + "Create new window for each new page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, + { + NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING, + "Do not open more than one window with the same page", + GTK_TYPE_BOOL, + FALSE, + NULL + }, +}; + +/* + * Private stuff + */ +static GtkWidget * +global_preferences_create_dialog (void) +{ + GtkWidget *prefs_dialog; + NautilusPreferencesBox *prefs_box; + GtkWidget *user_level_group; + + prefs_dialog = nautilus_preferences_dialog_new (GLOBAL_PREFERENCES_DIALOG_TITLE); + + prefs_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box (NAUTILUS_PREFERENCES_DIALOG (prefs_dialog))); + + panes[0] = nautilus_preferences_box_add_pane (prefs_box, + "User Level", + "User Level Something"); + + user_level_group = global_prefernces_create_enum_group (panes[0], + "User Level", + NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL); + + panes[1] = nautilus_preferences_box_add_pane (prefs_box, + "Window Options", + "Window Options Something"); + + global_preferences_create_check_group (panes[1], + "Basic window options", + global_preferences_window_option_pref_names, + NAUTILUS_N_ELEMENTS (global_preferences_window_option_pref_names)); + + panes[2] = nautilus_preferences_box_add_pane (prefs_box, + "Meta Views", + "Meta Views Something"); + + global_preferences_create_check_group (panes[2], + "Meta Views", + global_preferences_meta_view_names, + NAUTILUS_N_ELEMENTS (global_preferences_meta_view_names)); + + return prefs_dialog; +} + +static GtkWidget * +global_preferences_create_check_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_names[], + guint num_prefs) +{ + GtkWidget *group; + guint i; + + group = nautilus_preferences_group_new (group_title); + + for (i = 0; i < num_prefs; i++) + { + GtkWidget *item; + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_names[i], + NAUTILUS_PREFERENCES_ITEM_BOOL); + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), + item); + + gtk_widget_show (item); + } + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static GtkWidget * +global_prefernces_create_enum_group (GtkWidget *pane, + const gchar *group_title, + const gchar *pref_name) +{ + GtkWidget *group; + GtkWidget *item; + + group = nautilus_preferences_group_new (group_title); + + item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()), + pref_name, + NAUTILUS_PREFERENCES_ITEM_ENUM); + + + nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), item); + + gtk_widget_show (item); + + nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group); + + gtk_widget_show (group); + + return group; +} + +static void +global_preferences_register_static (NautilusPreferences *prefs) +{ + guint i; + + g_assert (prefs != NULL); + + /* Register the static prefs */ + for (i = 0; i < NAUTILUS_N_ELEMENTS (global_preferences_static_info); i++) + { + nautilus_preferences_register_from_info (prefs, &global_preferences_static_info[i]); + } +} + +static void +global_preferences_register_dynamic (NautilusPreferences *prefs) +{ + g_assert (prefs != NULL); + + /* + * Presummably, the following would be registered + * only if the component was present. Once we + * have smarter activation, that will be case. + * + * For now turn onall the ones we know off. + */ + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY, + "History View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH, + "Web Search View", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS, + "Annotations", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS, + "Help Contents", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX, + "Help Index", + GTK_TYPE_BOOL, + FALSE, + NULL); + + nautilus_preferences_register_from_values (prefs, + NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH, + "Help Search", + GTK_TYPE_BOOL, + FALSE, + NULL); +} + +static GtkWidget * +global_preferences_get_dialog (void) +{ + static GtkWidget * global_prefs_dialog = NULL; + + NautilusPreferences * global_prefs = nautilus_preferences_get_global_preferences (); + + if (!global_prefs) + { + g_warning ("something went terribly wrong with implicit prefs initialization\n"); + + return NULL; + } + + if (!global_prefs_dialog) + { + global_prefs_dialog = global_preferences_create_dialog (); + } + + return global_prefs_dialog; +} + +/* + * Public functions + */ +void +nautilus_global_preferences_show_dialog (void) +{ + GtkWidget * global_prefs_dialog = global_preferences_get_dialog (); + + gtk_widget_show (global_prefs_dialog); +} + +void +nautilus_global_preferences_shutdown (void) +{ + GtkWidget * global_prefs_dialog; + GtkObject * global_prefs; + + return; + + global_prefs_dialog = global_preferences_get_dialog (); + + global_prefs = GTK_OBJECT (nautilus_preferences_get_global_preferences ()); + + gtk_widget_unref (global_prefs_dialog); + + gtk_object_unref (global_prefs); +} + +void +nautilus_global_preferences_initialize (void) +{ + static gboolean initialized = FALSE; + + if (!initialized) + { + initialized = TRUE; + + global_preferences_register_static (nautilus_preferences_get_global_preferences ()); + global_preferences_register_dynamic (nautilus_preferences_get_global_preferences ()); + } +} diff --git a/libnautilus/nautilus-global-preferences.h b/libnautilus/nautilus-global-preferences.h new file mode 100644 index 000000000..3bd653aaa --- /dev/null +++ b/libnautilus/nautilus-global-preferences.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ + +/* nautilus-global-prefs.h - Nautilus main preferences api. + + 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: Ramiro Estrugo <ramiro@eazel.com> +*/ + +#ifndef NAUTILUS_PREFS_GLOBAL_H +#define NAUTILUS_PREFS_GLOBAL_H + +#include <gnome.h> +#include <nautilus-widgets/nautilus-preferences.h> + +BEGIN_GNOME_DECLS + +/* User level */ +#define NAUTILUS_GLOBAL_PREFERENCES_USER_LEVEL "/nautilus/prefs/user_level" + +/* Window options */ +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_ALWAYS_NEW "/nautilus/prefs/window_always_new" +#define NAUTILUS_GLOBAL_PREFERENCES_WINDOW_SEARCH_EXISTING "/nautilus/prefs/window_search_existing" + +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS "/nautilus/prefs/metaviews::ntl_notes_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS "/nautilus/prefs/metaviews::hyperbola_navigation_tree" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX "/nautilus/prefs/metaviews::hyperbola_navigation_index" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH "/nautilus/prefs/metaviews::hyperbola_navigation_search" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY "/nautilus/prefs/metaviews::ntl_history_view" +#define NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH "/nautilus/prefs/metaviews::ntl_websearch_view" + +enum +{ + NAUTILUS_USER_LEVEL_NOVICE, + NAUTILUS_USER_LEVEL_INTERMEDIATE, + NAUTILUS_USER_LEVEL_HACKER, + NAUTILUS_USER_LEVEL_ETTORE +}; + +void nautilus_global_preferences_shutdown (void); +void nautilus_global_preferences_initialize (void); +void nautilus_global_preferences_show_dialog (void); + +BEGIN_GNOME_DECLS + +#endif /* NAUTILUS_PREFS_GLOBAL_H */ + + diff --git a/src/Makefile.am b/src/Makefile.am index b5e8fac17..b4c3bb27f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -33,8 +33,6 @@ nautilus_SOURCES =\ nautilus-bookmarklist.h \ nautilus-bookmarks-window.c \ nautilus-bookmarks-window.h \ - nautilus-global-preferences.c \ - nautilus-global-preferences.h \ nautilus-signaller.c \ nautilus-signaller.h \ nautilus-zoom-control.c \ diff --git a/src/nautilus-global-preferences.c b/src/nautilus-global-preferences.c deleted file mode 100644 index 6bd10a001..000000000 --- a/src/nautilus-global-preferences.c +++ /dev/null @@ -1,393 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* nautilus-prefs-dialog.c - Implementation for preferences dialog. - - 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: Ramiro Estrugo <ramiro@eazel.com> -*/ - -#include "nautilus-global-preferences.h" -#include <nautilus-widgets/nautilus-preferences-group.h> -#include <nautilus-widgets/nautilus-preferences-item.h> -#include <nautilus-widgets/nautilus-preferences-dialog.h> - -#include <gnome.h> - -BEGIN_GNOME_DECLS - - -#include <libnautilus/nautilus-glib-extensions.h> - - -/* - * Constants - */ -#define NAUTILUS_PREFS_DIALOG_TITLE _("Nautilus Preferences") - -/* Private stuff */ -static GtkWidget *prefs_global_create_dialog (void); -static GtkWidget *prefs_global_create_enum_group (GtkWidget *pane, - const gchar *group_title, - const gchar *pref_name); -static GtkWidget *prefs_global_create_check_group (GtkWidget *pane, - const gchar *group_title, - const gchar *pref_names[], - guint num_prefs); - -static GtkWidget *prefs_global_get_prefs_dialog (void); - -//static void user_level_changed_cb (GtkWidget *group, gpointer call_data, gpointer client_data); - -static void prefs_global_register_static_prefs (NautilusPrefs *prefs); - -static void prefs_global_register_dynamic_prefs (NautilusPrefs *prefs); - - -static GtkWidget *panes[3]; - -static const gchar * PREFS_GLOBAL_NAMESPACE = "Nautilus::Global"; - -static const gchar *prefs_global_window_option_pref_names[] = -{ - NAUTILUS_PREFS_WINDOW_ALWAYS_NEW, - NAUTILUS_PREFS_WINDOW_SEARCH_EXISTING -}; - -#if 0 -static const gchar *META_VIEWS[] = -{ - "Annotations", - "Help Contents", - "Help Index", - "Help Search", - "History", - "Web Search" -}; -#endif - - -static const gchar * prefs_global_user_level_names[] = -{ - "novice", - "intermediate", - "hacker", - "ettore" -}; - -static const gchar * prefs_global_user_level_descriptions[] = -{ - "Novice", - "Intermediate", - "Hacker", - "Ettore" -}; - -static const gint prefs_global_user_level_values[] = -{ - NAUTILUS_USER_LEVEL_NOVICE, - NAUTILUS_USER_LEVEL_INTERMEDIATE, - NAUTILUS_USER_LEVEL_HACKER, - NAUTILUS_USER_LEVEL_ETTORE -}; - -static NautilusPrefEnumData prefs_global_user_level_data = -{ - prefs_global_user_level_names, - prefs_global_user_level_descriptions, - prefs_global_user_level_values, - NAUTILUS_N_ELEMENTS (prefs_global_user_level_names) -}; - -static NautilusPrefInfo prefs_global_static_pref_info[] = -{ - { - NAUTILUS_PREFS_USER_LEVEL, - "User Level", - GTK_TYPE_ENUM, - FALSE, - (gpointer) &prefs_global_user_level_data - }, - { - NAUTILUS_PREFS_WINDOW_ALWAYS_NEW, - "Create new window for each new page", - GTK_TYPE_BOOL, - FALSE, - NULL - }, - { - NAUTILUS_PREFS_WINDOW_SEARCH_EXISTING, - "Do not open more than one window with the same page", - GTK_TYPE_BOOL, - FALSE, - NULL - }, -}; - -/* - * Private stuff - */ -static GtkWidget * -prefs_global_create_dialog (void) -{ - GtkWidget *prefs_dialog; - NautilusPrefsBox *prefs_box; - GtkWidget *user_level_group; - - prefs_dialog = nautilus_prefs_dialog_new (NAUTILUS_PREFS_DIALOG_TITLE); - - prefs_box = NAUTILUS_PREFS_BOX (nautilus_prefs_dialog_get_prefs_box (NAUTILUS_PREFS_DIALOG (prefs_dialog))); - - panes[0] = nautilus_prefs_box_add_pane (prefs_box, - "User Level", - "User Level Something"); - - user_level_group = prefs_global_create_enum_group (panes[0], - "User Level", - NAUTILUS_PREFS_USER_LEVEL); - - panes[1] = nautilus_prefs_box_add_pane (prefs_box, - "Window Options", - "Window Options Something"); - - prefs_global_create_check_group (panes[1], - "Basic window options", - prefs_global_window_option_pref_names, - NAUTILUS_N_ELEMENTS (prefs_global_window_option_pref_names)); - -#if 0 - panes[2] = nautilus_prefs_box_add_pane (prefs_box, - "Meta Views", - "Meta Views Something"); - - prefs_global_create_check_group (panes[2], - "Meta Views", - META_VIEWS, - NAUTILUS_N_ELEMENTS (META_VIEWS)); -#endif - - return prefs_dialog; -} - -static GtkWidget * -prefs_global_create_check_group (GtkWidget *pane, - const gchar *group_title, - const gchar *pref_names[], - guint num_prefs) -{ - GtkWidget *group; - guint i; - - group = nautilus_preferences_group_new (group_title); - - for (i = 0; i < num_prefs; i++) - { - GtkWidget *item; - - item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_prefs_global_get_prefs ()), - pref_names[i], - NAUTILUS_PREFERENCES_ITEM_BOOL); - - nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), - item); - - gtk_widget_show (item); - } - - nautilus_prefs_pane_add_group (NAUTILUS_PREFS_PANE (pane), group); - - gtk_widget_show (group); - - return group; -} - -static GtkWidget * -prefs_global_create_enum_group (GtkWidget *pane, - const gchar *group_title, - const gchar *pref_name) -{ - GtkWidget *group; - GtkWidget *item; - - group = nautilus_preferences_group_new (group_title); - - item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_prefs_global_get_prefs ()), - pref_name, - NAUTILUS_PREFERENCES_ITEM_ENUM); - - - nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), item); - - gtk_widget_show (item); - - nautilus_prefs_pane_add_group (NAUTILUS_PREFS_PANE (pane), group); - - gtk_widget_show (group); - - return group; -} - -#if 0 -static void -user_level_changed_cb (GtkWidget *group, gpointer call_data, gpointer client_data) -{ - NautilusPrefsGroupRadioSignalData *data = (NautilusPrefsGroupRadioSignalData *) call_data; - - g_assert (data != NULL); - - // Do something -} -#endif - -static void -prefs_global_register_static_prefs (NautilusPrefs *prefs) -{ - guint i; - - g_assert (prefs != NULL); - - /* Register the static prefs */ - for (i = 0; i < NAUTILUS_N_ELEMENTS (prefs_global_static_pref_info); i++) - { - nautilus_prefs_register_from_info (prefs, &prefs_global_static_pref_info[i]); - } -} - -static void -prefs_global_register_dynamic_prefs (NautilusPrefs *prefs) -{ - g_assert (prefs != NULL); - - /* - * Presummably, the following would be registered - * only if the component was present. Once we - * have smarter activation, that will be case. - * - * For now turn onall the ones we know off. - */ - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::ntl_history_view", - "History View", - GTK_TYPE_BOOL, - FALSE, - NULL); - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::ntl_websearch_view", - "Web Search View", - GTK_TYPE_BOOL, - FALSE, - NULL); - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::ntl_notes_view", - "Annotations", - GTK_TYPE_BOOL, - FALSE, - NULL); - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::hyperbola_navigation_tree", - "Help Contents", - GTK_TYPE_BOOL, - FALSE, - NULL); - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::hyperbola_navigation_index", - "Help Index", - GTK_TYPE_BOOL, - FALSE, - NULL); - - nautilus_prefs_register_from_values (prefs, - "/nautilus/prefs/metaviews::hyperbola_navigation_search", - "Help Search", - GTK_TYPE_BOOL, - FALSE, - NULL); -} - -static GtkWidget * -prefs_global_get_prefs_dialog (void) -{ - static GtkWidget * global_prefs_dialog = NULL; - - NautilusPrefs * global_prefs = nautilus_prefs_global_get_prefs (); - - if (!global_prefs) - { - g_warning ("something went terribly wrong wrt implicit prefs initialization\n"); - - return NULL; - } - - if (!global_prefs_dialog) - { - global_prefs_dialog = prefs_global_create_dialog (); - } - - return global_prefs_dialog; -} - -/* - * Public functions - */ -NautilusPrefs * -nautilus_prefs_global_get_prefs (void) -{ - static GtkObject * global_prefs = NULL; - - if (!global_prefs) - { - global_prefs = nautilus_prefs_new (PREFS_GLOBAL_NAMESPACE); - - prefs_global_register_static_prefs (NAUTILUS_PREFS (global_prefs)); - prefs_global_register_dynamic_prefs (NAUTILUS_PREFS (global_prefs)); - } - - return NAUTILUS_PREFS (global_prefs); -} - -void -nautilus_prefs_global_show_dialog (void) -{ - GtkWidget * global_prefs_dialog = prefs_global_get_prefs_dialog (); - - nautilus_prefs_set_enum (nautilus_prefs_global_get_prefs (), - NAUTILUS_PREFS_USER_LEVEL, - NAUTILUS_USER_LEVEL_ETTORE); - - gtk_widget_show (global_prefs_dialog); -} - -void -nautilus_prefs_global_shutdown (void) -{ - GtkWidget * global_prefs_dialog; - GtkObject * global_prefs; - - global_prefs_dialog = prefs_global_get_prefs_dialog (); - - global_prefs = GTK_OBJECT (nautilus_prefs_global_get_prefs ()); - - gtk_widget_unref (global_prefs_dialog); - - gtk_object_unref (global_prefs); -} |