Bump version number.
[lxde/lxappearance.git] / src / widget-theme.c
index 75ed24b..6e23747 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);
 
@@ -108,6 +113,19 @@ static void load_themes()
     // g_signal_connect(gtk_settings_get_default(), "notify::gtk-theme-name", G_CALLBACK(on_sel_changed), NULL);
 }
 
+static void on_font_set(GtkFontButton* btn, gpointer user_data)
+{
+    const char* font_name = gtk_font_button_get_font_name(btn);
+    if(g_strcmp0(font_name, app.default_font))
+    {
+        g_free(app.default_font);
+        app.default_font = g_strdup(font_name);
+        g_object_set(gtk_settings_get_default(), "gtk-font-name", font_name, NULL);
+
+        lxappearance_changed();
+    }
+}
+
 void widget_theme_init(GtkBuilder* b)
 {
     GtkWidget* demo;
@@ -122,4 +140,8 @@ void widget_theme_init(GtkBuilder* b)
 
     /* load available themes */
     load_themes();
+
+    app.default_font_btn = GTK_WIDGET(gtk_builder_get_object(b, "default_font"));
+    gtk_font_button_set_font_name(GTK_FONT_BUTTON(app.default_font_btn), app.default_font);
+    g_signal_connect(app.default_font_btn, "font-set", G_CALLBACK(on_font_set), NULL);
 }