]>
Dogcows Code - chaz/tint2/blob - src/tint2conf/theme_view.c
4 #include "theme_view.h"
6 // The data columns that we export via the tree model interface
7 GtkWidget
*g_theme_view
;
9 int g_width_list
, g_height_list
;
10 GtkCellRenderer
*g_renderer
;
14 GtkWidget
*create_view()
16 GtkTreeViewColumn
*col
;
17 GtkCellRenderer
*renderer
;
20 g_store
= gtk_list_store_new(NB_COL
, G_TYPE_STRING
, GDK_TYPE_PIXBUF
);
22 view
= gtk_tree_view_new_with_model(GTK_TREE_MODEL(g_store
));
23 gtk_tree_view_set_rules_hint(GTK_TREE_VIEW(view
), TRUE
);
24 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(view
), FALSE
);
26 g_object_unref(g_store
); // destroy store automatically with view
28 renderer
= gtk_cell_renderer_text_new();
29 col
= gtk_tree_view_column_new();
30 gtk_tree_view_column_pack_start(col
, renderer
, TRUE
);
31 gtk_tree_view_column_add_attribute(col
, renderer
, "text", COL_THEME_FILE
);
32 gtk_tree_view_column_set_visible(col
, FALSE
);
33 gtk_tree_view_append_column(GTK_TREE_VIEW(view
),col
);
37 g_renderer
= gtk_cell_renderer_pixbuf_new();
38 g_object_set(g_renderer
, "xalign", 0.0, NULL
);
39 gtk_cell_renderer_set_fixed_size(g_renderer
, g_width_list
, g_height_list
);
40 // specific to gtk-2.18 or higher
41 //gtk_cell_renderer_set_padding(g_renderer, 5, 5);
42 col
= gtk_tree_view_column_new();
43 gtk_tree_view_column_pack_start(col
, g_renderer
, TRUE
);
44 gtk_tree_view_column_add_attribute(col
, g_renderer
, "pixbuf", COL_SNAPSHOT
);
45 gtk_tree_view_append_column(GTK_TREE_VIEW(view
),col
);
47 GtkTreeSortable
*sortable
;
48 sortable
= GTK_TREE_SORTABLE(g_store
);
49 gtk_tree_sortable_set_sort_column_id(sortable
, COL_THEME_FILE
, GTK_SORT_ASCENDING
);
54 void custom_list_append(const gchar
*name
)
58 gtk_list_store_append(g_store
, &iter
);
59 gtk_list_store_set(g_store
, &iter
, COL_THEME_FILE
, name
, -1);
63 gboolean
update_snapshot()
68 gboolean have_iter
, found
= FALSE
;
70 model
= gtk_tree_view_get_model(GTK_TREE_VIEW(g_theme_view
));
71 have_iter
= gtk_tree_model_get_iter_first(model
, &iter
);
73 gtk_tree_model_get(model
, &iter
, COL_SNAPSHOT
, &icon
, -1);
76 have_iter
= gtk_tree_model_iter_next(model
, &iter
);
85 // build panel's snapshot
87 gchar
*name
, *snap
, *cmd
;
88 gint pixWidth
, pixHeight
;
89 gboolean changeSize
= FALSE
;
91 snap
= g_build_filename (g_get_user_config_dir(), "tint2", "snap.jpg", NULL
);
94 gtk_tree_model_get(model
, &iter
, COL_THEME_FILE
, &name
, -1);
95 cmd
= g_strdup_printf("tint2 -c \'%s\' -s \'%s\'", name
, snap
);
99 pixbuf
= gdk_pixbuf_new_from_file(snap
, NULL
);
100 if (pixbuf
== NULL
) {
101 printf("snapshot NULL : %s\n", cmd
);
108 pixWidth
= gdk_pixbuf_get_width(pixbuf
);
109 pixHeight
= gdk_pixbuf_get_height(pixbuf
);
110 if (g_width_list
< pixWidth
) {
111 g_width_list
= pixWidth
;
114 if (g_height_list
< (pixHeight
+6)) {
115 g_height_list
= pixHeight
+6;
119 gtk_cell_renderer_set_fixed_size(g_renderer
, g_width_list
, g_height_list
);
121 gtk_list_store_set(g_store
, &iter
, COL_SNAPSHOT
, pixbuf
, -1);
This page took 0.03816 seconds and 4 git commands to generate.