Disable setting of custom colors if run without lxsession.
authorAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 12 Sep 2014 21:49:39 +0000 (00:49 +0300)
committerAndriy Grytsenko <andrej@rep.kiev.ua>
Fri, 12 Sep 2014 21:49:39 +0000 (00:49 +0300)
Unfortunately colors setting will not work without XSETTINGS daemon because
any custom settings in .gtkrc-2.0 file will be overridden by the theme.

Therefore we should not use ~/.gtkrc-2.0 to save gtk-color-scheme because
it is useless, and disable setting of custom colors without lxsession.

TODO: detect other XSETTINGS daemons and use them for color changes.

po/POTFILES.in
po/POTFILES.skip
po/lxappearance.pot
src/color-scheme.c
src/lxappearance.c

index 42a670c..3d11d02 100644 (file)
@@ -4,3 +4,4 @@ data/lxappearance.desktop.in
 [type: gettext/glade]data/ui/about.ui.in
 [type: gettext/glade]data/ui/lxappearance.ui
 src/utils.c
 [type: gettext/glade]data/ui/about.ui.in
 [type: gettext/glade]data/ui/lxappearance.ui
 src/utils.c
+src/color-scheme.c
index 9686cfe..60792fc 100644 (file)
@@ -1 +1,2 @@
 # List of source files which should be skipped during translation
 # List of source files which should be skipped during translation
+data/ui/about.ui
index 7afedb2..fc02be3 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2013-12-30 11:30+0100\n"
+"POT-Creation-Date: 2014-09-13 00:46+0300\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -316,3 +316,8 @@ msgstr ""
 #: ../src/utils.c:224
 msgid "*.tar.gz, *.tar.bz2 (Icon Theme)"
 msgstr ""
 #: ../src/utils.c:224
 msgid "*.tar.gz, *.tar.bz2 (Icon Theme)"
 msgstr ""
+
+#: ../src/color-scheme.c:299
+msgid ""
+"Setting color scheme is not available without lxsession as session manager."
+msgstr ""
index 7a3a19c..9901643 100644 (file)
@@ -20,6 +20,7 @@
 #include "lxappearance.h"
 #include "color-scheme.h"
 #include <string.h>
 #include "lxappearance.h"
 #include "color-scheme.h"
 #include <string.h>
+#include <glib/gi18n.h>
 
 static GRegex* gtkrc_include_reg = NULL;
 static GRegex* gtkrc_color_scheme_reg = NULL;
 
 static GRegex* gtkrc_include_reg = NULL;
 static GRegex* gtkrc_color_scheme_reg = NULL;
@@ -271,7 +272,10 @@ void color_scheme_update()
     else
         app.color_scheme_supported = FALSE;
 
     else
         app.color_scheme_supported = FALSE;
 
