[epiphany] Show a notification when the newly created web-app is ready to be used
- From: Xan Lopez <xan src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] Show a notification when the newly created web-app is ready to be used
- Date: Mon, 29 Aug 2011 13:51:58 +0000 (UTC)
commit 540c0c0ac46399462dfad2c3fd0a50a412882307
Author: Xan Lopez <xlopez igalia com>
Date: Mon Aug 29 15:49:08 2011 +0200
Show a notification when the newly created web-app is ready to be used
This will probably go away in 3.4 when the new dash design is
introduced, but for now it's the best we have.
configure.ac | 2 ++
src/ephy-main.c | 6 ++++++
src/window-commands.c | 35 +++++++++++++++++++++++++++++++++--
3 files changed, 41 insertions(+), 2 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index cdf52a8..dec2be9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -91,6 +91,7 @@ WEBKIT_GTK_REQUIRED=1.5.2
LIBSOUP_GNOME_REQUIRED=2.33.1
GNOME_KEYRING_REQUIRED=2.26.0
GSETTINGS_DESKTOP_SCHEMAS_REQUIRED=0.0.1
+LIBNOTIFY_REQUIRED=0.5.1
# Tests
@@ -118,6 +119,7 @@ PKG_CHECK_MODULES([DEPENDENCIES], [
libsoup-gnome-2.4 >= $LIBSOUP_GNOME_REQUIRED
gnome-keyring-1 >= $GNOME_KEYRING_REQUIRED
gsettings-desktop-schemas >= $GSETTINGS_DESKTOP_SCHEMAS_REQUIRED
+ libnotify >= $LIBNOTIFY_REQUIRED
])
# ******************
diff --git a/src/ephy-main.c b/src/ephy-main.c
index c74b2e7..19b4100 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -35,6 +35,7 @@
#include "eggsmclient.h"
#include <libxml/xmlversion.h>
+#include <libnotify/notify.h>
#include <glib/gi18n.h>
@@ -261,6 +262,8 @@ main (int argc,
*/
LIBXML_TEST_VERSION;
+ notify_init (PACKAGE);
+
/* If we're given -remote arguments, translate them */
if (argc >= 2 && strcmp (argv[1], "-remote") == 0) {
const char *opening, *closing;
@@ -463,6 +466,9 @@ main (int argc,
/* Shutdown */
g_object_unref (ephy_shell);
+ if (notify_is_initted ())
+ notify_uninit ();
+
ephy_file_save_accels ();
ephy_state_save ();
ephy_settings_shutdown ();
diff --git a/src/window-commands.c b/src/window-commands.c
index 341ea40..3cdbcf6 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -58,6 +58,7 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <webkit/webkit.h>
+#include <libnotify/notify.h>
static void
page_setup_done_cb (GtkPageSetup *setup,
@@ -503,6 +504,20 @@ fill_default_application_title (EphyApplicationDialogData *data)
gtk_entry_set_text (GTK_ENTRY (data->entry), title);
}
+static void
+notify_launch_cb (NotifyNotification *notification,
+ char *action,
+ gpointer user_data)
+{
+ char * desktop_file = user_data;
+ /* A gross hack to be able to launch epiphany from within
+ * Epiphany. Might be a good idea to figure out a better
+ * solution... */
+ g_unsetenv (EPHY_UUID_ENVVAR);
+ ephy_file_launch_desktop_file (desktop_file, NULL, 0, NULL);
+ g_free (desktop_file);
+}
+
void
window_cmd_file_save_as_application (GtkAction *action,
EphyWindow *window)
@@ -558,14 +573,30 @@ window_cmd_file_save_as_application (GtkAction *action,
if (response == GTK_RESPONSE_OK)
{
char *desktop_file;
+ char *message;
+ NotifyNotification *notification;
/* Create Web Application, including a new profile and .desktop file. */
desktop_file = ephy_web_view_create_web_application (view,
gtk_entry_get_text (GTK_ENTRY (data->entry)),
gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
- /* TODO: show a notification when the app is totally
- * created and ready to be launched */
+ message = g_strdup_printf (_("The application '%s' is ready to be used"),
+ gtk_entry_get_text (GTK_ENTRY (data->entry)));
+
+ notification = notify_notification_new (message,
+ NULL, NULL);
+ g_free (message);
+ notify_notification_add_action (notification, "launch", _("Launch"),
+ (NotifyActionCallback)notify_launch_cb,
+ g_path_get_basename (desktop_file),
+ NULL);
+ notify_notification_set_icon_from_pixbuf (notification, gtk_image_get_pixbuf (GTK_IMAGE (data->image)));
+ notify_notification_set_timeout (notification, NOTIFY_EXPIRES_DEFAULT);
+ notify_notification_set_urgency (notification, NOTIFY_URGENCY_LOW);
+ notify_notification_set_hint (notification, "transient", g_variant_new_boolean (TRUE));
+ notify_notification_show (notification, NULL);
+
g_free (desktop_file);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]