Mercurial > pidgin.yaz
comparison plugins/docklet/docklet.c @ 3570:b791019b2492
[gaim-migrate @ 3666]
You win, McQueen.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 29 Sep 2002 04:48:40 +0000 |
parents | cf00549c53d7 |
children | 3e47ffcbf805 |
comparison
equal
deleted
inserted
replaced
3569:d6468f276d24 | 3570:b791019b2492 |
---|---|
61 | 61 |
62 static void docklet_toggle_queue(GtkWidget *widget, void *data) { | 62 static void docklet_toggle_queue(GtkWidget *widget, void *data) { |
63 away_options ^= OPT_AWAY_QUEUE_UNREAD; | 63 away_options ^= OPT_AWAY_QUEUE_UNREAD; |
64 save_prefs(); | 64 save_prefs(); |
65 } | 65 } |
66 | 66 |
67 /* static void docklet_toggle_blist_show(GtkWidget *widget, void *data) { | |
68 blist_options ^= OPT_BLIST_APP_BUDDY_SHOW; | |
69 save_prefs(); | |
70 } */ | |
71 | |
67 static void docklet_flush_queue() { | 72 static void docklet_flush_queue() { |
68 purge_away_queue(unread_message_queue); | 73 if (unread_message_queue) { |
69 unread_message_queue = NULL; | 74 purge_away_queue(unread_message_queue); |
75 unread_message_queue = NULL; | |
76 } | |
70 } | 77 } |
71 | 78 |
72 static void docklet_menu(GdkEventButton *event) { | 79 static void docklet_menu(GdkEventButton *event) { |
73 static GtkWidget *menu = NULL; | 80 static GtkWidget *menu = NULL; |
74 GtkWidget *entry; | 81 GtkWidget *entry; |
156 | 163 |
157 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) { | 164 static void docklet_clicked(GtkWidget *button, GdkEventButton *event, void *data) { |
158 switch (event->button) { | 165 switch (event->button) { |
159 case 1: | 166 case 1: |
160 if (unread_message_queue) { | 167 if (unread_message_queue) { |
161 docklet_flush_queue(); | 168 docklet_flush_queue(); |
162 docklet_update_status(); | 169 docklet_update_status(); |
163 } | 170 } else { |
164 else { | |
165 docklet_toggle(); | 171 docklet_toggle(); |
166 } | 172 } |
167 break; | 173 break; |
168 case 2: | 174 case 2: |
169 break; | 175 break; |
185 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "away.png", NULL); | 191 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "away.png", NULL); |
186 break; | 192 break; |
187 case away_pending: | 193 case away_pending: |
188 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgpend.png", NULL); | 194 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgpend.png", NULL); |
189 break; | 195 break; |
190 case unread_pending: | 196 case unread_pending: |
191 /* XXX MAKE ME BLINK! */ | |
192 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgunread.png", NULL); | 197 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "msgunread.png", NULL); |
193 break; | 198 break; |
194 case connecting: | 199 case connecting: |
195 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "connect.png", NULL); | 200 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "connect.png", NULL); |
196 break; | 201 break; |
247 docklet_update_icon(); | 252 docklet_update_icon(); |
248 } | 253 } |
249 } | 254 } |
250 | 255 |
251 static void docklet_embedded(GtkWidget *widget, void *data) { | 256 static void docklet_embedded(GtkWidget *widget, void *data) { |
252 debug_printf("Docklet: embedded\n"); | 257 debug_printf("Docklet: embedded\n"); |
253 docklet_add(); | 258 docklet_add(); |
254 } | 259 } |
255 | 260 |
256 static void docklet_destroyed(GtkWidget *widget, void *data) { | 261 static void docklet_destroyed(GtkWidget *widget, void *data) { |
257 debug_printf("Docklet: destroyed\n"); | 262 debug_printf("Docklet: destroyed\n"); |
258 docklet_flush_queue(); | 263 docklet_flush_queue(); |
259 docklet_remove(); | 264 docklet_remove(); |
260 docklet_create(); | 265 docklet_create(); |
261 } | 266 } |
262 | 267 |
263 static void docklet_create() { | 268 static void docklet_create() { |
264 GtkWidget *box; | 269 GtkWidget *box; |
265 | 270 |
266 if (docklet) { | 271 if (docklet) { |
267 /* if this is being called when a docklet exists, it's because that | 272 /* if this is being called when a docklet exists, it's because that |
268 docklet is in the process of being destroyed. all we need to do | 273 docklet is in the process of being destroyed. all we need to do |
269 is tell gobject we're not interested in it any more, and throw | 274 is tell gobject we're not interested in it any more, and throw |
270 the pointer away. Alan Cox said so. */ | 275 the pointer away. */ |
271 | 276 g_object_unref(G_OBJECT(docklet)); |
272 /* Ooooh, look at me! I'm Robot101! I know Alan Cox! I talk to him | 277 docklet = NULL; |
273 all the time! I'm sooooo special! --Sean Egan */ | |
274 g_object_unref(G_OBJECT(docklet)); | |
275 docklet = NULL; | |
276 } | 278 } |
277 | 279 |
278 docklet = egg_tray_icon_new("Gaim"); | 280 docklet = egg_tray_icon_new("Gaim"); |
279 box = gtk_event_box_new(); | 281 box = gtk_event_box_new(); |
280 icon = gtk_image_new(); | 282 icon = gtk_image_new(); |
310 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) { | 312 static void gaim_away(struct gaim_connection *gc, char *state, char *message, void *data) { |
311 /* we only support global away. this is the way it is, ok? */ | 313 /* we only support global away. this is the way it is, ok? */ |
312 docklet_update_status(); | 314 docklet_update_status(); |
313 } | 315 } |
314 | 316 |
315 static void gaim_im_recv(struct gaim_connection *gc, char **who, char **what, void *data) { | 317 static void gaim_im_displayed_recv(struct gaim_connection *gc, char **who, char **what, void *data) { |
316 /* if message queuing while away is enabled, this event could be the first | 318 /* if message queuing while away is enabled, this event could be the first |
317 message so we need to see if the status (and hence icon) needs changing */ | 319 message so we need to see if the status (and hence icon) needs changing */ |
318 docklet_update_status(); | 320 docklet_update_status(); |
319 } | 321 } |
320 | 322 |
321 static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) { | 323 /* static void gaim_buddy_signon(struct gaim_connection *gc, char *who, void *data) { |
322 } | 324 } |
323 | 325 |
324 static void gaim_buddy_signoff(struct gaim_connection *gc, char *who, void *data) { | 326 static void gaim_buddy_signoff(struct gaim_connection *gc, char *who, void *data) { |
325 } | 327 } |
326 | 328 |
329 | 331 |
330 static void gaim_buddy_back(struct gaim_connection *gc, char *who, void *data) { | 332 static void gaim_buddy_back(struct gaim_connection *gc, char *who, void *data) { |
331 } | 333 } |
332 | 334 |
333 static void gaim_new_conversation(char *who, void *data) { | 335 static void gaim_new_conversation(char *who, void *data) { |
334 } | 336 } */ |
335 | 337 |
336 char *gaim_plugin_init(GModule *handle) { | 338 char *gaim_plugin_init(GModule *handle) { |
337 docklet_create(); | 339 docklet_create(); |
338 | 340 |
339 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); | 341 gaim_signal_connect(handle, event_signon, gaim_signon, NULL); |
340 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); | 342 gaim_signal_connect(handle, event_signoff, gaim_signoff, NULL); |
341 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); | 343 gaim_signal_connect(handle, event_connecting, gaim_connecting, NULL); |
342 gaim_signal_connect(handle, event_away, gaim_away, NULL); | 344 gaim_signal_connect(handle, event_away, gaim_away, NULL); |
343 gaim_signal_connect(handle, event_im_displayed_rcvd, gaim_im_recv, NULL); | 345 gaim_signal_connect(handle, event_im_displayed_rcvd, gaim_im_displayed_recv, NULL); |
344 gaim_signal_connect(handle, event_im_recv, gaim_im_recv, NULL); | 346 /* gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL); |
345 gaim_signal_connect(handle, event_buddy_signon, gaim_buddy_signon, NULL); | |
346 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL); | 347 gaim_signal_connect(handle, event_buddy_signoff, gaim_buddy_signoff, NULL); |
347 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL); | 348 gaim_signal_connect(handle, event_buddy_away, gaim_buddy_away, NULL); |
348 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL); | 349 gaim_signal_connect(handle, event_buddy_back, gaim_buddy_back, NULL); |
349 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); | 350 gaim_signal_connect(handle, event_new_conversation, gaim_new_conversation, NULL); */ |
350 | 351 |
351 return NULL; | 352 return NULL; |
352 } | 353 } |
353 | 354 |
354 void gaim_plugin_remove() { | 355 void gaim_plugin_remove() { |
355 if (GTK_WIDGET_VISIBLE(docklet)) { | 356 if (GTK_WIDGET_VISIBLE(docklet)) { |
356 docklet_remove(); | 357 docklet_remove(); |
357 } | 358 } |
358 | 359 |
359 docklet_flush_queue(); | 360 docklet_flush_queue(); |
360 | 361 |
361 g_object_unref(G_OBJECT(docklet)); | 362 g_object_unref(G_OBJECT(docklet)); |
362 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); | 363 g_signal_handlers_disconnect_by_func(G_OBJECT(docklet), G_CALLBACK(docklet_destroyed), NULL); |
363 gtk_widget_destroy(GTK_WIDGET(docklet)); | 364 gtk_widget_destroy(GTK_WIDGET(docklet)); |
364 | 365 |
365 debug_printf("Docklet: removed\n"); | 366 debug_printf("Docklet: removed\n"); |
366 } | 367 } |
367 | 368 |
368 static void config_close() { | 369 GtkWidget *gaim_plugin_config_gtk() { |
369 configwin = NULL; | 370 GtkWidget *frame; |
370 } | 371 GtkWidget *vbox, *hbox; |
371 | 372 GtkWidget *toggle; |
372 void gaim_plugin_config() { | 373 |
373 /* This is the sorriest dialog ever written ever */ | 374 frame = gtk_vbox_new(FALSE, 18); |
374 /* It's a good thing I plan on rewriting it later tonight */ | 375 gtk_container_set_border_width(GTK_CONTAINER(frame), 12); |
375 GtkWidget *button; | 376 |
376 GtkWidget *vbox; | 377 vbox = make_frame(frame, _("Docklet Configuration")); |
377 | 378 hbox = gtk_hbox_new(FALSE, 18); |
378 if (configwin) | 379 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
379 return; | 380 |
380 GAIM_DIALOG(configwin); | 381 /* toggle = gtk_check_button_new_with_mnemonic(_("_Automatically show buddy list on sign on")); |
381 g_signal_connect(G_OBJECT(configwin), "destroy", GTK_SIGNAL_FUNC(config_close), NULL); | 382 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), blist_options & OPT_BLIST_APP_BUDDY_SHOW); |
382 | 383 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_blist_show), NULL); |
383 vbox = gtk_vbox_new(0, 6); | 384 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); */ |
384 gtk_container_add(GTK_CONTAINER(configwin), vbox); | 385 |
385 gtk_window_set_title(GTK_WINDOW(configwin), "Docklet Configuration"); | 386 toggle = gtk_check_button_new_with_mnemonic(_("_Hide new messages until docklet is clicked")); |
386 | 387 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle), away_options & OPT_AWAY_QUEUE_UNREAD); |
387 button = gtk_check_button_new_with_mnemonic("_Hide new messages until docklet is clicked"); | 388 g_signal_connect(G_OBJECT(toggle), "clicked", G_CALLBACK(docklet_toggle_queue), NULL); |
388 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(button), away_options & OPT_AWAY_QUEUE_UNREAD); | 389 gtk_box_pack_start(GTK_BOX(vbox), toggle, FALSE, FALSE, 0); |
389 g_signal_connect(G_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(docklet_toggle_queue), NULL); | 390 |
390 gtk_box_pack_end(GTK_BOX(vbox), button, 0, 0, 0); | 391 gtk_widget_show_all(frame); |
391 | 392 return frame; |
392 gtk_widget_show_all(configwin); | 393 } |
393 } | 394 |
394 | |
395 struct gaim_plugin_description desc; | 395 struct gaim_plugin_description desc; |
396 struct gaim_plugin_description *gaim_plugin_desc() { | 396 struct gaim_plugin_description *gaim_plugin_desc() { |
397 desc.api_version = PLUGIN_API_VERSION; | 397 desc.api_version = PLUGIN_API_VERSION; |
398 desc.name = g_strdup("System Tray Docklet"); | 398 desc.name = g_strdup(_("System Tray Docklet")); |
399 desc.version = g_strdup(VERSION); | 399 desc.version = g_strdup(VERSION); |
400 desc.description = g_strdup("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window."); | 400 desc.description = g_strdup(_("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window.")); |
401 desc.authors = g_strdup("Robert McQueen <robot101@debian.org>"); | 401 desc.authors = g_strdup(_("Robert McQueen <robot101@debian.org>")); |
402 desc.url = g_strdup(WEBSITE); | 402 desc.url = g_strdup(WEBSITE); |
403 return &desc; | 403 return &desc; |
404 } | 404 } |
405 | 405 |
406 | 406 char *name() { |
407 const char *name() { | |
408 return _("System Tray Docklet"); | 407 return _("System Tray Docklet"); |
409 } | 408 } |
410 | 409 |
411 const char *description() { | 410 char *description() { |
412 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window."); | 411 return _("Interacts with a System Tray applet (in GNOME or KDE, for example) to display the current status of Gaim, allow fast access to commonly used functions, and to toggle display of the buddy list or login window."); |
413 } | 412 } |