Merge branch 'multi-battery-support' into 'master'

Multi battery support

Hi ,

I have a couple of patches for the battery widget
making it actually useful on my ThinkPad X250.

-- Sebastian

See merge request !6
This commit is contained in:
o9000
2015-08-06 20:38:29 +00:00
8 changed files with 429 additions and 184 deletions

View File

@@ -92,6 +92,7 @@ GtkWidget *clock_background;
GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color;
GtkWidget *battery_background;
GtkWidget *battery_tooltip;
GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command;
// systray
@@ -3829,6 +3830,20 @@ void create_battery(GtkWidget *parent)
gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING);
row = 0, col = 2;
label = gtk_label_new(_("Tooltips"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);
gtk_table_attach(GTK_TABLE(table), label, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
battery_tooltip = gtk_check_button_new();
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), 1);
gtk_widget_show(battery_tooltip);
gtk_table_attach(GTK_TABLE(table), battery_tooltip, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_tooltip, _("If enabled, shows a tooltip with detailed battery information when the mouse is moved over the battery widget."), NULL);
row++, col = 2;
label = gtk_label_new(_("Left click command"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_widget_show(label);

View File

@@ -95,6 +95,7 @@ extern GtkWidget *clock_background;
extern GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
extern GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_font_line2, *battery_font_color;
extern GtkWidget *battery_background;
extern GtkWidget *battery_tooltip;
extern GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command;
// systray

View File

@@ -560,6 +560,7 @@ void config_write_battery(FILE *fp)
fprintf(fp, "#-------------------------------------\n");
fprintf(fp, "# Battery\n");
fprintf(fp, "battery_tooltip = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(battery_tooltip)) ? 1 : 0);
fprintf(fp, "battery_low_status = %g\n", gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_alert_if_lower)));
fprintf(fp, "battery_low_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_alert_cmd)));
fprintf(fp, "bat1_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(battery_font_line1)));
@@ -898,12 +899,13 @@ void add_entry(char *key, char *value)
}
/* Battery */
else if (strcmp(key, "systray") == 0) {
else if (strcmp(key, "battery") == 0) {
// Obsolete option
config_has_battery = 1;
config_battery_enabled = atoi(value);
}
else if (strcmp(key, "battery_low_status") == 0) {
} else if (strcmp(key, "battery_tooltip") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_tooltip), atoi(value));
} else if (strcmp(key, "battery_low_status") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_alert_if_lower), atof(value));
}
else if (strcmp(key, "battery_low_cmd") == 0) {
@@ -1464,4 +1466,4 @@ char *get_action(GtkWidget *combo)
if (gtk_combo_box_get_active(GTK_COMBO_BOX(combo)) == 10)
return "prev_task";
return "none";
}
}