morlenxus pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=97b1caef3780f405e2e5447f50e890140fb51067

commit 97b1caef3780f405e2e5447f50e890140fb51067
Author: Brian 'morlenxus' Miculcy <morlen...@gmx.net>
Date:   Mon Sep 15 19:27:17 2014 +0200

    mixer: Optionally select an external mixer application.
    
    This feature allows to define an external mixer application, which replaces 
the internal mixer.
    Examples: 'terminology -e alsamixer', 'pavucontrol'
    @feature
---
 src/modules/mixer/conf_module.c | 29 ++++++++++++++++++++++++++---
 src/modules/mixer/e_mod_main.c  | 20 ++++++++++++++++++++
 src/modules/mixer/e_mod_main.h  |  6 +++++-
 3 files changed, 51 insertions(+), 4 deletions(-)

diff --git a/src/modules/mixer/conf_module.c b/src/modules/mixer/conf_module.c
index 0ee1bd4..f239e81 100644
--- a/src/modules/mixer/conf_module.c
+++ b/src/modules/mixer/conf_module.c
@@ -75,6 +75,14 @@ _basic_apply(E_Config_Dialog *dialog, E_Config_Dialog_Data 
*cfdata)
 
         conf->desktop_notification = ctxt->desktop_notification;
         conf->disable_pulse = ctxt->disable_pulse;
+
+               if ((ctxt->external_mixer_enabled) && 
(!strlen(ctxt->external_mixer_command)))
+                 return 0;
+               conf->external_mixer_enabled = ctxt->external_mixer_enabled;
+               if (conf->external_mixer_command)
+                 eina_stringshare_del(conf->external_mixer_command);
+               if (ctxt->external_mixer_enabled)
+                 conf->external_mixer_command = 
eina_stringshare_add(ctxt->external_mixer_command);
      }
 
    return 1;
@@ -85,7 +93,7 @@ _basic_create_general(E_Config_Dialog *dialog, Evas *evas, 
E_Config_Dialog_Data
 {
    struct mixer_config_ui_general *ui = &cfdata->ui.general;
    E_Mixer_Module_Context *ctxt = dialog->data;
-   Evas_Object *label, *chk;
+   Evas_Object *label, *chk, *edit;
    Eina_List *l;
    int i;
 
@@ -116,15 +124,22 @@ _basic_create_general(E_Config_Dialog *dialog, Evas 
*evas, E_Config_Dialog_Data
 
    e_widget_list_object_append(cfdata->ui.list, ui->frame, 1, 1, 0.5);
    chk = e_widget_check_add(evas, _("Display desktop notifications on volume 
change"), &ctxt->desktop_notification);
-   e_widget_check_checked_set(chk, ctxt->conf->desktop_notification);
+   e_widget_check_checked_set(chk, ctxt->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);
 
    chk = e_widget_check_add(evas, _("Disable PulseAudio"), 
&ctxt->disable_pulse);
-   e_widget_check_checked_set(chk, ctxt->conf->disable_pulse);
+   e_widget_check_checked_set(chk, ctxt->disable_pulse);
+   e_widget_list_object_append(cfdata->ui.list, chk, 1, 1, 0.5);
+
+   chk = e_widget_check_add(evas, _("Enable external Mixer Command"), 
&ctxt->external_mixer_enabled);
+   e_widget_check_checked_set(chk, ctxt->external_mixer_enabled);
    e_widget_list_object_append(cfdata->ui.list, chk, 1, 1, 0.5);
+
+   edit = e_widget_entry_add(evas, &ctxt->external_mixer_command, NULL, NULL, 
NULL);
+   e_widget_list_object_append(cfdata->ui.list, edit, 1, 1, 0.5);
 }
 
 static void
@@ -146,6 +161,14 @@ cb_mixer_call(void *data, void *data2 __UNUSED__)
         return;
      }
 
+   if (ctxt->conf->external_mixer_enabled)
+     {
+           E_Zone *zone;
+       zone = e_util_zone_current_get(e_manager_current_get());
+           e_exec (zone, NULL, ctxt->conf->external_mixer_command, NULL, NULL);
+           return;
+        }
+
    ctxt->mixer_dialog = e_mixer_app_dialog_new(NULL, cb_mixer_app_del, ctxt);
 
    for (l = ctxt->instances; l; l = l->next)
diff --git a/src/modules/mixer/e_mod_main.c b/src/modules/mixer/e_mod_main.c
index 24d252f..cb758f7 100644
--- a/src/modules/mixer/e_mod_main.c
+++ b/src/modules/mixer/e_mod_main.c
@@ -188,6 +188,8 @@ _mixer_module_configuration_new(void)
    conf = E_NEW(E_Mixer_Module_Config, 1);
    conf->desktop_notification = 1;
    conf->disable_pulse = 0;
+   conf->external_mixer_enabled = 0;
+   conf->external_mixer_command = eina_stringshare_add("");
 
    return conf;
 }
@@ -205,6 +207,9 @@ _mixer_module_configuration_free(E_Mixer_Module_Config 
*conf)
         eina_hash_free(conf->gadgets);
      }
    eina_stringshare_del(conf->default_gc_id);
+
+   if (conf->external_mixer_command)
+     eina_stringshare_del(conf->external_mixer_command);
    free(conf);
 }
 
