diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c index c83ef30e4487a00254f900257e108f80a6215f1b..7af27316cb13a64f05a1a4c9e603a7d5eee040de 100644 --- a/src/nautilus-properties-window.c +++ b/src/nautilus-properties-window.c @@ -51,8 +51,6 @@ #define PREVIEW_IMAGE_WIDTH 96 -#define ROW_PAD 6 - static GHashTable *windows; static GHashTable *pending_lists; @@ -282,49 +280,49 @@ static const GtkTargetEntry target_table[] = */ #define CHOWN_CHGRP_TIMEOUT 300 /* milliseconds */ -static void schedule_directory_contents_update (NautilusPropertiesWindow *window); -static void directory_contents_value_field_update (NautilusPropertiesWindow *window); +static void schedule_directory_contents_update (NautilusPropertiesWindow *self); +static void directory_contents_value_field_update (NautilusPropertiesWindow *self); static void file_changed_callback (NautilusFile *file, gpointer user_data); -static void permission_button_update (NautilusPropertiesWindow *window, +static void permission_button_update (NautilusPropertiesWindow *self, GtkToggleButton *button); -static void permission_combo_update (NautilusPropertiesWindow *window, +static void permission_combo_update (NautilusPropertiesWindow *self, GtkComboBox *combo); -static void value_field_update (NautilusPropertiesWindow *window, +static void value_field_update (NautilusPropertiesWindow *self, GtkLabel *field); -static void properties_window_update (NautilusPropertiesWindow *window, +static void properties_window_update (NautilusPropertiesWindow *self, GList *files); static void is_directory_ready_callback (NautilusFile *file, gpointer data); static void cancel_group_change_callback (GroupChange *change); static void cancel_owner_change_callback (OwnerChange *change); static void select_image_button_callback (GtkWidget *widget, - NautilusPropertiesWindow *properties_window); + NautilusPropertiesWindow *self); static void set_icon (const char *icon_path, - NautilusPropertiesWindow *properties_window); + NautilusPropertiesWindow *self); static void remove_pending (StartupData *data, gboolean cancel_call_when_ready, gboolean cancel_timed_wait); -static void append_extension_pages (NautilusPropertiesWindow *window); +static void append_extension_pages (NautilusPropertiesWindow *self); static void name_field_focus_changed (GObject *object, GParamSpec *pspec, gpointer user_data); static void name_field_activate (GtkWidget *name_field, gpointer user_data); -static void setup_pie_widget (NautilusPropertiesWindow *window); +static void setup_pie_widget (NautilusPropertiesWindow *self); G_DEFINE_TYPE (NautilusPropertiesWindow, nautilus_properties_window, GTK_TYPE_WINDOW); static gboolean -is_multi_file_window (NautilusPropertiesWindow *window) +is_multi_file_window (NautilusPropertiesWindow *self) { GList *l; int count; count = 0; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (!nautilus_file_is_gone (NAUTILUS_FILE (l->data))) { @@ -340,14 +338,14 @@ is_multi_file_window (NautilusPropertiesWindow *window) } static int -get_not_gone_original_file_count (NautilusPropertiesWindow *window) +get_not_gone_original_file_count (NautilusPropertiesWindow *self) { GList *l; int count; count = 0; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (!nautilus_file_is_gone (NAUTILUS_FILE (l->data))) { @@ -359,16 +357,16 @@ get_not_gone_original_file_count (NautilusPropertiesWindow *window) } static NautilusFile * -get_original_file (NautilusPropertiesWindow *window) +get_original_file (NautilusPropertiesWindow *self) { - g_return_val_if_fail (!is_multi_file_window (window), NULL); + g_return_val_if_fail (!is_multi_file_window (self), NULL); - if (window->original_files == NULL) + if (self->original_files == NULL) { return NULL; } - return NAUTILUS_FILE (window->original_files->data); + return NAUTILUS_FILE (self->original_files->data); } static NautilusFile * @@ -386,26 +384,26 @@ get_target_file_for_original_file (NautilusFile *file) } static NautilusFile * -get_target_file (NautilusPropertiesWindow *window) +get_target_file (NautilusPropertiesWindow *self) { - return NAUTILUS_FILE (window->target_files->data); + return NAUTILUS_FILE (self->target_files->data); } static void -get_image_for_properties_window (NautilusPropertiesWindow *window, +get_image_for_properties_window (NautilusPropertiesWindow *self, char **icon_name, GdkPixbuf **icon_pixbuf) { - NautilusIconInfo *icon, *new_icon; + g_autoptr (NautilusIconInfo) icon = NULL; GList *l; gint icon_scale; - icon = NULL; - icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (window->notebook)); + icon_scale = gtk_widget_get_scale_factor (GTK_WIDGET (self->notebook)); - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { NautilusFile *file; + g_autoptr (NautilusIconInfo) new_icon = NULL; file = NAUTILUS_FILE (l->data); @@ -423,11 +421,9 @@ get_image_for_properties_window (NautilusPropertiesWindow *window, if (!new_icon || new_icon != icon) { g_object_unref (icon); - g_object_unref (new_icon); icon = NULL; break; } - g_object_unref (new_icon); } } @@ -447,36 +443,32 @@ get_image_for_properties_window (NautilusPropertiesWindow *window, { *icon_pixbuf = nautilus_icon_info_get_pixbuf_at_size (icon, NAUTILUS_CANVAS_ICON_SIZE_STANDARD); } - - g_object_unref (icon); } static void -update_properties_window_icon (NautilusPropertiesWindow *window) +update_properties_window_icon (NautilusPropertiesWindow *self) { - GdkPixbuf *pixbuf; + g_autoptr (GdkPixbuf) pixbuf = NULL; cairo_surface_t *surface; - char *name; + g_autofree char *name = NULL; - get_image_for_properties_window (window, &name, &pixbuf); + get_image_for_properties_window (self, &name, &pixbuf); if (name != NULL) { - gtk_window_set_icon_name (GTK_WINDOW (window), name); + gtk_window_set_icon_name (GTK_WINDOW (self), name); } else { - gtk_window_set_icon (GTK_WINDOW (window), pixbuf); + gtk_window_set_icon (GTK_WINDOW (self), pixbuf); } - surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, gtk_widget_get_scale_factor (GTK_WIDGET (window)), - gtk_widget_get_window (GTK_WIDGET (window))); - gtk_image_set_from_surface (GTK_IMAGE (window->icon_image), surface); - gtk_image_set_from_surface (GTK_IMAGE (window->icon_button_image), surface); + surface = gdk_cairo_surface_create_from_pixbuf (pixbuf, gtk_widget_get_scale_factor (GTK_WIDGET (self)), + gtk_widget_get_window (GTK_WIDGET (self))); + gtk_image_set_from_surface (GTK_IMAGE (self->icon_image), surface); + gtk_image_set_from_surface (GTK_IMAGE (self->icon_button_image), surface); - g_free (name); - g_object_unref (pixbuf); cairo_surface_destroy (surface); } @@ -484,8 +476,8 @@ update_properties_window_icon (NautilusPropertiesWindow *window) static gboolean uri_is_local_image (const char *uri) { - GdkPixbuf *pixbuf; - char *image_path; + g_autoptr (GdkPixbuf) pixbuf = NULL; + g_autofree char *image_path = NULL; image_path = g_filename_from_uri (uri, NULL, NULL); if (image_path == NULL) @@ -494,23 +486,22 @@ uri_is_local_image (const char *uri) } pixbuf = gdk_pixbuf_new_from_file (image_path, NULL); - g_free (image_path); if (pixbuf == NULL) { return FALSE; } - g_object_unref (pixbuf); + return TRUE; } static void -reset_icon (NautilusPropertiesWindow *properties_window) +reset_icon (NautilusPropertiesWindow *self) { GList *l; - for (l = properties_window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { NautilusFile *file; @@ -583,33 +574,33 @@ nautilus_properties_window_drag_data_received (GtkWidget *widget, } static void -setup_image_widget (NautilusPropertiesWindow *window, +setup_image_widget (NautilusPropertiesWindow *self, gboolean is_customizable) { - update_properties_window_icon (window); + update_properties_window_icon (self); if (is_customizable) { /* prepare the image to receive dropped objects to assign custom images */ - gtk_drag_dest_set (window->icon_button_image, + gtk_drag_dest_set (self->icon_button_image, GTK_DEST_DEFAULT_MOTION | GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, target_table, G_N_ELEMENTS (target_table), GDK_ACTION_COPY | GDK_ACTION_MOVE); - g_signal_connect (window->icon_button_image, "drag-data-received", + g_signal_connect (self->icon_button_image, "drag-data-received", G_CALLBACK (nautilus_properties_window_drag_data_received), NULL); - g_signal_connect (window->icon_button, "clicked", - G_CALLBACK (select_image_button_callback), window); - gtk_stack_set_visible_child (window->icon_stack, window->icon_button); + g_signal_connect (self->icon_button, "clicked", + G_CALLBACK (select_image_button_callback), self); + gtk_stack_set_visible_child (self->icon_stack, self->icon_button); } else { - gtk_stack_set_visible_child (window->icon_stack, window->icon_image); + gtk_stack_set_visible_child (self->icon_stack, self->icon_image); } } static void -set_name_field (NautilusPropertiesWindow *window, +set_name_field (NautilusPropertiesWindow *self, const gchar *original_name, const gchar *name) { @@ -617,19 +608,19 @@ set_name_field (NautilusPropertiesWindow *window, GtkWidget *stack_child_entry; gboolean use_label; - stack_child_label = gtk_stack_get_child_by_name (window->name_stack, "name_value_label"); - stack_child_entry = gtk_stack_get_child_by_name (window->name_stack, "name_value_entry"); + stack_child_label = gtk_stack_get_child_by_name (self->name_stack, "name_value_label"); + stack_child_entry = gtk_stack_get_child_by_name (self->name_stack, "name_value_entry"); - use_label = is_multi_file_window (window) || !nautilus_file_can_rename (get_original_file (window)); + use_label = is_multi_file_window (self) || !nautilus_file_can_rename (get_original_file (self)); if (use_label) { gtk_label_set_text (GTK_LABEL (stack_child_label), name); - gtk_stack_set_visible_child (window->name_stack, stack_child_label); + gtk_stack_set_visible_child (self->name_stack, stack_child_label); } else { - gtk_stack_set_visible_child (window->name_stack, stack_child_entry); + gtk_stack_set_visible_child (self->name_stack, stack_child_entry); } /* Only replace text if the file's name has changed. */ @@ -641,26 +632,25 @@ set_name_field (NautilusPropertiesWindow *window, * currently showing. This causes minimal ripples (e.g. * selection change). */ - gchar *displayed_name = gtk_editable_get_chars (GTK_EDITABLE (window->name_field), 0, -1); + g_autofree gchar *displayed_name = gtk_editable_get_chars (GTK_EDITABLE (self->name_field), 0, -1); if (strcmp (displayed_name, name) != 0) { - gtk_entry_set_text (GTK_ENTRY (window->name_field), name); + gtk_entry_set_text (GTK_ENTRY (self->name_field), name); } - g_free (displayed_name); } } } static void -update_name_field (NautilusPropertiesWindow *window) +update_name_field (NautilusPropertiesWindow *self) { NautilusFile *file; - gtk_label_set_text_with_mnemonic (window->name_title_label, + gtk_label_set_text_with_mnemonic (self->name_title_label, ngettext ("_Name", "_Names", - get_not_gone_original_file_count (window))); + get_not_gone_original_file_count (self))); - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { /* Multifile property dialog, show all names */ GString *str; @@ -672,7 +662,7 @@ update_name_field (NautilusPropertiesWindow *window) first = TRUE; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { file = NAUTILUS_FILE (l->data); @@ -689,7 +679,7 @@ update_name_field (NautilusPropertiesWindow *window) g_free (name); } } - set_name_field (window, NULL, str->str); + set_name_field (self, NULL, str->str); g_string_free (str, TRUE); } else @@ -697,7 +687,7 @@ update_name_field (NautilusPropertiesWindow *window) const char *original_name = NULL; char *current_name; - file = get_original_file (window); + file = get_original_file (self); if (file == NULL || nautilus_file_is_gone (file)) { @@ -713,14 +703,14 @@ update_name_field (NautilusPropertiesWindow *window) * an edit in progress. If the name hasn't changed (but some other * aspect of the file might have), then don't clobber changes. */ - original_name = (const char *) g_object_get_data (G_OBJECT (window->name_field), "original_name"); + original_name = (const char *) g_object_get_data (G_OBJECT (self->name_field), "original_name"); - set_name_field (window, original_name, current_name); + set_name_field (self, original_name, current_name); if (original_name == NULL || g_strcmp0 (original_name, current_name) != 0) { - g_object_set_data_full (G_OBJECT (window->name_field), + g_object_set_data_full (G_OBJECT (self->name_field), "original_name", current_name, g_free); @@ -736,7 +726,7 @@ static void name_field_restore_original_name (GtkWidget *name_field) { const char *original_name; - char *displayed_name; + g_autofree char *displayed_name = NULL; original_name = (const char *) g_object_get_data (G_OBJECT (name_field), "original_name"); @@ -753,8 +743,6 @@ name_field_restore_original_name (GtkWidget *name_field) gtk_entry_set_text (GTK_ENTRY (name_field), original_name); } gtk_editable_select_region (GTK_EDITABLE (name_field), 0, -1); - - g_free (displayed_name); } static void @@ -763,48 +751,44 @@ rename_callback (NautilusFile *file, GError *error, gpointer callback_data) { - NautilusPropertiesWindow *window; - - window = NAUTILUS_PROPERTIES_WINDOW (callback_data); + g_autoptr (NautilusPropertiesWindow) self = NAUTILUS_PROPERTIES_WINDOW (callback_data); /* Complain to user if rename failed. */ if (error != NULL) { nautilus_report_error_renaming_file (file, - window->pending_name, + self->pending_name, error, - GTK_WINDOW (window)); - name_field_restore_original_name (window->name_field); + GTK_WINDOW (self)); + name_field_restore_original_name (self->name_field); } - - g_object_unref (window); } static void -set_pending_name (NautilusPropertiesWindow *window, +set_pending_name (NautilusPropertiesWindow *self, const char *name) { - g_free (window->pending_name); - window->pending_name = g_strdup (name); + g_free (self->pending_name); + self->pending_name = g_strdup (name); } static void name_field_done_editing (GtkWidget *name_field, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { NautilusFile *file; - char *new_name; + g_autofree char *new_name = NULL; const char *original_name; g_return_if_fail (GTK_IS_ENTRY (name_field)); /* Don't apply if the dialog has more than one file */ - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { return; } - file = get_original_file (window); + file = get_original_file (self); /* This gets called when the window is closed, which might be * caused by the file having been deleted. @@ -823,21 +807,19 @@ name_field_done_editing (GtkWidget *name_field, } else { - original_name = (const char *) g_object_get_data (G_OBJECT (window->name_field), + original_name = (const char *) g_object_get_data (G_OBJECT (self->name_field), "original_name"); /* Don't rename if not changed since we read the display name. * This is needed so that we don't save the display name to the * file when nothing is changed */ if (strcmp (new_name, original_name) != 0) { - set_pending_name (window, new_name); - g_object_ref (window); + set_pending_name (self, new_name); + g_object_ref (self); nautilus_file_rename (file, new_name, - rename_callback, window); + rename_callback, self); } } - - g_free (new_name); } static void @@ -860,14 +842,14 @@ name_field_focus_changed (GObject *object, static gboolean select_all_at_idle (gpointer user_data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; - window = NAUTILUS_PROPERTIES_WINDOW (user_data); + self = NAUTILUS_PROPERTIES_WINDOW (user_data); - gtk_editable_select_region (GTK_EDITABLE (window->name_field), + gtk_editable_select_region (GTK_EDITABLE (self->name_field), 0, -1); - window->select_idle_id = 0; + self->select_idle_id = 0; return FALSE; } @@ -876,36 +858,36 @@ static void name_field_activate (GtkWidget *name_field, gpointer user_data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; g_assert (GTK_IS_ENTRY (name_field)); g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (user_data)); - window = NAUTILUS_PROPERTIES_WINDOW (user_data); + self = NAUTILUS_PROPERTIES_WINDOW (user_data); /* Accept changes. */ - name_field_done_editing (name_field, window); + name_field_done_editing (name_field, self); - if (window->select_idle_id == 0) + if (self->select_idle_id == 0) { - window->select_idle_id = g_idle_add (select_all_at_idle, - window); + self->select_idle_id = g_idle_add (select_all_at_idle, + self); } } static void -update_properties_window_title (NautilusPropertiesWindow *window) +update_properties_window_title (NautilusPropertiesWindow *self) { char *name, *title; NautilusFile *file; - g_return_if_fail (GTK_IS_WINDOW (window)); + g_return_if_fail (GTK_IS_WINDOW (self)); title = g_strdup_printf (_("Properties")); - if (!is_multi_file_window (window)) + if (!is_multi_file_window (self)) { - file = get_original_file (window); + file = get_original_file (self); if (file != NULL) { @@ -926,30 +908,30 @@ update_properties_window_title (NautilusPropertiesWindow *window) } } - gtk_window_set_title (GTK_WINDOW (window), title); + gtk_window_set_title (GTK_WINDOW (self), title); g_free (title); } static void -clear_extension_pages (NautilusPropertiesWindow *window) +clear_extension_pages (NautilusPropertiesWindow *self) { int i; int num_pages; GtkWidget *page; num_pages = gtk_notebook_get_n_pages - (GTK_NOTEBOOK (window->notebook)); + (GTK_NOTEBOOK (self->notebook)); for (i = 0; i < num_pages; i++) { page = gtk_notebook_get_nth_page - (GTK_NOTEBOOK (window->notebook), i); + (GTK_NOTEBOOK (self->notebook), i); if (g_object_get_data (G_OBJECT (page), "is-extension-page")) { gtk_notebook_remove_page - (GTK_NOTEBOOK (window->notebook), i); + (GTK_NOTEBOOK (self->notebook), i); num_pages--; i--; } @@ -957,14 +939,14 @@ clear_extension_pages (NautilusPropertiesWindow *window) } static void -refresh_extension_pages (NautilusPropertiesWindow *window) +refresh_extension_pages (NautilusPropertiesWindow *self) { - clear_extension_pages (window); - append_extension_pages (window); + clear_extension_pages (self); + append_extension_pages (self); } static void -remove_from_dialog (NautilusPropertiesWindow *window, +remove_from_dialog (NautilusPropertiesWindow *self, NautilusFile *file) { int index; @@ -973,38 +955,38 @@ remove_from_dialog (NautilusPropertiesWindow *window, NautilusFile *original_file; NautilusFile *target_file; - index = g_list_index (window->target_files, file); + index = g_list_index (self->target_files, file); if (index == -1) { - index = g_list_index (window->original_files, file); + index = g_list_index (self->original_files, file); g_return_if_fail (index != -1); } - original_link = g_list_nth (window->original_files, index); - target_link = g_list_nth (window->target_files, index); + original_link = g_list_nth (self->original_files, index); + target_link = g_list_nth (self->target_files, index); g_return_if_fail (original_link && target_link); original_file = NAUTILUS_FILE (original_link->data); target_file = NAUTILUS_FILE (target_link->data); - window->original_files = g_list_remove_link (window->original_files, original_link); + self->original_files = g_list_remove_link (self->original_files, original_link); g_list_free (original_link); - window->target_files = g_list_remove_link (window->target_files, target_link); + self->target_files = g_list_remove_link (self->target_files, target_link); g_list_free (target_link); - g_hash_table_remove (window->initial_permissions, target_file); + g_hash_table_remove (self->initial_permissions, target_file); g_signal_handlers_disconnect_by_func (original_file, G_CALLBACK (file_changed_callback), - window); + self); g_signal_handlers_disconnect_by_func (target_file, G_CALLBACK (file_changed_callback), - window); + self); - nautilus_file_monitor_remove (original_file, &window->original_files); - nautilus_file_monitor_remove (target_file, &window->target_files); + nautilus_file_monitor_remove (original_file, &self->original_files); + nautilus_file_monitor_remove (target_file, &self->target_files); nautilus_file_unref (original_file); nautilus_file_unref (target_file); @@ -1028,13 +1010,13 @@ mime_list_equal (GList *a, } static GList * -get_mime_list (NautilusPropertiesWindow *window) +get_mime_list (NautilusPropertiesWindow *self) { GList *ret; GList *l; ret = NULL; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { ret = g_list_append (ret, nautilus_file_get_mime_type (NAUTILUS_FILE (l->data))); } @@ -1043,55 +1025,55 @@ get_mime_list (NautilusPropertiesWindow *window) } static gboolean -start_spinner_callback (NautilusPropertiesWindow *window) +start_spinner_callback (NautilusPropertiesWindow *self) { - gtk_widget_show (window->contents_spinner); - gtk_spinner_start (GTK_SPINNER (window->contents_spinner)); - window->deep_count_spinner_timeout_id = 0; + gtk_widget_show (self->contents_spinner); + gtk_spinner_start (GTK_SPINNER (self->contents_spinner)); + self->deep_count_spinner_timeout_id = 0; return FALSE; } static void -schedule_start_spinner (NautilusPropertiesWindow *window) +schedule_start_spinner (NautilusPropertiesWindow *self) { - if (window->deep_count_spinner_timeout_id == 0) + if (self->deep_count_spinner_timeout_id == 0) { - window->deep_count_spinner_timeout_id + self->deep_count_spinner_timeout_id = g_timeout_add_seconds (1, (GSourceFunc) start_spinner_callback, - window); + self); } } static void -stop_spinner (NautilusPropertiesWindow *window) +stop_spinner (NautilusPropertiesWindow *self) { - gtk_spinner_stop (GTK_SPINNER (window->contents_spinner)); - gtk_widget_hide (window->contents_spinner); - if (window->deep_count_spinner_timeout_id > 0) + gtk_spinner_stop (GTK_SPINNER (self->contents_spinner)); + gtk_widget_hide (self->contents_spinner); + if (self->deep_count_spinner_timeout_id > 0) { - g_source_remove (window->deep_count_spinner_timeout_id); - window->deep_count_spinner_timeout_id = 0; + g_source_remove (self->deep_count_spinner_timeout_id); + self->deep_count_spinner_timeout_id = 0; } } static void -stop_deep_count_for_file (NautilusPropertiesWindow *window, +stop_deep_count_for_file (NautilusPropertiesWindow *self, NautilusFile *file) { - if (g_list_find (window->deep_count_files, file)) + if (g_list_find (self->deep_count_files, file)) { g_signal_handlers_disconnect_by_func (file, G_CALLBACK (schedule_directory_contents_update), - window); + self); nautilus_file_unref (file); - window->deep_count_files = g_list_remove (window->deep_count_files, file); + self->deep_count_files = g_list_remove (self->deep_count_files, file); } } static void -start_deep_count_for_file (NautilusPropertiesWindow *window, +start_deep_count_for_file (NautilusPropertiesWindow *self, NautilusFile *file) { if (!nautilus_file_is_directory (file)) @@ -1099,25 +1081,25 @@ start_deep_count_for_file (NautilusPropertiesWindow *window, return; } - if (!g_list_find (window->deep_count_files, file)) + if (!g_list_find (self->deep_count_files, file)) { nautilus_file_ref (file); - window->deep_count_files = g_list_prepend (window->deep_count_files, file); + self->deep_count_files = g_list_prepend (self->deep_count_files, file); nautilus_file_recompute_deep_counts (file); - if (!window->deep_count_finished) + if (!self->deep_count_finished) { g_signal_connect_object (file, "updated-deep-count-in-progress", G_CALLBACK (schedule_directory_contents_update), - window, G_CONNECT_SWAPPED); - schedule_start_spinner (window); + self, G_CONNECT_SWAPPED); + schedule_start_spinner (self); } } } static void -properties_window_update (NautilusPropertiesWindow *window, +properties_window_update (NautilusPropertiesWindow *self, GList *files) { GList *l; @@ -1140,21 +1122,21 @@ properties_window_update (NautilusPropertiesWindow *window, if (changed_file && nautilus_file_is_gone (changed_file)) { /* Remove the file from the property dialog */ - remove_from_dialog (window, changed_file); + remove_from_dialog (self, changed_file); changed_file = NULL; - if (window->original_files == NULL) + if (self->original_files == NULL) { return; } } if (changed_file == NULL || - g_list_find (window->original_files, changed_file)) + g_list_find (self->original_files, changed_file)) { dirty_original = TRUE; } if (changed_file == NULL || - g_list_find (window->target_files, changed_file)) + g_list_find (self->target_files, changed_file)) { dirty_target = TRUE; } @@ -1162,9 +1144,9 @@ properties_window_update (NautilusPropertiesWindow *window, if (dirty_original) { - update_properties_window_title (window); - update_properties_window_icon (window); - update_name_field (window); + update_properties_window_title (self); + update_properties_window_icon (self); + update_name_field (self); /* If any of the value fields start to depend on the original * value, value_field_updates should be added here */ @@ -1172,76 +1154,76 @@ properties_window_update (NautilusPropertiesWindow *window, if (dirty_target) { - for (l = window->permission_buttons; l != NULL; l = l->next) + for (l = self->permission_buttons; l != NULL; l = l->next) { - permission_button_update (window, GTK_TOGGLE_BUTTON (l->data)); + permission_button_update (self, GTK_TOGGLE_BUTTON (l->data)); } - for (l = window->permission_combos; l != NULL; l = l->next) + for (l = self->permission_combos; l != NULL; l = l->next) { - permission_combo_update (window, GTK_COMBO_BOX (l->data)); + permission_combo_update (self, GTK_COMBO_BOX (l->data)); } - for (l = window->value_fields; l != NULL; l = l->next) + for (l = self->value_fields; l != NULL; l = l->next) { - value_field_update (window, GTK_LABEL (l->data)); + value_field_update (self, GTK_LABEL (l->data)); } } - mime_list = get_mime_list (window); + mime_list = get_mime_list (self); - if (!window->mime_list) + if (!self->mime_list) { - window->mime_list = mime_list; + self->mime_list = mime_list; } else { - if (!mime_list_equal (window->mime_list, mime_list)) + if (!mime_list_equal (self->mime_list, mime_list)) { - refresh_extension_pages (window); + refresh_extension_pages (self); } - g_list_free_full (window->mime_list, g_free); - window->mime_list = mime_list; + g_list_free_full (self->mime_list, g_free); + self->mime_list = mime_list; } } static gboolean update_files_callback (gpointer data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; - window = NAUTILUS_PROPERTIES_WINDOW (data); + self = NAUTILUS_PROPERTIES_WINDOW (data); - window->update_files_timeout_id = 0; + self->update_files_timeout_id = 0; - properties_window_update (window, window->changed_files); + properties_window_update (self, self->changed_files); - if (window->original_files == NULL) + if (self->original_files == NULL) { /* Close the window if no files are left */ - gtk_widget_destroy (GTK_WIDGET (window)); + gtk_widget_destroy (GTK_WIDGET (self)); } else { - nautilus_file_list_free (window->changed_files); - window->changed_files = NULL; + nautilus_file_list_free (self->changed_files); + self->changed_files = NULL; } return FALSE; } static void -schedule_files_update (NautilusPropertiesWindow *window) +schedule_files_update (NautilusPropertiesWindow *self) { - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); - if (window->update_files_timeout_id == 0) + if (self->update_files_timeout_id == 0) { - window->update_files_timeout_id + self->update_files_timeout_id = g_timeout_add (FILES_UPDATE_INTERVAL, update_files_callback, - window); + self); } } @@ -1250,10 +1232,9 @@ file_list_attributes_identical (GList *file_list, const char *attribute_name) { gboolean identical; - char *first_attr; + g_autofree char *first_attr = NULL; GList *l; - first_attr = NULL; identical = TRUE; for (l = file_list; l != NULL; l = l->next) @@ -1273,19 +1254,16 @@ file_list_attributes_identical (GList *file_list, } else { - char *attr; + g_autofree char *attr = NULL; attr = nautilus_file_get_string_attribute_with_default (file, attribute_name); if (strcmp (attr, first_attr)) { identical = FALSE; - g_free (attr); break; } - g_free (attr); } } - g_free (first_attr); return identical; } @@ -1337,25 +1315,24 @@ file_list_all_directories (GList *file_list) "\xE2\x80\x92" static gboolean -location_show_original (NautilusPropertiesWindow *window) +location_show_original (NautilusPropertiesWindow *self) { NautilusFile *file; /* there is no way a recent item will be mixed with * other items so just pick the first file to check */ - file = NAUTILUS_FILE (g_list_nth_data (window->original_files, 0)); + file = NAUTILUS_FILE (g_list_nth_data (self->original_files, 0)); return (file != NULL && !nautilus_file_is_in_recent (file)); } static void -value_field_update (NautilusPropertiesWindow *window, +value_field_update (NautilusPropertiesWindow *self, GtkLabel *label) { GList *file_list; const char *attribute_name; - char *attribute_value; + g_autofree char *attribute_value = NULL; char *inconsistent_string; - char *mime_type, *tmp; gboolean is_where; g_assert (GTK_IS_LABEL (label)); @@ -1363,13 +1340,13 @@ value_field_update (NautilusPropertiesWindow *window, attribute_name = g_object_get_data (G_OBJECT (label), "file_attribute"); is_where = (g_strcmp0 (attribute_name, "where") == 0); - if (is_where && location_show_original (window)) + if (is_where && location_show_original (self)) { - file_list = window->original_files; + file_list = self->original_files; } else { - file_list = window->target_files; + file_list = self->target_files; } inconsistent_string = INCONSISTENT_STATE_STRING; @@ -1378,20 +1355,17 @@ value_field_update (NautilusPropertiesWindow *window, inconsistent_string); if (!strcmp (attribute_name, "detailed_type") && strcmp (attribute_value, inconsistent_string)) { - mime_type = file_list_get_string_attribute (file_list, - "mime_type", - inconsistent_string); + g_autofree char *mime_type = file_list_get_string_attribute (file_list, + "mime_type", + inconsistent_string); if (strcmp (mime_type, inconsistent_string)) { - tmp = attribute_value; - attribute_value = g_strdup_printf (C_("MIME type description (MIME type)", "%s (%s)"), attribute_value, mime_type); - g_free (tmp); + g_autofree char *tmp = g_steal_pointer (&attribute_value); + attribute_value = g_strdup_printf (C_("MIME type description (MIME type)", "%s (%s)"), tmp, mime_type); } - g_free (mime_type); } gtk_label_set_text (label, attribute_value); - g_free (attribute_value); } static void @@ -1410,7 +1384,7 @@ group_change_callback (NautilusFile *file, GError *error, GroupChange *change) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (change->window)); g_assert (NAUTILUS_IS_FILE (change->file)); @@ -1423,10 +1397,10 @@ group_change_callback (NautilusFile *file, nautilus_report_error_setting_group (change->file, error, change->window); } - window = NAUTILUS_PROPERTIES_WINDOW (change->window); - if (window->group_change == change) + self = NAUTILUS_PROPERTIES_WINDOW (change->window); + if (self->group_change == change) { - window->group_change = NULL; + self->group_change = NULL; } group_change_free (change); @@ -1465,37 +1439,37 @@ schedule_group_change_timeout (GroupChange *change) } static void -schedule_group_change (NautilusPropertiesWindow *window, +schedule_group_change (NautilusPropertiesWindow *self, NautilusFile *file, const char *group) { GroupChange *change; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); - g_assert (window->group_change == NULL); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); + g_assert (self->group_change == NULL); g_assert (NAUTILUS_IS_FILE (file)); change = g_new0 (GroupChange, 1); change->file = nautilus_file_ref (file); change->group = g_strdup (group); - change->window = GTK_WINDOW (g_object_ref (window)); + change->window = GTK_WINDOW (g_object_ref (self)); change->timeout = g_timeout_add (CHOWN_CHGRP_TIMEOUT, (GSourceFunc) schedule_group_change_timeout, change); - window->group_change = change; + self->group_change = change; } static void -unschedule_or_cancel_group_change (NautilusPropertiesWindow *window) +unschedule_or_cancel_group_change (NautilusPropertiesWindow *self) { GroupChange *change; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); - change = window->group_change; + change = self->group_change; if (change != NULL) { @@ -1511,7 +1485,7 @@ unschedule_or_cancel_group_change (NautilusPropertiesWindow *window) group_change_free (change); } - window->group_change = NULL; + self->group_change = NULL; } } @@ -1519,9 +1493,9 @@ static void changed_group_callback (GtkComboBox *combo_box, NautilusFile *file) { - NautilusPropertiesWindow *window; - char *group; - char *cur_group; + NautilusPropertiesWindow *self; + g_autofree char *group = NULL; + g_autofree char *cur_group = NULL; g_assert (GTK_IS_COMBO_BOX (combo_box)); g_assert (NAUTILUS_IS_FILE (file)); @@ -1532,13 +1506,11 @@ changed_group_callback (GtkComboBox *combo_box, if (group != NULL && strcmp (group, cur_group) != 0) { /* Try to change file group. If this fails, complain to user. */ - window = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (combo_box), GTK_TYPE_WINDOW)); + self = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (combo_box), GTK_TYPE_WINDOW)); - unschedule_or_cancel_group_change (window); - schedule_group_change (window, file, group); + unschedule_or_cancel_group_change (self); + schedule_group_change (self, file, group); } - g_free (group); - g_free (cur_group); } /* checks whether the given column at the first level @@ -1668,7 +1640,7 @@ synch_groups_combo_box (GtkComboBox *combo_box, GtkTreeModel *model; GtkListStore *store; const char *group_name; - char *current_group_name; + g_autofree char *current_group_name = NULL; int group_index; int current_group_index; @@ -1721,7 +1693,6 @@ synch_groups_combo_box (GtkComboBox *combo_box, } gtk_combo_box_set_active (combo_box, current_group_index); - g_free (current_group_name); g_list_free_full (groups, g_free); } @@ -1730,8 +1701,7 @@ combo_box_row_separator_func (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { - gchar *text; - gboolean ret; + g_autofree gchar *text = NULL; gtk_tree_model_get (model, iter, 0, &text, -1); @@ -1742,15 +1712,12 @@ combo_box_row_separator_func (GtkTreeModel *model, if (strcmp (text, "-") == 0) { - ret = TRUE; + return TRUE; } else { - ret = FALSE; + return FALSE; } - - g_free (text); - return ret; } static void @@ -1790,7 +1757,7 @@ owner_change_callback (NautilusFile *file, GError *error, OwnerChange *change) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (change->window)); g_assert (NAUTILUS_IS_FILE (change->file)); @@ -1803,10 +1770,10 @@ owner_change_callback (NautilusFile *file, nautilus_report_error_setting_owner (file, error, change->window); } - window = NAUTILUS_PROPERTIES_WINDOW (change->window); - if (window->owner_change == change) + self = NAUTILUS_PROPERTIES_WINDOW (change->window); + if (self->owner_change == change) { - window->owner_change = NULL; + self->owner_change = NULL; } owner_change_free (change); @@ -1845,37 +1812,37 @@ schedule_owner_change_timeout (OwnerChange *change) } static void -schedule_owner_change (NautilusPropertiesWindow *window, +schedule_owner_change (NautilusPropertiesWindow *self, NautilusFile *file, const char *owner) { OwnerChange *change; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); - g_assert (window->owner_change == NULL); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); + g_assert (self->owner_change == NULL); g_assert (NAUTILUS_IS_FILE (file)); change = g_new0 (OwnerChange, 1); change->file = nautilus_file_ref (file); change->owner = g_strdup (owner); - change->window = GTK_WINDOW (g_object_ref (window)); + change->window = GTK_WINDOW (g_object_ref (self)); change->timeout = g_timeout_add (CHOWN_CHGRP_TIMEOUT, (GSourceFunc) schedule_owner_change_timeout, change); - window->owner_change = change; + self->owner_change = change; } static void -unschedule_or_cancel_owner_change (NautilusPropertiesWindow *window) +unschedule_or_cancel_owner_change (NautilusPropertiesWindow *self) { OwnerChange *change; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); - change = window->owner_change; + change = self->owner_change; if (change != NULL) { @@ -1893,7 +1860,7 @@ unschedule_or_cancel_owner_change (NautilusPropertiesWindow *window) owner_change_free (change); } - window->owner_change = NULL; + self->owner_change = NULL; } } @@ -1901,9 +1868,9 @@ static void changed_owner_callback (GtkComboBox *combo_box, NautilusFile *file) { - NautilusPropertiesWindow *window; - char *new_owner; - char *cur_owner; + NautilusPropertiesWindow *self; + g_autofree char *new_owner = NULL; + g_autofree char *cur_owner = NULL; g_assert (GTK_IS_COMBO_BOX (combo_box)); g_assert (NAUTILUS_IS_FILE (file)); @@ -1918,13 +1885,11 @@ changed_owner_callback (GtkComboBox *combo_box, if (strcmp (new_owner, cur_owner) != 0) { /* Try to change file owner. If this fails, complain to user. */ - window = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (combo_box), GTK_TYPE_WINDOW)); + self = NAUTILUS_PROPERTIES_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET (combo_box), GTK_TYPE_WINDOW)); - unschedule_or_cancel_owner_change (window); - schedule_owner_change (window, file, new_owner); + unschedule_or_cancel_owner_change (self); + schedule_owner_change (self, file, new_owner); } - g_free (new_owner); - g_free (cur_owner); } static void @@ -1937,12 +1902,11 @@ synch_user_menu (GtkComboBox *combo_box, GtkListStore *store; GtkTreeIter iter; char *user_name; - char *owner_name; - char *nice_owner_name; + g_autofree char *owner_name = NULL; + g_autofree char *nice_owner_name = NULL; int user_index; int owner_index; - char **name_array; - char *combo_text; + g_assert (GTK_IS_COMBO_BOX (combo_box)); g_assert (NAUTILUS_IS_FILE (file)); @@ -1968,6 +1932,8 @@ synch_user_menu (GtkComboBox *combo_box, for (node = users, user_index = 0; node != NULL; node = node->next, ++user_index) { + g_auto (GStrv) name_array = NULL; + g_autofree char *combo_text; user_name = (char *) node->data; name_array = g_strsplit (user_name, "\n", 2); @@ -1986,9 +1952,6 @@ synch_user_menu (GtkComboBox *combo_box, 1, user_name, 2, name_array[0], -1); - - g_strfreev (name_array); - g_free (combo_text); } } @@ -2025,8 +1988,6 @@ synch_user_menu (GtkComboBox *combo_box, gtk_combo_box_set_active (combo_box, owner_index); - g_free (owner_name); - g_free (nice_owner_name); g_list_free_full (users, g_free); } @@ -2034,12 +1995,11 @@ static void setup_owner_combo_box (GtkWidget *combo_box, NautilusFile *file) { - GtkTreeModel *model; + g_autoptr (GtkTreeModel) model = NULL; GtkCellRenderer *renderer; model = GTK_TREE_MODEL (gtk_list_store_new (3, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING)); gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), model); - g_object_unref (G_OBJECT (model)); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo_box), renderer, TRUE); @@ -2095,10 +2055,10 @@ file_has_prefix (NautilusFile *file, } static void -directory_contents_value_field_update (NautilusPropertiesWindow *window) +directory_contents_value_field_update (NautilusPropertiesWindow *self) { NautilusRequestStatus file_status; - char *text, *temp; + g_autofree char *text = NULL; guint directory_count; guint file_count; guint total_count; @@ -2110,17 +2070,17 @@ directory_contents_value_field_update (NautilusPropertiesWindow *window) goffset file_size; gboolean deep_count_active; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); total_count = 0; total_size = 0; unreadable_directory_count = FALSE; - for (l = window->target_files; l; l = l->next) + for (l = self->target_files; l; l = l->next) { file = NAUTILUS_FILE (l->data); - if (file_has_prefix (file, window->target_files)) + if (file_has_prefix (file, self->target_files)) { /* don't count nested files twice */ continue; @@ -2144,7 +2104,7 @@ directory_contents_value_field_update (NautilusPropertiesWindow *window) if (file_status == NAUTILUS_REQUEST_DONE) { - stop_deep_count_for_file (window, file); + stop_deep_count_for_file (self, file); } } else @@ -2154,12 +2114,12 @@ directory_contents_value_field_update (NautilusPropertiesWindow *window) } } - deep_count_active = (window->deep_count_files != NULL); + deep_count_active = (self->deep_count_files != NULL); /* If we've already displayed the total once, don't do another visible * count-up if the deep_count happens to get invalidated. * But still display the new total, since it might have changed. */ - if (window->deep_count_finished && deep_count_active) + if (self->deep_count_finished && deep_count_active) { return; } @@ -2186,89 +2146,86 @@ directory_contents_value_field_update (NautilusPropertiesWindow *window) } else { - char *size_str; + g_autofree char *size_str = NULL; size_str = g_format_size (total_size); text = g_strdup_printf (ngettext ("%'d item, with size %s", "%'d items, totalling %s", total_count), total_count, size_str); - g_free (size_str); if (unreadable_directory_count != 0) { + g_autofree char *temp; temp = text; text = g_strconcat (temp, "\n", _("(some contents unreadable)"), NULL); - g_free (temp); } } - gtk_label_set_text (GTK_LABEL (window->contents_value_label), + gtk_label_set_text (GTK_LABEL (self->contents_value_label), text); - g_free (text); if (!deep_count_active) { - window->deep_count_finished = TRUE; - stop_spinner (window); + self->deep_count_finished = TRUE; + stop_spinner (self); } } static gboolean update_directory_contents_callback (gpointer data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; - window = NAUTILUS_PROPERTIES_WINDOW (data); + self = NAUTILUS_PROPERTIES_WINDOW (data); - window->update_directory_contents_timeout_id = 0; - directory_contents_value_field_update (window); + self->update_directory_contents_timeout_id = 0; + directory_contents_value_field_update (self); return FALSE; } static void -schedule_directory_contents_update (NautilusPropertiesWindow *window) +schedule_directory_contents_update (NautilusPropertiesWindow *self) { - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); - if (window->update_directory_contents_timeout_id == 0) + if (self->update_directory_contents_timeout_id == 0) { - window->update_directory_contents_timeout_id + self->update_directory_contents_timeout_id = g_timeout_add (DIRECTORY_CONTENTS_UPDATE_INTERVAL, update_directory_contents_callback, - window); + self); } } static void -setup_contents_field (NautilusPropertiesWindow *window, +setup_contents_field (NautilusPropertiesWindow *self, GtkGrid *grid) { GList *l; - for (l = window->target_files; l; l = l->next) + for (l = self->target_files; l; l = l->next) { NautilusFile *file; file = NAUTILUS_FILE (l->data); - start_deep_count_for_file (window, file); + start_deep_count_for_file (self, file); } /* Fill in the initial value. */ - directory_contents_value_field_update (window); + directory_contents_value_field_update (self); } static gboolean is_root_directory (NautilusFile *file) { - GFile *location; + g_autoptr (GFile) location = NULL; gboolean result; location = nautilus_file_get_location (file); result = nautilus_is_root_directory (location); - g_object_unref (location); return result; } @@ -2276,33 +2233,27 @@ is_root_directory (NautilusFile *file) static gboolean is_network_directory (NautilusFile *file) { - char *file_uri; - gboolean result; + g_autofree char *file_uri = NULL; file_uri = nautilus_file_get_uri (file); - result = strcmp (file_uri, "network:///") == 0; - g_free (file_uri); - return result; + return strcmp (file_uri, "network:///") == 0; } static gboolean is_burn_directory (NautilusFile *file) { - char *file_uri; - gboolean result; + g_autofree char *file_uri = NULL; file_uri = nautilus_file_get_uri (file); - result = strcmp (file_uri, "burn:///") == 0; - g_free (file_uri); - return result; + return strcmp (file_uri, "burn:///") == 0; } static gboolean -should_show_custom_icon_buttons (NautilusPropertiesWindow *window) +should_show_custom_icon_buttons (NautilusPropertiesWindow *self) { - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { return FALSE; } @@ -2311,12 +2262,12 @@ should_show_custom_icon_buttons (NautilusPropertiesWindow *window) } static gboolean -should_show_file_type (NautilusPropertiesWindow *window) +should_show_file_type (NautilusPropertiesWindow *self) { - if (!is_multi_file_window (window) - && (nautilus_file_is_in_trash (get_target_file (window)) || - is_network_directory (get_target_file (window)) || - is_burn_directory (get_target_file (window)))) + if (!is_multi_file_window (self) + && (nautilus_file_is_in_trash (get_target_file (self)) || + is_network_directory (get_target_file (self)) || + is_burn_directory (get_target_file (self)))) { return FALSE; } @@ -2326,11 +2277,11 @@ should_show_file_type (NautilusPropertiesWindow *window) } static gboolean -should_show_location_info (NautilusPropertiesWindow *window) +should_show_location_info (NautilusPropertiesWindow *self) { GList *l; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (nautilus_file_is_in_trash (NAUTILUS_FILE (l->data)) || is_root_directory (NAUTILUS_FILE (l->data)) || @@ -2345,11 +2296,11 @@ should_show_location_info (NautilusPropertiesWindow *window) } static gboolean -should_show_trash_orig_path (NautilusPropertiesWindow *window) +should_show_trash_orig_path (NautilusPropertiesWindow *self) { GList *l; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (!nautilus_file_is_in_trash (NAUTILUS_FILE (l->data))) { @@ -2361,14 +2312,14 @@ should_show_trash_orig_path (NautilusPropertiesWindow *window) } static gboolean -should_show_accessed_date (NautilusPropertiesWindow *window) +should_show_accessed_date (NautilusPropertiesWindow *self) { /* Accessed date for directory seems useless. If we some * day decide that it is useful, we should separately * consider whether it's useful for "trash:". */ - if (file_list_all_directories (window->target_files) - || is_multi_file_window (window)) + if (file_list_all_directories (self->target_files) + || is_multi_file_window (self)) { return FALSE; } @@ -2377,17 +2328,17 @@ should_show_accessed_date (NautilusPropertiesWindow *window) } static gboolean -should_show_modified_date (NautilusPropertiesWindow *window) +should_show_modified_date (NautilusPropertiesWindow *self) { - return !is_multi_file_window (window); + return !is_multi_file_window (self); } static gboolean -should_show_trashed_on (NautilusPropertiesWindow *window) +should_show_trashed_on (NautilusPropertiesWindow *self) { GList *l; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (!nautilus_file_is_in_trash (NAUTILUS_FILE (l->data))) { @@ -2399,10 +2350,10 @@ should_show_trashed_on (NautilusPropertiesWindow *window) } static gboolean -should_show_link_target (NautilusPropertiesWindow *window) +should_show_link_target (NautilusPropertiesWindow *self) { - if (!is_multi_file_window (window) - && nautilus_file_is_symbolic_link (get_target_file (window))) + if (!is_multi_file_window (self) + && nautilus_file_is_symbolic_link (get_target_file (self))) { return TRUE; } @@ -2411,18 +2362,18 @@ should_show_link_target (NautilusPropertiesWindow *window) } static gboolean -should_show_free_space (NautilusPropertiesWindow *window) +should_show_free_space (NautilusPropertiesWindow *self) { - if (!is_multi_file_window (window) - && (nautilus_file_is_in_trash (get_target_file (window)) || - is_network_directory (get_target_file (window)) || - nautilus_file_is_in_recent (get_target_file (window)) || - is_burn_directory (get_target_file (window)))) + if (!is_multi_file_window (self) + && (nautilus_file_is_in_trash (get_target_file (self)) || + is_network_directory (get_target_file (self)) || + nautilus_file_is_in_recent (get_target_file (self)) || + is_burn_directory (get_target_file (self)))) { return FALSE; } - if (file_list_all_directories (window->target_files)) + if (file_list_all_directories (self->target_files)) { return TRUE; } @@ -2431,16 +2382,16 @@ should_show_free_space (NautilusPropertiesWindow *window) } static gboolean -should_show_volume_info (NautilusPropertiesWindow *window) +should_show_volume_info (NautilusPropertiesWindow *self) { NautilusFile *file; - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { return FALSE; } - file = get_original_file (window); + file = get_original_file (self); if (file == NULL) { @@ -2456,17 +2407,17 @@ should_show_volume_info (NautilusPropertiesWindow *window) } static gboolean -should_show_volume_usage (NautilusPropertiesWindow *window) +should_show_volume_usage (NautilusPropertiesWindow *self) { NautilusFile *file; gboolean success = FALSE; - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { return FALSE; } - file = get_original_file (window); + file = get_original_file (self); if (file == NULL) { @@ -2580,13 +2531,13 @@ paint_pie_chart (GtkWidget *widget, cairo_t *cr, gpointer data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; double free, used, reserved; - window = NAUTILUS_PROPERTIES_WINDOW (data); + self = NAUTILUS_PROPERTIES_WINDOW (data); - free = (double) window->volume_free / (double) window->volume_capacity; - used = (double) window->volume_used / (double) window->volume_capacity; + free = (double) self->volume_free / (double) self->volume_capacity; + used = (double) self->volume_used / (double) self->volume_capacity; reserved = 1.0 - (used + free); paint_slice (widget, cr, @@ -2599,34 +2550,34 @@ paint_pie_chart (GtkWidget *widget, } static void -setup_pie_widget (NautilusPropertiesWindow *window) +setup_pie_widget (NautilusPropertiesWindow *self) { NautilusFile *file; - gchar *capacity; - gchar *used; - gchar *free; + g_autofree gchar *capacity = NULL; + g_autofree gchar *used = NULL; + g_autofree gchar *free = NULL; const char *fs_type; - gchar *uri; - GFile *location; - GFileInfo *info; + g_autofree gchar *uri = NULL; + g_autoptr (GFile) location = NULL; + g_autoptr (GFileInfo) info = NULL; - capacity = g_format_size (window->volume_capacity); - free = g_format_size (window->volume_free); - used = g_format_size (window->volume_used); + capacity = g_format_size (self->volume_capacity); + free = g_format_size (self->volume_free); + used = g_format_size (self->volume_used); - file = get_original_file (window); + file = get_original_file (self); uri = nautilus_file_get_activation_uri (file); /* Translators: "used" refers to the capacity of the filesystem */ - gtk_label_set_text (GTK_LABEL (window->used_value), used); + gtk_label_set_text (GTK_LABEL (self->used_value), used); /* Translators: "free" refers to the capacity of the filesystem */ - gtk_label_set_text (GTK_LABEL (window->free_value), free); + gtk_label_set_text (GTK_LABEL (self->free_value), free); - gtk_label_set_text (GTK_LABEL (window->total_capacity_value), capacity); + gtk_label_set_text (GTK_LABEL (self->total_capacity_value), capacity); - gtk_label_set_text (GTK_LABEL (window->file_system_value), NULL); + gtk_label_set_text (GTK_LABEL (self->file_system_value), NULL); location = g_file_new_for_uri (uri); info = g_file_query_filesystem_info (location, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE, @@ -2636,35 +2587,27 @@ setup_pie_widget (NautilusPropertiesWindow *window) fs_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE); if (fs_type != NULL) { - gtk_label_set_text (GTK_LABEL (window->file_system_value), fs_type); + gtk_label_set_text (GTK_LABEL (self->file_system_value), fs_type); } - - g_object_unref (info); } - g_object_unref (location); - g_free (uri); - g_free (capacity); - g_free (used); - g_free (free); - - g_signal_connect (window->pie_chart, "draw", - G_CALLBACK (paint_pie_chart), window); - g_signal_connect (window->used_color, "draw", - G_CALLBACK (paint_legend), window); - g_signal_connect (window->free_color, "draw", - G_CALLBACK (paint_legend), window); + g_signal_connect (self->pie_chart, "draw", + G_CALLBACK (paint_pie_chart), self); + g_signal_connect (self->used_color, "draw", + G_CALLBACK (paint_legend), self); + g_signal_connect (self->free_color, "draw", + G_CALLBACK (paint_legend), self); } static void -setup_volume_usage_widget (NautilusPropertiesWindow *window) +setup_volume_usage_widget (NautilusPropertiesWindow *self) { gchar *uri; NautilusFile *file; - GFile *location; + g_autoptr (GFile) location = NULL; GFileInfo *info; - file = get_original_file (window); + file = get_original_file (self); uri = nautilus_file_get_activation_uri (file); @@ -2673,31 +2616,29 @@ setup_volume_usage_widget (NautilusPropertiesWindow *window) if (info) { - window->volume_capacity = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE); - window->volume_free = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE); + self->volume_capacity = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_SIZE); + self->volume_free = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_FREE); if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_FILESYSTEM_USED)) { - window->volume_used = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_USED); + self->volume_used = g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_FILESYSTEM_USED); } else { - window->volume_used = window->volume_capacity - window->volume_free; + self->volume_used = self->volume_capacity - self->volume_free; } g_object_unref (info); } else { - window->volume_capacity = 0; - window->volume_free = 0; - window->volume_used = 0; + self->volume_capacity = 0; + self->volume_free = 0; + self->volume_used = 0; } - g_object_unref (location); - - if (window->volume_capacity > 0) + if (self->volume_capacity > 0) { - setup_pie_widget (window); + setup_pie_widget (self); } } @@ -2727,181 +2668,181 @@ open_in_disks (GtkButton *button, } static void -setup_basic_page (NautilusPropertiesWindow *window) +setup_basic_page (NautilusPropertiesWindow *self) { GtkGrid *grid; /* Icon pixmap */ - setup_image_widget (window, should_show_custom_icon_buttons (window)); + setup_image_widget (self, should_show_custom_icon_buttons (self)); - window->icon_chooser = NULL; + self->icon_chooser = NULL; /* Grid */ - grid = window->basic_grid; + grid = self->basic_grid; - update_name_field (window); + update_name_field (self); - g_signal_connect_object (window->name_field, "notify::has-focus", - G_CALLBACK (name_field_focus_changed), window, 0); - g_signal_connect_object (window->name_field, "activate", - G_CALLBACK (name_field_activate), window, 0); + g_signal_connect_object (self->name_field, "notify::has-focus", + G_CALLBACK (name_field_focus_changed), self, 0); + g_signal_connect_object (self->name_field, "activate", + G_CALLBACK (name_field_activate), self, 0); /* Start with name field selected, if it's an entry. */ - if (GTK_IS_ENTRY (gtk_stack_get_visible_child (window->name_stack))) + if (GTK_IS_ENTRY (gtk_stack_get_visible_child (self->name_stack))) { - gtk_widget_grab_focus (GTK_WIDGET (window->name_field)); + gtk_widget_grab_focus (GTK_WIDGET (self->name_field)); } - if (should_show_file_type (window)) + if (should_show_file_type (self)) { - gtk_widget_show (window->type_title_label); - gtk_widget_show (window->type_value_label); - g_object_set_data_full (G_OBJECT (window->type_value_label), "file_attribute", + gtk_widget_show (self->type_title_label); + gtk_widget_show (self->type_value_label); + g_object_set_data_full (G_OBJECT (self->type_value_label), "file_attribute", g_strdup ("detailed_type"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->type_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->type_value_label); } - if (should_show_link_target (window)) + if (should_show_link_target (self)) { - gtk_widget_show (window->link_target_title_label); - gtk_widget_show (window->link_target_value_label); - g_object_set_data_full (G_OBJECT (window->link_target_value_label), "file_attribute", + gtk_widget_show (self->link_target_title_label); + gtk_widget_show (self->link_target_value_label); + g_object_set_data_full (G_OBJECT (self->link_target_value_label), "file_attribute", g_strdup ("link_target"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->link_target_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->link_target_value_label); } - if (is_multi_file_window (window) || - nautilus_file_is_directory (get_target_file (window))) + if (is_multi_file_window (self) || + nautilus_file_is_directory (get_target_file (self))) { - gtk_widget_show (window->contents_title_label); - gtk_widget_show (window->contents_value_label); - setup_contents_field (window, grid); + gtk_widget_show (self->contents_title_label); + gtk_widget_show (self->contents_value_label); + setup_contents_field (self, grid); } else { - gtk_widget_show (window->size_title_label); - gtk_widget_show (window->size_value_label); + gtk_widget_show (self->size_title_label); + gtk_widget_show (self->size_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ - g_object_set_data_full (G_OBJECT (window->size_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->size_value_label), "file_attribute", g_strdup ("size_detail"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->size_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->size_value_label); } - if (should_show_location_info (window)) + if (should_show_location_info (self)) { - gtk_widget_show (window->parent_folder_title_label); - gtk_widget_show (window->parent_folder_value_label); + gtk_widget_show (self->parent_folder_title_label); + gtk_widget_show (self->parent_folder_value_label); - g_object_set_data_full (G_OBJECT (window->parent_folder_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->parent_folder_value_label), "file_attribute", g_strdup ("where"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->parent_folder_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->parent_folder_value_label); } - if (should_show_trash_orig_path (window)) + if (should_show_trash_orig_path (self)) { - gtk_widget_show (window->original_folder_title_label); - gtk_widget_show (window->original_folder_value_label); - g_object_set_data_full (G_OBJECT (window->original_folder_value_label), "file_attribute", + gtk_widget_show (self->original_folder_title_label); + gtk_widget_show (self->original_folder_value_label); + g_object_set_data_full (G_OBJECT (self->original_folder_value_label), "file_attribute", g_strdup ("trash_orig_path"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->original_folder_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->original_folder_value_label); } - if (should_show_volume_info (window)) + if (should_show_volume_info (self)) { - gtk_widget_show (window->volume_title_label); - gtk_widget_show (window->volume_value_label); - g_object_set_data_full (G_OBJECT (window->volume_value_label), "file_attribute", + gtk_widget_show (self->volume_title_label); + gtk_widget_show (self->volume_value_label); + g_object_set_data_full (G_OBJECT (self->volume_value_label), "file_attribute", g_strdup ("volume"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->volume_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->volume_value_label); } - if (should_show_trashed_on (window)) + if (should_show_trashed_on (self)) { - gtk_widget_show (window->trashed_on_title_label); - gtk_widget_show (window->trashed_on_value_label); - g_object_set_data_full (G_OBJECT (window->trashed_on_value_label), "file_attribute", + gtk_widget_show (self->trashed_on_title_label); + gtk_widget_show (self->trashed_on_value_label); + g_object_set_data_full (G_OBJECT (self->trashed_on_value_label), "file_attribute", g_strdup ("trashed_on_full"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->trashed_on_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->trashed_on_value_label); } - if (should_show_accessed_date (window) - || should_show_modified_date (window)) + if (should_show_accessed_date (self) + || should_show_modified_date (self)) { - gtk_widget_show (window->spacer_2); + gtk_widget_show (self->spacer_2); } - if (should_show_accessed_date (window)) + if (should_show_accessed_date (self)) { - gtk_widget_show (window->accessed_title_label); - gtk_widget_show (window->accessed_value_label); + gtk_widget_show (self->accessed_title_label); + gtk_widget_show (self->accessed_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ - g_object_set_data_full (G_OBJECT (window->accessed_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->accessed_value_label), "file_attribute", g_strdup ("date_accessed_full"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->accessed_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->accessed_value_label); } - if (should_show_modified_date (window)) + if (should_show_modified_date (self)) { - gtk_widget_show (window->modified_title_label); - gtk_widget_show (window->modified_value_label); + gtk_widget_show (self->modified_title_label); + gtk_widget_show (self->modified_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ - g_object_set_data_full (G_OBJECT (window->modified_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->modified_value_label), "file_attribute", g_strdup ("date_modified_full"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->modified_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->modified_value_label); } - if (should_show_free_space (window) - && !should_show_volume_usage (window)) + if (should_show_free_space (self) + && !should_show_volume_usage (self)) { - gtk_widget_show (window->spacer_3); - gtk_widget_show (window->free_space_title_label); - gtk_widget_show (window->free_space_value_label); + gtk_widget_show (self->spacer_3); + gtk_widget_show (self->free_space_title_label); + gtk_widget_show (self->free_space_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ - g_object_set_data_full (G_OBJECT (window->free_space_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->free_space_value_label), "file_attribute", g_strdup ("free_space"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->free_space_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->free_space_value_label); } - if (should_show_volume_usage (window)) + if (should_show_volume_usage (self)) { - gtk_widget_show (window->volume_widget_box); - gtk_widget_show (window->open_in_disks_button); - setup_volume_usage_widget (window); + gtk_widget_show (self->volume_widget_box); + gtk_widget_show (self->open_in_disks_button); + setup_volume_usage_widget (self); /*Translators: Here Disks mean the name of application GNOME Disks.*/ - g_signal_connect (window->open_in_disks_button, "clicked", G_CALLBACK (open_in_disks), NULL); + g_signal_connect (self->open_in_disks_button, "clicked", G_CALLBACK (open_in_disks), NULL); } } static gboolean -files_has_directory (NautilusPropertiesWindow *window) +files_has_directory (NautilusPropertiesWindow *self) { GList *l; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; file = NAUTILUS_FILE (l->data); @@ -2915,12 +2856,12 @@ files_has_directory (NautilusPropertiesWindow *window) } static gboolean -files_has_changable_permissions_directory (NautilusPropertiesWindow *window) +files_has_changable_permissions_directory (NautilusPropertiesWindow *self) { GList *l; gboolean changable = FALSE; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; file = NAUTILUS_FILE (l->data); @@ -2941,11 +2882,11 @@ files_has_changable_permissions_directory (NautilusPropertiesWindow *window) } static gboolean -files_has_file (NautilusPropertiesWindow *window) +files_has_file (NautilusPropertiesWindow *self) { GList *l; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; file = NAUTILUS_FILE (l->data); @@ -2959,32 +2900,32 @@ files_has_file (NautilusPropertiesWindow *window) } static void -start_long_operation (NautilusPropertiesWindow *window) +start_long_operation (NautilusPropertiesWindow *self) { - if (window->long_operation_underway == 0) + if (self->long_operation_underway == 0) { /* start long operation */ GdkDisplay *display; GdkCursor *cursor; - display = gtk_widget_get_display (GTK_WIDGET (window)); + display = gtk_widget_get_display (GTK_WIDGET (self)); cursor = gdk_cursor_new_for_display (display, GDK_WATCH); - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), cursor); + gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), cursor); g_object_unref (cursor); } - window->long_operation_underway++; + self->long_operation_underway++; } static void -end_long_operation (NautilusPropertiesWindow *window) +end_long_operation (NautilusPropertiesWindow *self) { - if (gtk_widget_get_window (GTK_WIDGET (window)) != NULL && - window->long_operation_underway == 1) + if (gtk_widget_get_window (GTK_WIDGET (self)) != NULL && + self->long_operation_underway == 1) { /* finished !! */ - gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), NULL); + gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (self)), NULL); } - window->long_operation_underway--; + self->long_operation_underway--; } static void @@ -2993,20 +2934,17 @@ permission_change_callback (NautilusFile *file, GError *error, gpointer callback_data) { - NautilusPropertiesWindow *window; - g_assert (callback_data != NULL); + g_autoptr (NautilusPropertiesWindow) self = NAUTILUS_PROPERTIES_WINDOW (callback_data); + g_assert (self != NULL); - window = NAUTILUS_PROPERTIES_WINDOW (callback_data); - end_long_operation (window); + end_long_operation (self); /* Report the error if it's an error. */ - nautilus_report_error_setting_permissions (file, error, GTK_WINDOW (window)); - - g_object_unref (window); + nautilus_report_error_setting_permissions (file, error, GTK_WINDOW (self)); } static void -update_permissions (NautilusPropertiesWindow *window, +update_permissions (NautilusPropertiesWindow *self, guint32 vfs_new_perm, guint32 vfs_mask, gboolean is_folder, @@ -3015,7 +2953,7 @@ update_permissions (NautilusPropertiesWindow *window, { GList *l; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; guint32 permissions; @@ -3038,7 +2976,7 @@ update_permissions (NautilusPropertiesWindow *window, if (use_original) { gpointer ptr; - if (g_hash_table_lookup_extended (window->initial_permissions, + if (g_hash_table_lookup_extended (self->initial_permissions, file, NULL, &ptr)) { permissions = (permissions & ~vfs_mask) | (GPOINTER_TO_INT (ptr) & vfs_mask); @@ -3049,17 +2987,17 @@ update_permissions (NautilusPropertiesWindow *window, permissions = (permissions & ~vfs_mask) | vfs_new_perm; } - start_long_operation (window); - g_object_ref (window); + start_long_operation (self); + g_object_ref (self); nautilus_file_set_permissions (file, permissions, permission_change_callback, - window); + self); } } static gboolean -initial_permission_state_consistent (NautilusPropertiesWindow *window, +initial_permission_state_consistent (NautilusPropertiesWindow *self, guint32 mask, gboolean is_folder, gboolean both_folder_and_dir) @@ -3070,7 +3008,7 @@ initial_permission_state_consistent (NautilusPropertiesWindow *window, first = TRUE; first_permissions = 0; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; guint32 permissions; @@ -3084,7 +3022,7 @@ initial_permission_state_consistent (NautilusPropertiesWindow *window, continue; } - permissions = GPOINTER_TO_INT (g_hash_table_lookup (window->initial_permissions, + permissions = GPOINTER_TO_INT (g_hash_table_lookup (self->initial_permissions, file)); if (first) @@ -3110,7 +3048,7 @@ initial_permission_state_consistent (NautilusPropertiesWindow *window, static void permission_button_toggled (GtkToggleButton *button, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { gboolean is_folder, is_special; guint32 permission_mask; @@ -3132,7 +3070,7 @@ permission_button_toggled (GtkToggleButton *button, inconsistent = TRUE; on = TRUE; - if (initial_permission_state_consistent (window, permission_mask, is_folder, is_special)) + if (initial_permission_state_consistent (self, permission_mask, is_folder, is_special)) { inconsistent = FALSE; on = TRUE; @@ -3152,16 +3090,16 @@ permission_button_toggled (GtkToggleButton *button, g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (permission_button_toggled), - window); + self); gtk_toggle_button_set_active (button, on); gtk_toggle_button_set_inconsistent (button, inconsistent); g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (permission_button_toggled), - window); + self); - update_permissions (window, + update_permissions (self, on ? permission_mask : 0, permission_mask, is_folder, @@ -3170,7 +3108,7 @@ permission_button_toggled (GtkToggleButton *button, } static void -permission_button_update (NautilusPropertiesWindow *window, +permission_button_update (NautilusPropertiesWindow *self, GtkToggleButton *button) { GList *l; @@ -3193,7 +3131,7 @@ permission_button_update (NautilusPropertiesWindow *window, all_unset = TRUE; all_cannot_set = TRUE; no_match = TRUE; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; guint32 file_permissions; @@ -3240,7 +3178,7 @@ permission_button_update (NautilusPropertiesWindow *window, g_signal_handlers_block_by_func (G_OBJECT (button), G_CALLBACK (permission_button_toggled), - window); + self); gtk_toggle_button_set_active (button, !all_unset); /* if actually inconsistent, or default value for file buttons @@ -3252,45 +3190,45 @@ permission_button_update (NautilusPropertiesWindow *window, g_signal_handlers_unblock_by_func (G_OBJECT (button), G_CALLBACK (permission_button_toggled), - window); + self); } static void -setup_execute_checkbox_with_label (NautilusPropertiesWindow *window, +setup_execute_checkbox_with_label (NautilusPropertiesWindow *self, guint32 permission_to_check) { gboolean a11y_enabled; GtkLabel *label_for; - label_for = GTK_LABEL (window->execute_label); - gtk_widget_show (window->execute_label); - gtk_widget_show (window->execute_checkbox); + label_for = GTK_LABEL (self->execute_label); + gtk_widget_show (self->execute_label); + gtk_widget_show (self->execute_checkbox); /* Load up the check_button with data we'll need when updating its state. */ - g_object_set_data (G_OBJECT (window->execute_checkbox), "permission", + g_object_set_data (G_OBJECT (self->execute_checkbox), "permission", GINT_TO_POINTER (permission_to_check)); - g_object_set_data (G_OBJECT (window->execute_checkbox), "properties_window", - window); - g_object_set_data (G_OBJECT (window->execute_checkbox), "is-folder", + g_object_set_data (G_OBJECT (self->execute_checkbox), "properties_window", + self); + g_object_set_data (G_OBJECT (self->execute_checkbox), "is-folder", GINT_TO_POINTER (FALSE)); - window->permission_buttons = - g_list_prepend (window->permission_buttons, - window->execute_checkbox); + self->permission_buttons = + g_list_prepend (self->permission_buttons, + self->execute_checkbox); - g_signal_connect_object (window->execute_checkbox, "toggled", + g_signal_connect_object (self->execute_checkbox, "toggled", G_CALLBACK (permission_button_toggled), - window, + self, 0); - a11y_enabled = GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (window->execute_checkbox)); + a11y_enabled = GTK_IS_ACCESSIBLE (gtk_widget_get_accessible (self->execute_checkbox)); if (a11y_enabled && label_for != NULL) { AtkObject *atk_widget; AtkObject *atk_label; atk_label = gtk_widget_get_accessible (GTK_WIDGET (label_for)); - atk_widget = gtk_widget_get_accessible (window->execute_checkbox); + atk_widget = gtk_widget_get_accessible (self->execute_checkbox); /* Create the label -> widget relation */ atk_object_add_relationship (atk_label, ATK_RELATION_LABEL_FOR, atk_widget); @@ -3391,7 +3329,7 @@ permission_from_vfs (PermissionType type, static void permission_combo_changed (GtkWidget *combo, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { GtkTreeIter iter; GtkTreeModel *model; @@ -3424,7 +3362,7 @@ permission_combo_changed (GtkWidget *combo, COLUMN_USE_ORIGINAL, &use_original, -1); vfs_new_perm = permission_to_vfs (type, new_perm); - update_permissions (window, vfs_new_perm, vfs_mask, + update_permissions (self, vfs_new_perm, vfs_mask, is_folder, FALSE, use_original); } @@ -3465,7 +3403,7 @@ permission_combo_add_multiple_choice (GtkComboBox *combo, } static void -permission_combo_update (NautilusPropertiesWindow *window, +permission_combo_update (NautilusPropertiesWindow *self, GtkComboBox *combo) { PermissionType type; @@ -3499,7 +3437,7 @@ permission_combo_update (NautilusPropertiesWindow *window, all_dir_cannot_set = TRUE; all_file_cannot_set = TRUE; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; guint32 file_permissions; @@ -3653,7 +3591,7 @@ permission_combo_update (NautilusPropertiesWindow *window, g_signal_handlers_block_by_func (G_OBJECT (combo), G_CALLBACK (permission_combo_changed), - window); + self); gtk_combo_box_set_active_iter (combo, &iter); @@ -3671,7 +3609,7 @@ permission_combo_update (NautilusPropertiesWindow *window, g_signal_handlers_unblock_by_func (G_OBJECT (combo), G_CALLBACK (permission_combo_changed), - window); + self); } static void @@ -3679,7 +3617,7 @@ setup_permissions_combo_box (GtkComboBox *combo, PermissionType type, gboolean is_folder) { - GtkListStore *store; + g_autoptr (GtkListStore) store = NULL; GtkCellRenderer *cell; GtkTreeIter iter; @@ -3747,7 +3685,6 @@ setup_permissions_combo_box (GtkComboBox *combo, COLUMN_ID, "rw", -1); } - g_object_unref (store); cell = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); @@ -3819,7 +3756,7 @@ get_initial_permissions (GList *file_list) } static void -create_simple_permissions (NautilusPropertiesWindow *window, +create_simple_permissions (NautilusPropertiesWindow *self, GtkGrid *page_grid) { gboolean has_directory; @@ -3829,140 +3766,140 @@ create_simple_permissions (NautilusPropertiesWindow *window, GtkWidget *group_combo_box; GtkWidget *group_value_label; - has_directory = files_has_directory (window); - has_file = files_has_file (window); + has_directory = files_has_directory (self); + has_file = files_has_file (self); - if (!is_multi_file_window (window) && nautilus_file_can_set_owner (get_target_file (window))) + if (!is_multi_file_window (self) && nautilus_file_can_set_owner (get_target_file (self))) { /* Combo box in this case. */ - owner_combo_box = gtk_stack_get_child_by_name (GTK_STACK (window->owner_value_stack), "combo_box"); - gtk_stack_set_visible_child (GTK_STACK (window->owner_value_stack), owner_combo_box); - setup_owner_combo_box (owner_combo_box, get_target_file (window)); + owner_combo_box = gtk_stack_get_child_by_name (GTK_STACK (self->owner_value_stack), "combo_box"); + gtk_stack_set_visible_child (GTK_STACK (self->owner_value_stack), owner_combo_box); + setup_owner_combo_box (owner_combo_box, get_target_file (self)); } else { /* Static text in this case. */ - owner_value_label = gtk_stack_get_child_by_name (GTK_STACK (window->owner_value_stack), "label"); - gtk_stack_set_visible_child (GTK_STACK (window->owner_value_stack), owner_value_label); + owner_value_label = gtk_stack_get_child_by_name (GTK_STACK (self->owner_value_stack), "label"); + gtk_stack_set_visible_child (GTK_STACK (self->owner_value_stack), owner_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ g_object_set_data_full (G_OBJECT (owner_value_label), "file_attribute", g_strdup ("owner"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - owner_value_label); + self->value_fields = g_list_prepend (self->value_fields, + owner_value_label); } if (has_directory && has_file) { - gtk_widget_show (window->owner_folder_access_label); - gtk_widget_show (window->owner_folder_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->owner_folder_access_combo), + gtk_widget_show (self->owner_folder_access_label); + gtk_widget_show (self->owner_folder_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->owner_folder_access_combo), PERMISSION_USER, TRUE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->owner_folder_access_combo); - g_signal_connect (window->owner_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->owner_folder_access_combo); + g_signal_connect (self->owner_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); - gtk_widget_show (window->owner_file_access_label); - gtk_widget_show (window->owner_file_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->owner_file_access_combo), + gtk_widget_show (self->owner_file_access_label); + gtk_widget_show (self->owner_file_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->owner_file_access_combo), PERMISSION_USER, FALSE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->owner_file_access_combo); - g_signal_connect (window->owner_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->owner_file_access_combo); + g_signal_connect (self->owner_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } else { - gtk_widget_show (window->owner_access_label); - gtk_widget_show (window->owner_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->owner_access_combo), + gtk_widget_show (self->owner_access_label); + gtk_widget_show (self->owner_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->owner_access_combo), PERMISSION_USER, has_directory); - window->permission_combos = g_list_prepend (window->permission_combos, - window->owner_access_combo); - g_signal_connect (window->owner_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->owner_access_combo); + g_signal_connect (self->owner_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } - if (!is_multi_file_window (window) && nautilus_file_can_set_group (get_target_file (window))) + if (!is_multi_file_window (self) && nautilus_file_can_set_group (get_target_file (self))) { /* Combo box in this case. */ - group_combo_box = gtk_stack_get_child_by_name (GTK_STACK (window->group_value_stack), "combo_box"); - gtk_stack_set_visible_child (GTK_STACK (window->group_value_stack), group_combo_box); - setup_group_combo_box (group_combo_box, get_target_file (window)); + group_combo_box = gtk_stack_get_child_by_name (GTK_STACK (self->group_value_stack), "combo_box"); + gtk_stack_set_visible_child (GTK_STACK (self->group_value_stack), group_combo_box); + setup_group_combo_box (group_combo_box, get_target_file (self)); } else { - group_value_label = gtk_stack_get_child_by_name (GTK_STACK (window->group_value_stack), "label"); - gtk_stack_set_visible_child (GTK_STACK (window->group_value_stack), group_value_label); + group_value_label = gtk_stack_get_child_by_name (GTK_STACK (self->group_value_stack), "label"); + gtk_stack_set_visible_child (GTK_STACK (self->group_value_stack), group_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ g_object_set_data_full (G_OBJECT (group_value_label), "file_attribute", g_strdup ("group"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - group_value_label); + self->value_fields = g_list_prepend (self->value_fields, + group_value_label); } if (has_directory && has_file) { - gtk_widget_show (window->group_folder_access_label); - gtk_widget_show (window->group_folder_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->group_folder_access_combo), + gtk_widget_show (self->group_folder_access_label); + gtk_widget_show (self->group_folder_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->group_folder_access_combo), PERMISSION_GROUP, TRUE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->group_folder_access_combo); - g_signal_connect (window->group_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->group_folder_access_combo); + g_signal_connect (self->group_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); - gtk_widget_show (window->group_file_access_label); - gtk_widget_show (window->group_file_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->group_file_access_combo), + gtk_widget_show (self->group_file_access_label); + gtk_widget_show (self->group_file_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->group_file_access_combo), PERMISSION_GROUP, FALSE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->group_file_access_combo); - g_signal_connect (window->group_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->group_file_access_combo); + g_signal_connect (self->group_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } else { - gtk_widget_show (window->group_access_label); - gtk_widget_show (window->group_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->group_access_combo), + gtk_widget_show (self->group_access_label); + gtk_widget_show (self->group_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->group_access_combo), PERMISSION_GROUP, has_directory); - window->permission_combos = g_list_prepend (window->permission_combos, - window->group_access_combo); - g_signal_connect (window->group_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->group_access_combo); + g_signal_connect (self->group_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } /* Others Row */ if (has_directory && has_file) { - gtk_widget_show (window->others_folder_access_label); - gtk_widget_show (window->others_folder_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->others_folder_access_combo), + gtk_widget_show (self->others_folder_access_label); + gtk_widget_show (self->others_folder_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->others_folder_access_combo), PERMISSION_OTHER, TRUE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->others_folder_access_combo); - g_signal_connect (window->others_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->others_folder_access_combo); + g_signal_connect (self->others_folder_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); - gtk_widget_show (window->others_file_access_label); - gtk_widget_show (window->others_file_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->others_file_access_combo), + gtk_widget_show (self->others_file_access_label); + gtk_widget_show (self->others_file_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->others_file_access_combo), PERMISSION_OTHER, FALSE); - window->permission_combos = g_list_prepend (window->permission_combos, - window->others_file_access_combo); - g_signal_connect (window->others_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->others_file_access_combo); + g_signal_connect (self->others_file_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } else { - gtk_widget_show (window->others_access_label); - gtk_widget_show (window->others_access_combo); - setup_permissions_combo_box (GTK_COMBO_BOX (window->others_access_combo), + gtk_widget_show (self->others_access_label); + gtk_widget_show (self->others_access_combo); + setup_permissions_combo_box (GTK_COMBO_BOX (self->others_access_combo), PERMISSION_OTHER, has_directory); - window->permission_combos = g_list_prepend (window->permission_combos, - window->others_access_combo); - g_signal_connect (window->others_access_combo, "changed", G_CALLBACK (permission_combo_changed), window); + self->permission_combos = g_list_prepend (self->permission_combos, + self->others_access_combo); + g_signal_connect (self->others_access_combo, "changed", G_CALLBACK (permission_combo_changed), self); } if (!has_directory) { - setup_execute_checkbox_with_label (window, + setup_execute_checkbox_with_label (self, UNIX_PERM_USER_EXEC | UNIX_PERM_GROUP_EXEC | UNIX_PERM_OTHER_EXEC); } } @@ -3971,18 +3908,14 @@ static void set_recursive_permissions_done (gboolean success, gpointer callback_data) { - NautilusPropertiesWindow *window; - - window = NAUTILUS_PROPERTIES_WINDOW (callback_data); - end_long_operation (window); - - g_object_unref (window); + g_autoptr (NautilusPropertiesWindow) self = NAUTILUS_PROPERTIES_WINDOW (callback_data); + end_long_operation (self); } static void on_change_permissions_response (GtkDialog *dialog, int response, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { guint32 file_permission, file_permission_mask; guint32 dir_permission, dir_permission_mask; @@ -3997,7 +3930,7 @@ on_change_permissions_response (GtkDialog *dialog, if (response != GTK_RESPONSE_OK) { - g_clear_pointer (&window->change_permission_combos, g_list_free); + g_clear_pointer (&self->change_permission_combos, g_list_free); gtk_widget_destroy (GTK_WIDGET (dialog)); return; } @@ -4008,7 +3941,7 @@ on_change_permissions_response (GtkDialog *dialog, dir_permission_mask = 0; /* Simple mode, minus exec checkbox */ - for (l = window->change_permission_combos; l != NULL; l = l->next) + for (l = self->change_permission_combos; l != NULL; l = l->next) { combo = l->data; @@ -4052,7 +3985,7 @@ on_change_permissions_response (GtkDialog *dialog, } } - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { NautilusFile *file; char *uri; @@ -4063,19 +3996,19 @@ on_change_permissions_response (GtkDialog *dialog, nautilus_file_can_set_permissions (file)) { uri = nautilus_file_get_uri (file); - start_long_operation (window); - g_object_ref (window); + start_long_operation (self); + g_object_ref (self); nautilus_file_set_permissions_recursive (uri, file_permission, file_permission_mask, dir_permission, dir_permission_mask, set_recursive_permissions_done, - window); + self); g_free (uri); } } - g_clear_pointer (&window->change_permission_combos, g_list_free); + g_clear_pointer (&self->change_permission_combos, g_list_free); gtk_widget_destroy (GTK_WIDGET (dialog)); } @@ -4180,103 +4113,102 @@ set_active_from_umask (GtkComboBox *combo, static void on_change_permissions_clicked (GtkWidget *button, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { GtkWidget *dialog; GtkComboBox *combo; - GtkBuilder *change_permissions_builder; + g_autoptr (GtkBuilder) change_permissions_builder = NULL; change_permissions_builder = gtk_builder_new_from_resource ("/org/gnome/nautilus/ui/nautilus-file-properties-change-permissions.ui"); dialog = GTK_WIDGET (gtk_builder_get_object (change_permissions_builder, "change_permissions_dialog")); - gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (window)); + gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (self)); /* Owner Permissions */ combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "file_owner_combo")); setup_permissions_combo_box (combo, PERMISSION_USER, FALSE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_USER, FALSE); combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "folder_owner_combo")); setup_permissions_combo_box (combo, PERMISSION_USER, TRUE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_USER, TRUE); /* Group Permissions */ combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "file_group_combo")); setup_permissions_combo_box (combo, PERMISSION_GROUP, FALSE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_GROUP, FALSE); combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "folder_group_combo")); setup_permissions_combo_box (combo, PERMISSION_GROUP, TRUE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_GROUP, TRUE); /* Others Permissions */ combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "file_other_combo")); setup_permissions_combo_box (combo, PERMISSION_OTHER, FALSE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_OTHER, FALSE); combo = GTK_COMBO_BOX (gtk_builder_get_object (change_permissions_builder, "folder_other_combo")); setup_permissions_combo_box (combo, PERMISSION_OTHER, TRUE); - window->change_permission_combos = g_list_prepend (window->change_permission_combos, - combo); + self->change_permission_combos = g_list_prepend (self->change_permission_combos, + combo); set_active_from_umask (combo, PERMISSION_OTHER, TRUE); - g_signal_connect (dialog, "response", G_CALLBACK (on_change_permissions_response), window); + g_signal_connect (dialog, "response", G_CALLBACK (on_change_permissions_response), self); gtk_widget_show_all (dialog); - g_object_unref (change_permissions_builder); } static void -setup_permissions_page (NautilusPropertiesWindow *window) +setup_permissions_page (NautilusPropertiesWindow *self) { char *file_name, *prompt_text; GList *file_list; - file_list = window->original_files; + file_list = self->original_files; - window->initial_permissions = NULL; + self->initial_permissions = NULL; - if (all_can_get_permissions (file_list) && all_can_get_permissions (window->target_files)) + if (all_can_get_permissions (file_list) && all_can_get_permissions (self->target_files)) { - window->initial_permissions = get_initial_permissions (window->target_files); - window->has_recursive_apply = files_has_changable_permissions_directory (window); + self->initial_permissions = get_initial_permissions (self->target_files); + self->has_recursive_apply = files_has_changable_permissions_directory (self); if (!all_can_set_permissions (file_list)) { - gtk_widget_show (window->not_the_owner_label); - gtk_widget_show (window->bottom_prompt_seperator); + gtk_widget_show (self->not_the_owner_label); + gtk_widget_show (self->bottom_prompt_seperator); } - gtk_widget_show (window->permissions_grid); - create_simple_permissions (window, GTK_GRID (window->permissions_grid)); + gtk_widget_show (self->permissions_grid); + create_simple_permissions (self, GTK_GRID (self->permissions_grid)); #ifdef HAVE_SELINUX - gtk_widget_show (window->security_context_title_label); - gtk_widget_show (window->security_context_value_label); + gtk_widget_show (self->security_context_title_label); + gtk_widget_show (self->security_context_value_label); /* Stash a copy of the file attribute name in this field for the callback's sake. */ - g_object_set_data_full (G_OBJECT (window->security_context_value_label), "file_attribute", + g_object_set_data_full (G_OBJECT (self->security_context_value_label), "file_attribute", g_strdup ("selinux_context"), g_free); - window->value_fields = g_list_prepend (window->value_fields, - window->security_context_value_label); + self->value_fields = g_list_prepend (self->value_fields, + self->security_context_value_label); #endif - if (window->has_recursive_apply) + if (self->has_recursive_apply) { - gtk_widget_show_all (window->change_permissions_button_box); - g_signal_connect (window->change_permissions_button, "clicked", + gtk_widget_show_all (self->change_permissions_button_box); + g_signal_connect (self->change_permissions_button, "clicked", G_CALLBACK (on_change_permissions_clicked), - window); + self); } } else @@ -4287,21 +4219,21 @@ setup_permissions_page (NautilusPropertiesWindow *window) * default label text. The default label text for a multifile * window is set in nautilus-properties-window.ui so no else block. */ - if (!is_multi_file_window (window)) + if (!is_multi_file_window (self)) { - file_name = nautilus_file_get_display_name (get_target_file (window)); + file_name = nautilus_file_get_display_name (get_target_file (self)); prompt_text = g_strdup_printf (_("The permissions of “%s” could not be determined."), file_name); - gtk_label_set_text (GTK_LABEL (window->permission_indeterminable_label), prompt_text); + gtk_label_set_text (GTK_LABEL (self->permission_indeterminable_label), prompt_text); g_free (file_name); g_free (prompt_text); } - gtk_widget_show (window->permission_indeterminable_label); + gtk_widget_show (self->permission_indeterminable_label); } } static void -append_extension_pages (NautilusPropertiesWindow *window) +append_extension_pages (NautilusPropertiesWindow *self) { GList *providers; GList *p; @@ -4317,7 +4249,7 @@ append_extension_pages (NautilusPropertiesWindow *window) provider = NAUTILUS_PROPERTY_PAGE_PROVIDER (p->data); pages = nautilus_property_page_provider_get_pages - (provider, window->original_files); + (provider, self->original_files); for (l = pages; l != NULL; l = l->next) { @@ -4331,9 +4263,9 @@ append_extension_pages (NautilusPropertiesWindow *window) "page", &page_widget, "label", &label, NULL); - gtk_notebook_append_page (window->notebook, + gtk_notebook_append_page (self->notebook, page_widget, label); - gtk_container_child_set (GTK_CONTAINER (window->notebook), + gtk_container_child_set (GTK_CONTAINER (self->notebook), page_widget, "tab-expand", TRUE, NULL); @@ -4355,14 +4287,14 @@ append_extension_pages (NautilusPropertiesWindow *window) } static gboolean -should_show_permissions (NautilusPropertiesWindow *window) +should_show_permissions (NautilusPropertiesWindow *self) { GList *l; /* Don't show permissions for Trash and Computer since they're not * really file system objects. */ - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { if (nautilus_file_is_in_trash (NAUTILUS_FILE (l->data)) || nautilus_file_is_in_recent (NAUTILUS_FILE (l->data))) @@ -4454,18 +4386,18 @@ static void file_changed_callback (NautilusFile *file, gpointer user_data) { - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); - if (!g_list_find (window->changed_files, file)) + if (!g_list_find (self->changed_files, file)) { nautilus_file_ref (file); - window->changed_files = g_list_prepend (window->changed_files, file); - schedule_files_update (window); + self->changed_files = g_list_prepend (self->changed_files, file); + schedule_files_update (self); } } static gboolean -should_show_open_with (NautilusPropertiesWindow *window) +should_show_open_with (NautilusPropertiesWindow *self) { NautilusFile *file; char *mime_type; @@ -4480,17 +4412,17 @@ should_show_open_with (NautilusPropertiesWindow *window) * leads to all sort of hard to understand errors. */ - if (is_multi_file_window (window)) + if (is_multi_file_window (self)) { GList *l; - if (!file_list_attributes_identical (window->target_files, + if (!file_list_attributes_identical (self->target_files, "mime_type")) { return FALSE; } - for (l = window->target_files; l; l = l->next) + for (l = self->target_files; l; l = l->next) { file = NAUTILUS_FILE (l->data); app_info = nautilus_mime_get_default_application_for_file (file); @@ -4502,11 +4434,11 @@ should_show_open_with (NautilusPropertiesWindow *window) /* since we just confirmed all the mime types are the * same we only need to test one file */ - file = window->target_files->data; + file = self->target_files->data; } else { - file = get_target_file (window); + file = get_target_file (self); app_info = nautilus_mime_get_default_application_for_file (file); if (nautilus_file_is_directory (file) || !app_info || file == NULL) @@ -4528,19 +4460,19 @@ static void add_clicked_cb (GtkButton *button, gpointer user_data) { - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); - GAppInfo *info; + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); + g_autoptr (GAppInfo) info = NULL; gchar *message; GError *error = NULL; - info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (window->app_chooser_widget)); + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget)); if (info == NULL) { return; } - g_app_info_set_as_last_used_for_type (info, window->content_type, &error); + g_app_info_set_as_last_used_for_type (info, self->content_type, &error); if (error != NULL) { @@ -4548,45 +4480,43 @@ add_clicked_cb (GtkButton *button, g_app_info_get_display_name (info), error->message); show_dialog (_("Could not add application"), message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (window))), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); g_error_free (error); g_free (message); } else { - gtk_app_chooser_refresh (GTK_APP_CHOOSER (window->app_chooser_widget)); + gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget)); g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed"); } - - g_object_unref (info); } static void remove_clicked_cb (GtkMenuItem *item, gpointer user_data) { - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); GError *error; GAppInfo *info; - info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (window->app_chooser_widget)); + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget)); if (info) { error = NULL; if (!g_app_info_remove_supports_type (info, - window->content_type, + self->content_type, &error)) { show_dialog (_("Could not forget association"), error->message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (window))), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); g_error_free (error); } - gtk_app_chooser_refresh (GTK_APP_CHOOSER (window->app_chooser_widget)); + gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget)); g_object_unref (info); } @@ -4600,7 +4530,7 @@ populate_popup_cb (GtkAppChooserWidget *widget, gpointer user_data) { GtkWidget *item; - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); if (g_app_info_can_remove_supports_type (app)) { @@ -4609,7 +4539,7 @@ populate_popup_cb (GtkAppChooserWidget *widget, gtk_widget_show (item); g_signal_connect (item, "activate", - G_CALLBACK (remove_clicked_cb), window); + G_CALLBACK (remove_clicked_cb), self); } } @@ -4617,12 +4547,12 @@ static void reset_clicked_cb (GtkButton *button, gpointer user_data) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; - window = NAUTILUS_PROPERTIES_WINDOW (user_data); + self = NAUTILUS_PROPERTIES_WINDOW (user_data); - g_app_info_reset_type_associations (window->content_type); - gtk_app_chooser_refresh (GTK_APP_CHOOSER (window->app_chooser_widget)); + g_app_info_reset_type_associations (self->content_type); + gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget)); g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed"); } @@ -4631,14 +4561,14 @@ static void set_as_default_clicked_cb (GtkButton *button, gpointer user_data) { - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); - GAppInfo *info; + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); + g_autoptr (GAppInfo) info = NULL; GError *error = NULL; gchar *message = NULL; - info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (window->app_chooser_widget)); + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget)); - g_app_info_set_as_default_for_type (info, window->content_type, + g_app_info_set_as_default_for_type (info, self->content_type, &error); if (error != NULL) @@ -4647,13 +4577,11 @@ set_as_default_clicked_cb (GtkButton *button, g_app_info_get_display_name (info), error->message); show_dialog (_("Could not set as default"), message, - GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (window))), + GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (self))), GTK_MESSAGE_ERROR); } - g_object_unref (info); - - gtk_app_chooser_refresh (GTK_APP_CHOOSER (window->app_chooser_widget)); + gtk_app_chooser_refresh (GTK_APP_CHOOSER (self->app_chooser_widget)); g_signal_emit_by_name (nautilus_signaller_get_current (), "mime-data-changed"); } @@ -4698,32 +4626,34 @@ application_selected_cb (GtkAppChooserWidget *widget, GAppInfo *info, gpointer user_data) { - NautilusPropertiesWindow *window = NAUTILUS_PROPERTIES_WINDOW (user_data); + NautilusPropertiesWindow *self = NAUTILUS_PROPERTIES_WINDOW (user_data); GAppInfo *default_app; - default_app = g_app_info_get_default_for_type (window->content_type, FALSE); + default_app = g_app_info_get_default_for_type (self->content_type, FALSE); if (default_app != NULL) { - gtk_widget_set_sensitive (window->set_as_default_button, + gtk_widget_set_sensitive (self->set_as_default_button, !g_app_info_equal (info, default_app)); g_object_unref (default_app); } - gtk_widget_set_sensitive (window->add_button, - app_info_can_add (info, window->content_type)); + gtk_widget_set_sensitive (self->add_button, + app_info_can_add (info, self->content_type)); } static void -application_chooser_apply_labels (NautilusPropertiesWindow *window) +application_chooser_apply_labels (NautilusPropertiesWindow *self) { - gchar *label, *extension = NULL, *description = NULL; + g_autofree gchar *label = NULL; + g_autofree gchar *extension = NULL; + g_autofree gchar *description = NULL; gint num_files; NautilusFile *file; - num_files = g_list_length (window->open_with_files); - file = window->open_with_files->data; + num_files = g_list_length (self->open_with_files); + file = self->open_with_files->data; /* here we assume all files are of the same content type */ - if (g_content_type_is_unknown (window->content_type)) + if (g_content_type_is_unknown (self->content_type)) { extension = nautilus_file_get_extension (file); @@ -4732,7 +4662,7 @@ application_chooser_apply_labels (NautilusPropertiesWindow *window) } else { - description = g_content_type_get_description (window->content_type); + description = g_content_type_get_description (self->content_type); } if (num_files > 1) @@ -4743,90 +4673,84 @@ application_chooser_apply_labels (NautilusPropertiesWindow *window) } else { - gchar *display_name; + g_autofree gchar *display_name = NULL; display_name = nautilus_file_get_display_name (file); /* Translators: first %s is filename, second %s is mime-type description */ label = g_strdup_printf (_("Select an application to open “%s” and other files of type “%s”"), display_name, description); - - g_free (display_name); } - gtk_label_set_markup (GTK_LABEL (window->open_with_label), label); - - g_free (label); - g_free (extension); - g_free (description); + gtk_label_set_markup (GTK_LABEL (self->open_with_label), label); } static void -setup_app_chooser_area (NautilusPropertiesWindow *window) +setup_app_chooser_area (NautilusPropertiesWindow *self) { GAppInfo *info; - window->app_chooser_widget = gtk_app_chooser_widget_new (window->content_type); - gtk_box_pack_start (GTK_BOX (window->app_chooser_widget_box), window->app_chooser_widget, TRUE, TRUE, 0); + self->app_chooser_widget = gtk_app_chooser_widget_new (self->content_type); + gtk_box_pack_start (GTK_BOX (self->app_chooser_widget_box), self->app_chooser_widget, TRUE, TRUE, 0); - gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (window->app_chooser_widget), TRUE); - gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (window->app_chooser_widget), TRUE); - gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (window->app_chooser_widget), TRUE); - gtk_widget_show (window->app_chooser_widget); - g_signal_connect (window->reset_button, "clicked", + gtk_app_chooser_widget_set_show_default (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget), TRUE); + gtk_app_chooser_widget_set_show_fallback (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget), TRUE); + gtk_app_chooser_widget_set_show_other (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget), TRUE); + gtk_widget_show (self->app_chooser_widget); + g_signal_connect (self->reset_button, "clicked", G_CALLBACK (reset_clicked_cb), - window); - g_signal_connect (window->add_button, "clicked", + self); + g_signal_connect (self->add_button, "clicked", G_CALLBACK (add_clicked_cb), - window); - g_signal_connect (window->set_as_default_button, "clicked", + self); + g_signal_connect (self->set_as_default_button, "clicked", G_CALLBACK (set_as_default_clicked_cb), - window); + self); /* initialize sensitivity */ - info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (window->app_chooser_widget)); + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (self->app_chooser_widget)); if (info != NULL) { - application_selected_cb (GTK_APP_CHOOSER_WIDGET (window->app_chooser_widget), - info, window); + application_selected_cb (GTK_APP_CHOOSER_WIDGET (self->app_chooser_widget), + info, self); g_object_unref (info); } - g_signal_connect (window->app_chooser_widget, + g_signal_connect (self->app_chooser_widget, "application-selected", G_CALLBACK (application_selected_cb), - window); - g_signal_connect (window->app_chooser_widget, + self); + g_signal_connect (self->app_chooser_widget, "populate-popup", G_CALLBACK (populate_popup_cb), - window); + self); - application_chooser_apply_labels (window); + application_chooser_apply_labels (self); } static void -setup_open_with_page (NautilusPropertiesWindow *window) +setup_open_with_page (NautilusPropertiesWindow *self) { GList *files = NULL; NautilusFile *target_file; - target_file = get_target_file (window); - window->content_type = nautilus_file_get_mime_type (target_file); + target_file = get_target_file (self); + self->content_type = nautilus_file_get_mime_type (target_file); - if (!is_multi_file_window (window)) + if (!is_multi_file_window (self)) { files = g_list_prepend (NULL, target_file); } else { - files = g_list_copy (window->original_files); + files = g_list_copy (self->original_files); if (files == NULL) { return; } } - window->open_with_files = files; - setup_app_chooser_area (window); + self->open_with_files = files; + setup_app_chooser_area (self); } @@ -4965,24 +4889,24 @@ get_target_file_list (GList *original_files) } static void -add_window (NautilusPropertiesWindow *window) +add_window (NautilusPropertiesWindow *self) { - if (!is_multi_file_window (window)) + if (!is_multi_file_window (self)) { g_hash_table_insert (windows, - get_original_file (window), - window); - g_object_set_data (G_OBJECT (window), "window_key", - get_original_file (window)); + get_original_file (self), + self); + g_object_set_data (G_OBJECT (self), "window_key", + get_original_file (self)); } } static void -remove_window (NautilusPropertiesWindow *window) +remove_window (NautilusPropertiesWindow *self) { gpointer key; - key = g_object_get_data (G_OBJECT (window), "window_key"); + key = g_object_get_data (G_OBJECT (self), "window_key"); if (key) { g_hash_table_remove (windows, key); @@ -5131,7 +5055,7 @@ nautilus_properties_window_present (GList *original_f StartupData *startup_data; GList *target_files; NautilusPropertiesWindow *existing_window; - char *pending_key; + g_autofree char *pending_key = NULL; g_return_if_fail (original_files != NULL); g_return_if_fail (parent_widget == NULL || GTK_IS_WIDGET (parent_widget)); @@ -5204,7 +5128,6 @@ nautilus_properties_window_present (GList *original_f NULL); nautilus_file_list_free (target_files); - g_free (pending_key); /* Wait until we can tell whether it's a directory before showing, since * some one-time layout decisions depend on that info. @@ -5237,71 +5160,71 @@ nautilus_properties_window_present (GList *original_f static void real_destroy (GtkWidget *object) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; GList *l; - window = NAUTILUS_PROPERTIES_WINDOW (object); + self = NAUTILUS_PROPERTIES_WINDOW (object); - remove_window (window); + remove_window (self); - unschedule_or_cancel_group_change (window); - unschedule_or_cancel_owner_change (window); + unschedule_or_cancel_group_change (self); + unschedule_or_cancel_owner_change (self); - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { - nautilus_file_monitor_remove (NAUTILUS_FILE (l->data), &window->original_files); + nautilus_file_monitor_remove (NAUTILUS_FILE (l->data), &self->original_files); } - nautilus_file_list_free (window->original_files); - window->original_files = NULL; + nautilus_file_list_free (self->original_files); + self->original_files = NULL; - for (l = window->target_files; l != NULL; l = l->next) + for (l = self->target_files; l != NULL; l = l->next) { - nautilus_file_monitor_remove (NAUTILUS_FILE (l->data), &window->target_files); + nautilus_file_monitor_remove (NAUTILUS_FILE (l->data), &self->target_files); } - nautilus_file_list_free (window->target_files); - window->target_files = NULL; + nautilus_file_list_free (self->target_files); + self->target_files = NULL; - nautilus_file_list_free (window->changed_files); - window->changed_files = NULL; + nautilus_file_list_free (self->changed_files); + self->changed_files = NULL; - if (window->deep_count_spinner_timeout_id > 0) + if (self->deep_count_spinner_timeout_id > 0) { - g_source_remove (window->deep_count_spinner_timeout_id); + g_source_remove (self->deep_count_spinner_timeout_id); } - while (window->deep_count_files) + while (self->deep_count_files) { - stop_deep_count_for_file (window, window->deep_count_files->data); + stop_deep_count_for_file (self, self->deep_count_files->data); } - g_list_free (window->permission_buttons); - window->permission_buttons = NULL; + g_list_free (self->permission_buttons); + self->permission_buttons = NULL; - g_list_free (window->permission_combos); - window->permission_combos = NULL; + g_list_free (self->permission_combos); + self->permission_combos = NULL; - g_list_free (window->change_permission_combos); - window->change_permission_combos = NULL; + g_list_free (self->change_permission_combos); + self->change_permission_combos = NULL; - if (window->initial_permissions) + if (self->initial_permissions) { - g_hash_table_destroy (window->initial_permissions); - window->initial_permissions = NULL; + g_hash_table_destroy (self->initial_permissions); + self->initial_permissions = NULL; } - g_list_free (window->value_fields); - window->value_fields = NULL; + g_list_free (self->value_fields); + self->value_fields = NULL; - if (window->update_directory_contents_timeout_id != 0) + if (self->update_directory_contents_timeout_id != 0) { - g_source_remove (window->update_directory_contents_timeout_id); - window->update_directory_contents_timeout_id = 0; + g_source_remove (self->update_directory_contents_timeout_id); + self->update_directory_contents_timeout_id = 0; } - if (window->update_files_timeout_id != 0) + if (self->update_files_timeout_id != 0) { - g_source_remove (window->update_files_timeout_id); - window->update_files_timeout_id = 0; + g_source_remove (self->update_files_timeout_id); + self->update_files_timeout_id = 0; } GTK_WIDGET_CLASS (nautilus_properties_window_parent_class)->destroy (object); @@ -5310,19 +5233,19 @@ real_destroy (GtkWidget *object) static void real_finalize (GObject *object) { - NautilusPropertiesWindow *window; + NautilusPropertiesWindow *self; - window = NAUTILUS_PROPERTIES_WINDOW (object); + self = NAUTILUS_PROPERTIES_WINDOW (object); - g_list_free_full (window->mime_list, g_free); + g_list_free_full (self->mime_list, g_free); - g_free (window->pending_name); - g_free (window->content_type); - g_list_free (window->open_with_files); + g_free (self->pending_name); + g_free (self->content_type); + g_list_free (self->open_with_files); - if (window->select_idle_id != 0) + if (self->select_idle_id != 0) { - g_source_remove (window->select_idle_id); + g_source_remove (self->select_idle_id); } G_OBJECT_CLASS (nautilus_properties_window_parent_class)->finalize (object); @@ -5331,14 +5254,14 @@ real_finalize (GObject *object) /* icon selection callback to set the image of the file object to the selected file */ static void set_icon (const char *icon_uri, - NautilusPropertiesWindow *properties_window) + NautilusPropertiesWindow *self) { NautilusFile *file; char *file_uri; char *icon_path; g_assert (icon_uri != NULL); - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (properties_window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); icon_path = g_filename_from_uri (icon_uri, NULL, NULL); /* we don't allow remote URIs */ @@ -5346,7 +5269,7 @@ set_icon (const char *icon_uri, { GList *l; - for (l = properties_window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { g_autoptr (GFile) file_location = NULL; g_autoptr (GFile) icon_location = NULL; @@ -5377,11 +5300,11 @@ set_icon (const char *icon_uri, static void update_preview_callback (GtkFileChooser *icon_chooser, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { GtkWidget *preview_widget; GdkPixbuf *pixbuf, *scaled_pixbuf; - char *filename; + g_autofree char *filename = NULL; double scale; pixbuf = NULL; @@ -5417,8 +5340,6 @@ update_preview_callback (GtkFileChooser *icon_chooser, gtk_file_chooser_set_preview_widget_active (icon_chooser, FALSE); } - g_free (filename); - if (pixbuf != NULL) { g_object_unref (pixbuf); @@ -5428,7 +5349,7 @@ update_preview_callback (GtkFileChooser *icon_chooser, static void custom_icon_file_chooser_response_cb (GtkDialog *dialog, gint response, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { char *uri; @@ -5436,7 +5357,7 @@ custom_icon_file_chooser_response_cb (GtkDialog *dialog, { case GTK_RESPONSE_NO: { - reset_icon (window); + reset_icon (self); } break; @@ -5445,11 +5366,11 @@ custom_icon_file_chooser_response_cb (GtkDialog *dialog, uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); if (uri != NULL) { - set_icon (uri, window); + set_icon (uri, self); } else { - reset_icon (window); + reset_icon (self); } g_free (uri); } @@ -5466,7 +5387,7 @@ custom_icon_file_chooser_response_cb (GtkDialog *dialog, static void select_image_button_callback (GtkWidget *widget, - NautilusPropertiesWindow *window) + NautilusPropertiesWindow *self) { GtkWidget *dialog, *preview; GtkFileFilter *filter; @@ -5476,13 +5397,13 @@ select_image_button_callback (GtkWidget *widget, char *image_path; gboolean revert_is_sensitive; - g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (window)); + g_assert (NAUTILUS_IS_PROPERTIES_WINDOW (self)); - dialog = window->icon_chooser; + dialog = self->icon_chooser; if (dialog == NULL) { - dialog = gtk_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (window), + dialog = gtk_file_chooser_dialog_new (_("Select Custom Icon"), GTK_WINDOW (self), GTK_FILE_CHOOSER_ACTION_OPEN, _("_Revert"), GTK_RESPONSE_NO, _("_Cancel"), GTK_RESPONSE_CANCEL, @@ -5505,18 +5426,18 @@ select_image_button_callback (GtkWidget *widget, gtk_file_chooser_set_preview_widget_active (GTK_FILE_CHOOSER (dialog), FALSE); g_signal_connect (dialog, "update-preview", - G_CALLBACK (update_preview_callback), window); + G_CALLBACK (update_preview_callback), self); - window->icon_chooser = dialog; + self->icon_chooser = dialog; g_object_add_weak_pointer (G_OBJECT (dialog), - (gpointer *) &window->icon_chooser); + (gpointer *) &self->icon_chooser); } /* it's likely that the user wants to pick an icon that is inside a local directory */ - if (g_list_length (window->original_files) == 1) + if (g_list_length (self->original_files) == 1) { - file = NAUTILUS_FILE (window->original_files->data); + file = NAUTILUS_FILE (self->original_files->data); if (nautilus_file_is_directory (file)) { @@ -5534,7 +5455,7 @@ select_image_button_callback (GtkWidget *widget, } revert_is_sensitive = FALSE; - for (l = window->original_files; l != NULL; l = l->next) + for (l = self->original_files; l != NULL; l = l->next) { file = NAUTILUS_FILE (l->data); image_path = nautilus_file_get_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, NULL); @@ -5549,7 +5470,7 @@ select_image_button_callback (GtkWidget *widget, gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_NO, revert_is_sensitive); g_signal_connect (dialog, "response", - G_CALLBACK (custom_icon_file_chooser_response_cb), window); + G_CALLBACK (custom_icon_file_chooser_response_cb), self); gtk_widget_show (dialog); } @@ -5660,8 +5581,8 @@ nautilus_properties_window_class_init (NautilusPropertiesWindowClass *klass) } static void -nautilus_properties_window_init (NautilusPropertiesWindow *window) +nautilus_properties_window_init (NautilusPropertiesWindow *self) { - gtk_widget_init_template (GTK_WIDGET (window)); - g_signal_connect (window, "close", G_CALLBACK (gtk_window_close), NULL); + gtk_widget_init_template (GTK_WIDGET (self)); + g_signal_connect (self, "close", G_CALLBACK (gtk_window_close), NULL); }