int main (int argc, char *argv[])
{
XEvent e;
- fd_set fd_set;
+ fd_set fdset;
int x11_fd, i;
Panel *panel;
GSList *it;
while (1) {
// thanks to AngryLlama for the timer
// Create a File Description Set containing x11_fd, and every timer_fd
- FD_ZERO (&fd_set);
- FD_SET (x11_fd, &fd_set);
+ FD_ZERO (&fdset);
+ FD_SET (x11_fd, &fdset);
int max_fd = x11_fd;
timer_iter = timer_list;
while (timer_iter) {
timer = timer_iter->data;
max_fd = timer->id > max_fd ? timer->id : max_fd;
- FD_SET(timer->id, &fd_set);
+ FD_SET(timer->id, &fdset);
timer_iter = timer_iter->next;
}
// Wait for X Event or a Timer
- if (pselect(max_fd+1, &fd_set, 0, 0, 0, &empty_mask) > 0) {
+ if (pselect(max_fd+1, &fdset, 0, 0, 0, &empty_mask) > 0) {
while (XPending (server.dsp)) {
XNextEvent(server.dsp, &e);
timer_iter = timer_list;
while (timer_iter) {
timer = timer_iter->data;
- if (FD_ISSET(timer->id, &fd_set)) {
+ if (FD_ISSET(timer->id, &fdset)) {
uint64_t dummy;
read(timer->id, &dummy, sizeof(uint64_t));
timer->_callback();
#include <glib/gi18n.h>
#include "common.h"
-
-
-// TODO
-// ** add, saveas
-// - liste de fichiers tint2rc*
-// - menu contextuel dans liste
-// - double clic dans liste
-// - données globales
-// - delete
-// - rename
-// - apply
-// - sauvegarde et lecture taille de fenetre
-// - activation des menus sur sélection dans la liste
-// - dialogue propriétés ...
+#include "theme_view.h"
#define LONG_VERSION_STRING "0.7"
-enum { LIST_ITEM = 0, N_COLUMNS };
// default config file and directory
char *g_path_config = 0;
GtkWidget *g_window;
GtkWidget *g_theme_view;
-GtkListStore *g_store;
GtkCellRenderer *g_renderer;
static GtkUIManager *globalUIManager = NULL;
static gboolean view_onButtonPressed (GtkWidget *treeview, GdkEventButton *event, gpointer userdata);
static void viewRowActivated( GtkTreeView *tree_view, GtkTreePath *path, GtkTreeViewColumn *column, gpointer user_data);
-// TreeView
-static void loadTheme();
-static void init_list(GtkWidget *list);
-static void add_to_list(GtkWidget *list, const gchar *str);
-void on_changed(GtkWidget *widget, gpointer label);
-void read_config();
-void write_config();
-void check_theme();
+// theme files
+static void load_theme();
+static void read_config();
+static void write_config();
+static void check_theme();
// define menubar, toolbar and popup
{
GtkWidget *vBox = NULL, *scrollbar = NULL;
GtkActionGroup *actionGroup;
- GtkTreeSelection *sel;
gtk_init (&argc, &argv);
g_thread_init( NULL );
gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_box_pack_start(GTK_BOX(vBox), scrollbar, TRUE, TRUE, 0);
- // define tree view
- g_theme_view = gtk_tree_view_new();
- gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(g_theme_view), FALSE);
- //gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(g_theme_view), TRUE);
-
- //g_renderer = (GtkCellRenderer *)g_object_new(TORRENT_CELL_RENDERER_TYPE, NULL);
-
- //GtkTreeViewColumn *col = GTK_TREE_VIEW_COLUMN (g_object_new(GTK_TYPE_TREE_VIEW_COLUMN, "title", _("Torrent"), "resizable", TRUE, "sizing", GTK_TREE_VIEW_COLUMN_FIXED, NULL));
-
-
- //gtk_widget_set_size_request(g_theme_view, g_width, g_height);
- //gtk_tree_view_set_fixed_height_mode(GTK_TREE_VIEW(g_theme_view), TRUE);
- //col = GTK_TREE_VIEW_COLUMN (g_object_new (GTK_TYPE_TREE_VIEW_COLUMN, "title", _("Theme"), "resizable", TRUE, "sizing", GTK_TREE_VIEW_COLUMN_FIXED, NULL));
- sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(g_theme_view));
- gtk_tree_selection_set_mode(GTK_TREE_SELECTION(sel), GTK_SELECTION_SINGLE);
+ // define theme view
+ g_theme_view = create_view_and_model();
gtk_container_add(GTK_CONTAINER(scrollbar), g_theme_view);
gtk_widget_show(g_theme_view);
g_signal_connect(g_theme_view, "button-press-event", (GCallback)view_onButtonPressed, NULL);
g_signal_connect(g_theme_view, "popup-menu", (GCallback)view_onPopupMenu, NULL);
g_signal_connect(g_theme_view, "row-activated", G_CALLBACK(viewRowActivated), NULL);
- g_signal_connect(sel, "changed", G_CALLBACK(on_changed), NULL);
-
- GtkCellRenderer *renderer;
- GtkTreeViewColumn *column;
- renderer = gtk_cell_renderer_text_new();
- column = gtk_tree_view_column_new_with_attributes("List Items", renderer, "text", LIST_ITEM, NULL);
- gtk_tree_view_append_column(GTK_TREE_VIEW(g_theme_view), column);
- g_store = gtk_list_store_new(N_COLUMNS, G_TYPE_STRING);
- gtk_tree_view_set_model(GTK_TREE_VIEW(g_theme_view), GTK_TREE_MODEL(g_store));
// load themes
- loadTheme(g_theme_view);
+ load_theme(g_theme_view);
// rig up idle/thread routines
//Glib::Thread::create(sigc::mem_fun(window.view, &Thumbview::load_cache_images), 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, LIST_ITEM, &value, -1);
+ gtk_tree_model_get(model, &iter, COL_TEXT, &value, -1);
gtk_tree_selection_unselect_all(sel);
// remove from the gui
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
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, LIST_ITEM, &value, -1);
+ gtk_tree_model_get(model, &iter, COL_TEXT, &value, -1);
name1 = g_build_filename ("\'", g_get_user_config_dir(), "tint2", value, NULL);
name2 = g_strdup_printf("%s.tint2rc\'", name1);
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, LIST_ITEM, &value, -1);
+ gtk_tree_model_get(model, &iter, COL_TEXT, &value, -1);
name1 = g_build_filename (g_get_user_config_dir(), "tint2", value, NULL);
name2 = g_strdup_printf("%s.tint2rc", name1);
g_free(name1);
}
-static void loadTheme(GtkWidget *list)
+static void load_theme(GtkWidget *list)
{
GDir *dir;
gchar *file, *pt1, *name;
}
-static void add_to_list(GtkWidget *list, const gchar *str)
-{
- GtkListStore *store;
- GtkTreeIter iter;
-
- store = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(list)));
-
- gtk_list_store_append(store, &iter);
- gtk_list_store_set(store, &iter, LIST_ITEM, str, -1);
-}
-
-
-void on_changed(GtkWidget *widget, gpointer label)
-{
- GtkTreeIter iter;
- GtkTreeModel *model;
- char *value;
-
- if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(widget), &model, &iter)) {
- gtk_tree_model_get(model, &iter, LIST_ITEM, &value, -1);
- //gtk_label_set_text(GTK_LABEL(label), value);
- g_free(value);
- }
-
-}
-