diff options
author | rbuj <[email protected]> | 2020-03-16 11:30:32 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2020-03-27 14:51:02 +0100 |
commit | 0820c6f9a271eb2cbf007d92354ed89f4bc248e5 (patch) | |
tree | c77694ee5e825f3998e65b31a90de79f82080a30 | |
parent | 64b4722006f4b998454ab936557ce85b6d9b130b (diff) | |
download | mate-control-center-0820c6f9a271eb2cbf007d92354ed89f4bc248e5.tar.bz2 mate-control-center-0820c6f9a271eb2cbf007d92354ed89f4bc248e5.tar.xz |
Port libslab_handle_g_error to the built-in GLib logging framework
-rw-r--r-- | libslab/Makefile.am | 1 | ||||
-rw-r--r-- | libslab/bookmark-agent.c | 58 | ||||
-rw-r--r-- | libslab/libslab-utils.c | 26 | ||||
-rw-r--r-- | libslab/libslab-utils.h | 1 |
4 files changed, 32 insertions, 54 deletions
diff --git a/libslab/Makefile.am b/libslab/Makefile.am index 97deea54..df720566 100644 --- a/libslab/Makefile.am +++ b/libslab/Makefile.am @@ -2,6 +2,7 @@ pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = mate-slab.pc AM_CPPFLAGS = \ + -DG_LOG_DOMAIN=\"libslab\" \ -I$(top_srcdir) \ $(LIBSLAB_CFLAGS) \ $(WARN_CFLAGS) diff --git a/libslab/bookmark-agent.c b/libslab/bookmark-agent.c index fac010e1..478fd54a 100644 --- a/libslab/bookmark-agent.c +++ b/libslab/bookmark-agent.c @@ -208,13 +208,12 @@ bookmark_agent_move_item (BookmarkAgent *this, const gchar *uri, const gchar *ur if (! TYPE_IS_RECENT (priv->type)) return; - gtk_recent_manager_move_item ( - gtk_recent_manager_get_default (), uri, uri_new, & error); - - if (error) - libslab_handle_g_error ( - & error, "%s: unable to update %s with renamed file, [%s] -> [%s].", - G_STRFUNC, priv->store_path, uri, uri_new); + gtk_recent_manager_move_item (gtk_recent_manager_get_default (), uri, uri_new, &error); + if (error) { + g_warning ("Unable to update %s with renamed file, [%s] -> [%s]: %s", + priv->store_path, uri, uri_new, error->message); + g_error_free (error); + } } void @@ -232,12 +231,12 @@ bookmark_agent_purge_items (BookmarkAgent *this) uris = g_bookmark_file_get_uris (priv->store, &uris_len); if (TYPE_IS_RECENT (priv->type)) { for (i = 0; i < uris_len; i++) { - gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], & error); - - if (error) - libslab_handle_g_error ( - & error, "%s: unable to remove [%s] from %s.", - G_STRFUNC, priv->store_path, uris [i]); + gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uris [i], &error); + if (error) { + g_warning ("Unable to remove [%s] from %s: %s", + priv->store_path, uris [i], error->message); + g_error_free (error); + } } } else { for (i = 0; i < uris_len; i++) { @@ -267,13 +266,11 @@ bookmark_agent_remove_item (BookmarkAgent *this, const gchar *uri) return; if (TYPE_IS_RECENT (priv->type)) { - gtk_recent_manager_remove_item ( - gtk_recent_manager_get_default (), uri, & error); - - if (error) - libslab_handle_g_error ( - & error, "%s: unable to remove [%s] from %s.", - G_STRFUNC, priv->store_path, uri); + gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, &error); + if (error) { + g_warning ("Unable to remove [%s] from %s: %s", priv->store_path, uri, error->message); + g_error_free (error); + } } else { rank = get_rank (this, uri); @@ -847,10 +844,12 @@ load_xbel_store (BookmarkAgent *this) g_bookmark_file_free (priv->store); priv->store = g_bookmark_file_new (); - libslab_handle_g_error ( - & error, "%s: couldn't load bookmark file [%s]\n", - G_STRFUNC, priv->store_path ? priv->store_path : "NULL"); - + if (error) { + g_debug ("Couldn't load bookmark file [%s]: %s", priv->store_path, error->message); + g_error_free (error); + } else { + g_debug ("Couldn't load bookmark file [NULL]"); + } return; } @@ -1032,10 +1031,15 @@ save_xbel_store (BookmarkAgent *this) GError *error = NULL; + if (g_bookmark_file_to_file (priv->store, priv->store_path, &error)) + return; - if (! g_bookmark_file_to_file (priv->store, priv->store_path, & error)) - libslab_handle_g_error ( - & error, "%s: couldn't save bookmark file [%s]\n", G_STRFUNC, priv->store_path); + if (error) { + g_warning ("Couldn't save bookmark file [%s]: %s", priv->store_path, error->message); + g_error_free (error); + } else { + g_warning ("Couldn't save bookmark file [%s]", priv->store_path); + } } static void diff --git a/libslab/libslab-utils.c b/libslab/libslab-utils.c index fc380719..f94ad39e 100644 --- a/libslab/libslab-utils.c +++ b/libslab/libslab-utils.c @@ -117,29 +117,3 @@ libslab_strcmp (const gchar *a, const gchar *b) return strcmp (a, b); } - -void -libslab_handle_g_error (GError **error, const gchar *msg_format, ...) -{ - gchar *msg; - va_list args; - - - va_start (args, msg_format); - msg = g_strdup_vprintf (msg_format, args); - va_end (args); - - if (*error) { - g_log ( - G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, - "\nGError raised: [%s]\nuser_message: [%s]\n", (*error)->message, msg); - - g_error_free (*error); - - *error = NULL; - } - else - g_log (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, "\nerror raised: [%s]\n", msg); - - g_free (msg); -} diff --git a/libslab/libslab-utils.h b/libslab/libslab-utils.h index ce2138ec..bfac3bdb 100644 --- a/libslab/libslab-utils.h +++ b/libslab/libslab-utils.h @@ -12,7 +12,6 @@ extern "C" { MateDesktopItem *libslab_mate_desktop_item_new_from_unknown_id (const gchar *id); guint32 libslab_get_current_time_millis (void); gint libslab_strcmp (const gchar *a, const gchar *b); -void libslab_handle_g_error (GError **error, const gchar *msg_format, ...); GdkScreen *libslab_get_current_screen (void); |