Executor: tint2conf support

This commit is contained in:
o9000
2015-12-23 23:17:39 +01:00
parent 8c3017634f
commit 6a285a628d
3 changed files with 367 additions and 178 deletions

View File

@@ -643,44 +643,51 @@ void config_write_battery(FILE *fp)
void config_write_execp(FILE *fp)
{
fprintf(fp, "#-------------------------------------\n");
fprintf(fp, "# Executor\n");
for (int i = 0; i < executors->len; i++) {
fprintf(fp, "#-------------------------------------\n");
fprintf(fp, "# Executor\n");
fprintf(fp, "execp_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_command)));
fprintf(fp, "execp_interval = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_interval)));
fprintf(fp, "execp_has_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(execp_has_icon)) ? 1 : 0);
fprintf(fp, "execp_cache_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(execp_cache_icon)) ? 1 : 0);
fprintf(fp, "execp_continuous = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_continuous)));
fprintf(fp, "execp_markup = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(execp_markup)) ? 1 : 0);
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(execp_show_tooltip))) {
fprintf(fp, "execp_tooltip = \n");
} else {
fprintf(fp, "execp_tooltip = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_tooltip)));
Executor *executor = &g_array_index(executors, Executor, i);
fprintf(fp, "execp = new\n");
fprintf(fp, "execp_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_command)));
fprintf(fp, "execp_interval = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_interval)));
fprintf(fp, "execp_has_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_has_icon)) ? 1 : 0);
fprintf(fp, "execp_cache_icon = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_cache_icon)) ? 1 : 0);
fprintf(fp, "execp_continuous = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_continuous)));
fprintf(fp, "execp_markup = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_markup)) ? 1 : 0);
if (!gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_show_tooltip))) {
fprintf(fp, "execp_tooltip = \n");
} else {
const gchar *text = gtk_entry_get_text(GTK_ENTRY(executor->execp_tooltip));
if (strlen(text) > 0)
fprintf(fp, "execp_tooltip = %s\n", text);
}
fprintf(fp, "execp_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_left_command)));
fprintf(fp, "execp_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_right_command)));
fprintf(fp, "execp_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_mclick_command)));
fprintf(fp, "execp_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_uwheel_command)));
fprintf(fp, "execp_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(executor->execp_dwheel_command)));
fprintf(fp, "execp_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(executor->execp_font)));
GdkColor color;
gtk_color_button_get_color(GTK_COLOR_BUTTON(executor->execp_font_color), &color);
config_write_color(fp,
"execp_font_color",
color,
gtk_color_button_get_alpha(GTK_COLOR_BUTTON(executor->execp_font_color)) * 100 / 0xffff);
fprintf(fp,
"execp_padding = %d %d\n",
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_x)),
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_padding_y)));
fprintf(fp, "execp_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(executor->execp_background)));
fprintf(fp, "execp_centered = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(executor->execp_centered)) ? 1 : 0);
fprintf(fp, "execp_icon_w = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_w)));
fprintf(fp, "execp_icon_h = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(executor->execp_icon_h)));
fprintf(fp, "\n");
}
fprintf(fp, "execp_lclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_left_command)));
fprintf(fp, "execp_rclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_right_command)));
fprintf(fp, "execp_mclick_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_mclick_command)));
fprintf(fp, "execp_uwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_uwheel_command)));
fprintf(fp, "execp_dwheel_command = %s\n", gtk_entry_get_text(GTK_ENTRY(execp_dwheel_command)));
fprintf(fp, "execp_font = %s\n", gtk_font_button_get_font_name(GTK_FONT_BUTTON(execp_font)));
GdkColor color;
gtk_color_button_get_color(GTK_COLOR_BUTTON(execp_font_color), &color);
config_write_color(fp,
"execp_font_color",
color,
gtk_color_button_get_alpha(GTK_COLOR_BUTTON(execp_font_color)) * 100 / 0xffff);
fprintf(fp,
"execp_padding = %d %d\n",
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_padding_x)),
(int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_padding_y)));
fprintf(fp, "execp_background_id = %d\n", gtk_combo_box_get_active(GTK_COMBO_BOX(execp_background)));
fprintf(fp, "execp_centered = %d\n", gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(execp_centered)) ? 1 : 0);
fprintf(fp, "execp_icon_w = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_icon_w)));
fprintf(fp, "execp_icon_h = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(execp_icon_h)));
fprintf(fp, "\n");
}
void config_write_tooltip(FILE *fp)
@@ -1615,73 +1622,76 @@ void add_entry(char *key, char *value)
}
/* Executor */
else if (strcmp(key, "execp") == 0) {
execp_create_new();
}
else if (strcmp(key, "execp_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_command), value);
}
else if (strcmp(key, "execp_interval") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_interval), atoi(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_interval), atoi(value));
}
else if (strcmp(key, "execp_has_icon") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_has_icon), atoi(value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_has_icon), atoi(value));
}
else if (strcmp(key, "execp_cache_icon") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_cache_icon), atoi(value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_cache_icon), atoi(value));
}
else if (strcmp(key, "execp_continuous") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_continuous), atoi(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_continuous), atoi(value));
}
else if (strcmp(key, "execp_markup") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_markup), atoi(value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_markup), atoi(value));
}
else if (strcmp(key, "execp_tooltip") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_show_tooltip), 1);
gtk_entry_set_text(GTK_ENTRY(execp_tooltip), value);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_show_tooltip), 1);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_tooltip), value);
}
else if (strcmp(key, "execp_lclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_left_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_left_command), value);
}
else if (strcmp(key, "execp_rclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_right_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_right_command), value);
}
else if (strcmp(key, "execp_mclick_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_mclick_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_mclick_command), value);
}
else if (strcmp(key, "execp_uwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_uwheel_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_uwheel_command), value);
}
else if (strcmp(key, "execp_dwheel_command") == 0) {
gtk_entry_set_text(GTK_ENTRY(execp_dwheel_command), value);
gtk_entry_set_text(GTK_ENTRY(execp_get_last()->execp_dwheel_command), value);
}
else if (strcmp(key, "execp_font") == 0) {
gtk_font_button_set_font_name(GTK_FONT_BUTTON(execp_font), value);
gtk_font_button_set_font_name(GTK_FONT_BUTTON(execp_get_last()->execp_font), value);
}
else if (strcmp(key, "execp_font_color") == 0) {
extract_values(value, &value1, &value2, &value3);
GdkColor col;
hex2gdk(value1, &col);
gtk_color_button_set_color(GTK_COLOR_BUTTON(execp_font_color), &col);
gtk_color_button_set_color(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), &col);
if (value2) {
int alpha = atoi(value2);
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(execp_font_color), (alpha*65535)/100);
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(execp_get_last()->execp_font_color), (alpha*65535)/100);
}
}
else if (strcmp(key, "execp_padding") == 0) {
extract_values(value, &value1, &value2, &value3);
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_padding_x), atoi(value1));
if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_padding_y), atoi(value2));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_x), atoi(value1));
if (value2) gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_padding_y), atoi(value2));
}
else if (strcmp(key, "execp_background_id") == 0) {
int id = background_index_safe(atoi(value));
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_background), id);
gtk_combo_box_set_active(GTK_COMBO_BOX(execp_get_last()->execp_background), id);
}
else if (strcmp(key, "execp_icon_w") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_icon_w), atoi(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_w), atoi(value));
}
else if (strcmp(key, "execp_icon_h") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_icon_h), atoi(value));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(execp_get_last()->execp_icon_h), atoi(value));
}
else if (strcmp(key, "execp_centered") == 0) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_centered), atoi(value));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(execp_get_last()->execp_centered), atoi(value));
}
if (value1) free(value1);