#include "socket.h"
#endif
-#if !HAVE_HILDON
-typedef struct _NotifyNotification NotifyNotification;
-
-typedef struct
-{
- gboolean (*init) (const gchar* app_name);
- void (*uninit) (void);
- NotifyNotification* (*notification_new) (const gchar* summary,
- const gchar* body,
- const gchar* icon,
- GtkWidget* attach);
- gboolean (*notification_show) (NotifyNotification* notification,
- GError** error);
-} LibNotifyFuncs;
+#if HAVE_LIBNOTIFY
+ #include <libnotify/notify.h>
#endif
struct _MidoriApp
MidoriAppInstance instance;
#if !HAVE_HILDON
- /* libnotify handling */
- gchar* program_notify_send;
- GModule* libnotify_module;
- LibNotifyFuncs libnotify_funcs;
+ gchar* program_notify_send;
#endif
};
static void
midori_app_finalize (GObject* object);
-static void
-midori_app_init_libnotify (MidoriApp* app);
-
static void
midori_app_set_property (GObject* object,
guint prop_id,
app->instance = MidoriAppInstanceNull;
- midori_app_init_libnotify (app);
+ #if HAVE_LIBNOTIFY
+ notify_init ("midori");
+ #endif
+
+ app->program_notify_send = g_find_program_in_path ("notify-send");
}
static void
sock_cleanup ();
#endif
- #if !HAVE_HILDON
- if (app->libnotify_module)
- {
- app->libnotify_funcs.uninit ();
- g_module_close (app->libnotify_module);
- }
- katze_assign (app->program_notify_send, NULL);
+ #if HAVE_LIBNOTIFY
+ if (notify_is_initted ())
+ notify_uninit ();
#endif
+ katze_assign (app->program_notify_send, NULL);
G_OBJECT_CLASS (midori_app_parent_class)->finalize (object);
}
g_signal_emit (app, signals[QUIT], 0);
}
-static void
-midori_app_init_libnotify (MidoriApp* app)
-{
- #if !HAVE_HILDON
- app->libnotify_module = g_module_open ("libnotify.so.1", G_MODULE_BIND_LOCAL);
-
- if (app->libnotify_module != NULL)
- {
- g_module_symbol (app->libnotify_module, "notify_init",
- (void*) &(app->libnotify_funcs.init));
- g_module_symbol (app->libnotify_module, "notify_uninit",
- (void*) &(app->libnotify_funcs.uninit));
- g_module_symbol (app->libnotify_module, "notify_notification_new",
- (void*) &(app->libnotify_funcs.notification_new));
- g_module_symbol (app->libnotify_module, "notify_notification_show",
- (void*) &(app->libnotify_funcs.notification_show));
-
- /* init libnotify */
- if (!app->libnotify_funcs.init || !app->libnotify_funcs.init ("midori"))
- {
- g_module_close (app->libnotify_module);
- app->libnotify_module = NULL;
- }
- }
-
- app->program_notify_send = g_find_program_in_path ("notify-send");
- #endif
-}
-
/**
* midori_app_send_notification:
* @app: a #MidoriApp
const gchar* title,
const gchar* message)
{
+ g_return_if_fail (MIDORI_IS_APP (app));
+ g_return_if_fail (title);
+
#if HAVE_HILDON
hildon_banner_show_information_with_markup (GTK_WIDGET (app->browser),
"midori", message);
#else
gboolean sent = FALSE;
- g_return_if_fail (MIDORI_IS_APP (app));
- g_return_if_fail (title);
-
- if (app->libnotify_module)
+ #if HAVE_LIBNOTIFY
+ if (notify_is_initted ())
{
- NotifyNotification* n;
+ NotifyNotification* note;
- n = app->libnotify_funcs.notification_new (title, message, "midori", NULL);
- sent = app->libnotify_funcs.notification_show (n, NULL);
- g_object_unref (n);
+ note = notify_notification_new (title, message, "midori", NULL);
+ sent = notify_notification_show (note, NULL);
+ g_object_unref (note);
}
+ #endif
+
/* Fall back to the command line program "notify-send" */
if (!sent && app->program_notify_send)
{
#include <glib/gi18n.h>
#include <libsoup/soup.h>
+#if HAVE_LIBNOTIFY
+ #include <libnotify/notify.h>
+#endif
+
struct _MidoriPreferences
{
KatzePreferences parent_instance;
SPANNED_ADD (button);
label = katze_property_proxy (settings, "ask-for-destination-folder", NULL);
INDENTED_ADD (label);
- button = katze_property_proxy (settings, "notify-transfer-completed", NULL);
- /* FIXME: Disable the option if notifications presumably cannot be sent
- gtk_widget_set_sensitive (button, FALSE); */
- SPANNED_ADD (button);
+ #if HAVE_LIBNOTIFY
+ if (notify_is_initted () || g_find_program_in_path ("notify-send"))
+ {
+ button = katze_property_proxy (settings, "notify-transfer-completed", NULL);
+ SPANNED_ADD (button);
+ }
+ #endif
#endif
/* Page "Appearance" */
sqlite = 'no '
conf.define ('HAVE_SQLITE', [0,1][sqlite == 'yes'])
+ if option_enabled ('libnotify'):
+ check_pkg ('libnotify', mandatory=False)
+ libnotify = ['N/A','yes'][conf.env['HAVE_LIBNOTIFY'] == 1]
+ if libnotify != 'yes':
+ option_checkfatal ('libnotify', 'notifications')
+ else:
+ libnotify = 'no '
+ conf.define ('HAVE_LIBNOTIFY', [0,1][libnotify == 'yes'])
+
conf.check (lib='m', mandatory=True)
check_pkg ('gmodule-2.0', '2.8.0', False)
check_pkg ('gthread-2.0', '2.8.0', False)
Localization: %(nls)s (intltool)
Icon optimizations: %(icons)s (rsvg-convert)
Persistent history: %(sqlite)s (sqlite3)
+ Notifications: %(libnotify)s (libnotify)
IDN support: %(idn)s (libidn or libsoup 2.27.90)
User documentation: %(user_docs)s (docutils)
add_enable_option ('unique', 'single instance support', group)
add_enable_option ('libidn', 'international domain name support', group)
add_enable_option ('sqlite', 'history database support', group)
+ add_enable_option ('libnotify', 'notification support', group)
add_enable_option ('addons', 'building of extensions', group)
add_enable_option ('hildon', 'Maemo integration', group, disable=not is_maemo ())