#include <glib/gstdio.h>
#include <glib/gi18n.h>
-#include "../version.h"
+#ifdef HAVE_VERSION_H
+ #include "version.h"
+#endif
#include "common.h"
#include "theme_view.h"
+#include "properties.h"
+#define SNAPSHOT_TICK 190
// default config file and directory
char *g_path_config = NULL;
char *g_path_dir = NULL;
char *g_default_theme = NULL;
+char *g_cmd_property = NULL;
int g_width, g_height;
GtkWidget *g_window;
-GtkWidget *g_theme_view;
static GtkUIManager *globalUIManager = NULL;
static void menuQuit();
static void menuRefresh();
static void menuRefreshAll();
-static void menuPreferences();
static void menuApply();
static void menuAbout();
static void selectTheme(const gchar *name);
static gboolean searchTheme(const gchar *name_theme, GtkTreeModel *model, GtkTreeIter *iter);
static void load_theme();
+static void initTheme();
static void read_config();
static void write_config();
-static void check_theme();
// define menubar, toolbar and popup
" <toolitem action='ViewApply'/>"
" </toolbar>"
" <popup name='ThemePopup'>"
- " <menuitem action='EditRefresh'/>"
" <menuitem action='ThemeProperties'/>"
+ " <menuitem action='EditRefresh'/>"
" <menuitem action='ViewApply'/>"
" <separator/>"
" <menuitem action='ThemeDelete'/>"
gtk_init (&argc, &argv);
g_thread_init( NULL );
read_config();
- check_theme();
+ initTheme();
// define main layout : container, menubar, toolbar
g_window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
// load themes
load_theme(g_theme_view);
- // rig up idle/thread routines
- //Glib::Thread::create(sigc::mem_fun(window.view, &Thumbview::load_cache_images), true);
- //Glib::Thread::create(sigc::mem_fun(window.view, &Thumbview::create_cache_images), true);
-
gtk_widget_show_all(g_window);
gtk_main ();
return 0;
{
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 };
- gtk_show_about_dialog(g_window, "name", g_get_application_name( ),
+ gtk_show_about_dialog(GTK_WINDOW(g_window), "name", g_get_application_name( ),
"comments", _("Theming tool for tint2 panel"),
"version", VERSION_STRING,
"copyright", _("Copyright 2009 tint2 team\nTint2 License GNU GPL version 2\nTintwizard License GNU GPL version 3"),
GtkFileChooser *chooser;
GtkFileFilter *filter;
- 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);
+ dialog = gtk_file_chooser_dialog_new(_("Add a theme"), GTK_WINDOW(g_window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_ADD, GTK_RESPONSE_ACCEPT, NULL);
chooser = GTK_FILE_CHOOSER(dialog);
gtk_file_chooser_set_current_folder(chooser, g_get_home_dir());
gchar *message;
message = g_strdup_printf(_("Couldn't add duplicate theme\n\'%s\'."), pt1);
- GtkWidget *w = gtk_message_dialog_new(g_window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, message, NULL);
+ GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, message, NULL);
g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w);
gtk_widget_show(w);
g_free(message);
selectTheme(name_first);
g_free(name_first);
+ g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
}
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
if (!gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
- GtkWidget *w = gtk_message_dialog_new(g_window, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Select the theme to be saved."), NULL);
+ GtkWidget *w = gtk_message_dialog_new(GTK_WINDOW(g_window), 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, _("Select the theme to be saved."));
g_signal_connect_swapped(w, "response", G_CALLBACK(gtk_widget_destroy), w);
gtk_widget_show(w);
return;
pt1 = strrchr (file, '/');
if (pt1) pt1++;
- 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);
+ dialog = gtk_file_chooser_dialog_new(_("Save theme as"), GTK_WINDOW(g_window), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
chooser = GTK_FILE_CHOOSER(dialog);
gtk_file_chooser_set_do_overwrite_confirmation(chooser, TRUE);
sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
gtk_tree_model_get(model, &iter, COL_THEME_FILE, &file, -1);
-
- cmd = g_strdup_printf("gedit \'%s\' &", file);
+/*
+ GtkWidget *prop;
+ prop = create_properties();
+ gtk_window_present(GTK_WINDOW(prop));
+ //printf("menuProperties : fin\n");
+*/
+
+ cmd = g_strdup_printf("%s \'%s\' &", g_cmd_property, file);
+ printf("cmd %s\n", cmd);
system(cmd);
g_free(cmd);
g_free(file);
+
}
}
g_free(g_path_dir);
if (g_default_theme)
g_free(g_default_theme);
+ if (g_cmd_property)
+ g_free(g_cmd_property);
gtk_main_quit ();
}
static void menuRefresh()
{
- printf("menuRefresh\n");
+ GtkTreeSelection *sel;
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+
+ sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
+ if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(sel), &model, &iter)) {
+ gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, NULL, -1);
+ }
+
+ g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
}
static void menuRefreshAll()
{
- printf("menuRefreshAll\n");
-}
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ gboolean have_iter;
+ model = gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view));
+ have_iter = gtk_tree_model_get_iter_first(model, &iter);
+ while (have_iter) {
+ gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, NULL, -1);
+ have_iter = gtk_tree_model_iter_next(model, &iter);
+ }
-static void menuPreferences()
-{
- printf("menuPreferences\n");
+ g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
}
static void load_theme(GtkWidget *list)
{
GDir *dir;
- gchar *pt1, *name, *file;
+ gchar *pt1, *name;
+ const gchar *file;
gboolean found_theme = FALSE;
dir = g_dir_open(g_path_dir, 0, NULL);
}
selectTheme(g_default_theme);
+
+ g_timeout_add(SNAPSHOT_TICK, (GSourceFunc)update_snapshot, NULL);
}
}
-// theme file management
+void initTheme()
+{
+ g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
+ if (!g_file_test (g_path_dir, G_FILE_TEST_IS_DIR))
+ g_mkdir(g_path_dir, 0777);
+
+ g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
+}
+
+
void read_config()
{
char *path;
+ // default values
if (g_default_theme != NULL) {
g_free(g_default_theme);
g_default_theme = NULL;
}
-
g_width = 500;
g_height = 350;
+ g_cmd_property = g_strconcat( "python ", INSTALL_PREFIX, "/bin/tintwizard.py", (void*)0 );
+
+ // load config
path = g_build_filename (g_get_user_config_dir(), "tint2", "tint2confrc", NULL);
if (g_file_test (path, G_FILE_TEST_EXISTS)) {
FILE *fp;
while (fgets(line, sizeof(line), fp) != NULL) {
if (parse_line(line, &key, &value)) {
if (strcmp (key, "default_theme") == 0)
- g_default_theme = strdup (value);
+ g_default_theme = strdup(value);
+ else if (strcmp (key, "cmd_property") == 0) {
+ g_free(g_cmd_property);
+ g_cmd_property = strdup(value);
+ }
else if (strcmp (key, "width") == 0)
g_width = atoi(value);
else if (strcmp (key, "height") == 0)
fputs("# TINT2CONF CONFIG FILE\n", fp);
if (g_default_theme != NULL) {
fprintf(fp, "default_theme = %s\n", g_default_theme);
- printf("default_theme %s\n", g_default_theme);
+ }
+ if (g_cmd_property != NULL) {
+ fprintf(fp, "cmd_property = %s\n", g_cmd_property);
}
fprintf(fp, "width = %d\n", g_width);
fprintf(fp, "height = %d\n", g_height);
}
-void check_theme()
-{
- g_path_dir = g_build_filename (g_get_user_config_dir(), "tint2", NULL);
- if (!g_file_test (g_path_dir, G_FILE_TEST_IS_DIR))
- g_mkdir(g_path_dir, 0777);
-
- g_path_config = g_build_filename (g_get_user_config_dir(), "tint2", "tint2rc", NULL);
-
-}
-
-