comparison src/gtkstatusbox.c @ 11951:b6fa01513d76

[gaim-migrate @ 14242] sf patch #1343345, from Sadrul Habib Chowdhury This is a pretty rockin' patch that makes our statusbox not emit the changed signal when we set the status programatically. It fixes "gaim -n" and selecting either of the saved status options committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Wed, 02 Nov 2005 05:14:35 +0000
parents f1ada7870fae
children 351f4dd75718
comparison
equal deleted inserted replaced
11950:2b9ca8861ca5 11951:b6fa01513d76
287 const char *current_savedstatus_name; 287 const char *current_savedstatus_name;
288 GaimSavedStatus *saved_status; 288 GaimSavedStatus *saved_status;
289 289
290 current_savedstatus_name = gaim_prefs_get_string("/core/status/current"); 290 current_savedstatus_name = gaim_prefs_get_string("/core/status/current");
291 saved_status = gaim_savedstatus_find(current_savedstatus_name); 291 saved_status = gaim_savedstatus_find(current_savedstatus_name);
292
293 /*
294 * Suppress the "changed" signal because the status
295 * was changed programmatically.
296 */
297 gtk_widget_set_sensitive(GTK_WIDGET(status_box), FALSE);
298
292 if (saved_status == NULL) 299 if (saved_status == NULL)
293 { 300 {
294 /* Default to "available" */ 301 /* Default to "available" */
295 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0); 302 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 0);
296 } 303 }
320 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2); 327 gtk_combo_box_set_active(GTK_COMBO_BOX(status_box), 2);
321 } 328 }
322 329
323 message = gaim_savedstatus_get_message(saved_status); 330 message = gaim_savedstatus_get_message(saved_status);
324 if (message != NULL) 331 if (message != NULL)
332 {
333 /*
334 * Suppress the "changed" signal because the status
335 * was changed programmatically.
336 */
337 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), FALSE);
325 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0); 338 gtk_imhtml_append_text(GTK_IMHTML(status_box->imhtml), message, 0);
326 } 339 gtk_widget_set_sensitive(GTK_WIDGET(status_box->imhtml), TRUE);
340 }
341 }
342
343 /* Stop suppressing the "changed" signal. */
344 gtk_widget_set_sensitive(GTK_WIDGET(status_box), TRUE);
327 } 345 }
328 346
329 static void 347 static void
330 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box) 348 gtk_gaim_status_box_regenerate(GtkGaimStatusBox *status_box)
331 { 349 {
657 gchar *title; 675 gchar *title;
658 GtkTreeIter iter; 676 GtkTreeIter iter;
659 char *message; 677 char *message;
660 GaimSavedStatus *saved_status; 678 GaimSavedStatus *saved_status;
661 679
662 gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter); 680 if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(status_box), &iter))
681 return;
663 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter, 682 gtk_tree_model_get(GTK_TREE_MODEL(status_box->dropdown_store), &iter,
664 TYPE_COLUMN, &type, 683 TYPE_COLUMN, &type,
665 TITLE_COLUMN, &title, -1); 684 TITLE_COLUMN, &title, -1);
666 message = gtk_gaim_status_box_get_message(status_box); 685 message = gtk_gaim_status_box_get_message(status_box);
667 686
726 status_box->pixbuf = pixbuf; 745 status_box->pixbuf = pixbuf;
727 if (status_box->typing) 746 if (status_box->typing)
728 g_source_remove(status_box->typing); 747 g_source_remove(status_box->typing);
729 status_box->typing = 0; 748 status_box->typing = 0;
730 749
731 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM) 750 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
732 { 751 {
733 gaim_gtk_status_editor_show(NULL); 752 if (type == GTK_GAIM_STATUS_BOX_TYPE_CUSTOM)
734 update_to_reflect_current_status(status_box); 753 {
735 return; 754 gaim_gtk_status_editor_show(NULL);
736 } 755 update_to_reflect_current_status(status_box);
737 756 return;
738 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED) 757 }
739 { 758
740 gaim_gtk_status_window_show(); 759 if (type == GTK_GAIM_STATUS_BOX_TYPE_SAVED)
741 update_to_reflect_current_status(status_box); 760 {
742 return; 761 gaim_gtk_status_window_show();
762 update_to_reflect_current_status(status_box);
763 return;
764 }
743 } 765 }
744 766
745 /* 767 /*
746 * Show the message box whenever 'type' allows for a 768 * Show the message box whenever 'type' allows for a
747 * message attribute on any protocol that is enabled. 769 * message attribute on any protocol that is enabled.
765 g_list_free(accounts); 787 g_list_free(accounts);
766 788
767 if (status_box->imhtml_visible) 789 if (status_box->imhtml_visible)
768 { 790 {
769 gtk_widget_show_all(status_box->vbox); 791 gtk_widget_show_all(status_box->vbox);
770 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box); 792 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
793 status_box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, status_box);
771 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml)); 794 gtk_imhtml_clear(GTK_IMHTML(status_box->imhtml));
772 gtk_widget_grab_focus(status_box->imhtml); 795 gtk_widget_grab_focus(status_box->imhtml);
773 } 796 }
774 else 797 else
775 { 798 {
776 gtk_widget_hide_all(status_box->vbox); 799 gtk_widget_hide_all(status_box->vbox);
777 activate_currently_selected_status(status_box); 800 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(status_box)))
801 activate_currently_selected_status(status_box);
778 } 802 }
779 gtk_gaim_status_box_refresh(status_box); 803 gtk_gaim_status_box_refresh(status_box);
780 } 804 }
781 805
782 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data) 806 static void imhtml_changed_cb(GtkTextBuffer *buffer, void *data)
783 { 807 {
784 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data; 808 GtkGaimStatusBox *box = (GtkGaimStatusBox*)data;
785 if (box->typing) { 809 if (GTK_WIDGET_IS_SENSITIVE(GTK_WIDGET(box)))
786 gtk_gaim_status_box_pulse_typing(box); 810 {
787 g_source_remove(box->typing); 811 if (box->typing) {
788 } 812 gtk_gaim_status_box_pulse_typing(box);
789 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box); 813 g_source_remove(box->typing);
814 }
815 box->typing = g_timeout_add(3000, (GSourceFunc)remove_typing_cb, box);
816 }
790 gtk_gaim_status_box_refresh(box); 817 gtk_gaim_status_box_refresh(box);
791 } 818 }
792 819
793 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box) 820 GtkGaimStatusBoxItemType gtk_gaim_status_box_get_active_type(GtkGaimStatusBox *status_box)
794 { 821 {