Skip to content

Commit 5423134

Browse files
okaestnemtwebster
authored andcommitted
port from libnotify to GNotification
1 parent a731c11 commit 5423134

5 files changed

Lines changed: 54 additions & 54 deletions

File tree

src/nemo-application.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@
7575
#include <eel/eel-gtk-extensions.h>
7676
#include <eel/eel-stock-dialogs.h>
7777
#include <eel/eel-string.h>
78-
#include <libnotify/notify.h>
7978
#include <libxapp/xapp-favorites.h>
8079

8180
#define GNOME_DESKTOP_USE_UNSTABLE_API
@@ -552,7 +551,6 @@ nemo_application_startup (GApplication *app)
552551
init_menu_provider_callback ();
553552

554553
/* Initialize the UI handler singleton for file operations */
555-
notify_init (GETTEXT_PACKAGE);
556554
self->priv->progress_handler = nemo_progress_ui_handler_new ();
557555

558556
self->priv->cache_problem = FALSE;

src/nemo-desktop-application.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@
6262
#include <stdlib.h>
6363
#include <glib/gstdio.h>
6464
#include <glib/gi18n.h>
65-
#include <libnotify/notify.h>
6665
#include <gdk/gdkx.h>
6766
#include <X11/Xatom.h>
6867

src/nemo-main-application.c

Lines changed: 48 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@
7373
#include <gio/gio.h>
7474
#include <eel/eel-gtk-extensions.h>
7575
#include <eel/eel-stock-dialogs.h>
76-
#include <libnotify/notify.h>
7776

7877
#define GNOME_DESKTOP_USE_UNSTABLE_API
7978

@@ -90,6 +89,10 @@
9089
/* Disable the self-check functionality */
9190
#define NEMO_OMIT_SELF_CHECK "omit"
9291

92+
#define NEMO_NOTIFICATION_UNMOUNT_ICON_NAME "media-removable"
93+
#define NEMO_NOTIFICATION_UNMOUNT_ID_PENDING "unmount-pending"
94+
#define NEMO_NOTIFICATION_UNMOUNT_ID_DONE "unmount-done"
95+
9396
static void mount_removed_callback (GVolumeMonitor *monitor,
9497
GMount *mount,
9598
NemoMainApplication *application);
@@ -106,61 +109,67 @@ struct _NemoMainApplicationPriv {
106109
NemoFreedesktopDBus *fdb_manager;
107110

108111
gchar *geometry;
109-
110-
NotifyNotification *unmount_notify;
111112
};
112113

113114
static void
114-
nemo_main_application_notify_unmount_done (NemoApplication *application,
115-
const gchar *message)
115+
nemo_main_application_send_notification (NemoApplication *application,
116+
const gchar *title,
117+
const gchar *body,
118+
const gchar *icon_name,
119+
const gchar *notification_id,
120+
const GNotificationPriority prio)
116121
{
117-
NemoMainApplication *app = NEMO_MAIN_APPLICATION (application);
122+
NemoMainApplication *app = NEMO_MAIN_APPLICATION (application);
123+
GNotification *notification;
124+
GIcon *icon;
118125

119-
if (app->priv->unmount_notify) {
120-
notify_notification_close (app->priv->unmount_notify, NULL);
121-
g_clear_object (&app->priv->unmount_notify);
122-
}
126+
icon = g_themed_icon_new (icon_name);
127+
notification = g_notification_new (title);
128+
g_notification_set_body (notification, body);
129+
g_notification_set_icon (notification, icon);
130+
g_notification_set_priority (notification, prio);
123131

124-
if (message != NULL) {
125-
NotifyNotification *unplug;
126-
gchar **strings;
132+
g_application_send_notification (G_APPLICATION (app), notification_id, notification);
127133

128-
strings = g_strsplit (message, "\n", 0);
129-
unplug = notify_notification_new (strings[0], strings[1],
130-
"media-removable");
131-
132-
notify_notification_show (unplug, NULL);
133-
g_object_unref (unplug);
134-
g_strfreev (strings);
135-
}
134+
g_object_unref (notification);
135+
g_object_unref (icon);
136136
}
137137

