diff options
Diffstat (limited to 'libcaja-private')
37 files changed, 108 insertions, 309 deletions
diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index 5c7bfec8..eaaea4c6 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -43,8 +43,6 @@ #include "caja-desktop-icon-file.h" #include "caja-file-utilities.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - enum { AUTORUN_ASK, diff --git a/libcaja-private/caja-bookmark.c b/libcaja-private/caja-bookmark.c index 48952fbb..48e26ea3 100644 --- a/libcaja-private/caja-bookmark.c +++ b/libcaja-private/caja-bookmark.c @@ -45,7 +45,7 @@ enum #define ELLIPSISED_MENU_ITEM_MIN_CHARS 32 -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; struct CajaBookmarkDetails { diff --git a/libcaja-private/caja-clipboard-monitor.c b/libcaja-private/caja-clipboard-monitor.c index d1483ae4..eabb7844 100644 --- a/libcaja-private/caja-clipboard-monitor.c +++ b/libcaja-private/caja-clipboard-monitor.c @@ -58,7 +58,7 @@ struct CajaClipboardMonitorDetails CajaClipboardInfo *info; }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static GdkAtom copied_files_atom; G_DEFINE_TYPE (CajaClipboardMonitor, caja_clipboard_monitor, G_TYPE_OBJECT); diff --git a/libcaja-private/caja-clipboard.c b/libcaja-private/caja-clipboard.c index ab0b7987..87d390be 100644 --- a/libcaja-private/caja-clipboard.c +++ b/libcaja-private/caja-clipboard.c @@ -35,8 +35,6 @@ #include <gtk/gtk.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef struct _TargetCallbackData TargetCallbackData; typedef void (* SelectAllCallback) (gpointer target); diff --git a/libcaja-private/caja-column-chooser.c b/libcaja-private/caja-column-chooser.c index d1fd243a..41de4fa1 100644 --- a/libcaja-private/caja-column-chooser.c +++ b/libcaja-private/caja-column-chooser.c @@ -63,7 +63,7 @@ enum USE_DEFAULT, LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE(CajaColumnChooser, caja_column_chooser, GTK_TYPE_HBOX); diff --git a/libcaja-private/caja-customization-data.c b/libcaja-private/caja-customization-data.c index a1019301..c88871a9 100644 --- a/libcaja-private/caja-customization-data.c +++ b/libcaja-private/caja-customization-data.c @@ -23,7 +23,7 @@ */ /* caja-customization-data.c - functions to collect and load customization - names and imges */ + names and images */ #include <config.h> #include "caja-customization-data.h" @@ -43,8 +43,6 @@ #include <stdlib.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef enum { READ_PUBLIC_CUSTOMIZATIONS, diff --git a/libcaja-private/caja-debug-log.c b/libcaja-private/caja-debug-log.c index 446df48e..19462d34 100644 --- a/libcaja-private/caja-debug-log.c +++ b/libcaja-private/caja-debug-log.c @@ -30,8 +30,6 @@ #include "caja-debug-log.h" #include "caja-file.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - #define DEFAULT_RING_BUFFER_NUM_LINES 1000 #define KEY_FILE_GROUP "debug log" @@ -40,11 +38,7 @@ #define MAX_URI_COUNT 20 -#if GLIB_CHECK_VERSION(2, 31, 0) static GMutex log_mutex; -#else -static GStaticMutex log_mutex = G_STATIC_MUTEX_INIT; -#endif static GHashTable *domains_hash; static char **ring_buffer; @@ -58,21 +52,13 @@ static GSList *milestones_tail; static void lock (void) { - #if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_lock (&log_mutex); - #else - g_static_mutex_lock (&log_mutex); - #endif } static void unlock (void) { - #if GLIB_CHECK_VERSION(2, 31, 0) g_mutex_unlock (&log_mutex); - #else - g_static_mutex_unlock (&log_mutex); - #endif } void diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c index d5d97cf0..a795c161 100644 --- a/libcaja-private/caja-directory-async.c +++ b/libcaja-private/caja-directory-async.c @@ -39,8 +39,6 @@ #include <stdio.h> #include <stdlib.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - /* turn this on to see messages about each load_directory call: */ #if 0 #define DEBUG_LOAD_DIRECTORY diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c index fa9d7bd8..ba8d7d97 100644 --- a/libcaja-private/caja-directory.c +++ b/libcaja-private/caja-directory.c @@ -40,8 +40,6 @@ #include <gtk/gtk.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - enum { FILES_ADDED, @@ -51,7 +49,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static GHashTable *directories; diff --git a/libcaja-private/caja-dnd.c b/libcaja-private/caja-dnd.c index 792b3e79..9cfbcbc5 100644 --- a/libcaja-private/caja-dnd.c +++ b/libcaja-private/caja-dnd.c @@ -44,8 +44,6 @@ #include <stdio.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - /* a set of defines stolen from the eel-icon-dnd.c file. * These are in microseconds. */ diff --git a/libcaja-private/caja-emblem-utils.c b/libcaja-private/caja-emblem-utils.c index f837df69..2f4aa054 100644 --- a/libcaja-private/caja-emblem-utils.c +++ b/libcaja-private/caja-emblem-utils.c @@ -43,8 +43,6 @@ #include "caja-file.h" #include "caja-emblem-utils.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - #define EMBLEM_NAME_TRASH "emblem-trash" #define EMBLEM_NAME_SYMLINK "emblem-symbolic-link" #define EMBLEM_NAME_NOREAD "emblem-noread" @@ -395,7 +393,6 @@ caja_emblem_remove_emblem (const char *keyword) struct stat stat_buf; struct utimbuf ubuf; - dir = g_strdup_printf ("%s/.icons/hicolor/48x48/emblems", g_get_home_dir ()); stat_dir = g_strdup_printf ("%s/.icons/hicolor", @@ -425,6 +422,8 @@ caja_emblem_remove_emblem (const char *keyword) return FALSE; } + g_free (path); + /* Touch the toplevel dir */ if (stat (stat_dir, &stat_buf) == 0) { diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c index 8f5f9d79..a4baa8c8 100644 --- a/libcaja-private/caja-entry.c +++ b/libcaja-private/caja-entry.c @@ -53,7 +53,7 @@ enum SELECTION_CHANGED, LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static void caja_entry_editable_init (GtkEditableInterface *iface); diff --git a/libcaja-private/caja-extensions.c b/libcaja-private/caja-extensions.c index f553df13..cc167c5c 100644 --- a/libcaja-private/caja-extensions.c +++ b/libcaja-private/caja-extensions.c @@ -44,6 +44,10 @@ extension_new (gchar *filename, gboolean state, GObject *module) ext->filename = filename; ext->name = NULL; ext->description = NULL; + ext->author = NULL; + ext->copyright = NULL; + ext->version = NULL; + ext->website = NULL; ext->state = state; ext->module = module; @@ -53,7 +57,11 @@ extension_new (gchar *filename, gboolean state, GObject *module) { ext->name = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Name", NULL, NULL); ext->description = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Description", NULL, NULL); - ext->icon = g_key_file_get_locale_string (extension_file, CAJA_EXTENSION_GROUP, "Icon", NULL, NULL); + ext->icon = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Icon", NULL); + ext->author = g_key_file_get_string_list (extension_file, CAJA_EXTENSION_GROUP, "Author", NULL, NULL); + ext->copyright = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Copyright", NULL); + ext->version = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Version", NULL); + ext->website = g_key_file_get_string (extension_file, CAJA_EXTENSION_GROUP, "Website", NULL); } g_key_file_free (extension_file); g_free (extension_filename); diff --git a/libcaja-private/caja-extensions.h b/libcaja-private/caja-extensions.h index 5efcb569..01b3c819 100644 --- a/libcaja-private/caja-extensions.h +++ b/libcaja-private/caja-extensions.h @@ -32,6 +32,10 @@ typedef struct _Extension { gchar *name; gchar *description; gchar *icon; + gchar **author; + gchar *copyright; + gchar *version; + gchar *website; gboolean state; GObject *module; }Extension; diff --git a/libcaja-private/caja-file-changes-queue.c b/libcaja-private/caja-file-changes-queue.c index 127de7ed..8b60d63a 100644 --- a/libcaja-private/caja-file-changes-queue.c +++ b/libcaja-private/caja-file-changes-queue.c @@ -25,8 +25,6 @@ #include "caja-directory-notify.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - #ifdef G_THREADS_ENABLED #define MUTEX_LOCK(a) if ((a) != NULL) g_mutex_lock (a) #define MUTEX_UNLOCK(a) if ((a) != NULL) g_mutex_unlock (a) @@ -60,11 +58,7 @@ typedef struct GList *head; GList *tail; #ifdef G_THREADS_ENABLED -# if GLIB_CHECK_VERSION(2, 32, 0) GMutex mutex; -# else - GMutex *mutex; -# endif #endif } CajaFileChangesQueue; @@ -76,11 +70,7 @@ caja_file_changes_queue_new (void) result = g_new0 (CajaFileChangesQueue, 1); #ifdef G_THREADS_ENABLED -# if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_init (&result->mutex); -# else - result->mutex = g_mutex_new (); -# endif #endif return result; } @@ -135,11 +125,7 @@ caja_file_changes_queue_free (CajaFileChangesQueue *queue) g_list_free (queue->head); #ifdef G_THREADS_ENABLED -# if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_clear (&queue->mutex); -# else - g_mutex_free (queue->mutex); -# endif #endif g_free (queue); } @@ -151,21 +137,13 @@ caja_file_changes_queue_add_common (CajaFileChangesQueue *queue, CajaFileChange *new_item) { /* enqueue the new queue item while locking down the list */ -#if GLIB_CHECK_VERSION(2, 32, 0) MUTEX_LOCK (&queue->mutex); -#else - MUTEX_LOCK (queue->mutex); -#endif queue->head = g_list_prepend (queue->head, new_item); if (queue->tail == NULL) queue->tail = queue->head; -#if GLIB_CHECK_VERSION(2, 32, 0) MUTEX_UNLOCK (&queue->mutex); -#else - MUTEX_UNLOCK (queue->mutex); -#endif } void @@ -267,11 +245,7 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue) g_assert (queue != NULL); /* dequeue the tail item while locking down the list */ -#if GLIB_CHECK_VERSION (2, 32, 0) MUTEX_LOCK (&queue->mutex); -#else - MUTEX_LOCK (queue->mutex); -#endif if (queue->tail == NULL) { @@ -287,11 +261,7 @@ caja_file_changes_queue_get_change (CajaFileChangesQueue *queue) queue->tail = new_tail; } -#if GLIB_CHECK_VERSION (2, 32, 0) MUTEX_UNLOCK (&queue->mutex); -#else - MUTEX_UNLOCK (queue->mutex); -#endif return result; } diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index d78f961d..8b8dce74 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -340,8 +340,9 @@ file_list_ready_cb (GList *files, gtk_widget_hide (details->diff_button); if (!source_is_dir && !dest_is_dir) { - if (g_find_program_in_path ("meld")) { - + gchar *meld_found = g_find_program_in_path ("meld"); + if (meld_found) { + g_free (meld_found); gboolean src_is_binary; gboolean dest_is_binary; diff --git a/libcaja-private/caja-file-dnd.c b/libcaja-private/caja-file-dnd.c index 5e1beec5..061019e9 100644 --- a/libcaja-private/caja-file-dnd.c +++ b/libcaja-private/caja-file-dnd.c @@ -32,8 +32,6 @@ #include "caja-file-utilities.h" #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - static gboolean caja_drag_can_accept_files (CajaFile *drop_target_item) { diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index 35ddf81e..e310de1f 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -68,8 +68,6 @@ #include "caja-file-conflict-dialog.h" #include "caja-undostack-manager.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - /* TODO: TESTING!!! */ typedef struct { @@ -851,14 +849,10 @@ custom_size_to_string (char *format, va_list va) size = va_arg (va, goffset); - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - return g_format_size_full (size, G_FORMAT_SIZE_IEC_UNITS); - else - return g_format_size(size); - #else - return g_format_size_for_display(size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + return g_format_size_full (size, G_FORMAT_SIZE_IEC_UNITS); + else + return g_format_size(size); } static void @@ -5273,7 +5267,7 @@ link_file (CopyMoveJob *job, if (not_local) { secondary = f (_("Symbolic links only supported for local files")); details = NULL; - } else if (IS_IO_ERROR (error, NOT_SUPPORTED)) { + } else if (error != NULL && IS_IO_ERROR (error, NOT_SUPPORTED)) { secondary = f (_("The target doesn't support symbolic links.")); details = NULL; } else { diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c index cc08be57..51083122 100644 --- a/libcaja-private/caja-file-utilities.c +++ b/libcaja-private/caja-file-utilities.c @@ -43,8 +43,6 @@ #include <unistd.h> #include <stdlib.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #define CAJA_USER_DIRECTORY_NAME ".config/caja" #define DEFAULT_CAJA_DIRECTORY_MODE (0755) @@ -1107,18 +1105,13 @@ caja_find_file_insensitive_next (GFile *parent, const gchar *name) gboolean caja_is_engrampa_installed (void) { - static int installed = - 1; + static int installed = -1; if (installed < 0) { - if (g_find_program_in_path ("engrampa")) - { - installed = 1; - } - else - { - installed = 0; - } + gchar *found = g_find_program_in_path ("engrampa"); + installed = found ? 1 : 0; + g_free (found); } return installed > 0 ? TRUE : FALSE; diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index d80629e2..2e3ad466 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -72,8 +72,6 @@ #include <unistd.h> #include <sys/stat.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #ifdef HAVE_SELINUX #include <selinux/selinux.h> #endif @@ -116,7 +114,7 @@ enum { static int date_format_pref; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static GHashTable *symbolic_links; @@ -694,7 +692,7 @@ caja_file_get_internal (GFile *location, gboolean create) /* Ref or create the file. */ if (file != NULL) { caja_file_ref (file); - } else if (create) { + } else if (create && directory != NULL) { file = caja_file_new_from_filename (directory, basename, self_owned); if (self_owned) { g_assert (directory->details->as_file == NULL); @@ -5958,14 +5956,10 @@ caja_file_get_size_as_string (CajaFile *file) return NULL; } - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS); - else - return g_format_size (file->details->size); - #else // Since 2.16 - return g_format_size_for_display(file->details->size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + return g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS); + else + return g_format_size (file->details->size); } /** @@ -5985,8 +5979,8 @@ caja_file_get_size_as_string_with_real_size (CajaFile *file) { guint item_count; gboolean count_unreadable; - char * formated; - char * formated_plus_real; + char * formatted; + char * formatted_plus_real; char * real_size; if (file == NULL) { @@ -6006,21 +6000,17 @@ caja_file_get_size_as_string_with_real_size (CajaFile *file) return NULL; } - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - formated = g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS); - else - formated = g_format_size(file->details->size); - #else - formated = g_format_size_for_display(file->details->size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + formatted = g_format_size_full (file->details->size, G_FORMAT_SIZE_IEC_UNITS); + else + formatted = g_format_size(file->details->size); /* Do this in a separate stage so that we don't have to put G_GUINT64_FORMAT in the translated string */ real_size = g_strdup_printf (_("%"G_GUINT64_FORMAT), (guint64) file->details->size); - formated_plus_real = g_strdup_printf (_("%s (%s bytes)"), formated, real_size); + formatted_plus_real = g_strdup_printf (_("%s (%s bytes)"), formatted, real_size); g_free (real_size); - g_free (formated); - return formated_plus_real; + g_free (formatted); + return formatted_plus_real; } @@ -6081,14 +6071,10 @@ caja_file_get_deep_count_as_string_internal (CajaFile *file, */ if (report_size) { - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - return g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS); - else - return g_format_size(total_size); - #else - return g_format_size_for_display(total_size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + return g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS); + else + return g_format_size(total_size); } return format_item_count_for_display (report_directory_count @@ -6899,14 +6885,10 @@ caja_file_get_volume_free_space (CajaFile *file) if (directory->details->free_space != (guint64) -1) { - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - res = g_format_size_full (directory->details->free_space, G_FORMAT_SIZE_IEC_UNITS); - else - res = g_format_size(directory->details->free_space); - #else - res = g_format_size_for_display(directory->details->free_space); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + res = g_format_size_full (directory->details->free_space, G_FORMAT_SIZE_IEC_UNITS); + else + res = g_format_size(directory->details->free_space); } return res; diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 58ff44fa..fe44b9b2 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -50,8 +50,6 @@ #include <stdio.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #define EMBLEM_SPACING 2 /* gap between bottom of icon and start of text box */ diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index c33868dd..5db10601 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -52,8 +52,6 @@ #include <stdio.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #if !GTK_CHECK_VERSION(3, 0, 0) #define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment #define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment @@ -300,7 +298,7 @@ typedef struct gboolean tight; } PlacementGrid; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; /* Functions dealing with CajaIcons. */ @@ -2060,6 +2058,7 @@ align_icons (CajaIconContainer *container) if (!grid) { + g_list_free (unplaced_icons); return; } @@ -10000,7 +9999,6 @@ caja_icon_container_accessible_add_selection (AtkSelection *accessible, { GtkWidget *widget; CajaIconContainer *container; - GList *l; GList *selection; CajaIcon *icon; @@ -10012,11 +10010,9 @@ caja_icon_container_accessible_add_selection (AtkSelection *accessible, container = CAJA_ICON_CONTAINER (widget); - l = g_list_nth (container->details->icons, i); - if (l) + icon = g_list_nth_data (container->details->icons, i); + if (icon) { - icon = l->data; - selection = caja_icon_container_get_selection (container); selection = g_list_prepend (selection, icon->data); @@ -10054,17 +10050,14 @@ caja_icon_container_accessible_ref_selection (AtkSelection *accessible, { AtkObject *atk_object; CajaIconContainerAccessiblePrivate *priv; - GList *item; CajaIcon *icon; caja_icon_container_accessible_update_selection (ATK_OBJECT (accessible)); priv = accessible_get_priv (ATK_OBJECT (accessible)); - item = (g_list_nth (priv->selection, i)); - - if (item) + icon = g_list_nth_data (priv->selection, i); + if (icon) { - icon = item->data; atk_object = atk_gobject_accessible_for_object (G_OBJECT (icon->item)); if (atk_object) { @@ -10098,7 +10091,6 @@ caja_icon_container_accessible_is_child_selected (AtkSelection *accessible, int i) { CajaIconContainer *container; - GList *l; CajaIcon *icon; GtkWidget *widget; @@ -10110,13 +10102,8 @@ caja_icon_container_accessible_is_child_selected (AtkSelection *accessible, container = CAJA_ICON_CONTAINER (widget); - l = g_list_nth (container->details->icons, i); - if (l) - { - icon = l->data; - return icon->is_selected; - } - return FALSE; + icon = g_list_nth_data (container->details->icons, i); + return icon ? icon->is_selected : FALSE; } static gboolean @@ -10125,7 +10112,6 @@ caja_icon_container_accessible_remove_selection (AtkSelection *accessible, { CajaIconContainer *container; CajaIconContainerAccessiblePrivate *priv; - GList *l; GList *selection; CajaIcon *icon; GtkWidget *widget; @@ -10141,11 +10127,9 @@ caja_icon_container_accessible_remove_selection (AtkSelection *accessible, container = CAJA_ICON_CONTAINER (widget); - l = g_list_nth (priv->selection, i); - if (l) + icon = g_list_nth_data (priv->selection, i); + if (icon) { - icon = l->data; - selection = caja_icon_container_get_selection (container); selection = g_list_remove (selection, icon->data); caja_icon_container_set_selection (container, selection); @@ -10238,7 +10222,6 @@ caja_icon_container_accessible_ref_child (AtkObject *accessible, int i) { AtkObject *atk_object; CajaIconContainer *container; - GList *item; CajaIcon *icon; GtkWidget *widget; @@ -10250,12 +10233,9 @@ caja_icon_container_accessible_ref_child (AtkObject *accessible, int i) container = CAJA_ICON_CONTAINER (widget); - item = (g_list_nth (container->details->icons, i)); - - if (item) + icon = g_list_nth_data (container->details->icons, i); + if (icon) { - icon = item->data; - atk_object = atk_gobject_accessible_for_object (G_OBJECT (icon->item)); g_object_ref (atk_object); diff --git a/libcaja-private/caja-link.c b/libcaja-private/caja-link.c index 89971772..4f39a474 100644 --- a/libcaja-private/caja-link.c +++ b/libcaja-private/caja-link.c @@ -416,19 +416,14 @@ caja_link_local_get_additional_text (const char *path) static char * caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_file_uri) { - GFile *file, *parent; - char *type; - char *retval; - char *scheme; - - retval = NULL; - - type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL); + char *type = g_key_file_get_string (key_file, MAIN_GROUP, "Type", NULL); if (type == NULL) { return NULL; } + char *retval = NULL; + if (strcmp (type, "URL") == 0) { /* Some old broken desktop files use this nonstandard feature, we need handle it though */ @@ -450,11 +445,11 @@ caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_fil * g_file_parse_name(), but it does not know how to resolve * relative file names, since the base directory is unknown. */ - scheme = g_uri_parse_scheme (retval); + char *scheme = g_uri_parse_scheme (retval); if (scheme == NULL) { - file = g_file_new_for_uri (desktop_file_uri); - parent = g_file_get_parent (file); + GFile *file = g_file_new_for_uri (desktop_file_uri); + GFile *parent = g_file_get_parent (file); g_object_unref (file); if (parent != NULL) @@ -466,6 +461,10 @@ caja_link_get_link_uri_from_desktop (GKeyFile *key_file, const char *desktop_fil g_object_unref (parent); } } + else + { + g_free (scheme); + } } return retval; diff --git a/libcaja-private/caja-merged-directory.c b/libcaja-private/caja-merged-directory.c index bb7ce9eb..2c8d825d 100644 --- a/libcaja-private/caja-merged-directory.c +++ b/libcaja-private/caja-merged-directory.c @@ -33,8 +33,6 @@ #include <eel/eel-gtk-macros.h> #include <gtk/gtk.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - struct CajaMergedDirectoryDetails { GList *directories; @@ -71,7 +69,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (CajaMergedDirectory, caja_merged_directory, CAJA_TYPE_DIRECTORY); diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c index bbcc6f4d..2a303f72 100644 --- a/libcaja-private/caja-mime-actions.c +++ b/libcaja-private/caja-mime-actions.c @@ -44,8 +44,6 @@ #include "caja-debug-log.h" #include "caja-open-with-dialog.h" -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef enum { ACTIVATION_ACTION_LAUNCH_DESKTOP_FILE, diff --git a/libcaja-private/caja-mime-application-chooser.c b/libcaja-private/caja-mime-application-chooser.c index 21c56c1a..c989bad1 100644 --- a/libcaja-private/caja-mime-application-chooser.c +++ b/libcaja-private/caja-mime-application-chooser.c @@ -39,8 +39,6 @@ #include <gtk/gtk.h> #include <gio/gio.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - struct _CajaMimeApplicationChooserDetails { char *uri; diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c index 0d7a4537..0d0e6e28 100644 --- a/libcaja-private/caja-open-with-dialog.c +++ b/libcaja-private/caja-open-with-dialog.c @@ -36,8 +36,6 @@ #include <gtk/gtk.h> #include <gio/gio.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #define sure_string(s) ((const char *)((s)!=NULL?(s):"")) #define DESKTOP_ENTRY_GROUP "Desktop Entry" diff --git a/libcaja-private/caja-program-choosing.c b/libcaja-private/caja-program-choosing.c index 8958119a..8ac87f0b 100644 --- a/libcaja-private/caja-program-choosing.c +++ b/libcaja-private/caja-program-choosing.c @@ -42,8 +42,6 @@ #include <gdk/gdk.h> #include <gdk/gdkx.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - /** * application_cannot_open_location * diff --git a/libcaja-private/caja-query.c b/libcaja-private/caja-query.c index df4a8753..e0359a04 100644 --- a/libcaja-private/caja-query.c +++ b/libcaja-private/caja-query.c @@ -30,8 +30,6 @@ #include <glib/gi18n.h> #include <libcaja-private/caja-file-utilities.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - struct CajaQueryDetails { char *text; @@ -308,6 +306,7 @@ caja_query_parse_xml (char *xml, gsize xml_len) ctx = g_markup_parse_context_new (&parser, 0, &info, NULL); g_markup_parse_context_parse (ctx, xml, xml_len, NULL); + g_markup_parse_context_free (ctx); return info.query; } diff --git a/libcaja-private/caja-search-engine-beagle.c b/libcaja-private/caja-search-engine-beagle.c index 1b63bb28..14bbb605 100644 --- a/libcaja-private/caja-search-engine-beagle.c +++ b/libcaja-private/caja-search-engine-beagle.c @@ -27,8 +27,6 @@ #include <eel/eel-gtk-macros.h> #include <gmodule.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef struct _BeagleHit BeagleHit; typedef struct _BeagleQuery BeagleQuery; typedef struct _BeagleClient BeagleClient; diff --git a/libcaja-private/caja-search-engine-simple.c b/libcaja-private/caja-search-engine-simple.c index dc30dbe8..8a768e50 100644 --- a/libcaja-private/caja-search-engine-simple.c +++ b/libcaja-private/caja-search-engine-simple.c @@ -30,8 +30,6 @@ #include <eel/eel-gtk-macros.h> #include <gio/gio.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - #define BATCH_SIZE 500 typedef struct diff --git a/libcaja-private/caja-search-engine-tracker.c b/libcaja-private/caja-search-engine-tracker.c index edf725c8..5f97a70e 100644 --- a/libcaja-private/caja-search-engine-tracker.c +++ b/libcaja-private/caja-search-engine-tracker.c @@ -27,8 +27,6 @@ #include <gmodule.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef struct _TrackerClient TrackerClient; typedef enum diff --git a/libcaja-private/caja-search-engine.c b/libcaja-private/caja-search-engine.c index e5b1a311..59bb05ab 100644 --- a/libcaja-private/caja-search-engine.c +++ b/libcaja-private/caja-search-engine.c @@ -43,7 +43,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static void caja_search_engine_class_init (CajaSearchEngineClass *class); static void caja_search_engine_init (CajaSearchEngine *engine); diff --git a/libcaja-private/caja-signaller.c b/libcaja-private/caja-signaller.c index 38f75110..0d31bed7 100644 --- a/libcaja-private/caja-signaller.c +++ b/libcaja-private/caja-signaller.c @@ -44,7 +44,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static GType caja_signaller_get_type (void); diff --git a/libcaja-private/caja-trash-monitor.c b/libcaja-private/caja-trash-monitor.c index 5c2341f6..b7c3b8b7 100644 --- a/libcaja-private/caja-trash-monitor.c +++ b/libcaja-private/caja-trash-monitor.c @@ -47,7 +47,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static CajaTrashMonitor *caja_trash_monitor = NULL; G_DEFINE_TYPE(CajaTrashMonitor, caja_trash_monitor, G_TYPE_OBJECT) diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index 294d78a4..22a5cc51 100644 --- a/libcaja-private/caja-tree-view-drag-dest.c +++ b/libcaja-private/caja-tree-view-drag-dest.c @@ -79,7 +79,7 @@ enum static void caja_tree_view_drag_dest_init (CajaTreeViewDragDest *dest); static void caja_tree_view_drag_dest_class_init (CajaTreeViewDragDestClass *class); -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (CajaTreeViewDragDest, caja_tree_view_drag_dest, G_TYPE_OBJECT); diff --git a/libcaja-private/caja-undostack-manager.c b/libcaja-private/caja-undostack-manager.c index 5686abfa..1d988cda 100644 --- a/libcaja-private/caja-undostack-manager.c +++ b/libcaja-private/caja-undostack-manager.c @@ -34,8 +34,6 @@ #include <locale.h> #include <gdk/gdk.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - /* ***************************************************************** Private fields ***************************************************************** */ @@ -100,11 +98,7 @@ struct _CajaUndoStackManagerPrivate GQueue *stack; guint undo_levels; guint index; -#if GLIB_CHECK_VERSION(2, 32, 0) GMutex mutex; /* Used to protect access to stack (because of async file ops) */ -#else - GMutex *mutex; /* Used to protect access to stack (because of async file ops) */ -#endif gboolean dispose_has_run; gboolean undo_redo_flag; gboolean confirm_delete; @@ -273,11 +267,7 @@ caja_undostack_manager_init (CajaUndoStackManager * self) /* Initialize private fields */ priv->stack = g_queue_new (); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_init (&priv->mutex); -#else - priv->mutex = g_mutex_new (); -#endif priv->index = 0; priv->dispose_has_run = FALSE; priv->undo_redo_flag = FALSE; @@ -293,22 +283,13 @@ caja_undostack_manager_dispose (GObject * object) if (priv->dispose_has_run) return; -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif /* Free each undoable action in the stack and the stack itself */ undostack_dispose_all (priv->stack); g_queue_free (priv->stack); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); g_mutex_clear (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); - g_mutex_free (priv->mutex); -#endif priv->dispose_has_run = TRUE; @@ -339,17 +320,9 @@ caja_undostack_manager_set_property (GObject * object, guint prop_id, new_undo_levels = g_value_get_uint (value); if (new_undo_levels > 0 && (priv->undo_levels != new_undo_levels)) { priv->undo_levels = new_undo_levels; -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif stack_fix_size (priv); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif do_menu_update (manager); } break; @@ -436,12 +409,7 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager, char *puri; CajaUndoStackManagerPrivate *priv = manager->priv; -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif - CajaUndoStackActionData *action = stack_scroll_left (priv); @@ -450,12 +418,7 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager, action->locked = TRUE; } -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif - do_menu_update (manager); @@ -585,11 +548,7 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager, char *new_name; CajaUndoStackManagerPrivate *priv = manager->priv; -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif CajaUndoStackActionData *action = stack_scroll_right (priv); @@ -597,11 +556,7 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager, action->locked = TRUE; } -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif do_menu_update (manager); @@ -757,22 +712,13 @@ caja_undostack_manager_add_action (CajaUndoStackManager * manager, action->manager = manager; -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif stack_push_action (priv, action); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif do_menu_update (manager); - } static GList * @@ -825,11 +771,7 @@ caja_undostack_manager_trash_has_emptied (CajaUndoStackManager * /* Clear actions from the oldest to the newest move to trash */ -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif clear_redo_actions (priv); CajaUndoStackActionData *action = NULL; @@ -855,11 +797,7 @@ caja_undostack_manager_trash_has_emptied (CajaUndoStackManager * } g_queue_free (tmp_stack); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif do_menu_update (manager); } @@ -1922,11 +1860,7 @@ do_menu_update (CajaUndoStackManager * manager) CajaUndoStackManagerPrivate *priv = manager->priv; CajaUndoStackMenuData *data = g_slice_new0 (CajaUndoStackMenuData); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_lock (&priv->mutex); -#else - g_mutex_lock (priv->mutex); -#endif action = get_next_undo_action (priv); data->undo_label = get_undo_label (action); @@ -1937,11 +1871,7 @@ do_menu_update (CajaUndoStackManager * manager) data->redo_label = get_redo_label (action); data->redo_description = get_redo_description (action); -#if GLIB_CHECK_VERSION(2, 32, 0) g_mutex_unlock (&priv->mutex); -#else - g_mutex_unlock (priv->mutex); -#endif /* Update menus */ g_signal_emit_by_name (manager, "request-menu-update", data); @@ -2034,66 +1964,52 @@ get_uri_parent_path (char *uri) static GHashTable * retrieve_files_to_restore (GHashTable * trashed) { - GFileEnumerator *enumerator; - GFileInfo *info; - GFile *trash; - GFile *item; - guint64 mtime_item; - guint64 *mtime; - const char *origpath; - GFile *origfile; - char *origuri; - gpointer lookupvalue; - GHashTable *to_restore; - - to_restore = - g_hash_table_new_full (g_direct_hash, - g_direct_equal, g_object_unref, g_free); + if (!(g_hash_table_size (trashed)) > 0) { + return NULL; + } - trash = g_file_new_for_uri ("trash:"); + GFile *trash = g_file_new_for_uri ("trash:"); - enumerator = g_file_enumerate_children (trash, + GFileEnumerator *enumerator = g_file_enumerate_children (trash, G_FILE_ATTRIBUTE_STANDARD_NAME "," G_FILE_ATTRIBUTE_TIME_MODIFIED ",trash::orig-path", G_FILE_QUERY_INFO_NOFOLLOW_SYMLINKS, FALSE, NULL); - mtime = 0; - - guint nb; - GList *l; - if (!(g_hash_table_size (trashed)) > 0) - return NULL; - + GHashTable *to_restore = g_hash_table_new_full (g_direct_hash, + g_direct_equal, g_object_unref, g_free); + if (enumerator) { - while ((info = - g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { + GFileInfo *info; + while ((info = g_file_enumerator_next_file (enumerator, NULL, NULL)) != NULL) { /* Retrieve the original file uri */ - origpath = g_file_info_get_attribute_byte_string (info, "trash::orig-path"); - origfile = g_file_new_for_path (origpath); - origuri = g_file_get_uri (origfile); + const char *origpath = g_file_info_get_attribute_byte_string (info, "trash::orig-path"); + GFile *origfile = g_file_new_for_path (origpath); + char *origuri = g_file_get_uri (origfile); g_object_unref (origfile); - lookupvalue = g_hash_table_lookup (trashed, origuri); + gboolean origuri_inserted = FALSE; + gpointer lookupvalue = g_hash_table_lookup (trashed, origuri); if (lookupvalue) { - mtime = (guint64 *) - lookupvalue; - mtime_item = - g_file_info_get_attribute_uint64 - (info, G_FILE_ATTRIBUTE_TIME_MODIFIED); + guint64 *mtime = (guint64 *) lookupvalue; + guint64 mtime_item = g_file_info_get_attribute_uint64(info, G_FILE_ATTRIBUTE_TIME_MODIFIED); if (*mtime == mtime_item) { - item = g_file_get_child (trash, g_file_info_get_name (info)); /* File in the trash */ + GFile *item = g_file_get_child (trash, g_file_info_get_name (info)); /* File in the trash */ g_hash_table_insert (to_restore, item, origuri); + origuri_inserted = TRUE; } - } else { - g_free (origuri); } + if (!origuri_inserted) { + g_free (origuri); + } } + g_file_enumerator_close (enumerator, FALSE, NULL); g_object_unref (enumerator); } + g_object_unref (trash); return to_restore; |