Add separator plugin

This commit is contained in:
Oskari Rauta 2016-08-15 01:12:33 -04:00 committed by o9000
parent 7dbc894d2e
commit 6304715df3
10 changed files with 552 additions and 4 deletions

View file

@ -87,6 +87,7 @@ include_directories( ${PROJECT_BINARY_DIR}
src/util
src/execplugin
src/freespace
src/separator
${X11_INCLUDE_DIRS}
${PANGOCAIRO_INCLUDE_DIRS}
${PANGO_INCLUDE_DIRS}
@ -114,6 +115,7 @@ set( SOURCES src/config.c
src/tooltip/tooltip.c
src/execplugin/execplugin.c
src/freespace/freespace.c
src/separator/separator.c
src/util/area.c
src/util/common.c
src/util/strnatcmp.c

View file

@ -51,6 +51,7 @@
#include "window.h"
#include "tooltip.h"
#include "timer.h"
#include "separator.h"
#include "execplugin.h"
#ifdef ENABLE_BATTERY
@ -201,6 +202,15 @@ void load_launcher_app_dir(const char *path)
g_list_free(files);
}
Separator *get_or_create_last_separator()
{
if (!panel_config.separator_list) {
fprintf(stderr, "Warning: separator items should shart with 'separator = new'\n");
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
}
return (Separator *)g_list_last(panel_config.separator_list)->data;
}
Execp *get_or_create_last_execp()
{
if (!panel_config.execp_list) {
@ -526,6 +536,22 @@ void add_entry(char *key, char *value)
#endif
}
/* Separator */
else if (strcmp(key, "separator") == 0) {
panel_config.separator_list = g_list_append(panel_config.separator_list, create_separator());
} else if (strcmp(key, "separator_color") == 0) {
Separator *separator = get_or_create_last_separator();
extract_values(value, &value1, &value2, &value3);
get_color(value1, separator->color.rgb);
if (value2)
separator->color.alpha = (atoi(value2) / 100.0);
else
separator->color.alpha = 0.5;
} else if (strcmp(key, "separator_style") == 0) {
Separator *separator = get_or_create_last_separator();
separator->style = atoi(value);
}
/* Execp */
else if (strcmp(key, "execp") == 0) {
panel_config.execp_list = g_list_append(panel_config.execp_list, create_execp());

View file

@ -171,6 +171,7 @@ void init_panel()
init_battery();
#endif
init_taskbar();
init_separator();
init_execp();
// number of panels (one monitor or 'all' monitors)
@ -204,6 +205,7 @@ void init_panel()
p->area.size_mode = LAYOUT_DYNAMIC;
p->area._resize = resize_panel;
p->area._clear = panel_clear_background;
p->separator_list = NULL;
init_panel_size_and_position(p);
// add children according to panel_items
for (int k = 0; k < strlen(panel_items_order); k++) {
@ -223,6 +225,8 @@ void init_panel()
init_clock_panel(p);
if (panel_items_order[k] == 'F' && !strstr(panel_items_order, "T"))
init_freespace_panel(p);
if (panel_items_order[k] == ':')
init_separator_panel(p);
if (panel_items_order[k] == 'E')
init_execp_panel(p);
}
@ -552,6 +556,7 @@ void set_panel_items_order(Panel *p)
}
int i_execp = 0;
int i_separator = 0;
for (int k = 0; k < strlen(panel_items_order); k++) {
if (panel_items_order[k] == 'L') {
p->area.children = g_list_append(p->area.children, &p->launcher);
@ -573,6 +578,12 @@ void set_panel_items_order(Panel *p)
p->area.children = g_list_append(p->area.children, &p->clock);
if (panel_items_order[k] == 'F')
p->area.children = g_list_append(p->area.children, &p->freespace);
if (panel_items_order[k] == ':') {
GList *item = g_list_nth(p->separator_list, i_separator);
i_separator++;
if (item)
p->area.children = g_list_append(p->area.children, (Area *)item->data);
}
if (panel_items_order[k] == 'E') {
GList *item = g_list_nth(p->execp_list, i_execp);
i_execp++;

View file

@ -22,6 +22,7 @@
#include "launcher.h"
#include "freespace.h"
#include "execplugin.h"
#include "separator.h"
#ifdef ENABLE_BATTERY
#include "battery.h"
@ -127,6 +128,7 @@ typedef struct Panel {
Launcher launcher;
FreeSpace freespace;
GList *separator_list;
GList *execp_list;
// Autohide

217
src/separator/separator.c Normal file
View file

@ -0,0 +1,217 @@
// Tint2 : Separator plugin
// Author: Oskari Rauta
#include <string.h>
#include <stdio.h>
#include <cairo.h>
#include <cairo-xlib.h>
#include <pango/pangocairo.h>
#include <stdlib.h>
#include <math.h>
#include "window.h"
#include "server.h"
#include "panel.h"
#include "common.h"
#include "separator.h"
Separator *create_separator()
{
Separator *separator = calloc(1, sizeof(Separator));
return separator;
}
void destroy_separator(void *obj)
{
Separator *separator = (Separator *)obj;
remove_area(&separator->area);
free_area(&separator->area);
free_and_null(separator);
}
void init_separator()
{
GList *to_remove = panel_config.separator_list;
for (int k = 0; k < strlen(panel_items_order) && to_remove; k++) {
if (panel_items_order[k] == ':') {
to_remove = to_remove->next;
}
}
if (to_remove) {
if (to_remove == panel_config.separator_list) {
g_list_free_full(to_remove, destroy_separator);
panel_config.separator_list = NULL;
} else {
// Cut panel_config.separator_list
if (to_remove->prev)
to_remove->prev->next = NULL;
to_remove->prev = NULL;
// Remove all elements of to_remove and to_remove itself
g_list_free_full(to_remove, destroy_separator);
}
}
}
void init_separator_panel(void *p)
{
Panel *panel = (Panel *)p;
// Make sure this is only done once if there are multiple items
if (panel->separator_list)
return;
// panel->separator_list is now a copy of the pointer panel_config.separator_list
// We make it a deep copy
panel->separator_list = g_list_copy_deep(panel_config.separator_list, NULL, NULL);
for (GList *l = panel->separator_list; l; l = l->next) {
Separator *separator = l->data;
if (!separator->area.bg)
separator->area.bg = &g_array_index(backgrounds, Background, 0);
separator->area.parent = p;
separator->area.panel = p;
snprintf(separator->area.name, sizeof(separator->area.name), "separator");
separator->area.size_mode = LAYOUT_FIXED;
separator->area.resize_needed = 1;
separator->area.on_screen = TRUE;
separator->area._resize = resize_separator;
separator->area._draw_foreground = draw_separator;
}
}
void cleanup_separator()
{
// Cleanup frontends
for (int i = 0; i < num_panels; i++) {
g_list_free_full(panels[i].separator_list, destroy_separator);
panels[i].separator_list = NULL;
}
// Cleanup backends
g_list_free_full(panel_config.separator_list, destroy_separator);
panel_config.separator_list = NULL;
}
gboolean resize_separator(void *obj)
{
Separator *separator = obj;
// Panel *panel = separator->area.panel;
if (!separator->area.on_screen)
return FALSE;
double d_height = panel_horizontal ? separator->area.height : separator->area.width;
double d_thickness = round(d_height / 16) >= 1.0 ? round(d_height / 16) : 1.0;
if (separator->style == 3)
d_thickness = round(d_height / 8) >= 1.0 ? round(d_height / 8) : 1.0;
double d_len = round(d_height / 16) >= 1.0 ? round(d_height / 16) : 1.0;
double d_width = d_thickness * 5;
if (separator->style == 4) {
d_width = d_thickness * 7;
d_thickness = d_thickness * 3;
}
if (separator->style == 2) {
d_width = d_height;
d_thickness = round(d_height / 8) >= 1.0 ? round(d_height / 8) : 1.0;
d_len = d_thickness;
}
double d_empty_thickness = d_thickness;
if (separator->style == 5 || separator->style == 6) {
d_width = (d_thickness * 4) + 2.0;
d_thickness = 1.0;
}
if (panel_horizontal) {
separator->area.width = d_width;
separator->area.height = d_height;
} else {
separator->area.width = d_height;
separator->area.height = d_width;
}
separator->empty_thickness = d_empty_thickness;
separator->thickness = d_thickness;
separator->len = d_len;
schedule_redraw(&separator->area);
panel_refresh = TRUE;
return TRUE;
}
void draw_separator(void *obj, cairo_t *c)
{
Separator *separator = obj;
if (separator->style == 0 )
return;
double start_point = 0 + ( separator->thickness * 2 );
double end_point = separator->area.height - ( separator->thickness * 2 );
if (!panel_horizontal)
end_point = separator->area.width - ( separator->thickness * 2 );
double count = end_point - start_point;
double thickness = separator->thickness;
double len = separator->len;
int alt = 0;
double x_fix = 0;
if (separator->style == 2) {
if (!panel_horizontal)
start_point=start_point + 2;
cairo_set_source_rgba(c, separator->color.rgb[0], separator->color.rgb[1], separator->color.rgb[2], separator->color.alpha);
cairo_set_line_width(c, 1);
cairo_rectangle(c, start_point - 2, start_point - (panel_horizontal ? 0 : 4), end_point - thickness - 3, end_point - thickness - ( panel_horizontal ? 3 : 3));
cairo_stroke_preserve(c);
cairo_fill(c);
return;
}
if (count < thickness)
return;
while (((int) count) % 2) {
if (alt) {
start_point++;
alt = 0;
} else {
end_point--;
alt = 1;
}
count = end_point - start_point;
if (count < thickness)
return;
}
if (separator->style == 3 || separator->style == 4)
x_fix = round(thickness / 2) + (separator->style == 4 ? 1.0 : 0.0);
if (separator->style == 5 || separator->style == 6) {
x_fix = -1.0;
start_point = start_point + 2;
end_point--;
}
double separator_pattern[] = { len, len };
double separator_style6_pattern[] = { 1.0 };
cairo_set_source_rgba(c, separator->color.rgb[0], separator->color.rgb[1], separator->color.rgb[2], separator->color.alpha);
cairo_set_line_width(c, thickness);
if (separator->style == 6)
cairo_set_dash(c, separator_style6_pattern, 1, 0);
else
cairo_set_dash(c, separator_pattern, sizeof(separator_pattern) / sizeof(separator_pattern[0]), 0);
if (panel_horizontal) {
cairo_move_to(c, (separator->area.width / 2) - thickness + x_fix, start_point);
cairo_line_to(c, (separator->area.width / 2) - thickness + x_fix, end_point);
} else {
cairo_move_to(c, start_point, (separator->area.height / 2) - thickness + x_fix);
cairo_line_to(c, end_point, (separator->area.height / 2) - thickness + x_fix);
}
cairo_stroke(c);
}

27
src/separator/separator.h Normal file
View file

@ -0,0 +1,27 @@
// Tint2 : Separator
// Author: Oskari Rauta <oskari.rauta@gmail.com>
#ifndef SEPARATOR_H
#define SEPARATOR_H
#include "common.h"
#include "area.h"
typedef struct Separator {
Area area;
int style;
Color color;
double empty_thickness;
double thickness;
double len;
} Separator;
Separator *create_separator();
void destroy_separator(void *obj);
void init_separator();
void init_separator_panel(void *p);
void cleanup_separator();
gboolean resize_separator(void *obj);
void draw_separator(void *obj, cairo_t *c);
#endif

View file

@ -121,6 +121,9 @@ GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
GtkWidget *tooltip_background;
// Separators
GArray *separators;
// Executors
GArray *executors;
@ -186,6 +189,7 @@ void create_task_status(GtkWidget *notebook,
GtkWidget **task_status_icon_brightness,
GtkWidget **task_status_background,
GtkWidget **task_status_background_set);
void create_separator(GtkWidget *parent, int i);
void create_execp(GtkWidget *parent, int i);
void create_clock(GtkWidget *parent);
void create_systemtray(GtkWidget *parent);
@ -257,6 +261,7 @@ GtkWidget *create_properties()
tooltips = gtk_tooltips_new();
(void) tooltips;
separators = g_array_new(FALSE, TRUE, sizeof(Separator));
executors = g_array_new(FALSE, TRUE, sizeof(Executor));
// global layer
@ -1790,6 +1795,11 @@ void create_panel_items(GtkWidget *parent)
itemsColValue, "F",
-1);
gtk_list_store_append(all_items, &iter);
gtk_list_store_set(all_items, &iter,
itemsColName, _("Separator"),
itemsColValue, ":",
-1);
gtk_list_store_append(all_items, &iter);
gtk_list_store_set(all_items, &iter,
itemsColName, _("Executor"),
itemsColValue, "E",
@ -1952,7 +1962,9 @@ void set_panel_items(const char *items)
{
gtk_list_store_clear(panel_items);
int separator_index = -1;
int execp_index = -1;
for (; items && *items; items++) {
const char *value = NULL;
const char *name = NULL;
@ -1977,6 +1989,12 @@ void set_panel_items(const char *items)
} else if (v == 'F') {
value = "F";
name = _("Free space");
} else if (v == ':') {
separator_index++;
buffer[0] = 0;
sprintf(buffer, "%s %d", _("Separator"), separator_index + 1);
name = buffer;
value = ":";
} else if (v == 'E') {
execp_index++;
buffer[0] = 0;
@ -2010,7 +2028,17 @@ void panel_add_item(GtkWidget *widget, gpointer data)
itemsColValue, &value,
-1);
if (!panel_contains(value) || g_str_equal(value, "E")) {
if (!panel_contains(value) || g_str_equal(value, ":")) {
GtkTreeIter iter;
gtk_list_store_append(panel_items, &iter);
gtk_list_store_set(panel_items, &iter,
itemsColName, g_strdup(name),
itemsColValue, g_strdup(value),
-1);
if (g_str_equal(value, ":")) {
separator_create_new();
}
} else if (!panel_contains(value) || g_str_equal(value, "E")) {
GtkTreeIter iter;
gtk_list_store_append(panel_items, &iter);
gtk_list_store_set(panel_items, &iter,
@ -2022,6 +2050,7 @@ void panel_add_item(GtkWidget *widget, gpointer data)
}
}
}
separator_update_indices();
execp_update_indices();
}
@ -2039,7 +2068,15 @@ void panel_remove_item(GtkWidget *widget, gpointer data)
itemsColValue, &value,
-1);
if (g_str_equal(value, "E")) {
if (g_str_equal(value, ":")) {
for (int i = 0; i < separators->len; i++) {
Separator *separator = &g_array_index(separators, Separator, i);
if (g_str_equal(name, separator->name)) {
separator_remove(i);
break;
}
}
} else if (g_str_equal(value, "E")) {
for (int i = 0; i < executors->len; i++) {
Executor *executor = &g_array_index(executors, Executor, i);
if (g_str_equal(name, executor->name)) {
@ -2052,6 +2089,7 @@ void panel_remove_item(GtkWidget *widget, gpointer data)
gtk_list_store_remove(panel_items, &iter);
}
separator_update_indices();
execp_update_indices();
}
@ -2076,7 +2114,22 @@ void panel_move_item_down(GtkWidget *widget, gpointer data)
itemsColValue, &value2,
-1);
if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) {
if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) {
Separator *separator1 = NULL;
Separator *separator2 = NULL;
for (int i = 0; i < separators->len; i++) {
Separator *separator = &g_array_index(separators, Separator, i);
if (g_str_equal(name1, separator->name)) {
separator1 = separator;
}
if (g_str_equal(name2, separator->name)) {
separator2 = separator;
}
}
Separator tmp = *separator1;
*separator1 = *separator2;
*separator2 = tmp;
} else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) {
Executor *executor1 = NULL;
Executor *executor2 = NULL;
for (int i = 0; i < executors->len; i++) {
@ -2096,6 +2149,7 @@ void panel_move_item_down(GtkWidget *widget, gpointer data)
gtk_list_store_swap(panel_items, &iter, &next);
}
}
separator_update_indices();
execp_update_indices();
}
@ -2121,7 +2175,22 @@ void panel_move_item_up(GtkWidget *widget, gpointer data)
itemsColValue, &value2,
-1);
if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) {
if (g_str_equal(value1, ":") && g_str_equal(value2, ":")) {
Separator *separator1 = NULL;
Separator *separator2 = NULL;
for (int i = 0; i < separators->len; i++) {
Separator *separator = &g_array_index(separators, Separator, i);
if (g_str_equal(name1, separator->name)) {
separator1 = separator;
}
if (g_str_equal(name2, separator->name)) {
separator2 = separator;
}
}
Separator tmp = *separator1;
*separator1 = *separator2;
*separator2 = tmp;
} else if (g_str_equal(value1, "E") && g_str_equal(value2, "E")) {
Executor *executor1 = NULL;
Executor *executor2 = NULL;
for (int i = 0; i < executors->len; i++) {
@ -2142,6 +2211,7 @@ void panel_move_item_up(GtkWidget *widget, gpointer data)
}
}
}
separator_update_indices();
execp_update_indices();
}
@ -4354,6 +4424,76 @@ void create_clock(GtkWidget *parent)
change_paragraph(parent);
}
void create_separator(GtkWidget *notebook, int i)
{
GtkWidget *label;
GtkWidget *table;
int row, col;
GtkTooltips *tooltips = gtk_tooltips_new();
Separator *separator = &g_array_index(separators, Separator, i);
separator->name[0] = 0;
sprintf(separator->name, "%s %d", _("Separator"), i + 1);
separator->page_label = gtk_label_new(separator->name);
gtk_widget_show(separator->page_label);
separator->page_separator = gtk_vbox_new(FALSE, DEFAULT_HOR_SPACING);
separator->container = addScrollBarToWidget(separator->page_separator);
gtk_container_set_border_width(GTK_CONTAINER(separator->page_separator), 10);
gtk_widget_show(separator->page_separator);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), separator->container, separator->page_label);
GtkWidget *parent = separator->page_separator;
table = gtk_table_new(1, 2, 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(_("<b>Format</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(3, 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(_("Foreground color"));
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++;
separator->separator_color = gtk_color_button_new();
gtk_color_button_set_use_alpha(GTK_COLOR_BUTTON(separator->separator_color), TRUE);
gtk_widget_show(separator->separator_color);
gtk_table_attach(GTK_TABLE(table), separator->separator_color, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, separator->separator_color, _("Specifies separator's color."), NULL);
row++, col = 2;
label = gtk_label_new(_("Separator style"));
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++;
separator->separator_style = gtk_spin_button_new_with_range(0, 6, 1);
gtk_widget_show(separator->separator_style);
gtk_table_attach(GTK_TABLE(table), separator->separator_style, col, col+1, row, row+1, GTK_FILL, 0, 0, 0);
col++;
gtk_tooltips_set_tip(tooltips, separator->separator_style, _("Specifies separator's appearance. 0 is empty/invisible separator."), NULL);
change_paragraph(parent);
}
void create_execp(GtkWidget *notebook, int i)
{
GtkWidget *label;
@ -4730,12 +4870,25 @@ void create_execp(GtkWidget *notebook, int i)
change_paragraph(parent);
}
void separator_create_new()
{
g_array_set_size(separators, separators->len + 1);
create_separator(notebook, separators->len - 1);
}
void execp_create_new()
{
g_array_set_size(executors, executors->len + 1);
create_execp(notebook, executors->len - 1);
}
Separator *separator_get_last()
{
if (separators->len <= 0)
separator_create_new();
return &g_array_index(separators, Separator, separators->len - 1);
}
Executor *execp_get_last()
{
if (executors->len <= 0)
@ -4743,6 +4896,21 @@ Executor *execp_get_last()
return &g_array_index(executors, Executor, executors->len - 1);
}
void separator_remove(int i)
{
Separator *separator = &g_array_index(separators, Separator, i);
for (int i_page = 0; i_page < gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); i_page++) {
GtkWidget *page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i_page);
if (page == separator->container) {
gtk_widget_hide(page);
gtk_notebook_remove_page(GTK_NOTEBOOK(notebook), i_page);
}
}
separators = g_array_remove_index(separators, i);
}
void execp_remove(int i)
{
Executor *executor = &g_array_index(executors, Executor, i);
@ -4758,6 +4926,43 @@ void execp_remove(int i)
executors = g_array_remove_index(executors, i);
}
void separator_update_indices()
{
for (int i = 0; i < separators->len; i++) {
Separator *separator = &g_array_index(separators, Separator, i);
sprintf(separator->name, "%s %d", _("Separator"), i + 1);
gtk_label_set_text(GTK_LABEL(separator->page_label), separator->name);
}
GtkTreeModel *model = GTK_TREE_MODEL(panel_items);
GtkTreeIter iter;
if (!gtk_tree_model_get_iter_first(model, &iter))
return;
int separator_index = -1;
while (1) {
gchar *name;
gchar *value;
gtk_tree_model_get(model, &iter,
itemsColName, &name,
itemsColValue, &value,
-1);
if (g_str_equal(value, ":")) {
separator_index++;
char buffer[256];
buffer[0] = 0;
sprintf(buffer, "%s %d", _("Separator"), separator_index + 1);
gtk_list_store_set(panel_items, &iter,
itemsColName, buffer,
-1);
}
if (!gtk_tree_model_iter_next(model, &iter))
break;
}
}
void execp_update_indices()
{
for (int i = 0; i < executors->len; i++) {

View file

@ -119,6 +119,19 @@ extern GtkWidget *tooltip_task_show, *tooltip_show_after, *tooltip_hide_after;
extern GtkWidget *clock_format_tooltip, *clock_tmz_tooltip;
extern GtkWidget *tooltip_background;
// Separator
typedef struct Separator {
char name[256];
GtkWidget *container;
GtkWidget *page_separator;
GtkWidget *page_label;
GtkWidget *separator_background;
GtkWidget *separator_color;
GtkWidget *separator_style;
} Separator;
extern GArray *separators;
// Executor
typedef struct Executor {
char name[256];
@ -208,6 +221,11 @@ int background_index_safe(int index);
GtkWidget *create_properties();
void separator_create_new();
Separator *separator_get_last();
void separator_remove(int i);
void separator_update_indices();
void execp_create_new();
Executor *execp_get_last();
void execp_remove(int i);

View file

@ -670,6 +670,26 @@ void config_write_battery(FILE *fp)
fprintf(fp, "\n");
}
void config_write_separator(FILE *fp)
{
for (int i = 0; i < separators->len; i++) {
fprintf(fp, "#-------------------------------------\n");
fprintf(fp, "# Separator %d\n", i + 1);
Separator *separator = &g_array_index(separators, Separator, i);
fprintf(fp, "separator = new\n");
GdkColor color;
gtk_color_button_get_color(GTK_COLOR_BUTTON(separator->separator_color), &color);
config_write_color(fp,
"separator_color",
color,
gtk_color_button_get_alpha(GTK_COLOR_BUTTON(separator->separator_color)) * 100 / 0xffff);
fprintf(fp, "separator_style = %d\n", (int)gtk_spin_button_get_value(GTK_SPIN_BUTTON(separator->separator_style)));
fprintf(fp, "\n");
}
}
void config_write_execp(FILE *fp)
{
for (int i = 0; i < executors->len; i++) {
@ -789,6 +809,7 @@ void config_save_file(const char *path) {
config_write_launcher(fp);
config_write_clock(fp);
config_write_battery(fp);
config_write_separator(fp);
config_write_execp(fp);
config_write_tooltip(fp);
@ -1675,6 +1696,24 @@ void add_entry(char *key, char *value)
set_action(value, task_mouse_scroll_down);
}
/* Separator */
else if (strcmp(key, "separator") == 0) {
separator_create_new();
}
else if (strcmp(key, "separator_color") == 0) {
extract_values(value, &value1, &value2, &value3);
GdkColor col;
hex2gdk(value1, &col);
gtk_color_button_set_color(GTK_COLOR_BUTTON(separator_get_last()->separator_color), &col);
if (value2) {
int alpha = atoi(value2);
gtk_color_button_set_alpha(GTK_COLOR_BUTTON(separator_get_last()->separator_color), (alpha*65535)/100);
}
}
else if (strcmp(key, "separator_style") == 0) {
gtk_spin_button_set_value(GTK_SPIN_BUTTON(separator_get_last()->separator_style), atoi(value));
}
/* Executor */
else if (strcmp(key, "execp") == 0) {
execp_create_new();

View file

@ -21,5 +21,6 @@ po
src/tint2conf/po
src/freespace
src/execplugin
src/separator
themes
doc