Commit 838aa6f1 authored by Sean Davis's avatar Sean Davis 🕶

Merge in GTK3 port. Special thanks to Simon for appearance fixes, widget...

Merge in GTK3 port. Special thanks to Simon for appearance fixes, widget cleanup, and suggestion of the WindowScalingFactor setting. Summary of changes:
- All components and glade files have been ported to GTK 3.20, all deprecated widgets and functions replaced
- Build requirements have been bumped to gtk+-3.0 3.20, glib-2.0 2.45, gio-2.0 2.45, gio-unix-2.0 2.45, exo-2 0.11.0, libxfce4ui-2 4.13.0, libxfce4kbd-private-3 4.12.0
- Added support for /Gdk/WindowScalingFactor

Squashed commit of the following:

commit 9d52b25530c7f88d86573c7e6cf0c8e938702107
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 22:34:10 2016 -0400

    Upgrade all glade files to gtk 3.20, replace deprecated widgets

commit 9ccbace18fc19f03c9cfd5959f8f48d6cb865ad0
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 20:46:27 2016 -0400

    Bump required versions to support GTK 3.20 and Xfce 4.13+

commit ca182a87113bf0e2720420ce99fc58cfe2dbe223
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 20:18:11 2016 -0400

    Fix drawing issues (again)

commit eb5b63cb505b5fd311a075410607c13a2b72645c
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 18:11:25 2016 -0400

    Current progress, runs, no display

commit 3d76c9fe59e70a207bf9ee76a35e9d48276494d6
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Wed Sep 14 23:31:35 2016 +0200

    Drop unused vars

commit fdf7cc3da5d889e590f76b6e3cb9b31f49e29056
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 06:27:11 2016 -0400

    Fix deprecations

commit 59b3ea798178240f13168cf4e10d56ff894a965b
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 06:11:53 2016 -0400

    Fix paint callback

commit 07753d65d89193149a0bf609ef50c0b6e405fca4
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 06:02:41 2016 -0400

    Replace expose event with draw

commit 559abb683b2dd6ad5df7b6bc398941aba12f7dd2
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Wed Sep 14 05:56:00 2016 -0400

    Discard IFDEFs

commit 8d1d5af66c9df099c952015fa050f90c8488b169
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Wed Sep 14 11:20:27 2016 +0200

    Fix background color of scrollarea

commit c1048c7a0eea7d58b511d3ca4ad37970fd04a416
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue Sep 13 22:52:21 2016 -0400

    Replace string

commit 6fd34046d40315839b65bbb82e6a79b90cb49630
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue Sep 13 22:48:17 2016 -0400

    Support Gdk WindowScalingFactor

commit 9df1063fee837128fe78070900d19544a20b6f17
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue Sep 13 22:03:10 2016 -0400

    Import latest foo-marshall and scrollarea from mate, builds with --disable-debug

commit 2bb20c12fcd36e3e567a28f338423556f730316a
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat Sep 3 06:13:55 2016 -0400

    Drop definition of xfce_widget_reparent, bump required libxfce4ui version to 4.13.0 which now provides it

commit 03b2bf87e7702f9c89760417d27c8c86a199b1c7
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sun Aug 21 21:35:14 2016 -0400

    Partially port display settings

commit 1316fb377b3fa2c5b42060981385c1909c634a16
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Mon Aug 8 00:22:33 2016 +0200

    Drop all deprecated widgets from the a11y settings dialog

commit 8b36f4ce5c834eed09b7e18ed7235e58e4311e64
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Mon Aug 8 00:02:22 2016 +0200

    Drop all deprecated widgets from the mouse settings dialog

commit c5d40bf125b0a05ec4c2fad2c03bfdbf78ac3443
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Sun Aug 7 23:48:27 2016 +0200

    Drop all deprecated widgets from the keyboard settings dialog

commit f017811a1e25722e8e7233a2f323c0e342973710
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Sun Aug 7 23:40:50 2016 +0200

    Drop all deprecated widgets from the appearance settings dialog

