From 57c38c462c8d706b58d33f306c0051db6296d9fe Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Wed, 5 Aug 2015 03:07:18 +0200 Subject: [PATCH] Add support for battery tooltip option in tint2conf --- src/tint2conf/properties.c | 15 +++++++++++++++ src/tint2conf/properties.h | 1 + src/tint2conf/properties_rw.c | 6 ++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index 4e4b678..a4eec73 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -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); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 268b20d..00a94b5 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -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 diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index ad217a3..81f3ca4 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -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))); @@ -904,8 +905,9 @@ void add_entry(char *key, char *value) // 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) {