From 6b019a98f3d3636a9c804cf7a0b6f9600bad5c10 Mon Sep 17 00:00:00 2001 From: eidheim Date: Thu, 17 Sep 2015 13:24:36 +0200 Subject: [PATCH] Can now change default size of juci window in config.json. --- src/config.cc | 1 + src/files.h | 4 ++++ src/window.cc | 13 +++++++------ src/window.h | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/config.cc b/src/config.cc index 61ad2c6..6bc771e 100644 --- a/src/config.cc +++ b/src/config.cc @@ -59,6 +59,7 @@ void MainConfig::retrieve_config() { Singleton::Config::window()->theme_name=cfg.get("gtk_theme.name"); Singleton::Config::window()->theme_variant=cfg.get("gtk_theme.variant"); Singleton::Config::window()->version = cfg.get("version"); + Singleton::Config::window()->default_size = {cfg.get("default_window_size.width"), cfg.get("default_window_size.height")}; Singleton::Config::terminal()->make_command=cfg.get("project.make_command"); Singleton::Config::terminal()->cmake_command=cfg.get("project.cmake_command"); } diff --git a/src/files.h b/src/files.h index 0c9da9b..629d862 100644 --- a/src/files.h +++ b/src/files.h @@ -5,6 +5,10 @@ const std::string configjson = "{\n" " \"version\": \""+std::string(JUCI_VERSION)+"\",\n" +" \"default_window_size\": {\n" +" \"width\": 600,\n" +" \"height\": 400\n" +" },\n" " \"gtk_theme\": {\n" " \"name\": \"Adwaita\", //Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh\n" " \"variant\": \"\" //Use \"\" for default variant, and \"dark\" for dark theme variant\n" diff --git a/src/window.cc b/src/window.cc index a24214c..343fda6 100644 --- a/src/window.cc +++ b/src/window.cc @@ -33,13 +33,14 @@ void Window::generate_keybindings() { Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compiling(false) { DEBUG("start"); set_title("juCi++"); - set_default_size(600, 400); set_events(Gdk::POINTER_MOTION_MASK|Gdk::FOCUS_CHANGE_MASK|Gdk::SCROLL_MASK); - add(box); - - configure(); + configure(); + set_default_size(Singleton::Config::window()->default_size.first, Singleton::Config::window()->default_size.second); + //PluginApi(&this->notebook, &this->menu); + add(box); + //TODO: Do not use deprecated ui_manager? And make menu shortcuts update when config.json is saved (in configure()) generate_keybindings(); create_menu(); @@ -51,8 +52,8 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL), notebook(directories), compil notebook_vbox.pack_start(notebook); notebook_vbox.pack_end(entry_box, Gtk::PACK_SHRINK); directory_and_notebook_panes.pack2(notebook_vbox, Gtk::SHRINK); - directory_and_notebook_panes.set_position(120); - vpaned.set_position(300); + directory_and_notebook_panes.set_position(static_cast(0.2*Singleton::Config::window()->default_size.first)); + vpaned.set_position(static_cast(0.75*Singleton::Config::window()->default_size.second)); vpaned.pack1(directory_and_notebook_panes, true, false); terminal_scrolled_window.add(*Singleton::terminal()); diff --git a/src/window.h b/src/window.h index 2fcdd49..095e949 100644 --- a/src/window.h +++ b/src/window.h @@ -19,6 +19,7 @@ public: std::string theme_name; std::string theme_variant; std::string version; + std::pair default_size; boost::property_tree::ptree keybindings; };