Commit 216a3f89 authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

Many prefernece api changes. Make pref api behave more like the metadata

api.  Dont expose user levels publically.  Tweak preference dialog widgets
to make them easier to use.
parent 0f7f115f
2000-04-18 Ramiro Estrugo <ramiro@eazel.com>
* nautilus-widgets/nautilus-preferences.c,
nautilus-widgets/nautilus-preferences.h: Dont expose the
preference/enum info structure. Remove these and use the
NautilusPreference object instead to describe preferences.
Add usage of default values to get_* api. So now callers can
provide a default which will be given back to them if no default
exists for the preference. For example, no default will exists
for the preference when it was implicitly pulled out of someone's
ass.
The callback function no longer passes along the value. Instead
the caller is expected to use the get_ functions.
Rename nautilus_preferences_{get,set}_string() to
nautilus_preferences_{get,set}. This matches the
NautilusDirectory metadata api which uses strings for metadata by
default.
Also constify the get functions.
(nautilus_preferneces_get_info): Changed to
(nautilus_preferneces_get_preference) which returns a referenced
pointer to the preference description object. Prehaps this could
have a better name.
(nautilus_preferences_enum_add_entry): New function to add entries
to enumerated preferences.
* nautilus-widgets/nautilus-preferences-group.c,
nautilus-widgets/nautilus-preferences-group.h:
(nautilus_preferences_group_add): retire
(nautilus_preferences_group_add_item): New function that does all
the work of creating an item based on a given item_type.
* nautilus-widgets/nautilus-preferences-item.c,
nautilus-widgets/nautilus-preferences-item.h:
Use NautilusPreferences directly instead of GtkObject.
Ref/unref the preference object properly.
Use more consistent identifiers. Fix some stupid style things.
Update for NautilusPreference usage (instead of the info struct
hack).
* nautilus-widgets/nautilus-preferences-pane.c,
nautilus-widgets/nautilus-preferences-pane.h:
(nautilus_preferences_pane_add_item_to_nth_group) : New function
to do all the work of adding and managing an item based on a given
type.
* nautilus-widgets/test-nautilus-widgets.c: Update for all the
api changes.
* nautilus-widgets/Makefile.am: Add building of
nautilus-preference.[ch] and the self test driver.
* libnautilus-extensions/nautilus-global-preferences.c,
libnautilus-extensions/nautilus-global-preferences.h:
Add CLICK_ACTIVATION_TYPE preferences. Add HOME_URI
preference. Add SHOW_HIDDEN_FILES preference.
Make all the user level stuff private. Dont expose either the
user level preference or the user level values at all. Instead,
track user level changes in a callback and set appropiate
preferences.
(nautilus_global_preferences_startup): Hook to make the above work
properly.
Cleanup the creation of the preferences dialog.
* libnautilus-extensions/nautilus-icon-factory.c:
(icon_theme_changed_callback): Preference changed callback no
longer passes in the value. Value needs to be manually fetched.
(nautilus_get_current_icon_factory): No need to call
nautilus_preferences_set_info. Instead give
nautilus_preferences_get a default value. This way, we can always
get something reasonable back.
* src/nautilus-window-menus.c:
(use_eazel_theme_icons_cb): Update for pref api changes. Feed the
get function a default value.
* src/ntl-app.c:
(nautilus_app_class_init): Call
nautilus_global_preferences_startup so that user level callbacks
and such that preferences exposed in the ui have nice defaults.
* src/ntl-main.c:
(main): Add nautilus-widgets self checks.
* src/ntl-uri-map.c:
(add_meta_view_iids_from_preferences): Feed the pref api function
a default value.
* src/ntl-window-state.c:
(nautilus_window_set_initial_state): User level is no longer
publicly exposed over here. Determine the home uri, instead by
fetching the HOME_URI preference.
* src/file-manager/fm-directory-view.c:
(use_new_window_changed_callback): Retired. Instead check
preference when needed. There really is not need to go to the
trouble of installing a callback. Its just as easy and not
slow to check directly. Also, retire the 'use_new_window' member.
(user_level_changed_callback): Retired. User level no longer
publically exposed.
(show_hidden_files_changed_callback): Check SHOW_HIDDEN_FILES
preference to determine if hidden files should be filtered.
Add a 'show_hidden_files' member that keeps track of changes in
this preference.
(fm_directory_view_initialize): Initialize 'show_hidden_files'.
Update for callback name change.
(nautilus_preferences_remove_callback): Remove uneeded unregister
call for retired use_new_window callback.
(queue_pending_files): Do hidden file filtering based on
'show_hidden_files' instead of using the user level.
(fm_directory_view_activate_file): Check USE_NEW_WINDOW preference
to determine if a new window is requested.
* src/file-manager/fm-icon-text-window.c:
Include fm-icon-virw.h and use
DEFAULT_ICON_VIEW_TEXT_ATTRIBUTE_NAMES from it instead of
ATTRIBUTE_NAMES_DEFAULT. This makes sure the default is not out
of whack. This define should probably be placed in a better place.
(synch_menus_with_preference),
(changed_attributes_option_menu_cb): Update for preference api changes.
(preference_changed_callback): Rename to
icon_view_text_attribute_changed_callback for clarity.
(icon_view_text_attribute_changed_callback): Value no longer
passed into callback. Need to check preferences manually.
* src/file-manager/fm-icon-view.h:
Add DEFAULT_ICON_VIEW_TEXT_ATTRIBUTE_NAMES to share with
fm-icon-text-window.
* src/file-manager/fm-icon-view.c:
(fm_icon_view_icon_text_changed_callback): Update for preference
api changes.
Minor anal style formatting of the private prototypes.
(fm_icon_view_initialize_class): Yank
nautilus_preferences_set_info call. No longer needed for there to
be proper defaults.
(text_attribute_names_changed_callback): Value no longer
passed into callback. Need to check preferences manually. Also,
feed the get function a reasonable default.
* components/help/Makefile.am: Needs to link with
libnautilus-extensions.
* components/websearch/Makefile.am: Needs to link with
libnautilus-extensions.
2000-04-18 Ramiro Estrugo <ramiro@eazel.com>
* libnautilus-extensions/nautilus-string-list.c,
......
......@@ -10,8 +10,9 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) \
-DINFODIR=\"$(infodir)\"
LDADD =\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
$(GNOMEUI_LIBS) \
......
......@@ -4,6 +4,7 @@ INCLUDES=-I$(top_srcdir) -I$(top_builddir) $(GNOMEUI_CFLAGS) $(BONOBO_CFLAGS) $(
LDADD=\
$(top_builddir)/nautilus-widgets/libnautilus-widgets.la \
$(top_builddir)/libnautilus-extensions/libnautilus-extensions.la \
$(top_builddir)/libnautilus/libnautilus.la \
$(top_builddir)/librsvg/librsvg.la \
$(BONOBO_LIBS) \
......
......@@ -29,95 +29,28 @@
#include <nautilus-widgets/nautilus-preferences-item.h>
#include <nautilus-widgets/nautilus-preferences-dialog.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
/*
* Constants
*/
/* Constants */
#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences")
/* Private stuff */
static GtkWidget *global_preferences_create_dialog (void);
static GtkWidget *global_preferences_create_enum_group (GtkWidget *pane,
const char *group_title,
const char *pref_name);
static GtkWidget *global_preferences_create_check_group (GtkWidget *pane,
const char *group_title,
const char * const pref_names[],
guint num_prefs);
static GtkWidget *global_preferences_get_dialog (void);
static void global_preferences_register_for_ui (void);
static void global_preferences_register_static (NautilusPreferences *prefs);
static void global_preferences_register_dynamic (NautilusPreferences *prefs);
static const char * const global_preferences_window_option_pref_names[] =
{
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
NAUTILUS_PREFERENCES_WINDOW_SEARCH_EXISTING
};
static const char * const 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 char * const global_preferences_user_level_names[] =
{
"novice",
"intermediate",
"hacker"
};
static const char * const global_preferences_user_level_descriptions[] =
{
"Novice",
"Intermediate",
"Hacker"
};
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL "/nautilus/preferences/user_level"
static const gint global_preferences_user_level_values[] =
enum
{
NAUTILUS_USER_LEVEL_NOVICE,
NAUTILUS_USER_LEVEL_INTERMEDIATE,
NAUTILUS_USER_LEVEL_HACKER
};
static const 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 const NautilusPreferencesInfo global_preferences_static_info[] =
{
{
NAUTILUS_PREFERENCES_USER_LEVEL,
"User Level",
NAUTILUS_PREFERENCE_ENUM,
(gconstpointer) NAUTILUS_USER_LEVEL_HACKER,
(gpointer) &global_preferences_user_level_data
},
{
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
"Create new window for each new page",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
NULL
},
{
NAUTILUS_PREFERENCES_WINDOW_SEARCH_EXISTING,
"Do not open more than one window with the same page",
NAUTILUS_PREFERENCE_BOOLEAN,
FALSE,
NULL
},
};
/* Private stuff */
static GtkWidget *global_preferences_create_dialog (void);
static GtkWidget *global_preferences_get_dialog (void);
static void global_preferences_register_for_ui (NautilusPreferences *preferences);
static void user_level_changed_callback (NautilusPreferences *preferences,
const char *name,
gpointer user_data);
/*
* Private stuff
......@@ -125,119 +58,129 @@ static const NautilusPreferencesInfo global_preferences_static_info[] =
static GtkWidget *
global_preferences_create_dialog (void)
{
GtkWidget *panes[3];
GtkWidget *prefs_dialog;
NautilusPreferencesBox *prefs_box;
global_preferences_register_for_ui ();
NautilusPreferencesBox *preference_box;
NautilusPreferences *preferences;
GtkWidget *user_level_pane;
GtkWidget *window_options_pane;
GtkWidget *meta_view_pane;
GtkWidget *icon_view_pane;
preferences = nautilus_preferences_get_global_preferences ();
/*
* In the soon to come star trek future, the following widgetry
* might be either fetched from a glade file or generated from
* an xml file.
*/
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");
/* Create a preference box */
preference_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box
(NAUTILUS_PREFERENCES_DIALOG (prefs_dialog)));
global_preferences_create_enum_group (panes[0],
"User Level",
NAUTILUS_PREFERENCES_USER_LEVEL);
panes[1] = nautilus_preferences_box_add_pane (prefs_box,
"Window Options",
"Window Options Something");
/*
* User level pane
*/
user_level_pane = nautilus_preferences_box_add_pane (preference_box,
"User Level",
"User Level 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");
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (user_level_pane), "User Level");
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 char *group_title,
const char * const 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_PREFERENCE_BOOLEAN);
nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group),
item);
gtk_widget_show (item);
}
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (user_level_pane),
0,
preferences,
NAUTILUS_PREFERENCES_USER_LEVEL,
NAUTILUS_PREFERENCE_ITEM_ENUM);
/*
* Window options pane
*/
window_options_pane = nautilus_preferences_box_add_pane (preference_box,
"Window Options",
"Window Options Something");
gtk_widget_show (group);
return group;
}
static GtkWidget *
global_preferences_create_enum_group (GtkWidget *pane,
const char *group_title,
const char *pref_name)
{
GtkWidget *group;
GtkWidget *item;
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (window_options_pane), "Basic window options");
group = nautilus_preferences_group_new (group_title);
item = nautilus_preferences_item_new (GTK_OBJECT (nautilus_preferences_get_global_preferences ()),
pref_name,
NAUTILUS_PREFERENCE_ENUM);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (window_options_pane),
0,
preferences,
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (window_options_pane),
0,
preferences,
NAUTILUS_PREFERENCES_WINDOW_SEARCH_EXISTING,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_group_add (NAUTILUS_PREFERENCES_GROUP (group), item);
/*
* Meta view pane
*/
meta_view_pane = nautilus_preferences_box_add_pane (preference_box,
"Meta Views",
"Meta Views Something");
gtk_widget_show (item);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (pane), group);
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane), "Meta Views");
gtk_widget_show (group);
return group;
}
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_ANNOTATIONS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_CONTENTS,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_INDEX,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HELP_SEARCH,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_HISTORY,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (meta_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_META_VIEWS_SHOW_WEB_SEARCH,
NAUTILUS_PREFERENCE_ITEM_BOOLEAN);
/*
* Clicking pane
*/
icon_view_pane = nautilus_preferences_box_add_pane (preference_box,
"Icon View",
"Icon View something");
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (icon_view_pane), "Number of clicks");
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (icon_view_pane),
0,
preferences,
NAUTILUS_PREFERENCES_CLICK_ACTIVATION_TYPE,
NAUTILUS_PREFERENCE_ITEM_ENUM);
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_set_info (prefs,
global_preferences_static_info[i].name,
global_preferences_static_info[i].description,
global_preferences_static_info[i].type,
global_preferences_static_info[i].default_value,
global_preferences_static_info[i].data);
}
return prefs_dialog;
}
/*
......@@ -268,88 +211,197 @@ nautilus_global_preferences_get_meta_view_iids (void)
return meta_view_names;
}
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");
return NULL;
}
if (!global_prefs_dialog)
{
global_prefs_dialog = global_preferences_create_dialog ();
}
return global_prefs_dialog;
}
static void
global_preferences_register_dynamic (NautilusPreferences *prefs)
global_preferences_register_for_ui (NautilusPreferences *preferences)
{
g_assert (prefs != NULL);
static gboolean preference_for_ui_registered = FALSE;
g_assert (preferences != NULL);
if (preference_for_ui_registered)
return;
preference_for_ui_registered = TRUE;
preferences = nautilus_preferences_get_global_preferences ();
g_assert (preferences != NULL);
/*
* In the soon to come star trek future, the following information
* will be fetched using the latest xml techniques.
*/
nautilus_preferences_set_info (prefs,
/* Window create new */
nautilus_preferences_set_info (preferences,
NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
"Create new window for each new page",
NAUTILUS_PREFERENCE_BOOLEAN,
(gconstpointer) FALSE);
/* Window seatch existing */
nautilus_preferences_set_info (preferences,
NAUTILUS_PREFERENCES_WINDOW_SEARCH_EXISTING,
"Do not open more than one window with the same page",
NAUTILUS_PREFERENCE_BOOLEAN,
(gconstpointer) FALSE);
/* Click activation type */
nautilus_preferences_set_info (preferences,
NAUTILUS_PREFERENCES_CLICK_ACTIVATION_TYPE,
"Click activation type",