Implement UI for icon and cursor themes.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 26 Jul 2010 18:36:14 +0000 (02:36 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Mon, 26 Jul 2010 18:36:14 +0000 (02:36 +0800)
data/ui/lxappearance.glade
src/Makefile.am
src/color-scheme.c [new file with mode: 0644]
src/color-scheme.h [new file with mode: 0644]
src/cursor-theme.c
src/icon-theme.c
src/icon-theme.h
src/lxappearance2.c
src/lxappearance2.h [new file with mode: 0644]
src/widget-theme.c

index a76ee5b..9522817 100644 (file)
@@ -1,72 +1,11 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
-  <object class="GtkListStore" id="tb_style_store">
-    <columns>
-      <!-- column-name item -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">Icons only</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Text only</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Text below icons</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">Text beside icons</col>
-      </row>
-    </data>
-  </object>
-  <object class="GtkListStore" id="icon_theme_store"/>
-  <object class="GtkListStore" id="cursor_theme_store"/>
-  <object class="GtkListStore" id="cursor_demo_store"/>
-  <object class="GtkListStore" id="icon_demo_store">
-    <columns>
-      <!-- column-name icon-name -->
-      <column type="gchararray"/>
-    </columns>
-    <data>
-      <row>
-        <col id="0" translatable="yes">user-home</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">user-desktop</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">folder</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">folder-remote</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">user-trash</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">x-office-document</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">application-x-executable</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">image-x-generic</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">text-x-generic</col>
-      </row>
-      <row>
-        <col id="0" translatable="yes">text-html</col>
-      </row>
-    </data>
-  </object>
   <object class="GtkDialog" id="dlg">
     <property name="border_width">5</property>
     <property name="title" translatable="yes">Look and Feels</property>
-    <property name="default_width">512</property>
+    <property name="default_width">540</property>
     <property name="icon_name">preferences-desktop-theme</property>
     <property name="type_hint">normal</property>
     <property name="has_separator">False</property>
                         <property name="can_focus">True</property>
                         <property name="has_focus">True</property>
                         <property name="headers_visible">False</property>
+                        <child>
+                          <object class="GtkTreeViewColumn" id="treeviewcolumn3">
+                            <child>
+                              <object class="GtkCellRendererText" id="cellrenderertext7"/>
+                              <attributes>
+                                <attribute name="text">0</attribute>
+                              </attributes>
+                            </child>
+                          </object>
+                        </child>
                       </object>
                     </child>
                   </object>
                                                   <object class="GtkEntry" id="entry1">
                                                     <property name="visible">True</property>
                                                     <property name="can_focus">True</property>
-                                                    <property name="invisible_char">&#x25CF;</property>
+                                                    <property name="invisible_char"></property>
                                                   </object>
                                                 </child>
                                               </object>
                                                             <object class="GtkSpinButton" id="spinbutton1">
                                                             <property name="visible">True</property>
                                                             <property name="can_focus">True</property>
-                                                            <property name="invisible_char">&#x25CF;</property>
+                                                            <property name="invisible_char"></property>
                                                             <property name="climb_rate">1</property>
                                                             </object>
                                                             <packing>
                                                 <child>
                                                   <object class="GtkTreeViewColumn" id="treeviewcolumn1">
                                                     <property name="title">column</property>
+                                                    <child>
+                                                      <object class="GtkCellRendererPixbuf" id="cellrendererpixbuf1"/>
+                                                      <attributes>
+                                                        <attribute name="icon-name">0</attribute>
+                                                      </attributes>
+                                                    </child>
                                                   </object>
                                                 </child>
                                                 <child>
                                                   <object class="GtkTreeViewColumn" id="treeviewcolumn2">
                                                     <property name="title">column</property>
+                                                    <child>
+                                                      <object class="GtkCellRendererText" id="cellrenderertext6"/>
+                                                      <attributes>
+                                                        <attribute name="text">0</attribute>
+                                                      </attributes>
+                                                    </child>
                                                   </object>
                                                 </child>
                                               </object>
                           <object class="GtkTreeView" id="icon_theme_view">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="model">icon_theme_store</property>
+                            <property name="headers_visible">False</property>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn4">
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext8"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
                         <property name="position">0</property>
                       </packing>
                     </child>
-                    <child>
-                      <object class="GtkFrame" id="frame3">
-                        <property name="visible">True</property>
-                        <property name="label_xalign">0</property>
-                        <property name="shadow_type">none</property>
-                        <child>
-                          <object class="GtkAlignment" id="alignment1">
-                            <property name="visible">True</property>
-                            <property name="left_padding">12</property>
-                            <child>
-                              <object class="GtkTable" id="table1">
-                                <property name="visible">True</property>
-                                <property name="n_rows">3</property>
-                                <property name="n_columns">4</property>
-                                <property name="column_spacing">12</property>
-                                <property name="row_spacing">6</property>
-                                <child>
-                                  <object class="GtkLabel" id="label8">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Menu:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options">GTK_FILL</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkSpinButton" id="spinbutton2">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="right_attach">2</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="label15">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Button:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options">GTK_FILL</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="label17">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Dialog:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options">GTK_FILL</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkSpinButton" id="spinbutton3">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="right_attach">2</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkSpinButton" id="spinbutton4">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">1</property>
-                                    <property name="right_attach">2</property>
-                                    <property name="top_attach">2</property>
-                                    <property name="bottom_attach">3</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="label20">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Small Toolbar:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options">GTK_FILL</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkLabel" id="label21">
-                                    <property name="visible">True</property>
-                                    <property name="xalign">0</property>
-                                    <property name="label" translatable="yes">Large Toolbar:</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">2</property>
-                                    <property name="right_attach">3</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
-                                    <property name="x_options">GTK_FILL</property>
-                                    <property name="y_options">GTK_FILL</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkSpinButton" id="spinbutton5">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">3</property>
-                                    <property name="right_attach">4</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <object class="GtkSpinButton" id="spinbutton6">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">True</property>
-                                    <property name="invisible_char">&#x25CF;</property>
-                                  </object>
-                                  <packing>
-                                    <property name="left_attach">3</property>
-                                    <property name="right_attach">4</property>
-                                    <property name="top_attach">1</property>
-                                    <property name="bottom_attach">2</property>
-                                  </packing>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                                <child>
-                                  <placeholder/>
-                                </child>
-                              </object>
-                            </child>
-                          </object>
-                        </child>
-                        <child type="label">
-                          <object class="GtkLabel" id="label3">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">&lt;b&gt;Icon Sizes&lt;/b&gt;</property>
-                            <property name="use_markup">True</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
                   </object>
                   <packing>
                     <property name="position">1</property>
             <child type="tab">
               <object class="GtkLabel" id="label2">
                 <property name="visible">True</property>
-                <property name="label" translatable="yes">Icon</property>
+                <property name="label" translatable="yes">Icon Theme</property>
               </object>
               <packing>
                 <property name="position">2</property>
                           <object class="GtkTreeView" id="cursor_theme_view">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="model">cursor_theme_store</property>
+                            <property name="headers_visible">False</property>
+                            <child>
+                              <object class="GtkTreeViewColumn" id="treeviewcolumn5">
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext9"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
                     </child>
                   </object>
                   <packing>
-                    <property name="expand">False</property>
                     <property name="position">0</property>
                   </packing>
                 </child>
                           <object class="GtkIconView" id="cursor_demo_view">
                             <property name="visible">True</property>
                             <property name="can_focus">True</property>
-                            <property name="model">cursor_demo_store</property>
                             <child>
                               <object class="GtkCellRendererPixbuf" id="cellrenderertext4">
                                 <property name="stock_size">6</property>
               <object class="GtkVBox" id="vbox1">
                 <property name="visible">True</property>
                 <property name="border_width">12</property>
-                <property name="spacing">6</property>
+                <property name="spacing">18</property>
                 <child>
-                  <object class="GtkHBox" id="hbox5">
+                  <object class="GtkFrame" id="frame4">
                     <property name="visible">True</property>
-                    <property name="spacing">6</property>
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkLabel" id="label19">
+                      <object class="GtkAlignment" id="alignment4">
                         <property name="visible">True</property>
-                        <property name="xalign">0</property>
-                        <property name="label" translatable="yes">Toolbar Style: </property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkTable" id="table2">
+                            <property name="visible">True</property>
+                            <property name="n_rows">2</property>
+                            <property name="n_columns">2</property>
+                            <property name="column_spacing">12</property>
+                            <property name="row_spacing">6</property>
+                            <child>
+                              <object class="GtkLabel" id="label24">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Toolbar Style: </property>
+                              </object>
+                              <packing>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkLabel" id="label25">
+                                <property name="visible">True</property>
+                                <property name="xalign">0</property>
+                                <property name="label" translatable="yes">Toolbar Icon Size: </property>
+                              </object>
+                              <packing>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="tb_style">
+                                <property name="visible">True</property>
+                                <property name="model">tb_style_store</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkComboBox" id="tb_icon_size">
+                                <property name="visible">True</property>
+                                <property name="model">tb_icon_size_store</property>
+                                <child>
+                                  <object class="GtkCellRendererText" id="cellrenderertext5"/>
+                                  <attributes>
+                                    <attribute name="text">0</attribute>
+                                  </attributes>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
+                                <property name="y_options">GTK_FILL</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
                     </child>
-                    <child>
-                      <object class="GtkComboBox" id="tb_style">
+                    <child type="label">
+                      <object class="GtkLabel" id="label19">
                         <property name="visible">True</property>
-                        <property name="model">tb_style_store</property>
-                        <child>
-                          <object class="GtkCellRendererText" id="cellrenderertext2"/>
-                          <attributes>
-                            <attribute name="text">0</attribute>
-                          </attributes>
-                        </child>
+                        <property name="label" translatable="yes">&lt;b&gt;Toolbar&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
                       </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
                     </child>
                   </object>
                   <packing>
                   </packing>
                 </child>
                 <child>
-                  <placeholder/>
+                  <object class="GtkFrame" id="frame3">
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment1">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox12">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCheckButton" id="custom_icon_size">
+                                <property name="label" translatable="yes">Use customized icon sizes</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkTable" id="table1">
+                                <property name="visible">True</property>
+                                <property name="n_rows">6</property>
+                                <property name="n_columns">2</property>
+                                <property name="column_spacing">12</property>
+                                <property name="row_spacing">6</property>
+                                <child>
+                                  <object class="GtkLabel" id="label8">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Menu:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label15">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Button:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">1</property>
+                                    <property name="bottom_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label17">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Dialog:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">2</property>
+                                    <property name="bottom_attach">3</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkHBox" id="hbox9">
+                                    <property name="visible">True</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkSpinButton" id="gtk-menu-size">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="snap_to_ticks">True</property>
+                                        <property name="numeric">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkLabel" id="label23">
+                                        <property name="visible">True</property>
+                                        <property name="label" translatable="yes">x</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkSpinButton" id="gtk-menu-size1">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="invisible_char">●</property>
+                                        <property name="snap_to_ticks">True</property>
+                                        <property name="numeric">True</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="position">2</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="right_attach">2</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label20">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Small Toolbar:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">3</property>
+                                    <property name="bottom_attach">4</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label21">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Large Toolbar:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">4</property>
+                                    <property name="bottom_attach">5</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <object class="GtkLabel" id="label22">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="label" translatable="yes">Drag Icon:</property>
+                                  </object>
+                                  <packing>
+                                    <property name="top_attach">5</property>
+                                    <property name="bottom_attach">6</property>
+                                    <property name="x_options">GTK_FILL</property>
+                                    <property name="y_options">GTK_FILL</property>
+                                  </packing>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                                <child>
+                                  <placeholder/>
+                                </child>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label3">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Icon Sizes&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
               </object>
               <packing>
       </object>
     </child>
     <action-widgets>
-      <action-widget response="0">about</action-widget>
-      <action-widget response="-5">apply</action-widget>
-      <action-widget response="-6">close</action-widget>
+      <action-widget response="1">about</action-widget>
+      <action-widget response="-10">apply</action-widget>
+      <action-widget response="-7">close</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkListStore" id="icon_demo_store">
+    <columns>
+      <!-- column-name icon-name -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">user-home</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">user-desktop</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">folder</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">folder-remote</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">user-trash</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">x-office-document</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">application-x-executable</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">image-x-generic</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">text-x-generic</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">text-html</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkListStore" id="tb_icon_size_store">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+      <!-- column-name value -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Large</col>
+        <col id="1">3</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Small</col>
+        <col id="1">2</col>
+      </row>
+    </data>
+  </object>
+  <object class="GtkListStore" id="tb_style_store">
+    <columns>
+      <!-- column-name item -->
+      <column type="gchararray"/>
+      <!-- column-name value -->
+      <column type="gint"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Icons only</col>
+        <col id="1">0</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Text only</col>
+        <col id="1">0</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Text below icons</col>
+        <col id="1">0</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Text beside icons</col>
+        <col id="1">0</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkImage" id="image2">
     <property name="visible">True</property>
     <property name="stock">gtk-add</property>
index 3fc2c3f..093fcf7 100644 (file)
@@ -10,8 +10,11 @@ AM_CPPFLAGS = \
 bin_PROGRAMS = lxappearance2
 lxappearance2_SOURCES = \
        lxappearance2.c \
+       lxappearance2.h \
        widget-theme.c \
        widget-theme.h \
+       color-scheme.c \
+       color-scheme.h \
        icon-theme.c \
        icon-theme.h \
        cursor-theme.c \
diff --git a/src/color-scheme.c b/src/color-scheme.c
new file mode 100644 (file)
index 0000000..710090c
--- /dev/null
@@ -0,0 +1,76 @@
+//      color-scheme.c
+//
+//      Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+//
+//      This program is free software; you can redistribute it and/or modify
+//      it under the terms of the GNU General Public License as published by
+//      the Free Software Foundation; either version 2 of the License, or
+//      (at your option) any later version.
+//
+//      This program is distributed in the hope that it will be useful,
+//      but WITHOUT ANY WARRANTY; without even the implied warranty of
+//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//      GNU General Public License for more details.
+//
+//      You should have received a copy of the GNU General Public License
+//      along with this program; if not, write to the Free Software
+//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+//      MA 02110-1301, USA.
+
+#include "lxappearance2.h"
+#include "color-scheme.h"
+#include <string.h>
+
+void color_scheme_init()
+{
+    color_scheme_update();
+}
+
+static gboolean gtkrc_supports_colors(const char* gtkrc_file, gboolean* support)
+{
+    char* content;
+    gboolean support_colors = FALSE;
+    if(g_file_get_contents(gtkrc_file, &content, NULL, NULL))
+    {
+        /* FIXME: check included gtkrc files, too. */
+        if(strstr(content, "gtk-color-scheme"))
+            support_colors = TRUE;
+        g_free(content);
+    }
+    *support = support_colors;
+}
+
+/* check if current gtk+ widget theme supports color schemes */
+void color_scheme_update()
+{
+    gboolean supported = FALSE;
+    if(app.widget_theme)
+    {
+        gboolean file_found;
+        char* gtkrc = g_build_filename(g_get_home_dir(), ".themes", app.widget_theme, "gtk-2.0/gtkrc", NULL);
+        file_found = gtkrc_supports_colors(gtkrc, &supported);
+        g_free(gtkrc);
+
+        if(!file_found)
+        {
+            gtkrc = g_build_filename(gtk_rc_get_theme_dir(), app.widget_theme, "gtk-2.0/gtkrc", NULL);
+            gtkrc_supports_colors(gtkrc, &supported);
+            g_free(gtkrc);
+        }
+    }
+
+    g_free(app.color_scheme);
+    if(supported)
+    {
+        g_object_get(gtk_settings_get_default(), "gtk-color-scheme", &app.color_scheme, NULL);
+        g_debug("color-scheme: %s", app.color_scheme);
+        //gtk_widget_set_sensitive(, TRUE);
+    }
+    else
+    {
+        app.color_scheme = NULL;
+        //gtk_widget_set_sensitive(, FALSE);
+        g_debug("color-scheme is not supported by this theme");
+    }
+}
+
diff --git a/src/color-scheme.h b/src/color-scheme.h
new file mode 100644 (file)
index 0000000..81e3701
--- /dev/null
@@ -0,0 +1,31 @@
+//      color-scheme.h
+//
+//      Copyright 2010 Hong Jen Yee (PCMan) <pcman.tw@gmail.com>
+//
+//      This program is free software; you can redistribute it and/or modify
+//      it under the terms of the GNU General Public License as published by
+//      the Free Software Foundation; either version 2 of the License, or
+//      (at your option) any later version.
+//
+//      This program is distributed in the hope that it will be useful,
+//      but WITHOUT ANY WARRANTY; without even the implied warranty of
+//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//      GNU General Public License for more details.
+//
+//      You should have received a copy of the GNU General Public License
+//      along with this program; if not, write to the Free Software
+//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+//      MA 02110-1301, USA.
+
+
+#ifndef __COLOR_SCHEME_H__
+#define __COLOR_SCHEME_H__
+
+G_BEGIN_DECLS
+
+void color_scheme_init();
+void color_scheme_update();
+
+G_END_DECLS
+
+#endif /* __COLOR_SCHEME_H__ */
index 5f56d29..960feca 100644 (file)
  */
 
 #include "cursor-theme.h"
+#include "lxappearance2.h"
 
 static GtkWidget* cursor_theme_view;
 
 void cursor_theme_init(GtkBuilder* b)
 {
+    /* treeview and model are already set up in icon_theme_init() */
 
 }
index c4b33da..6094d33 100644 (file)
  */
 
 #include "icon-theme.h"
+#include "lxappearance2.h"
+#include <string.h>
 
-static GtkWidget* icon_theme_view;
+gint icon_theme_cmp_name(IconTheme* t, const char* name)
+{
+    return strcmp(t->name, name);
+}
+
+gint icon_theme_cmp_disp_name(IconTheme* t1, IconTheme* t2)
+{
+    return g_utf8_collate(t1->disp_name, t2->disp_name);
+}
+
+static void icon_theme_free(IconTheme* theme)
+{
+    g_free(theme->comment);
+    g_free(theme->name);
+    if(theme->disp_name != theme->name)
+        g_free(theme->disp_name);
+    g_slice_free(IconTheme, theme);
+}
+
+static void load_icon_themes_from_dir(const char* theme_dir, GKeyFile* kf)
+{
+    GDir* dir = g_dir_open(theme_dir, 0, NULL);
+    if(dir)
+    {
+        const char* name;
+        while(name = g_dir_read_name(dir))
+        {
+            /* skip "default" */
+            if(G_UNLIKELY(strcmp(name, "default") == 0))
+                continue;
+            /* test if we already have this in list */
+            if(!g_slist_find_custom(app.icon_themes, name, (GCompareFunc)icon_theme_cmp_name))
+            {
+                IconTheme* theme = g_slice_new0(IconTheme);
+                char* index_theme;
+                char* cursor_subdir;
+
+                theme->name = g_strdup(name);
+                index_theme = g_build_filename(theme_dir, name, "index.theme", NULL);
+                if(g_key_file_load_from_file(kf, index_theme, 0, NULL))
+                {
+                    /* skip hidden ones */
+                    if(!g_key_file_get_boolean(kf, "Icon Theme", "Hidden", NULL))
+                    {
+                        theme->disp_name = g_key_file_get_locale_string(kf, "Icon Theme", "Name", NULL, NULL);
+                        /* test if this is a icon theme or it's a cursor theme */
+                        theme->comment = g_key_file_get_locale_string(kf, "Icon Theme", "Comment", NULL, NULL);
+
+                        /* icon theme must have this key, so it has icons if it has this key */
+                        theme->has_icon = g_key_file_has_key(kf, "Icon Theme", "Directories", NULL);
+                    }
+                }
+                else
+                    theme->disp_name = theme->name;
+                g_free(index_theme);
+
+                cursor_subdir = g_build_filename(theme_dir, name, "cursors", NULL);
+                /* it contains a cursor theme */
+                if(g_file_test(cursor_subdir, G_FILE_TEST_IS_DIR))
+                    theme->has_cursor = TRUE;
+                g_free(cursor_subdir);
+
+                if(theme->has_icon || theme->has_cursor)
+                    app.icon_themes = g_slist_prepend(app.icon_themes, theme);
+                else /* this dir contains no icon or cursor theme, drop it. */
+                    icon_theme_free(theme);
+            }
+        }
+        g_dir_close(dir);
+    }
+}
+
+static void load_icon_themes()
+{
+    const char* const *dirs = g_get_system_data_dirs();
+    const char* const *pdir;
+    char* dir_path;
+    GKeyFile* kf = g_key_file_new();
+
+    dir_path = g_build_filename(g_get_home_dir(), ".icons", NULL);
+    load_icon_themes_from_dir(dir_path, kf);
+    g_free(dir_path);
+
+    dir_path = g_build_filename(g_get_user_data_dir(), "icons", NULL);
+    load_icon_themes_from_dir(dir_path, kf);
+    g_free(dir_path);
+
+    for(pdir = dirs; *pdir; ++pdir)
+    {
+        dir_path = g_build_filename(*pdir, "icons", NULL);
+        load_icon_themes_from_dir(dir_path, kf);
+        g_free(dir_path);
+    }
+    g_key_file_free(kf);
+
+    app.icon_themes = g_slist_sort(app.icon_themes, (GCompareFunc)icon_theme_cmp_disp_name);
+}
+
+static void icon_sizes_init(GtkBuilder* b)
+{
+    const char* names[] = {
+        "gtk-menu",
+        "gtk-button",
+        "gtk-small-toolbar",
+        "gtk-large-toolbar",
+        "gtk-dnd",
+        "gtk-dialog"
+    };
+    char* sizes_str;
+    g_object_get(gtk_settings_get_default(), "gtk-icon-sizes", &sizes_str);
+    g_debug("%s", sizes_str);
+}
 
 void icon_theme_init(GtkBuilder* b)
 {
+    GSList* l;
+    GtkTreeIter it;
+    GtkTreeIter icon_theme_sel_it = {0};
+    GtkTreeIter cursor_theme_sel_it = {0};
+    GtkTreeSelection* sel;
+
+    app.icon_theme_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
+    app.cursor_theme_store = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_POINTER);
+    app.icon_theme_view = GTK_WIDGET(gtk_builder_get_object(b, "icon_theme_view"));
+    app.cursor_theme_view = GTK_WIDGET(gtk_builder_get_object(b, "cursor_theme_view"));
+
     /* load icon themes */
+    load_icon_themes();
+
+    for(l = app.icon_themes; l; l=l->next)
+    {
+        IconTheme* theme = (IconTheme*)l->data;
+
+        if(theme->has_icon)
+        {
+            gtk_list_store_insert_with_values(app.icon_theme_store, &it, -1, 0, theme->disp_name, 1, theme, -1);
+            if(!icon_theme_sel_it.user_data)
+            {
+                if(strcmp(theme->name, app.icon_theme) == 0)
+                    icon_theme_sel_it = it;
+            }
+        }
+
+        if(theme->has_cursor)
+        {
+            gtk_list_store_insert_with_values(app.cursor_theme_store, &it, -1, 0, theme->disp_name, 1, theme, -1);
+            if(!cursor_theme_sel_it.user_data)
+            {
+                if(g_strcmp0(theme->name, app.cursor_theme) == 0)
+                    cursor_theme_sel_it = it;
+            }
+        }
+    }
+
+    /* select the currently used theme from the list */
+    gtk_tree_view_set_model(app.icon_theme_view, GTK_TREE_MODEL(app.icon_theme_store));
+    sel = gtk_tree_view_get_selection(app.icon_theme_view);
+    if(icon_theme_sel_it.user_data)
+        gtk_tree_selection_select_iter(sel, &icon_theme_sel_it);
+
+    gtk_tree_view_set_model(app.cursor_theme_view, GTK_TREE_MODEL(app.cursor_theme_store));
+    sel = gtk_tree_view_get_selection(app.cursor_theme_view);
+    if(cursor_theme_sel_it.user_data)
+        gtk_tree_selection_select_iter(sel, &cursor_theme_sel_it);
 
     /* load "gtk-icon-sizes" */
-    /*
-    gtk-menu,
-    gtk-button,
-    gtk-small-toolbar,
-    gtk-large-toolbar,
-    gtk-dnd,
-    gtk-dialog
-    */
+    icon_sizes_init(b);
 }
