forked from enlightenment/enlightenment
module overhaul, passes -Wextra and reports more errors.
* check_changed for both basic and advanced dialog modes; * disable sliders and other widgets that depend on the checkbox; * smaller sliders; * ensure there is a timer if alert is set; * check all fgets() return, report error if format was not expected, simplify some cases. SVN revision: 46802
This commit is contained in:
parent
cada5ccf88
commit
4a4faa95b5
|
@ -2,6 +2,10 @@
|
|||
* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
@ -11,6 +15,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
# include <sys/sysctl.h>
|
||||
|
@ -64,15 +69,13 @@ static int have_power = -2;
|
|||
static int
|
||||
int_file_get(const char *file)
|
||||
{
|
||||
FILE *f;
|
||||
int val = -1;
|
||||
char buf[256];
|
||||
|
||||
f = fopen(file, "r");
|
||||
FILE *f = fopen(file, "r");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f);
|
||||
val = atoi(buf);
|
||||
char buf[256];
|
||||
char *str = fgets(buf, sizeof(buf), f);
|
||||
if (str) val = atoi(str);
|
||||
fclose(f);
|
||||
}
|
||||
return val;
|
||||
|
@ -81,52 +84,85 @@ int_file_get(const char *file)
|
|||
static char *
|
||||
str_file_get(const char *file)
|
||||
{
|
||||
FILE *f;
|
||||
char *val = NULL;
|
||||
char buf[4096];
|
||||
int len;
|
||||
|
||||
f = fopen(file, "r");
|
||||
FILE *f = fopen(file, "r");
|
||||
if (f)
|
||||
{
|
||||
fgets(buf, sizeof(buf), f);
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
len = strlen(buf);
|
||||
if (len > 0) buf[len - 1] = 0;
|
||||
val = strdup(buf);
|
||||
char buf[PATH_MAX];
|
||||
char *str = fgets(buf, sizeof(buf), f);
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str);
|
||||
if ((len > 0) && (str[len - 1] == '\n'))
|
||||
{
|
||||
len--;
|
||||
str[len] = 0;
|
||||
}
|
||||
val = malloc(len + 1);
|
||||
if (val) memcpy(val, str, len + 1);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
static int
|
||||
int_get(char *buf)
|
||||
int_get(const char *buf)
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
p = strchr(buf, ':');
|
||||
const char *p = strchr(buf, ':');
|
||||
if (!p) return 0;
|
||||
p++;
|
||||
while (*p == ' ') p++;
|
||||
q = p;
|
||||
while ((*q != ' ') && (*q != '\n')) q++;
|
||||
if (q) *q = 0;
|
||||
return atoi(p);
|
||||
}
|
||||
|
||||
static char *
|
||||
str_get(char *buf)
|
||||
str_get(const char *buf)
|
||||
{
|
||||
char *p, *q;
|
||||
|
||||
p = strchr(buf, ':');
|
||||
const char *p = strchr(buf, ':');
|
||||
const char *q;
|
||||
char *ret;
|
||||
|
||||
if (!p) return NULL;
|
||||
p++;
|
||||
while (*p == ' ') p++;
|
||||
q = p;
|
||||
while ((*q) && (*q != ' ') && (*q != '\n')) q++;
|
||||
if (q) *q = 0;
|
||||
return strdup(p);
|
||||
|
||||
q = p + strlen(p) - 1;
|
||||
while ((q > p) && ((*q == ' ') || (*q == '\n'))) q--;
|
||||
|
||||
if (q < p) return NULL;
|
||||
q++;
|
||||
ret = malloc(q - p + 1);
|
||||
if (!ret) return NULL;
|
||||
memcpy(ret, p, q - p);
|
||||
ret[q - p] = '\0';
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *
|
||||
file_str_entry_get(FILE *f, const char *entry)
|
||||
{
|
||||
char buf[4096];
|
||||
char *tmp;
|
||||
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (!tmp)
|
||||
{
|
||||
EINA_LOG_ERR("unexpected end of file, expected: '%s'", entry);
|
||||
return NULL;
|
||||
}
|
||||
if (strcmp(tmp, entry) != 0)
|
||||
{
|
||||
EINA_LOG_ERR("unexpected file entry, expected: '%s'", entry);
|
||||
return NULL;
|
||||
}
|
||||
tmp = str_get(tmp);
|
||||
if (!tmp)
|
||||
{
|
||||
EINA_LOG_ERR("unexpected file entry, missing value for '%s'", entry);
|
||||
return NULL;
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
|
@ -848,7 +884,7 @@ static int event_fd = -1;
|
|||
static Ecore_Fd_Handler *event_fd_handler = NULL;
|
||||
|
||||
static int
|
||||
linux_acpi_cb_delay_check(void *data)
|
||||
linux_acpi_cb_delay_check(void *data __UNUSED__)
|
||||
{
|
||||
linux_acpi_init();
|
||||
poll_cb(NULL);
|
||||
|
@ -857,13 +893,13 @@ linux_acpi_cb_delay_check(void *data)
|
|||
}
|
||||
|
||||
static int
|
||||
linux_acpi_cb_acpid_add(void *data, int type, void *event)
|
||||
linux_acpi_cb_acpid_add(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
linux_acpi_cb_acpid_del(void *data, int type, void *event)
|
||||
linux_acpi_cb_acpid_del(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
ecore_con_server_del(acpid);
|
||||
acpid = NULL;
|
||||
|
@ -877,7 +913,7 @@ linux_acpi_cb_acpid_del(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static int
|
||||
linux_acpi_cb_acpid_data(void *data, int type, void *event)
|
||||
linux_acpi_cb_acpid_data(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
if (delay_check) ecore_timer_del(delay_check);
|
||||
delay_check = ecore_timer_add(0.2, linux_acpi_cb_delay_check, NULL);
|
||||
|
@ -885,7 +921,7 @@ linux_acpi_cb_acpid_data(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static int
|
||||
linux_acpi_cb_event_fd_active(void *data, Ecore_Fd_Handler *fd_handler)
|
||||
linux_acpi_cb_event_fd_active(void *data __UNUSED__, Ecore_Fd_Handler *fd_handler)
|
||||
{
|
||||
if (ecore_main_fd_handler_active_get(fd_handler, ECORE_FD_READ))
|
||||
{
|
||||
|
@ -950,8 +986,8 @@ linux_acpi_init(void)
|
|||
char *tmp;
|
||||
|
||||
/* state */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (tmp) tmp = str_get(tmp);
|
||||
if (tmp)
|
||||
{
|
||||
if (!strcmp(tmp, "on-line")) have_power = 1;
|
||||
|
@ -978,24 +1014,24 @@ linux_acpi_init(void)
|
|||
char *tmp;
|
||||
|
||||
/* present */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (tmp) tmp = str_get(tmp);
|
||||
if (tmp)
|
||||
{
|
||||
if (!strcmp(tmp, "yes")) have_battery = 1;
|
||||
free(tmp);
|
||||
}
|
||||
/* design cap */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (tmp) tmp = str_get(tmp);
|
||||
if (tmp)
|
||||
{
|
||||
if (strcmp(tmp, "unknown")) acpi_max_design += atoi(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
/* last full cap */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (tmp) tmp = str_get(tmp);
|
||||
if (tmp)
|
||||
{
|
||||
if (strcmp(tmp, "unknown")) acpi_max_full += atoi(tmp);
|
||||
|
@ -1052,60 +1088,47 @@ linux_acpi_check(void)
|
|||
char *name;
|
||||
int rate = 0;
|
||||
int capacity = 0;
|
||||
|
||||
|
||||
EINA_LIST_FREE(bats, name)
|
||||
{
|
||||
char buf[4096];
|
||||
char *tmp;
|
||||
FILE *f;
|
||||
|
||||
snprintf(buf, sizeof(buf), "/proc/acpi/battery/%s/state", name);
|
||||
f = fopen(buf, "r");
|
||||
if (f)
|
||||
{
|
||||
char *tmp;
|
||||
|
||||
/* present */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
if (tmp)
|
||||
{
|
||||
if (!strcasecmp(tmp, "yes")) have_battery = 1;
|
||||
free(tmp);
|
||||
}
|
||||
/* capacity state: ok/? */
|
||||
fgets(buf, sizeof(buf), f);
|
||||
/* charging state: charging/? */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
if (tmp)
|
||||
{
|
||||
if (have_power == 0)
|
||||
{
|
||||
if (!strcasecmp(tmp, "charging")) have_power = 1;
|
||||
}
|
||||
free(tmp);
|
||||
}
|
||||
/* present rate: unknown/NNN */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
if (tmp)
|
||||
{
|
||||
if (strcasecmp(tmp, "unknown")) rate += atoi(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
/* remaining capacity: NNN */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = str_get(buf);
|
||||
if (tmp)
|
||||
{
|
||||
if (strcasecmp(tmp, "unknown")) capacity += atoi(tmp);
|
||||
free(tmp);
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof(buf), "/proc/acpi/battery/%s/state", name);
|
||||
free(name);
|
||||
f = fopen(buf, "r");
|
||||
if (!f) continue;
|
||||
|
||||
tmp = file_str_entry_get(f, "present:");
|
||||
if (!tmp) goto fclose_and_continue;
|
||||
if (!strcasecmp(tmp, "yes")) have_battery = 1;
|
||||
free(tmp);
|
||||
|
||||
tmp = file_str_entry_get(f, "capacity state:");
|
||||
if (!tmp) goto fclose_and_continue;
|
||||
free(tmp);
|
||||
|
||||
tmp = file_str_entry_get(f, "charging state:");
|
||||
if (!tmp) goto fclose_and_continue;
|
||||
if ((have_power == 0) && (!strcasecmp(tmp, "charging")))
|
||||
have_power = 1;
|
||||
free(tmp);
|
||||
|
||||
tmp = file_str_entry_get(f, "present rate:");
|
||||
if (!tmp) goto fclose_and_continue;
|
||||
if (strcasecmp(tmp, "unknown")) rate += atoi(tmp);
|
||||
free(tmp);
|
||||
|
||||
tmp = file_str_entry_get(f, "remaining capacity:");
|
||||
if (!tmp) goto fclose_and_continue;
|
||||
if (strcasecmp(tmp, "unknown")) capacity += atoi(tmp);
|
||||
free(tmp);
|
||||
|
||||
fclose_and_continue:
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
if (acpi_max_full > 0)
|
||||
battery_full = 100 * (long long)capacity / acpi_max_full;
|
||||
else if (acpi_max_design > 0)
|
||||
|
@ -1113,7 +1136,7 @@ linux_acpi_check(void)
|
|||
else
|
||||
battery_full = -1;
|
||||
if (rate <= 0) time_left = -1;
|
||||
else
|
||||
else
|
||||
{
|
||||
if (have_power)
|
||||
time_left = (3600 * ((long long)acpi_max_full - (long long)capacity)) / rate;
|
||||
|
@ -1152,31 +1175,36 @@ static void
|
|||
linux_apm_check(void)
|
||||
{
|
||||
FILE *f;
|
||||
char s[256], s1[32], s2[32], s3[32];
|
||||
char s1[32], s2[32], s3[32], *endptr;
|
||||
int apm_flags, ac_stat, bat_stat, bat_flags, bat_val, time_val;
|
||||
|
||||
|
||||
battery_full = -1;
|
||||
time_left = -1;
|
||||
have_battery = 0;
|
||||
have_power = 0;
|
||||
|
||||
|
||||
f = fopen("/proc/apm", "r");
|
||||
if (!f) return;
|
||||
|
||||
fgets(s, sizeof(s), f); s[sizeof(s) - 1] = 0;
|
||||
if (sscanf(s, "%*s %*s %x %x %x %x %s %s %s",
|
||||
|
||||
if (fscanf(f, "%*s %*s %x %x %x %x %31s %31s %31s",
|
||||
&apm_flags, &ac_stat, &bat_stat, &bat_flags, s1, s2, s3) != 7)
|
||||
{
|
||||
fclose(f);
|
||||
return;
|
||||
}
|
||||
s1[strlen(s1) - 1] = 0;
|
||||
bat_val = atoi(s1);
|
||||
fclose(f);
|
||||
|
||||
bat_val = strtol(s1, &endptr, 10);
|
||||
if (*endptr != '%')
|
||||
{
|
||||
bat_val = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp(s3, "sec")) time_val = atoi(s2);
|
||||
else if (!strcmp(s3, "min")) time_val = atoi(s2) * 60;
|
||||
else time_val = 0;
|
||||
fclose(f);
|
||||
|
||||
|
||||
if ((bat_flags != 0xff) && (bat_flags & 0x80))
|
||||
{
|
||||
have_battery = 0;
|
||||
|
@ -1264,13 +1292,30 @@ linux_pmu_check(void)
|
|||
f = fopen("/proc/pmu/info", "r");
|
||||
if (f)
|
||||
{
|
||||
char *tmp;
|
||||
/* Skip driver */
|
||||
fgets(buf, sizeof(buf), f);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (!tmp)
|
||||
{
|
||||
EINA_LOG_ERR("no driver info in /proc/pmu/info");
|
||||
goto fclose_and_continue;
|
||||
}
|
||||
/* Skip firmware */
|
||||
fgets(buf, sizeof(buf), f);
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (!tmp)
|
||||
{
|
||||
EINA_LOG_ERR("no firmware info in /proc/pmu/info");
|
||||
goto fclose_and_continue;
|
||||
}
|
||||
/* Read ac */
|
||||
fgets(buf, sizeof(buf), f); buf[sizeof(buf) - 1] = 0;
|
||||
tmp = fgets(buf, sizeof(buf), f);
|
||||
if (!tmp)
|
||||
{
|
||||
EINA_LOG_ERR("no AC info in /proc/pmu/info");
|
||||
goto fclose_and_continue;
|
||||
}
|
||||
ac = int_get(buf);
|
||||
fclose_and_continue:
|
||||
fclose(f);
|
||||
}
|
||||
bats = ecore_file_ls("/proc/pmu");
|
||||
|
@ -1429,7 +1474,7 @@ init(void)
|
|||
}
|
||||
|
||||
static int
|
||||
poll_cb(void *data)
|
||||
poll_cb(void *data __UNUSED__)
|
||||
{
|
||||
int ptime_left;
|
||||
int pbattery_full;
|
||||
|
|
|
@ -10,6 +10,13 @@ struct _E_Config_Dialog_Data
|
|||
int dismiss_alert;
|
||||
int alert_timeout;
|
||||
int force_mode; // 0 == auto, 1 == batget, 2 == hal
|
||||
struct {
|
||||
Evas_Object *show_alert_label;
|
||||
Evas_Object *show_alert_time;
|
||||
Evas_Object *show_alert_percent;
|
||||
Evas_Object *dismiss_alert_label;
|
||||
Evas_Object *alert_timeout;
|
||||
} ui;
|
||||
};
|
||||
|
||||
/* Protos */
|
||||
|
@ -17,8 +24,10 @@ static void *_create_data(E_Config_Dialog *cfd);
|
|||
static void _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _basic_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static Evas_Object *_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata);
|
||||
static int _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
static int _advanced_check_changed(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata);
|
||||
|
||||
E_Config_Dialog *
|
||||
e_int_config_battery_module(E_Container *con, const char *params __UNUSED__)
|
||||
|
@ -32,8 +41,10 @@ e_int_config_battery_module(E_Container *con, const char *params __UNUSED__)
|
|||
v->free_cfdata = _free_data;
|
||||
v->basic.apply_cfdata = _basic_apply_data;
|
||||
v->basic.create_widgets = _basic_create_widgets;
|
||||
v->basic.check_changed = _basic_check_changed;
|
||||
v->advanced.apply_cfdata = _advanced_apply_data;
|
||||
v->advanced.create_widgets = _advanced_create_widgets;
|
||||
v->advanced.check_changed = _advanced_check_changed;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/e-module-battery.edj",
|
||||
e_module_dir_get(battery_config->module));
|
||||
|
@ -66,8 +77,18 @@ _fill_data(E_Config_Dialog_Data *cfdata)
|
|||
cfdata->dismiss_alert = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_ensure_alert_time(E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if ((cfdata->alert_time > 0) || (cfdata->alert_percent > 0))
|
||||
return;
|
||||
|
||||
// must handle the case where user toggled the checkbox but set no threshold
|
||||
cfdata->alert_time = 5;
|
||||
}
|
||||
|
||||
static void *
|
||||
_create_data(E_Config_Dialog *cfd)
|
||||
_create_data(E_Config_Dialog *cfd __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata;
|
||||
|
||||
|
@ -77,7 +98,7 @@ _create_data(E_Config_Dialog *cfd)
|
|||
}
|
||||
|
||||
static void
|
||||
_free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
_free_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!battery_config) return;
|
||||
battery_config->config_dialog = NULL;
|
||||
|
@ -85,7 +106,7 @@ _free_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
}
|
||||
|
||||
static Evas_Object *
|
||||
_basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_basic_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *of, *ob;
|
||||
|
||||
|
@ -98,34 +119,63 @@ _basic_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cf
|
|||
return o;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
static int
|
||||
_basic_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!battery_config) return 0;
|
||||
|
||||
if (cfdata->show_alert)
|
||||
{
|
||||
{
|
||||
_ensure_alert_time(cfdata);
|
||||
battery_config->alert = cfdata->alert_time;
|
||||
battery_config->alert_p = cfdata->alert_percent;
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
battery_config->alert = 0;
|
||||
battery_config->alert_p = 0;
|
||||
}
|
||||
|
||||
if (cfdata->dismiss_alert)
|
||||
battery_config->alert_timeout = cfdata->alert_timeout;
|
||||
else
|
||||
battery_config->alert_timeout = 0;
|
||||
|
||||
_battery_config_updated();
|
||||
e_config_save_queue();
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_basic_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
int old_show_alert = ((battery_config->alert > 0) ||
|
||||
(battery_config->alert_p > 0));
|
||||
|
||||
return (cfdata->show_alert != old_show_alert);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_show_alert_changed(void *data, Evas_Object *obj __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = data;
|
||||
Eina_Bool show_alert = cfdata->show_alert;
|
||||
Eina_Bool dismiss_alert = cfdata->show_alert && cfdata->dismiss_alert;
|
||||
|
||||
e_widget_disabled_set(cfdata->ui.show_alert_label, !show_alert);
|
||||
e_widget_disabled_set(cfdata->ui.show_alert_time, !show_alert);
|
||||
e_widget_disabled_set(cfdata->ui.show_alert_percent, !show_alert);
|
||||
e_widget_disabled_set(cfdata->ui.dismiss_alert_label, !show_alert);
|
||||
|
||||
e_widget_disabled_set(cfdata->ui.alert_timeout, !dismiss_alert);
|
||||
}
|
||||
|
||||
static void
|
||||
_cb_dismiss_alert_changed(void *data, Evas_Object *obj __UNUSED__)
|
||||
{
|
||||
E_Config_Dialog_Data *cfdata = data;
|
||||
Eina_Bool dismiss_alert = cfdata->show_alert && cfdata->dismiss_alert;
|
||||
|
||||
e_widget_disabled_set(cfdata->ui.alert_timeout, !dismiss_alert);
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
_advanced_create_widgets(E_Config_Dialog *cfd __UNUSED__, Evas *evas, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
Evas_Object *o, *ob, *otb;
|
||||
E_Radio_Group *rg;
|
||||
|
@ -138,29 +188,39 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
ob = e_widget_label_add(evas, _("Check every:"));
|
||||
e_widget_table_object_append(o, ob, 0, 0, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f ticks"), 1, 256, 4, 0,
|
||||
NULL, &(cfdata->poll_interval), 180);
|
||||
NULL, &(cfdata->poll_interval), 100);
|
||||
e_widget_table_object_append(o, ob, 0, 1, 1, 1, 1, 0, 1, 0);
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Polling"), o, 0, 0, 0, 0,
|
||||
0.5, 0.0);
|
||||
|
||||
o = e_widget_table_add(evas, 0);
|
||||
ob = e_widget_check_add(evas, _("Show alert on low battery"),
|
||||
ob = e_widget_check_add(evas, _("Show low battery alert"),
|
||||
&(cfdata->show_alert));
|
||||
e_widget_table_object_append(o, ob, 0, 0, 1, 1, 1, 1, 1, 0);
|
||||
e_widget_on_change_hook_set(ob, _cb_show_alert_changed, cfdata);
|
||||
e_widget_table_object_append(o, ob, 0, 0, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_label_add(evas, _("Alert when at:"));
|
||||
cfdata->ui.show_alert_label = ob;
|
||||
e_widget_table_object_append(o, ob, 0, 1, 1, 1, 1, 0, 1, 1);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f min"), 0, 60, 1, 0, NULL,
|
||||
&(cfdata->alert_time), 180);
|
||||
&(cfdata->alert_time), 100);
|
||||
cfdata->ui.show_alert_time = ob;
|
||||
e_widget_table_object_append(o, ob, 0, 2, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f %%"), 0, 100, 1, 0, NULL,
|
||||
&(cfdata->alert_percent), 180);
|
||||
&(cfdata->alert_percent), 100);
|
||||
cfdata->ui.show_alert_percent = ob;
|
||||
e_widget_table_object_append(o, ob, 0, 3, 1, 1, 1, 0, 1, 0);
|
||||
ob = e_widget_check_add(evas, _("Auto dismiss in..."),
|
||||
ob = e_widget_check_add(evas, _("Auto dismiss in..."),
|
||||
&(cfdata->dismiss_alert));
|
||||
e_widget_table_object_append(o, ob, 0, 4, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f sec"), 1, 300, 1, 0, NULL,
|
||||
&(cfdata->alert_timeout), 180);
|
||||
cfdata->ui.dismiss_alert_label = ob;
|
||||
e_widget_on_change_hook_set(ob, _cb_dismiss_alert_changed, cfdata);
|
||||
e_widget_table_object_append(o, ob, 0, 4, 1, 1, 1, 1, 1, 0);
|
||||
ob = e_widget_slider_add(evas, 1, 0, _("%1.0f sec"), 1, 300, 1, 0, NULL,
|
||||
&(cfdata->alert_timeout), 100);
|
||||
cfdata->ui.alert_timeout = ob;
|
||||
e_widget_table_object_append(o, ob, 0, 5, 1, 1, 1, 0, 1, 0);
|
||||
|
||||
_cb_show_alert_changed(cfdata, NULL);
|
||||
|
||||
e_widget_toolbook_page_append(otb, NULL, _("Alert"), o, 0, 0, 0, 0,
|
||||
0.5, 0.0);
|
||||
|
||||
|
@ -181,25 +241,26 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data
|
|||
return otb;
|
||||
}
|
||||
|
||||
static int
|
||||
_advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
||||
static int
|
||||
_advanced_apply_data(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
if (!battery_config) return 0;
|
||||
|
||||
battery_config->poll_interval = cfdata->poll_interval;
|
||||
|
||||
if (cfdata->show_alert)
|
||||
{
|
||||
{
|
||||
_ensure_alert_time(cfdata);
|
||||
battery_config->alert = cfdata->alert_time;
|
||||
battery_config->alert_p = cfdata->alert_percent;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
battery_config->alert = 0;
|
||||
battery_config->alert_p = 0;
|
||||
}
|
||||
|
||||
if (cfdata->dismiss_alert)
|
||||
if ((cfdata->dismiss_alert) && (cfdata->alert_timeout > 0))
|
||||
battery_config->alert_timeout = cfdata->alert_timeout;
|
||||
else
|
||||
battery_config->alert_timeout = 0;
|
||||
|
@ -211,3 +272,19 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata)
|
|||
return 1;
|
||||
}
|
||||
|
||||
static int
|
||||
_advanced_check_changed(E_Config_Dialog *cfd __UNUSED__, E_Config_Dialog_Data *cfdata)
|
||||
{
|
||||
int old_show_alert = ((battery_config->alert > 0) ||
|
||||
(battery_config->alert_p > 0));
|
||||
int old_dismiss_alert = (battery_config->alert_timeout > 0);
|
||||
|
||||
return ((cfdata->alert_time != battery_config->alert) ||
|
||||
(cfdata->alert_percent != battery_config->alert_p) ||
|
||||
(cfdata->poll_interval != battery_config->poll_interval) ||
|
||||
(cfdata->alert_timeout != battery_config->alert_timeout) ||
|
||||
(cfdata->force_mode != battery_config->force_mode) ||
|
||||
(cfdata->show_alert != old_show_alert) ||
|
||||
(cfdata->dismiss_alert != old_dismiss_alert));
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ _gc_shutdown(E_Gadcon_Client *gcc)
|
|||
}
|
||||
|
||||
static void
|
||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
||||
_gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient __UNUSED__)
|
||||
{
|
||||
Instance *inst;
|
||||
Evas_Coord mw, mh, mxw, mxh;
|
||||
|
@ -130,13 +130,13 @@ _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
|
|||
}
|
||||
|
||||
static char *
|
||||
_gc_label(E_Gadcon_Client_Class *client_class)
|
||||
_gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
|
||||
{
|
||||
return _("Battery");
|
||||
}
|
||||
|
||||
static Evas_Object *
|
||||
_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas)
|
||||
_gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
|
||||
{
|
||||
Evas_Object *o;
|
||||
char buf[4096];
|
||||
|
@ -149,7 +149,7 @@ _gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas)
|
|||
}
|
||||
|
||||
static const char *
|
||||
_gc_id_new(E_Gadcon_Client_Class *client_class)
|
||||
_gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
|
||||
{
|
||||
return _gadcon_class.name;
|
||||
}
|
||||
|
@ -191,7 +191,7 @@ _button_cb_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
_menu_cb_post(void *data, E_Menu *m)
|
||||
_menu_cb_post(void *data __UNUSED__, E_Menu *m __UNUSED__)
|
||||
{
|
||||
if (!battery_config->menu) return;
|
||||
e_object_del(E_OBJECT(battery_config->menu));
|
||||
|
@ -227,8 +227,8 @@ _battery_face_time_set(Evas_Object *battery, int time_left)
|
|||
edje_object_part_text_set(battery, "e.text.time", buf);
|
||||
}
|
||||
|
||||
static void
|
||||
_battery_face_cb_menu_configure(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
static void
|
||||
_battery_face_cb_menu_configure(void *data __UNUSED__, E_Menu *m, E_Menu_Item *mi __UNUSED__)
|
||||
{
|
||||
if (!battery_config) return;
|
||||
if (battery_config->config_dialog) return;
|
||||
|
@ -389,7 +389,7 @@ _battery_hal_shutdown(void)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_battery_props(void *data, void *reply_data, DBusError *error)
|
||||
_battery_hal_battery_props(void *data, void *reply_data, DBusError *error __UNUSED__)
|
||||
{
|
||||
E_Hal_Properties *ret = reply_data;
|
||||
int err = 0;
|
||||
|
@ -434,7 +434,7 @@ _battery_hal_battery_props(void *data, void *reply_data, DBusError *error)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_ac_adapter_props(void *data, void *reply_data, DBusError *error)
|
||||
_battery_hal_ac_adapter_props(void *data, void *reply_data, DBusError *error __UNUSED__)
|
||||
{
|
||||
E_Hal_Properties *ret = reply_data;
|
||||
int err = 0;
|
||||
|
@ -464,7 +464,7 @@ _battery_hal_ac_adapter_props(void *data, void *reply_data, DBusError *error)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_battery_property_changed(void *data, DBusMessage *msg)
|
||||
_battery_hal_battery_property_changed(void *data, DBusMessage *msg __UNUSED__)
|
||||
{
|
||||
E_DBus_Connection *conn;
|
||||
|
||||
|
@ -476,7 +476,7 @@ _battery_hal_battery_property_changed(void *data, DBusMessage *msg)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_ac_adapter_property_changed(void *data, DBusMessage *msg)
|
||||
_battery_hal_ac_adapter_property_changed(void *data, DBusMessage *msg __UNUSED__)
|
||||
{
|
||||
E_DBus_Connection *conn;
|
||||
|
||||
|
@ -585,7 +585,7 @@ _battery_hal_ac_adapter_del(const char *udi)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_find_battery(void *user_data, void *reply_data, DBusError *error)
|
||||
_battery_hal_find_battery(void *user_data __UNUSED__, void *reply_data, DBusError *error __UNUSED__)
|
||||
{
|
||||
Eina_List *l;
|
||||
char *device;
|
||||
|
@ -599,7 +599,7 @@ _battery_hal_find_battery(void *user_data, void *reply_data, DBusError *error)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_find_ac(void *user_data, void *reply_data, DBusError *err)
|
||||
_battery_hal_find_ac(void *user_data __UNUSED__, void *reply_data, DBusError *err __UNUSED__)
|
||||
{
|
||||
Eina_List *l;
|
||||
char *device;
|
||||
|
@ -649,7 +649,7 @@ _battery_hal_is_ac_adapter(void *user_data, void *reply_data, DBusError *err)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_dev_add(void *data, DBusMessage *msg)
|
||||
_battery_hal_dev_add(void *data __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBusError err;
|
||||
char *udi = NULL;
|
||||
|
@ -668,7 +668,7 @@ _battery_hal_dev_add(void *data, DBusMessage *msg)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_dev_del(void *data, DBusMessage *msg)
|
||||
_battery_hal_dev_del(void *data __UNUSED__, DBusMessage *msg)
|
||||
{
|
||||
DBusError err;
|
||||
char *udi = NULL;
|
||||
|
@ -681,7 +681,7 @@ _battery_hal_dev_del(void *data, DBusMessage *msg)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_hal_have_hal(void *data, DBusMessage *msg, DBusError *err)
|
||||
_battery_hal_have_hal(void *data __UNUSED__, DBusMessage *msg, DBusError *err)
|
||||
{
|
||||
dbus_bool_t ok = 0;
|
||||
E_DBus_Connection *conn;
|
||||
|
@ -790,7 +790,7 @@ _battery_cb_warning_popup_timeout(void *data)
|
|||
}
|
||||
|
||||
static void
|
||||
_battery_cb_warning_popup_hide(void *data, Evas *e, Evas_Object *obj, void *event)
|
||||
_battery_cb_warning_popup_hide(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event __UNUSED__)
|
||||
{
|
||||
Instance *inst = NULL;
|
||||
|
||||
|
@ -968,7 +968,7 @@ _battery_update(int full, int time_left, int have_battery, int have_power)
|
|||
}
|
||||
|
||||
static int
|
||||
_battery_cb_exe_data(void *data, int type, void *event)
|
||||
_battery_cb_exe_data(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Ecore_Exe_Event_Data *ev;
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ _battery_cb_exe_data(void *data, int type, void *event)
|
|||
}
|
||||
|
||||
static int
|
||||
_battery_cb_exe_del(void *data, int type, void *event)
|
||||
_battery_cb_exe_del(void *data __UNUSED__, int type __UNUSED__, void *event)
|
||||
{
|
||||
Ecore_Exe_Event_Del *ev;
|
||||
|
||||
|
@ -1100,7 +1100,7 @@ e_modapi_init(E_Module *m)
|
|||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_shutdown(E_Module *m)
|
||||
e_modapi_shutdown(E_Module *m __UNUSED__)
|
||||
{
|
||||
e_configure_registry_item_del("advanced/battery");
|
||||
e_configure_registry_category_del("advanced");
|
||||
|
@ -1145,7 +1145,7 @@ e_modapi_shutdown(E_Module *m)
|
|||
}
|
||||
|
||||
EAPI int
|
||||
e_modapi_save(E_Module *m)
|
||||
e_modapi_save(E_Module *m __UNUSED__)
|
||||
{
|
||||
e_config_domain_save("module.battery", conf_edd, battery_config);
|
||||
return 1;
|
||||
|
|
Loading…
Reference in New Issue