commit a90e9c10848dc81da234b424b121b6b4af30ef8d
Author: Simon Steinbeiss <simon.steinbeiss@elfenbeinturm.at>
Date:   Sun Aug 7 23:15:09 2016 +0200

    Fix background styles of header and viewport in manager

commit 02097c9c1052f4639e79488113b73eeb496bd7c7
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat Jun 18 14:17:29 2016 -0400

    Use text renderer to fix display issue

commit 9fff5000548ed99a4bf65f9862e50bd201552c0f
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat Jun 18 12:54:36 2016 -0400

    Initial broken port of the settings manager

commit 7f98f7d11624dac51dcc2e67e2d744ba36b40b3f
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sun Jun 5 18:42:10 2016 -0400

    Mostly fix colors, selected color is still broken for some themes

commit 298974550d7ee2164fe0d1b5db3fec8b4b05de5b
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sun Jun 5 14:01:42 2016 -0400

    Port appearance settings. FIXME: showcase colors are always black

commit 3487e364d7a2340924ffe25dcda212cdcf0ae1e5
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sun Jun 5 08:25:35 2016 -0400

    Port xfce4-settings-editor

commit 95f86ffe126b8110d0fcf6c4a349a3b6e4bd2d61
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue May 31 21:50:47 2016 -0400

    Port xfsettingsd to gtk3

commit 8beea08b96fbfad32c9e6aa8fbc0068e656c6164
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue May 31 21:09:39 2016 -0400

    Port xfce4-mouse-settings to gtk3

commit c2db3c3a1c448339424077ab1a2168643c77c385
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Tue May 31 20:48:38 2016 -0400

    Port xfce4-keyboard-settings to gtk3

commit 3648eece22e403daf4710f24f4b3f00437a4adc9
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat May 21 09:44:56 2016 -0400

    Drop unused libxfce4util references in the keyboard settings

commit 11d60fde191cfd0b8704dd7baa181b8ea8273747
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat May 21 09:18:26 2016 -0400

    Port xfce4-accessibility-settings (plug functionality untested)

commit 4e9fac5214f30584e770e02b04fa22c5f59bbc3a
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Sat May 21 08:17:13 2016 -0400

    Complete port of xfce4-mime-settings

commit 859d8a62fa330bc9f3c95c2d0964352bfa346541
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Thu May 19 22:19:50 2016 -0400

    Partially ported xfce4-mime-settings, does not build

commit 4ac0151520eed29b2d3bf5f8bffe4602b1bc0d66
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Thu May 19 21:18:39 2016 -0400

    Further seal and replace deprecations, should now be ready to port

commit ba64a334c90a1caf5562233d22df67bdc1bfca24
Author: Sean Davis <smd.seandavis@gmail.com>
Date:   Thu May 19 20:39:13 2016 -0400

    Build with GTK_DISABLE_SINGLE_INCLUDES, GDK_DISABLE_DEPRECATED, GTK_DISABLE_DEPRECATED, GSEAL_ENABLE where possible
parent bbeb457e
......@@ -88,14 +88,14 @@ AC_DEFINE([XFCE4_SETTINGS_VERSION_SHORT], [xfce4_settings_version_short], [Short
dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([EXO], [exo-1], [0.7.1])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.20.0])
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.24.0])
XDT_CHECK_PACKAGE([EXO], [exo-2], [0.11.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.20.0])
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.45.8])
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.45.8])
XDT_CHECK_PACKAGE([GARCON], [garcon-1], [0.1.10])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.9.0])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.11.0])
XDT_CHECK_PACKAGE([LIBXFCE4KBD_PRIVATE], [libxfce4kbd-private-2], [4.9.0])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.13.0])
XDT_CHECK_PACKAGE([LIBXFCE4KBD_PRIVATE], [libxfce4kbd-private-3], [4.12.0])
XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.9.0])
XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
XDT_CHECK_PACKAGE([FONTCONFIG], [fontconfig], [2.6.0])
......@@ -162,7 +162,7 @@ XDT_CHECK_OPTIONAL_PACKAGE([LIBNOTIFY], [libnotify], [0.1.3],
dnl *********************
dnl *** Mime settings ***
dnl *********************
XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0], [2.24],
XDT_CHECK_OPTIONAL_PACKAGE([GIO_UNIX], [gio-unix-2.0], [2.45],
[gio-unix], [Mime settings])
dnl ************************************
......@@ -317,5 +317,3 @@ else
echo "* Mime settings (gio-unix): no"
fi
echo
......@@ -17,7 +17,13 @@ xfce4_accessibility_settings_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(XFCONF_CFLAGS) \
$(PLATFORM_CFLAGS)
$(PLATFORM_CFLAGS) \
-DGTK_DISABLE_SINGLE_INCLUDES \
-DGDK_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
-DGSEAL_ENABLE \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
-DG_DISABLE_DEPRECATED
xfce4_accessibility_settings_LDFLAGS = \
-no-undefined \
......
......@@ -27,6 +27,9 @@
#include <glib.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <gdk/gdkx.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4util/libxfce4util.h>
......@@ -36,7 +39,7 @@
static GdkNativeWindow opt_socket_id = 0;
static gint opt_socket_id = 0;
static gboolean opt_version = FALSE;
static GOptionEntry entries[] =
{
......@@ -137,9 +140,10 @@ accessibility_settings_dialog_configure_widgets (GtkBuilder *builder)
/* Mouse keys */
object = gtk_builder_get_object (builder, "mouse-emulation-enabled");
box = gtk_builder_get_object (builder, "mouse-emulation-box");
box = gtk_builder_get_object (builder, "mouse-emulation-grid");
g_signal_connect (object, "toggled", G_CALLBACK (accessibility_settings_sensitivity), box);
xfconf_g_property_bind (accessibility_channel, "/MouseKeys", G_TYPE_BOOLEAN, object, "active");
gtk_widget_set_sensitive (GTK_WIDGET(box), xfconf_channel_get_bool(accessibility_channel, "/MouseKeys", TRUE));
object = gtk_builder_get_object (builder, "mouse-emulation-delay");
xfconf_g_property_bind (accessibility_channel, "/MouseKeys/Delay", G_TYPE_INT, object, "value");
......@@ -252,7 +256,7 @@ main (gint argc, gchar **argv)
gtk_window_present (GTK_WINDOW (dialog));
/* To prevent the settings dialog to be saved in the session */
gdk_set_sm_client_id ("FAKE ID");
gdk_x11_set_sm_client_id ("FAKE ID");
gtk_main ();
}
......@@ -268,11 +272,11 @@ main (gint argc, gchar **argv)
/* Get plug child widget */
plug_child = gtk_builder_get_object (builder, "plug-child");
gtk_widget_reparent (GTK_WIDGET (plug_child), plug);
xfce_widget_reparent (GTK_WIDGET (plug_child), plug);
gtk_widget_show (GTK_WIDGET (plug_child));
/* To prevent the settings dialog to be saved in the session */
gdk_set_sm_client_id ("FAKE ID");
gdk_x11_set_sm_client_id ("FAKE ID");
/* Enter main loop */
gtk_main ();
......
......@@ -19,7 +19,13 @@ xfce4_appearance_settings_CFLAGS = \
$(GTK_CFLAGS) \
$(LIBXFCE4UI_CFLAGS) \
$(XFCONF_CFLAGS) \
$(PLATFORM_CFLAGS)
$(PLATFORM_CFLAGS) \
-DGTK_DISABLE_SINGLE_INCLUDES \
-DGDK_DISABLE_DEPRECATED \
-DGTK_DISABLE_DEPRECATED \
-DGSEAL_ENABLE \
-DGDK_PIXBUF_DISABLE_DEPRECATED \
-DG_DISABLE_DEPRECATED
xfce4_appearance_settings_LDFLAGS = \
-no-undefined \
......
......@@ -36,6 +36,9 @@
#include <glib/gstdio.h>
#include <fcntl.h>
#include <gtk/gtk.h>
#include <gtk/gtkx.h>
#include <gdk/gdkx.h>
#include <libxfce4ui/libxfce4ui.h>
#include <libxfce4util/libxfce4util.h>
......@@ -59,9 +62,8 @@
#define GTK_RC_TOKEN_NORMAL ((gpointer) 4)
#define GTK_RC_TOKEN_SELECTED ((gpointer) 5)
gchar *gtkrc_get_color_scheme_for_theme (const gchar *gtkrc_filename);
gboolean color_scheme_parse_colors (const gchar *scheme, GdkColor *colors);
static GdkPixbuf *theme_create_preview (GdkColor *colors);
gboolean gtkcss_get_color_scheme_for_theme (const gchar *gtkcss_filename, GdkRGBA **colors);
static GdkPixbuf *theme_create_preview (GdkRGBA **colors);
enum
{
......@@ -109,7 +111,7 @@ static const GtkTargetEntry theme_drop_targets[] =
};
/* Option entries */
static GdkNativeWindow opt_socket_id = 0;
static gint opt_socket_id = 0;
static gboolean opt_version = FALSE;
static GOptionEntry option_entries[] =
{
......@@ -185,304 +187,91 @@ compute_xsettings_dpi (GtkWidget *widget)
return dpi;
}
/* Try to retrieve the color scheme and alternatively parse the colors from the gtkrc */
gchar *
gtkrc_get_color_scheme_for_theme (const gchar *gtkrc_filename)
{
gint file = -1;
GString *result_string = g_string_new("");
GString *fallback_string = g_string_new("");
GString *tmp_string = g_string_new("");
gchar *result = NULL;
gboolean bg_normal = FALSE;
gboolean bg_selected = FALSE;
gboolean fg_normal = FALSE;
GSList *files = NULL;
GSList *read_files = NULL;
GTokenType token;
GScanner *scanner = gtk_rc_scanner_new ();
g_return_val_if_fail (gtkrc_filename != NULL, "");
g_scanner_scope_add_symbol (scanner, 0, "gtk_color_scheme", COLOR_SCHEME_SYMBOL);
g_scanner_scope_add_symbol (scanner, 0, "gtk-color-scheme", COLOR_SCHEME_SYMBOL);
g_scanner_scope_add_symbol (scanner, 0, "fg", GTK_RC_TOKEN_FG);
g_scanner_scope_add_symbol (scanner, 0, "bg", GTK_RC_TOKEN_BG);
g_scanner_scope_add_symbol (scanner, 0, "NORMAL", GTK_RC_TOKEN_NORMAL);
g_scanner_scope_add_symbol (scanner, 0, "SELECTED", GTK_RC_TOKEN_SELECTED);
files = g_slist_prepend (files, g_strdup (gtkrc_filename));
while (files != NULL)
{
gchar *filename = files->data;
files = g_slist_delete_link (files, files);
if (filename == NULL)
continue;
if (g_slist_find_custom (read_files, filename, (GCompareFunc) strcmp))
{
g_warning ("Recursion in the gtkrc detected!");
g_free (filename);
continue; /* skip this file since we've done it before... */
}
read_files = g_slist_prepend (read_files, filename);
file = g_open (filename, O_RDONLY);
if (file == -1)
g_warning ("Could not open file \"%s\"", filename);
else
{
g_scanner_input_file (scanner, file);
while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF)
{
/* Scan the gtkrc file for the gtk-color-scheme */
if (GINT_TO_POINTER (token) == COLOR_SCHEME_SYMBOL)
{
if (g_scanner_get_next_token (scanner) == '=')
{
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_STRING)
{
g_string_append_printf(result_string, "\n%s", scanner->value.v_string);
}
bg_normal = g_strstr_len(result_string->str, -1, "bg_color") != NULL;
bg_selected = g_strstr_len(result_string->str, -1, "selected_bg_color") != NULL;
fg_normal = g_strstr_len(result_string->str, -1, "fg_color") != NULL;
}
}
/* Scan the gtkrc file for first occurences of bg[NORMAL], bg[SELECTED] and fg[NORMAL] in case
* it doesn't provide a gtk-color-scheme */
if (result_string->len == 0)
{
if (GINT_TO_POINTER (token) == GTK_RC_TOKEN_BG)
{
if (g_scanner_get_next_token (scanner) == G_TOKEN_LEFT_BRACE)
{
/* bg[SELECTED] */
if (GINT_TO_POINTER (token = g_scanner_get_next_token (scanner)) == GTK_RC_TOKEN_SELECTED
&& g_scanner_get_next_token (scanner) == G_TOKEN_RIGHT_BRACE
&& g_scanner_get_next_token (scanner) == '=')
{
token = g_scanner_get_next_token (scanner);
/* Parse colors in hex #rrggbb format */
if (token == G_TOKEN_STRING)
{
if (!g_strrstr (fallback_string->str, "selected_bg_color"))
{
g_string_append_printf(fallback_string, "\nselected_bg_color:%s", scanner->value.v_string);
bg_selected = TRUE;
}
}
/* Parse colors in { r, g, b } format */
else if (token == G_TOKEN_LEFT_CURLY)
{
if (!g_strrstr (fallback_string->str, "selected_bg_color"))
{
g_string_erase(tmp_string, 0, -1);
while (token != G_TOKEN_RIGHT_CURLY)
{
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_FLOAT)
g_string_append_printf(tmp_string, "%02x", (uint) (scanner->value.v_float*255));
}
g_string_append_printf(fallback_string, "\nselected_bg_color:#%s", tmp_string->str);
bg_selected = TRUE;
}
}
}
/* bg[NORMAL] */
else if (GINT_TO_POINTER (token) == GTK_RC_TOKEN_NORMAL
&& g_scanner_get_next_token (scanner) == G_TOKEN_RIGHT_BRACE
&& g_scanner_get_next_token (scanner) == '=')
{
token = g_scanner_get_next_token (scanner);
/* Parse colors in hex #rrggbb format */
if (token == G_TOKEN_STRING)
{
if (!g_strrstr (fallback_string->str, "bg_color"))
{
g_string_append_printf(fallback_string, "\nbg_color:%s", scanner->value.v_string);
bg_normal = TRUE;
}
}
/* Parse colors in { r, g, b } format */
else if (token == G_TOKEN_LEFT_CURLY)
{
if (!g_strrstr (fallback_string->str, "bg_color"))
{
g_string_erase(tmp_string, 0, -1);
while (token != G_TOKEN_RIGHT_CURLY)
{
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_FLOAT)
g_string_append_printf(tmp_string, "%02x", (uint) (scanner->value.v_float*255));
}
g_string_append_printf(fallback_string, "\nbg_color:#%s", tmp_string->str);
bg_normal = TRUE;
}
}
}
}
}
else if (GINT_TO_POINTER (token) == GTK_RC_TOKEN_FG)
{
/* fg[NORMAL] */
if (g_scanner_get_next_token (scanner) == G_TOKEN_LEFT_BRACE
&& GINT_TO_POINTER (token = g_scanner_get_next_token (scanner)) == GTK_RC_TOKEN_NORMAL
&& g_scanner_get_next_token (scanner) == G_TOKEN_RIGHT_BRACE
&& g_scanner_get_next_token (scanner) == '=')
{
token = g_scanner_get_next_token (scanner);
/* Parse colors in hex #rrggbb format */
if (token == G_TOKEN_STRING)
{
if (!g_strrstr (fallback_string->str, "fg_color"))
{
g_string_append_printf(fallback_string, "\nfg_color:%s", scanner->value.v_string);
fg_normal = TRUE;
}
}
/* Parse colors in { r, g, b } format */
else if (token == G_TOKEN_LEFT_CURLY)
{
if (!g_strrstr (fallback_string->str, "fg_color"))
{
g_string_erase(tmp_string, 0, -1);
while (token != G_TOKEN_RIGHT_CURLY)
{
token = g_scanner_get_next_token (scanner);
if (token == G_TOKEN_FLOAT)
g_string_append_printf(tmp_string, "%02x", (uint) (scanner->value.v_float*255));
}
g_string_append_printf(fallback_string, "\nfg_color:#%s", tmp_string->str);
fg_normal = TRUE;
}
}
}
}
}
/* Check whether we can stop parsing because all colors have been retrieved somehow */
if (bg_normal && bg_selected && fg_normal)
break;
}
close (file);
}
}
g_slist_foreach (read_files, (GFunc) g_free, NULL);
g_slist_free (read_files);
g_scanner_destroy (scanner);
/* Use the fallback colors parsed from the theme if gtk-color-scheme is not defined */
/*
if (!result)
result = fallback;
*/
if (result_string->len == 0)
result = g_strdup(fallback_string->str);
else
result = g_strdup(result_string->str);
g_string_free(result_string, TRUE);
g_string_free(fallback_string, TRUE);
g_string_free(tmp_string, TRUE);
return result;
}
gboolean
color_scheme_parse_colors (const gchar *scheme, GdkColor *colors)
gtkcss_get_color_scheme_for_theme (const gchar *gtkcss_filename,
GdkRGBA **colors)
{
gchar **color_scheme_strings, **color_scheme_pair, *current_string;
gboolean found = FALSE;
gint i;
if (!scheme || !strcmp (scheme, ""))
return FALSE;
/* Initialise the array, fallback color is white */
for (i = 0; i < NUM_SYMBOLIC_COLORS; i++)
colors[i].red = colors[i].green = colors[i].blue = 65535.0;
/* The color scheme string consists of name:color pairs, separated by
* either semicolons or newlines, so first we split the string up by delimiter */
if (g_strrstr (scheme, ";"))
color_scheme_strings = g_strsplit (scheme, ";", 0);
else
color_scheme_strings = g_strsplit (scheme, "\n", 0);
/* Loop through the name:color pairs, and save the color if we recognise the name */
i = 0;
while ((current_string = color_scheme_strings[i++]))
{
color_scheme_pair = g_strsplit (current_string, ":", 0);
if (color_scheme_pair[0] != NULL && color_scheme_pair[1] != NULL)
{
g_strstrip (color_scheme_pair[0]);
g_strstrip (color_scheme_pair[1]);
if (!strcmp ("fg_color", color_scheme_pair[0]))
{
gdk_color_parse (color_scheme_pair[1], &colors[COLOR_FG]);
found = TRUE;
}
else if (!strcmp ("bg_color", color_scheme_pair[0]))
{
gdk_color_parse (color_scheme_pair[1], &colors[COLOR_BG]);
found = TRUE;
}
else if (!strcmp ("selected_bg_color", color_scheme_pair[0]))
{
gdk_color_parse (color_scheme_pair[1], &colors[COLOR_SELECTED_BG]);
found = TRUE;
}
}
g_strfreev (color_scheme_pair);
}
g_strfreev (color_scheme_strings);
return found;
GdkRGBA *bgn, *bgs, *fgn;
GtkCssProvider *provider;
GtkWidget *window, *icon_view;
GtkStyleContext *window_ctx, *icon_view_ctx;
g_return_val_if_fail (gtkcss_filename != NULL, FALSE);
provider = gtk_css_provider_new();
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
icon_view = gtk_icon_view_new();
gtk_container_add (GTK_CONTAINER(window), icon_view);
window_ctx = gtk_widget_get_style_context(window);
icon_view_ctx = gtk_widget_get_style_context(icon_view);
gtk_css_provider_load_from_path (provider,
gtkcss_filename,
NULL);
gtk_style_context_add_provider(window_ctx,
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_style_context_add_provider(icon_view_ctx,
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_style_context_get (window_ctx,
GTK_STATE_FLAG_NORMAL,
"background-color", &bgn,
NULL);
gtk_style_context_get (icon_view_ctx,
GTK_STATE_FLAG_SELECTED,
"background-color", &bgs,
NULL);
gtk_style_context_get (window_ctx,
GTK_STATE_FLAG_NORMAL,
"color", &fgn,
NULL);
colors[COLOR_BG] = bgn;
colors[COLOR_SELECTED_BG] = bgs;
colors[COLOR_FG] = fgn;
gtk_widget_destroy(window);
return TRUE;
}
static GdkPixbuf *
theme_create_preview (GdkColor *colors)
theme_create_preview (GdkRGBA **colors)
{
GdkPixbuf *theme_preview;
GdkPixmap *drawable;
GdkColormap *cmap = gdk_colormap_get_system ();
cairo_surface_t *s;
cairo_t *cr;
gint width = 44;
gint height = 22;
drawable = gdk_pixmap_new (gdk_get_default_root_window(), width, height,
gdk_drawable_get_depth (gdk_get_default_root_window ()));
cr = gdk_cairo_create (drawable);
s = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
cr = cairo_create (s);
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
/* Draw three rectangles showcasing the background, foreground and selected background colors */
/* FIXME - Colors always appear solid black */
cairo_rectangle (cr, 0, 0, 16, 22);
cairo_set_source_rgb (cr, colors[COLOR_BG].red / 65535.0, colors[COLOR_BG].green / 65535.0, colors[COLOR_BG].blue / 65535.0);
cairo_set_source_rgb (cr, colors[COLOR_BG]->red, colors[COLOR_BG]->green, colors[COLOR_BG]->blue);
cairo_fill (cr);
cairo_rectangle (cr, 15, 0, 30, 22);
cairo_set_source_rgb (cr, colors[COLOR_FG].red / 65535.0, colors[COLOR_FG].green / 65535.0, colors[COLOR_FG].blue / 65535.0);
cairo_set_source_rgb (cr, colors[COLOR_FG]->red, colors[COLOR_FG]->green, colors[COLOR_FG]->blue);
cairo_fill (cr);
cairo_rectangle (cr, 29, 0, 42, 22);
cairo_set_source_rgb (cr, colors[COLOR_SELECTED_BG].red / 65535.0, colors[COLOR_SELECTED_BG].green / 65535.0, colors[COLOR_SELECTED_BG].blue / 65535.0);
cairo_set_source_rgb (cr, colors[COLOR_SELECTED_BG]->red, colors[COLOR_SELECTED_BG]->green, colors[COLOR_SELECTED_BG]->blue);
cairo_fill (cr);
theme_preview = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
gdk_pixbuf_get_from_drawable (theme_preview, drawable, cmap, 0, 0, 0, 0, width, height);
theme_preview = gdk_pixbuf_get_from_surface (s, 0, 0, width, height);
g_object_unref (drawable);
cairo_destroy (cr);
cairo_surface_destroy (s);
return theme_preview;
}
......@@ -537,6 +326,18 @@ cb_toolbar_style_combo_changed (GtkComboBox *combo)
xfconf_channel_set_string (xsettings_channel, "/Gtk/ToolbarStyle", toolbar_styles_array[active]);
}
static void
cb_window_scaling_factor_combo_changed (GtkComboBox *combo)
{
gint active;
/* Get active item, prevent number outside the array (stay within zero-index) */
active = CLAMP (gtk_combo_box_get_active (combo) + 1, 1, 2);
/* Save setting */
xfconf_channel_set_int (xsettings_channel, "/Gdk/WindowScalingFactor", active);
}
static void
cb_antialias_check_button_toggled (GtkToggleButton *toggle)
{
......@@ -619,7 +420,7 @@ cb_custom_dpi_spin_button_changed (GtkSpinButton *custom_dpi_spin,
{
gint dpi = gtk_spin_button_get_value_as_int (custom_dpi_spin);
if (GTK_WIDGET_IS_SENSITIVE (custom_dpi_spin) && gtk_toggle_button_get_active (custom_dpi_toggle))
if (gtk_widget_is_sensitive (GTK_WIDGET(custom_dpi_spin)) && gtk_toggle_button_get_active (custom_dpi_toggle))
{
/* Custom DPI is turned on and the spin button has changed, so remember the value */
xfconf_channel_set_int (xsettings_channel, "/Xfce/LastCustomDPI", dpi);
......@@ -829,12 +630,13 @@ appearance_settings_load_ui_themes (preview_data *pd)
const gchar *theme_comment;
gchar *active_theme_name;
gchar *gtkrc_filename;
gchar *gtkcss_filename;
gchar *comment_escaped;
gint i;
GSList *check_list = NULL;
gchar *color_scheme = NULL;
GdkPixbuf *preview;
GdkColor colors[NUM_SYMBOLIC_COLORS];
GdkRGBA *colors[NUM_SYMBOLIC_COLORS];
g_return_val_if_fail (pd != NULL, FALSE);
......@@ -864,6 +666,7 @@ appearance_settings_load_ui_themes (preview_data *pd)
{
/* Build the theme style filename */
gtkrc_filename = g_build_filename (ui_theme_dirs[i], file, "gtk-2.0", "gtkrc", NULL);
gtkcss_filename = g_build_filename (ui_theme_dirs[i], file, "gtk-3.0", "gtk.css", NULL);
/* Check if the gtkrc file exists and the theme is not already in the list */
if (g_file_test (gtkrc_filename, G_FILE_TEST_EXISTS)
......@@ -895,9 +698,10 @@ appearance_settings_load_ui_themes (preview_data *pd)
}
/* Retrieve the color values from the theme, parse them and create the palette preview pixbuf */
color_scheme = gtkrc_get_color_scheme_for_theme (gtkrc_filename);
if (color_scheme_parse_colors (color_scheme, colors))
if (g_file_test (gtkcss_filename, G_FILE_TEST_EXISTS) && gtkcss_get_color_scheme_for_theme (gtkcss_filename, colors))
{
preview = theme_create_preview (colors);
}
/* If the color scheme parsing doesn't return anything useful, show a blank pixbuf */
else
{
......@@ -935,6 +739,7 @@ appearance_settings_load_ui_themes (preview_data *pd)
/* Free gtkrc filename */
g_free (gtkrc_filename);
g_free (gtkcss_filename);
}
/* Close directory handle */
......@@ -1000,6 +805,12 @@ appearance_settings_dialog_channel_property_changed (XfconfChannel *channel,
}
g_free (str);
}
else if (strcmp (property_name, "/Gdk/WindowScalingFactor") == 0)
{
i = xfconf_channel_get_int (xsettings_channel, property_name, 1);
object = gtk_builder_get_object (builder, "gdk_window_scaling_factor_combo_box");
gtk_combo_box_set_active (GTK_COMBO_BOX (object), i - 1);
}
else if (strcmp (property_name, "/Xft/HintStyle") == 0)
{
str = xfconf_channel_get_string (xsettings_channel, property_name, xft_hint_styles_array[0]);
......@@ -1236,7 +1047,7 @@ cb_theme_uri_dropped (GtkWidget *widget,
g_strfreev (uris);
gdk_window_set_cursor (gdkwindow, NULL);
gdk_cursor_unref (cursor);
g_object_unref (cursor);
if (something_installed)
{
......@@ -1281,7 +1092,6 @@ appearance_settings_dialog_configure_widgets (GtkBuilder *builder)
gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (list_store), COLUMN_THEME_DISPLAY_NAME, GTK_SORT_ASCENDING);