After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 519060 - Add notifications on file reception
Add notifications on file reception
Status: RESOLVED FIXED
Product: gnome-user-share
Classification: Core
Component: bluetooth
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-user-share maintainers
gnome-user-share maintainers
: 538995 (view as bug list)
Depends on:
Blocks:
 
 
Reported: 2008-02-27 14:18 UTC by Bastien Nocera
Modified: 2008-06-18 18:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
a rough patch to display notification (3.71 KB, patch)
2008-05-20 20:11 UTC, Baptiste Mille-Mathias
needs-work Details | Review
Rough patch, take 2 (4.38 KB, patch)
2008-05-21 21:56 UTC, Baptiste Mille-Mathias
none Details | Review
Patch #3 (5.05 KB, patch)
2008-05-24 18:10 UTC, Baptiste Mille-Mathias
needs-work Details | Review
Patch version 4 (5.42 KB, patch)
2008-05-24 22:24 UTC, Baptiste Mille-Mathias
none Details | Review

Description Bastien Nocera 2008-02-27 14:18:22 UTC
See transfer_completed_cb(). The status icon shouldn't disappear while there's transfers going on, or while the notification is visible.
Comment 1 Bastien Nocera 2008-02-27 15:47:49 UTC
Note that the UI bits are already implemented, just remove the line saying:
gtk_widget_hide (notify_received_obexpush_check);

in file-share-properties.c
Comment 2 Baptiste Mille-Mathias 2008-05-20 20:11:54 UTC
Created attachment 111257 [details] [review]
a rough patch to display notification

This is a Work-in-Progress, I don't understand why the function hide_statusicon is not called when I close the notification message.
Comment 3 Bastien Nocera 2008-05-21 12:16:36 UTC
Comment on attachment 111257 [details] [review]
a rough patch to display notification

<snip>
>Index: src/obexpush.c
>===================================================================
>--- src/obexpush.c	(révision 244)
>+++ src/obexpush.c	(copie de travail)
<snip>
>@@ -44,10 +47,40 @@
> static GtkStatusIcon *statusicon = NULL;
> 
> static void
>+hide_statusicon (void)
>+{
>+	gtk_status_icon_set_visible (statusicon, FALSE);
>+}
>+
>+static void
>+show_notification (void)
>+{
>+	NotifyNotification *notification;
>+
>+	if (!notify_init("gnome-user-share-obexpush")) {
>+		g_warning("Unable to initialize the notification system\n");
>+	}

You should run the notify_init() in obexpush_init().

>+	notification = notify_notification_new_with_status_icon ("You received a file",
>+						      "You received file \"%s\" from Bluetooh",

That's not translated, and the file won't be replaced either.

>+						      "dialog-information",
>+						      GTK_STATUS_ICON (statusicon));
>+	notify_notification_set_timeout (notification, 30000);

Use NOTIFY_EXPIRES_DEFAULT as the default.

> 	if (statusicon == NULL) {
>-		statusicon = gtk_status_icon_new_from_icon_name ("gnome-obex-server");
>+		statusicon = gtk_status_icon_new_from_icon_name ("package");

It should be an icon that we'd provide. just add a FIXME here as well.

You should probably add some actions on the notification as well, to either "reveal" the file (open the directory that's got the file), and open the file with the default handler.
Comment 4 Bastien Nocera 2008-05-21 12:20:29 UTC
About the notification icon icon not disappearing, is hide_statusicon() called at all? How do you close the notification popup (clicking on it, or using the close icon?).
Comment 5 Baptiste Mille-Mathias 2008-05-21 17:02:05 UTC
Okay I'll do that all the changes,
For all the i18n things, it was not really ready to consumation, I need to
> 
> You should probably add some actions on the notification as well, to either
> "reveal" the file (open the directory that's got the file), and open the file
> with the default handler.
> 
It's was on my Todo list but I wanted to focus on the basic functionality :)

For the notification, hide_statusicon is just used in NOTIFY_ACTION_CALLBACK
About icon issue, I tried both closing the widget with the button and clicking on it.
Comment 6 Baptiste Mille-Mathias 2008-05-21 21:56:47 UTC
Created attachment 111303 [details] [review]
Rough patch, take 2

It is not really working totally, specially for launching the file viewer.
there is an hard-coded call to /usr/bin/xdg-open, and passing the filename doesn't work. I try to fix that tomorrow.

I solved my notification problem thanks to Nickolay V. Shmyrev (mix of libnotify system and from jhbuild).
Comment 7 Baptiste Mille-Mathias 2008-05-24 18:10:00 UTC
Created attachment 111472 [details] [review]
Patch #3

It is working fine now.
you can open the file received from the notification, using xdg-open.
I've just a problem, I'm leaking the notification, but I don't have an idea where can I unref it.
Comment 8 Bastien Nocera 2008-05-24 18:18:13 UTC
Don't use xdg-open, it's junk :)
Look at totem_embedded_launch_player() in that patch:
http://svn.gnome.org/viewvc/totem/trunk/browser-plugin/totem-plugin-viewer.c?r1=5399&r2=5421

You'll just create a GdkAppLaunchContext, if running with a newer GTK+, and call:
g_app_info_launch_default_for_uri(); with it, and your URI.

Like 5 lines of code, and you'll get a startup notification for free with the new GTK+.


About the notification, you can unref it when clicked, or closed (ie. at the end of display_file, and in hide_statusicon(), just make sure you pass it as the user_data).
Comment 9 Baptiste Mille-Mathias 2008-05-24 22:24:55 UTC
Created attachment 111484 [details] [review]
Patch version 4

Patch updated
Comment 10 Baptiste Mille-Mathias 2008-05-24 22:38:00 UTC
by the way, I didn't find gdk_app_launch_context_set_screen and gdk_app_launch_context_set_timestamp in my svn check out of GTK+ (configure says 2.13.1), so that's why I set GTK_CHECK_VERSION(2,13,2) and of course I didn't tested this code.

cheers
Comment 11 Bastien Nocera 2008-05-25 17:20:47 UTC
Committed with a couple of changes:
- no need to use GIO just to get a URI, use g_filename_to_uri instead (you were leaking the GFile anyway :)
- Also we use g_filename_display_basename() to get a string to display in the notification popup
- You were leaking the GConfClient
- Use "gnome-obex-server" for the notification icon, as we install that icon in data/icons
- hide the status icon when we've finished a transfer and we're not displaying notifications
- add a gio-2.0 dep in the configure.in

I also added a "num_notifications", so that we'd only hide the status icon when there's no more uses for it (no transfer, no popups).

Note that we're still missing an option to reveal the file in nautilus. Could you please file a new bug and make it depend on http://bugzilla.gnome.org/show_bug.cgi?id=498506 ?

2008-05-25  Bastien Nocera  <hadess@hadess.net>

	* configure.in:
	* src/file-share-properties.c (main):
	* src/obexpush.c (hide_statusicon), (on_close_notification),
	(launch_viewer_for_file), (show_notification), (show_icon),
	(transfer_completed_cb), (obexpush_init), (obexpush_set_notify):
	Implement notifications when transfers are received, so people
	can open the received files, based on work by Baptiste Mille-Mathias
	<baptiste.millemathias@gmail.com> (Closes: #519060)
Comment 12 Baptiste Mille-Mathias 2008-05-25 17:33:33 UTC
Okay, I hope you'll do better code next time :/
I'm opening the bug right now;

thanks for the review
Comment 13 Bastien Nocera 2008-06-18 18:16:39 UTC
*** Bug 538995 has been marked as a duplicate of this bug. ***