From 6782e17682d610b75e8d088ecc8bab252794139e Mon Sep 17 00:00:00 2001 From: gnunn1 Date: Wed, 13 Jan 2016 17:17:18 -0500 Subject: [PATCH] Fix some appearance issues on Ubuntu, code improvements --- data/resources/css/terminix.adwaita.css | 5 ++--- source/app.d | 13 ++++++++++--- source/gx/gtk/util.d | 14 ++++++++++---- source/gx/terminix/appwindow.d | 19 +------------------ source/gx/terminix/constants.d | 2 +- source/gx/terminix/session.d | 19 +++++++++++++++---- source/gx/terminix/terminal/terminal.d | 7 ++++++- 7 files changed, 45 insertions(+), 34 deletions(-) diff --git a/data/resources/css/terminix.adwaita.css b/data/resources/css/terminix.adwaita.css index 62655780..47edcd15 100644 --- a/data/resources/css/terminix.adwaita.css +++ b/data/resources/css/terminix.adwaita.css @@ -13,8 +13,7 @@ padding: 1px 4px 1px 4px; font-size: 0.8em; } + .terminix-notebook-page { background-color: @theme_bg_color; -} - - +} \ No newline at end of file diff --git a/source/app.d b/source/app.d index 79861478..e475c328 100644 --- a/source/app.d +++ b/source/app.d @@ -21,8 +21,8 @@ import gx.terminix.constants; int main(string[] args) { //Version checking cribbed from grestful, thanks! - string error = Version.checkVersion(GTK_VERSION_MAJOR, GTK_VERSION_MINOR, GTK_VERSION_PATCH); - if (error !is null) { + string gtkError = Version.checkVersion(GTK_VERSION_MAJOR, GTK_VERSION_MINOR, GTK_VERSION_PATCH); + if (gtkError !is null) { Main.init(args); MessageDialog dialog = new MessageDialog( @@ -45,7 +45,14 @@ int main(string[] args) { auto terminixApp = new Terminix(cp); //Bypass GTK command line handling since we handle it ourselves string[] tempArgs; - return terminixApp.run(tempArgs); + int result; + try { + result = terminixApp.run(tempArgs); + } catch (Exception e) { + error("Unexpected exception occurred"); + error("Error: " ~ e.msg); + } + return result; } else { return cp.exitCode; } diff --git a/source/gx/gtk/util.d b/source/gx/gtk/util.d index edc19da8..4b31ba6b 100644 --- a/source/gx/gtk/util.d +++ b/source/gx/gtk/util.d @@ -16,6 +16,7 @@ import gdk.Screen; import gio.File : GFile = File; import gio.Resource; +import glib.GException; import glib.ListG; import glib.Util; @@ -159,10 +160,15 @@ Resource findResource(string resourcePath, bool register = true) { } bool addCssProvider(string filename, ProviderPriority priority) { - CssProvider provider = new CssProvider(); - if (provider.loadFromFile(GFile.parseName(filename))) { - StyleContext.addProviderForScreen(Screen.getDefault(), provider, priority); - return true; + try { + CssProvider provider = new CssProvider(); + if (provider.loadFromFile(GFile.parseName(filename))) { + StyleContext.addProviderForScreen(Screen.getDefault(), provider, priority); + return true; + } + } catch (GException ge) { + error("Unexpected error loading resource " ~ filename); + error("Error: " ~ ge.msg); } return false; } diff --git a/source/gx/terminix/appwindow.d b/source/gx/terminix/appwindow.d index 3839aeeb..ec94c98c 100644 --- a/source/gx/terminix/appwindow.d +++ b/source/gx/terminix/appwindow.d @@ -181,7 +181,7 @@ private: session.focusRestore(); saSyncInput.setState(new GVariant(session.synchronizeInput)); }, ConnectFlags.AFTER); - this.add(nb); + add(nb); } /** @@ -573,23 +573,6 @@ public: addOnDelete(&onWindowClosed); addOnDestroy(&onWindowDestroyed); addOnCompositedChanged(&onCompositedChanged); - /* - addOnDraw(delegate(Scoped!Context cr, Widget widget) { - StyleContext context = widget.getStyleContext(); - gtk.Border.Border border; - int x = 0; - int y = 0; - int w = widget.getAllocatedWidth(); - int h = widget.getAllocatedHeight(); - context.getShadowWidth(widget.getStateFlags(), border); - x = x + border.getBorderStruct().left; - y = y + border.getBorderStruct().top; - - StyleContext.renderBackground(context, cr, x, y, w, h); - StyleContext.renderFrame(context, cr, x, y, w, h); - return false; - }); - */ } void initialize() { diff --git a/source/gx/terminix/constants.d b/source/gx/terminix/constants.d index b7602c03..c4e8c957 100644 --- a/source/gx/terminix/constants.d +++ b/source/gx/terminix/constants.d @@ -20,7 +20,7 @@ enum APPLICATION_ID = "com.gexperts.Terminix"; // Application values used in About Dialog enum APPLICATION_NAME = "Terminix"; -enum APPLICATION_VERSION = "0.32.0"; +enum APPLICATION_VERSION = "0.35.0"; enum APPLICATION_AUTHOR = "Gerald Nunn"; enum APPLICATION_COPYRIGHT = "Copyright \xc2\xa9 2015 " ~ APPLICATION_AUTHOR; enum APPLICATION_COMMENTS = _("A VTE based terminal emulator for Linux"); diff --git a/source/gx/terminix/session.d b/source/gx/terminix/session.d index 20464b79..568deb9f 100644 --- a/source/gx/terminix/session.d +++ b/source/gx/terminix/session.d @@ -136,6 +136,16 @@ private: terminal.terminalID = i; } } + + /** + * Create a Paned widget and modify some properties to + * make it look somewhat attractive on Ubuntu and non Adwaita themes. + */ + Paned createPaned(Orientation orientation) { + Paned result = new Paned(orientation); + result.setWideHandle(false); + return result; + } /** * Creates the terminal widget and wires the various @@ -231,7 +241,9 @@ private: void onTerminalRequestSplit(Terminal terminal, Orientation orientation) { trace("Splitting Terminal"); Terminal newTerminal = createTerminal(terminal.profileUUID); + trace("Inserting terminal"); insertTerminal(terminal, newTerminal, orientation, 2); + trace("Intializing terminal"); newTerminal.initTerminal(terminal.currentDirectory, false); } @@ -317,6 +329,7 @@ private: paned.pack2(b2, true, true); parent.remove(dest); + parent.showAll(); if (child == 1) { b1.add(src); b2.add(dest); @@ -325,15 +338,13 @@ private: b2.add(src); } - switch (orientation) { + final switch (orientation) { case Orientation.HORIZONTAL: paned.setPosition(width / 2); break; case Orientation.VERTICAL: paned.setPosition(height / 2); break; - default: - assert(0); } parent.add(paned); parent.showAll(); @@ -566,7 +577,7 @@ private: Paned parsePaned(JSONValue value, SessionSizeInfo sizeInfo) { trace("Loading paned"); Orientation orientation = cast(Orientation) value[NODE_ORIENTATION].integer(); - Paned paned = new Paned(orientation); + Paned paned = createPaned(orientation); Box b1 = new Box(Orientation.VERTICAL, 0); b1.add(parseNode(value[NODE_CHILD1], sizeInfo)); Box b2 = new Box(Orientation.VERTICAL, 0); diff --git a/source/gx/terminix/terminal/terminal.d b/source/gx/terminix/terminal/terminal.d index 38e27c66..115fc7a7 100644 --- a/source/gx/terminix/terminal/terminal.d +++ b/source/gx/terminix/terminal/terminal.d @@ -481,7 +481,7 @@ private: box.add(sb); return box; } - + /** * Updates the terminal title in response to UI changes */ @@ -793,6 +793,8 @@ private: vte.addOnDragMotion(&onVTEDragMotion); vte.addOnDragLeave(&onVTEDragLeave); vte.addOnDraw(&onVTEDraw, ConnectFlags.AFTER); + + trace("Drag and drop completed"); } /** @@ -1031,8 +1033,11 @@ public: gsProfile = prfMgr.getProfileSettings(profileUUID); gsShortcuts = new GSettings(SETTINGS_PROFILE_KEY_BINDINGS_ID); createUI(); + trace("Apply preferences"); applyPreferences(); + trace("Profile Event Handler"); gsProfile.addOnChanged(delegate(string key, Settings) { applyPreference(key); }); + trace("Finished creation"); } /**