summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Sullivan <sullivan@src.gnome.org>2001-03-31 00:16:50 +0000
committerJohn Sullivan <sullivan@src.gnome.org>2001-03-31 00:16:50 +0000
commit982aef48f1cfe184370216a792076885d155e7be (patch)
tree544893e5e82038972101650839533a8eb5f32813
parent168c194bd3e9b41c5bb06ff370c979c693382e77 (diff)
downloadnautilus-982aef48f1cfe184370216a792076885d155e7be.tar.gz
Removed bogus return_if_fail.
* libnautilus-extensions/nautilus-preferences.c: (update_auto_integer_or_boolean): Removed bogus return_if_fail. * libnautilus-extensions/nautilus-icon-container.c: (nautilus_icon_container_initialize_class): Set up auto-storage variable for click policy preference. (button_press_event): Use auto-storage variable instead of calling nautilus_preferences_get. * src/file-manager/fm-directory-view.c: (fm_directory_view_initialize_class): Set up auto-storage variables for three preferences checked elsewhere in this class. (open_alternate_callback), (open_location), (confirm_delete_directly), (confirm_delete_from_trash), (fm_directory_view_activate_files): Use auto-storage variables instead of calling nautilus_preferences_get. (confirm_trash_changed_callback), (enable_delete_changed_callback): Removed these functions. (real_update_menus): Removed code setting up callbacks to update static variables when the preference changed. The auto-storage variables have the same effect with much less code.
-rw-r--r--ChangeLog23
-rw-r--r--libnautilus-extensions/nautilus-icon-container.c10
-rw-r--r--libnautilus-extensions/nautilus-preferences.c3
-rw-r--r--libnautilus-private/nautilus-icon-container.c10
-rw-r--r--libnautilus-private/nautilus-preferences.c3
-rw-r--r--src/file-manager/fm-directory-view.c70
6 files changed, 57 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index 7a66f7503..d65b436f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2001-03-30 John Sullivan <sullivan@eazel.com>
+
+ * libnautilus-extensions/nautilus-preferences.c:
+ (update_auto_integer_or_boolean): Removed bogus return_if_fail.
+
+ * libnautilus-extensions/nautilus-icon-container.c:
+ (nautilus_icon_container_initialize_class): Set up auto-storage
+ variable for click policy preference.
+ (button_press_event): Use auto-storage variable instead of
+ calling nautilus_preferences_get.
+
+ * src/file-manager/fm-directory-view.c:
+ (fm_directory_view_initialize_class): Set up auto-storage variables
+ for three preferences checked elsewhere in this class.
+ (open_alternate_callback), (open_location), (confirm_delete_directly),
+ (confirm_delete_from_trash), (fm_directory_view_activate_files):
+ Use auto-storage variables instead of calling nautilus_preferences_get.
+ (confirm_trash_changed_callback), (enable_delete_changed_callback):
+ Removed these functions.
+ (real_update_menus): Removed code setting up callbacks to update
+ static variables when the preference changed. The auto-storage
+ variables have the same effect with much less code.
+
2001-03-30 Michael Engber <engber@eazel.com>
* components/notes/nautilus-notes.c:
diff --git a/libnautilus-extensions/nautilus-icon-container.c b/libnautilus-extensions/nautilus-icon-container.c
index 82b5a884b..7746cb6eb 100644
--- a/libnautilus-extensions/nautilus-icon-container.c
+++ b/libnautilus-extensions/nautilus-icon-container.c
@@ -147,6 +147,8 @@ static gboolean is_renaming (NautilusIconContainer *contain
static gboolean is_renaming_pending (NautilusIconContainer *container);
static void process_pending_icon_to_rename (NautilusIconContainer *container);
+static int click_policy_auto_value;
+
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer,
nautilus_icon_container,
GNOME_TYPE_CANVAS)
@@ -2434,7 +2436,6 @@ button_press_event (GtkWidget *widget,
gboolean selection_changed;
gboolean return_value;
gboolean clicked_on_icon;
- int click_mode;
gint64 current_time;
static gint64 last_click_time = 0;
static gint click_count = 0;
@@ -2451,9 +2452,7 @@ button_press_event (GtkWidget *widget,
last_click_time = current_time;
/* Ignore double click if we are in single click mode */
- click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
-
- if (click_mode == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
+ if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
return TRUE;
}
@@ -3314,6 +3313,9 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
/* Initialize the stipple bitmap. */
stipple = gdk_bitmap_create_from_data (NULL, stipple_bits, 2, 2);
+
+ nautilus_preferences_add_auto_integer (NAUTILUS_PREFERENCES_CLICK_POLICY,
+ &click_policy_auto_value);
}
static void
diff --git a/libnautilus-extensions/nautilus-preferences.c b/libnautilus-extensions/nautilus-preferences.c
index b20d29cf8..a2aa70f77 100644
--- a/libnautilus-extensions/nautilus-preferences.c
+++ b/libnautilus-extensions/nautilus-preferences.c
@@ -434,7 +434,7 @@ static char *
preferences_key_make_for_getter (const char *name)
{
char *key;
-
+
g_return_val_if_fail (name != NULL, NULL);
if (preferences_preference_is_default (name)) {
@@ -778,7 +778,6 @@ static void
update_auto_integer_or_boolean (gpointer data, gpointer callback_data)
{
g_return_if_fail (data != NULL);
- g_return_if_fail (callback_data != NULL);
*(int *)data = GPOINTER_TO_INT (callback_data);
}
diff --git a/libnautilus-private/nautilus-icon-container.c b/libnautilus-private/nautilus-icon-container.c
index 82b5a884b..7746cb6eb 100644
--- a/libnautilus-private/nautilus-icon-container.c
+++ b/libnautilus-private/nautilus-icon-container.c
@@ -147,6 +147,8 @@ static gboolean is_renaming (NautilusIconContainer *contain
static gboolean is_renaming_pending (NautilusIconContainer *container);
static void process_pending_icon_to_rename (NautilusIconContainer *container);
+static int click_policy_auto_value;
+
NAUTILUS_DEFINE_CLASS_BOILERPLATE (NautilusIconContainer,
nautilus_icon_container,
GNOME_TYPE_CANVAS)
@@ -2434,7 +2436,6 @@ button_press_event (GtkWidget *widget,
gboolean selection_changed;
gboolean return_value;
gboolean clicked_on_icon;
- int click_mode;
gint64 current_time;
static gint64 last_click_time = 0;
static gint click_count = 0;
@@ -2451,9 +2452,7 @@ button_press_event (GtkWidget *widget,
last_click_time = current_time;
/* Ignore double click if we are in single click mode */
- click_mode = nautilus_preferences_get_integer (NAUTILUS_PREFERENCES_CLICK_POLICY);
-
- if (click_mode == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
+ if (click_policy_auto_value == NAUTILUS_CLICK_POLICY_SINGLE && click_count >= 2) {
return TRUE;
}
@@ -3314,6 +3313,9 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
/* Initialize the stipple bitmap. */
stipple = gdk_bitmap_create_from_data (NULL, stipple_bits, 2, 2);
+
+ nautilus_preferences_add_auto_integer (NAUTILUS_PREFERENCES_CLICK_POLICY,
+ &click_policy_auto_value);
}
static void
diff --git a/libnautilus-private/nautilus-preferences.c b/libnautilus-private/nautilus-preferences.c
index b20d29cf8..a2aa70f77 100644
--- a/libnautilus-private/nautilus-preferences.c
+++ b/libnautilus-private/nautilus-preferences.c
@@ -434,7 +434,7 @@ static char *
preferences_key_make_for_getter (const char *name)
{
char *key;
-
+
g_return_val_if_fail (name != NULL, NULL);
if (preferences_preference_is_default (name)) {
@@ -778,7 +778,6 @@ static void
update_auto_integer_or_boolean (gpointer data, gpointer callback_data)
{
g_return_if_fail (data != NULL);
- g_return_if_fail (callback_data != NULL);
*(int *)data = GPOINTER_TO_INT (callback_data);
}
diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c
index 78c1731be..98101429a 100644
--- a/src/file-manager/fm-directory-view.c
+++ b/src/file-manager/fm-directory-view.c
@@ -148,7 +148,9 @@ static guint signals[LAST_SIGNAL];
static GdkAtom clipboard_atom;
static GdkAtom copied_files_atom;
-static gboolean show_delete_command;
+static gboolean show_delete_command_auto_value;
+static gboolean confirm_trash_auto_value;
+static gboolean use_new_window_auto_value;
struct FMDirectoryViewDetails
{
@@ -508,7 +510,7 @@ open_alternate_callback (BonoboUIComponent *component, gpointer callback_data, c
view = FM_DIRECTORY_VIEW (callback_data);
selection = fm_directory_view_get_selection (view);
- if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
+ if (use_new_window_auto_value) {
/* UI should have prevented this from being called unless exactly
* one item is selected.
*/
@@ -572,7 +574,7 @@ open_location (FMDirectoryView *directory_view,
switch (choice) {
case RESPECT_PREFERENCE:
- if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
+ if (use_new_window_auto_value) {
nautilus_view_open_location_prefer_existing_window
(directory_view->details->nautilus_view, new_uri);
} else {
@@ -734,7 +736,7 @@ confirm_delete_directly (FMDirectoryView *view,
g_assert (FM_IS_DIRECTORY_VIEW (view));
/* Just Say Yes if the preference says not to confirm. */
- if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
+ if (!confirm_trash_auto_value) {
return TRUE;
}
@@ -2785,7 +2787,7 @@ confirm_delete_from_trash (FMDirectoryView *view, GList *uris)
g_assert (FM_IS_DIRECTORY_VIEW (view));
/* Just Say Yes if the preference says not to confirm. */
- if (!nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH)) {
+ if (!confirm_trash_auto_value) {
return TRUE;
}
@@ -3911,25 +3913,9 @@ real_merge_menus (FMDirectoryView *view)
view->details->scripts_invalid = TRUE;
}
-static gboolean confirm_trash = TRUE;
-
-static void
-confirm_trash_changed_callback (gpointer callback_data)
-{
- confirm_trash = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH);
-}
-
-static void
-enable_delete_changed_callback (gpointer callback_data)
-{
- show_delete_command = nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_ENABLE_DELETE);
-}
-
static void
real_update_menus (FMDirectoryView *view)
{
- static gboolean confirm_trash_changed_callback_installed = FALSE;
- static gboolean enable_delete_changed_callback_installed = FALSE;
GList *selection;
gint selection_count;
const char *tip, *accelerator, *label;
@@ -3943,28 +3929,6 @@ real_update_menus (FMDirectoryView *view)
selection = fm_directory_view_get_selection (view);
selection_count = g_list_length (selection);
- /* Add the callback once for the life of our process */
- if (!confirm_trash_changed_callback_installed) {
- nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
- confirm_trash_changed_callback,
- NULL);
- confirm_trash_changed_callback_installed = TRUE;
-
- /* Peek for the first time */
- confirm_trash_changed_callback (NULL);
- }
-
- /* Add the callback once for the life of our process */
- if (!enable_delete_changed_callback_installed) {
- nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_ENABLE_DELETE,
- enable_delete_changed_callback,
- NULL);
- enable_delete_changed_callback_installed = TRUE;
-
- /* Peek for the first time */
- enable_delete_changed_callback (NULL);
- }
-
selection_contains_special_link = special_link_in_selection (view);
can_create_files = fm_directory_view_supports_creating_files (view);
@@ -3979,7 +3943,7 @@ real_update_menus (FMDirectoryView *view)
FM_DIRECTORY_VIEW_COMMAND_OPEN,
selection_count != 0);
- if (nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW)) {
+ if (use_new_window_auto_value) {
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_OPEN_ALTERNATE,
selection_count == 1);
@@ -4010,7 +3974,7 @@ real_update_menus (FMDirectoryView *view)
reset_bonobo_open_with_menu (view, selection);
if (fm_directory_all_selected_items_in_trash (view)) {
- label = confirm_trash ? _("Delete from _Trash...") : _("Delete from _Trash");
+ label = confirm_trash_auto_value ? _("Delete from _Trash...") : _("Delete from _Trash");
accelerator = "";
tip = _("Delete all selected items permanently");
show_separate_delete_command = FALSE;
@@ -4018,7 +3982,7 @@ real_update_menus (FMDirectoryView *view)
label = _("Move to _Trash");
accelerator = "*Control*t";
tip = _("Move all selected items to the Trash");
- show_separate_delete_command = show_delete_command;
+ show_separate_delete_command = show_delete_command_auto_value;
}
can_delete_files = !fm_directory_view_is_read_only (view)
@@ -4048,7 +4012,7 @@ real_update_menus (FMDirectoryView *view)
(view->details->ui,
FM_DIRECTORY_VIEW_MENU_PATH_DELETE,
FM_DIRECTORY_VIEW_COMMAND_DELETE,
- confirm_trash ? _("De_lete...") : _("De_lete"));
+ confirm_trash_auto_value ? _("De_lete...") : _("De_lete"));
nautilus_bonobo_set_sensitive (view->details->ui,
FM_DIRECTORY_VIEW_COMMAND_DELETE,
can_delete_files);
@@ -4088,7 +4052,7 @@ real_update_menus (FMDirectoryView *view)
(view->details->ui,
FM_DIRECTORY_VIEW_MENU_PATH_EMPTY_TRASH,
FM_DIRECTORY_VIEW_COMMAND_EMPTY_TRASH,
- confirm_trash
+ confirm_trash_auto_value
? _("_Empty Trash...")
: _("_Empty Trash"));
nautilus_bonobo_set_sensitive (view->details->ui,
@@ -4589,8 +4553,7 @@ fm_directory_view_activate_files (FMDirectoryView *view,
* but it proved mysterious in practice.
*/
file_count = g_list_length (files);
- use_new_window = file_count > 1
- || nautilus_preferences_get_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW);
+ use_new_window = file_count > 1 || use_new_window_auto_value;
if (!use_new_window || fm_directory_view_confirm_multiple_windows (view, file_count)) {
for (node = files; node != NULL; node = node->next) {
@@ -5559,4 +5522,11 @@ fm_directory_view_initialize_class (FMDirectoryViewClass *klass)
clipboard_atom = gdk_atom_intern ("CLIPBOARD", FALSE);
copied_files_atom = gdk_atom_intern ("x-special/gnome-copied-files", FALSE);
+
+ nautilus_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_CONFIRM_TRASH,
+ &confirm_trash_auto_value);
+ nautilus_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_ENABLE_DELETE,
+ &show_delete_command_auto_value);
+ nautilus_preferences_add_auto_boolean (NAUTILUS_PREFERENCES_WINDOW_ALWAYS_NEW,
+ &use_new_window_auto_value);
}