Skip to content
Snippets Groups Projects
Commit 697e188d authored by Alexander Schwinn's avatar Alexander Schwinn
Browse files

Regression: Fix build with notifications disabled (Issue #909)

- Regression introduced by d77eee4d
(Issue #903)
parent 3aa0e839
No related branches found
No related tags found
No related merge requests found
Pipeline #17758 passed
......@@ -38,7 +38,14 @@
#ifdef HAVE_LIBNOTIFY
static gboolean thunar_notify_initted = FALSE;
static void thunar_notify_undo_or_redo (ThunarJobOperation *operation, gboolean undo);
static gboolean thunar_notify_init (void);
static gchar* thunar_get_device_icon (ThunarDevice *device);
static void thunar_notify_show (ThunarDevice *device,
const gchar *summary,
const gchar *message);
static gboolean thunar_notify_device_readonly (ThunarDevice *device);
static void thunar_notify_undo_or_redo (ThunarJobOperation *operation,
gboolean undo);
......@@ -160,8 +167,58 @@ thunar_notify_device_readonly (ThunarDevice *device)
return readonly;
}
static void
thunar_notify_undo_or_redo (ThunarJobOperation *operation,
gboolean undo)
{
NotifyNotification *notification;
gchar *summary;
gchar *message;
gchar *icon_name;
if (!thunar_notify_init ())
return;
/* prepare the notification args according to whether it's an undo operation
* or not, in which case it must be a redo operation */
if (undo)
{
summary = g_strdup (_("Undo performed"));
message = g_strdup_printf (_("%s operation was undone"), thunar_job_operation_get_kind_nick (operation));
icon_name = g_strdup ("edit-undo-symbolic");
}
else
{
summary = g_strdup (_("Redo performed"));
message = g_strdup_printf (_("%s operation was redone"), thunar_job_operation_get_kind_nick (operation));
icon_name = g_strdup ("edit-redo-symbolic");
}
/* create notification */
#ifdef NOTIFY_CHECK_VERSION
#if NOTIFY_CHECK_VERSION (0, 7, 0)
notification = notify_notification_new (summary, message, icon_name);
#else
notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
#else
notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
notify_notification_show (notification, NULL);
g_free (summary);
g_free (message);
g_free (icon_name);
}
#endif /* HAVE_LIBNOTIFY */
void
......@@ -307,66 +364,18 @@ thunar_notify_finish (ThunarDevice *device)
void
thunar_notify_undo (ThunarJobOperation *operation)
{
if (!thunar_notify_init ())
return;
#ifdef HAVE_LIBNOTIFY
thunar_notify_undo_or_redo (operation, TRUE);
#endif
}
void
thunar_notify_redo (ThunarJobOperation *operation)
{
thunar_notify_undo_or_redo (operation, FALSE);
}
static void
thunar_notify_undo_or_redo (ThunarJobOperation *operation,
gboolean undo)
{
#ifdef HAVE_LIBNOTIFY
NotifyNotification *notification;
gchar *summary;
gchar *message;
gchar *icon_name;
/* prepare the notification args according to whether it's an undo operation
* or not, in which case it must be a redo operation */
if (undo)
{
summary = g_strdup (_("Undo performed"));
message = g_strdup_printf (_("%s operation was undone"), thunar_job_operation_get_kind_nick (operation));
icon_name = g_strdup ("edit-undo-symbolic");
}
else
{
summary = g_strdup (_("Redo performed"));
message = g_strdup_printf (_("%s operation was redone"), thunar_job_operation_get_kind_nick (operation));
icon_name = g_strdup ("edit-redo-symbolic");
}
/* create notification */
#ifdef NOTIFY_CHECK_VERSION
#if NOTIFY_CHECK_VERSION (0, 7, 0)
notification = notify_notification_new (summary, message, icon_name);
#else
notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
#else
notification = notify_notification_new (summary, message, icon_name, NULL);
#endif
notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
notify_notification_show (notification, NULL);
g_free (summary);
g_free (message);
g_free (icon_name);
thunar_notify_undo_or_redo (operation, FALSE);
#endif
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment