Skip to content

Commit

Permalink
Fix some appearance issues on Ubuntu, code improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
gnunn1 committed Jan 13, 2016
1 parent f7f6d06 commit 6782e17
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 34 deletions.
5 changes: 2 additions & 3 deletions data/resources/css/terminix.adwaita.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
padding: 1px 4px 1px 4px;
font-size: 0.8em;
}

.terminix-notebook-page {
background-color: @theme_bg_color;
}


}
13 changes: 10 additions & 3 deletions source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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;
}
Expand Down
14 changes: 10 additions & 4 deletions source/gx/gtk/util.d
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import gdk.Screen;
import gio.File : GFile = File;
import gio.Resource;

import glib.GException;
import glib.ListG;
import glib.Util;

Expand Down Expand Up @@ -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;
}
Expand Down
19 changes: 1 addition & 18 deletions source/gx/terminix/appwindow.d
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private:
session.focusRestore();
saSyncInput.setState(new GVariant(session.synchronizeInput));
}, ConnectFlags.AFTER);
this.add(nb);
add(nb);
}

/**
Expand Down Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion source/gx/terminix/constants.d
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
19 changes: 15 additions & 4 deletions source/gx/terminix/session.d
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -317,6 +329,7 @@ private:
paned.pack2(b2, true, true);

parent.remove(dest);
parent.showAll();
if (child == 1) {
b1.add(src);
b2.add(dest);
Expand All @@ -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();
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 6 additions & 1 deletion source/gx/terminix/terminal/terminal.d
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ private:
box.add(sb);
return box;
}

/**
* Updates the terminal title in response to UI changes
*/
Expand Down Expand Up @@ -793,6 +793,8 @@ private:
vte.addOnDragMotion(&onVTEDragMotion);
vte.addOnDragLeave(&onVTEDragLeave);
vte.addOnDraw(&onVTEDraw, ConnectFlags.AFTER);

trace("Drag and drop completed");
}

/**
Expand Down Expand Up @@ -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");
}

/**
Expand Down

0 comments on commit 6782e17

Please sign in to comment.