@@ -506,6 +511,14 @@ _mixer_popup_cb_mixer(void *data, void *data2 __UNUSED__)
         return;
      }
 
+   if (ctxt->conf->external_mixer_enabled)
+     {
+           E_Zone *zone;
+       zone = e_util_zone_current_get(e_manager_current_get());
+           e_exec (zone, NULL, ctxt->conf->external_mixer_command, NULL, NULL);
+           return;
+        }
+
    ctxt->mixer_dialog = e_mixer_app_dialog_new(NULL, _mixer_app_cb_del, ctxt);
 
    _mixer_app_select_current(ctxt->mixer_dialog, inst);
@@ -1212,6 +1225,8 @@ _mixer_module_configuration_descriptor_new(E_Config_DD 
*gadget_conf_edd)
    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);
    E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, disable_pulse, INT);
+   E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, external_mixer_enabled, INT);
+   E_CONFIG_VAL(conf_edd, E_Mixer_Module_Config, external_mixer_command, STR);
 
    return conf_edd;
 }
@@ -1287,6 +1302,11 @@ _mixer_module_configuration_setup(E_Mixer_Module_Context 
*ctxt)
    ctxt->conf->version = MOD_CONFIG_FILE_VERSION;
    ctxt->desktop_notification = ctxt->conf->desktop_notification;
    ctxt->disable_pulse = ctxt->conf->disable_pulse;
+   ctxt->external_mixer_enabled = ctxt->conf->external_mixer_enabled;
+   if (ctxt->conf->external_mixer_command)
+     ctxt->external_mixer_command = strdup(ctxt->conf->external_mixer_command);
+   else
+     ctxt->external_mixer_command = strdup("");
 }
 
 static const char _act_increase[] = "volume_increase";
diff --git a/src/modules/mixer/e_mod_main.h b/src/modules/mixer/e_mod_main.h
index 063bf66..a105cd6 100644
--- a/src/modules/mixer/e_mod_main.h
+++ b/src/modules/mixer/e_mod_main.h
@@ -7,7 +7,7 @@
 /* Increment for Major Changes */
 #define MOD_CONFIG_FILE_EPOCH      1
 /* Increment for Minor Changes (ie: user doesn't need a new config) */
-#define MOD_CONFIG_FILE_GENERATION 0
+#define MOD_CONFIG_FILE_GENERATION 1
 #define MOD_CONFIG_FILE_VERSION    ((MOD_CONFIG_FILE_EPOCH * 1000000) + 
MOD_CONFIG_FILE_GENERATION)
 
 typedef struct E_Mixer_Gadget_Config
@@ -31,6 +31,8 @@ typedef struct E_Mixer_Module_Config
    Eina_Hash *gadgets;
    int desktop_notification;
    int disable_pulse;
+   int external_mixer_enabled;
+   const char *external_mixer_command;
 } E_Mixer_Module_Config;
 
 typedef struct E_Mixer_Instance
@@ -78,6 +80,8 @@ typedef struct E_Mixer_Module_Context
    } actions;
    int desktop_notification;
    int disable_pulse;
+   int external_mixer_enabled;
+   char *external_mixer_command;
 } E_Mixer_Module_Context;
 
 EAPI extern E_Module_Api e_modapi;

-- 


Reply via email to