index 0790aee..81841ed 100644 (file)
 
 G_BEGIN_DECLS
 
+typedef struct
+{
+    char* name;
+    char* disp_name;
+    char* comment;
+    gboolean has_icon : 1;
+    gboolean has_cursor : 1;
+}IconTheme;
+
 void icon_theme_init(GtkBuilder* b);
 
 G_END_DECLS
index b6b9f03..af56e08 100644 (file)
 #include <config.h>
 #endif
 
+#include "lxappearance2.h"
+
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
+
+#include <X11/X.h>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <gdk/gdkx.h>
+
 #include "widget-theme.h"
 #include "icon-theme.h"
 #include "cursor-theme.h"
 
+LXAppearance app = {0};
+
+Atom lxsession_atom = 0;
+
+static void check_lxsession()
+{
+    lxsession_atom = XInternAtom( GDK_DISPLAY(), "_LXSESSION", True );
+    if( lxsession_atom != None )
+    {
+        XGrabServer( GDK_DISPLAY() );
+        if( XGetSelectionOwner( GDK_DISPLAY(), lxsession_atom ) )
+            app.use_lxsession = TRUE;
+        XUngrabServer( GDK_DISPLAY() );
+    }
+}
+
 static GOptionEntry option_entries[] =
 {
     { NULL }
 };
 
+static void lxappearance_save_gtkrc()
+{
+
+}
+
+static void lxappearance_save_lxsession()
+{
+
+}
+
+static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
+{
+    switch(res)
+    {
+    case GTK_RESPONSE_APPLY:
+
+        if(app.use_lxsession)
+            lxappearance_save_lxsession();
+        else
+            lxappearance_save_gtkrc();
+
+        app.changed = FALSE;
+        gtk_dialog_set_response_sensitive(app.dlg, GTK_RESPONSE_APPLY, FALSE);
+        break;
+    case 1: /* about dialog */
+        {
+            GtkBuilder* b = gtk_builder_new();
+            if(gtk_builder_add_from_file(b, PACKAGE_UI_DIR "/about.ui", NULL))
+            {
+                GtkWidget* dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
+                gtk_dialog_run(dlg);
+                gtk_widget_destroy(dlg);
+            }
+            g_object_unref(b);
+        }
+        break;
+    default:
+        gtk_main_quit();
+    }
+}
+
+static void settings_init()
+{
+    g_object_get(gtk_settings_get_default(), "gtk-theme-name", &app.widget_theme, NULL);
+    g_object_get(gtk_settings_get_default(), "gtk-icon-theme-name", &app.icon_theme, NULL);
+
+    /* try to figure out cursor theme used. */
+    g_object_get(gtk_settings_get_default(), "gtk-cursor-theme-name", &app.cursor_theme, NULL);
+    if(!app.cursor_theme || g_strcmp0(app.cursor_theme, "default") == 0)
+    {
+        /* get the real theme name from default. */
+        GKeyFile* kf = g_key_file_new();
+        char* fpath = g_build_filename(g_get_home_dir(), ".icons/default/index.theme", NULL);
+        gboolean ret = g_key_file_load_from_file(kf, fpath, 0, NULL);
+        g_free(fpath);
+
+        if(!ret)
+            ret = g_key_file_load_from_data_dirs(kf, "icons/default/index.theme", NULL, 0, NULL);
+
+        if(ret)
+        {
+            app.cursor_theme = g_key_file_get_string(kf, "Icon Theme", "Inherits", NULL);
+            g_debug("cursor theme name: %s", app.cursor_theme);
+        }
+        g_key_file_free(kf);
+    }
+}
+
 int main(int argc, char** argv)
 {
     GError* err = NULL;
     GtkBuilder* b;
-    GtkWidget* win;
 
     /* gettext support */
 #ifdef ENABLE_NLS
@@ -60,6 +151,12 @@ int main(int argc, char** argv)
         return 1;
     }
 