138138
static void
139-
nemo_main_application_notify_unmount_show (NemoApplication *application,
139+
nemo_main_application_notify_unmount_done (NemoApplication *application,
140140
const gchar *message)
141141
{
142-
NemoMainApplication *app = NEMO_MAIN_APPLICATION (application);
142+
NemoMainApplication *app = NEMO_MAIN_APPLICATION (application);
143+
gchar **strings;
143144

144-
gchar **strings;
145+
// remove notification for pending unmount state
146+
g_application_withdraw_notification (G_APPLICATION (app), NEMO_NOTIFICATION_UNMOUNT_ID_PENDING);
145147

146-
strings = g_strsplit (message, "\n", 0);
148+
g_return_if_fail (message != NULL);
149+
strings = g_strsplit (message, "\n", 2);
147150

148-
if (!app->priv->unmount_notify) {
149-
app->priv->unmount_notify = notify_notification_new (strings[0], strings[1],
150-
"media-removable");
151+
nemo_main_application_send_notification (application, strings[0], strings[1],
152+
NEMO_NOTIFICATION_UNMOUNT_ICON_NAME,
153+
NEMO_NOTIFICATION_UNMOUNT_ID_DONE,
154+
G_NOTIFICATION_PRIORITY_NORMAL);
155+
156+
g_strfreev (strings);
157+
}
151158

152-
notify_notification_set_hint (app->priv->unmount_notify,
153-
"transient", g_variant_new_boolean (TRUE));
154-
notify_notification_set_urgency (app->priv->unmount_notify,
155-
NOTIFY_URGENCY_CRITICAL);
156-
} else {
157-
notify_notification_update (app->priv->unmount_notify,
158-
strings[0], strings[1],
159-
"media-removable");
160-
}
159+
static void
160+
nemo_main_application_notify_unmount_show (NemoApplication *application,
161+
const gchar *message)
162+
{
163+
gchar **strings;
164+
165+
g_return_if_fail (message != NULL);
166+
strings = g_strsplit (message, "\n", 2);
161167

162-
notify_notification_show (app->priv->unmount_notify, NULL);
163-
g_strfreev (strings);
168+
nemo_main_application_send_notification (application, strings[0], strings[1],
169+
NEMO_NOTIFICATION_UNMOUNT_ICON_NAME,
170+
NEMO_NOTIFICATION_UNMOUNT_ID_PENDING,
171+
G_NOTIFICATION_PRIORITY_URGENT);
172+
g_strfreev (strings);
164173
}
165174

166175
static void

src/nemo-places-sidebar.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@
6161
#include "nemo-window.h"
6262
#include "nemo-window-slot.h"
6363

64-
#include <libnotify/notify.h>
65-
6664
#define DEBUG_FLAG NEMO_DEBUG_PLACES
6765
#include <libnemo-private/nemo-debug.h>
6866

@@ -130,8 +128,6 @@ typedef struct {
130128
NemoWindowSlot *go_to_after_mount_slot;
131129
NemoWindowOpenFlags go_to_after_mount_flags;
132130

133-
NotifyNotification *unmount_notify;
134-
135131
guint bookmarks_changed_id;
136132

137133
gboolean my_computer_expanded;
@@ -4413,7 +4409,6 @@ nemo_places_sidebar_dispose (GObject *object)
44134409
sidebar->uri = NULL;
44144410

44154411
free_drag_data (sidebar);
4416-
g_clear_object (&sidebar->unmount_notify);
44174412

44184413
if (sidebar->bookmarks_changed_id != 0) {
44194414
g_signal_handler_disconnect (sidebar->bookmarks,

src/nemo-progress-ui-handler.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@
3131
#include "nemo-application.h"
3232
#include "nemo-progress-info-widget.h"
3333

34+
#include <gio/gio.h>
3435
#include <glib/gi18n.h>
3536

3637
#include <eel/eel-string.h>
3738

3839
#include <libnemo-private/nemo-progress-info.h>
3940
#include <libnemo-private/nemo-progress-info-manager.h>
4041

41-
#include <libnotify/notify.h>
4242
#include <libxapp/xapp-gtk-window.h>
4343
#include <libxapp/xapp-status-icon.h>
4444

@@ -262,13 +262,12 @@ progress_ui_handler_add_to_window (NemoProgressUIHandler *self,
262262
static void
263263
progress_ui_handler_show_complete_notification (NemoProgressUIHandler *self)
264264
{
265-
NotifyNotification *complete_notification;
266-
267-
complete_notification = notify_notification_new (_("File Operations"),
268-
_("All file operations have been successfully completed"),
269-
NULL);
270-
notify_notification_show (complete_notification, NULL);
265+
GNotification *complete_notification;
271266

267+
complete_notification = g_notification_new (_("File Operations"));
268+
g_notification_set_body (complete_notification, _("All file operations have been successfully completed"));
269+
270+
g_application_send_notification (G_APPLICATION (nemo_application_get_singleton ()), NULL, complete_notification);
272271
g_object_unref (complete_notification);
273272
}
274273

0 commit comments

Comments
 (0)