Bläddra i källkod

Reflect current font in menu on app load

Previously, "Serif" would be selected in the menu when the app first
loaded, no matter what the actual setting was.
tags/v1.0.2
Matt Baer 5 år sedan
förälder
incheckning
8312087ec9
1 ändrade filer med 17 tillägg och 3 borttagningar
  1. +17
    -3
      src/window.vala

+ 17
- 3
src/window.vala Visa fil

@@ -20,6 +20,9 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
private Gtk.TextView canvas;
private Gtk.HeaderBar header;
private Granite.ModeSwitch darkmode_switch;
private Gtk.RadioMenuItem font_serif_option;
private Gtk.RadioMenuItem font_sans_option;
private Gtk.RadioMenuItem font_wrap_option;

private static string data_dir = ".writeas";
private static string version = "1.0.1";
@@ -162,10 +165,10 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
fonts.popup = new Gtk.Menu();
header.pack_start(fonts);

build_fontoption(fonts.popup, _("Serif"), "serif", font);
build_fontoption(fonts.popup, _("Sans-serif"), "sans",
font_serif_option = build_fontoption(fonts.popup, _("Serif"), "serif", font);
font_sans_option = build_fontoption(fonts.popup, _("Sans-serif"), "sans",
"'Open Sans', 'Segoe UI', Tahoma, Arial, sans-serif");
build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
font_wrap_option = build_fontoption(fonts.popup, _("Monospace"), "wrap", "Hack, consolas," +
"Menlo-Regular, Menlo, Monaco, 'ubuntu mono', monospace");
fonts.popup.show_all();
}
@@ -193,6 +196,8 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
}

menu.add(option);

return option;
}

public override void grab_focus() {
@@ -213,6 +218,15 @@ public class WriteAs.MainWindow : Gtk.ApplicationWindow {
font = theme.get_string("Post", "font");
fontstyle = theme.get_string("Post", "fontstyle");

// Select the current font in the menu
if (fontstyle == "serif") {
font_serif_option.set_active(true);
} else if (fontstyle == "sans") {
font_sans_option.set_active(true);
} else if (fontstyle == "wrap") {
font_wrap_option.set_active(true);
}

adjust_text_style(false);
} catch (Error err) {/* No biggy... */}
}


Laddar…
Avbryt
Spara