Fixed the coding style.
This commit is contained in:
parent
3b0e8d2986
commit
fd53ececa2
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Thu Jan 19 21:55:08 PST 2006 Christian Hammond <chipx86@chipx86.com>
|
||||
|
||||
* libnotify/dbus-compat.h:
|
||||
* libnotify/notify.c:
|
||||
* libnotify/notifycommon.h:
|
||||
* libnotify/notify.h:
|
||||
* libnotify/notifynotification.c:
|
||||
* libnotify/notifynotification.h:
|
||||
- Fixed the coding style.
|
||||
|
||||
Thu Jan 19 01:34:57 PST 2006 Christian Hammond <chipx86@chipx86.com>
|
||||
|
||||
* tools/notify-send.c:
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
|
||||
/**
|
||||
* @file libnotify/dbus-compat.h Private D-BUS Compatibility API
|
||||
*
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
/* -*- mode: c-mode; tab-width: 4; indent-tabs-mode: t; -*- */
|
||||
/**
|
||||
* @file libnotify/notify.c Notifications library
|
||||
*
|
||||
* @Copyright (C) 2004 Christian Hammond <chipx86@chipx86.com>
|
||||
* @Copyright (C) 2004 Mike Hearn <mike@navi.cx>
|
||||
* @Copyright (C) 2004-2006 Christian Hammond <chipx86@chipx86.com>
|
||||
* @Copyright (C) 2004-2006 Mike Hearn <mike@navi.cx>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
/* -*- mode: c-mode; tab-width: 4; indent-tabs-mode: t; -*- */
|
||||
/**
|
||||
* @file libnotify/notify.h Notifications library
|
||||
*
|
||||
* @Copyright (C) 2004 Christian Hammond
|
||||
* @Copyright (C) 2004-2006 Christian Hammond
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -19,7 +18,6 @@
|
|||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _LIBNOTIFY_NOTIFY_H_
|
||||
#define _LIBNOTIFY_NOTIFY_H_
|
||||
|
||||
|
@ -58,6 +56,11 @@ void notify_uninit(void);
|
|||
*/
|
||||
gboolean notify_is_initted(void);
|
||||
|
||||
/**
|
||||
* Returns the name of the application set when notify_init() was called.
|
||||
*
|
||||
* @return The name of the application.
|
||||
*/
|
||||
const gchar *notify_get_app_name(void);
|
||||
|
||||
/**
|
||||
|
@ -79,8 +82,10 @@ GList *notify_get_server_caps(void);
|
|||
*
|
||||
* @return TRUE if the call succeeded, or FALSE if there were errors.
|
||||
*/
|
||||
gboolean notify_get_server_info(char **ret_name, char **ret_vendor,
|
||||
char **ret_version, char **ret_spec_version);
|
||||
gboolean notify_get_server_info(char **ret_name,
|
||||
char **ret_vendor,
|
||||
char **ret_version,
|
||||
char **ret_spec_version);
|
||||
|
||||
/*@}*/
|
||||
|
||||
|
|
|
@ -1,18 +1,22 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
/**
|
||||
* @file libnotify/notifynotification.c Notification object
|
||||
*
|
||||
* @Copyright (C) 2006 Christian Hammond
|
||||
* @Copyright (C) 2006 John Palmieri
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with main.c; if not, write to:
|
||||
* The Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330,
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#include "config.h"
|
||||
|
@ -26,28 +30,26 @@
|
|||
static void notify_notification_class_init(NotifyNotificationClass *klass);
|
||||
static void notify_notification_init(NotifyNotification *sp);
|
||||
static void notify_notification_finalize(GObject *object);
|
||||
static void _close_signal_handler (DBusGProxy *proxy,
|
||||
guint32 id,
|
||||
static void _close_signal_handler(DBusGProxy *proxy, guint32 id,
|
||||
NotifyNotification *notification);
|
||||
|
||||
static void _action_signal_handler (DBusGProxy *proxy,
|
||||
guint32 id,
|
||||
static void _action_signal_handler(DBusGProxy *proxy, guint32 id,
|
||||
gchar *action,
|
||||
NotifyNotification *notification);
|
||||
|
||||
struct NotifyNotificationPrivate
|
||||
struct _NotifyNotificationPrivate
|
||||
{
|
||||
guint32 id;
|
||||
gchar *summary;
|
||||
gchar *message;
|
||||
|
||||
/*NULL to use icon data
|
||||
anything else to have server lookup icon */
|
||||
/* NULL to use icon data anything else to have server lookup icon */
|
||||
gchar *icon_name;
|
||||
|
||||
/*-1 = use server default
|
||||
0 = never timeout
|
||||
>0 = Number of milliseconds before we timeout
|
||||
/*
|
||||
* -1 = use server default
|
||||
* 0 = never timeout
|
||||
* > 0 = Number of milliseconds before we timeout
|
||||
*/
|
||||
gint timeout;
|
||||
|
||||
|
@ -71,11 +73,13 @@ typedef enum
|
|||
{
|
||||
SIGNAL_TYPE_CLOSED,
|
||||
LAST_SIGNAL
|
||||
|
||||
} NotifyNotificationSignalType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NotifyNotification *object;
|
||||
|
||||
} NotifyNotificationSignal;
|
||||
|
||||
static guint notify_notification_signals[LAST_SIGNAL] = { 0 };
|
||||
|
@ -122,16 +126,12 @@ notify_notification_class_init (NotifyNotificationClass * klass)
|
|||
G_SIGNAL_RUN_FIRST,
|
||||
G_STRUCT_OFFSET(NotifyNotificationClass, closed),
|
||||
NULL, NULL,
|
||||
g_cclosure_marshal_VOID__VOID,
|
||||
G_TYPE_NONE,
|
||||
0);
|
||||
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||
|
||||
dbus_g_object_register_marshaller(notify_marshal_VOID__UINT_STRING,
|
||||
G_TYPE_NONE,
|
||||
G_TYPE_UINT,
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
G_TYPE_STRING, G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -147,23 +147,17 @@ notify_notification_init (NotifyNotification * obj)
|
|||
obj->priv = g_new0(NotifyNotificationPrivate, 1);
|
||||
|
||||
obj->priv->id = 0;
|
||||
|
||||
obj->priv->summary = NULL;
|
||||
obj->priv->message = NULL;
|
||||
obj->priv->icon_name = NULL;
|
||||
obj->priv->timeout = NOTIFY_TIMEOUT_DEFAULT;
|
||||
|
||||
obj->priv->actions = NULL;
|
||||
obj->priv->hints = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
obj->priv->hints = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
g_free,
|
||||
(GDestroyNotify) _g_value_free);
|
||||
(GFreeFunc)_g_value_free);
|
||||
|
||||
|
||||
obj->priv->action_map = g_hash_table_new_full (g_str_hash,
|
||||
g_str_equal,
|
||||
g_free,
|
||||
NULL);
|
||||
obj->priv->action_map = g_hash_table_new_full(g_str_hash, g_str_equal,
|
||||
g_free, NULL);
|
||||
|
||||
obj->priv->attached_widget = NULL;
|
||||
obj->priv->user_data = NULL;
|
||||
|
@ -175,23 +169,18 @@ notify_notification_init (NotifyNotification * obj)
|
|||
obj->priv->widget_old_y = 0;
|
||||
|
||||
obj->priv->proxy = NULL;
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
notify_notification_finalize(GObject *object)
|
||||
{
|
||||
NotifyNotification *obj;
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
||||
obj = NOTIFY_NOTIFICATION (object);
|
||||
priv = obj->priv;
|
||||
NotifyNotification *obj = NOTIFY_NOTIFICATION(object);
|
||||
NotifyNotificationPrivate *priv = obj->priv;
|
||||
|
||||
g_free(priv->summary);
|
||||
g_free(priv->message);
|
||||
g_free(priv->icon_name);
|
||||
|
||||
|
||||
if (priv->actions != NULL)
|
||||
{
|
||||
g_slist_foreach(priv->actions, (GFunc)g_free, NULL);
|
||||
|
@ -205,17 +194,17 @@ notify_notification_finalize (GObject * object)
|
|||
g_hash_table_destroy(priv->hints);
|
||||
|
||||
if (priv->attached_widget != NULL)
|
||||
gtk_widget_unref (priv->attached_widget);
|
||||
g_object_unref(G_OBJECT(priv->attached_widget));
|
||||
|
||||
if (priv->user_data_free_func != NULL)
|
||||
priv->user_data_free_func(priv->user_data);
|
||||
|
||||
dbus_g_proxy_disconnect_signal(priv->proxy, "NotificationClosed",
|
||||
(GCallback) _close_signal_handler,
|
||||
G_CALLBACK(_close_signal_handler),
|
||||
object);
|
||||
|
||||
dbus_g_proxy_disconnect_signal(priv->proxy, "ActionInvoked",
|
||||
(GCallback) _action_signal_handler,
|
||||
G_CALLBACK(_action_signal_handler),
|
||||
object);
|
||||
|
||||
g_free(obj->priv);
|
||||
|
@ -225,25 +214,21 @@ notify_notification_finalize (GObject * object)
|
|||
static gboolean
|
||||
_notify_notification_update_applet_hints(NotifyNotification *n)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
gboolean update_pending;
|
||||
|
||||
update_pending = FALSE;
|
||||
priv = n->priv;
|
||||
NotifyNotificationPrivate *priv = n->priv;
|
||||
gboolean update_pending = FALSE;
|
||||
|
||||
if (priv->attached_widget != NULL)
|
||||
{
|
||||
gint x, y, h, w;
|
||||
GtkWidget *widget;
|
||||
GtkWidget *widget = priv->attached_widget;
|
||||
GtkRequisition requisition;
|
||||
|
||||
widget = priv->attached_widget;
|
||||
|
||||
gtk_widget_size_request(widget, &requisition);
|
||||
w = requisition.width;
|
||||
h = requisition.height;
|
||||
|
||||
gdk_window_get_origin(widget->window, &x, &y);
|
||||
|
||||
if (GTK_WIDGET_NO_WINDOW(widget))
|
||||
{
|
||||
x += widget->allocation.x;
|
||||
|
@ -284,15 +269,13 @@ _notify_notification_update_applet_hints (NotifyNotification * n)
|
|||
static gboolean
|
||||
_idle_check_updates(void *user_data)
|
||||
{
|
||||
NotifyNotification *n;
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
||||
n = NOTIFY_NOTIFICATION (user_data);
|
||||
priv = n->priv;
|
||||
NotifyNotification *n = NOTIFY_NOTIFICATION(user_data);
|
||||
NotifyNotificationPrivate *priv = n->priv;
|
||||
|
||||
if (priv->is_visible)
|
||||
{
|
||||
priv->updates_pending = _notify_notification_update_applet_hints(n);
|
||||
|
||||
if (priv->updates_pending)
|
||||
{
|
||||
/* Try again if we fail on next idle */
|
||||
|
@ -304,9 +287,6 @@ _idle_check_updates (void *user_data)
|
|||
priv->updates_pending = FALSE;
|
||||
}
|
||||
|
||||
n = NOTIFY_NOTIFICATION (user_data);
|
||||
priv = n->priv;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
@ -315,14 +295,14 @@ GdkFilterReturn
|
|||
_catch(GdkXEvent *xevent, GdkEvent *event, gpointer data)
|
||||
{
|
||||
static int i = 1;
|
||||
|
||||
printf("here, %i\n", i);
|
||||
i++;
|
||||
return GDK_FILTER_CONTINUE;
|
||||
}
|
||||
|
||||
NotifyNotification *
|
||||
notify_notification_new (const gchar * summary,
|
||||
const gchar * message,
|
||||
notify_notification_new(const gchar *summary, const gchar *message,
|
||||
const gchar *icon, GtkWidget *attach)
|
||||
{
|
||||
NotifyNotification *obj;
|
||||
|
@ -338,7 +318,7 @@ notify_notification_new (const gchar * summary,
|
|||
|
||||
if (attach != NULL)
|
||||
{
|
||||
gtk_widget_ref (attach);
|
||||
g_object_ref(G_OBJECT(attach));
|
||||
obj->priv->attached_widget = attach;
|
||||
}
|
||||
|
||||
|
@ -350,9 +330,8 @@ notify_notification_update (NotifyNotification * notification,
|
|||
const gchar *summary,
|
||||
const gchar *message, const gchar *icon)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
NotifyNotificationPrivate *priv = notification->priv;
|
||||
|
||||
priv = notification->priv;
|
||||
g_free(priv->summary);
|
||||
g_free(priv->message);
|
||||
g_free(priv->icon_name);
|
||||
|
@ -371,31 +350,25 @@ void
|
|||
notify_notification_attach_to_widget(NotifyNotification *notification,
|
||||
GtkWidget *attach)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
||||
priv = notification->priv;
|
||||
NotifyNotificationPrivate *priv = notification->priv;
|
||||
|
||||
if (priv->attached_widget != NULL)
|
||||
gtk_widget_unref (priv->attached_widget);
|
||||
|
||||
if (attach != NULL)
|
||||
priv->attached_widget = gtk_widget_ref (attach);
|
||||
else
|
||||
priv->attached_widget = NULL;
|
||||
g_object_unref(priv->attached_widget);
|
||||
|
||||
priv->attached_widget = (attach != NULL ? g_object_ref(attach) : NULL);
|
||||
}
|
||||
|
||||
gboolean
|
||||
notify_notification_set_user_data(NotifyNotification *notification,
|
||||
void *user_data, GFreeFunc free_func)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
||||
priv = notification->priv;
|
||||
NotifyNotificationPrivate *priv = notification->priv;
|
||||
|
||||
if (priv->user_data)
|
||||
{
|
||||
if (priv->user_data_free_func)
|
||||
priv->user_data_free_func(priv->user_data);
|
||||
}
|
||||
|
||||
priv->user_data = user_data;
|
||||
priv->user_data_free_func = free_func;
|
||||
|
@ -407,32 +380,28 @@ notify_notification_set_user_data (NotifyNotification * notification,
|
|||
gpointer
|
||||
notify_notification_get_user_data(NotifyNotification *notification)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
return priv->user_data;
|
||||
return notification->priv->user_data;
|
||||
}
|
||||
|
||||
static void
|
||||
_close_signal_handler (DBusGProxy *proxy,
|
||||
guint32 id,
|
||||
_close_signal_handler(DBusGProxy *proxy, guint32 id,
|
||||
NotifyNotification *notification)
|
||||
{
|
||||
printf ("Got the NotificationClosed signal (id = %i, notification->id = %i)\n"
|
||||
, id, notification->priv->id);
|
||||
printf("Got the NotificationClosed signal (id = %i, "
|
||||
"notification->id = %i)\n",
|
||||
id, notification->priv->id);
|
||||
|
||||
if (id == notification->priv->id)
|
||||
{
|
||||
g_signal_emit(notification,
|
||||
notify_notification_signals[SIGNAL_TYPE_CLOSED],
|
||||
0);
|
||||
notify_notification_signals[SIGNAL_TYPE_CLOSED], 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_action_signal_handler(DBusGProxy *proxy,
|
||||
guint32 id,
|
||||
gchar *action,
|
||||
NotifyNotification *notification)
|
||||
gchar *action, NotifyNotification *notification)
|
||||
{
|
||||
g_assert(NOTIFY_IS_NOTIFICATION(notification));
|
||||
|
||||
|
@ -440,61 +409,47 @@ _action_signal_handler (DBusGProxy *proxy,
|
|||
{
|
||||
NotifyActionCallback callback;
|
||||
|
||||
callback = (NotifyActionCallback) g_hash_table_lookup (notification->priv->action_map,
|
||||
action);
|
||||
callback = (NotifyActionCallback)g_hash_table_lookup(
|
||||
notification->priv->action_map, action);
|
||||
|
||||
if (callback == NULL)
|
||||
g_warning("Recieved unknown action %s", action);
|
||||
else
|
||||
callback(notification, action);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
static gchar **
|
||||
_gslist_to_string_array(GSList *list)
|
||||
{
|
||||
GSList *element;
|
||||
GSList *l;
|
||||
GArray *a;
|
||||
gsize len;
|
||||
gchar **result;
|
||||
|
||||
len = g_slist_length (list);
|
||||
a = g_array_sized_new(TRUE, FALSE, sizeof(gchar *),
|
||||
g_slist_length(list));
|
||||
|
||||
a = g_array_sized_new (TRUE, FALSE, sizeof (gchar *), len);
|
||||
for (l = list; l != NULL; l = l->next)
|
||||
g_array_append_val(a, l->data);
|
||||
|
||||
element = list;
|
||||
while (element != NULL)
|
||||
{
|
||||
g_array_append_val (a, element->data);
|
||||
|
||||
element = g_slist_next (element);
|
||||
}
|
||||
|
||||
result = (gchar **)g_array_free (a, FALSE);
|
||||
|
||||
return result;
|
||||
return (gchar **)g_array_free(a, FALSE);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_notify_notification_show_internal(NotifyNotification *notification,
|
||||
GError **error,
|
||||
gboolean ignore_reply)
|
||||
GError **error, gboolean ignore_reply)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GError *tmp_error;
|
||||
NotifyNotificationPrivate *priv = notification->priv;
|
||||
GError *tmp_error = NULL;
|
||||
gchar **action_array;
|
||||
|
||||
g_return_val_if_fail(error == NULL || *error == NULL, FALSE);
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
tmp_error = NULL;
|
||||
|
||||
if (priv->proxy == NULL)
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
|
||||
bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
|
||||
|
||||
if (tmp_error != NULL)
|
||||
{
|
||||
g_propagate_error(error, tmp_error);
|
||||
|
@ -509,54 +464,59 @@ _notify_notification_show_internal (NotifyNotification *notification,
|
|||
dbus_g_proxy_add_signal(priv->proxy, "NotificationClosed",
|
||||
G_TYPE_UINT, G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal(priv->proxy, "NotificationClosed",
|
||||
(GCallback) _close_signal_handler,
|
||||
G_CALLBACK(_close_signal_handler),
|
||||
notification, NULL);
|
||||
|
||||
dbus_g_proxy_add_signal(priv->proxy, "ActionInvoked",
|
||||
G_TYPE_UINT, G_TYPE_STRING, G_TYPE_INVALID);
|
||||
G_TYPE_UINT, G_TYPE_STRING,
|
||||
G_TYPE_INVALID);
|
||||
dbus_g_proxy_connect_signal(priv->proxy, "ActionInvoked",
|
||||
(GCallback) _action_signal_handler,
|
||||
G_CALLBACK(_action_signal_handler),
|
||||
notification, NULL);
|
||||
|
||||
|
||||
dbus_g_connection_unref(bus);
|
||||
}
|
||||
|
||||
/*if attached to a widget modify x and y in hints */
|
||||
/* If attached to a widget, modify x and y in hints */
|
||||
_notify_notification_update_applet_hints(notification);
|
||||
|
||||
action_array = _gslist_to_string_array(priv->actions);
|
||||
|
||||
/* TODO: make this nonblocking */
|
||||
|
||||
if (!ignore_reply)
|
||||
{
|
||||
dbus_g_proxy_call(priv->proxy, "Notify", &tmp_error,
|
||||
G_TYPE_STRING, notify_get_app_name(),
|
||||
G_TYPE_STRING,
|
||||
(priv->icon_name != NULL) ? priv->icon_name : "",
|
||||
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
||||
G_TYPE_STRING, priv->message,
|
||||
G_TYPE_STRV,
|
||||
action_array, dbus_g_type_get_map ("GHashTable",
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_VALUE),
|
||||
priv->hints, G_TYPE_INT, priv->timeout, G_TYPE_INVALID,
|
||||
G_TYPE_UINT, priv->id, G_TYPE_STRING,
|
||||
priv->summary, G_TYPE_STRING, priv->message,
|
||||
G_TYPE_STRV, action_array,
|
||||
dbus_g_type_get_map("GHashTable", G_TYPE_STRING,
|
||||
G_TYPE_VALUE), priv->hints,
|
||||
G_TYPE_INT, priv->timeout, G_TYPE_INVALID,
|
||||
G_TYPE_UINT, &priv->id, G_TYPE_INVALID);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbus_g_proxy_call_no_reply(priv->proxy, "Notify",
|
||||
G_TYPE_STRING, notify_get_app_name(),
|
||||
G_TYPE_STRING,
|
||||
(priv->icon_name != NULL) ? priv->icon_name : "",
|
||||
G_TYPE_UINT, priv->id, G_TYPE_STRING, priv->summary,
|
||||
G_TYPE_STRING, priv->message,
|
||||
G_TYPE_STRV,
|
||||
action_array, dbus_g_type_get_map ("GHashTable",
|
||||
(priv->icon_name !=
|
||||
NULL) ? priv->icon_name : "",
|
||||
G_TYPE_UINT, priv->id, G_TYPE_STRING,
|
||||
priv->summary, G_TYPE_STRING,
|
||||
priv->message, G_TYPE_STRV,
|
||||
action_array,
|
||||
dbus_g_type_get_map("GHashTable",
|
||||
G_TYPE_STRING,
|
||||
G_TYPE_VALUE),
|
||||
priv->hints, G_TYPE_INT, priv->timeout, G_TYPE_INVALID);
|
||||
priv->hints, G_TYPE_INT, priv->timeout,
|
||||
G_TYPE_INVALID);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*don't free the elements because they are owned by priv->actions */
|
||||
/* Don't free the elements because they are owned by priv->actions */
|
||||
g_free(action_array);
|
||||
|
||||
if (tmp_error != NULL)
|
||||
|
@ -568,8 +528,6 @@ _notify_notification_show_internal (NotifyNotification *notification,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
notify_notification_show(NotifyNotification *notification, GError **error)
|
||||
{
|
||||
|
@ -577,11 +535,12 @@ notify_notification_show (NotifyNotification *notification, GError **error)
|
|||
}
|
||||
|
||||
gboolean
|
||||
notify_notification_show_and_forget (NotifyNotification *notification, GError **error)
|
||||
notify_notification_show_and_forget(NotifyNotification *notification,
|
||||
GError **error)
|
||||
{
|
||||
gboolean result;
|
||||
gboolean result =
|
||||
_notify_notification_show_internal(notification, error, TRUE);
|
||||
|
||||
result = _notify_notification_show_internal (notification, error, TRUE);
|
||||
g_object_unref(G_OBJECT(notification));
|
||||
|
||||
return result;
|
||||
|
@ -613,15 +572,13 @@ notify_notification_set_urgency (NotifyNotification * notification,
|
|||
static gboolean
|
||||
_gvalue_array_append_int(GValueArray *array, gint i)
|
||||
{
|
||||
GValue *value;
|
||||
GValue *value = g_new0(GValue, 1);
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
if (!value)
|
||||
if (value == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_value_init(value, G_TYPE_INT);
|
||||
g_value_set_int(value, i);
|
||||
|
||||
g_value_array_append(array, value);
|
||||
|
||||
return TRUE;
|
||||
|
@ -630,35 +587,32 @@ _gvalue_array_append_int (GValueArray * array, gint i)
|
|||
static gboolean
|
||||
_gvalue_array_append_bool(GValueArray *array, gboolean b)
|
||||
{
|
||||
GValue *value;
|
||||
GValue *value = g_new0(GValue, 1);
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
if (!value)
|
||||
if (value == NULL)
|
||||
return FALSE;
|
||||
|
||||
g_value_init(value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean(value, b);
|
||||
|
||||
g_value_array_append(array, value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
_gvalue_array_append_byte_array (GValueArray * array,
|
||||
guchar * bytes, gsize len)
|
||||
_gvalue_array_append_byte_array(GValueArray *array, guchar *bytes, gsize len)
|
||||
{
|
||||
GArray *byte_array;
|
||||
GValue *value;
|
||||
|
||||
byte_array = g_array_sized_new(FALSE, FALSE, sizeof(guchar), len);
|
||||
if (!byte_array)
|
||||
|
||||
if (byte_array == NULL)
|
||||
return FALSE;
|
||||
|
||||
byte_array = g_array_append_vals(byte_array, bytes, len);
|
||||
|
||||
value = g_new0 (GValue, 1);
|
||||
if (!value)
|
||||
if ((value = g_new0(GValue, 1)) == NULL)
|
||||
{
|
||||
g_array_free(byte_array, TRUE);
|
||||
return FALSE;
|
||||
|
@ -666,17 +620,14 @@ _gvalue_array_append_byte_array (GValueArray * array,
|
|||
|
||||
g_value_init(value, dbus_g_type_get_collection("GArray", G_TYPE_UCHAR));
|
||||
g_value_set_boxed_take_ownership(value, byte_array);
|
||||
|
||||
g_value_array_append(array, value);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
gboolean
|
||||
notify_notification_set_icon_data_from_pixbuf (NotifyNotification *
|
||||
notification, GdkPixbuf * icon)
|
||||
notify_notification_set_icon_data_from_pixbuf(
|
||||
NotifyNotification *notification, GdkPixbuf *icon)
|
||||
{
|
||||
gint width;
|
||||
gint height;
|
||||
|
@ -686,8 +637,6 @@ notify_notification_set_icon_data_from_pixbuf (NotifyNotification *
|
|||
gint n_channels;
|
||||
guchar *image;
|
||||
gsize image_len;
|
||||
gchar *key_dup;
|
||||
|
||||
GValueArray *image_struct;
|
||||
GValue *value;
|
||||
NotifyNotificationPrivate *priv;
|
||||
|
@ -700,15 +649,14 @@ notify_notification_set_icon_data_from_pixbuf (NotifyNotification *
|
|||
n_channels = gdk_pixbuf_get_n_channels(icon);
|
||||
bits_per_sample = gdk_pixbuf_get_bits_per_sample(icon);
|
||||
alpha = gdk_pixbuf_get_has_alpha(icon);
|
||||
image_len =
|
||||
(height - 1) * rowstride +
|
||||
width * ((n_channels * bits_per_sample + 7) / 8);
|
||||
image_len = (height - 1) * rowstride + width *
|
||||
((n_channels * bits_per_sample + 7) / 8);
|
||||
|
||||
image = gdk_pixbuf_get_pixels(icon);
|
||||
|
||||
image_struct = g_value_array_new(8);
|
||||
|
||||
if (!image_struct)
|
||||
if (image_struct == NULL)
|
||||
goto fail;
|
||||
|
||||
_gvalue_array_append_int(image_struct, width);
|
||||
|
@ -720,23 +668,21 @@ notify_notification_set_icon_data_from_pixbuf (NotifyNotification *
|
|||
_gvalue_array_append_byte_array(image_struct, image, image_len);
|
||||
|
||||
value = g_new0(GValue, 1);
|
||||
if (!value)
|
||||
|
||||
if (value == NULL)
|
||||
goto fail;
|
||||
|
||||
g_value_init(value, G_TYPE_VALUE_ARRAY);
|
||||
g_value_set_boxed(value, image_struct);
|
||||
|
||||
key_dup = g_strdup ("icon_data");
|
||||
if (!key_dup)
|
||||
goto fail;
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, value);
|
||||
g_hash_table_insert(priv->hints, g_strdup("icon_data"), value);
|
||||
|
||||
return TRUE;
|
||||
|
||||
fail:
|
||||
if (image_struct != NULL)
|
||||
g_value_array_free(image_struct);
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -746,7 +692,6 @@ notify_notification_set_hint_int32 (NotifyNotification * notification,
|
|||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GValue *hint_value;
|
||||
gchar *key_dup;
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
|
@ -754,9 +699,7 @@ notify_notification_set_hint_int32 (NotifyNotification * notification,
|
|||
g_value_init(hint_value, G_TYPE_INT);
|
||||
g_value_set_int(hint_value, value);
|
||||
|
||||
key_dup = g_strdup (key);
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, hint_value);
|
||||
g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
|
||||
|
||||
/* TODO: return FALSE on OOM */
|
||||
return TRUE;
|
||||
|
@ -768,7 +711,6 @@ notify_notification_set_hint_double (NotifyNotification * notification,
|
|||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GValue *hint_value;
|
||||
gchar *key_dup;
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
|
@ -776,9 +718,7 @@ notify_notification_set_hint_double (NotifyNotification * notification,
|
|||
g_value_init(hint_value, G_TYPE_FLOAT);
|
||||
g_value_set_float(hint_value, value);
|
||||
|
||||
key_dup = g_strdup (key);
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, hint_value);
|
||||
g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
|
||||
|
||||
/* TODO: return FALSE on OOM */
|
||||
return TRUE;
|
||||
|
@ -790,7 +730,6 @@ notify_notification_set_hint_byte (NotifyNotification * notification,
|
|||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GValue *hint_value;
|
||||
gchar *key_dup;
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
|
@ -798,9 +737,7 @@ notify_notification_set_hint_byte (NotifyNotification * notification,
|
|||
g_value_init(hint_value, G_TYPE_UCHAR);
|
||||
g_value_set_uchar(hint_value, value);
|
||||
|
||||
key_dup = g_strdup (key);
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, hint_value);
|
||||
g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
|
||||
|
||||
/* TODO: return FALSE on OOM */
|
||||
return TRUE;
|
||||
|
@ -813,7 +750,6 @@ notify_notification_set_hint_byte_array (NotifyNotification * notification,
|
|||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GValue *hint_value;
|
||||
gchar *key_dup;
|
||||
GArray *byte_array;
|
||||
|
||||
priv = notification->priv;
|
||||
|
@ -822,25 +758,22 @@ notify_notification_set_hint_byte_array (NotifyNotification * notification,
|
|||
byte_array = g_array_append_vals(byte_array, value, len);
|
||||
|
||||
hint_value = g_new0(GValue, 1);
|
||||
g_value_init (hint_value,
|
||||
dbus_g_type_get_collection ("GArray", G_TYPE_UCHAR));
|
||||
g_value_init(hint_value, dbus_g_type_get_collection("GArray",
|
||||
G_TYPE_UCHAR));
|
||||
g_value_set_boxed_take_ownership(hint_value, byte_array);
|
||||
key_dup = g_strdup (key);
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, hint_value);
|
||||
g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
|
||||
|
||||
/* TODO: return FALSE on OOM */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
notify_notification_set_hint_string(NotifyNotification *notification,
|
||||
const gchar *key, const gchar *value)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GValue *hint_value;
|
||||
gchar *key_dup;
|
||||
|
||||
priv = notification->priv;
|
||||
|
||||
|
@ -848,9 +781,7 @@ notify_notification_set_hint_string (NotifyNotification * notification,
|
|||
g_value_init(hint_value, G_TYPE_STRING);
|
||||
g_value_set_string(hint_value, value);
|
||||
|
||||
key_dup = g_strdup (key);
|
||||
|
||||
g_hash_table_insert (priv->hints, key_dup, hint_value);
|
||||
g_hash_table_insert(priv->hints, g_strdup(key), hint_value);
|
||||
|
||||
/* TODO: return FALSE on OOM */
|
||||
return TRUE;
|
||||
|
@ -872,7 +803,8 @@ notify_notification_clear_hints (NotifyNotification *notification)
|
|||
void
|
||||
notify_notification_clear_actions(NotifyNotification *notification)
|
||||
{
|
||||
g_hash_table_foreach_remove (notification->priv->action_map, (GHRFunc) _remove_all, NULL);
|
||||
g_hash_table_foreach_remove(notification->priv->action_map,
|
||||
(GHRFunc)_remove_all, NULL);
|
||||
|
||||
if (notification->priv->actions != NULL)
|
||||
{
|
||||
|
@ -902,7 +834,8 @@ notify_notification_add_action (NotifyNotification *notification,
|
|||
}
|
||||
|
||||
gboolean
|
||||
notify_notification_close (NotifyNotification * notification, GError ** error)
|
||||
notify_notification_close(NotifyNotification *notification,
|
||||
GError **error)
|
||||
{
|
||||
NotifyNotificationPrivate *priv;
|
||||
GError *tmp_error;
|
||||
|
@ -915,9 +848,8 @@ notify_notification_close (NotifyNotification * notification, GError ** error)
|
|||
|
||||
if (priv->proxy == NULL)
|
||||
{
|
||||
DBusGConnection *bus;
|
||||
DBusGConnection *bus = dbus_g_bus_get(DBUS_BUS_SESSION, &tmp_error);
|
||||
|
||||
bus = dbus_g_bus_get (DBUS_BUS_SESSION, &tmp_error);
|
||||
if (tmp_error != NULL)
|
||||
{
|
||||
g_propagate_error(error, tmp_error);
|
||||
|
@ -932,7 +864,8 @@ notify_notification_close (NotifyNotification * notification, GError ** error)
|
|||
}
|
||||
|
||||
dbus_g_proxy_call(priv->proxy, "CloseNotification", &tmp_error,
|
||||
G_TYPE_UINT, priv->id, G_TYPE_INVALID, G_TYPE_INVALID);
|
||||
G_TYPE_UINT, priv->id, G_TYPE_INVALID,
|
||||
G_TYPE_INVALID);
|
||||
|
||||
if (tmp_error != NULL)
|
||||
{
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
/**
|
||||
* @file libnotify/notifynotification.h Notification object
|
||||
*
|
||||
* @Copyright (C) 2006 Christian Hammond
|
||||
* @Copyright (C) 2006 John Palmieri
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with main.c; if not, write to:
|
||||
* The Free Software Foundation, Inc.,
|
||||
* 59 Temple Place - Suite 330,
|
||||
* License along with this library; if not, write to the
|
||||
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
* Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef NOTIFY_NOTIFICATION_H
|
||||
#define NOTIFY_NOTIFICATION_H
|
||||
#ifndef _NOTIFY_NOTIFICATION_H_
|
||||
#define _NOTIFY_NOTIFICATION_H_
|
||||
|
||||
#include <glib.h>
|
||||
#include <glib-object.h>
|
||||
|
@ -28,28 +31,42 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
#define NOTIFY_TYPE_NOTIFICATION (notify_notification_get_type ())
|
||||
#define NOTIFY_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotification))
|
||||
#define NOTIFY_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
|
||||
#define NOTIFY_IS_NOTIFICATION(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
|
||||
#define NOTIFY_IS_NOTIFICATION_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
|
||||
#define NOTIFY_NOTIFICATION_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, NotifyNotificationClass))
|
||||
#define NOTIFY_NOTIFICATION(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST ((o), NOTIFY_TYPE_NOTIFICATION, \
|
||||
NotifyNotification))
|
||||
#define NOTIFY_NOTIFICATION_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((k), NOTIFY_TYPE_NOTIFICATION, \
|
||||
NotifyNotificationClass))
|
||||
#define NOTIFY_IS_NOTIFICATION(o) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE ((o), NOTIFY_TYPE_NOTIFICATION))
|
||||
#define NOTIFY_IS_NOTIFICATION_CLASS(k) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE ((k), NOTIFY_TYPE_NOTIFICATION))
|
||||
#define NOTIFY_NOTIFICATION_GET_CLASS(o) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((o), NOTIFY_TYPE_NOTIFICATION, \
|
||||
NotifyNotificationClass))
|
||||
|
||||
typedef struct NotifyNotificationPrivate NotifyNotificationPrivate;
|
||||
typedef struct _NotifyNotification NotifyNotification;
|
||||
typedef struct _NotifyNotificationClass NotifyNotificationClass;
|
||||
typedef struct _NotifyNotificationPrivate NotifyNotificationPrivate;
|
||||
|
||||
typedef struct {
|
||||
struct _NotifyNotification
|
||||
{
|
||||
GObject parent;
|
||||
NotifyNotificationPrivate *priv;
|
||||
} NotifyNotification;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
struct _NotifyNotificationClass
|
||||
{
|
||||
GObjectClass parent_class;
|
||||
/* Add Signal Functions Here */
|
||||
void (*closed) (void);
|
||||
} NotifyNotificationClass;
|
||||
|
||||
/* Signals */
|
||||
void (*closed)(NotifyNotification *notification);
|
||||
};
|
||||
|
||||
typedef void (*NotifyActionCallback)(NotifyNotification *, gchar *);
|
||||
|
||||
GType notify_notification_get_type();
|
||||
|
||||
NotifyNotification *notify_notification_new(const gchar *summary,
|
||||
const gchar *message,
|
||||
const gchar *icon,
|
||||
|
@ -84,13 +101,11 @@ gboolean notify_notification_set_category (NotifyNotification *notification,
|
|||
gboolean notify_notification_set_urgency(NotifyNotification *notification,
|
||||
NotifyUrgency l);
|
||||
|
||||
gboolean notify_notification_set_icon_data_from_pixbuf (NotifyNotification *notification,
|
||||
GdkPixbuf *icon);
|
||||
|
||||
gboolean notify_notification_set_icon_data_from_pixbuf(
|
||||
NotifyNotification *notification, GdkPixbuf *icon);
|
||||
|
||||
gboolean notify_notification_set_hint_int32(NotifyNotification *notification,
|
||||
const gchar *key,
|
||||
gint value);
|
||||
const gchar *key, gint value);
|
||||
|
||||
gboolean notify_notification_set_hint_double(NotifyNotification *notification,
|
||||
const gchar *key,
|
||||
|
@ -105,10 +120,8 @@ gboolean notify_notification_set_hint_byte (NotifyNotification *notification,
|
|||
guchar value);
|
||||
|
||||
gboolean notify_notification_set_hint_byte_array(
|
||||
NotifyNotification *notification,
|
||||
const gchar *key,
|
||||
const guchar *value,
|
||||
gsize len);
|
||||
NotifyNotification *notification, const gchar *key,
|
||||
const guchar *value, gsize len);
|
||||
|
||||
void notify_notification_clear_hints(NotifyNotification *notification);
|
||||
|
||||
|
@ -123,4 +136,5 @@ gboolean notify_notification_close (NotifyNotification *notification,
|
|||
|
||||
NotifyNotification *notify_notification_ref(NotifyNotification *notification);
|
||||
void notify_notification_unref(NotifyNotification *notification);
|
||||
|
||||
#endif /* NOTIFY_NOTIFICATION_H */
|
||||
|
|
Loading…
Reference in New Issue