Commit 93e47686 authored by Ramiro Estrugo's avatar Ramiro Estrugo
Browse files

Remove the user level pane from the preferences dialog. Place the

user level choices directly in the settings menu.

Also uncouple user level from preferences.  User level is no
longer a preference itself.

* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_create_dialog),
(global_preferences_register_for_ui),
(user_level_changed_callback),
(nautilus_global_preferences_shutdown),
(nautilus_global_preferences_startup):
Remove all of the user level ui stuff.

* nautilus-widgets/nautilus-user-level-manager.c:
(user_level_manager_new), (nautilus_user_level_manager_initialize),
(nautilus_user_level_manager_initialize_class),
(user_level_manager_destroy), (gconf_get_user_level_string),
(user_level_set_default_if_needed),
(gconf_user_level_changed_callback),
(nautilus_user_level_manager_get),
(nautilus_user_level_manager_set_user_level),
(nautilus_user_level_manager_get_user_level):
Emit the the "user_level_changed" signal from a gconf callback
instead of "by hand".  Otherwise we are out of whack because of
gconf asyncness.

* src/nautilus-window-menus.c:
(settings_menu_user_level_radio_group_callback),
(settings_menu_user_level_customize_callback),
(settings_menu_customize_callback),
(nautilus_window_initialize_menus),
(user_level_menu_path_to_user_level),
(user_level_user_level_to_menu_path):
* src/nautilus-window.h:
Remove the "General Settings" menu item.  Replace it with a
user level chooser as well as current user level customizer.
parent f2fda23a
2000-05-31 Ramiro Estrugo <ramiro@eazel.com>
Remove the user level pane from the preferences dialog. Place the
user level choices directly in the settings menu.
Also uncouple user level from preferences. User level is no
longer a preference itself.
* libnautilus-extensions/nautilus-global-preferences.c:
(global_preferences_create_dialog),
(global_preferences_register_for_ui),
(user_level_changed_callback),
(nautilus_global_preferences_shutdown),
(nautilus_global_preferences_startup):
Remove all of the user level ui stuff.
* nautilus-widgets/nautilus-user-level-manager.c:
(user_level_manager_new), (nautilus_user_level_manager_initialize),
(nautilus_user_level_manager_initialize_class),
(user_level_manager_destroy), (gconf_get_user_level_string),
(user_level_set_default_if_needed),
(gconf_user_level_changed_callback),
(nautilus_user_level_manager_get),
(nautilus_user_level_manager_set_user_level),
(nautilus_user_level_manager_get_user_level):
Emit the the "user_level_changed" signal from a gconf callback
instead of "by hand". Otherwise we are out of whack because of
gconf asyncness.
* src/nautilus-window-menus.c:
(settings_menu_user_level_radio_group_callback),
(settings_menu_user_level_customize_callback),
(settings_menu_customize_callback),
(nautilus_window_initialize_menus),
(user_level_menu_path_to_user_level),
(user_level_user_level_to_menu_path):
* src/nautilus-window.h:
Remove the "General Settings" menu item. Replace it with a
user level chooser as well as current user level customizer.
2000-05-31 Fatih Demir <kabalak@gmx.net>
* nautilus.desktop: Added the Turkish entries.
......
......@@ -31,6 +31,7 @@
#include <nautilus-widgets/nautilus-preferences-group.h>
#include <nautilus-widgets/nautilus-preferences-item.h>
#include <nautilus-widgets/nautilus-preferences-dialog.h>
#include <nautilus-widgets/nautilus-user-level-manager.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-view-identifier.h>
......@@ -38,17 +39,6 @@
/* Constants */
#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences")
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL_KEY "/nautilus/preferences/user_level"
enum
{
/* Start at something other than zero - which is reserved as the unspecified default value. */
NAUTILUS_USER_LEVEL_NOVICE = 100,
NAUTILUS_USER_LEVEL_INTERMEDIATE,
NAUTILUS_USER_LEVEL_HACKER
};
/* Private stuff */
static GtkWidget *global_preferences_create_dialog (void);
static GtkWidget *global_preferences_get_dialog (void);
......@@ -58,10 +48,6 @@ static gboolean global_preferences_is_sidebar_panel_enabled (Nautilu
gpointer ignore);
static GList * global_preferences_get_sidebar_panel_view_identifiers (void);
/* Preference change callbacks */
static void user_level_changed_callback (gpointer user_data);
/*
* Private stuff
*/
......@@ -70,7 +56,6 @@ global_preferences_create_dialog (void)
{
GtkWidget *prefs_dialog;
NautilusPreferencesBox *preference_box;
GtkWidget *user_level_pane;
GtkWidget *directory_views_pane;
GtkWidget *sidebar_panels_pane;
GtkWidget *appearance_pane;
......@@ -86,19 +71,7 @@ global_preferences_create_dialog (void)
preference_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box
(NAUTILUS_PREFERENCES_DIALOG (prefs_dialog)));
/*
* User level pane
*/
user_level_pane = nautilus_preferences_box_add_pane (preference_box,
"User Level",
"User Level Something");
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (user_level_pane), "User Level");
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (user_level_pane),
0,
NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
NAUTILUS_PREFERENCE_ITEM_ENUM);
/*
* Directory Views pane
*/
......@@ -397,28 +370,6 @@ global_preferences_register_for_ui (void)
NAUTILUS_PREFERENCE_BOOLEAN,
(gconstpointer) FALSE);
/* User level */
nautilus_preferences_set_info (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"User Level",
NAUTILUS_PREFERENCE_ENUM,
(gconstpointer) NAUTILUS_USER_LEVEL_HACKER);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"novice",
"Novice",
NAUTILUS_USER_LEVEL_NOVICE);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"intermediate",
"Intermediate",
NAUTILUS_USER_LEVEL_INTERMEDIATE);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"hacker",
"Hacker",
NAUTILUS_USER_LEVEL_HACKER);
/* Sidebar panels */
global_preferences_register_sidebar_panels_preferences_for_ui ();
......@@ -447,10 +398,15 @@ global_preferences_register_for_ui (void)
(gconstpointer) FALSE);
}
#define USER_LEVEL_NOVICE 0
#define USER_LEVEL_INTERMEDIATE 1
#define USER_LEVEL_HACKER 2
static void
user_level_changed_callback (gpointer user_data)
user_level_changed_callback (GtkObject *user_level_manager,
gpointer user_data)
{
gint user_level;
int new_user_level;
char *home_uri_string;
gboolean show_hidden_files = FALSE;
......@@ -460,26 +416,25 @@ user_level_changed_callback (gpointer user_data)
const char *user_main_directory;
user_level = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
NAUTILUS_USER_LEVEL_HACKER);
new_user_level = nautilus_user_level_manager_get_user_level ();
/* Set some preferences according to the user level */
switch (user_level) {
case NAUTILUS_USER_LEVEL_NOVICE:
switch (new_user_level) {
case USER_LEVEL_NOVICE:
show_hidden_files = FALSE;
use_real_home = FALSE;
show_real_file_name = FALSE;
can_add_content = FALSE;
break;
case NAUTILUS_USER_LEVEL_INTERMEDIATE:
case USER_LEVEL_INTERMEDIATE:
show_hidden_files = FALSE;
use_real_home = TRUE;
show_real_file_name = FALSE;
can_add_content = TRUE;
break;
case NAUTILUS_USER_LEVEL_HACKER:
case USER_LEVEL_HACKER:
default:
show_hidden_files = TRUE;
use_real_home = TRUE;
......@@ -497,7 +452,6 @@ user_level_changed_callback (gpointer user_data)
nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT,
can_add_content);
/* FIXME bugzilla.eazel.com 715: This call needs to be spanked to conform. Should return a strduped string */
user_main_directory = nautilus_user_main_directory ();
......@@ -532,9 +486,9 @@ nautilus_global_preferences_shutdown (void)
GtkWidget * global_prefs_dialog = global_preferences_get_dialog ();
gtk_widget_destroy (global_prefs_dialog);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
user_level_changed_callback,
NULL);
gtk_signal_disconnect_by_func (GTK_OBJECT (nautilus_user_level_manager_get ()),
user_level_changed_callback,
NULL);
/* Now free the preferences tables and stuff */
nautilus_preferences_shutdown ();
......@@ -555,12 +509,13 @@ nautilus_global_preferences_startup (int argc, char **argv)
global_preferences_register_for_ui ();
/* Keep track of user level changes */
nautilus_preferences_add_enum_callback (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
user_level_changed_callback,
NULL);
/* Register to find out about user level changes */
gtk_signal_connect (GTK_OBJECT (nautilus_user_level_manager_get ()),
"user_level_changed",
user_level_changed_callback,
NULL);
/* Invoke the callback once to make sure stuff is properly setup */
user_level_changed_callback (NULL);
user_level_changed_callback (NULL, NULL);
}
......@@ -65,6 +65,7 @@ struct _NautilusUserLevelManager
NautilusStringList *user_level_names;
GConfClient *gconf_client;
int user_level_changed_connection;
};
typedef struct
......@@ -86,8 +87,18 @@ static void nautilus_user_level_manager_initialize (N
static void user_level_manager_destroy (GtkObject *object);
static NautilusUserLevelManager *user_level_manager_new (void);
static void user_level_manager_ensure_global_manager (void);
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
char * get_gconf_user_level_string (void);
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
char * gconf_get_user_level_string (void);
/* Gconf callbacks */
static void gconf_user_level_changed_callback (GConfClient *client,
guint cnxn_id,
const gchar *key,
GConfValue *value,
gboolean is_default,
gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusUserLevelManager, nautilus_user_level_manager, GTK_TYPE_OBJECT)
......@@ -119,6 +130,14 @@ user_level_manager_new ()
user_level_set_default_if_needed (manager);
/* Add a gconf notification for user_level changes. */
manager->user_level_changed_connection = gconf_client_notify_add (manager->gconf_client,
USER_LEVEL_KEY,
gconf_user_level_changed_callback,
NULL,
NULL,
NULL);
return manager;
}
......@@ -128,6 +147,7 @@ nautilus_user_level_manager_initialize (NautilusUserLevelManager *manager)
manager->num_user_levels = 0;
manager->gconf_client = NULL;
manager->user_level_changed_connection = 0;
}
static void
......@@ -135,7 +155,7 @@ nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *use
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (user_level_manager_class);
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("icons_changed",
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("user_level_changed",
GTK_RUN_LAST,
object_class->type,
0,
......@@ -159,6 +179,14 @@ user_level_manager_destroy (GtkObject *object)
/* Right now, the global manager is not destroyed on purpose */
g_assert_not_reached ();
/* Remove the gconf notification if its still lingering */
if (manager->user_level_changed_connection != 0) {
gconf_client_notify_remove (manager->gconf_client,
manager->user_level_changed_connection);
manager->user_level_changed_connection = 0;
}
if (manager->gconf_client != NULL) {
gtk_object_unref (GTK_OBJECT (manager->gconf_client));
}
......@@ -177,7 +205,7 @@ user_level_manager_ensure_global_manager (void)
}
char *
get_gconf_user_level_string (void)
gconf_get_user_level_string (void)
{
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
char *user_level_string;
......@@ -207,8 +235,6 @@ user_level_set_default_if_needed (NautilusUserLevelManager *manager)
gconf_client_set (manager->gconf_client, USER_LEVEL_KEY, value, NULL);
gconf_client_suggest_sync (manager->gconf_client, NULL);
/* g_print ("setting default user_level to %s\n", DEFAULT_USER_LEVEL_NAMES[DEFAULT_USER_LEVEL]); */
}
g_assert (value != NULL);
......@@ -216,11 +242,27 @@ user_level_set_default_if_needed (NautilusUserLevelManager *manager)
gconf_value_destroy (value);
}
static void
gconf_user_level_changed_callback (GConfClient *client,
guint connection_id,
const gchar *key,
GConfValue *value,
gboolean is_default,
gpointer user_data)
{
NautilusUserLevelManager *manager = nautilus_user_level_manager_get ();
gtk_signal_emit (GTK_OBJECT (manager), user_level_manager_signals[USER_LEVEL_CHANGED]);
}
/* Public NautilusUserLevelManager functions */
NautilusUserLevelManager *
nautilus_user_level_manager_get (void)
{
user_level_manager_ensure_global_manager ();
g_assert (global_manager != NULL);
g_assert (NAUTILUS_IS_USER_LEVEL_MANAGER (global_manager));
return global_manager;
}
......@@ -254,10 +296,6 @@ nautilus_user_level_manager_set_user_level (guint user_level)
g_assert (result);
gconf_client_suggest_sync (manager->gconf_client, NULL);
/* g_print ("user_level changed from %d to %d\n", old_user_level, user_level); */
gtk_signal_emit (GTK_OBJECT (manager), user_level_manager_signals[USER_LEVEL_CHANGED]);
}
guint
......@@ -267,14 +305,12 @@ nautilus_user_level_manager_get_user_level (void)
char *user_level_string;
gint index;
user_level_string = get_gconf_user_level_string ();
user_level_string = gconf_get_user_level_string ();
g_assert (user_level_string != NULL);
index = nautilus_string_list_get_index_for_string (manager->user_level_names,
user_level_string);
/* g_print ("user_level_string = %s, index = %d\n", user_level_string, index); */
g_free (user_level_string);
g_assert (index != NAUTILUS_STRING_LIST_NOT_FOUND);
......
......@@ -31,6 +31,7 @@
#include <nautilus-widgets/nautilus-preferences-group.h>
#include <nautilus-widgets/nautilus-preferences-item.h>
#include <nautilus-widgets/nautilus-preferences-dialog.h>
#include <nautilus-widgets/nautilus-user-level-manager.h>
#include <libnautilus-extensions/nautilus-glib-extensions.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
#include <libnautilus-extensions/nautilus-view-identifier.h>
......@@ -38,17 +39,6 @@
/* Constants */
#define GLOBAL_PREFERENCES_DIALOG_TITLE _("Nautilus Preferences")
/* User level */
#define NAUTILUS_PREFERENCES_USER_LEVEL_KEY "/nautilus/preferences/user_level"
enum
{
/* Start at something other than zero - which is reserved as the unspecified default value. */
NAUTILUS_USER_LEVEL_NOVICE = 100,
NAUTILUS_USER_LEVEL_INTERMEDIATE,
NAUTILUS_USER_LEVEL_HACKER
};
/* Private stuff */
static GtkWidget *global_preferences_create_dialog (void);
static GtkWidget *global_preferences_get_dialog (void);
......@@ -58,10 +48,6 @@ static gboolean global_preferences_is_sidebar_panel_enabled (Nautilu
gpointer ignore);
static GList * global_preferences_get_sidebar_panel_view_identifiers (void);
/* Preference change callbacks */
static void user_level_changed_callback (gpointer user_data);
/*
* Private stuff
*/
......@@ -70,7 +56,6 @@ global_preferences_create_dialog (void)
{
GtkWidget *prefs_dialog;
NautilusPreferencesBox *preference_box;
GtkWidget *user_level_pane;
GtkWidget *directory_views_pane;
GtkWidget *sidebar_panels_pane;
GtkWidget *appearance_pane;
......@@ -86,19 +71,7 @@ global_preferences_create_dialog (void)
preference_box = NAUTILUS_PREFERENCES_BOX (nautilus_preferences_dialog_get_prefs_box
(NAUTILUS_PREFERENCES_DIALOG (prefs_dialog)));
/*
* User level pane
*/
user_level_pane = nautilus_preferences_box_add_pane (preference_box,
"User Level",
"User Level Something");
nautilus_preferences_pane_add_group (NAUTILUS_PREFERENCES_PANE (user_level_pane), "User Level");
nautilus_preferences_pane_add_item_to_nth_group (NAUTILUS_PREFERENCES_PANE (user_level_pane),
0,
NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
NAUTILUS_PREFERENCE_ITEM_ENUM);
/*
* Directory Views pane
*/
......@@ -397,28 +370,6 @@ global_preferences_register_for_ui (void)
NAUTILUS_PREFERENCE_BOOLEAN,
(gconstpointer) FALSE);
/* User level */
nautilus_preferences_set_info (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"User Level",
NAUTILUS_PREFERENCE_ENUM,
(gconstpointer) NAUTILUS_USER_LEVEL_HACKER);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"novice",
"Novice",
NAUTILUS_USER_LEVEL_NOVICE);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"intermediate",
"Intermediate",
NAUTILUS_USER_LEVEL_INTERMEDIATE);
nautilus_preferences_enum_add_entry (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
"hacker",
"Hacker",
NAUTILUS_USER_LEVEL_HACKER);
/* Sidebar panels */
global_preferences_register_sidebar_panels_preferences_for_ui ();
......@@ -447,10 +398,15 @@ global_preferences_register_for_ui (void)
(gconstpointer) FALSE);
}
#define USER_LEVEL_NOVICE 0
#define USER_LEVEL_INTERMEDIATE 1
#define USER_LEVEL_HACKER 2
static void
user_level_changed_callback (gpointer user_data)
user_level_changed_callback (GtkObject *user_level_manager,
gpointer user_data)
{
gint user_level;
int new_user_level;
char *home_uri_string;
gboolean show_hidden_files = FALSE;
......@@ -460,26 +416,25 @@ user_level_changed_callback (gpointer user_data)
const char *user_main_directory;
user_level = nautilus_preferences_get_enum (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
NAUTILUS_USER_LEVEL_HACKER);
new_user_level = nautilus_user_level_manager_get_user_level ();
/* Set some preferences according to the user level */
switch (user_level) {
case NAUTILUS_USER_LEVEL_NOVICE:
switch (new_user_level) {
case USER_LEVEL_NOVICE:
show_hidden_files = FALSE;
use_real_home = FALSE;
show_real_file_name = FALSE;
can_add_content = FALSE;
break;
case NAUTILUS_USER_LEVEL_INTERMEDIATE:
case USER_LEVEL_INTERMEDIATE:
show_hidden_files = FALSE;
use_real_home = TRUE;
show_real_file_name = FALSE;
can_add_content = TRUE;
break;
case NAUTILUS_USER_LEVEL_HACKER:
case USER_LEVEL_HACKER:
default:
show_hidden_files = TRUE;
use_real_home = TRUE;
......@@ -497,7 +452,6 @@ user_level_changed_callback (gpointer user_data)
nautilus_preferences_set_boolean (NAUTILUS_PREFERENCES_CAN_ADD_CONTENT,
can_add_content);
/* FIXME bugzilla.eazel.com 715: This call needs to be spanked to conform. Should return a strduped string */
user_main_directory = nautilus_user_main_directory ();
......@@ -532,9 +486,9 @@ nautilus_global_preferences_shutdown (void)
GtkWidget * global_prefs_dialog = global_preferences_get_dialog ();
gtk_widget_destroy (global_prefs_dialog);
nautilus_preferences_remove_callback (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
user_level_changed_callback,
NULL);
gtk_signal_disconnect_by_func (GTK_OBJECT (nautilus_user_level_manager_get ()),
user_level_changed_callback,
NULL);
/* Now free the preferences tables and stuff */
nautilus_preferences_shutdown ();
......@@ -555,12 +509,13 @@ nautilus_global_preferences_startup (int argc, char **argv)
global_preferences_register_for_ui ();
/* Keep track of user level changes */
nautilus_preferences_add_enum_callback (NAUTILUS_PREFERENCES_USER_LEVEL_KEY,
user_level_changed_callback,
NULL);
/* Register to find out about user level changes */
gtk_signal_connect (GTK_OBJECT (nautilus_user_level_manager_get ()),
"user_level_changed",
user_level_changed_callback,
NULL);
/* Invoke the callback once to make sure stuff is properly setup */
user_level_changed_callback (NULL);
user_level_changed_callback (NULL, NULL);
}
......@@ -65,6 +65,7 @@ struct _NautilusUserLevelManager
NautilusStringList *user_level_names;
GConfClient *gconf_client;
int user_level_changed_connection;
};
typedef struct
......@@ -86,8 +87,18 @@ static void nautilus_user_level_manager_initialize (N
static void user_level_manager_destroy (GtkObject *object);
static NautilusUserLevelManager *user_level_manager_new (void);
static void user_level_manager_ensure_global_manager (void);
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
char * get_gconf_user_level_string (void);
static void user_level_set_default_if_needed (NautilusUserLevelManager *manager);
char * gconf_get_user_level_string (void);
/* Gconf callbacks */
static void gconf_user_level_changed_callback (GConfClient *client,
guint cnxn_id,
const gchar *key,
GConfValue *value,
gboolean is_default,
gpointer user_data);
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusUserLevelManager, nautilus_user_level_manager, GTK_TYPE_OBJECT)
......@@ -119,6 +130,14 @@ user_level_manager_new ()
user_level_set_default_if_needed (manager);
/* Add a gconf notification for user_level changes. */
manager->user_level_changed_connection = gconf_client_notify_add (manager->gconf_client,
USER_LEVEL_KEY,
gconf_user_level_changed_callback,
NULL,
NULL,
NULL);
return manager;
}
......@@ -128,6 +147,7 @@ nautilus_user_level_manager_initialize (NautilusUserLevelManager *manager)
manager->num_user_levels = 0;
manager->gconf_client = NULL;
manager->user_level_changed_connection = 0;
}
static void
......@@ -135,7 +155,7 @@ nautilus_user_level_manager_initialize_class (NautilusUserLevelManagerClass *use
{
GtkObjectClass *object_class = GTK_OBJECT_CLASS (user_level_manager_class);
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("icons_changed",
user_level_manager_signals[USER_LEVEL_CHANGED] = gtk_signal_new ("user_level_changed",
GTK_RUN_LAST,
object_class->type,
0,
......@@ -159,6 +179,14 @@ user_level_manager_destroy (GtkObject *object)
/* Right now, the global manager is not destroyed on purpose */
g_assert_not_reached ();
/* Remove the gconf notification if its still lingering */