Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set some settings in GSettings as well #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions data/ui/lxappearance.glade
Original file line number Diff line number Diff line change
Expand Up @@ -2125,24 +2125,12 @@
<column type="gchararray"/>
</columns>
<data>
<row>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean those extra choices should not be used or cannot be used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not in the old config file, can not in the new GSettings.

<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">
Expand Down
94 changes: 94 additions & 0 deletions src/lxappearance.c
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,97 @@ static void lxappearance_save_gtkrc()
g_free(file_path);
}

#if GLIB_CHECK_VERSION(2, 40, 0)
static void lxappearance_save_gsettings()
{
GSettingsSchemaSource *source = g_settings_schema_source_get_default();
if (!source)
return;

GSettingsSchema *schema = g_settings_schema_source_lookup(source, "org.gnome.desktop.interface", TRUE);
if (!schema)
return;

GSettings *settings = g_settings_new("org.gnome.desktop.interface");

if (app.widget_theme && g_settings_schema_has_key(schema, "gtk-theme"))
g_settings_set_string(settings, "gtk-theme", app.widget_theme);

if (app.icon_theme && g_settings_schema_has_key(schema, "icon-theme"))
g_settings_set_string(settings, "icon-theme", app.icon_theme);

if (app.default_font && g_settings_schema_has_key(schema, "font-name"))
g_settings_set_string(settings, "font-name", app.default_font);

if (app.cursor_theme && g_settings_schema_has_key(schema, "cursor-theme"))
g_settings_set_string(settings, "cursor-theme", app.cursor_theme);

if (g_settings_schema_has_key(schema, "cursor-size"))
g_settings_set_int(settings, "cursor-size", app.cursor_theme_size);

if (app.font_rgba && g_settings_schema_has_key(schema, "font-antialiasing") && g_settings_schema_has_key(schema, "font-rgba-order"))
{
if (!app.enable_antialising)
g_settings_set_string(settings, "font-antialiasing", "none");
else if (strcmp(app.font_rgba, "none") == 0)
g_settings_set_string(settings, "font-antialiasing", "grayscale");
else
{
g_settings_set_string(settings, "font-antialiasing", "rgba");
if (strcmp(app.font_rgba, "rgb") == 0)
g_settings_set_string(settings, "font-rgba-order", "rgb");
else if (strcmp(app.font_rgba, "bgr") == 0)
g_settings_set_string(settings, "font-rgba-order", "bgr");
else if (strcmp(app.font_rgba, "vrgb") == 0)
g_settings_set_string(settings, "font-rgba-order", "vrgb");
else if (strcmp(app.font_rgba, "vbgr") == 0)
g_settings_set_string(settings, "font-rgba-order", "vbgr");
}
}

if (app.hinting_style && g_settings_schema_has_key(schema, "font-hinting"))
{
if (!app.enable_hinting || strcmp(app.hinting_style, "hintnone") == 0)
g_settings_set_string(settings, "font-hinting", "none");
else if (strcmp(app.hinting_style, "hintslight") == 0)
g_settings_set_string(settings, "font-hinting", "slight");
else if (strcmp(app.hinting_style, "hintmedium") == 0)
g_settings_set_string(settings, "font-hinting", "medium");
else if (strcmp(app.hinting_style, "hintfull") == 0)
g_settings_set_string(settings, "font-hinting", "full");
}

if (g_settings_schema_has_key(schema, "menus-have-icons"))
g_settings_set_boolean(settings, "menus-have-icons", app.menu_images);

if (g_settings_schema_has_key(schema, "buttons-have-icons"))
g_settings_set_boolean(settings, "buttons-have-icons", app.button_images);

if (g_settings_schema_has_key(schema, "toolbar-style"))
{
if (app.toolbar_style == 0)
g_settings_set_string(settings, "toolbar-style", "icons");
else if (app.toolbar_style == 1)
g_settings_set_string(settings, "toolbar-style", "text");
else if (app.toolbar_style == 2)
g_settings_set_string(settings, "toolbar-style", "both");
else if (app.toolbar_style == 3)
g_settings_set_string(settings, "toolbar-style", "both-horiz");
}

if (g_settings_schema_has_key(schema, "toolbar-icons-size"))
{
if (app.toolbar_icon_size == 2)
g_settings_set_string(settings, "toolbar-icons-size", "small");
else if (app.toolbar_icon_size == 3)
g_settings_set_string(settings, "toolbar-icons-size", "large");
}

g_settings_schema_unref(schema);
g_object_unref(settings);
}
#endif

static void lxappearance_save_lxsession()
{
char* rel_path = g_strconcat("lxsession/", lxsession_name, "/desktop.conf", NULL);
Expand Down Expand Up @@ -532,6 +623,9 @@ static void on_dlg_response(GtkDialog* dlg, int res, gpointer user_data)
if(app.use_lxsession)
lxappearance_save_lxsession();
lxappearance_save_gtkrc();
#if GLIB_CHECK_VERSION(2, 40, 0)
lxappearance_save_gsettings();
#endif

reload_all_programs();

Expand Down
4 changes: 2 additions & 2 deletions src/other.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ static void on_tb_style_changed(GtkComboBox* combo, gpointer user_data)

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;
app.toolbar_icon_size = gtk_combo_box_get_active(combo) + GTK_ICON_SIZE_SMALL_TOOLBAR;
lxappearance_changed();
}

Expand Down Expand Up @@ -72,7 +72,7 @@ void other_init(GtkBuilder* b)
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;
idx = app.toolbar_icon_size - GTK_ICON_SIZE_SMALL_TOOLBAR;
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);

Expand Down