+    /* check if we're under LXSession */
+    check_lxsession();
+
+    /* load config values */
+    settings_init();
+
     /* create GUI here */
     b = gtk_builder_new();
     if(!gtk_builder_add_from_file(b, PACKAGE_UI_DIR "/lxappearance.ui", NULL))
@@ -69,12 +166,22 @@ int main(int argc, char** argv)
     icon_theme_init(b);
     cursor_theme_init(b);
 
-    win = gtk_builder_get_object(b, "dlg");
+    app.dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
+    g_signal_connect(app.dlg, "response", G_CALLBACK(on_dlg_response), NULL);
 
-    gtk_window_present(GTK_WINDOW(win));
+    gtk_window_present(GTK_WINDOW(app.dlg));
     g_object_unref(b);
 
     gtk_main();
 
     return 0;
 }
+
+void lxappearance_changed()
+{
+    if(!app.changed)
+    {
+        app.changed = TRUE;
+        gtk_dialog_set_response_sensitive(app.dlg, GTK_RESPONSE_APPLY, TRUE);
+    }
+}
diff --git a/src/lxappearance2.h b/src/lxappearance2.h
new file mode 100644 (file)
index 0000000..05d19bb
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *      lxappearance2.h
+ *
+ *      Copyright 2010 PCMan <pcman.tw@gmail.com>
+ *
+ *      This program is free software; you can redistribute it and/or modify
+ *      it under the terms of the GNU General Public License as published by
+ *      the Free Software Foundation; either version 2 of the License, or
+ *      (at your option) any later version.
+ *
+ *      This program is distributed in the hope that it will be useful,
+ *      but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *      GNU General Public License for more details.
+ *
+ *      You should have received a copy of the GNU General Public License
+ *      along with this program; if not, write to the Free Software
+ *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ *      MA 02110-1301, USA.
+ */
+
+#ifndef _LXAPPEARANCE2_H_
+#define _LXAPPEARANCE2_H_
+
+#include <gtk/gtk.h>
+
+typedef struct _LXAppearance    LXAppearance;
+struct _LXAppearance
+{
+    GtkWidget* dlg;
+    GtkWidget* notebook;
+
+    GtkWidget* widget_theme_view;
+    GtkListStore* widget_theme_store;
+
+    GtkWidget* icon_theme_view;
+    GtkListStore* icon_theme_store;
+
+    GtkWidget* cursor_theme_view;
+    GtkListStore* cursor_theme_store;
+
+    GSList* icon_themes; /* a list of IconTheme struct */
+
+    char* widget_theme;
+    char* icon_theme;
+    char* cursor_theme;
+    char* color_scheme;
+    char* icon_sizes;
+    int toolbar_style;
+    int toolbar_size;
+    gboolean changed;
+    gboolean use_lxsession;
+};
+
+extern LXAppearance app;
+
+void lxappearance_changed();
+
+#endif
index 48b34d9..75ed24b 100644 (file)
  *      MA 02110-1301, USA.
  */
 
