Changeset 2477
- Timestamp:
- 01/23/06 01:10:55
- Files:
-
- trunk/libnotify/ChangeLog (modified) (1 diff)
- trunk/libnotify/libnotify/internal.h (modified) (1 diff)
- trunk/libnotify/libnotify/notification.c (modified) (8 diffs)
- trunk/libnotify/libnotify/notify.c (modified) (9 diffs)
- trunk/libnotify/tests/test-replace-widget.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/libnotify/ChangeLog
r2469 r2477 1 Mon Jan 23 01:10:23 PST 2006 Christian Hammond <chipx86@chipx86.com> 2 3 * libnotify/internal.h: 4 * libnotify/notification.c: 5 * libnotify/notify.c: 6 * tests/test-replace-widget.c: 7 - Make a best attempt at clearing away notifications that require 8 actions or that exist until clicked when the calling application 9 exits. This doesn't always work. 10 1 11 Sun Jan 22 23:46:27 PST 2006 Christian Hammond <chipx86@chipx86.com> 2 12 trunk/libnotify/libnotify/internal.h
r2457 r2477 37 37 #define NOTIFY_DBUS_CORE_OBJECT "/org/freedesktop/Notifications" 38 38 39 DBusGConnection *get_dbus_g_conn(void); 40 DBusGProxy *get_g_proxy(void); 39 DBusGConnection *_notify_get_dbus_g_conn(void); 40 DBusGProxy *_notify_get_g_proxy(void); 41 42 void _notify_cache_add_notification(NotifyNotification *n); 43 void _notify_cache_remove_notification(NotifyNotification *n); 44 gint _notify_notification_get_timeout(const NotifyNotification *n); 45 gboolean _notify_notification_has_nondefault_actions( 46 const NotifyNotification *n); 41 47 42 48 #endif /* _LIBNOTIFY_INTERNAL_H_ */ trunk/libnotify/libnotify/notification.c
r2469 r2477 73 73 gint widget_old_y; 74 74 75 gboolean has_nondefault_actions; 75 76 gboolean updates_pending; 76 77 gboolean signals_registered; … … 142 143 NotifyNotification *obj = NOTIFY_NOTIFICATION(object); 143 144 NotifyNotificationPrivate *priv = obj->priv; 144 DBusGProxy *proxy = get_g_proxy(); 145 DBusGProxy *proxy = _notify_get_g_proxy(); 146 147 _notify_cache_remove_notification(obj); 145 148 146 149 g_free(priv->summary); … … 283 286 } 284 287 288 _notify_cache_add_notification(obj); 289 285 290 return obj; 286 291 } … … 381 386 382 387 priv = notification->priv; 383 proxy = get_g_proxy();388 proxy = _notify_get_g_proxy(); 384 389 385 390 if (!priv->signals_registered) … … 438 443 } 439 444 445 gint 446 _notify_notification_get_timeout(const NotifyNotification *notification) 447 { 448 g_return_val_if_fail(notification != NULL, -1); 449 g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(notification), -1); 450 451 return notification->priv->timeout; 452 } 453 440 454 void 441 455 notify_notification_set_category(NotifyNotification *notification, … … 693 707 694 708 notification->priv->actions = NULL; 709 notification->priv->has_nondefault_actions = FALSE; 695 710 } 696 711 … … 720 735 pair->user_data = user_data; 721 736 g_hash_table_insert(priv->action_map, g_strdup(action), pair); 737 738 if (notification->priv->has_nondefault_actions && 739 g_ascii_strcasecmp(action, "default")) 740 { 741 notification->priv->has_nondefault_actions = TRUE; 742 } 743 } 744 745 gboolean 746 _notify_notification_has_nondefault_actions(const NotifyNotification *n) 747 { 748 g_return_val_if_fail(n != NULL, FALSE); 749 g_return_val_if_fail(NOTIFY_IS_NOTIFICATION(n), FALSE); 750 751 return n->priv->has_nondefault_actions; 722 752 } 723 753 … … 735 765 priv = notification->priv; 736 766 737 dbus_g_proxy_call( get_g_proxy(), "CloseNotification", &tmp_error,767 dbus_g_proxy_call(_notify_get_g_proxy(), "CloseNotification", &tmp_error, 738 768 G_TYPE_UINT, priv->id, G_TYPE_INVALID, 739 769 G_TYPE_INVALID); trunk/libnotify/libnotify/notify.c
r2457 r2477 32 32 static DBusGProxy *_proxy = NULL; 33 33 static DBusGConnection *_dbus_gconn = NULL; 34 static GList *_active_notifications = NULL; 34 35 35 36 #ifdef __GNUC__ … … 81 82 G_TYPE_INVALID); 82 83 83 #ifdef HAVE_ATEXIT 84 atexit(notify_uninit); 85 #endif /* HAVE_ATEXIT */ 84 g_atexit(notify_uninit); 86 85 87 86 _initted = TRUE; … … 99 98 notify_uninit(void) 100 99 { 100 GList *l; 101 101 102 if (_app_name != NULL) 102 103 { … … 105 106 } 106 107 107 /* 108 * TODO: Keep track of all notifications and destroy them here? 109 * Definitely all notifications that don't expire. 110 */ 108 for (l = _active_notifications; l != NULL; l = l->next) 109 { 110 NotifyNotification *n = NOTIFY_NOTIFICATION(l->data); 111 112 if (_notify_notification_get_timeout(n) == 0 || 113 _notify_notification_has_nondefault_actions(n)) 114 { 115 notify_notification_close(n, NULL); 116 } 117 } 111 118 } 112 119 … … 118 125 119 126 DBusGConnection * 120 get_dbus_g_conn(void)127 _notify_get_dbus_g_conn(void) 121 128 { 122 129 return _dbus_gconn; … … 124 131 125 132 DBusGProxy * 126 get_g_proxy(void)133 _notify_get_g_proxy(void) 127 134 { 128 135 return _proxy; … … 135 142 char **caps = NULL, **cap; 136 143 GList *result = NULL; 137 DBusGProxy *proxy = get_g_proxy();144 DBusGProxy *proxy = _notify_get_g_proxy(); 138 145 139 146 g_return_val_if_fail(proxy != NULL, NULL); … … 163 170 { 164 171 GError *error = NULL; 165 DBusGProxy *proxy = get_g_proxy();172 DBusGProxy *proxy = _notify_get_g_proxy(); 166 173 char *name, *vendor, *version, *spec_version; 167 174 … … 194 201 return TRUE; 195 202 } 203 204 void 205 _notify_cache_add_notification(NotifyNotification *n) 206 { 207 _active_notifications = g_list_prepend(_active_notifications, n); 208 } 209 210 void 211 _notify_cache_remove_notification(NotifyNotification *n) 212 { 213 _active_notifications = g_list_remove(_active_notifications, n); 214 } trunk/libnotify/tests/test-replace-widget.c
r2391 r2477 42 42 43 43 window = gtk_window_new(GTK_WINDOW_TOPLEVEL); 44 g_signal_connect(G_OBJECT(window), "delete_event", 45 G_CALLBACK(gtk_main_quit), NULL); 46 44 47 button = gtk_button_new_with_label("click here to change notification"); 45 48 gtk_container_add(GTK_CONTAINER(window), button);
