Mercurial > pidgin
comparison src/gtkstatusbox.c @ 12125:3c1bac709234
[gaim-migrate @ 14425]
Change /core/savedstatus/current and /core/savedstatus/idleaway
to ints (they used to be strings, where the value was the title of a
GaimSavedStatus).
The value is now equal to the "creation" timestamp of a saved_status.
The creation timestamp is used as the unique key. The primary reason
for this is to allow for saved statuses to have NULL titles. NULL titles
are needed for transient statuses. I also added a "last_used" timestamp.
This all paves the way for keeping track of recently used statuses
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 18 Nov 2005 07:23:29 +0000 |
parents | 355c7acbb61d |
children | 152748df85cf |
comparison
equal
deleted
inserted
replaced
12124:9c123e27e2f6 | 12125:3c1bac709234 |
---|---|
304 * keyboard signals instead of the changed signal? | 304 * keyboard signals instead of the changed signal? |
305 */ | 305 */ |
306 static void | 306 static void |
307 update_to_reflect_current_status(GtkGaimStatusBox *status_box) | 307 update_to_reflect_current_status(GtkGaimStatusBox *status_box) |
308 { | 308 { |
309 const char *current_savedstatus_name; | |
310 GaimSavedStatus *saved_status; | 309 GaimSavedStatus *saved_status; |
310 GaimStatusPrimitive primitive; | |
311 const char *message; | |
311 | 312 |
312 /* this function is inappropriate for ones with accounts */ | 313 /* this function is inappropriate for ones with accounts */ |
313 if (status_box->account) | 314 if (status_box->account) |
314 return; | 315 return; |
315 | 316 |
316 current_savedstatus_name = gaim_prefs_get_string("/core/savedstatus/current"); | 317 saved_status = gaim_savedstatus_get_current(); |
317 saved_status = gaim_savedstatus_find(current_savedstatus_name); | |
318 | 318 |
319 /* | 319 /* |
320 * Suppress the "changed" signal because the status | 320 * Suppress the "changed" signal because the status |
321 * was changed programmatically. | 321 * was changed programmatically. |
322 */ | 322 */ |
323 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); | 323 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE); |
324 | 324 |
325 if (saved_status == NULL) | 325 primitive = gaim_savedstatus_get_type(saved_status); |
326 { | 326 if (gaim_savedstatus_has_substatuses(saved_status) || |
327 /* Default to "available" */ | 327 ((primitive != GAIM_STATUS_AVAILABLE) && |
328 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | 328 (primitive != GAIM_STATUS_OFFLINE) && |
329 (primitive != GAIM_STATUS_AWAY) && | |
330 (primitive != GAIM_STATUS_HIDDEN))) | |
331 { | |
332 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 5); | |
329 } | 333 } |
330 else | 334 else |
331 { | 335 { |
332 GaimStatusPrimitive primitive; | 336 if (primitive == GAIM_STATUS_AVAILABLE) |
333 const char *message; | 337 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); |
334 | 338 if (primitive == GAIM_STATUS_OFFLINE) |
335 primitive = gaim_savedstatus_get_type(saved_status); | 339 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); |
336 if (gaim_savedstatus_has_substatuses(saved_status) || | 340 else if (primitive == GAIM_STATUS_AWAY) |
337 ((primitive != GAIM_STATUS_AVAILABLE) && | 341 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); |
338 (primitive != GAIM_STATUS_OFFLINE) && | 342 else if (primitive == GAIM_STATUS_HIDDEN) |
339 (primitive != GAIM_STATUS_AWAY) && | 343 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); |
340 (primitive != GAIM_STATUS_HIDDEN))) | 344 } |
341 { | 345 |
342 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 5); | 346 message = gaim_savedstatus_get_message(saved_status); |
343 } | 347 if (!message || !*message) |
344 else | 348 { |
345 { | 349 status_box->imhtml_visible = FALSE; |
346 if (primitive == GAIM_STATUS_AVAILABLE) | 350 gtk_widget_hide_all(status_box->vbox); |
347 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); | 351 } |
348 if (primitive == GAIM_STATUS_OFFLINE) | 352 else |
349 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 3); | 353 { |
350 else if (primitive == GAIM_STATUS_AWAY) | 354 status_box->imhtml_visible = TRUE; |
351 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 1); | 355 gtk_widget_show_all(status_box->vbox); |
352 else if (primitive == GAIM_STATUS_HIDDEN) | 356 |
353 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); | 357 /* |
354 } | 358 * Suppress the "changed" signal because the status |
355 | 359 * was changed programmatically. |
356 message = gaim_savedstatus_get_message(saved_status); | 360 */ |
357 if (!message || !*message) | 361 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); |
358 { | 362 |
359 status_box->imhtml_visible = FALSE; | 363 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); |
360 gtk_widget_hide_all(status_box->vbox); | 364 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); |
361 } | 365 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); |
362 else | |
363 { | |
364 status_box->imhtml_visible = TRUE; | |
365 gtk_widget_show_all(status_box->vbox); | |
366 | |
367 /* | |
368 * Suppress the "changed" signal because the status | |
369 * was changed programmatically. | |
370 */ | |
371 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE); | |
372 | |
373 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); | |
374 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); | |
375 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE); | |
376 } | |
377 } | 366 } |
378 | 367 |
379 /* Stop suppressing the "changed" signal. */ | 368 /* Stop suppressing the "changed" signal. */ |
380 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); | 369 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE); |
381 } | 370 } |
813 * update_to_reflect_current_status() | 802 * update_to_reflect_current_status() |
814 */ | 803 */ |
815 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES)) | 804 if ((type < 0) || (type >= GAIM_STATUS_NUM_PRIMITIVES)) |
816 return; | 805 return; |
817 | 806 |
818 /* TODO: Should save the previous status as a transient status? */ | |
819 | |
820 if (status_box->account) { | 807 if (status_box->account) { |
821 gint active; | 808 gint active; |
822 GaimStatusType *status_type; | 809 GaimStatusType *status_type; |
823 GaimStatus *status; | 810 GaimStatus *status; |
824 const char *id = NULL; | 811 const char *id = NULL; |
846 gaim_account_set_status(status_box->account, id, | 833 gaim_account_set_status(status_box->account, id, |
847 TRUE, NULL); | 834 TRUE, NULL); |
848 } | 835 } |
849 } else { | 836 } else { |
850 /* Save the newly selected status to prefs.xml and status.xml */ | 837 /* Save the newly selected status to prefs.xml and status.xml */ |
851 /* TODO: This should be saved as transient. */ | |
852 const char *current = NULL; | |
853 | 838 |
854 /* Has the status been really changed? */ | 839 /* Has the status been really changed? */ |
855 current = gaim_prefs_get_string("/core/savedstatus/current"); | 840 saved_status = gaim_savedstatus_get_current(); |
856 saved_status = gaim_savedstatus_find(current); | 841 if (gaim_savedstatus_get_type(saved_status) == type) |
857 if (saved_status && gaim_savedstatus_get_type(saved_status) == type) | |
858 { | 842 { |
859 if (!message_changed(gaim_savedstatus_get_message(saved_status), message)) | 843 if (!message_changed(gaim_savedstatus_get_message(saved_status), message)) |
860 changed = FALSE; | 844 changed = FALSE; |
861 } | 845 } |
862 | 846 |
863 if (changed) | 847 if (changed) |
864 { | 848 { |
865 saved_status = gaim_savedstatus_find(_("Default")); | 849 /* Create a new transient saved status */ |
866 if (saved_status == NULL) | 850 saved_status = gaim_savedstatus_new(NULL, type); |
867 saved_status = gaim_savedstatus_new(_("Default"), type); | |
868 gaim_savedstatus_set_type(saved_status, type); | 851 gaim_savedstatus_set_type(saved_status, type); |
869 gaim_savedstatus_set_message(saved_status, message); | 852 gaim_savedstatus_set_message(saved_status, message); |
870 | 853 |
871 /* Set the status for each account */ | 854 /* Set the status for each account */ |
872 gaim_savedstatus_activate(saved_status); | 855 gaim_savedstatus_activate(saved_status); |