Mercurial > pidgin
comparison finch/gntsound.c @ 19160:fbecc35c23bb
Profiles now work with the new layout
author | Eric Polino <aluink@pidgin.im> |
---|---|
date | Thu, 12 Jul 2007 23:37:35 +0000 |
parents | 67fc276e5332 |
children | 4521c558796e |
comparison
equal
deleted
inserted
replaced
19159:67fc276e5332 | 19160:fbecc35c23bb |
---|---|
279 g_source_remove(mute_login_sounds_timeout); | 279 g_source_remove(mute_login_sounds_timeout); |
280 mute_login_sounds = TRUE; | 280 mute_login_sounds = TRUE; |
281 mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL); | 281 mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL); |
282 } | 282 } |
283 | 283 |
284 static void * | 284 void * |
285 finch_sound_get_handle() | 285 finch_sound_get_handle() |
286 { | 286 { |
287 static int handle; | 287 static int handle; |
288 | 288 |
289 return &handle; | 289 return &handle; |
617 finch_sound_set_active_profile(const char *name) | 617 finch_sound_set_active_profile(const char *name) |
618 { | 618 { |
619 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name); | 619 purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name); |
620 } | 620 } |
621 | 621 |
622 gboolean | |
623 finch_sound_profile_exists(const char *name){ | |
624 gchar * tmp; | |
625 gboolean ret = purple_prefs_exists(tmp = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s",name)); | |
626 g_free(tmp); | |
627 return ret; | |
628 } | |
622 | 629 |
623 static void | 630 static void |
624 save_cb(GntWidget *button, gpointer win) | 631 save_cb(GntWidget *button, gpointer win) |
625 { | 632 { |
626 GList * itr; | 633 GList * itr; |
773 gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref)); | 780 gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref)); |
774 | 781 |
775 g_free(boolpref); | 782 g_free(boolpref); |
776 } | 783 } |
777 | 784 |
778 /* Can someone double check to make sure there isn't a leak in the way I'm keeping | 785 gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles),(gchar *)finch_sound_get_active_profile()); |
779 * track of thest profile suggests in the entry. Thanks! | 786 |
780 */ | |
781 gnt_widget_draw(pref_dialog->window); | 787 gnt_widget_draw(pref_dialog->window); |
782 } | 788 } |
783 | 789 |
784 static void | 790 static void |
785 reload_pref_window(const char *profile) | 791 reload_pref_window(const char *profile) |
792 | 798 |
793 static void | 799 static void |
794 prof_del_cb(GntWidget *button, gpointer null) | 800 prof_del_cb(GntWidget *button, gpointer null) |
795 { | 801 { |
796 | 802 |
797 const gchar * profile = gnt_entry_get_text(GNT_ENTRY(pref_dialog->profiles)); | 803 gchar * profile = gnt_tree_get_selection_data(GNT_TREE(pref_dialog->profiles)); |
798 gchar * pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s",profile); | 804 gchar * pref; |
799 | 805 |
800 if(!strcmp(profile,DEFAULT_PROFILE)) | 806 if(!strcmp(profile,DEFAULT_PROFILE)) |
801 return; | 807 return; |
802 | 808 |
809 pref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s",profile); | |
803 purple_prefs_remove(pref); | 810 purple_prefs_remove(pref); |
804 g_free(pref); | 811 g_free(pref); |
805 | 812 |
806 g_free(pref_dialog->original_profile); | 813 if(!strcmp(pref_dialog->original_profile,profile)){ |
807 pref_dialog->original_profile = g_strdup(DEFAULT_PROFILE); | 814 g_free(pref_dialog->original_profile); |
815 pref_dialog->original_profile = g_strdup(DEFAULT_PROFILE); | |
816 } | |
817 | |
818 gnt_tree_remove(GNT_TREE(pref_dialog->profiles),profile); | |
808 | 819 |
809 reload_pref_window(DEFAULT_PROFILE); | 820 reload_pref_window(DEFAULT_PROFILE); |
810 } | 821 } |
811 | 822 |
812 static void | 823 static void |
813 prof_add_cb(GntEntry *entry, gpointer null) | 824 prof_add_cb(GntButton *button, GntEntry * entry) |
814 { | 825 { |
815 const char * profile = gnt_entry_get_text(entry); | 826 const char * profile = gnt_entry_get_text(entry); |
816 | 827 GntTreeRow * row; |
828 if(!finch_sound_profile_exists(profile)){ | |
829 gpointer key = g_strdup(profile); | |
830 row = gnt_tree_create_row(GNT_TREE(pref_dialog->profiles),profile); | |
831 gnt_tree_add_row_after(GNT_TREE(pref_dialog->profiles),key, | |
832 row, | |
833 NULL,NULL); | |
834 gnt_entry_set_text(entry,""); | |
835 gnt_tree_set_selected(GNT_TREE(pref_dialog->profiles),key); | |
836 } | |
837 | |
817 reload_pref_window(profile); | 838 reload_pref_window(profile); |
818 | 839 |
840 } | |
841 | |
842 static void | |
843 prof_load_cb(GntTree *tree, gpointer oldkey, gpointer newkey, gpointer null) | |
844 { | |
845 reload_pref_window(newkey); | |
819 } | 846 } |
820 | 847 |
821 static void | 848 static void |
822 cancel_cb(GntButton *button, gpointer win) | 849 cancel_cb(GntButton *button, gpointer win) |
823 { | 850 { |
835 GntWidget *label; | 862 GntWidget *label; |
836 GntWidget *tree; | 863 GntWidget *tree; |
837 GntWidget *win; | 864 GntWidget *win; |
838 | 865 |
839 gint i; | 866 gint i; |
867 GList *itr,*list; | |
840 | 868 |
841 if(pref_dialog) { | 869 if(pref_dialog) { |
842 gnt_window_present(pref_dialog->window); | 870 gnt_window_present(pref_dialog->window); |
843 return; | 871 return; |
844 } | 872 } |
858 splitbox = gnt_hbox_new(FALSE); | 886 splitbox = gnt_hbox_new(FALSE); |
859 | 887 |
860 box = gnt_vbox_new(FALSE); | 888 box = gnt_vbox_new(FALSE); |
861 gnt_box_add_widget(GNT_BOX(box),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD)); | 889 gnt_box_add_widget(GNT_BOX(box),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD)); |
862 pref_dialog->profiles = tree = gnt_tree_new(); | 890 pref_dialog->profiles = tree = gnt_tree_new(); |
891 gnt_tree_set_hash_fns(GNT_TREE(tree), g_str_hash, g_str_equal, g_free); | |
892 gnt_tree_set_compare_func(GNT_TREE(tree),(GCompareFunc)g_ascii_strcasecmp); | |
893 g_signal_connect(G_OBJECT(tree),"selection-changed",G_CALLBACK(prof_load_cb),NULL); | |
894 | |
895 itr = list = finch_sound_get_profiles(); | |
896 for(;itr;itr = itr->next){ | |
897 gnt_tree_add_row_after(GNT_TREE(tree),itr->data,gnt_tree_create_row(GNT_TREE(tree),itr->data),NULL,NULL); | |
898 } | |
899 g_list_free(list); | |
900 | |
863 gnt_box_add_widget(GNT_BOX(box),tree); | 901 gnt_box_add_widget(GNT_BOX(box),tree); |
864 | 902 |
865 pref_dialog->new_profile = entry = gnt_entry_new(""); | 903 pref_dialog->new_profile = entry = gnt_entry_new(""); |
866 gnt_box_add_widget(GNT_BOX(box),entry); | 904 gnt_box_add_widget(GNT_BOX(box),entry); |
867 | 905 |
868 tmpbox = gnt_hbox_new(FALSE); | 906 tmpbox = gnt_hbox_new(FALSE); |
869 button = gnt_button_new("Add"); | 907 button = gnt_button_new("Add"); |
870 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(prof_add_cb),NULL); | 908 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(prof_add_cb),entry); |
871 gnt_box_add_widget(GNT_BOX(tmpbox),button); | 909 gnt_box_add_widget(GNT_BOX(tmpbox),button); |
872 button = gnt_button_new("Delete"); | 910 button = gnt_button_new("Delete"); |
873 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(prof_del_cb),NULL); | 911 g_signal_connect(G_OBJECT(button),"activate",G_CALLBACK(prof_del_cb),NULL); |
874 gnt_box_add_widget(GNT_BOX(tmpbox),button); | 912 gnt_box_add_widget(GNT_BOX(tmpbox),button); |
875 gnt_box_add_widget(GNT_BOX(box),tmpbox); | 913 gnt_box_add_widget(GNT_BOX(box),tmpbox); |