tint2conf: Add more mouse events for clock and battery (issue #505)

This commit is contained in:
o9000 2015-08-01 09:31:11 +02:00
parent c874e76343
commit e345c0ddcd
4 changed files with 172 additions and 2 deletions

View file

@ -22,5 +22,5 @@ Contributors:
Marcelo Vianna : taskbar sorting
Xico Atelo : startup notifications
Craig Oakes : WM flags, issue tracker organization
Jeff Blake (https://gitlab.com/u/berkley4) : more mouse event handlers

View file

@ -84,6 +84,7 @@ GtkWidget *task_iconified_color, *task_iconified_color_set,
// clock
GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;
GtkWidget *clock_left_command, *clock_right_command;
GtkWidget *clock_mclick_command, *clock_rclick_command, *clock_uwheel_command, *clock_dwheel_command;
GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color;
GtkWidget *clock_background;
@ -91,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_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command;
// systray
GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing;
@ -3316,7 +3318,7 @@ void create_clock(GtkWidget *parent)
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(parent), label, FALSE, FALSE, 0);
table = gtk_table_new(2, 10, FALSE);
table = gtk_table_new(5, 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);
@ -3352,6 +3354,51 @@ void create_clock(GtkWidget *parent)
gtk_tooltips_set_tip(tooltips, clock_right_command,
_("Specifies a command that will be executed when the clock receives a right click."), NULL);
row++, col = 2;
label = gtk_label_new(_("Middle click 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++;
clock_mclick_command = gtk_entry_new();
gtk_widget_show(clock_mclick_command);
gtk_entry_set_width_chars(GTK_ENTRY(clock_mclick_command), 50);
gtk_table_attach(GTK_TABLE(table), clock_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, clock_mclick_command,
_("Specifies a command that will be executed when the clock receives a middle click."), NULL);
row++, col = 2;
label = gtk_label_new(_("Wheel scroll up 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++;
clock_uwheel_command = gtk_entry_new();
gtk_widget_show(clock_uwheel_command);
gtk_entry_set_width_chars(GTK_ENTRY(clock_uwheel_command), 50);
gtk_table_attach(GTK_TABLE(table), clock_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, clock_uwheel_command,
_("Specifies a command that will be executed when the clock receives a mouse scroll up."), NULL);
row++, col = 2;
label = gtk_label_new(_("Wheel scroll down 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++;
clock_dwheel_command = gtk_entry_new();
gtk_widget_show(clock_dwheel_command);
gtk_entry_set_width_chars(GTK_ENTRY(clock_dwheel_command), 50);
gtk_table_attach(GTK_TABLE(table), clock_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, clock_dwheel_command,
_("Specifies a command that will be executed when the clock receives a mouse scroll down."), NULL);
change_paragraph(parent);
label = gtk_label_new(_("<b>Appearance</b>"));
@ -3769,6 +3816,95 @@ void create_battery(GtkWidget *parent)
change_paragraph(parent);
label = gtk_label_new(_("<b>Mouse events</b>"));
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(5, 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(_("Left click 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++;
battery_left_command = gtk_entry_new();
gtk_widget_show(battery_left_command);
gtk_entry_set_width_chars(GTK_ENTRY(battery_left_command), 50);
gtk_table_attach(GTK_TABLE(table), battery_left_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_left_command,
_("Specifies a command that will be executed when the battery receives a left click."), NULL);
row++, col = 2;
label = gtk_label_new(_("Right click 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++;
battery_right_command = gtk_entry_new();
gtk_widget_show(battery_right_command);
gtk_entry_set_width_chars(GTK_ENTRY(battery_right_command), 50);
gtk_table_attach(GTK_TABLE(table), battery_right_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_right_command,
_("Specifies a command that will be executed when the battery receives a right click."), NULL);
row++, col = 2;
label = gtk_label_new(_("Middle click 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++;
battery_mclick_command = gtk_entry_new();
gtk_widget_show(battery_mclick_command);
gtk_entry_set_width_chars(GTK_ENTRY(battery_mclick_command), 50);
gtk_table_attach(GTK_TABLE(table), battery_mclick_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_mclick_command,
_("Specifies a command that will be executed when the battery receives a middle click."), NULL);
row++, col = 2;
label = gtk_label_new(_("Wheel scroll up 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++;
battery_uwheel_command = gtk_entry_new();
gtk_widget_show(battery_uwheel_command);
gtk_entry_set_width_chars(GTK_ENTRY(battery_uwheel_command), 50);
gtk_table_attach(GTK_TABLE(table), battery_uwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_uwheel_command,
_("Specifies a command that will be executed when the battery receives a mouse scroll up."), NULL);
row++, col = 2;
label = gtk_label_new(_("Wheel scroll down 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++;
battery_dwheel_command = gtk_entry_new();
gtk_widget_show(battery_dwheel_command);
gtk_entry_set_width_chars(GTK_ENTRY(battery_dwheel_command), 50);
gtk_table_attach(GTK_TABLE(table), battery_dwheel_command, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, battery_dwheel_command,
_("Specifies a command that will be executed when the battery receives a mouse scroll down."), NULL);
change_paragraph(parent);
label = gtk_label_new(_("<b>Appearance</b>"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
gtk_label_set_use_markup(GTK_LABEL(label), TRUE);

View file

@ -87,6 +87,7 @@ extern GtkWidget *task_iconified_color, *task_iconified_color_set,
// clock
extern GtkWidget *clock_format_line1, *clock_format_line2, *clock_tmz_line1, *clock_tmz_line2;
extern GtkWidget *clock_left_command, *clock_right_command;
extern GtkWidget *clock_mclick_command, *clock_rclick_command, *clock_uwheel_command, *clock_dwheel_command;
extern GtkWidget *clock_padding_x, *clock_padding_y, *clock_font_line1, *clock_font_line2, *clock_font_color;
extern GtkWidget *clock_background;
@ -94,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_left_command, *battery_mclick_command, *battery_right_command, *battery_uwheel_command, *battery_dwheel_command;
// systray
extern GtkWidget *systray_icon_order, *systray_padding_x, *systray_padding_y, *systray_spacing;

View file

@ -548,6 +548,9 @@ void config_write_clock(FILE *fp)
fprintf(fp, "clock_tooltip_timezone = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_tmz_tooltip)));
fprintf(fp, "clock_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_left_command)));
fprintf(fp, "clock_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_right_command)));
fprintf(fp, "clock_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_mclick_command)));
fprintf(fp, "clock_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_uwheel_command)));
fprintf(fp, "clock_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(clock_dwheel_command)));
fprintf(fp, "\n");
}
@ -573,6 +576,11 @@ void config_write_battery(FILE *fp)
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_padding_y)));
fprintf(fp, "battery_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(battery_background)));
fprintf(fp, "battery_hide = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(battery_hide_if_higher)));
fprintf(fp, "battery_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_left_command)));
fprintf(fp, "battery_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_right_command)));
fprintf(fp, "battery_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(battery_mclick_command)));
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, "\n");
}
@ -935,6 +943,21 @@ void add_entry(char *key, char *value)
else
gtk_spin_button_set_value(GTK_SPIN_BUTTON(battery_hide_if_higher), atoi(value));
}
else if (strcmp(key, "battery_lclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_left_command), value);
}
else if (strcmp(key, "battery_rclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_right_command), value);
}
else if (strcmp(key, "battery_mclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_mclick_command), value);
}
else if (strcmp(key, "battery_uwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_uwheel_command), value);
}
else if (strcmp(key, "battery_dwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(battery_dwheel_command), value);
}
/* Clock */
else if (strcmp(key, "time1_format") == 0) {
@ -987,6 +1010,15 @@ void add_entry(char *key, char *value)
else if (strcmp(key, "clock_rclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(clock_right_command), value);
}
else if (strcmp(key, "clock_mclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(clock_mclick_command), value);
}
else if (strcmp(key, "clock_uwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(clock_uwheel_command), value);
}
else if (strcmp(key, "clock_dwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(clock_dwheel_command), value);
}
/* Taskbar */
else if (strcmp(key, "taskbar_mode") == 0) {