Merge battery format from https://gitlab.com/berkley4/tint2 (issue #229)
This commit is contained in:
@@ -83,7 +83,7 @@ GtkWidget *clock_background;
|
||||
GtkWidget *battery_hide_if_higher, *battery_alert_if_lower, *battery_alert_cmd;
|
||||
GtkWidget *battery_padding_x, *battery_padding_y;
|
||||
GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set,
|
||||
*battery_font_color;
|
||||
*battery_font_color, *battery_format1, *battery_format2;
|
||||
GtkWidget *battery_background;
|
||||
GtkWidget *battery_tooltip;
|
||||
GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command,
|
||||
@@ -5749,6 +5749,46 @@ void create_battery(GtkWidget *parent)
|
||||
_("Specifies the font clor used to display the battery text."),
|
||||
NULL);
|
||||
|
||||
row++, col = 2;
|
||||
label = gtk_label_new(_("First line format"));
|
||||
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_format1 = gtk_entry_new();
|
||||
gtk_widget_show(battery_format1);
|
||||
gtk_entry_set_width_chars(GTK_ENTRY(battery_format1), 16);
|
||||
gtk_table_attach(GTK_TABLE(table), battery_format1, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
char *bat_format_spec = "Format specification:\n"
|
||||
" %s: State (charging, discharging, full, unknown).\n"
|
||||
" %m: Minutes left until completely charged/discharged (estimated).\n"
|
||||
" %h: Hours left until completely charged/discharged (estimated).\n"
|
||||
" %t: Time left. Shows \"hrs:mins\" when charging/discharging, or \"Full\".\n"
|
||||
" %p: Percentage. Includes the % sign.";
|
||||
gtk_tooltips_set_tip(tooltips,
|
||||
battery_format1,
|
||||
_(bat_format_spec),
|
||||
NULL);
|
||||
|
||||
row++, col = 2;
|
||||
label = gtk_label_new(_("Second line format"));
|
||||
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_format2 = gtk_entry_new();
|
||||
gtk_widget_show(battery_format2);
|
||||
gtk_entry_set_width_chars(GTK_ENTRY(battery_format2), 16);
|
||||
gtk_table_attach(GTK_TABLE(table), battery_format2, col, col + 1, row, row + 1, GTK_FILL, 0, 0, 0);
|
||||
col++;
|
||||
gtk_tooltips_set_tip(tooltips,
|
||||
battery_format2,
|
||||
_(bat_format_spec),
|
||||
NULL);
|
||||
|
||||
change_paragraph(parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -91,7 +91,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;
|
||||
extern GtkWidget *battery_font_line1, *battery_font_line1_set, *battery_font_line2, *battery_font_line2_set,
|
||||
*battery_font_color;
|
||||
*battery_font_color, *battery_format1, *battery_format2;
|
||||
extern GtkWidget *battery_background;
|
||||
extern GtkWidget *battery_tooltip;
|
||||
extern GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command,
|
||||
|
||||
@@ -765,6 +765,8 @@ void config_write_battery(FILE *fp)
|
||||
"battery_font_color",
|
||||
color,
|
||||
gtk_color_button_get_alpha(GTK_COLOR_BUTTON(battery_font_color)) * 100 / 0xffff);
|
||||
fprintf(fp, "bat1_format = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_format1)));
|
||||
fprintf(fp, "bat2_format = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_format2)));
|
||||
fprintf(fp,
|
||||
"battery_padding = %d %d\n",
|
||||
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_x)),
|
||||
@@ -1412,6 +1414,10 @@ void add_entry(char *key, char *value)
|
||||
} else if (strcmp(key, "bat2_font") == 0) {
|
||||
gtk_font_button_set_font_name(GTK_FONT_BUTTON(battery_font_line2), value);
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(battery_font_line2_set), TRUE);
|
||||
} else if (strcmp(key, "bat1_format") == 0) {
|
||||
gtk_entry_set_text(GTK_ENTRY(battery_format1), value);
|
||||
} else if (strcmp(key, "bat2_format") == 0) {
|
||||
gtk_entry_set_text(GTK_ENTRY(battery_format2), value);
|
||||
} else if (strcmp(key, "battery_font_color") == 0) {
|
||||
extract_values(value, &value1, &value2, &value3);
|
||||
GdkColor col;
|
||||
|
||||
Reference in New Issue
Block a user