+#include "lxappearance2.h"
 #include "widget-theme.h"
+#include "color-scheme.h"
 #include <string.h>
 
-static GtkWidget* widget_theme_view;
-static GtkListStore* store;
-
 static GSList* load_themes_in_dir(const char* theme_dir, GSList* themes)
 {
     GDir* dir = g_dir_open(theme_dir, 0, NULL);
@@ -39,7 +38,7 @@ static GSList* load_themes_in_dir(const char* theme_dir, GSList* themes)
                 /* test if this is a gtk theme */
                 char* gtkrc = g_build_filename(theme_dir, name, "gtk-2.0/gtkrc", NULL);
                 if(g_file_test(gtkrc, G_FILE_TEST_EXISTS))
-                    themes = g_list_prepend(themes, g_strdup(name));
+                    themes = g_slist_prepend(themes, g_strdup(name));
                 g_free(gtkrc);
             }
         }
@@ -54,19 +53,13 @@ static void on_sel_changed(GtkTreeSelection* sel, gpointer user_data)
     GtkTreeModel* model;
     if(gtk_tree_selection_get_selected(sel, &model, &it))
     {
-        char* theme_name;
-        gtk_tree_model_get(model, &it, 0, &theme_name, -1);
-        g_object_set(gtk_settings_get_default(), "gtk-theme-name", theme_name, NULL);
-        g_free(theme_name);
-
-        /*
-        FIXME: check if current theme support color schemes.
-
-        char* color_scheme;
-        g_object_get(gtk_settings_get_default(), "gtk-color-scheme", &color_scheme, NULL);
-        g_debug("gtk-color-scheme:%s", color_scheme);
-        g_free(color_scheme);
-        */
+        g_free(app.widget_theme);
+        gtk_tree_model_get(model, &it, 0, &app.widget_theme, -1);
+        g_object_set(gtk_settings_get_default(), "gtk-theme-name", app.widget_theme, NULL);
+        lxappearance_changed();
+
+        /* check if current theme support color schemes. */
+        color_scheme_update();
     }
 }
 
