From 169278c9d8b33e1e06e26007df8dc223ab56bf23 Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Fri, 7 Aug 2015 05:33:33 +0200 Subject: [PATCH] tint2conf: add support for ac_connected_cmd and ac_disconnected_cmd --- src/tint2conf/properties.c | 45 +++++++++++++++++++++++++++++++++++ src/tint2conf/properties.h | 1 + src/tint2conf/properties_rw.c | 9 +++++++ 3 files changed, 55 insertions(+) diff --git a/src/tint2conf/properties.c b/src/tint2conf/properties.c index a4eec73..019a333 100644 --- a/src/tint2conf/properties.c +++ b/src/tint2conf/properties.c @@ -94,6 +94,7 @@ GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *battery_ GtkWidget *battery_background; GtkWidget *battery_tooltip; GtkWidget *battery_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command; +GtkWidget *ac_connected_cmd, *ac_disconnected_cmd; // systray GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; @@ -3817,6 +3818,50 @@ void create_battery(GtkWidget *parent) change_paragraph(parent); + label = gtk_label_new(_("AC connection events")); + gtk_misc_set_alignment(GTK_MISC(label), 0, 0); + gtk_label_set_use_markup(GTK_LABEL(label), TRUE); + gtk_widget_show(label); + gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0); + + table = gtk_table_new(2, 10, FALSE); + gtk_widget_show(table); + gtk_box_pack_start(GTK_BOX(parent), table, FALSE, FALSE, 0); + gtk_table_set_row_spacings(GTK_TABLE(table), ROW_SPACING); + gtk_table_set_col_spacings(GTK_TABLE(table), COL_SPACING); + + row = 0, col = 2; + label = gtk_label_new(_("AC connected command")); + 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++; + + ac_connected_cmd = gtk_entry_new(); + gtk_widget_show(ac_connected_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(ac_connected_cmd), 50); + gtk_table_attach(GTK_TABLE(table), ac_connected_cmd, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, ac_connected_cmd, + _("Specifies a command that will be executed when AC is connected to the system."), NULL); + + row++, col = 2; + label = gtk_label_new(_("AC disconnected command")); + 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++; + + ac_disconnected_cmd = gtk_entry_new(); + gtk_widget_show(ac_disconnected_cmd); + gtk_entry_set_width_chars(GTK_ENTRY(ac_disconnected_cmd), 50); + gtk_table_attach(GTK_TABLE(table), ac_disconnected_cmd, col, col+1, row, row+1, GTK_FILL, 0, 0, 0); + col++; + gtk_tooltips_set_tip(tooltips, ac_disconnected_cmd, + _("Specifies a command that will be executed when AC is disconnected to the system."), NULL); + + change_paragraph(parent); + label = gtk_label_new(_("Mouse events")); gtk_misc_set_alignment(GTK_MISC(label), 0, 0); gtk_label_set_use_markup(GTK_LABEL(label), TRUE); diff --git a/src/tint2conf/properties.h b/src/tint2conf/properties.h index 00a94b5..c61821a 100644 --- a/src/tint2conf/properties.h +++ b/src/tint2conf/properties.h @@ -97,6 +97,7 @@ extern GtkWidget *battery_padding_x, *battery_padding_y, *battery_font_line1, *b 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; +extern GtkWidget *ac_connected_cmd, *ac_disconnected_cmd; // systray extern GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing; diff --git a/src/tint2conf/properties_rw.c b/src/tint2conf/properties_rw.c index 7f3affd..996297a 100644 --- a/src/tint2conf/properties_rw.c +++ b/src/tint2conf/properties_rw.c @@ -583,6 +583,9 @@ void config_write_battery(FILE *fp) fprintf(fp, "battery_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_uwheel_command))); fprintf(fp, "battery_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_dwheel_command))); + fprintf(fp, "ac_connected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_connected_cmd))); + fprintf(fp, "ac_disconnected_cmd = %s\n", gtk_entry_get_text(GTK_ENTRY(ac_disconnected_cmd))); + fprintf(fp, "\n"); } @@ -958,6 +961,12 @@ void add_entry(char *key, char *value) else if (strcmp(key, "battery_dwheel_command") == 0) { gtk_entry_set_text(GTK_ENTRY(battery_dwheel_command), value); } + else if (strcmp(key, "ac_connected_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(ac_connected_cmd), value); + } + else if (strcmp(key, "ac_disconnected_cmd") == 0) { + gtk_entry_set_text(GTK_ENTRY(ac_disconnected_cmd), value); + } /* Clock */ else if (strcmp(key, "time1_format") == 0) {