Tue, 24 Nov 2015 23:16:45 -0800
Replace magic numbers on the sound API
Added an enum for the enable sound preference.
Added sound.c on the list to convert them to GEnums
| libpurple/Makefile.am | file | annotate | diff | comparison | revisions | |
| libpurple/sound.c | file | annotate | diff | comparison | revisions | |
| libpurple/sound.h | file | annotate | diff | comparison | revisions | |
| pidgin/gtkprefs.c | file | annotate | diff | comparison | revisions |
--- a/libpurple/Makefile.am Sun Nov 22 18:29:08 2015 -0300 +++ b/libpurple/Makefile.am Tue Nov 24 23:16:45 2015 -0800 @@ -262,6 +262,7 @@ $(srcdir)/protocols.h \ $(srcdir)/roomlist.h \ $(srcdir)/status.h \ + ${srcdir}/sound.h \ $(srcdir)/xfer.h marshallers.h: marshallers.list
--- a/libpurple/sound.c Sun Nov 22 18:29:08 2015 -0300 +++ b/libpurple/sound.c Tue Nov 24 23:16:45 2015 -0800 @@ -29,10 +29,6 @@ #include "theme-manager.h" static PurpleSoundUiOps *sound_ui_ops = NULL; - -#define STATUS_AVAILABLE 1 -#define STATUS_AWAY 2 - static time_t last_played[PURPLE_NUM_SOUNDS]; static gboolean @@ -40,7 +36,7 @@ { gint pref_status = purple_prefs_get_int("/purple/sound/while_status"); - if (pref_status == 3) + if (pref_status == PURPLE_SOUND_STATUS_ALWAYS) { /* Play sounds: Always */ return TRUE; @@ -53,8 +49,8 @@ if (purple_status_is_online(status)) { gboolean available = purple_status_is_available(status); - return (( available && pref_status == STATUS_AVAILABLE) || - (!available && pref_status == STATUS_AWAY)); + return (( available && pref_status == PURPLE_SOUND_STATUS_AVAILABLE) || + (!available && pref_status == PURPLE_SOUND_STATUS_AWAY)); } } @@ -160,7 +156,7 @@ G_TYPE_BOOLEAN, 2, G_TYPE_INT, PURPLE_TYPE_ACCOUNT); purple_prefs_add_none("/purple/sound"); - purple_prefs_add_int("/purple/sound/while_status", STATUS_AVAILABLE); + purple_prefs_add_int("/purple/sound/while_status", PURPLE_SOUND_STATUS_AVAILABLE); memset(last_played, 0, sizeof(last_played)); purple_theme_manager_register_type(g_object_new(PURPLE_TYPE_SOUND_THEME_LOADER, "type", "sound", NULL));
--- a/libpurple/sound.h Sun Nov 22 18:29:08 2015 -0300 +++ b/libpurple/sound.h Tue Nov 24 23:16:45 2015 -0800 @@ -24,7 +24,7 @@ /** * SECTION:sound * @section_id: libpurple-sound - * @short_description: <filename>sound.h</filename> + * @short_description: Sound subsystem definition. * @title: Sound API * @see_also: <link linkend="chapter-signals-sound">Sound signals</link> */ @@ -39,6 +39,14 @@ typedef struct _PurpleSoundUiOps PurpleSoundUiOps; /** + */ +typedef enum { + PURPLE_SOUND_STATUS_AVAILABLE = 1, + PURPLE_SOUND_STATUS_AWAY, + PURPLE_SOUND_STATUS_ALWAYS, +} PurpleSoundStatus; + +/** * PurpleSoundEventID: * @PURPLE_SOUND_BUDDY_ARRIVE: Buddy signs on. * @PURPLE_SOUND_BUDDY_LEAVE: Buddy signs off.
--- a/pidgin/gtkprefs.c Sun Nov 22 18:29:08 2015 -0300 +++ b/pidgin/gtkprefs.c Tue Nov 24 23:16:45 2015 -0800 @@ -3246,9 +3246,9 @@ PIDGIN_PREFS_ROOT "/sound/conv_focus", vbox); pidgin_prefs_dropdown(vbox, _("_Enable sounds:"), PURPLE_PREF_INT, "/purple/sound/while_status", - _("Only when available"), 1, - _("Only when not available"), 2, - _("Always"), 3, + _("Only when available"), PURPLE_SOUND_STATUS_AVAILABLE, + _("Only when not available"), PURPLE_SOUND_STATUS_AWAY, + _("Always"), PURPLE_SOUND_STATUS_ALWAYS, NULL); #ifdef USE_GSTREAMER