GNOME Bugzilla – Bug 519060
Add notifications on file reception
Last modified: 2008-06-18 18:16:39 UTC
See transfer_completed_cb(). The status icon shouldn't disappear while there's transfers going on, or while the notification is visible.
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
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 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.
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?).
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.
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).
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.
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).
Created attachment 111484 [details] [review] Patch version 4 Patch updated
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
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)
Okay, I hope you'll do better code next time :/ I'm opening the bug right now; thanks for the review
*** Bug 538995 has been marked as a duplicate of this bug. ***