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
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;
selectTheme(name_first);
g_free(name_first);
+ g_timeout_add(100, (GSourceFunc)update_snapshot, NULL);
}
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(100, (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(100, (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(100, (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;
}
-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);
-
-}
-
-
+#include <stdlib.h>
+#include <glib.h>
+#include <glib/gstdio.h>
+
#include "theme_view.h"
// The data columns that we export via the tree model interface
+GtkWidget *g_theme_view;
GtkListStore *g_store;
int g_width_list, g_height_list;
GtkCellRenderer *g_renderer;
gtk_tree_view_column_add_attribute(col, g_renderer, "pixbuf", COL_SNAPSHOT);
gtk_tree_view_append_column(GTK_TREE_VIEW(view),col);
- //g_timeout_add(50, (GSourceFunc) increase_timeout, NULL);
-
return view;
}
void custom_list_append(const gchar *name)
+{
+ GtkTreeIter iter;
+
+ gtk_list_store_append(g_store, &iter);
+ gtk_list_store_set(g_store, &iter, COL_THEME_FILE, name, -1);
+}
+
+
+gboolean update_snapshot()
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GdkPixbuf *icon;
+ gboolean have_iter, found = FALSE;
+
+ 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_tree_model_get(model, &iter, COL_SNAPSHOT, &icon, -1);
+ if (icon != NULL) {
+ g_object_unref(icon);
+ have_iter = gtk_tree_model_iter_next(model, &iter);
+ }
+ else {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (found) {
+ // build panel's snapshot
+ GdkPixbuf *pixbuf;
+ gchar *name, *snap, *cmd;
+ gint pixWidth, pixHeight;
+ gboolean changeSize = FALSE;
+
+ snap = g_build_filename (g_get_user_config_dir(), "tint2", "snap.jpg", NULL);
+ g_remove(snap);
+
+ gtk_tree_model_get(model, &iter, COL_THEME_FILE, &name, -1);
+ cmd = g_strdup_printf("tint2 -c \'%s\' -s \'%s\'", name, snap);
+ system(cmd);
+
+ // load
+ pixbuf = gdk_pixbuf_new_from_file(snap, NULL);
+ if (pixbuf == NULL) {
+ printf("snapshot NULL : %s\n", cmd);
+ found = FALSE;
+ }
+ g_free(snap);
+ g_free(cmd);
+ g_free(name);
+
+ pixWidth = gdk_pixbuf_get_width(pixbuf);
+ pixHeight = gdk_pixbuf_get_height(pixbuf);
+ if (g_width_list < pixWidth) {
+ g_width_list = pixWidth;
+ changeSize = TRUE;
+ }
+ if (g_height_list < (pixHeight+6)) {
+ g_height_list = pixHeight+6;
+ changeSize = TRUE;
+ }
+ if (changeSize)
+ gtk_cell_renderer_set_fixed_size(g_renderer, g_width_list, g_height_list);
+
+ gtk_list_store_set(g_store, &iter, COL_SNAPSHOT, pixbuf, -1);
+ }
+ return found;
+}
+
+
+
+void custom_list_append2(const gchar *name)
{
GtkTreeIter iter;
gchar *snap, *cmd;
gtk_list_store_set(g_store, &iter, COL_THEME_FILE, name, COL_SNAPSHOT, icon, -1);
}
-/*
-gboolean increase_timeout (GtkCellRenderer *renderer)
-{
- GtkTreeIter iter;
- gfloat perc = 0.0;
- //gchar buf[20];
-
- gtk_tree_model_get_iter_first(GTK_TREE_MODEL(g_store), &iter);
-
- gtk_tree_model_get (GTK_TREE_MODEL(g_store), &iter, COL_SNAPSHOT, &perc, -1);
-
- if ( perc > (1.0-STEP) || (perc < STEP && perc > 0.0) )
- {
- increasing = (!increasing);
- }
-
- if (increasing)
- perc = perc + STEP;
- else
- perc = perc - STEP;
-
- //g_snprintf(buf, sizeof(buf), "%u %%", (guint)(perc*100));
-
- gtk_list_store_set (g_store, &iter, COL_SNAPSHOT, perc, -1);
-
- return TRUE;
-}
-*/
#include <gtk/gtk.h>
+extern GtkWidget *g_theme_view;
+extern GtkListStore *g_store;
enum { COL_THEME_FILE = 0, COL_SNAPSHOT, NB_COL, };
GtkWidget *create_view();
void custom_list_append(const gchar *name);
+gboolean update_snapshot();
#endif