Improve UI, add options to set toolbar icon size.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Wed, 28 Jul 2010 14:37:42 +0000 (22:37 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Wed, 28 Jul 2010 14:37:42 +0000 (22:37 +0800)
data/lxappearance2.desktop.in
data/ui/about.glade.in
data/ui/lxappearance.glade
src/Makefile.am
src/icon-theme.c
src/lxappearance2.c
src/lxappearance2.h
src/other.c [new file with mode: 0644]
src/other.h [new file with mode: 0644]
src/widget-theme.c

index c2aabc0..b0b1329 100644 (file)
@@ -1,9 +1,9 @@
 [Desktop Entry]
 Type=Application
-_Name=LXAppearance
-_GenericName=LXAppearance
-_Comment=LXAppearance Description
-Icon=LXAppearance
+_Name=Desktop Look and Feels
+_GenericName=Desktop Look and Feels
+_Comment=Configures look and feels of your desktop and applications
+Icon=preferences-desktop-theme
 Exec=lxappearance2
 StartupNotify=true
 Categories=GTK;
index 689aa5b..f5b7bf8 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 2.12 -->
   <!-- interface-naming-policy toplevel-contextual -->
@@ -9,8 +9,8 @@
     <property name="has_separator">False</property>
     <property name="program_name">LXAppearance</property>
     <property name="version">@VERSION@</property>
-    <property name="copyright" translatable="yes">Copyright (C) 2010</property>
-    <property name="comments" translatable="yes">LXAppearance Description</property>
+    <property name="copyright" translatable="yes">Copyright (C) 2010 LXDE Project</property>
+    <property name="comments" translatable="yes">Configures look and feels of your desktop</property>
     <property name="website">http://lxde.org/</property>
     <property name="license">Copyright (C) 2010 LXDE Team
 
@@ -27,14 +27,13 @@ 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.</property>
-    <property name="authors">LXDE Team</property>
+    <property name="authors">洪任諭 Hong Jen Yee (PCMan) &lt;pcman.tw@gmail.com&gt;</property>
     <property name="translator_credits" translatable="yes" comments="Please replace this line with your own names, one name per line. ">translator-credits</property>
     <property name="artists"></property>
     <property name="wrap_license">True</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox1">
         <property name="visible">True</property>
-        <property name="orientation">vertical</property>
         <property name="spacing">2</property>
         <child internal-child="action_area">
           <object class="GtkHButtonBox" id="dialog-action_area1">
index 9522817..30f5142 100644 (file)
@@ -2,9 +2,109 @@
 <interface>
   <requires lib="gtk+" version="2.16"/>
   <!-- interface-naming-policy project-wide -->
+  <object class="GtkListStore" id="tb_icon_size_store">
+    <columns>
+      <!-- column-name name -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Same as menu items</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Small toolbar icon</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Large toolbar icon</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Same as buttons</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Same as drag icons</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Same as dialogs</col>
+      </row>
+    </data>
+  </object>
+  <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="GtkImage" id="image5">
+    <property name="visible">True</property>
+    <property name="stock">gtk-remove</property>
+  </object>
+  <object class="GtkImage" id="image4">
+    <property name="visible">True</property>
+    <property name="stock">gtk-add</property>
+  </object>
+  <object class="GtkImage" id="image3">
+    <property name="visible">True</property>
+    <property name="stock">gtk-remove</property>
+  </object>
+  <object class="GtkImage" id="image2">
+    <property name="visible">True</property>
+    <property name="stock">gtk-add</property>
+  </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="GtkDialog" id="dlg">
     <property name="border_width">5</property>
-    <property name="title" translatable="yes">Look and Feels</property>
+    <property name="title" translatable="yes">Desktop Look and Feels</property>
     <property name="default_width">540</property>
     <property name="icon_name">preferences-desktop-theme</property>
     <property name="type_hint">normal</property>
                     <property name="position">1</property>
                   </packing>
                 </child>
+                <child>
+                  <object class="GtkFrame" id="sound_effect">
+                    <property name="label_xalign">0</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment" id="alignment5">
+                        <property name="visible">True</property>
+                        <property name="left_padding">12</property>
+                        <child>
+                          <object class="GtkVBox" id="vbox13">
+                            <property name="visible">True</property>
+                            <property name="spacing">6</property>
+                            <child>
+                              <object class="GtkCheckButton" id="event_sound">
+                                <property name="label" translatable="yes">Play event sounds</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">0</property>
+                              </packing>
+                            </child>
+                            <child>
+                              <object class="GtkCheckButton" id="input_feedback_sound">
+                                <property name="label" translatable="yes">play event sounds as feedback to user input</property>
+                                <property name="visible">True</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="use_action_appearance">False</property>
+                                <property name="draw_indicator">True</property>
+                              </object>
+                              <packing>
+                                <property name="position">1</property>
+                              </packing>
+                            </child>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label28">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">&lt;b&gt;Sound Effect&lt;/b&gt;</property>
+                        <property name="use_markup">True</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
               </object>
               <packing>
                 <property name="position">5</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="apply">
-                <property name="label">gtk-apply</property>
+              <object class="GtkButton" id="close">
+                <property name="label">gtk-close</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
               </packing>
             </child>
             <child>
-              <object class="GtkButton" id="close">
-                <property name="label">gtk-close</property>
+              <object class="GtkButton" id="apply">
+                <property name="label">gtk-apply</property>
                 <property name="visible">True</property>
+                <property name="sensitive">False</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="use_stock">True</property>
     </child>
     <action-widgets>
       <action-widget response="1">about</action-widget>
-      <action-widget response="-10">apply</action-widget>
       <action-widget response="-7">close</action-widget>
+      <action-widget response="-10">apply</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>
-  </object>
-  <object class="GtkImage" id="image3">
-    <property name="visible">True</property>
-    <property name="stock">gtk-remove</property>
-  </object>
-  <object class="GtkImage" id="image4">
-    <property name="visible">True</property>
-    <property name="stock">gtk-add</property>
-  </object>
-  <object class="GtkImage" id="image5">
-    <property name="visible">True</property>
-    <property name="stock">gtk-remove</property>
-  </object>
 </interface>
index 093fcf7..e6101c7 100644 (file)
@@ -19,6 +19,8 @@ lxappearance2_SOURCES = \
        icon-theme.h \
        cursor-theme.c \
        cursor-theme.h \
+       other.c \
+       other.h \
        utils.c \
        utils.h \
        $(NULL)
index 6094d33..53fdd3e 100644 (file)
@@ -181,12 +181,22 @@ void icon_theme_init(GtkBuilder* b)
     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)