-    if(app.color_scheme_supported)
+    /* unfortunately we cannot set colors without XSETTINGS daemon,
+       themes will override any custom settings in .gtkrc-2.0 file */
+    /* FIXME: we should support other xsettings daemons too */
+    if(app.color_scheme_supported && app.use_lxsession)
     {
         gtk_widget_set_sensitive(app.custom_colors, TRUE);
         gtk_widget_set_sensitive(app.color_table, app.color_scheme != NULL);
     {
         gtk_widget_set_sensitive(app.custom_colors, TRUE);
         gtk_widget_set_sensitive(app.color_table, app.color_scheme != NULL);
@@ -290,7 +294,14 @@ void color_scheme_update()
     {
         gtk_widget_set_sensitive(app.color_table, FALSE);
         gtk_widget_set_sensitive(app.custom_colors, FALSE);
     {
         gtk_widget_set_sensitive(app.color_table, FALSE);
         gtk_widget_set_sensitive(app.custom_colors, FALSE);
+        if (app.color_scheme_supported)
+            gtk_label_set_text(GTK_LABEL(app.no_custom_colors),
+                               _("Setting color scheme is not available without lxsession as session manager."));
+        else
+            gtk_label_set_text(GTK_LABEL(app.no_custom_colors),
+                               _("Color scheme is not supported by currently selected widget theme."));
         gtk_widget_show(app.no_custom_colors);
         gtk_widget_show(app.no_custom_colors);
+        app.color_scheme_supported = FALSE;
     }
     /* set the color to buttons */
     update_color_buttons();
     }
     /* set the color to buttons */
     update_color_buttons();
index a64045a..272b23d 100644 (file)
@@ -248,6 +248,10 @@ static void lxappearance_save_gtkrc()
         g_string_append_printf(content,
             "gtk-xft-rgba=\"%s\"\n", app.font_rgba);
 
         g_string_append_printf(content,
             "gtk-xft-rgba=\"%s\"\n", app.font_rgba);
 
+#if 0
+    /* unfortunately we cannot set colors without XSETTINGS daemon,
+       themes will override any custom settings in .gtkrc-2.0 file */
+    /* FIXME: we should support other xsettings daemons too */
     if(app.color_scheme)
     {
         char* escaped = g_strescape(app.color_scheme, NULL);
     if(app.color_scheme)
     {
         char* escaped = g_strescape(app.color_scheme, NULL);
@@ -256,6 +260,7 @@ static void lxappearance_save_gtkrc()
             escaped);
         g_free(escaped);
     }
             escaped);
         g_free(escaped);
     }
+#endif
 
     g_string_append_printf(content,
         "include \"%s/.gtkrc-2.0.mine\"\n",
 
     g_string_append_printf(content,
         "include \"%s/.gtkrc-2.0.mine\"\n",
@@ -326,6 +331,10 @@ static void lxappearance_save_gtkrc()
         g_string_append_printf(content_gtk3,
             "gtk-xft-rgba=%s\n", app.font_rgba);
 
         g_string_append_printf(content_gtk3,
             "gtk-xft-rgba=%s\n", app.font_rgba);
 
+#if 0
+    /* unfortunately we cannot set colors without XSETTINGS daemon,
+       themes will override any custom settings in .gtkrc-2.0 file */
+    /* FIXME: we should support other xsettings daemons too */
     if(app.color_scheme)
     {
         char* escaped = g_strescape(app.color_scheme, NULL);
     if(app.color_scheme)
     {
         char* escaped = g_strescape(app.color_scheme, NULL);
@@ -334,6 +343,7 @@ static void lxappearance_save_gtkrc()
             escaped);
         g_free(escaped);
     }
             escaped);
         g_free(escaped);
     }
+#endif
 
     g_file_set_contents(file_path_settings, content_gtk3->str, content_gtk3->len, NULL);
 
 
     g_file_set_contents(file_path_settings, content_gtk3->str, content_gtk3->len, NULL);
 
@@ -505,6 +515,10 @@ static void settings_init()
             }
         }
     }
             }
         }
     }
+#if 0
+    /* unfortunately we cannot set colors without XSETTINGS daemon,
+       themes will override any custom settings in .gtkrc-2.0 file */
+    /* FIXME: we should support other xsettings daemons too */
     else
     {
         char* gtkrc_file = g_build_filename(g_get_home_dir(), ".gtkrc-2.0", NULL);
     else
     {
         char* gtkrc_file = g_build_filename(g_get_home_dir(), ".gtkrc-2.0", NULL);
@@ -513,6 +527,7 @@ static void settings_init()
         if(g_hash_table_size(app.color_scheme_hash) > 0)
             app.color_scheme = color_scheme_hash_to_str(app.color_scheme_hash);
     }
         if(g_hash_table_size(app.color_scheme_hash) > 0)
             app.color_scheme = color_scheme_hash_to_str(app.color_scheme_hash);
     }
+#endif
 }
 
 int main(int argc, char** argv)
 }
 
 int main(int argc, char** argv)