diff --git a/src/math-window.vala b/src/math-window.vala index 9b07786..bfcf451 100644 --- a/src/math-window.vala +++ b/src/math-window.vala @@ -78,15 +78,37 @@ public class MathWindow : Gtk.ApplicationWindow menu_button.relief = Gtk.ReliefStyle.NONE; menu_button.show (); + var main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + add (main_vbox); + main_vbox.show (); + headerbar = new Gtk.HeaderBar (); headerbar.show_close_button = true; headerbar.custom_title = menu_button; headerbar.show (); - set_titlebar (headerbar); - - var main_vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); - add (main_vbox); - main_vbox.show (); + if (!is_desktop ("Unity")) + set_titlebar (headerbar); + else + { + var menu = new Menu (); + var section = new Menu (); + menu.append_submenu (_("Mode"), section); + var item = new MenuItem (_("Basic Mode"), null); + item.set_action_and_target ("win.mode", "s", "basic"); + section.append_item (item); + item = new MenuItem (_("Advanced Mode"), null); + item.set_action_and_target ("win.mode", "s", "advanced"); + section.append_item (item); + item = new MenuItem (_("Financial Mode"), null); + item.set_action_and_target ("win.mode", "s", "financial"); + section.append_item (item); + item = new MenuItem (_("Programming Mode"), null); + item.set_action_and_target ("win.mode", "s", "programming"); + section.append_item (item); + var menubar = new Gtk.MenuBar.from_model (menu); + menubar.visible = true; + main_vbox.pack_start (menubar, true, true, 0); + } var vbox = new Gtk.Box (Gtk.Orientation.VERTICAL, 6); vbox.border_width = 6; @@ -113,6 +135,19 @@ public class MathWindow : Gtk.ApplicationWindow mode_changed_cb (); } + private bool is_desktop (string name) + { + var desktop_name_list = Environment.get_variable ("XDG_CURRENT_DESKTOP"); + if (desktop_name_list == null) + return false; + + foreach (var n in desktop_name_list.split (":")) + if (n == name) + return true; + + return false; + } + private void mode_changed_cb () { var action = (SimpleAction) lookup_action ("mode");