Put demo window in another process to prevent some bugs of gtk+.
[lxde/lxappearance.git] / src / demo.c
1 #ifdef HAVE_CONFIG_H
2 # include <config.h>
3 #endif
4
5 #include <gtk/gtk.h>
6
7 #include "demo.h"
8 #include "demo-ui.h"
9 #include "glade-support.h"
10
11 static GtkIconView* icon_view = NULL;
12
13 static void load_demo_icons()
14 {
15 static const char** icon_names[]={
16 "gnome-fs-home",
17 "gnome-fs-desktop",
18 "gnome-fs-directory",
19 "gnome-fs-trash-empty",
20 "gnome-fs-regular",
21 "gnome-fs-executable",
22 "gnome-mime-image",
23 "gnome-mime-text"
24 };
25
26 int i;
27 GtkIconTheme* theme = gtk_icon_theme_get_default();
28 GtkListStore* demo_icon_list;
29
30 demo_icon_list = gtk_list_store_new( 2, GDK_TYPE_PIXBUF, G_TYPE_STRING );
31
32 for( i = 0; i < G_N_ELEMENTS(icon_names); ++i )
33 {
34 GtkTreeIter it;
35 GdkPixbuf* icon = gtk_icon_theme_load_icon( theme, icon_names[i], 32, 0, NULL );
36 gtk_list_store_append( demo_icon_list, &it );
37 gtk_list_store_set( demo_icon_list, &it, 0, icon, 1, icon_names[i], -1 );
38 if( icon )
39 g_object_unref( icon );
40 }
41 gtk_icon_view_set_model( icon_view, demo_icon_list );
42 g_object_unref( demo_icon_list );
43 }
44
45 void show_demo( GdkNativeWindow wid )
46 {
47 GtkWidget* demo = create_demo_window();
48 GtkWidget* plug = gtk_plug_new( wid );
49 GtkWidget* top_vbox;
50
51 icon_view = lookup_widget( demo, "icon_view" );
52 gtk_widget_show_all( demo );
53 gtk_container_add( (GtkContainer*)plug, demo );
54
55 gtk_widget_show( plug );
56 gtk_icon_view_set_pixbuf_column( icon_view, 0 );
57 gtk_icon_view_set_text_column( icon_view, 1 );
58 gtk_icon_view_set_item_width( icon_view, 64 );
59 gtk_icon_view_set_column_spacing( icon_view, 8 );
60 gtk_icon_view_set_row_spacing( icon_view, 8 );
61
62 load_demo_icons();
63 }