Hi Jeff, thanks to Eet's capabilities and Hannes' (jeffdameth) kindness, config wiping isn't necessary anymore! Have fun with this!
2011/8/31 Enlightenment SVN <[email protected]>: > Log: > e17/mixer: apply patch from Leif (T_UNIX). split conf->version into > major/minor. no need to wipe config. not tested notification > > > Author: jeffdameth > Date: 2011-08-31 05:30:56 -0700 (Wed, 31 Aug 2011) > New Revision: 63026 > Trac: http://trac.enlightenment.org/e/changeset/63026 > > Modified: > trunk/e/src/modules/mixer/Makefile.am > trunk/e/src/modules/mixer/conf_module.c > trunk/e/src/modules/mixer/e_mod_main.c trunk/e/src/modules/mixer/e_mod_main.h > > Modified: trunk/e/src/modules/mixer/Makefile.am > =================================================================== > --- trunk/e/src/modules/mixer/Makefile.am 2011-08-31 11:36:46 UTC (rev > 63025) > +++ trunk/e/src/modules/mixer/Makefile.am 2011-08-31 12:30:56 UTC (rev > 63026) > @@ -15,6 +15,10 @@ > -I$(top_builddir)/src/bin \ > -I$(top_srcdir)/src/modules \ > @e_cflags@ @SOUND_CFLAGS@ > +if HAVE_ENOTIFY > +INCLUDES += @ENOTIFY_CFLAGS@ > +endif > + > pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) > pkg_LTLIBRARIES = module.la > > @@ -32,6 +36,10 @@ > endif > > module_la_LIBADD = @SOUND_LIBS@ @e_libs@ @dlopen_libs@ > +if HAVE_ENOTIFY > +module_la_LIBADD += @ENOTIFY_LIBS@ > +endif > + > module_la_LDFLAGS = -module -avoid-version > module_la_DEPENDENCIES = $(top_builddir)/config.h > > > Modified: trunk/e/src/modules/mixer/conf_module.c > =================================================================== > --- trunk/e/src/modules/mixer/conf_module.c 2011-08-31 11:36:46 UTC (rev > 63025) > +++ trunk/e/src/modules/mixer/conf_module.c 2011-08-31 12:30:56 UTC (rev > 63026) > @@ -72,6 +72,8 @@ > > id = ctxt->default_instance->gcc->cf->id; > conf->default_gc_id = eina_stringshare_add(id); > + > + conf->desktop_notification = ctxt->desktop_notification; > } > > return 1; > @@ -82,7 +84,7 @@ > { > struct mixer_config_ui_general *ui = &cfdata->ui.general; > E_Mixer_Module_Context *ctxt = dialog->data; > - Evas_Object *label; > + Evas_Object *label, *chk; > Eina_List *l; > int i; > > @@ -111,7 +113,14 @@ > e_widget_framelist_object_append(ui->frame, o); > } > > + > e_widget_list_object_append(cfdata->ui.list, ui->frame, 1, 1, 0.5); > + chk = e_widget_check_add(evas, _("Diplay desktop notifications on volume > change"), &ctxt->desktop_notification); > + e_widget_check_checked_set(chk, ctxt->conf->desktop_notification); > +#ifndef HAVE_ENOTIFY > + e_widget_disabled_set(chk, EINA_TRUE); > +#endif > + e_widget_list_object_append(cfdata->ui.list, chk, 1, 1, 0.5); > } > > static void > > Modified: trunk/e/src/modules/mixer/e_mod_main.c > =================================================================== > --- trunk/e/src/modules/mixer/e_mod_main.c 2011-08-31 11:36:46 UTC (rev > 63025) > +++ trunk/e/src/modules/mixer/e_mod_main.c 2011-08-31 12:30:56 UTC (rev > 63026) > @@ -1,5 +1,8 @@ > #include "e_mod_main.h" > #include "e_mod_system.h" > +#ifdef HAVE_ENOTIFY > +#include <E_Notify.h> > +#endif > > static void _mixer_popup_timer_new(E_Mixer_Instance *inst); > static Eina_Bool _mixer_popup_timer_cb(void *data); > @@ -11,6 +14,41 @@ > static const char _name[] = "mixer"; > const char _e_mixer_Name[] = "Mixer"; > > +static void > +_mixer_notify(const float val, E_Mixer_Instance *inst) > +{ > +#ifdef HAVE_ENOTIFY > + E_Notification *n; > + E_Mixer_Module_Context *ctxt; > + char *icon, buf[56]; > + int ret; > + > + if (val > 100.0 || val < 0.0) > + return; > + > + if (!(ctxt = (E_Mixer_Module_Context*)mixer_mod->data) || > !ctxt->desktop_notification) > + return; > + > + ret = snprintf(buf, (sizeof(buf) - 1), "%s: %d%%", _("New volume"), > (int)(val + 0.5)); > + if ((ret < 0) || (ret > sizeof(buf))) > + return; > + //Names are taken from FDO icon naming scheme > + if (val == 0.0) > + icon = "audio-volume-muted"; > + else if (val > 66.6) > + icon = "audio-volume-high"; > + else if ((val > 33.3) && (val < 66.6)) > + icon = "audio-volume-medium"; > + else if (val < 33.3) > + icon = "audio-volume-low"; > + > + n = e_notification_full_new(_("Mixer"), 0, icon, _("Volume changed"), > buf, 2000); > + e_notification_replaces_id_set(n, EINA_TRUE); > + e_notification_send(n, NULL, NULL); > + e_notification_unref(n); > +#endif > +} > + > const char * > e_mixer_theme_path(void) > { > @@ -137,8 +175,6 @@ > if (!conf) > return NULL; > > - conf->version = MOD_CONF_VERSION; > - > return conf; > } > > @@ -249,7 +285,7 @@ > } > > static void > -_mixer_volume_increase(E_Mixer_Instance *inst) > +_mixer_volume_increase(E_Mixer_Instance *inst, Eina_Bool non_ui) > { > E_Mixer_Channel_State *state; > > @@ -275,10 +311,12 @@ > e_mixer_system_set_volume(inst->sys, inst->channel, > state->left, state->right); > _mixer_gadget_update(inst); > + if (non_ui) > + _mixer_notify(((float)state->left + (float)state->right) / 2.0, inst); > } > > static void > -_mixer_volume_decrease(E_Mixer_Instance *inst) > +_mixer_volume_decrease(E_Mixer_Instance *inst, Eina_Bool non_ui) > { > E_Mixer_Channel_State *state; > > @@ -303,10 +341,12 @@ > e_mixer_system_set_volume(inst->sys, inst->channel, > state->left, state->right); > _mixer_gadget_update(inst); > + if (non_ui) > + _mixer_notify(((float)state->left + (float)state->right) / 2.0, inst); > } > > static void > -_mixer_toggle_mute(E_Mixer_Instance *inst) > +_mixer_toggle_mute(E_Mixer_Instance *inst, Eina_Bool non_ui) > { > E_Mixer_Channel_State *state; > > @@ -318,6 +358,8 @@ > state->mute = !state->mute; > e_mixer_system_set_mute(inst->sys, inst->channel, state->mute); > _mixer_gadget_update(inst); > + if (non_ui) > + _mixer_notify(0.0, inst); > } > > static void > @@ -425,12 +467,12 @@ > if (strcmp(keysym, "Escape") == 0) > _mixer_popup_del(inst); > else if (strcmp(keysym, "Up") == 0) > - _mixer_volume_increase(inst); > + _mixer_volume_increase(inst, EINA_FALSE); > else if (strcmp(keysym, "Down") == 0) > - _mixer_volume_decrease(inst); > + _mixer_volume_decrease(inst, EINA_FALSE); > else if ((strcmp(keysym, "Return") == 0) || > (strcmp(keysym, "KP_Enter") == 0)) > - _mixer_toggle_mute(inst); > + _mixer_toggle_mute(inst, EINA_FALSE); > else > { > E_Action *act; > @@ -744,7 +786,7 @@ > _mixer_popup_del(inst); > } > else if (ev->button == 2) > - _mixer_toggle_mute(inst); > + _mixer_toggle_mute(inst, EINA_FALSE); > else if ((ev->button == 3) && (!inst->menu)) > _mixer_menu_new(inst, ev); > } > @@ -758,9 +800,9 @@ > if (ev->direction == 0) > { > if (ev->z > 0) > - _mixer_volume_decrease(inst); > + _mixer_volume_decrease(inst, EINA_FALSE); > else if (ev->z < 0) > - _mixer_volume_increase(inst); > + _mixer_volume_increase(inst, EINA_FALSE); > } > else if (ev->direction == 1) > { > @@ -1062,7 +1104,7 @@ > > if (ctxt->default_instance->conf->keybindings_popup) > _mixer_popup_timer_new(ctxt->default_instance); > - _mixer_volume_increase(ctxt->default_instance); > + _mixer_volume_increase(ctxt->default_instance, EINA_TRUE); > } > > static void > @@ -1082,7 +1124,7 @@ > > if (ctxt->default_instance->conf->keybindings_popup) > _mixer_popup_timer_new(ctxt->default_instance); > - _mixer_volume_decrease(ctxt->default_instance); > + _mixer_volume_decrease(ctxt->default_instance, EINA_TRUE); > } > > static void > @@ -1102,7 +1144,7 @@ > > if (ctxt->default_instance->conf->keybindings_popup) > _mixer_popup_timer_new(ctxt->default_instance); > - _mixer_toggle_mute(ctxt->default_instance); > + _mixer_toggle_mute(ctxt->default_instance, EINA_TRUE); > } > > static E_Config_Dialog * > @@ -1162,6 +1204,7 @@ > E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, version, INT); > E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, default_gc_id, STR); > E_CONFIG_HASH(conf_edd, E_Mixer_Module_Config, gadgets, gadget_conf_edd); > + E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, desktop_notification, INT); > > return conf_edd; > } > @@ -1205,23 +1248,17 @@ > E_Mixer_Module_Config *conf; > > conf = e_config_domain_load(_conf_domain, module_conf_edd); > + > if (!conf) > - return _mixer_module_configuration_new(); > + return _mixer_module_configuration_new(); > + > + if (conf && !e_util_module_config_check (_("Mixer Module"), conf->version, > + MOD_CONFIG_FILE_EPOCH, > MOD_CONFIG_FILE_VERSION)) > + { > + _mixer_module_configuration_free(conf); > + return _mixer_module_configuration_new(); > + } > > - if (conf->version != MOD_CONF_VERSION) > - { > - _mixer_module_configuration_free(conf); > - conf = _mixer_module_configuration_new(); > - if (!conf) > - return NULL; > - > - ecore_timer_add(1.0, _mixer_module_configuration_alert, > - _("Mixer Module Settings data changed.<br>" > - "Your old configuration has been replaced with " > - "new default.<br>Sorry for the inconvenience.")); > - return conf; > - } > - > return conf; > } > > @@ -1235,6 +1272,15 @@ > ctxt->gadget_conf_edd = gadget_edd; > ctxt->module_conf_edd = module_edd; > ctxt->conf = _mixer_module_configuration_load(module_edd); > + > +#define IFMODCFG(v) if ((ctxt->conf->version & 0xffff) < v) { > +#define IFMODCFGEND } > + > + IFMODCFG(0x0003); > + ctxt->conf->desktop_notification = 1; > + IFMODCFGEND; > + > + ctxt->conf->version = MOD_CONFIG_FILE_VERSION; > } > > static const char _act_increase[] = "volume_increase"; > @@ -1303,6 +1349,10 @@ > if (!ctxt) > return NULL; > > +#ifdef HAVE_ENOTIFY > + e_notification_init(); > +#endif > + > _mixer_configure_registry_register(); > _mixer_actions_register(ctxt); > e_gadcon_provider_register(&_gc_class); > @@ -1348,6 +1398,10 @@ > _mixer_module_configuration_descriptor_free(ctxt->module_conf_edd); > } > > +#ifdef HAVE_ENOTIFY > + e_notification_shutdown(); > +#endif > + > E_FREE(ctxt); > mixer_mod = NULL; > return 1; > > Modified: trunk/e/src/modules/mixer/e_mod_main.h > =================================================================== > --- trunk/e/src/modules/mixer/e_mod_main.h 2011-08-31 11:36:46 UTC (rev > 63025) > +++ trunk/e/src/modules/mixer/e_mod_main.h 2011-08-31 12:30:56 UTC (rev > 63026) > @@ -5,7 +5,10 @@ > #include "e_mod_system.h" > #include <e.h> > > -#define MOD_CONF_VERSION 3 > +#define MOD_CONFIG_FILE_EPOCH 0x0000 > +#define MOD_CONFIG_FILE_GENERATION 0x0003 > +#define MOD_CONFIG_FILE_VERSION \ > + ((MOD_CONFIG_FILE_EPOCH << 16) | MOD_CONFIG_FILE_GENERATION) > > typedef struct E_Mixer_Gadget_Config > { > @@ -24,6 +27,7 @@ > int version; > const char *default_gc_id; > Eina_Hash *gadgets; > + int desktop_notification; > } E_Mixer_Module_Config; > > typedef struct E_Mixer_Instance > @@ -71,6 +75,7 @@ > E_Action *decr; > E_Action *mute; > } actions; > + int desktop_notification; > } E_Mixer_Module_Context; > > EAPI extern E_Module_Api e_modapi; > > > ------------------------------------------------------------------------------ > Special Offer -- Download ArcSight Logger for FREE! > Finally, a world-class log management solution at an even better > price-free! And you'll get a free "Love Thy Logs" t-shirt when you > download Logger. Secure your free ArcSight Logger TODAY! > http://p.sf.net/sfu/arcsisghtdev2dev > _______________________________________________ > enlightenment-svn mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/enlightenment-svn > -- Leif ------------------------------------------------------------------------------ Special Offer -- Download ArcSight Logger for FREE! Finally, a world-class log management solution at an even better price-free! And you'll get a free "Love Thy Logs" t-shirt when you download Logger. Secure your free ArcSight Logger TODAY! http://p.sf.net/sfu/arcsisghtdev2dev _______________________________________________ enlightenment-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/enlightenment-devel
