if( -> if (
This commit is contained in:
parent
03dd8b8483
commit
00a1803348
6 changed files with 25 additions and 25 deletions
|
@ -75,7 +75,7 @@ void update_battery_tick(void* arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (old_ac_connected != battery_state.ac_connected) {
|
if (old_ac_connected != battery_state.ac_connected) {
|
||||||
if(battery_state.ac_connected)
|
if (battery_state.ac_connected)
|
||||||
tint_exec(ac_connected_cmd);
|
tint_exec(ac_connected_cmd);
|
||||||
else
|
else
|
||||||
tint_exec(ac_disconnected_cmd);
|
tint_exec(ac_disconnected_cmd);
|
||||||
|
|
|
@ -82,7 +82,7 @@ static struct uevent_notify psy_plug = {
|
||||||
uevent_battery_plug
|
uevent_battery_plug
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RETURN_ON_ERROR(err) if(error) { g_error_free(err); return FALSE; }
|
#define RETURN_ON_ERROR(err) if (error) { g_error_free(err); return FALSE; }
|
||||||
|
|
||||||
static GList *batteries = NULL;
|
static GList *batteries = NULL;
|
||||||
static GList *mains = NULL;
|
static GList *mains = NULL;
|
||||||
|
@ -104,12 +104,12 @@ static enum psy_type power_supply_get_type(const gchar *entryname) {
|
||||||
return PSY_UNKNOWN;
|
return PSY_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!g_strcmp0(type, "Battery\n")) {
|
if (!g_strcmp0(type, "Battery\n")) {
|
||||||
g_free(type);
|
g_free(type);
|
||||||
return PSY_BATTERY;
|
return PSY_BATTERY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!g_strcmp0(type, "Mains\n")) {
|
if (!g_strcmp0(type, "Mains\n")) {
|
||||||
g_free(type);
|
g_free(type);
|
||||||
return PSY_MAINS;
|
return PSY_MAINS;
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ static gboolean init_linux_battery(struct psy_battery *bat) {
|
||||||
goto err1;
|
goto err1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!bat->energy_in_uamp) {
|
if (!bat->energy_in_uamp) {
|
||||||
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "energy_full", NULL);
|
bat->path_energy_full = g_build_filename("/sys/class/power_supply", entryname, "energy_full", NULL);
|
||||||
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
if (!g_file_test(bat->path_energy_full, G_FILE_TEST_EXISTS))
|
||||||
goto err2;
|
goto err2;
|
||||||
|
@ -234,7 +234,7 @@ static void add_battery(const char *entryname) {
|
||||||
struct psy_battery *bat = g_malloc0(sizeof(*bat));
|
struct psy_battery *bat = g_malloc0(sizeof(*bat));
|
||||||
bat->name = g_strdup(entryname);
|
bat->name = g_strdup(entryname);
|
||||||
|
|
||||||
if(init_linux_battery(bat)) {
|
if (init_linux_battery(bat)) {
|
||||||
batteries = g_list_append(batteries, bat);
|
batteries = g_list_append(batteries, bat);
|
||||||
fprintf(stdout, "found battery \"%s\"\n", bat->name);
|
fprintf(stdout, "found battery \"%s\"\n", bat->name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -247,7 +247,7 @@ static void add_mains(const char *entryname) {
|
||||||
struct psy_mains *ac = g_malloc0(sizeof(*ac));
|
struct psy_mains *ac = g_malloc0(sizeof(*ac));
|
||||||
ac->name = g_strdup(entryname);
|
ac->name = g_strdup(entryname);
|
||||||
|
|
||||||
if(init_linux_mains(ac)) {
|
if (init_linux_mains(ac)) {
|
||||||
mains = g_list_append(mains, ac);
|
mains = g_list_append(mains, ac);
|
||||||
fprintf(stdout, "found mains \"%s\"\n", ac->name);
|
fprintf(stdout, "found mains \"%s\"\n", ac->name);
|
||||||
} else {
|
} else {
|
||||||
|
@ -308,7 +308,7 @@ static gboolean update_linux_battery(struct psy_battery *bat) {
|
||||||
g_free(data);
|
g_free(data);
|
||||||
|
|
||||||
/* we are done, if battery is not present */
|
/* we are done, if battery is not present */
|
||||||
if(!bat->present)
|
if (!bat->present)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
/* status */
|
/* status */
|
||||||
|
@ -403,9 +403,9 @@ int battery_os_update(struct batstate *state) {
|
||||||
|
|
||||||
/* calculate seconds */
|
/* calculate seconds */
|
||||||
if (total_power_now > 0) {
|
if (total_power_now > 0) {
|
||||||
if(state->state == BATTERY_CHARGING)
|
if (state->state == BATTERY_CHARGING)
|
||||||
seconds = 3600 * (total_energy_full - total_energy_now) / total_power_now;
|
seconds = 3600 * (total_energy_full - total_energy_now) / total_power_now;
|
||||||
else if(state->state == BATTERY_DISCHARGING)
|
else if (state->state == BATTERY_DISCHARGING)
|
||||||
seconds = 3600 * total_energy_now / total_power_now;
|
seconds = 3600 * total_energy_now / total_power_now;
|
||||||
}
|
}
|
||||||
batstate_set_time(state, seconds);
|
batstate_set_time(state, seconds);
|
||||||
|
|
|
@ -354,7 +354,7 @@ void add_entry (char *key, char *value)
|
||||||
else if (strcmp (key, "battery_low_status") == 0) {
|
else if (strcmp (key, "battery_low_status") == 0) {
|
||||||
#ifdef ENABLE_BATTERY
|
#ifdef ENABLE_BATTERY
|
||||||
battery_low_status = atoi(value);
|
battery_low_status = atoi(value);
|
||||||
if(battery_low_status < 0 || battery_low_status > 100)
|
if (battery_low_status < 0 || battery_low_status > 100)
|
||||||
battery_low_status = 0;
|
battery_low_status = 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
16
src/tint.c
16
src/tint.c
|
@ -438,7 +438,7 @@ int tint2_handles_click(Panel* panel, XButtonEvent* e)
|
||||||
{
|
{
|
||||||
Task* task = click_task(panel, e->x, e->y);
|
Task* task = click_task(panel, e->x, e->y);
|
||||||
if (task) {
|
if (task) {
|
||||||
if( (e->button == 1 && mouse_left != 0)
|
if ( (e->button == 1 && mouse_left != 0)
|
||||||
|| (e->button == 2 && mouse_middle != 0)
|
|| (e->button == 2 && mouse_middle != 0)
|
||||||
|| (e->button == 3 && mouse_right != 0)
|
|| (e->button == 3 && mouse_right != 0)
|
||||||
|| (e->button == 4 && mouse_scroll_up != 0)
|
|| (e->button == 4 && mouse_scroll_up != 0)
|
||||||
|
@ -521,27 +521,27 @@ void event_button_press (XEvent *e)
|
||||||
void event_button_motion_notify (XEvent *e)
|
void event_button_motion_notify (XEvent *e)
|
||||||
{
|
{
|
||||||
Panel * panel = get_panel(e->xany.window);
|
Panel * panel = get_panel(e->xany.window);
|
||||||
if(!panel || !task_drag)
|
if (!panel || !task_drag)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find the taskbar on the event's location
|
// Find the taskbar on the event's location
|
||||||
Taskbar * event_taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y);
|
Taskbar * event_taskbar = click_taskbar(panel, e->xbutton.x, e->xbutton.y);
|
||||||
if(event_taskbar == NULL)
|
if (event_taskbar == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find the task on the event's location
|
// Find the task on the event's location
|
||||||
Task * event_task = click_task(panel, e->xbutton.x, e->xbutton.y);
|
Task * event_task = click_task(panel, e->xbutton.x, e->xbutton.y);
|
||||||
|
|
||||||
// If the event takes place on the same taskbar as the task being dragged
|
// If the event takes place on the same taskbar as the task being dragged
|
||||||
if(event_taskbar == task_drag->area.parent) {
|
if (event_taskbar == task_drag->area.parent) {
|
||||||
if (taskbar_sort_method != TASKBAR_NOSORT) {
|
if (taskbar_sort_method != TASKBAR_NOSORT) {
|
||||||
sort_tasks(event_taskbar);
|
sort_tasks(event_taskbar);
|
||||||
} else {
|
} else {
|
||||||
// Swap the task_drag with the task on the event's location (if they differ)
|
// Swap the task_drag with the task on the event's location (if they differ)
|
||||||
if(event_task && event_task != task_drag) {
|
if (event_task && event_task != task_drag) {
|
||||||
GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag);
|
GList * drag_iter = g_list_find(event_taskbar->area.list, task_drag);
|
||||||
GList * task_iter = g_list_find(event_taskbar->area.list, event_task);
|
GList * task_iter = g_list_find(event_taskbar->area.list, event_task);
|
||||||
if(drag_iter && task_iter) {
|
if (drag_iter && task_iter) {
|
||||||
gpointer temp = task_iter->data;
|
gpointer temp = task_iter->data;
|
||||||
task_iter->data = drag_iter->data;
|
task_iter->data = drag_iter->data;
|
||||||
drag_iter->data = temp;
|
drag_iter->data = temp;
|
||||||
|
@ -553,13 +553,13 @@ void event_button_motion_notify (XEvent *e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else { // The event is on another taskbar than the task being dragged
|
else { // The event is on another taskbar than the task being dragged
|
||||||
if(task_drag->desktop == ALLDESKTOP || panel_mode != MULTI_DESKTOP)
|
if (task_drag->desktop == ALLDESKTOP || panel_mode != MULTI_DESKTOP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent;
|
Taskbar * drag_taskbar = (Taskbar*)task_drag->area.parent;
|
||||||
drag_taskbar->area.list = g_list_remove(drag_taskbar->area.list, task_drag);
|
drag_taskbar->area.list = g_list_remove(drag_taskbar->area.list, task_drag);
|
||||||
|
|
||||||
if(event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) {
|
if (event_taskbar->area.posx > drag_taskbar->area.posx || event_taskbar->area.posy > drag_taskbar->area.posy) {
|
||||||
int i = (taskbarname_enabled) ? 1 : 0;
|
int i = (taskbarname_enabled) ? 1 : 0;
|
||||||
event_taskbar->area.list = g_list_insert(event_taskbar->area.list, task_drag, i);
|
event_taskbar->area.list = g_list_insert(event_taskbar->area.list, task_drag, i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,15 +20,15 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void fxfree(void** ptr){
|
void fxfree(void** ptr){
|
||||||
if(*ptr){
|
if (*ptr){
|
||||||
free(*ptr);
|
free(*ptr);
|
||||||
*ptr=NULL;
|
*ptr=NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FXint fxmalloc(void** ptr,unsigned long size){
|
FXint fxmalloc(void** ptr,unsigned long size){
|
||||||
*ptr=NULL;
|
*ptr=NULL;
|
||||||
if(size!=0){
|
if (size!=0){
|
||||||
if((*ptr=malloc(size))==NULL) return FALSE;
|
if ((*ptr=malloc(size))==NULL) return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -108,7 +108,7 @@ static struct uevent *uevent_new(char *buffer, int size) {
|
||||||
val = strchr(s, '=');
|
val = strchr(s, '=');
|
||||||
if (val) {
|
if (val) {
|
||||||
struct uevent_parameter *param = malloc(sizeof(*param));
|
struct uevent_parameter *param = malloc(sizeof(*param));
|
||||||
if(param) {
|
if (param) {
|
||||||
param->key = strndup(s, val-s);
|
param->key = strndup(s, val-s);
|
||||||
param->val = strdup(val+1);
|
param->val = strdup(val+1);
|
||||||
ev->params = g_list_append(ev->params, param);
|
ev->params = g_list_append(ev->params, param);
|
||||||
|
@ -132,7 +132,7 @@ void uevent_unregister_notifier(struct uevent_notify *nb) {
|
||||||
GList *next = l->next;
|
GList *next = l->next;
|
||||||
struct uevent_notify *lnb = l->data;
|
struct uevent_notify *lnb = l->data;
|
||||||
|
|
||||||
if(memcmp(nb, lnb, sizeof(struct uevent_notify)) == 0)
|
if (memcmp(nb, lnb, sizeof(struct uevent_notify)) == 0)
|
||||||
notifiers = g_list_delete_link(notifiers, l);
|
notifiers = g_list_delete_link(notifiers, l);
|
||||||
|
|
||||||
l = next;
|
l = next;
|
||||||
|
@ -152,7 +152,7 @@ void uevent_handler() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ev = uevent_new(buf, len);
|
ev = uevent_new(buf, len);
|
||||||
if(ev) {
|
if (ev) {
|
||||||
for (l = notifiers; l != NULL; l = l->next) {
|
for (l = notifiers; l != NULL; l = l->next) {
|
||||||
struct uevent_notify *nb = l->data;
|
struct uevent_notify *nb = l->data;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue