Changeset 2512
- Timestamp:
- 01/29/06 13:07:46
- Files:
-
- trunk/notification-daemon/ChangeLog (modified) (1 diff)
- trunk/notification-daemon/src/daemon.c (modified) (6 diffs)
- trunk/notification-daemon/src/engines.c (modified) (4 diffs)
- trunk/notification-daemon/themes/standard/theme.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/notification-daemon/ChangeLog
r2511 r2512 1 Sun Jan 29 13:03:09 PST 2006 Christian Hammond <chipx86@chipx86.com> 2 3 * src/daemon.c: 4 * src/engines.c: 5 * themes/standard/theme.c: 6 - Patch by Michael Vogt and modified a bit by me to add a close 7 button to notifications. This is similar to the one used in Ubuntu 8 Dapper, with a small placement change and functionality change: the 9 notification no longer emits the ActionInvoked for the default action 10 when closed. This closes ticket #8. 11 - Moved data freeing for the standard theme and for theme engine 12 unreffing out of the close functions and into a callback specified 13 through g_object_set_data_full(). 14 - The daemon now listens for when notification windows are destroyed, 15 and reacts appropriately, instead of crashing. 16 1 17 Sun Jan 29 12:12:43 PST 2006 Christian Hammond <chipx86@chipx86.com> 2 18 trunk/notification-daemon/src/daemon.c
r2497 r2512 231 231 232 232 static void 233 _close_notification(NotifyDaemon *daemon, guint id )233 _close_notification(NotifyDaemon *daemon, guint id, gboolean hide_notification) 234 234 { 235 235 NotifyDaemonPrivate *priv = daemon->priv; … … 242 242 _emit_closed_signal(G_OBJECT(nt->nw)); 243 243 244 theme_hide_notification(nt->nw); 244 if (hide_notification) 245 theme_hide_notification(nt->nw); 246 245 247 g_hash_table_remove(priv->notification_hash, &id); 246 248 } 249 } 250 251 static void 252 _notification_destroyed_cb(GtkWindow *nw, NotifyDaemon *daemon) 253 { 254 _close_notification( 255 daemon, 256 GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")), 257 FALSE); 247 258 } 248 259 … … 526 537 _action_invoked_cb(nw, "default"); 527 538 528 _close_notification(daemon, 529 GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id"))); 539 _close_notification( 540 daemon, 541 GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(nw), "_notify_id")), 542 TRUE); 530 543 } 531 544 … … 819 832 g_object_set_data(G_OBJECT(nw), "_notify_daemon", daemon); 820 833 new_notification = TRUE; 834 835 g_signal_connect(G_OBJECT(nw), "button-release-event", 836 G_CALLBACK(window_clicked_cb), daemon); 837 g_signal_connect(G_OBJECT(nw), "destroy", 838 G_CALLBACK(_notification_destroyed_cb), daemon); 821 839 } 822 840 … … 930 948 } 931 949 932 g_signal_connect(G_OBJECT(nw), "button-release-event",933 G_CALLBACK(window_clicked_cb), daemon);934 935 936 950 if (!screensaver_active(GTK_WIDGET(nw)) && 937 951 !fullscreen_window_exists(GTK_WIDGET(nw))) … … 966 980 guint id, GError ** error) 967 981 { 968 _close_notification(daemon, id );982 _close_notification(daemon, id, TRUE); 969 983 970 984 return TRUE; trunk/notification-daemon/src/engines.c
r2446 r2512 40 40 g_free(filename); 41 41 42 printf("Loading path '%s'\n", path);43 42 engine = g_new0(ThemeEngine, 1); 44 43 engine->ref_count = 1; … … 146 145 } 147 146 147 static void 148 theme_engine_unref(ThemeEngine *engine) 149 { 150 engine->ref_count--; 151 152 if (engine->ref_count == 0) 153 destroy_engine(engine); 154 } 155 148 156 GtkWindow * 149 157 theme_create_notification(UrlClickedCb url_clicked_cb) … … 151 159 ThemeEngine *engine = get_theme_engine(); 152 160 GtkWindow *nw = engine->create_notification(url_clicked_cb); 153 g_object_set_data(G_OBJECT(nw), "_theme_engine", engine); 161 g_object_set_data_full(G_OBJECT(nw), "_theme_engine", engine, 162 (GDestroyNotify)theme_engine_unref); 154 163 engine->ref_count++; 155 164 return nw; … … 161 170 ThemeEngine *engine = g_object_get_data(G_OBJECT(nw), "_theme_engine"); 162 171 engine->destroy_notification(nw); 163 164 engine->ref_count--;165 166 if (engine->ref_count == 0)167 destroy_engine(engine);168 172 } 169 173 trunk/notification-daemon/themes/standard/theme.c
r2467 r2512 83 83 } 84 84 85 static void 86 destroy_windata(WindowData *windata) 87 { 88 if (windata->gc != NULL) 89 g_object_unref(G_OBJECT(windata->gc)); 90 91 if (windata->border_points != NULL) 92 g_free(windata->border_points); 93 94 if (windata->window_region != NULL) 95 gdk_region_destroy(windata->window_region); 96 } 97 85 98 GtkWindow * 86 99 create_notification(UrlClickedCb url_clicked) … … 89 102 GtkWidget *main_vbox; 90 103 GtkWidget *hbox; 104 GtkWidget *hbox2; 91 105 GtkWidget *vbox; 106 GtkWidget *close_button; 107 GtkWidget *image; 92 108 GtkRequisition req; 93 109 WindowData *windata; … … 98 114 win = gtk_window_new(GTK_WINDOW_POPUP); 99 115 gtk_widget_add_events(win, GDK_BUTTON_RELEASE_MASK); 100 g_object_set_data(G_OBJECT(win), "windata", windata); 116 g_object_set_data_full(G_OBJECT(win), "windata", windata, 117 (GDestroyNotify)destroy_windata); 101 118 gtk_widget_set_app_paintable(win, TRUE); 102 119 … … 144 161 gtk_container_set_border_width(GTK_CONTAINER(vbox), 10); 145 162 163 hbox2 = gtk_hbox_new(FALSE, 6); 164 gtk_widget_show(hbox2); 165 gtk_box_pack_start(GTK_BOX(vbox), hbox2, FALSE, FALSE, 0); 166 146 167 windata->summary_label = gtk_label_new(NULL); 147 168 gtk_widget_show(windata->summary_label); 148 gtk_box_pack_start(GTK_BOX( vbox), windata->summary_label, FALSE, FALSE, 0);169 gtk_box_pack_start(GTK_BOX(hbox2), windata->summary_label, TRUE, TRUE, 0); 149 170 gtk_misc_set_alignment(GTK_MISC(windata->summary_label), 0, 0); 150 171 gtk_label_set_line_wrap(GTK_LABEL(windata->summary_label), TRUE); 172 173 /* Add the close button */ 174 close_button = gtk_button_new(); 175 gtk_widget_show(close_button); 176 gtk_box_pack_start(GTK_BOX(hbox2), close_button, FALSE, FALSE, 0); 177 gtk_button_set_relief(GTK_BUTTON(close_button), GTK_RELIEF_NONE); 178 gtk_container_set_border_width(GTK_CONTAINER(close_button), 0); 179 gtk_widget_set_size_request(close_button, 20, 20); 180 g_signal_connect_swapped(G_OBJECT(close_button), "clicked", 181 G_CALLBACK(gtk_widget_destroy), win); 182 183 image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); 184 gtk_widget_show(image); 185 gtk_container_add(GTK_CONTAINER(close_button), image); 151 186 152 187 windata->body_label = sexy_url_label_new(); … … 171 206 destroy_notification(GtkWindow *nw) 172 207 { 173 WindowData *windata = g_object_get_data(G_OBJECT(nw), "windata");174 g_assert(windata != NULL);175 176 if (windata->gc != NULL)177 g_object_unref(G_OBJECT(windata->gc));178 179 if (windata->border_points != NULL)180 g_free(windata->border_points);181 182 if (windata->window_region != NULL)183 gdk_region_destroy(windata->window_region);184 185 208 gtk_widget_destroy(GTK_WIDGET(nw)); 186 209 }
