]> Dogcows Code - chaz/tint2/blob - src/tint2conf/main.c
tint2conf : cleanup and asynchronous panel preview
[chaz/tint2] / src / tint2conf / main.c
1 /**************************************************************************
2 *
3 * Tint2conf
4 *
5 * Copyright (C) 2009 Thierry lorthiois (lorthiois@bbsoft.fr)
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License version 2
9 * as published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 **************************************************************************/
19
20 #include <string.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23 #include <locale.h>
24 #include <X11/Xlib.h>
25 #include <gdk/gdkx.h>
26 #include <gtk/gtk.h>
27 #include <glib.h>
28 #include <glib/gstdio.h>
29 #include <glib/gi18n.h>
30
31 #include "../version.h"
32 #include "common.h"
33 #include "theme_view.h"
34
35
36
37 // default config file and directory
38 char *g_path_config = NULL;
39 char *g_path_dir = NULL;
40 char *g_default_theme = NULL;
41 int g_width, g_height;
42
43 GtkWidget *g_window;
44
45 static GtkUIManager *globalUIManager = NULL;
46
47 static void menuAddWidget (GtkUIManager *, GtkWidget *, GtkContainer *);
48
49 // action on menus
50 static void menuAdd();
51 static void menuSaveAs();
52 static void menuDelete();
53 static void menuProperties();
54 static void menuQuit();
55 static void menuRefresh();
56 static void menuRefreshAll();
57 static void menuApply();
58 static void menuAbout();
59
60 static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata);
61 static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata);
62 static void windowSizeAllocated();
63 static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
64
65
66 // theme files
67 static void selectTheme(const gchar *name);
68 static gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter);
69 static void load_theme();
70 static void initTheme();
71 static void read_config();
72 static void write_config();
73
74
75 // define menubar, toolbar and popup
76 static const char *global_ui =
77 "<ui>"
78 " <menubar name='MenuBar'>"
79 " <menu action='ThemeMenu'>"
80 " <menuitem action='ThemeAdd'/>"
81 " <menuitem action='ThemeSaveAs'/>"
82 " <separator/>"
83 " <menuitem action='ThemeDelete'/>"
84 " <separator/>"
85 // " <menuitem action='ThemeProperties'/>"
86 // " <separator/>"
87 " <menuitem action='ThemeQuit'/>"
88 " </menu>"
89 " <menu action='EditMenu'>"
90 " <menuitem action='EditRefresh'/>"
91 " <menuitem action='EditRefreshAll'/>"
92 // " <separator/>"
93 // " <menuitem action='EditPreferences'/>"
94 " </menu>"
95 " <menu action='HelpMenu'>"
96 " <menuitem action='HelpAbout'/>"
97 " </menu>"
98 " </menubar>"
99 " <toolbar name='ToolBar'>"
100 " <toolitem action='ThemeProperties'/>"
101 " <toolitem action='ViewApply'/>"
102 " </toolbar>"
103 " <popup name='ThemePopup'>"
104 " <menuitem action='EditRefresh'/>"
105 " <menuitem action='ThemeProperties'/>"
106 " <menuitem action='ViewApply'/>"
107 " <separator/>"
108 " <menuitem action='ThemeDelete'/>"
109 " </popup>"
110 "</ui>";
111
112
113 // define menubar and toolbar action
114 static GtkActionEntry entries[] = {
115 {"ThemeMenu", NULL, "Theme", NULL, NULL, NULL},
116 {"ThemeAdd", GTK_STOCK_ADD, "_Add...", "<Control>N", "Add theme", G_CALLBACK (menuAdd)},
117 {"ThemeSaveAs", GTK_STOCK_SAVE_AS, "_Save as...", NULL, "Save theme as", G_CALLBACK (menuSaveAs)},
118 {"ThemeDelete", GTK_STOCK_DELETE, "_Delete", NULL, "Delete theme", G_CALLBACK (menuDelete)},
119 {"ThemeProperties", GTK_STOCK_PROPERTIES, "_Properties...", NULL, "Show properties", G_CALLBACK (menuProperties)},
120 {"ThemeQuit", GTK_STOCK_QUIT, "_Quit", "<control>Q", "Quit", G_CALLBACK (menuQuit)},
121 {"EditMenu", NULL, "Edit", NULL, NULL, NULL},
122 {"EditRefresh", GTK_STOCK_REFRESH, "Refresh", NULL, "Refresh", G_CALLBACK (menuRefresh)},
123 {"EditRefreshAll", GTK_STOCK_REFRESH, "Refresh all", NULL, "Refresh all", G_CALLBACK (menuRefreshAll)},
124 // {"EditPreferences", GTK_STOCK_PREFERENCES, "Preferences", NULL, "Preferences", G_CALLBACK (menuPreferences)},
125 {"ViewApply", GTK_STOCK_APPLY, "Apply", NULL, "Apply theme", G_CALLBACK (menuApply)},
126 {"HelpMenu", NULL, "Help", NULL, NULL, NULL},
127 {"HelpAbout", GTK_STOCK_ABOUT, "_About", "<Control>A", "About", G_CALLBACK (menuAbout)}
128 };
129
130
131 int main (int argc, char ** argv)
132 {
133 GtkWidget *vBox = NULL, *scrollbar = NULL;
134 GtkActionGroup *actionGroup;
135
136 gtk_init (&argc, &argv);
137 g_thread_init( NULL );
138 read_config();
139 initTheme();
140
141 // define main layout : container, menubar, toolbar
142 g_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
143 gtk_window_set_title(GTK_WINDOW(g_window), _("Panel theming"));
144 gtk_window_resize(GTK_WINDOW(g_window), g_width, g_height);
145 g_signal_connect(G_OBJECT(g_window), "destroy", G_CALLBACK (menuQuit), NULL);
146 g_signal_connect(g_window, "size-allocate", G_CALLBACK(windowSizeAllocated), NULL);
147 vBox = gtk_vbox_new (FALSE, 0);
148 gtk_container_add (GTK_CONTAINER(g_window), vBox);
149
150 actionGroup = gtk_action_group_new ("menuActionGroup");
151 gtk_action_group_add_actions (actionGroup, entries, G_N_ELEMENTS (entries), NULL);
152 globalUIManager = gtk_ui_manager_new();
153 gtk_ui_manager_insert_action_group (globalUIManager, actionGroup, 0);
154 gtk_ui_manager_add_ui_from_string (globalUIManager, global_ui, -1, NULL );
155 g_signal_connect(globalUIManager, "add_widget", G_CALLBACK (menuAddWidget), vBox);
156 gtk_ui_manager_ensure_update(globalUIManager);
157 scrollbar = gtk_scrolled_window_new(NULL, NULL);
158 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
159 gtk_box_pack_start(GTK_BOX(vBox), scrollbar, TRUE, TRUE, 0);
160
161 // define theme view
162 g_theme_view = create_view();
163 gtk_container_add(GTK_CONTAINER(scrollbar), g_theme_view);
164 gtk_widget_show(g_theme_view);
165 g_signal_connect(g_theme_view, "button-press-event", (GCallback)view_onButtonPressed, NULL);
166 g_signal_connect(g_theme_view, "popup-menu", (GCallback)view_onPopupMenu, NULL);
167 g_signal_connect(g_theme_view, "row-activated", G_CALLBACK(viewRowActivated), NULL);
168
169 // load themes
170 load_theme(g_theme_view);
171
172 gtk_widget_show_all(g_window);
173 gtk_main ();
174 return 0;
175 }
176
177
178 static void menuAddWidget (GtkUIManager * p_uiManager, GtkWidget * p_widget, GtkContainer * p_box)
179 {
180 gtk_box_pack_start(GTK_BOX(p_box), p_widget, FALSE, FALSE, 0);
181 gtk_widget_show(p_widget);
182 }
183
184
185 static void menuAbout()
186 {
187 const char *authors[] = { "Thierry Lorthiois <lorthiois@bbsoft.fr>", "Andreas Fink <andreas.fink85@googlemail.com>", "Christian Ruppert <Spooky85@gmail.com> (Build system)", "Euan Freeman <euan04@gmail.com> (tintwizard)\n See http://code.google.com/p/tintwizard/", NULL };
188
189 gtk_show_about_dialog(g_window, "name", g_get_application_name( ),
190 "comments", _("Theming tool for tint2 panel"),
191 "version", VERSION_STRING,
192 "copyright", _("Copyright 2009 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU GPL version 3"),
193 "logo-icon-name", NULL, "authors", authors,
194 /* Translators: translate "translator-credits" as
195 your name to have it appear in the credits in the "About"
196 dialog */
197 "translator-credits", _("translator-credits"),
198 NULL);
199 }
200
201
202 static void menuAdd()
203 {
204 GtkWidget *dialog;
205 GtkFileChooser *chooser;
206 GtkFileFilter *filter;
207
208 dialog = gtk_file_chooser_dialog_new(_("Add a theme"), g_window, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL);
209 chooser = GTK_FILE_CHOOSER(dialog);
210
211 gtk_file_chooser_set_current_folder(chooser, g_get_home_dir());
212 gtk_file_chooser_set_select_multiple(chooser, TRUE);
213
214 filter = gtk_file_filter_new();
215 gtk_file_filter_set_name(filter, _("Tint2 theme files"));
216 gtk_file_filter_add_pattern(filter, "*.tint2rc");
217 gtk_file_chooser_add_filter(chooser, filter);
218
219 if (gtk_dialog_run (GTK_DIALOG(dialog)) != GTK_RESPONSE_ACCEPT) {
220 gtk_widget_destroy(dialog);
221 return;
222 }
223
224 GtkTreeIter iter;
225 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
226 GSList *l, *list = gtk_file_chooser_get_filenames(chooser);
227 gchar *file, *pt1, *name, *path, *name_first=NULL;
228 for (l = list; l ; l = l->next) {
229 file = (char *)l->data;
230 pt1 = strrchr(file, '/');
231 if (pt1 == NULL) continue;
232 pt1++;
233 if (*pt1 == 0) continue;
234
235 name = g_strdup(pt1);
236 path = g_build_filename (g_get_user_config_dir(), "tint2", name, NULL);
237
238 // check existing
239 if (searchTheme(path, model, &iter)) {
240 gchar *message;
241 message = g_strdup_printf(_("Couldn't add duplicate theme\n\'%s\'."), pt1);
242
243 GtkWidget *w = gtk_message_dialog_new(g_window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, message, NULL);
244 g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w);
245 gtk_widget_show(w);
246 g_free(message);
247 continue;
248 }
249
250 // append theme
251 copy_file(file, path);
252 custom_list_append(path);
253 if (name_first == NULL)
254 name_first = g_strdup(path);
255 g_free(path);
256 g_free(name);
257 }
258 g_slist_foreach(list, (GFunc)g_free, NULL);
259 g_slist_free(list);
260 gtk_widget_destroy(dialog);
261
262 selectTheme(name_first);
263 g_free(name_first);
264 g_timeout_add(100, (GSourceFunc)update_snapshot, NULL);
265 }
266
267
268 static void menuSaveAs ()
269 {
270 GtkWidget *dialog;
271 GtkFileChooser *chooser;
272 GtkTreeSelection *sel;
273 GtkTreeIter iter;
274 GtkTreeModel *model;
275 gchar *file, *pt1;
276
277 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
278 if (!gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
279 GtkWidget *w = gtk_message_dialog_new(g_window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Select the theme to be saved."), NULL);
280 g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w);
281 gtk_widget_show(w);
282 return;
283 }
284
285 gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
286 pt1 = strrchr (file, '/');
287 if (pt1) pt1++;
288
289 dialog = gtk_file_chooser_dialog_new(_("Save theme as"), g_window, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
290 chooser = GTK_FILE_CHOOSER(dialog);
291
292 gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
293 gtk_file_chooser_set_current_folder(chooser, g_get_home_dir());
294 gtk_file_chooser_set_current_name(chooser, pt1);
295
296 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
297 char *filename = gtk_file_chooser_get_filename(chooser);
298 copy_file(file, filename);
299 g_free (filename);
300 }
301 g_free(file);
302 gtk_widget_destroy (dialog);
303 }
304
305
306 static void menuDelete()
307 {
308 GtkTreeSelection *sel;
309 GtkTreeIter iter;
310 GtkTreeModel *model;
311 gchar *filename;
312
313 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
314 if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
315 gtk_tree_model_get(model, &iter, COL_THEME_FILE, &filename, -1);
316 gtk_tree_selection_unselect_all(sel);
317
318 // remove (gui and file)
319 gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
320 GFile *file = g_file_new_for_path(filename);
321 g_file_trash(file, NULL, NULL);
322 g_object_unref(G_OBJECT(file));
323 g_free(filename);
324 }
325 }
326
327
328 static void menuProperties()
329 {
330 GtkTreeSelection *sel;
331 GtkTreeIter iter;
332 GtkTreeModel *model;
333 char *file, *cmd;
334
335 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
336 if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
337 gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
338
339 cmd = g_strdup_printf("gedit \'%s\' &", file);
340 system(cmd);
341
342 g_free(cmd);
343 g_free(file);
344 }
345 }
346
347
348 static void menuQuit()
349 {
350 write_config();
351
352 if (g_path_config)
353 g_free(g_path_config);
354 if (g_path_dir)
355 g_free(g_path_dir);
356 if (g_default_theme)
357 g_free(g_default_theme);
358
359 gtk_main_quit ();
360 }
361
362
363 static void menuRefresh()
364 {
365 GtkTreeSelection *sel;
366 GtkTreeIter iter;
367 GtkTreeModel *model;
368
369 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
370 if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
371 gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, NULL, -1);
372 }
373
374 g_timeout_add(100, (GSourceFunc)update_snapshot, NULL);
375 }
376
377
378 static void menuRefreshAll()
379 {
380 GtkTreeIter iter;
381 GtkTreeModel *model;
382 gboolean have_iter;
383
384 model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
385 have_iter = gtk_tree_model_get_iter_first(model, &iter);
386 while (have_iter) {
387 gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, NULL, -1);
388 have_iter = gtk_tree_model_iter_next(model, &iter);
389 }
390
391 g_timeout_add(100, (GSourceFunc)update_snapshot, NULL);
392 }
393
394
395 static void menuApply()
396 {
397 GtkTreeSelection *sel;
398 GtkTreeIter iter;
399 GtkTreeModel *model;
400
401 if (g_default_theme) {
402 g_free(g_default_theme);
403 g_default_theme = NULL;
404 }
405 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
406 if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
407 gtk_tree_model_get(model, &iter, COL_THEME_FILE, &g_default_theme, -1);
408 // overwrite tint2rc
409 copy_file(g_default_theme, g_path_config);
410
411 // restart panel
412 system("killall -SIGUSR1 tint2");
413 }
414 }
415
416
417 static void view_popup_menu(GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
418 {
419 GtkWidget *w = gtk_ui_manager_get_widget(globalUIManager, "/ThemePopup");
420
421 gtk_menu_popup(GTK_MENU(w), NULL, NULL, NULL, NULL, (event != NULL) ? event->button : 0, gdk_event_get_time((GdkEvent*)event));
422 }
423
424
425 static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata)
426 {
427 // single click with the right mouse button?
428 if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
429 GtkTreeSelection *selection;
430
431 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(treeview));
432
433 if (gtk_tree_selection_count_selected_rows(selection) <= 1) {
434 GtkTreePath *path;
435
436 // Get tree path for row that was clicked
437 if (gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(treeview), (gint) event->x, (gint) event->y, &path, NULL, NULL, NULL)) {
438 gtk_tree_selection_unselect_all(selection);
439 gtk_tree_selection_select_path(selection, path);
440 gtk_tree_path_free(path);
441 }
442 }
443
444 view_popup_menu(treeview, event, userdata);
445 return TRUE;
446 }
447 return FALSE;
448 }
449
450
451 static gboolean view_onPopupMenu (GtkWidget *treeview, gpointer userdata)
452 {
453 view_popup_menu(treeview, NULL, userdata);
454 return TRUE;
455 }
456
457
458 static void viewRowActivated(GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data)
459 {
460 menuApply();
461 }
462
463
464 static void windowSizeAllocated()
465 {
466 const gboolean isMaximized = g_window->window && (gdk_window_get_state(g_window->window) & GDK_WINDOW_STATE_MAXIMIZED);
467
468 if(!isMaximized)
469 gtk_window_get_size(GTK_WINDOW(g_window), &g_width, &g_height);
470 }
471
472
473 static void load_theme(GtkWidget *list)
474 {
475 GDir *dir;
476 gchar *pt1, *name;
477 const gchar *file;
478 gboolean found_theme = FALSE;
479
480 dir = g_dir_open(g_path_dir, 0, NULL);
481 if (dir == NULL) return;
482 while ((file = g_dir_read_name(dir))) {
483 pt1 = strstr(file, ".tint2rc");
484 if (pt1) {
485 found_theme = TRUE;
486 name = g_build_filename (g_path_dir, file, NULL);
487 custom_list_append(name);
488 g_free(name);
489 }
490 }
491 g_dir_close(dir);
492
493 if (!found_theme) {
494 // create default theme file
495 name = g_build_filename(g_get_user_config_dir(), "tint2", "default.tint2rc", NULL);
496 copy_file(g_path_config, name);
497 custom_list_append(name);
498 if (g_default_theme) g_free(g_default_theme);
499 g_default_theme = strdup(name);
500 g_free(name);
501 }
502
503 selectTheme(g_default_theme);
504
505 g_timeout_add(100, (GSourceFunc)update_snapshot, NULL);
506 }
507
508
509 void selectTheme(const gchar *name_theme)
510 {
511 gboolean have_iter, found_theme;
512 GtkTreeIter iter;
513 GtkTreeModel *model;
514
515 if (!name_theme) return;
516
517 model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
518 found_theme = searchTheme(name_theme, model, &iter);
519
520 GtkTreePath *path = NULL;
521 if (found_theme)
522 path = gtk_tree_model_get_path(model, &iter);
523 else {
524 have_iter = gtk_tree_model_get_iter_first(model, &iter);
525 if (have_iter)
526 path = gtk_tree_model_get_path(model, &iter);
527 }
528 if (path) {
529 gtk_tree_selection_select_iter(gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view)), &iter);
530 gtk_tree_view_scroll_to_cell(GTK_TREE_VIEW(g_theme_view), path, NULL, FALSE, 0, 0);
531 gtk_tree_path_free(path);
532 }
533 }
534
535
536 gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter)
537 {
538 gchar *name;
539 gboolean have_iter, found = FALSE;
540
541 have_iter = gtk_tree_model_get_iter_first(model, iter);
542 while (have_iter) {
543 gtk_tree_model_get(model, iter, COL_THEME_FILE, &name, -1);
544 found = (strcmp(name, name_theme) == 0);
545 g_free(name);
546 if (found)
547 break;
548 have_iter = gtk_tree_model_iter_next(model, iter);
549 }
550 return found;
551 }
552
553
554 void initTheme()
555 {
556 g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
557 if (!g_file_test (g_path_dir, G_FILE_TEST_IS_DIR))
558 g_mkdir(g_path_dir, 0777);
559
560 g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
561 }
562
563
564 void read_config()
565 {
566 char *path;
567
568 if (g_default_theme != NULL) {
569 g_free(g_default_theme);
570 g_default_theme = NULL;
571 }
572
573 g_width = 500;
574 g_height = 350;
575 path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL);
576 if (g_file_test (path, G_FILE_TEST_EXISTS)) {
577 FILE *fp;
578 char line[80];
579 char *key, *value;
580 if ((fp = fopen(path, "r")) != NULL) {
581 while (fgets(line, sizeof(line), fp) != NULL) {
582 if (parse_line(line, &key, &value)) {
583 if (strcmp (key, "default_theme") == 0)
584 g_default_theme = strdup (value);
585 else if (strcmp (key, "width") == 0)
586 g_width = atoi(value);
587 else if (strcmp (key, "height") == 0)
588 g_height = atoi(value);
589 free (key);
590 free (value);
591 }
592 }
593 fclose (fp);
594 }
595 }
596 g_free(path);
597 }
598
599
600 void write_config()
601 {
602 char *path;
603 FILE *fp;
604
605 path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL);
606 fp = fopen(path, "w");
607 if (fp != NULL) {
608 fputs("#---------------------------------------------\n", fp);
609 fputs("# TINT2CONF CONFIG FILE\n", fp);
610 if (g_default_theme != NULL) {
611 fprintf(fp, "default_theme = %s\n", g_default_theme);
612 printf("default_theme %s\n", g_default_theme);
613 }
614 fprintf(fp, "width = %d\n", g_width);
615 fprintf(fp, "height = %d\n", g_height);
616 fputs("\n", fp);
617 fclose (fp);
618 }
619 g_free(path);
620 }
621
622
623
This page took 0.064418 seconds and 4 git commands to generate.