diff options
Diffstat (limited to 'src')
41 files changed, 395 insertions, 244 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 189c1f5f..37bf1f54 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -162,7 +162,6 @@ caja_SOURCES = \ caja-zoom-action.h \ caja-zoom-control.c \ caja-zoom-control.h \ - glibcompat.h \ $(NULL) nodist_caja_SOURCES = \ diff --git a/src/caja-application.c b/src/caja-application.c index b7199725..e4d2d973 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -78,8 +78,6 @@ #define MATE_DESKTOP_USE_UNSTABLE_API #include <libmate-desktop/mate-bg.h> -#include "glibcompat.h" /* for g_list_free_full */ - enum { COMMAND_0, /* unused: 0 is an invalid command */ @@ -122,7 +120,10 @@ static void mount_added_callback (GVolumeMonitor *mo static void volume_added_callback (GVolumeMonitor *monitor, GVolume *volume, CajaApplication *application); -static void drive_connected_callback (GVolumeMonitor *monitor, +static void volume_removed_callback (GVolumeMonitor *monitor, + GVolume *volume, + CajaApplication *application); + static void drive_connected_callback (GVolumeMonitor *monitor, GDrive *drive, CajaApplication *application); static void drive_listen_for_eject_button (GDrive *drive, @@ -362,7 +363,18 @@ caja_application_finalize (GObject *object) g_object_unref (application->unique_app); - if (application->automount_idle_id != 0) + if (application->ss_watch_id > 0) + { + g_bus_unwatch_name (application->ss_watch_id); + } + + if (application->volume_queue != NULL) + { + g_list_free_full (application->volume_queue, g_object_unref); + application->volume_queue = NULL; + } + + if (application->automount_idle_id != 0) { g_source_remove (application->automount_idle_id); application->automount_idle_id = 0; @@ -374,6 +386,12 @@ caja_application_finalize (GObject *object) fdb_manager = NULL; } + if (application->ss_proxy != NULL) + { + g_object_unref (application->ss_proxy); + application->ss_proxy = NULL; + } + G_OBJECT_CLASS (caja_application_parent_class)->finalize (object); } @@ -554,6 +572,180 @@ out: } static void +check_volume_queue (CajaApplication *application) +{ + GList *l, *next; + GVolume *volume; + + l = application->volume_queue; + + if (application->screensaver_active) + { + return; + } + + while (l != NULL) { + volume = l->data; + next = l->next; + + caja_file_operations_mount_volume (NULL, volume, TRUE); + application->volume_queue = + g_list_remove (application->volume_queue, volume); + + g_object_unref (volume); + l = next; + } + + application->volume_queue = NULL; +} + +#define SCREENSAVER_NAME "org.mate.ScreenSaver" +#define SCREENSAVER_PATH "/org/mate/ScreenSaver" +#define SCREENSAVER_INTERFACE "org.mate.ScreenSaver" + +static void +screensaver_signal_callback (GDBusProxy *proxy, + const gchar *sender_name, + const gchar *signal_name, + GVariant *parameters, + gpointer user_data) +{ + CajaApplication *application = user_data; + + if (g_strcmp0 (signal_name, "ActiveChanged") == 0) + { + g_variant_get (parameters, "(b)", &application->screensaver_active); + g_debug ("Screensaver active changed to %d", application->screensaver_active); + + check_volume_queue (application); + } +} + +static void +screensaver_get_active_ready_cb (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + CajaApplication *application = user_data; + GDBusProxy *proxy = application->ss_proxy; + GVariant *result; + GError *error = NULL; + + result = g_dbus_proxy_call_finish (proxy, + res, + &error); + + if (error != NULL) { + g_warning ("Can't call GetActive() on the ScreenSaver object: %s", + error->message); + g_error_free (error); + + return; + } + + g_variant_get (result, "(b)", &application->screensaver_active); + g_variant_unref (result); + + g_debug ("Screensaver GetActive() returned %d", application->screensaver_active); +} + +static void +screensaver_proxy_ready_cb (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + CajaApplication *application = user_data; + GError *error = NULL; + GDBusProxy *ss_proxy; + + ss_proxy = g_dbus_proxy_new_finish (res, &error); + + if (error != NULL) + { + g_warning ("Can't get proxy for the ScreenSaver object: %s", + error->message); + g_error_free (error); + + return; + } + + g_debug ("ScreenSaver proxy ready"); + + application->ss_proxy = ss_proxy; + + g_signal_connect (ss_proxy, "g-signal", + G_CALLBACK (screensaver_signal_callback), application); + + g_dbus_proxy_call (ss_proxy, + "GetActive", + NULL, + G_DBUS_CALL_FLAGS_NO_AUTO_START, + -1, + NULL, + screensaver_get_active_ready_cb, + application); +} + +static void +screensaver_appeared_callback (GDBusConnection *connection, + const gchar *name, + const gchar *name_owner, + gpointer user_data) +{ + CajaApplication *application = user_data; + + g_debug ("ScreenSaver name appeared"); + + application->screensaver_active = FALSE; + + g_dbus_proxy_new (connection, + G_DBUS_PROXY_FLAGS_DO_NOT_AUTO_START, + NULL, + name, + SCREENSAVER_PATH, + SCREENSAVER_INTERFACE, + NULL, + screensaver_proxy_ready_cb, + application); +} + +static void +screensaver_vanished_callback (GDBusConnection *connection, + const gchar *name, + gpointer user_data) +{ + CajaApplication *application = user_data; + + g_debug ("ScreenSaver name vanished"); + + application->screensaver_active = FALSE; + g_object_unref (&application->ss_proxy); + + /* in this case force a clear of the volume queue, without + * mounting them. + */ + if (application->volume_queue != NULL) + { + g_list_free_full (application->volume_queue, g_object_unref); + application->volume_queue = NULL; + } +} + +static void +do_initialize_screensaver (CajaApplication *application) +{ + application->ss_watch_id = + g_bus_watch_name (G_BUS_TYPE_SESSION, + SCREENSAVER_NAME, + G_BUS_NAME_WATCHER_FLAGS_NONE, + screensaver_appeared_callback, + screensaver_vanished_callback, + application, + NULL); +} + + +static void do_upgrades_once (CajaApplication *application, gboolean no_desktop) { @@ -601,7 +793,11 @@ finish_startup (CajaApplication *application, /* Initialize the desktop link monitor singleton */ caja_desktop_link_monitor_get (); - /* Watch for mounts so we can restore open windows This used + /* Initialize MATE screen saver listener to control automount + * permission */ + do_initialize_screensaver (application); + + /* Watch for mounts so we can restore open windows This used * to be for showing new window on mount, but is not used * anymore */ @@ -616,6 +812,8 @@ finish_startup (CajaApplication *application, G_CALLBACK (mount_added_callback), application, 0); g_signal_connect_object (application->volume_monitor, "volume_added", G_CALLBACK (volume_added_callback), application, 0); + g_signal_connect_object (application->volume_monitor, "volume_removed", + G_CALLBACK (volume_removed_callback), application, 0); g_signal_connect_object (application->volume_monitor, "drive_connected", G_CALLBACK (drive_connected_callback), application, 0); @@ -1477,6 +1675,34 @@ window_can_be_closed (CajaWindow *window) } static void +check_screen_lock_and_mount (CajaApplication *application, + GVolume *volume) +{ + if (application->screensaver_active) + { + /* queue the volume, to mount it after the screensaver state changed */ + g_debug ("Queuing volume %p", volume); + application->volume_queue = g_list_prepend (application->volume_queue, + g_object_ref (volume)); + } else { + /* mount it immediately */ + caja_file_operations_mount_volume (NULL, volume, TRUE); + } +} + +static void +volume_removed_callback (GVolumeMonitor *monitor, + GVolume *volume, + CajaApplication *application) +{ + g_debug ("Volume %p removed, removing from the queue", volume); + + /* clear it from the queue, if present */ + application->volume_queue = + g_list_remove (application->volume_queue, volume); +} + +static void volume_added_callback (GVolumeMonitor *monitor, GVolume *volume, CajaApplication *application) @@ -1485,7 +1711,7 @@ volume_added_callback (GVolumeMonitor *monitor, g_volume_should_automount (volume) && g_volume_can_mount (volume)) { - caja_file_operations_mount_volume (NULL, volume, TRUE); + check_screen_lock_and_mount (application, volume); } else { diff --git a/src/caja-application.h b/src/caja-application.h index 27cd8e18..699083a8 100644 --- a/src/caja-application.h +++ b/src/caja-application.h @@ -66,6 +66,10 @@ typedef struct EggSMClient* smclient; GVolumeMonitor* volume_monitor; unsigned int automount_idle_id; + gboolean screensaver_active; + guint ss_watch_id; + GDBusProxy *ss_proxy; + GList *volume_queue; } CajaApplication; typedef struct diff --git a/src/caja-bookmark-list.c b/src/caja-bookmark-list.c index 8ea12d41..c0976396 100644 --- a/src/caja-bookmark-list.c +++ b/src/caja-bookmark-list.c @@ -35,8 +35,6 @@ #include <gio/gio.h> #include <string.h> -#include "glibcompat.h" /* for g_list_free_full */ - #define MAX_BOOKMARK_LENGTH 80 #define LOAD_JOB 1 #define SAVE_JOB 2 @@ -47,7 +45,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static char *window_geometry; static CajaBookmarkList *singleton = NULL; @@ -335,6 +333,8 @@ caja_bookmark_list_delete_item_at (CajaBookmarkList *bookmarks, g_return_if_fail (index < g_list_length (bookmarks->list)); doomed = g_list_nth (bookmarks->list, index); + g_return_if_fail (doomed != NULL); + bookmarks->list = g_list_remove_link (bookmarks->list, doomed); g_assert (CAJA_IS_BOOKMARK (doomed->data)); @@ -366,6 +366,8 @@ caja_bookmark_list_move_item (CajaBookmarkList *bookmarks, } bookmark_item = g_list_nth (bookmarks->list, index); + g_return_if_fail (bookmark_item != NULL); + bookmarks->list = g_list_remove_link (bookmarks->list, bookmark_item); diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index b068e6b2..921b2597 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -602,7 +602,7 @@ connect_dialog_connect_to_server (CajaConnectServerDialog *dialog) uri = g_strdup_printf ("%s://%s%s%s%s%s%s", meth->scheme, (user != NULL) ? user : "", - (user[0] != 0) ? "@" : "", + (user != NULL && user[0] != 0) ? "@" : "", server, (port_str != NULL) ? ":" : "", (port_str != NULL) ? port_str : "", @@ -869,6 +869,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) label = gtk_label_new (NULL); str = g_strdup_printf ("<b>%s</b>", _("Server Details")); gtk_label_set_markup (GTK_LABEL (label), str); + g_free (str); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6); gtk_widget_show (label); @@ -1042,6 +1043,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) label = gtk_label_new (NULL); str = g_strdup_printf ("<b>%s</b>", _("User Details")); gtk_label_set_markup (GTK_LABEL (label), str); + g_free (str); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6); diff --git a/src/caja-convert-metadata.c b/src/caja-convert-metadata.c index d3968abe..2047ace0 100644 --- a/src/caja-convert-metadata.c +++ b/src/caja-convert-metadata.c @@ -338,10 +338,6 @@ main (int argc, char *argv[]) GError *error = NULL; int i; -#if !GLIB_CHECK_VERSION (2, 36, 0) - g_type_init (); -#endif - context = g_option_context_new ("<caja metadata files> - convert caja metadata"); g_option_context_add_main_entries (context, entries, NULL); if (!g_option_context_parse (context, &argc, &argv, &error)) diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index b1e6ec58..fe254515 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -47,8 +47,6 @@ #include <libcaja-private/caja-module.h> #include <libcaja-private/caja-signaller.h> -#include "glibcompat.h" /* for g_list_free_full */ - struct CajaEmblemSidebarDetails { CajaWindowInfo *window; diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 9df0695b..24283611 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -43,6 +43,8 @@ #include <libcaja-private/caja-autorun.h> +#include <libmate-desktop/mate-aboutdialog.h> + /* string enum preferences */ #define CAJA_FILE_MANAGEMENT_PROPERTIES_DEFAULT_VIEW_WIDGET "default_view_combobox" #define CAJA_FILE_MANAGEMENT_PROPERTIES_ICON_VIEW_ZOOM_WIDGET "icon_view_zoom_combobox" @@ -613,6 +615,51 @@ out: g_free (x_content_type); } +static gulong extension_about_id = 0; + +static void +extension_about_clicked (GtkButton *button, Extension *ext) +{ + MateAboutDialog *extension_about_dialog; + + extension_about_dialog = mate_about_dialog_new(); + mate_about_dialog_set_program_name (extension_about_dialog, ext->name != NULL ? ext->name : ext->filename); + mate_about_dialog_set_comments (extension_about_dialog, ext->description); + mate_about_dialog_set_logo_icon_name (extension_about_dialog, ext->icon != NULL ? ext->icon : "system-run"); + mate_about_dialog_set_copyright (extension_about_dialog, ext->copyright); + mate_about_dialog_set_authors (extension_about_dialog, ext->author); + mate_about_dialog_set_version (extension_about_dialog, ext->version); + mate_about_dialog_set_website (extension_about_dialog, ext->website); + gtk_window_set_title (GTK_WINDOW(extension_about_dialog), _("About Extension")); + gtk_dialog_run (GTK_DIALOG (extension_about_dialog)); + gtk_widget_destroy (extension_about_dialog); +} + +static void +extension_list_selection_changed (GtkTreeSelection *selection, GtkButton *about_button) +{ + GtkTreeModel *model; + GtkTreeIter iter; + Extension *ext; + + gtk_widget_set_sensitive (about_button, FALSE); + + if (extension_about_id > 0) + { + g_signal_handler_disconnect (about_button, extension_about_id); + extension_about_id = 0; + } + + if (!gtk_tree_selection_get_selected (selection, &model, &iter)) + return; + + gtk_tree_model_get (model, &iter, EXT_STRUCT_COLUMN, &ext, -1); + if (ext != NULL) { + gtk_widget_set_sensitive (about_button, TRUE); + extension_about_id = g_signal_connect (about_button, "clicked", G_CALLBACK (extension_about_clicked), ext); + } +} + static void extension_state_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer data) { @@ -628,8 +675,6 @@ extension_state_toggled (GtkCellRendererToggle *cell, gchar *path_str, gpointer g_object_get (G_OBJECT (cell), "active", &new_state, NULL); gtk_tree_model_get_iter_from_string (model, &iter, path_str); - - new_state ^= 1; if (&iter != NULL) @@ -762,16 +807,18 @@ caja_file_management_properties_dialog_setup_extension_page (GtkBuilder *builder GtkCellRendererToggle *toggle; GtkListStore *store; GtkTreeView *view; + GtkTreeSelection *selection; GtkTreeIter iter; GtkIconTheme *icon_theme; GdkPixbuf *ext_pixbuf_icon; + GtkButton *about_button; gchar *ext_text_info; GList *extensions; int i; - + extensions = caja_extensions_get_list (); - + view = GTK_TREE_VIEW ( gtk_builder_get_object (builder, "extension_view")); store = GTK_LIST_STORE ( @@ -826,6 +873,13 @@ caja_file_management_properties_dialog_setup_extension_page (GtkBuilder *builder if (ext_pixbuf_icon) g_object_unref (ext_pixbuf_icon); } + + about_button = GTK_BUTTON (gtk_builder_get_object (builder, "about_extension_button")); + selection = gtk_tree_view_get_selection (view); + gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE); + g_signal_connect (selection, "changed", + G_CALLBACK (extension_list_selection_changed), + about_button); } static void diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index dbba67dd..05f94460 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -271,6 +271,8 @@ <property name="border_width">5</property> <property name="title" translatable="yes">File Management Preferences</property> <property name="window_position">center</property> + <property name="default_width">600</property> + <property name="default_height">600</property> <property name="type_hint">dialog</property> <child internal-child="vbox"> <object class="GtkVBox" id="dialog-vbox1"> @@ -1522,14 +1524,14 @@ </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">1</property> </packing> </child> </object> <packing> - <property name="expand">False</property> + <property name="expand">True</property> <property name="fill">True</property> <property name="position">0</property> </packing> @@ -2480,7 +2482,7 @@ <property name="spacing">8</property> <property name="layout_style">end</property> <child> - <object class="GtkButton" id="button1"> + <object class="GtkButton" id="about_extension_button"> <property name="label" translatable="yes">_About Extension</property> <property name="visible">True</property> <property name="sensitive">False</property> @@ -2496,7 +2498,7 @@ </packing> </child> <child> - <object class="GtkButton" id="button2"> + <object class="GtkButton" id="configure_extension_button"> <property name="label" translatable="yes">C_onfigure Extension</property> <property name="visible">True</property> <property name="sensitive">False</property> diff --git a/src/caja-history-sidebar.c b/src/caja-history-sidebar.c index 72993d73..c064156f 100644 --- a/src/caja-history-sidebar.c +++ b/src/caja-history-sidebar.c @@ -40,8 +40,6 @@ #include "caja-history-sidebar.h" -#include "glibcompat.h" /* for g_list_free_full */ - #define CAJA_HISTORY_SIDEBAR_CLASS(klass) \ (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_HISTORY_SIDEBAR, CajaHistorySidebarClass)) #define CAJA_IS_HISTORY_SIDEBAR(obj) \ diff --git a/src/caja-image-properties-page.c b/src/caja-image-properties-page.c index 1e5b53e2..a5b5e0b5 100644 --- a/src/caja-image-properties-page.c +++ b/src/caja-image-properties-page.c @@ -38,11 +38,11 @@ #include <libexif/exif-data.h> #include <libexif/exif-ifd.h> #include <libexif/exif-loader.h> -#endif +#endif /*HAVE_EXIF*/ #ifdef HAVE_EXEMPI #include <exempi/xmp.h> #include <exempi/xmpconsts.h> -#endif +#endif /*HAVE_EXEMPI*/ #define LOAD_BUFFER_SIZE 8192 @@ -62,7 +62,7 @@ struct CajaImagePropertiesPageDetails #endif /*HAVE_EXIF*/ #ifdef HAVE_EXEMPI XmpPtr xmp; -#endif +#endif /*HAVE_EXEMPI*/ }; #ifdef HAVE_EXIF @@ -192,9 +192,7 @@ static void exif_content_callback (ExifContent *content, gpointer data) { struct ExifAttribute *attribute; -#ifndef HAVE_OLD_EXIF char b[1024]; -#endif attribute = (struct ExifAttribute *)data; if (attribute->found) @@ -202,11 +200,7 @@ exif_content_callback (ExifContent *content, gpointer data) return; } -#ifdef HAVE_OLD_EXIF - attribute->value = g_strdup (exif_content_get_value (content, attribute->tag)); -#else attribute->value = g_strdup (exif_content_get_value (content, attribute->tag, b, sizeof(b))); -#endif if (attribute->value != NULL) { attribute->found = TRUE; @@ -315,13 +309,9 @@ append_xmp_value_pair (CajaImagePropertiesPage *page, XmpStringPtr value; value = xmp_string_new(); -#ifdef HAVE_EXEMPI_NEW_API + if (xmp_get_property (xmp, ns, propname, value, &options)) { -#else - if (xmp_get_property_and_bits (xmp, ns, propname, value, &options)) - { -#endif if (XMP_IS_PROP_SIMPLE (options)) { append_label_take_str @@ -381,7 +371,7 @@ append_xmpdata_string (XmpPtr xmp, CajaImagePropertiesPage *page) /* TODO add CC licenses */ } } -#endif +#endif /*HAVE EXEMPI*/ static void load_finished (CajaImagePropertiesPage *page) @@ -399,7 +389,7 @@ load_finished (CajaImagePropertiesPage *page) { #ifdef HAVE_EXIF ExifData *exif_data; -#endif +#endif /*HAVE_EXIF*/ format = gdk_pixbuf_loader_get_format (page->details->loader); @@ -431,7 +421,7 @@ load_finished (CajaImagePropertiesPage *page) #endif /*HAVE_EXIF*/ #ifdef HAVE_EXEMPI append_xmpdata_string (page->details->xmp, page); -#endif /*HAVE EXEMPI*/ +#endif /*HAVE_EXEMPI*/ } else { @@ -457,7 +447,7 @@ load_finished (CajaImagePropertiesPage *page) xmp_free(page->details->xmp); page->details->xmp = NULL; } -#endif +#endif /*HAVE_EXEMPI*/ } static void @@ -490,7 +480,7 @@ file_read_callback (GObject *object, count_read); #else exif_still_loading = 0; -#endif +#endif /*HAVE_EXIF*/ if (page->details->pixbuf_still_loading) { diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c index 89891410..19e2b01a 100644 --- a/src/caja-information-panel.c +++ b/src/caja-information-panel.c @@ -49,8 +49,6 @@ #include <libcaja-private/caja-sidebar-provider.h> #include <libcaja-private/caja-module.h> -#include "glibcompat.h" /* for g_list_free_full */ - struct CajaInformationPanelDetails { GtkVBox *container; @@ -102,7 +100,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; /* drag and drop definitions */ diff --git a/src/caja-location-bar.c b/src/caja-location-bar.c index 428f26a1..a2e27653 100644 --- a/src/caja-location-bar.c +++ b/src/caja-location-bar.c @@ -135,6 +135,7 @@ drag_data_received_callback (GtkWidget *widget, if (names == NULL || *names == NULL) { g_warning ("No D&D URI's"); + g_strfreev (names); gtk_drag_finish (context, FALSE, FALSE, time); return; } @@ -172,6 +173,7 @@ drag_data_received_callback (GtkWidget *widget, if (!new_windows_for_extras) { + g_strfreev (names); gtk_drag_finish (context, FALSE, FALSE, time); return; } diff --git a/src/caja-main.c b/src/caja-main.c index 7eee311a..4307e0f3 100644 --- a/src/caja-main.c +++ b/src/caja-main.c @@ -389,10 +389,6 @@ main (int argc, char *argv[]) mallopt (M_MMAP_THRESHOLD, 128 *1024); #endif -#if !GLIB_CHECK_VERSION (2, 32, 0) - g_thread_init (NULL); -#endif - #if !GLIB_CHECK_VERSION (2, 42, 0) /* This will be done by gtk+ later, but for now, force it to MATE */ g_desktop_app_info_set_desktop_env ("MATE"); @@ -469,6 +465,10 @@ main (int argc, char *argv[]) no_default_window = TRUE; no_desktop = FALSE; } + else if (g_strcmp0 (g_getenv ("XDG_CURRENT_DESKTOP"), "MATE") != 0) + { + no_desktop = TRUE; + } if (perform_self_check && remaining != NULL) { diff --git a/src/caja-navigation-bar.c b/src/caja-navigation-bar.c index 89cd0e20..0c766bbd 100644 --- a/src/caja-navigation-bar.c +++ b/src/caja-navigation-bar.c @@ -41,7 +41,7 @@ enum LOCATION_CHANGED, LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static void caja_navigation_bar_class_init (CajaNavigationBarClass *class); static void caja_navigation_bar_init (CajaNavigationBar *bar); diff --git a/src/caja-navigation-window-slot.c b/src/caja-navigation-window-slot.c index 6c4cfbc6..4b3cb461 100644 --- a/src/caja-navigation-window-slot.c +++ b/src/caja-navigation-window-slot.c @@ -31,8 +31,6 @@ #include <libcaja-private/caja-file.h> #include <eel/eel-gtk-macros.h> -#include "glibcompat.h" /* for g_list_free_full */ - static void caja_navigation_window_slot_init (CajaNavigationWindowSlot *slot); static void caja_navigation_window_slot_class_init (CajaNavigationWindowSlotClass *class); diff --git a/src/caja-notebook.c b/src/caja-notebook.c index 6f65ff30..82d9810b 100644 --- a/src/caja-notebook.c +++ b/src/caja-notebook.c @@ -67,7 +67,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; G_DEFINE_TYPE (CajaNotebook, caja_notebook, GTK_TYPE_NOTEBOOK); diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index 1d634db5..0531a992 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -35,8 +35,6 @@ #include "caja-window-private.h" #include "caja-window-slot.h" -#include "glibcompat.h" /* for g_list_free_full */ - #if !GTK_CHECK_VERSION(3,0,0) #define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) #endif diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 06281c6c..55517be2 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -53,8 +53,6 @@ #include "caja-places-sidebar.h" #include "caja-window.h" -#include "glibcompat.h" /* for g_list_free_full and g_clear_object */ - #define EJECT_BUTTON_XPAD 6 #define ICON_CELL_XPAD 6 @@ -1247,7 +1245,7 @@ drag_motion_callback (GtkTreeView *tree_view, { GtkTreePath *path; GtkTreeViewDropPosition pos; - int action; + int action = 0; GtkTreeIter iter; char *uri; gboolean res; @@ -1457,7 +1455,7 @@ reorder_bookmarks (CajaPlacesSidebar *sidebar, /* Get the selected path */ if (!get_selected_iter (sidebar, &iter)) - g_assert_not_reached (); + return; gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, @@ -1522,7 +1520,9 @@ drag_data_received_callback (GtkWidget *widget, } /* Compute position */ - compute_drop_position (tree_view, x, y, &tree_path, &tree_pos, sidebar); + success = compute_drop_position (tree_view, x, y, &tree_path, &tree_pos, sidebar); + if (!success) + goto out; success = FALSE; diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index bb9e4058..d1d75f8d 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -55,8 +55,6 @@ #include <libcaja-private/caja-signaller.h> #include <atk/atkrelationset.h> -#include "glibcompat.h" /* for g_list_free_full */ - /* property types */ typedef enum diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index 34488d8e..45201831 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -34,8 +34,6 @@ #include <gdk/gdkkeysyms.h> #include <gtk/gtk.h> -#include "glibcompat.h" /* for g_list_free_full */ - typedef enum { CAJA_QUERY_EDITOR_ROW_LOCATION, @@ -92,7 +90,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static void caja_query_editor_class_init (CajaQueryEditorClass *class); static void caja_query_editor_init (CajaQueryEditor *editor); diff --git a/src/caja-search-bar.c b/src/caja-search-bar.c index 4ff4ef4b..cd1a473b 100644 --- a/src/caja-search-bar.c +++ b/src/caja-search-bar.c @@ -43,7 +43,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static void caja_search_bar_class_init (CajaSearchBarClass *class); static void caja_search_bar_init (CajaSearchBar *bar); diff --git a/src/caja-side-pane.c b/src/caja-side-pane.c index caea7d8e..d30f4918 100644 --- a/src/caja-side-pane.c +++ b/src/caja-side-pane.c @@ -66,7 +66,7 @@ enum LAST_SIGNAL }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; EEL_CLASS_BOILERPLATE (CajaSidePane, caja_side_pane, GTK_TYPE_VBOX) diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 45525f33..4c655f64 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -62,8 +62,6 @@ #include <libcaja-private/caja-search-engine.h> #include <libcaja-private/caja-signaller.h> -#include "glibcompat.h" /* for g_list_free_full */ - #if !GTK_CHECK_VERSION(3,0,0) #define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) #endif diff --git a/src/caja-trash-bar.c b/src/caja-trash-bar.c index 47cac9df..186c8527 100644 --- a/src/caja-trash-bar.c +++ b/src/caja-trash-bar.c @@ -33,8 +33,6 @@ #include <libcaja-private/caja-file.h> #include <libcaja-private/caja-trash-monitor.h> -#include "glibcompat.h" /* for g_list_free_full */ - #define CAJA_TRASH_BAR_GET_PRIVATE(o)\ (G_TYPE_INSTANCE_GET_PRIVATE ((o), CAJA_TYPE_TRASH_BAR, CajaTrashBarPrivate)) diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index 09d1ac94..e34f7542 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -76,8 +76,6 @@ */ #include "caja-desktop-window.h" -#include "glibcompat.h" /* for g_list_free_full */ - /* This number controls a maximum character count for a URL that is * displayed as part of a dialog. It's fairly arbitrary -- big enough * to allow most "normal" URIs to display in full, but small enough to diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 2fc0d640..4a0d721d 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -43,7 +43,6 @@ #include <gio/gio.h> #include <glib/gi18n.h> #include <eel/eel-gtk-extensions.h> -#include <libmate-desktop/mate-aboutdialog.h> #include <libcaja-extension/caja-menu-provider.h> #include <libcaja-private/caja-extensions.h> #include <libcaja-private/caja-file-utilities.h> @@ -55,6 +54,11 @@ #include <libcaja-private/caja-search-engine.h> #include <libcaja-private/caja-signaller.h> #include <libcaja-private/caja-trash-monitor.h> + +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-aboutdialog.h> +#include <libmate-desktop/mate-desktop-utils.h> + #include <string.h> #define MENU_PATH_EXTENSION_ACTIONS "/MenuBar/File/Extension Actions" @@ -574,40 +578,11 @@ action_caja_manual_callback (GtkAction *action, error = NULL; window = CAJA_WINDOW (user_data); - if (CAJA_IS_DESKTOP_WINDOW (window)) - { -#if GTK_CHECK_VERSION (3, 0, 0) - GdkScreen *screen; - GdkAppLaunchContext *launch_context; - GAppInfo *app_info = NULL; - app_info = g_app_info_create_from_commandline ("mate-help", - NULL, - G_APP_INFO_CREATE_NONE, - &error); - if (error == NULL) - { - screen = gtk_window_get_screen(GTK_WINDOW(window)); - launch_context = gdk_app_launch_context_new (); - gdk_app_launch_context_set_screen (launch_context, screen); - g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), &error); - g_object_unref (launch_context); - } - if (app_info != NULL) - g_object_unref (app_info); -#else -#if GTK_CHECK_VERSION (2, 24, 0) - gdk_spawn_command_line_on_screen(gtk_window_get_screen(GTK_WINDOW(window)), "mate-help", &error); -#else - g_spawn_command_line_async("mate-help", &error); -#endif -#endif - } - else - { - gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)), - "help:mate-user-guide/goscaja-1", - gtk_get_current_event_time (), &error); - } + gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (window)), + CAJA_IS_DESKTOP_WINDOW (window) + ? "help:mate-user-guide" + : "help:mate-user-guide/goscaja-1", + gtk_get_current_event_time (), &error); if (error) { diff --git a/src/caja-window-slot.c b/src/caja-window-slot.c index 0fe2375b..128b52f7 100644 --- a/src/caja-window-slot.c +++ b/src/caja-window-slot.c @@ -33,8 +33,6 @@ #include <eel/eel-gtk-macros.h> #include <eel/eel-string.h> -#include "glibcompat.h" /* for g_list_free_full */ - static void caja_window_slot_init (CajaWindowSlot *slot); static void caja_window_slot_class_init (CajaWindowSlotClass *class); static void caja_window_slot_dispose (GObject *object); diff --git a/src/caja-window.c b/src/caja-window.c index 365c3696..c460ae98 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -65,8 +65,6 @@ #include <math.h> #include <sys/time.h> -#include "glibcompat.h" /* for g_list_free_full */ - #define MAX_HISTORY_ITEMS 50 #define EXTRA_VIEW_WIDGETS_BACKGROUND "#a7c6e1" @@ -168,6 +166,13 @@ caja_window_init (CajaWindow *window) statusbar = gtk_statusbar_new (); gtk_widget_set_name (statusbar, "statusbar-noborder"); + +/* set margin to zero to reduce size of statusbar */ +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_widget_set_margin_top (GTK_WIDGET (statusbar), 0); + gtk_widget_set_margin_bottom (GTK_WIDGET (statusbar), 0); +#endif + window->details->statusbar = statusbar; window->details->help_message_cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "help_message"); diff --git a/src/caja-zoom-control.c b/src/caja-zoom-control.c index 1b251da2..2fe7b5a5 100644 --- a/src/caja-zoom-control.c +++ b/src/caja-zoom-control.c @@ -76,7 +76,7 @@ struct CajaZoomControlDetails }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static gpointer accessible_parent_class; diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 06fdc930..7f02efb5 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -600,6 +600,8 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) g_signal_connect_object (desktop_icon_view, "unrealize", G_CALLBACK (unrealized_callback), desktop_icon_view, 0); + default_zoom_level_changed (desktop_icon_view); + g_signal_connect_swapped (caja_icon_view_preferences, "changed::" CAJA_PREFERENCES_ICON_VIEW_DEFAULT_ZOOM_LEVEL, G_CALLBACK (default_zoom_level_changed), @@ -610,7 +612,6 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) G_CALLBACK (font_changed_callback), desktop_icon_view); - default_zoom_level_changed (desktop_icon_view); fm_desktop_icon_view_update_icon_container_fonts (desktop_icon_view); g_signal_connect_swapped (mate_lockdown_preferences, diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index eadb3750..ebf80eb3 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -83,7 +83,8 @@ #include <libcaja-private/caja-icon-names.h> #include <libcaja-private/caja-undostack-manager.h> -#include <src/glibcompat.h> /* for g_list_free_full */ +#define MATE_DESKTOP_USE_UNSTABLE_API +#include <libmate-desktop/mate-desktop-utils.h> /* Minimum starting update inverval */ #define UPDATE_INTERVAL_MIN 100 @@ -150,7 +151,7 @@ enum }; -static guint signals[LAST_SIGNAL]; +static guint signals[LAST_SIGNAL] = { 0 }; static GdkAtom copied_files_atom; @@ -2326,14 +2327,10 @@ fm_directory_view_display_selection_info (FMDirectoryView *view) if (non_folder_size_known) { char *size_string; - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS); - else - size_string = g_format_size(non_folder_size); - #else - size_string = g_format_size_for_display(non_folder_size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + size_string = g_format_size_full (non_folder_size, G_FORMAT_SIZE_IEC_UNITS); + else + size_string = g_format_size(non_folder_size); /* This is marked for translation in case a localiser * needs to use something other than parentheses. The @@ -10195,23 +10192,8 @@ fm_directory_view_move_copy_items (const GList *item_uris, if (screen == NULL) { screen = gdk_screen_get_default (); } -#if GTK_CHECK_VERSION (3, 0, 0) - GdkAppLaunchContext *launch_context; - GAppInfo *app_info = NULL; - app_info = g_app_info_create_from_commandline (command, - NULL, - G_APP_INFO_CREATE_NONE, - NULL); - if (app_info != NULL) { - launch_context = gdk_app_launch_context_new (); - gdk_app_launch_context_set_screen (launch_context, screen); - g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (launch_context), NULL); - g_object_unref (launch_context); - g_object_unref (app_info); - } -#else - gdk_spawn_command_line_on_screen (screen, command, NULL); -#endif + + mate_gdk_spawn_command_line_on_screen(screen, command, NULL); g_free (command); return; @@ -10519,6 +10501,7 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view, handle_netscape_url_drop_ask_cb, data); + g_strfreev (bits); g_free (container_uri); return; } @@ -10534,6 +10517,7 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view, eel_show_warning_dialog (_("Drag and drop is not supported."), _("An invalid drag type was used."), fm_directory_view_get_containing_window (view)); + g_strfreev (bits); g_free (container_uri); return; } @@ -10592,7 +10576,6 @@ fm_directory_view_handle_netscape_url_drop (FMDirectoryView *view, } g_strfreev (bits); - g_free (container_uri); } diff --git a/src/file-manager/fm-ditem-page.c b/src/file-manager/fm-ditem-page.c index 52958feb..0acec773 100644 --- a/src/file-manager/fm-ditem-page.c +++ b/src/file-manager/fm-ditem-page.c @@ -218,6 +218,7 @@ fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *contex } file = caja_file_get_by_uri (uris[0]); + g_strfreev (uris); g_return_if_fail (file != NULL); @@ -248,8 +249,6 @@ fm_ditem_page_exec_drag_data_received (GtkWidget *widget, GdkDragContext *contex g_free (uri); caja_file_unref (file); - - g_strfreev (uris); } static void diff --git a/src/file-manager/fm-icon-container.c b/src/file-manager/fm-icon-container.c index 0ecc0180..08b87529 100644 --- a/src/file-manager/fm-icon-container.c +++ b/src/file-manager/fm-icon-container.c @@ -595,6 +595,10 @@ fm_icon_container_class_init (FMIconContainerClass *klass) static void fm_icon_container_init (FMIconContainer *icon_container) { +#if GTK_CHECK_VERSION (3, 0, 0) + gtk_style_context_add_class (gtk_widget_get_style_context (GTK_WIDGET (icon_container)), + GTK_STYLE_CLASS_VIEW); +#endif } CajaIconContainer * diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index 6ab19c4e..3d29bead 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -2146,7 +2146,13 @@ get_preview_argv (char *uri) return argv; } - command = g_find_program_in_path ("gst-launch-0.10"); + command = g_find_program_in_path ("gst-launch-1.0"); + + if (!command) + { + command = g_find_program_in_path ("gst-launch-0.10"); + } + if (command) { argv = g_new (char *, 10); @@ -2155,7 +2161,7 @@ get_preview_argv (char *uri) argv[i++] = g_strdup ("playbin"); argv[i++] = g_strconcat ("uri=", uri, NULL); /* do not display videos */ - argv[i++] = g_strdup ("current-video=-1"); + argv[i++] = g_strdup ("video-sink=fakesink"); argv[i++] = NULL; return argv; } diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c index 1be811f4..6a1692f4 100644 --- a/src/file-manager/fm-list-model.c +++ b/src/file-manager/fm-list-model.c @@ -35,8 +35,6 @@ #include <libcaja-private/caja-dnd.h> #include <glib.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - enum { SUBDIRECTORY_UNLOADED, diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index c92e0c12..626c3836 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -61,8 +61,6 @@ #include <libcaja-private/caja-clipboard.h> #include <libcaja-private/caja-cell-renderer-text-ellipsized.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - struct FMListViewDetails { GtkTreeView *tree_view; diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index ddec36b9..ba305015 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -68,8 +68,6 @@ #include <sys/mount.h> #endif -#include <src/glibcompat.h> /* for g_list_free_full */ - #define USED_FILL_R (0.988235294 * 65535) #define USED_FILL_G (0.91372549 * 65535) #define USED_FILL_B (0.309803922 * 65535) @@ -2321,14 +2319,10 @@ directory_contents_value_field_update (FMPropertiesWindow *window) } else { char *size_str; - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) - size_str = g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS); - else - size_str = g_format_size(total_size); - #else - size_str = g_format_size_for_display(total_size); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) + size_str = g_format_size_full (total_size, G_FORMAT_SIZE_IEC_UNITS); + else + size_str = g_format_size(total_size); text = g_strdup_printf (ngettext("%'d item, with size %s", "%'d items, totalling %s", @@ -3147,22 +3141,16 @@ create_pie_widget (FMPropertiesWindow *window) GFile *location; GFileInfo *info; - #if GLIB_CHECK_VERSION(2, 30, 0) - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) { - capacity = g_format_size_full(window->details->volume_capacity, G_FORMAT_SIZE_IEC_UNITS); - free = g_format_size_full(window->details->volume_free, G_FORMAT_SIZE_IEC_UNITS); - used = g_format_size_full(window->details->volume_capacity - window->details->volume_free, G_FORMAT_SIZE_IEC_UNITS); - } - else { - capacity = g_format_size(window->details->volume_capacity); - free = g_format_size(window->details->volume_free); - used = g_format_size(window->details->volume_capacity - window->details->volume_free); - } - #else - capacity = g_format_size_for_display(window->details->volume_capacity); - free = g_format_size_for_display(window->details->volume_free); - used = g_format_size_for_display(window->details->volume_capacity - window->details->volume_free); - #endif + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_USE_IEC_UNITS)) { + capacity = g_format_size_full(window->details->volume_capacity, G_FORMAT_SIZE_IEC_UNITS); + free = g_format_size_full(window->details->volume_free, G_FORMAT_SIZE_IEC_UNITS); + used = g_format_size_full(window->details->volume_capacity - window->details->volume_free, G_FORMAT_SIZE_IEC_UNITS); + } + else { + capacity = g_format_size(window->details->volume_capacity); + free = g_format_size(window->details->volume_free); + used = g_format_size(window->details->volume_capacity - window->details->volume_free); + } file = get_original_file (window); @@ -3209,7 +3197,9 @@ create_pie_widget (FMPropertiesWindow *window) if (info) { fs_type = g_file_info_get_attribute_string (info, G_FILE_ATTRIBUTE_FILESYSTEM_TYPE); if (fs_type != NULL) { - gtk_label_set_text (GTK_LABEL (fstype_label), g_strconcat (_("Filesystem type:"), " ", fs_type, NULL)); + gchar *fstype_text = g_strconcat (_("Filesystem type:"), " ", fs_type, NULL); + gtk_label_set_text (GTK_LABEL (fstype_label), fstype_text); + g_free (fstype_text); } g_object_unref (info); diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index 604c660e..504dd89a 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -37,8 +37,6 @@ #include <gtk/gtk.h> #include <string.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - enum { ROW_LOADED, diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index ab2f1593..f86a0634 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -55,8 +55,6 @@ #include <libcaja-private/caja-window-info.h> #include <libcaja-private/caja-window-slot-info.h> -#include <src/glibcompat.h> /* for g_list_free_full */ - typedef struct { GObject parent; diff --git a/src/glibcompat.h b/src/glibcompat.h deleted file mode 100644 index 4c71b2b5..00000000 --- a/src/glibcompat.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ - -/* - * glibcompat.h - GLib version-dependent definitions - * - * Copyright (C) 2012 MATE Desktop Project - * - * Caja is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * Caja is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public - * License along with this program; if not, write to the Free - * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. - * - * Authors: Jasmine Hassan <[email protected]> - * - */ - -#ifndef GLIB_COMPAT_H -#define GLIB_COMPAT_H - -#include <glib.h> -#include <glib-object.h> - -#if !GLIB_CHECK_VERSION (2, 27, 2) -static inline void -g_list_free_full (GList *list, GDestroyNotify free_func) -{ - g_list_foreach (list, (GFunc) free_func, NULL); - g_list_free (list); -} -#endif - -#if !GLIB_CHECK_VERSION(2,28,0) -static inline void -g_clear_object_inline(volatile GObject **object_ptr) -{ - gpointer * const ptr = (gpointer)object_ptr; - gpointer old; - - do { - old = g_atomic_pointer_get(ptr); - } while G_UNLIKELY(!g_atomic_pointer_compare_and_exchange(ptr, old, NULL)); - - if (old) - g_object_unref(old); -} -#undef g_clear_object -#define g_clear_object(obj) g_clear_object_inline((volatile GObject **)(obj)) -#endif - -#endif /* GLIB_COMPAT_H */ |