@@ -74,13 +67,9 @@ static void load_themes()
 {
     char* dir;
     GSList* themes = NULL, *l;
-    GtkTreeViewColumn* col;
-    char* current;
     GtkTreeIter sel_it = {0};
     GtkTreeSelection* tree_sel;
 
-    g_object_get(gtk_settings_get_default(), "gtk-theme-name", &current, NULL);
-
     /* load user dir */
     dir = g_build_filename(g_get_home_dir(), ".themes", NULL);
     themes = load_themes_in_dir(dir, themes);
@@ -91,31 +80,27 @@ static void load_themes()
     themes = load_themes_in_dir(dir, themes);
     g_free(dir);
 
-    col = gtk_tree_view_column_new_with_attributes("", gtk_cell_renderer_text_new(), "text", 0, NULL);
-    gtk_tree_view_append_column(widget_theme_view, col);
-
     themes = g_slist_sort(themes, (GCompareFunc)strcmp);
     for(l = themes; l; l=l->next)
     {
         GtkTreeIter it;
         char* name = (char*)l->data;
-        gtk_list_store_insert_with_values(store, &it, -1, 0, name, -1);
+        gtk_list_store_insert_with_values(app.widget_theme_store, &it, -1, 0, name, -1);
         /* if this theme is the one currently in use */
         if(!sel_it.user_data)
         {
-            if(strcmp(name, current) == 0)
+            if(strcmp(name, app.widget_theme) == 0)
                 sel_it = it;
         }
         g_free(name);
     }
-    g_free(current);
 
-    gtk_tree_view_set_model(widget_theme_view, GTK_TREE_MODEL(store));
-    tree_sel = gtk_tree_view_get_selection(widget_theme_view);
+    gtk_tree_view_set_model(app.widget_theme_view, GTK_TREE_MODEL(app.widget_theme_store));
+    tree_sel = gtk_tree_view_get_selection(app.widget_theme_view);
     if(sel_it.user_data)
         gtk_tree_selection_select_iter(tree_sel, &sel_it);
 
-    g_list_free(themes);
+    g_slist_free(themes);
 
     g_signal_connect(tree_sel, "changed", G_CALLBACK(on_sel_changed), NULL);
 
@@ -129,11 +114,12 @@ void widget_theme_init(GtkBuilder* b)
     GdkColor black = {0, 0, 0, 0};
 
     demo = GTK_WIDGET(gtk_builder_get_object(b, "demo"));
-    widget_theme_view = GTK_WIDGET(gtk_builder_get_object(b, "widget_theme_view"));
+    app.widget_theme_view = GTK_WIDGET(gtk_builder_get_object(b, "widget_theme_view"));
 
     gtk_widget_modify_bg(demo, GTK_STATE_NORMAL, &black);
 
+    app.widget_theme_store = gtk_list_store_new(1, G_TYPE_STRING);
+
     /* load available themes */
-    store = gtk_list_store_new(1, G_TYPE_STRING);
     load_themes();
 }