# HG changeset patch # User Sadrul Habib Chowdhury # Date 1184175375 0 # Node ID 01d574f529e0f1170673fb08622054bd530615d0 # Parent 5a6f174bf6ddc64e14bef7ec4de581790b782063 One leak fix. Mostly cosmetic changes. diff -r 5a6f174bf6dd -r 01d574f529e0 finch/gntsound.c --- a/finch/gntsound.c Wed Jul 11 16:20:12 2007 +0000 +++ b/finch/gntsound.c Wed Jul 11 17:36:15 2007 +0000 @@ -74,13 +74,12 @@ GntWidget *profiles; } SoundPrefDialog; -SoundPrefDialog *pref_dialog; +static SoundPrefDialog *pref_dialog; #define PLAY_SOUND_TIMEOUT 15000 static guint mute_login_sounds_timeout = 0; static gboolean mute_login_sounds = FALSE; -static gchar * pref_string = NULL; #ifdef USE_GSTREAMER static gboolean gst_init_failed; @@ -113,8 +112,9 @@ static gchar * make_pref(const char *name) { - g_free(pref_string); - pref_string = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s%s",finch_sound_get_active_profile(),name); + static char pref_string[512]; + g_snprintf(pref_string, sizeof(pref_string), + FINCH_PREFS_ROOT "/sound/profiles/%s%s", finch_sound_get_active_profile(), name); return pref_string; } @@ -191,10 +191,9 @@ if (flags & PURPLE_MESSAGE_DELAYED) return; - if (conv==NULL){ + if (conv==NULL) { purple_sound_play_event(PURPLE_SOUND_FIRST_RECEIVE, account); - } - else{ + } else { play_conv_event(conv, event); } } @@ -274,10 +273,10 @@ if (mute_login_sounds_timeout != 0) g_source_remove(mute_login_sounds_timeout); mute_login_sounds = TRUE; - mute_login_sounds_timeout = purple_timeout_add(10000, unmute_login_sounds_cb, NULL); + mute_login_sounds_timeout = purple_timeout_add_seconds(10, unmute_login_sounds_cb, NULL); } -void * +static void * finch_sound_get_handle() { static int handle; @@ -290,38 +289,39 @@ static void load_profile(const char *name, PurplePrefType type, gconstpointer val, gpointer null) { - if(!purple_prefs_exists(make_pref(""))){ - purple_prefs_add_none(make_pref("")); - purple_prefs_add_none(make_pref("/enabled")); - purple_prefs_add_none(make_pref("/file")); - purple_prefs_add_bool(make_pref("/enabled/login"), TRUE); - purple_prefs_add_path(make_pref("/file/login"), ""); - purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE); - purple_prefs_add_path(make_pref("/file/logout"), ""); - purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE); - purple_prefs_add_path(make_pref("/file/im_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); - purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE); - purple_prefs_add_path(make_pref("/file/send_im"), ""); - purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); - purple_prefs_add_path(make_pref("/file/join_chat"), ""); - purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); - purple_prefs_add_path(make_pref("/file/left_chat"), ""); - purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); - purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); - purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); - purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); - purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); - purple_prefs_add_path(make_pref("/file/nick_said"), ""); - purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE); - purple_prefs_add_path(make_pref("/file/pounce_default"), ""); - purple_prefs_add_bool(make_pref("/conv_focus"), TRUE); - purple_prefs_add_bool(make_pref("/mute"), FALSE); - purple_prefs_add_path(make_pref("/command"), ""); - purple_prefs_add_string(make_pref("/method"), "automatic"); - purple_prefs_add_int(make_pref("/volume"), 50); - } + if(purple_prefs_exists(make_pref(""))) + return; + + purple_prefs_add_none(make_pref("")); + purple_prefs_add_none(make_pref("/enabled")); + purple_prefs_add_none(make_pref("/file")); + purple_prefs_add_bool(make_pref("/enabled/login"), TRUE); + purple_prefs_add_path(make_pref("/file/login"), ""); + purple_prefs_add_bool(make_pref("/enabled/logout"), TRUE); + purple_prefs_add_path(make_pref("/file/logout"), ""); + purple_prefs_add_bool(make_pref("/enabled/im_recv"), TRUE); + purple_prefs_add_path(make_pref("/file/im_recv"), ""); + purple_prefs_add_bool(make_pref("/enabled/first_im_recv"), FALSE); + purple_prefs_add_path(make_pref("/file/first_im_recv"), ""); + purple_prefs_add_bool(make_pref("/enabled/send_im"), TRUE); + purple_prefs_add_path(make_pref("/file/send_im"), ""); + purple_prefs_add_bool(make_pref("/enabled/join_chat"), FALSE); + purple_prefs_add_path(make_pref("/file/join_chat"), ""); + purple_prefs_add_bool(make_pref("/enabled/left_chat"), FALSE); + purple_prefs_add_path(make_pref("/file/left_chat"), ""); + purple_prefs_add_bool(make_pref("/enabled/send_chat_msg"), FALSE); + purple_prefs_add_path(make_pref("/file/send_chat_msg"), ""); + purple_prefs_add_bool(make_pref("/enabled/chat_msg_recv"), FALSE); + purple_prefs_add_path(make_pref("/file/chat_msg_recv"), ""); + purple_prefs_add_bool(make_pref("/enabled/nick_said"), FALSE); + purple_prefs_add_path(make_pref("/file/nick_said"), ""); + purple_prefs_add_bool(make_pref("/enabled/pounce_default"), TRUE); + purple_prefs_add_path(make_pref("/file/pounce_default"), ""); + purple_prefs_add_bool(make_pref("/conv_focus"), TRUE); + purple_prefs_add_bool(make_pref("/mute"), FALSE); + purple_prefs_add_path(make_pref("/command"), ""); + purple_prefs_add_string(make_pref("/method"), "automatic"); + purple_prefs_add_int(make_pref("/volume"), 50); } static void @@ -614,7 +614,7 @@ void finch_sound_set_active_profile(const char *name) { - if(profile_exists(name)){ + if(profile_exists(name)) { purple_prefs_set_string(FINCH_PREFS_ROOT "/sound/actprofile",name); } } @@ -703,7 +703,7 @@ static void pref_save_cb(GntWidget *button, gpointer null) { - + /* XXX: */ } static void @@ -764,26 +764,25 @@ gchar *filepref; const char * profile = finch_sound_get_active_profile(); - boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",profile,event->pref); - filepref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/file/%s",profile,event->pref); event->file = g_strdup(purple_prefs_get_path(filepref)); - if(event->label == NULL){ + g_free(filepref); + if (event->label == NULL) { continue; } + boolpref = g_strdup_printf(FINCH_PREFS_ROOT "/sound/profiles/%s/enabled/%s",profile,event->pref); gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),0,event->label); gnt_tree_change_text(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),1,event->file[0] ? g_path_get_basename(event->file) : "(default)"); gnt_tree_set_choice(GNT_TREE(pref_dialog->events),GINT_TO_POINTER(i),purple_prefs_get_bool(boolpref)); g_free(boolpref); - g_free(filepref); } } void finch_sounds_show_all(void) { - GntWidget *box; GntWidget *cmbox; GntWidget *slider; + GntWidget *box, *cmbox, *slider; GntWidget *entry; GntWidget *chkbox; GntWidget *button; @@ -794,7 +793,7 @@ GList *itr,*list; gint i; - if(pref_dialog){ + if(pref_dialog) { gnt_window_present(pref_dialog->window); return; } @@ -817,6 +816,7 @@ gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"custom",_("Command")); gnt_combo_box_add_data(GNT_COMBO_BOX(cmbox),"nosound",_("No Sound")); + /* Sound method */ label = gnt_label_new_with_format(_("Sound Method"),GNT_TEXT_FLAG_BOLD); gnt_box_add_widget(GNT_BOX(win),label); box = gnt_hbox_new(TRUE); @@ -836,6 +836,7 @@ gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); + /* Sound options */ gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Options"),GNT_TEXT_FLAG_BOLD)); pref_dialog->conv_focus = chkbox = gnt_check_box_new(_("Sounds when conversation has focus")); gnt_box_add_widget(GNT_BOX(win),chkbox); @@ -865,8 +866,9 @@ gnt_box_add_widget(GNT_BOX(box),label); gnt_box_add_widget(GNT_BOX(win),box); - gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); + gnt_box_add_widget(GNT_BOX(win), gnt_hline_new()); + /* Sound events */ gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Sound Events"),GNT_TEXT_FLAG_BOLD)); pref_dialog->events = tree = gnt_tree_new_with_columns(2); gnt_tree_set_column_titles(GNT_TREE(tree),_("Event"),_("File")); @@ -901,6 +903,7 @@ gnt_box_add_widget(GNT_BOX(win), gnt_line_new(FALSE)); + /* Sound profiles */ gnt_box_add_widget(GNT_BOX(win),gnt_label_new_with_format(_("Profiles"),GNT_TEXT_FLAG_BOLD)); box = gnt_hbox_new(FALSE); pref_dialog->profiles = cmbox = gnt_combo_box_new(); @@ -957,3 +960,4 @@ { return &sound_ui_ops; } + diff -r 5a6f174bf6dd -r 01d574f529e0 finch/gntsound.h --- a/finch/gntsound.h Wed Jul 11 16:20:12 2007 +0000 +++ b/finch/gntsound.h Wed Jul 11 17:36:15 2007 +0000 @@ -28,52 +28,37 @@ #include "sound.h" /**********************************************************************/ -/** @name GNT Sound API */ +/** @name GNT Sound API */ /**********************************************************************/ /*@{*/ /** -* Get the prefs option for an event. -* -* @param event The event. -* @return The option. -*/ -const char *finch_sound_get_event_option(PurpleSoundEventID event); - -/** -* Get the label for an event. -* -* @param event The event. -* @return The label. -*/ -const char *finch_sound_get_event_label(PurpleSoundEventID event); - -/* * Get the name of the active sound profile. * - * @return the name + * @return The name of the profile */ const char *finch_sound_get_active_profile(void); /** * Set the active profile. If the profile doesn't exist, nothing is changed. * - * + * @param name The name of the profile */ void finch_sound_set_active_profile(const char *name); /** * Get a list of available sound profiles. * - * @return A list of strings denoting sound profile names. Free this list when you're done with it. + * @return A list of strings denoting sound profile names. + * Caller must free the list (but not the data). */ GList *finch_sound_get_profiles(void); /** -* Gets GNT sound UI ops. -* -* @return The UI operations structure. -*/ + * Gets GNT sound UI ops. + * + * @return The UI operations structure. + */ PurpleSoundUiOps *finch_sound_get_ui_ops(void); /** @@ -81,13 +66,6 @@ */ void finch_sounds_show_all(void); -/** -* Get the handle for the GNT sound system. -* -* @return The handle to the sound system -*/ -void *finch_sound_get_handle(void); - /*@}*/ #endif