+    {
+        GtkTreePath* tp = gtk_tree_model_get_path(GTK_TREE_MODEL(app.icon_theme_store), &icon_theme_sel_it);
         gtk_tree_selection_select_iter(sel, &icon_theme_sel_it);
+        gtk_tree_view_scroll_to_cell(app.icon_theme_view, tp, NULL, FALSE, 0, 0);
+        gtk_tree_path_free(tp);
+    }
 
     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)
+    {
+        GtkTreePath* tp = gtk_tree_model_get_path(GTK_TREE_MODEL(app.cursor_theme_store), &cursor_theme_sel_it);
         gtk_tree_selection_select_iter(sel, &cursor_theme_sel_it);
+        gtk_tree_view_scroll_to_cell(app.cursor_theme_view, tp, NULL, FALSE, 0, 0);
+        gtk_tree_path_free(tp);
+    }
 
     /* load "gtk-icon-sizes" */
     icon_sizes_init(b);
index af56e08..1669e82 100644 (file)
@@ -36,6 +36,7 @@
 #include "widget-theme.h"
 #include "icon-theme.h"
 #include "cursor-theme.h"
+#include "other.h"
 
 LXAppearance app = {0};
 
@@ -101,11 +102,15 @@ static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
 
 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);
-
+    GtkSettings* settings = gtk_settings_get_default();
+    g_object_get(settings,
+                "gtk-theme-name", &app.widget_theme,
+                "gtk-icon-theme-name", &app.icon_theme,
+                "gtk-cursor-theme-name", &app.cursor_theme,
+                "gtk-toolbar-style", &app.toolbar_style,
+                "gtk-toolbar-icon-size", &app.toolbar_icon_size,
+                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. */
@@ -119,6 +124,7 @@ static void settings_init()
 
         if(ret)
         {
+            g_free(app.cursor_theme);
             app.cursor_theme = g_key_file_get_string(kf, "Icon Theme", "Inherits", NULL);
             g_debug("cursor theme name: %s", app.cursor_theme);
         }
@@ -162,11 +168,13 @@ int main(int argc, char** argv)
     if(!gtk_builder_add_from_file(b, PACKAGE_UI_DIR "/lxappearance.ui", NULL))
         return 1;
 
+    app.dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
+
     widget_theme_init(b);
     icon_theme_init(b);
     cursor_theme_init(b);
+    other_init(b);
 
-    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(app.dlg));
index 05d19bb..1289520 100644 (file)
@@ -41,13 +41,16 @@ struct _LXAppearance
 
     GSList* icon_themes; /* a list of IconTheme struct */
 
+    GtkWidget* tb_style_combo;
+    GtkWidget* tb_icon_size_combo;
+
     char* widget_theme;
     char* icon_theme;
     char* cursor_theme;
     char* color_scheme;
     char* icon_sizes;
     int toolbar_style;
-    int toolbar_size;
+    int toolbar_icon_size;
     gboolean changed;
     gboolean use_lxsession;
 };
diff --git a/src/other.c b/src/other.c
new file mode 100644 (file)
index 0000000..d94bec6
--- /dev/null
@@ -0,0 +1,50 @@
+//      other.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 "other.h"
+#include <glib/gi18n.h>
+
+static void on_tb_style_changed(GtkComboBox* combo, gpointer user_data)
+{
+    app.toolbar_style = gtk_combo_box_get_active(combo) + GTK_TOOLBAR_ICONS;
+    lxappearance_changed();
+}
+
+static void on_tb_icon_size_changed(GtkComboBox* combo, gpointer user_data)
+{
+    app.toolbar_icon_size = gtk_combo_box_get_active(combo) + GTK_ICON_SIZE_MENU;
+    lxappearance_changed();
+}
+
+void other_init(GtkBuilder* b)
+{
+    int idx;
+    app.tb_style_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_style"));
+    idx = app.toolbar_style - GTK_TOOLBAR_ICONS;
+    gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_style_combo), idx);
+    g_signal_connect(app.tb_style_combo, "changed", G_CALLBACK(on_tb_style_changed), NULL);
+
+    app.tb_icon_size_combo = GTK_WIDGET(gtk_builder_get_object(b, "tb_icon_size"));
+    idx = app.toolbar_icon_size - GTK_ICON_SIZE_MENU;
+    gtk_combo_box_set_active(GTK_COMBO_BOX(app.tb_icon_size_combo), idx);
+    g_signal_connect(app.tb_icon_size_combo, "changed", G_CALLBACK(on_tb_icon_size_changed), NULL);
+}
+
diff --git a/src/other.h b/src/other.h
new file mode 100644 (file)
index 0000000..be72511
--- /dev/null
@@ -0,0 +1,30 @@
+//      other.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 __OTHER_H__
+#define __OTHER_H__
+
+G_BEGIN_DECLS
+
+void other_init(GtkBuilder* b);
+
+G_END_DECLS
+
+#endif /* __OTHER_H__ */
index 75ed24b..bcc953a 100644 (file)
@@ -98,7 +98,12 @@ static void load_themes()
     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)
+    {
+        GtkTreePath* tp = gtk_tree_model_get_path(GTK_TREE_MODEL(app.widget_theme_store), &sel_it);
         gtk_tree_selection_select_iter(tree_sel, &sel_it);
+        gtk_tree_view_scroll_to_cell(app.widget_theme_view, tp, NULL, FALSE, 0, 0);
+        gtk_tree_path_free(tp);
+    }
 
     g_slist_free(themes);