#include "server.h"
#include "task.h"
#include "taskbar.h"
+#include "systraybar.h"
#include "clock.h"
#include "panel.h"
#include "config.h"
/* Clock */
else if (strcmp (key, "time1_format") == 0) {
if (time1_format) g_free(time1_format);
- if (strlen(value) > 0) time1_format = strdup (value);
- else time1_format = 0;
+ if (strlen(value) > 0) {
+ time1_format = strdup (value);
+ panel_config->clock.area.on_screen = 1;
+ }
+ else {
+ time1_format = 0;
+ panel_config->clock.area.on_screen = 0;
+ }
}
else if (strcmp (key, "time2_format") == 0) {
if (time2_format) g_free(time2_format);
memcpy(&panel_config->g_task.area.pix_active.border, &a->pix.border, sizeof(Border));
}
+ /* Systray */
+ else if (strcmp (key, "systray_padding") == 0) {
+ extract_values(value, &value1, &value2, &value3);
+ systray.area.paddingxlr = systray.area.paddingx = atoi (value1);
+ if (value2) systray.area.paddingy = atoi (value2);
+ if (value3) systray.area.paddingx = atoi (value3);
+ systray.area.on_screen = 1;
+ }
+ else if (strcmp (key, "systray_background_id") == 0) {
+ int id = atoi (value);
+ Area *a = g_slist_nth_data(list_back, id);
+ memcpy(&systray.area.pix.back, &a->pix.back, sizeof(Color));
+ memcpy(&systray.area.pix.border, &a->pix.border, sizeof(Border));
+ }
+
/* Mouse actions */
else if (strcmp (key, "mouse_middle") == 0)
get_action (value, &mouse_middle);
}
else
- fprintf(stderr, "Invalid option: \"%s\", correct your config file\n", key);
+ fprintf(stderr, "tint2 : invalid option \"%s\", correct your config file\n", key);
if (value1) free (value1);
if (value2) free (value2);
fprintf(stderr, "tint2 exit : monitor %d not found.\n", panel_config->monitor+1);
exit(0);
}
- else {
- if (!server.monitor[panel_config->monitor].width || !server.monitor[panel_config->monitor].height)
- fprintf(stderr, "tint2 error : invalid monitor size.\n");
- }
// alloc panels
int i;
if (panel_config->monitor >= 0) {
+ // one monitor
nb_panel = 1;
panel1 = calloc(nb_panel, sizeof(Panel));
memcpy(panel1, panel_config, sizeof(Panel));
+ panel1->monitor = panel_config->monitor;
}
else {
- // multi monitor
+ // all monitors
nb_panel = server.nb_monitor;
panel1 = calloc(nb_panel, sizeof(Panel));
}
}
+ // TODO: user can configure layout => ordered objects in panel.area.list
+ // clock and systray before taskbar because resize(clock) can resize others object ??
init_panel();
+ init_clock();
+ init_systray();
init_taskbar();
visible_object();
- task_refresh_tasklist();
- panel_refresh = 1;
-
cleanup_config();
+
+ task_refresh_tasklist();
}
int config_read ()
{
const gchar * const * system_dirs;
- char *path1, *path2, *dir;
+ char *path1;
gint i;
save_file_config = 0;
+ // follow XDG specification
deb:
- // check tint2rc file according to XDG specification
+ // check tint2rc in user directory
path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
- if (!g_file_test (path1, G_FILE_TEST_EXISTS)) {
+ if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
+ i = config_read_file (path1);
+ g_free(path1);
+ return i;
+ }
- if (save_file_config) {
- fprintf(stderr, "tint2 error : enable to write $HOME/.config/tint2/tint2rc\n");
- exit(0);
- }
- // check old tintrc config file
- path1 = g_build_filename (g_get_user_config_dir(), "tint", "tintrc", NULL);
- if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
- save_file_config = 1;
- old_task_font = 0;
- old_time1_font = 0;
- old_time2_font = 0;
- config_read_file (path1);
- save_config();
- if (old_task_font) g_free(old_task_font);
- if (old_time1_font) g_free(old_time1_font);
- if (old_time2_font) g_free(old_time2_font);
- goto deb;
- }
- else {
- path2 = 0;
- system_dirs = g_get_system_config_dirs();
- for (i = 0; system_dirs[i]; i++) {
- path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL);
-
- if (g_file_test(path2, G_FILE_TEST_EXISTS)) break;
- g_free (path2);
- path2 = 0;
- }
+ g_free(path1);
+ if (save_file_config) {
+ fprintf(stderr, "tint2 exit : enable to write $HOME/.config/tint2/tint2rc\n");
+ exit(0);
+ }
- if (path2) {
- // copy file in user directory (path1)
- dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
- if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777);
- g_free(dir);
+ // check old tintrc config file
+ path1 = g_build_filename (g_get_user_config_dir(), "tint", "tintrc", NULL);
+ if (g_file_test (path1, G_FILE_TEST_EXISTS)) {
+ save_file_config = 1;
+ old_task_font = 0;
+ old_time1_font = 0;
+ old_time2_font = 0;
+ config_read_file (path1);
+ save_config();
+ if (old_task_font) g_free(old_task_font);
+ if (old_time1_font) g_free(old_time1_font);
+ if (old_time2_font) g_free(old_time2_font);
+ g_free(path1);
+ goto deb;
+ }
- copy_file(path2, path1);
- g_free(path2);
- }
- }
- }
+ // copy tint2rc from system directory to user directory
+ g_free(path1);
+ char *path2 = 0;
+ system_dirs = g_get_system_config_dirs();
+ for (i = 0; system_dirs[i]; i++) {
+ path2 = g_build_filename(system_dirs[i], "tint2", "tint2rc", NULL);
- i = config_read_file (path1);
- g_free(path1);
+ if (g_file_test(path2, G_FILE_TEST_EXISTS)) break;
+ g_free (path2);
+ path2 = 0;
+ }
+
+ if (path2) {
+ // copy file in user directory (path1)
+ char *dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
+ if (!g_file_test (dir, G_FILE_TEST_IS_DIR)) g_mkdir(dir, 0777);
+ g_free(dir);
- return i;
+ path1 = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
+ copy_file(path2, path1);
+ g_free(path2);
+
+ i = config_read_file (path1);
+ g_free(path1);
+ return i;
+ }
+ return 0;
}
void save_config ()
{
- fprintf(stderr, "tint2 warning : convert user's config file tintrc to tint2rc\n");
+ fprintf(stderr, "tint2 : convert user's config file tintrc to tint2rc\n");
char *path, *dir;
FILE *fp;
fputs("task_background_id = 2\n", fp);
fputs("task_active_background_id = 3\n", fp);
+ fputs("\n#---------------------------------------------\n", fp);
+ fputs("# SYSTRAYBAR\n", fp);
+ fputs("#---------------------------------------------\n", fp);
+ fputs("systray_padding = 4 3 4\n", fp);
+ fputs("systray_background_id = 0\n", fp);
+
fputs("\n#---------------------------------------------\n", fp);
fputs("# CLOCK\n", fp);
fputs("#---------------------------------------------\n", fp);