Support setting gtk-button-images and gtk-menu-images properties.
authorHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Fri, 6 Aug 2010 07:00:18 +0000 (15:00 +0800)
committerHong Jen Yee (PCMan) <pcman.tw@gmail.com>
Fri, 6 Aug 2010 07:00:18 +0000 (15:00 +0800)
data/ui/lxappearance.glade
src/lxappearance2.c
src/lxappearance2.h
src/other.c

index 41b6103..de14584 100644 (file)
                         <property name="visible">True</property>
                         <property name="left_padding">12</property>
                         <child>
-                          <object class="GtkTable" id="table2">
+                          <object class="GtkVBox" id="vbox5">
                             <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>
+                            <property name="spacing">6</property>
                             <child>
-                              <object class="GtkLabel" id="label25">
+                              <object class="GtkTable" id="table2">
                                 <property name="visible">True</property>
-                                <property name="xalign">0</property>
-                                <property name="label" translatable="yes">Toolbar Icon Size: </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>
                               <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>
+                                <property name="position">0</property>
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkComboBox" id="tb_style">
+                              <object class="GtkCheckButton" id="button_images">
+                                <property name="label" translatable="yes">Show images on buttons</property>
                                 <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="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</property>
                               </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>
+                                <property name="position">1</property>
                               </packing>
                             </child>
                             <child>
-                              <object class="GtkComboBox" id="tb_icon_size">
+                              <object class="GtkCheckButton" id="menu_images">
+                                <property name="label" translatable="yes">Show images in menus</property>
                                 <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>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">False</property>
+                                <property name="draw_indicator">True</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>
-                                <property name="x_options">GTK_FILL</property>
-                                <property name="y_options">GTK_FILL</property>
+                                <property name="position">2</property>
                               </packing>
                             </child>
                           </object>
                     <child type="label">
                       <object class="GtkLabel" id="label19">
                         <property name="visible">True</property>
-                        <property name="label" translatable="yes">&lt;b&gt;Toolbar&lt;/b&gt;</property>
+                        <property name="label" translatable="yes">&lt;b&gt;GUI Options&lt;/b&gt;</property>
                         <property name="use_markup">True</property>
                       </object>
                     </child>
               </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>
               </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="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="-7">close</action-widget>
       <action-widget response="-10">apply</action-widget>
+      <action-widget response="-7">close</action-widget>
     </action-widgets>
   </object>
   <object class="GtkImage" id="image2">
index f036917..216436e 100644 (file)
@@ -154,6 +154,8 @@ static void lxappearance_save_gtkrc()
         "gtk-toolbar-icon-size=%s\n"
         "gtk-cursor-theme-name=\"%s\"\n"
         "gtk-cursor-theme-size=%d\n"
+        "gtk-button-images=%s\n"
+        "gtk-menu-images=%s\n"
 #if GTK_CHECK_VERSION(2, 14, 0)
         "gtk-enable-event-sounds=%s\n"
         "gtk-enable-input-feedback-sounds=%s\n",
@@ -165,6 +167,8 @@ static void lxappearance_save_gtkrc()
         tb_icon_sizes[app.toolbar_icon_size],
         app.cursor_theme,
         app.cursor_theme_size,
+        bool2str(app.button_images),
+        bool2str(app.menu_images),
 #if GTK_CHECK_VERSION(2, 14, 0)
         bool2str(app.enable_event_sound),
         bool2str(app.enable_input_feedback)
@@ -225,10 +229,13 @@ static void lxappearance_save_lxsession()
     g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarStyle", app.toolbar_style );
     g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarIconSize", app.toolbar_icon_size );
 
-#if GTK_CHECK_VERSION(2, 14, 0)
     g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarStyle", app.toolbar_style );
     g_key_file_set_integer( kf, "GTK", "iGtk/ToolbarIconSize", app.toolbar_icon_size );
 
+    g_key_file_set_integer( kf, "GTK", "iGtk/ButtonImages", app.button_images );
+    g_key_file_set_integer( kf, "GTK", "iGtk/MenuImages", app.menu_images );
+
+#if GTK_CHECK_VERSION(2, 14, 0)
     /* "Net/SoundThemeName\0"      "gtk-sound-theme-name\0" */
     g_key_file_set_integer( kf, "GTK", "iNet/EnableEventSounds", app.enable_event_sound);
     g_key_file_set_integer( kf, "GTK", "iNet/EnableInputFeedbackSounds", app.enable_input_feedback);
@@ -286,6 +293,8 @@ static void settings_init()
                 "gtk-cursor-theme-size", &app.cursor_theme_size,
                 "gtk-toolbar-style", &app.toolbar_style,
                 "gtk-toolbar-icon-size", &app.toolbar_icon_size,
+                "gtk-button-images", &app.button_images,
+                "gtk-menu-images", &app.menu_images,
 #if GTK_CHECK_VERSION(2, 14, 0)
                 "gtk-enable-event-sounds", &app.enable_event_sound,
                 "gtk-enable-input-feedback-sounds", &app.enable_input_feedback,
@@ -370,14 +379,20 @@ int main(int argc, char** argv)
     /* 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))
         return 1;
 
+    /* NOTE: GUI must be created prior to loading settings from GtkSettings object.
+     * Some properties of GtkSettings class are installed by some other gtk classes.
+     * For example, "gtk-menu-images" property is actually installed by initialization
+     * of GtkImageMenuItem class. If we load the GUI first, then when the menu items
+     * are created, this property gets correctly registered. So later it can be read. */
+
+    /* load config values */
+    settings_init();
+
     app.dlg = GTK_WIDGET(gtk_builder_get_object(b, "dlg"));
 
     widget_theme_init(b);
index 541b4b3..eb04256 100644 (file)
@@ -63,6 +63,9 @@ struct _LXAppearance
     GtkWidget* tb_style_combo;
     GtkWidget* tb_icon_size_combo;
 
+    GtkWidget* button_images_check;
+    GtkWidget* menu_images_check;
+
     char* widget_theme;
     char* default_font;
     char* icon_theme;
@@ -72,6 +75,9 @@ struct _LXAppearance
     int toolbar_style;
     int toolbar_icon_size;
 
+    gboolean button_images;
+    gboolean menu_images;
+
 #if GTK_CHECK_VERSION(2, 14, 0)
     GtkWidget* event_sound_check;
     GtkWidget* input_feedback_check;
index a7bd7eb..e9c15f9 100644 (file)
@@ -58,6 +58,14 @@ void other_init(GtkBuilder* b)
     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);
 
+    app.button_images_check = GTK_WIDGET(gtk_builder_get_object(b, "button_images"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.button_images_check), app.button_images);
+    g_signal_connect(app.button_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.button_images);
+
+    app.menu_images_check = GTK_WIDGET(gtk_builder_get_object(b, "menu_images"));
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.menu_images_check), app.menu_images);
+    g_signal_connect(app.menu_images_check, "toggled", G_CALLBACK(on_check_button_toggled), &app.menu_images);
+
 #if GTK_CHECK_VERSION(2, 14, 0)
     app.event_sound_check = GTK_WIDGET(gtk_builder_get_object(b, "event_sound"));
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(app.event_sound_check), app.enable_event_sound);