Enlightenment CVS committal Author : lok Project : e_modules Module : mixer
Dir : e_modules/mixer Modified Files: Makefile.am README e_mod_main.c e_mod_main.h e_mod_types.h mixer.edc Added Files: e_mod_keybindings.c e_mod_keybindings.h pulsar.edc pulsar.png vol.png Log Message: Added keybindings for increase/decrease or mute the mixer. =================================================================== RCS file: /cvs/e/e_modules/mixer/Makefile.am,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- Makefile.am 12 Oct 2006 18:29:04 -0000 1.10 +++ Makefile.am 11 Nov 2006 19:58:58 -0000 1.11 @@ -15,10 +15,13 @@ EXTRA_DIST = \ $(files_DATA) \ mixer.edc \ +pulsar.edc \ mixer-volume-high.png \ mixer-volume-medium.png \ mixer-volume-low.png \ mixer-volume-muted.png \ +pulsar.png \ +vol.png \ e_modules-mixer.spec.in \ e_modules-mixer.spec @@ -41,6 +44,8 @@ alsa_mixer.c \ oss_mixer.h \ oss_mixer.c \ + e_mod_keybindings.h \ + e_mod_keybindings.c \ e_mod_config.c module_la_LIBADD = @e_libs@ @SOUND_LDFLAGS@ =================================================================== RCS file: /cvs/e/e_modules/mixer/README,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- README 7 Sep 2006 13:46:25 -0000 1.1 +++ README 11 Nov 2006 19:58:58 -0000 1.2 @@ -0,0 +1,3 @@ +The pulsar.png used for the theme is on an unkown licence. +I hope that the author isn't against that use. +If there is a problem please let us know, we'll change it. =================================================================== RCS file: /cvs/e/e_modules/mixer/e_mod_main.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -3 -r1.54 -r1.55 --- e_mod_main.c 12 Oct 2006 18:29:04 -0000 1.54 +++ e_mod_main.c 11 Nov 2006 19:58:58 -0000 1.55 @@ -4,6 +4,7 @@ #include <e.h> #include "e_mod_main.h" #include "e_mod_types.h" +#include "e_mod_keybindings.h" #if defined(HAVE_ALSA) # include "alsa_mixer.h" @@ -15,6 +16,7 @@ #define DEBUG 0 #define SLIDE_LENGTH 0.5 #define SLIDE_FRAMERATE (1.0 / 75.0) +#define VOL_STEP 4 /* Gadcon Protos */ static E_Gadcon_Client *_gc_init (E_Gadcon * gc, const char *name, const char *id, const char *style); @@ -23,6 +25,10 @@ static char *_gc_label (void); static Evas_Object *_gc_icon (Evas * evas); +void mixer_vol_increase (Instance *inst); +void mixer_vol_decrease (Instance *inst); +void mixer_mute_toggle (Instance *inst); + /* Module Protos */ static void _mixer_simple_volume_change (Mixer *mixer, Config_Item *ci, double val); static void _mixer_volume_change (Mixer *mixer, Config_Item *ci, int channel_id, double val); @@ -50,6 +56,14 @@ static int _mixer_window_simple_mouse_up_cb (void *data, int type, void *event); static int _mixer_window_simple_mouse_wheel_cb (void *data, int type, void *event); +static void _mixer_window_gauge_send_vol (Mixer_Win_Gauge *win, Mixer *mixer, Config_Item *ci); +static void _mixer_window_gauge_free (Mixer_Win_Gauge *win); +static int _mixer_window_gauge_visible_cb (void *data); +static void _mixer_window_gauge_pop_down (Mixer_Win_Gauge *win); +static void _mixer_window_gauge_pop_up (Instance *inst); +static void _mixer_volume_increase (Mixer *mixer, Config_Item *ci); +static void _mixer_volume_decrease (Mixer *mixer, Config_Item *ci); + /* Private vars */ static E_Config_DD *conf_edd = NULL; static E_Config_DD *conf_item_edd = NULL; @@ -145,6 +159,7 @@ if (mixer->mix_sys) _mixer_system_shutdown(mixer->mix_sys); if (mixer->base) evas_object_del(mixer->base); + if (mixer->gauge_win) _mixer_window_gauge_free(mixer->gauge_win); mixer_config->instances = evas_list_remove(mixer_config->instances, inst); E_FREE(mixer); @@ -178,6 +193,54 @@ return o; } +void +mixer_vol_increase(Instance *inst) +{ + Mixer_Win_Gauge *win; + Config_Item *ci; + + _mixer_window_gauge_pop_up(inst); + + if (!inst || !inst->mixer) return; + ci = _mixer_config_item_get(inst->mixer, inst->gcc->id); + if (!ci) return; + + win = inst->mixer->gauge_win; + _mixer_volume_increase(inst->mixer, ci); + _mixer_window_gauge_send_vol(win, inst->mixer, ci); + edje_object_signal_emit(win->pulsar, "vol,increase", "e"); +} + +void +mixer_vol_decrease(Instance *inst) +{ + Mixer_Win_Gauge *win; + Config_Item *ci; + + _mixer_window_gauge_pop_up(inst); + + if (!inst || !inst->mixer) return; + ci = _mixer_config_item_get(inst->mixer, inst->gcc->id); + if (!ci) return; + + win = inst->mixer->gauge_win; + _mixer_volume_decrease(inst->mixer, ci); + _mixer_window_gauge_send_vol(win, inst->mixer, ci); + edje_object_signal_emit(win->pulsar, "vol,decrease", "e"); +} + +void +mixer_mute_toggle(Instance *inst) +{ + Config_Item *ci; + + if (!inst || !inst->mixer) return; + ci = _mixer_config_item_get(inst->mixer, inst->gcc->id); + if (!ci) return; + + _mixer_simple_mute_toggle(inst->mixer, ci); +} + static void _mixer_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { @@ -435,6 +498,27 @@ #undef D #define T Config #define D conf_edd + E_CONFIG_VAL(D, T, decrease_vol_key.context, INT); + E_CONFIG_VAL(D, T, decrease_vol_key.modifiers, INT); + E_CONFIG_VAL(D, T, decrease_vol_key.key, STR); + E_CONFIG_VAL(D, T, decrease_vol_key.action, STR); + E_CONFIG_VAL(D, T, decrease_vol_key.params, STR); + E_CONFIG_VAL(D, T, decrease_vol_key.any_mod, UCHAR); + + E_CONFIG_VAL(D, T, increase_vol_key.context, INT); + E_CONFIG_VAL(D, T, increase_vol_key.modifiers, INT); + E_CONFIG_VAL(D, T, increase_vol_key.key, STR); + E_CONFIG_VAL(D, T, increase_vol_key.action, STR); + E_CONFIG_VAL(D, T, increase_vol_key.params, STR); + E_CONFIG_VAL(D, T, increase_vol_key.any_mod, UCHAR); + + E_CONFIG_VAL(D, T, mute_key.context, INT); + E_CONFIG_VAL(D, T, mute_key.modifiers, INT); + E_CONFIG_VAL(D, T, mute_key.key, STR); + E_CONFIG_VAL(D, T, mute_key.action, STR); + E_CONFIG_VAL(D, T, mute_key.params, STR); + E_CONFIG_VAL(D, T, mute_key.any_mod, UCHAR); + E_CONFIG_LIST(D, T, items, conf_item_edd); mixer_config = e_config_domain_load("module.mixer", conf_edd); @@ -452,6 +536,8 @@ ci->use_app = 0; mixer_config->items = evas_list_append(mixer_config->items, ci); } + mixer_register_module_actions(); + mixer_register_module_keybindings(); mixer_config->module = m; @@ -462,6 +548,9 @@ EAPI int e_modapi_shutdown(E_Module *m) { + mixer_unregister_module_actions(); + mixer_unregister_module_keybindings(); + mixer_config->module = NULL; e_gadcon_provider_unregister(&_gc_class); @@ -1016,3 +1105,160 @@ return 1; } + +static void +_mixer_window_gauge_free(Mixer_Win_Gauge *win) +{ + if (!win) return; + + e_object_del(E_OBJECT(win->window)); + evas_object_del(win->bg_obj); + evas_object_del(win->pulsar); + win->mixer->gauge_win = NULL; + if (win->timer) + { + ecore_timer_del(win->timer); + win->timer = NULL; + } + E_FREE(win); +} + +static int +_mixer_window_gauge_visible_cb(void *data) +{ + Mixer_Win_Gauge *win; + Ecore_Timer *timer; + + win = data; + _mixer_window_gauge_pop_down(win); + if (win->timer) + { + ecore_timer_del(win->timer); + win->timer = NULL; + } + return 0; +} + +static void +_mixer_window_gauge_pop_down(Mixer_Win_Gauge *win) +{ + if (!win) return; + e_popup_hide(win->window); +} + +static void +_mixer_window_gauge_pop_up(Instance *inst) +{ + E_Container *con; + Config_Item *ci; + Mixer_Win_Gauge *win; + char buf[4096]; + + if (!inst || !inst->mixer) return; + if (!(con = e_container_current_get(e_manager_current_get()))) return; + + ci = _mixer_config_item_get(inst->mixer, inst->gcc->id); + if (!ci) return; + + if (!(win = inst->mixer->gauge_win)) + { + win = E_NEW(Mixer_Win_Gauge, 1); + win->mixer = inst->mixer; + inst->mixer->gauge_win = win; + win->window = e_popup_new(e_zone_current_get(con), 0, 0, 0, 0); + win->bg_obj = edje_object_add(win->window->evas); + e_theme_edje_object_set(win->bg_obj, "base/theme/menus", + "e/widgets/menu/default/background"); + edje_object_part_text_set(win->bg_obj, "e.text.title", D_("Volume")); + edje_object_signal_emit(win->bg_obj, "e,action,show,title", "e"); + edje_object_message_signal_process(win->bg_obj); + + win->pulsar = edje_object_add(win->window->evas); + snprintf(buf, sizeof(buf), "%s/mixer.edj", + e_module_dir_get(mixer_config->module)); + edje_object_file_set(win->pulsar, buf, "e/modules/mixer/pulsar"); + evas_object_show(win->pulsar); + evas_object_move(win->pulsar, -10, 0); + evas_object_resize(win->pulsar, 300, 90); + + evas_object_show(win->bg_obj); + evas_object_move(win->bg_obj, 0, 0); + evas_object_resize(win->bg_obj, 300, 90); + e_popup_resize(win->window, 300, 90); + } + else + { + win = inst->mixer->gauge_win; + } + + e_popup_move(win->window, (con->w/2.0)-150, (con->h/2.0)-45); + e_popup_show(win->window); + + if (win->timer) ecore_timer_del(win->timer); + + win->timer = ecore_timer_add(3.0, _mixer_window_gauge_visible_cb, win); +} + +static void +_mixer_window_gauge_send_vol(Mixer_Win_Gauge *win, Mixer *mixer, Config_Item *ci) +{ + Edje_Message_Int *msg; + int vol; + + if (!mixer || !mixer->mix_sys || !mixer->mix_sys->get_volume) return; + msg = malloc(sizeof(Edje_Message_Int)); + vol = (int)mixer->mix_sys->get_volume(ci->card_id, ci->channel_id); + msg->val = vol; + + edje_object_message_send(win->pulsar, EDJE_MESSAGE_INT, 0, msg); + free(msg); +} + +/* Increase the volume by VOL_STEP */ +static void +_mixer_volume_increase(Mixer *mixer, Config_Item *ci) +{ + int m; + double vol; + + if (!mixer) return; + if (!mixer->mix_sys) return; + if (!mixer->mix_sys->get_mute) return; + if (!mixer->mix_sys->get_volume) return; + if (!mixer->mix_sys->set_volume) return; + if (!ci) return; + + m = mixer->mix_sys->get_mute(ci->card_id, ci->channel_id); + if (m) return; + + if ((ci->card_id != 0) && (ci->channel_id != 0)) + { + vol = mixer->mix_sys->get_volume(ci->card_id, ci->channel_id); + mixer->mix_sys->set_volume(ci->card_id, ci->channel_id, vol+VOL_STEP); + } +} + +/* Decrease the volume by VOL_STEP */ +static void +_mixer_volume_decrease(Mixer *mixer, Config_Item *ci) +{ + int m; + double vol; + + if (!mixer) return; + if (!mixer->mix_sys) return; + if (!mixer->mix_sys->get_mute) return; + if (!mixer->mix_sys->set_volume) return; + if (!ci) return; + + m = mixer->mix_sys->get_mute(ci->card_id, ci->channel_id); + if (m) return; + + if ((ci->card_id != 0) && (ci->channel_id != 0)) + { + vol = mixer->mix_sys->get_volume(ci->card_id, ci->channel_id); + vol = vol-VOL_STEP < 0 ? 0 : vol-VOL_STEP; + mixer->mix_sys->set_volume(ci->card_id, ci->channel_id, vol); + } +} + =================================================================== RCS file: /cvs/e/e_modules/mixer/e_mod_main.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- e_mod_main.h 12 Oct 2006 18:29:04 -0000 1.8 +++ e_mod_main.h 11 Nov 2006 19:58:58 -0000 1.9 @@ -13,6 +13,10 @@ E_Menu *menu; Evas_List *instances; Evas_List *items; + + E_Config_Binding_Key decrease_vol_key; + E_Config_Binding_Key increase_vol_key; + E_Config_Binding_Key mute_key; }; struct _Config_Item =================================================================== RCS file: /cvs/e/e_modules/mixer/e_mod_types.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- e_mod_types.h 12 Sep 2006 16:53:46 -0000 1.9 +++ e_mod_types.h 11 Nov 2006 19:58:58 -0000 1.10 @@ -4,6 +4,7 @@ typedef struct _Instance Instance; typedef struct _Mixer Mixer; typedef struct _Mixer_Win_Simple Mixer_Win_Simple; +typedef struct _Mixer_Win_Gauge Mixer_Win_Gauge; typedef struct _Mixer_System Mixer_System; typedef struct _Mixer_Card Mixer_Card; typedef struct _Mixer_Channel Mixer_Channel; @@ -22,6 +23,7 @@ Mixer_System *mix_sys; Mixer_Win_Simple *simple_win; + Mixer_Win_Gauge *gauge_win; Evas_Object *base; }; @@ -50,6 +52,17 @@ int mute; Ecore_Animator *slide_timer; +}; + +struct _Mixer_Win_Gauge +{ + Mixer *mixer; + E_Popup *window; + + Evas_Object *bg_obj; + Evas_Object *pulsar; + + Ecore_Timer *timer; }; struct _Mixer_System =================================================================== RCS file: /cvs/e/e_modules/mixer/mixer.edc,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- mixer.edc 11 Sep 2006 10:03:21 -0000 1.4 +++ mixer.edc 11 Nov 2006 19:58:58 -0000 1.5 @@ -100,3 +100,5 @@ } /* end programs */ } /* end group */ } /* end collections */ + +#include "pulsar.edc" ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs