[moserial] indent and space cleanup, astyle -A8 -c *.vala
- From: Michael J. Chudobiak <mjc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [moserial] indent and space cleanup, astyle -A8 -c *.vala
- Date: Sat, 16 Jan 2021 14:46:16 +0000 (UTC)
commit d178d227edeca024219cb43e8a523eff0a0ffd79
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date: Sat Jan 16 09:45:49 2021 -0500
indent and space cleanup, astyle -A8 -c *.vala
src/AutoScroll.vala | 12 +-
src/DefaultPaths.vala | 15 ++-
src/HexTextBuffer.vala | 15 ++-
src/InputParser.vala | 144 ++++++++++-----------
src/Main.vala | 9 +-
src/MainWindow.vala | 278 +++++++++++++++++++++++++----------------
src/MoUtils.vala | 30 +++--
src/Preferences.vala | 21 ++--
src/PreferencesDialog.vala | 24 ++--
src/Profile.vala | 51 +++++---
src/ReceiveChooserDialog.vala | 15 ++-
src/ReceiveProgressDialog.vala | 20 +--
src/RecordDialog.vala | 37 +++---
src/Rzwrapper.vala | 56 +++++----
src/SendChooserDialog.vala | 17 ++-
src/SendProgressDialog.vala | 18 ++-
src/SerialConnection.vala | 173 +++++++++++++------------
src/SerialStreamRecorder.vala | 27 ++--
src/Settings.vala | 67 +++++-----
src/SettingsDialog.vala | 24 ++--
src/Szwrapper.vala | 53 ++++----
src/XmodemFilenameDialog.vala | 17 ++-
22 files changed, 673 insertions(+), 450 deletions(-)
---
diff --git a/src/AutoScroll.vala b/src/AutoScroll.vala
index 6b3fc09..9edcb85 100644
--- a/src/AutoScroll.vala
+++ b/src/AutoScroll.vala
@@ -18,19 +18,23 @@
*/
using Gtk;
-public class moserial.AutoScroll : GLib.Object {
- public static void scroll (Gtk.Adjustment va) {
+public class moserial.AutoScroll : GLib.Object
+{
+ public static void scroll (Gtk.Adjustment va)
+ {
va.value = va.upper - va.page_size;
}
- public static void doAutoScroll (Gtk.Adjustment va) {
+ public static void doAutoScroll (Gtk.Adjustment va)
+ {
if (va.value == va.upper - va.page_size)
va.changed.connect (scroll);
else
va.changed.disconnect (scroll);
}
- public static void setup (Gtk.Adjustment incomingAsciiVerticalAdjuster, Gtk.Adjustment
incomingHexVerticalAdjuster, Gtk.Adjustment outgoingAsciiVerticalAdjuster, Gtk.Adjustment
outgoingHexVerticalAdjuster) {
+ public static void setup (Gtk.Adjustment incomingAsciiVerticalAdjuster, Gtk.Adjustment
incomingHexVerticalAdjuster, Gtk.Adjustment outgoingAsciiVerticalAdjuster, Gtk.Adjustment
outgoingHexVerticalAdjuster)
+ {
incomingAsciiVerticalAdjuster.changed.connect (scroll);
incomingAsciiVerticalAdjuster.value_changed.connect (doAutoScroll);
diff --git a/src/DefaultPaths.vala b/src/DefaultPaths.vala
index bf9f667..d3800c5 100644
--- a/src/DefaultPaths.vala
+++ b/src/DefaultPaths.vala
@@ -18,18 +18,21 @@
*/
using GLib;
-public class DefaultPaths : GLib.Object {
+public class DefaultPaths : GLib.Object
+{
public string ? recordTo { get; set; }
public string ? receiveTo { get; set; }
public string ? sendFrom { get; set; }
- public DefaultPaths (string ? RecordTo, string ? ReceiveTo, string ? SendFrom) {
+ public DefaultPaths (string ? RecordTo, string ? ReceiveTo, string ? SendFrom)
+ {
this.recordTo = RecordTo;
this.receiveTo = ReceiveTo;
this.sendFrom = SendFrom;
}
- public void saveToProfile (Profile profile) {
+ public void saveToProfile (Profile profile)
+ {
if (recordTo != null)
profile.keyFile.set_string ("paths", "last_record_path", recordTo);
if (receiveTo != null)
@@ -38,7 +41,8 @@ public class DefaultPaths : GLib.Object {
profile.keyFile.set_string ("paths", "last_send_path", sendFrom);
}
- public static DefaultPaths loadFromProfile (Profile profile) {
+ public static DefaultPaths loadFromProfile (Profile profile)
+ {
string ? RecordTo = null;
string ? ReceiveTo = null;
string ? SendFrom = null;
@@ -50,7 +54,8 @@ public class DefaultPaths : GLib.Object {
return new DefaultPaths (RecordTo, ReceiveTo, SendFrom);
}
- public static string ? getPath (Profile profile, string group, string key) {
+ public static string ? getPath (Profile profile, string group, string key)
+ {
string ? path = null;
try {
path = profile.keyFile.get_string (group, key);
diff --git a/src/HexTextBuffer.vala b/src/HexTextBuffer.vala
index d73326d..fa89efc 100644
--- a/src/HexTextBuffer.vala
+++ b/src/HexTextBuffer.vala
@@ -20,7 +20,8 @@
using Gtk;
using GLib;
-public class moserial.HexTextBuffer : TextBuffer {
+public class moserial.HexTextBuffer : TextBuffer
+{
private TextMark nextHexMark;
private TextMark nextCharMark;
private TextTag addressTag;
@@ -29,18 +30,21 @@ public class moserial.HexTextBuffer : TextBuffer {
setup ();
addressTag = this.create_tag ("hex_address", "foreground", "#2020ff", null);
}
- public void applyPreferences (Preferences preferences) {
+ public void applyPreferences (Preferences preferences)
+ {
addressTag.foreground = preferences.highlightColor;
}
- public void clear () {
+ public void clear ()
+ {
this.delete_mark (nextHexMark);
this.delete_mark (nextCharMark);
this.set_text ("", 0);
setup ();
}
- private void setup () {
+ private void setup ()
+ {
TextIter nextHexIter;
TextIter nextCharIter;
this.get_end_iter (out nextHexIter);
@@ -52,7 +56,8 @@ public class moserial.HexTextBuffer : TextBuffer {
hexBytes = 0;
}
- public void add (uchar data) {
+ public void add (uchar data)
+ {
TextIter nextHexIter;
TextIter nextCharIter;
string incomingHexBuffer = "";
diff --git a/src/InputParser.vala b/src/InputParser.vala
index f12884e..c8005f4 100644
--- a/src/InputParser.vala
+++ b/src/InputParser.vala
@@ -20,10 +20,12 @@
public errordomain HexParseError {
INVALID_INPUT;
}
-public class InputParser : GLib.Object {
+public class InputParser : GLib.Object
+{
/* We need this due to some strange Vala bug stopping us using string.replace in two different classes
should look into it and possibly file a bug */
- public static string statusReplace (string oldString) {
+ public static string statusReplace (string oldString)
+ {
return oldString.replace ("\\r", "\\n");
}
@@ -31,7 +33,8 @@ public class InputParser : GLib.Object {
long len = s.length;
uchar[] r = new uchar[(len + 1) / 2];
- for (int x = 0; x < (len + 1) / 2; x++) {
+ for (int x = 0; x < (len + 1) / 2; x++)
+ {
unichar c;
int i;
int temp;
@@ -62,76 +65,77 @@ public class InputParser : GLib.Object {
}
// There should be bindings to something in vala that can do this but there dosen't seem to be yet
2009-01-31
- private static uchar xtoi (unichar c) {
+ private static uchar xtoi (unichar c)
+ {
uchar i = 16; // an invalid positive result
switch (c) {
- case '0':
- i = 0;
- break;
- case '1':
- i = 1;
- break;
- case '2':
- i = 2;
- break;
- case '3':
- i = 3;
- break;
- case '4':
- i = 4;
- break;
- case '5':
- i = 5;
- break;
- case '6':
- i = 6;
- break;
- case '7':
- i = 7;
- break;
- case '8':
- i = 8;
- break;
- case '9':
- i = 9;
- break;
- case 'a':
- i = 10;
- break;
- case 'b':
- i = 11;
- break;
- case 'c':
- i = 12;
- break;
- case 'd':
- i = 13;
- break;
- case 'e':
- i = 14;
- break;
- case 'f':
- i = 15;
- break;
+ case '0':
+ i = 0;
+ break;
+ case '1':
+ i = 1;
+ break;
+ case '2':
+ i = 2;
+ break;
+ case '3':
+ i = 3;
+ break;
+ case '4':
+ i = 4;
+ break;
+ case '5':
+ i = 5;
+ break;
+ case '6':
+ i = 6;
+ break;
+ case '7':
+ i = 7;
+ break;
+ case '8':
+ i = 8;
+ break;
+ case '9':
+ i = 9;
+ break;
+ case 'a':
+ i = 10;
+ break;
+ case 'b':
+ i = 11;
+ break;
+ case 'c':
+ i = 12;
+ break;
+ case 'd':
+ i = 13;
+ break;
+ case 'e':
+ i = 14;
+ break;
+ case 'f':
+ i = 15;
+ break;
- case 'A':
- i = 10;
- break;
- case 'B':
- i = 11;
- break;
- case 'C':
- i = 12;
- break;
- case 'D':
- i = 13;
- break;
- case 'E':
- i = 14;
- break;
- case 'F':
- i = 15;
- break;
+ case 'A':
+ i = 10;
+ break;
+ case 'B':
+ i = 11;
+ break;
+ case 'C':
+ i = 12;
+ break;
+ case 'D':
+ i = 13;
+ break;
+ case 'E':
+ i = 14;
+ break;
+ case 'F':
+ i = 15;
+ break;
}
return i;
}
diff --git a/src/Main.vala b/src/Main.vala
index c532acb..5d91612 100644
--- a/src/Main.vala
+++ b/src/Main.vala
@@ -19,13 +19,15 @@
using Gtk;
-class moserial.Main : GLib.Object {
+class moserial.Main : GLib.Object
+{
static string profileFilename;
const OptionEntry[] options = {
{ "profile", 'p', 0, OptionArg.FILENAME, out profileFilename, N_ ("Profile file to load"),
"foo.conf" },
{ null }
};
- public void run () {
+ public void run ()
+ {
moserial.MainWindow mainWindow;
if (!(profileFilename == null) && (!GLib.Path.is_absolute (profileFilename)))
@@ -34,7 +36,8 @@ class moserial.Main : GLib.Object {
mainWindow.showWindow ();
}
- public static int main (string[] args) {
+ public static int main (string[] args)
+ {
OptionContext context;
Gtk.init (ref args);
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index 52f9292..f47e3b3 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -109,7 +109,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
private Label serialStatusSignals[4];
- public MainWindow (string ? profileFilename) {
+ public MainWindow (string ? profileFilename)
+ {
GLib.Object (startupProfileFilename: profileFilename);
}
construct {
@@ -131,7 +132,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
int width = profile.getWindowWidth ();
int height = profile.getWindowHeight ();
int panedPosition = profile.getWindowPanedPosition ();
- if ((width > 0) && (height > 0)) {
+ if ((width > 0) && (height > 0))
+ {
gtkWindow.resize (width, height);
}
@@ -290,9 +292,11 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
inputModeCombo = (ComboBox) builder.get_object ("input_mode");
MoUtils.populateComboBox (inputModeCombo, inputModeStrings);
- if (profile.getInputModeHex ()) {
+ if (profile.getInputModeHex ())
+ {
inputModeCombo.set_active (inputModeValues.HEX);
- } else {
+ } else
+ {
inputModeCombo.set_active (inputModeValues.ASCII);
}
inputModeCombo.changed.connect (inputModeChanged);
@@ -367,15 +371,18 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
currentPaths = DefaultPaths.loadFromProfile (profile);
}
- private void onIncomingNotebookSwitchPage (Widget page, uint page_num) {
+ private void onIncomingNotebookSwitchPage (Widget page, uint page_num)
+ {
profile.setNotebookTab (false, page_num);
}
- private void onOutgoingNotebookSwitchPage (Widget page, uint page_num) {
+ private void onOutgoingNotebookSwitchPage (Widget page, uint page_num)
+ {
profile.setNotebookTab (true, page_num);
}
- private void toggleRTS (ToggleButton button) {
+ private void toggleRTS (ToggleButton button)
+ {
// Toogle only when connected
if (!serialConnection.isConnected ()) {
return;
@@ -388,7 +395,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void toggleDTR (ToggleButton button) {
+ private void toggleDTR (ToggleButton button)
+ {
// Toogle only when connected
if (!serialConnection.isConnected ()) {
return;
@@ -401,17 +409,20 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void clearIncoming () {
+ private void clearIncoming ()
+ {
incomingHexTextBuffer.clear ();
incomingAsciiTextBuffer.set_text ("", 0);
}
- private void clearOutgoing () {
+ private void clearOutgoing ()
+ {
outgoingHexTextBuffer.clear ();
outgoingAsciiTextBuffer.set_text ("", 0);
}
- private void applyProfile (string filename) {
+ private void applyProfile (string filename)
+ {
if (profile.load (filename, gtkWindow)) {
profileFilename = filename;
ensureDisconnected ();
@@ -433,7 +444,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void setWindowTitle (string ? recordingFilename) {
+ private void setWindowTitle (string ? recordingFilename)
+ {
var builder = new StringBuilder ();
builder.append ("moserial");
@@ -450,7 +462,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
gtkWindow.set_title (builder.str);
}
- private void recentItemOpen (RecentChooser r) {
+ private void recentItemOpen (RecentChooser r)
+ {
try {
applyProfile (GLib.Filename.from_uri (r.get_current_uri ()));
} catch (GLib.ConvertError e) {
@@ -458,7 +471,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void insertBufferEnd (TextBuffer buf, string s) {
+ private void insertBufferEnd (TextBuffer buf, string s)
+ {
TextIter iter;
int i;
var builder = new StringBuilder ();
@@ -474,7 +488,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
buf.insert (ref iter, builder.str, (int) builder.str.length);
}
- public void sendString (Widget w) {
+ public void sendString (Widget w)
+ {
string s;
s = entry.get_text ();
// profile.setInputString (s);
@@ -539,31 +554,33 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
echoStartMark = incomingAsciiTextBuffer.create_mark ("echo", echoStartIter, true);
}
- private void doSendChooser (ToolButton button) {
+ private void doSendChooser (ToolButton button)
+ {
if (!ensureConnected ())
return;
sendChooserDialog.show (currentPaths.sendFrom);
}
- private void doSend (SendChooserDialog dialog) {
+ private void doSend (SendChooserDialog dialog)
+ {
Szwrapper.Protocol protocol;
string filename;
filename = dialog.filename;
currentPaths.sendFrom = MoUtils.getParentFolder (filename);
switch (dialog.protocolCombo.get_active ()) {
- case 0:
- protocol = Szwrapper.Protocol.XMODEM;
- break;
- case 1:
- protocol = Szwrapper.Protocol.YMODEM;
- break;
- case 2:
- default:
- protocol = Szwrapper.Protocol.ZMODEM;
- break;
- case 3:
- protocol = Szwrapper.Protocol.RAW;
- break;
+ case 0:
+ protocol = Szwrapper.Protocol.XMODEM;
+ break;
+ case 1:
+ protocol = Szwrapper.Protocol.YMODEM;
+ break;
+ case 2:
+ default:
+ protocol = Szwrapper.Protocol.ZMODEM;
+ break;
+ case 3:
+ protocol = Szwrapper.Protocol.RAW;
+ break;
}
sz = new Szwrapper (protocol, serialConnection, filename);
if (sz.running) {
@@ -574,20 +591,23 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- public void sendComplete (GLib.Object o) {
+ public void sendComplete (GLib.Object o)
+ {
sz.updateStatus.disconnect (sendProgressDialog.updateStatus);
sendProgressDialog.transferCanceled.disconnect (sz.transferCanceled);
sendProgressDialog.hide ();
}
- private void doReceiveChooser (ToolButton button) {
+ private void doReceiveChooser (ToolButton button)
+ {
if (!ensureConnected ())
return;
receiveChooserDialog.show (currentPaths.receiveTo);
}
- private void doReceive (ReceiveChooserDialog dialog) {
+ private void doReceive (ReceiveChooserDialog dialog)
+ {
string filename = "";
currentPaths.receiveTo = dialog.path;
if (dialog.protocolCombo.get_active () == 0) { // get the filename for xmodem
@@ -596,16 +616,16 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
Rzwrapper.Protocol protocol;
switch (dialog.protocolCombo.get_active ()) {
- case 0:
- protocol = Rzwrapper.Protocol.XMODEM;
- break;
- case 1:
- protocol = Rzwrapper.Protocol.YMODEM;
- break;
- case 2:
- default:
- protocol = Rzwrapper.Protocol.ZMODEM;
- break;
+ case 0:
+ protocol = Rzwrapper.Protocol.XMODEM;
+ break;
+ case 1:
+ protocol = Rzwrapper.Protocol.YMODEM;
+ break;
+ case 2:
+ default:
+ protocol = Rzwrapper.Protocol.ZMODEM;
+ break;
}
rz = new Rzwrapper (protocol, serialConnection, dialog.path, filename);
if (rz.running) {
@@ -616,13 +636,15 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- public void receiveComplete (GLib.Object o) {
+ public void receiveComplete (GLib.Object o)
+ {
rz.updateStatus.disconnect (receiveProgressDialog.updateStatus);
receiveProgressDialog.transferCanceled.disconnect (rz.transferCanceled);
receiveProgressDialog.hide ();
}
- public void record (ToggleToolButton button) {
+ public void record (ToggleToolButton button)
+ {
if (button.get_active ()) {
if (!ensureConnected ()) {
button.set_active (false);
@@ -641,11 +663,13 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- public void stopRecording (moserial.RecordDialog dialog) {
+ public void stopRecording (moserial.RecordDialog dialog)
+ {
recordButton.set_active (false); // this generates recordButton.clicked signal
}
- public void startRecording (moserial.RecordDialog dialog, string filename,
moserial.SerialStreamRecorder.Direction direction) {
+ public void startRecording (moserial.RecordDialog dialog, string filename,
moserial.SerialStreamRecorder.Direction direction)
+ {
try {
streamRecorder.open (filename, direction);
currentPaths.recordTo = MoUtils.getParentFolder (filename);
@@ -660,16 +684,19 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- public bool recordTimeout () {
+ public bool recordTimeout ()
+ {
recordButton.set_active (false);
return false;
}
- public void showWindow () {
+ public void showWindow ()
+ {
gtkWindow.show_all ();
}
- private void updateSettings (SettingsDialog d, Settings newSettings) {
+ private void updateSettings (SettingsDialog d, Settings newSettings)
+ {
currentSettings = newSettings;
statusbar.pop (statusbarContext);
statusbar.push (statusbarContext, currentSettings.getStatusbarString (false));
@@ -677,7 +704,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
profileChanged = true;
}
- private void updateOutgoingInputArea () {
+ private void updateOutgoingInputArea ()
+ {
if (currentSettings.accessMode == READONLY) {
entry.set_sensitive (false);
sendButton.set_sensitive (false);
@@ -687,7 +715,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void updatePreferences (PreferencesDialog ? d, Preferences newPreferences) {
+ private void updatePreferences (PreferencesDialog ? d, Preferences newPreferences)
+ {
currentPreferences = newPreferences;
string font;
if (currentPreferences.useSystemMonospaceFont)
@@ -707,42 +736,51 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
int weight = (int) fd.get_weight ();
var style = """
- .TextviewColor text {
- color: %s;
- background-color: %s;
- }
- .TextInputColor {
- color: %s;
- background-color: %s;
- }
- .TextFont {
- font-family: %s;
- font-size: %d%s;
- font-weight: %d;
- }
+ .TextviewColor text {
+ color:
+ %s;
+ background-color:
+ %s;
+ }
+ .TextInputColor {
+color:
+ %s;
+background-color:
+ %s;
+ }
+ .TextFont {
+font-family:
+ %s;
+font-size:
+ %d%s;
+font-weight:
+ %d;
+ }
""".printf (
- currentPreferences.fontColor,
- currentPreferences.backgroundColor,
- currentPreferences.fontColor,
- currentPreferences.backgroundColor,
- family,
- size,
- unit,
- weight
- );
+ currentPreferences.fontColor,
+ currentPreferences.backgroundColor,
+ currentPreferences.fontColor,
+ currentPreferences.backgroundColor,
+ family,
+ size,
+ unit,
+ weight
+ );
var css_provider = new Gtk.CssProvider ();
- try {
+ try
+ {
css_provider.load_from_data (style, -1);
- } catch (GLib.Error e) {
+ } catch (GLib.Error e)
+ {
warning ("Failed to parse CSS style : %s", e.message);
}
Gtk.StyleContext.add_provider_for_screen (
Gdk.Screen.get_default (),
- css_provider,
- Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
+ css_provider,
+ Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
);
echoTag.foreground = currentPreferences.highlightColor;
@@ -751,26 +789,31 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
profileChanged = true;
}
- private void showSettingsDialog (GLib.Object o) {
+ private void showSettingsDialog (GLib.Object o)
+ {
settingsDialog.show (currentSettings);
}
- private void showPreferencesDialog (GLib.Object o) {
+ private void showPreferencesDialog (GLib.Object o)
+ {
preferencesDialog.show (currentPreferences, recordButton.get_active ());
}
- public bool ensureConnected () {
+ public bool ensureConnected ()
+ {
if (!connectButton.get_active ())
connectButton.set_active (true);
return connectButton.get_active ();
}
- public void ensureDisconnected () {
+ public void ensureDisconnected ()
+ {
if (connectButton.get_active ())
connectButton.set_active (false);
}
- private bool startConnection () {
+ private bool startConnection ()
+ {
if (!(serialConnection.doConnect (currentSettings))) {
connectButton.set_active (false);
var dialog = new MessageDialog (gtkWindow, DialogFlags.DESTROY_WITH_PARENT, MessageType.ERROR,
ButtonsType.CLOSE, "%s: %s", _("Error: Could not open device"), currentSettings.device);
@@ -795,7 +838,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
return true;
}
- private void connectButtonClick (ToggleToolButton button) {
+ private void connectButtonClick (ToggleToolButton button)
+ {
if (button.get_active ()) {
startConnection ();
} else {
@@ -817,7 +861,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private bool showSerialStatus () {
+ private bool showSerialStatus ()
+ {
if (!serialConnection.isConnected ()) {
return true;
}
@@ -830,7 +875,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
return true;
}
- private void updateIncoming (SerialConnection sc, uchar[] data, int size) {
+ private void updateIncoming (SerialConnection sc, uchar[] data, int size)
+ {
if (rz.running) {
for (int x = 0; x < size; x++) {
rz.writeChar (data[x]);
@@ -897,7 +943,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void inputModeChanged (ComboBox inputModeCombo) {
+ private void inputModeChanged (ComboBox inputModeCombo)
+ {
if (inputModeCombo.get_active () == inputModeValues.HEX) {
outgoing_notebook.set_current_page (1);
profile.setNotebookTab (true, 1);
@@ -909,19 +956,23 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void lineEndChanged (ComboBox lineEndCombo) {
+ private void lineEndChanged (ComboBox lineEndCombo)
+ {
profile.setInputLineEnd (lineEndCombo.get_active ());
}
- private void showHelpButton (ToolButton button) {
+ private void showHelpButton (ToolButton button)
+ {
showHelp ();
}
- private void showHelpAction () {
+ private void showHelpAction ()
+ {
showHelp ();
}
- private void showHelp () {
+ private void showHelp ()
+ {
try {
show_uri_on_window (null, "help:moserial", Gdk.CURRENT_TIME);
} catch (GLib.Error e) {
@@ -929,7 +980,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void showAboutDialog () {
+ private void showAboutDialog ()
+ {
string license_trans = _(license[0]) + "\n" + _(license[1]) + "\n" + _(license[2]);
@@ -947,19 +999,22 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
null);
}
- private void quitSizeSave () {
+ private void quitSizeSave ()
+ {
windowSizeSave ();
quitSave ();
}
- private bool deleteSaveSize () {
+ private bool deleteSaveSize ()
+ {
windowSizeSave ();
quitSave ();
Gtk.main_quit ();
return true;
}
- private bool keyPress (Widget widget, EventKey key) {
+ private bool keyPress (Widget widget, EventKey key)
+ {
// GLib.print("key:%x\r\n",key.keyval);
if (key.keyval == Gdk.keyval_from_name ("Escape")) {
AutoScroll.scroll (va1);
@@ -974,7 +1029,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
return false;
}
- private void windowSizeSave () {
+ private void windowSizeSave ()
+ {
int width = 0;
int height = 0;
@@ -984,7 +1040,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
profile.saveWindowPanedPosition (pos);
}
- private void quitSave () {
+ private void quitSave ()
+ {
currentPreferences.saveToProfile (profile);
currentSettings.saveToProfile (profile);
currentPaths.saveToProfile (profile);
@@ -1005,7 +1062,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
Gtk.main_quit ();
}
- private void saveProfile () {
+ private void saveProfile ()
+ {
currentPreferences.saveToProfile (profile);
currentSettings.saveToProfile (profile);
currentPaths.saveToProfile (profile);
@@ -1023,7 +1081,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void saveProfileAs () {
+ private void saveProfileAs ()
+ {
var dialog = new FileChooserDialog (null, gtkWindow, Gtk.FileChooserAction.SAVE);
dialog.add_buttons ("gtk-cancel", Gtk.ResponseType.CANCEL, "gtk-save", Gtk.ResponseType.ACCEPT,
null);
dialog.set_do_overwrite_confirmation (true);
@@ -1037,11 +1096,13 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
saveProfile ();
}
- private void loadProfileOnStartup (string profileFilename) {
+ private void loadProfileOnStartup (string profileFilename)
+ {
applyProfile (profileFilename);
}
- private void loadProfile () {
+ private void loadProfile ()
+ {
var dialog = new FileChooserDialog (null, gtkWindow, Gtk.FileChooserAction.OPEN);
dialog.add_buttons ("gtk-cancel", Gtk.ResponseType.CANCEL, "gtk-open", Gtk.ResponseType.ACCEPT,
null);
dialog.set_local_only (false);
@@ -1052,7 +1113,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
dialog.destroy ();
}
- private void copy () {
+ private void copy ()
+ {
if (gtkWindow.get_focus () == (Gtk.Widget)outgoingAsciiTextView || gtkWindow.get_focus () ==
(Gtk.Widget)incomingAsciiTextView || gtkWindow.get_focus () == (Gtk.Widget)outgoingHexTextView ||
gtkWindow.get_focus () == (Gtk.Widget)incomingHexTextView) {
TextView tv = (TextView) gtkWindow.get_focus ();
tv.buffer.copy_clipboard (Gtk.Clipboard.get (Gdk.SELECTION_CLIPBOARD));
@@ -1061,13 +1123,15 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void cut () {
+ private void cut ()
+ {
if (gtkWindow.get_focus () == (Gtk.Widget)entry) {
entry.cut_clipboard ();
}
}
- private void editMenu () {
+ private void editMenu ()
+ {
if (gtkWindow.get_focus () == (Gtk.Widget)outgoingAsciiTextView || gtkWindow.get_focus () ==
(Gtk.Widget)incomingAsciiTextView || gtkWindow.get_focus () == (Gtk.Widget)outgoingHexTextView ||
gtkWindow.get_focus () == (Gtk.Widget)incomingHexTextView) {
cutMenuItem.set_sensitive (false);
TextView tv = (TextView) gtkWindow.get_focus ();
@@ -1089,7 +1153,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void paste () {
+ private void paste ()
+ {
entry.paste_clipboard ();
if (!entry.has_focus) {
entry.grab_focus ();
@@ -1097,7 +1162,8 @@ public class moserial.MainWindow : Gtk.Window // Have to extend Gtk.Winow to get
}
}
- private void clear () {
+ private void clear ()
+ {
this.clearOutgoing ();
this.clearIncoming ();
entry.set_text ("");
diff --git a/src/MoUtils.vala b/src/MoUtils.vala
index 6776f80..b08bdaa 100644
--- a/src/MoUtils.vala
+++ b/src/MoUtils.vala
@@ -20,8 +20,10 @@
using GLib;
using Gtk;
-public class MoUtils : GLib.Object {
- public static GLib.File newFile (string path) {
+public class MoUtils : GLib.Object
+{
+ public static GLib.File newFile (string path)
+ {
string uri;
if ("://" in path)
uri = path;
@@ -30,12 +32,14 @@ public class MoUtils : GLib.Object {
return File.new_for_uri (uri);
}
- public static bool fileExists (string path) {
+ public static bool fileExists (string path)
+ {
GLib.File file = newFile (path);
return file.query_exists (null);
}
- public static int64 fileSize (string path) {
+ public static int64 fileSize (string path)
+ {
GLib.File file = newFile (path);
try {
GLib.FileInfo info = file.query_info (FileAttribute.STANDARD_SIZE, 0, null);
@@ -46,13 +50,15 @@ public class MoUtils : GLib.Object {
return 0;
}
- public static string getParentFolder (string path) {
+ public static string getParentFolder (string path)
+ {
GLib.File file = newFile (path);
GLib.File parent = file.get_parent ();
return parent.get_parse_name ();
}
- public static string ? getKeyString (Profile profile, string group, string key) {
+ public static string ? getKeyString (Profile profile, string group, string key)
+ {
string ? result = null;
try {
result = profile.keyFile.get_string (group, key);
@@ -62,7 +68,8 @@ public class MoUtils : GLib.Object {
return result;
}
- public static int getKeyInteger (Profile profile, string group, string key, int default_val) {
+ public static int getKeyInteger (Profile profile, string group, string key, int default_val)
+ {
int result = default_val;
try {
result = profile.keyFile.get_integer (group, key);
@@ -72,7 +79,8 @@ public class MoUtils : GLib.Object {
return result;
}
- public static bool getKeyBoolean (Profile profile, string group, string key, bool default_val) {
+ public static bool getKeyBoolean (Profile profile, string group, string key, bool default_val)
+ {
bool result = default_val;
try {
result = profile.keyFile.get_boolean (group, key);
@@ -82,7 +90,8 @@ public class MoUtils : GLib.Object {
return result;
}
- public static string ? getLastMessage (string ? messages) {
+ public static string ? getLastMessage (string ? messages)
+ {
string ? message = null;
string ? escaped = messages.escape ("");
escaped = InputParser.statusReplace (escaped);
@@ -95,7 +104,8 @@ public class MoUtils : GLib.Object {
return message;
}
- public static void populateComboBox (ComboBox Combo, string[] val_array, bool render_cell = true) {
+ public static void populateComboBox (ComboBox Combo, string[] val_array, bool render_cell = true)
+ {
Gtk.ListStore Model = new Gtk.ListStore (1, typeof (string));
foreach (string val_item in val_array) {
TreeIter iter;
diff --git a/src/Preferences.vala b/src/Preferences.vala
index 1480fff..1f49d17 100644
--- a/src/Preferences.vala
+++ b/src/Preferences.vala
@@ -18,7 +18,8 @@
*/
using GLib;
-public class Preferences : GLib.Object {
+public class Preferences : GLib.Object
+{
public static bool DEFAULT_USE_SYSTEM_MONOSPACE_FONT = true;
public static string DEFAULT_FONT = "Monospace 10";
public static string DEFAULT_FONT_COLOR = "black";
@@ -35,7 +36,8 @@ public class Preferences : GLib.Object {
public bool enableTimeout { get; construct; }
public int timeout { get; construct; }
- public Preferences (bool useSystemMonospaceFont, string ? font, string ? fontColor, string ?
backgroundColor, string ? highlightColor, bool recordLaunch, bool enableTimeout, int timeout) {
+ public Preferences (bool useSystemMonospaceFont, string ? font, string ? fontColor, string ?
backgroundColor, string ? highlightColor, bool recordLaunch, bool enableTimeout, int timeout)
+ {
GLib.Object (useSystemMonospaceFont: useSystemMonospaceFont,
font: font,
recordLaunch: recordLaunch,
@@ -56,7 +58,8 @@ public class Preferences : GLib.Object {
if (highlightColor == null)
highlightColor = DEFAULT_HIGHLIGHT_COLOR;
}
- public static string getSystemDefaultMonospaceFont () {
+ public static string getSystemDefaultMonospaceFont ()
+ {
var settings = new GLib.Settings ("org.gnome.desktop.interface");
string value = settings.get_string ("monospace-font-name");
@@ -69,13 +72,15 @@ public class Preferences : GLib.Object {
return value;
}
- public static Gdk.RGBA getGdkRGBA (string color) {
+ public static Gdk.RGBA getGdkRGBA (string color)
+ {
Gdk.RGBA c = Gdk.RGBA ();
c.parse (color);
return c;
}
- public void toString () {
+ public void toString ()
+ {
stdout.printf ("useSystemMonospaceFont: ");
if (useSystemMonospaceFont)
stdout.printf ("true\n");
@@ -92,7 +97,8 @@ public class Preferences : GLib.Object {
stdout.printf ("false\n");
}
- public void saveToProfile (Profile profile) {
+ public void saveToProfile (Profile profile)
+ {
profile.keyFile.set_boolean ("preferences", "use_system_monospace_font", useSystemMonospaceFont);
profile.keyFile.set_string ("preferences", "font", font);
profile.keyFile.set_string ("preferences", "font_color", fontColor);
@@ -103,7 +109,8 @@ public class Preferences : GLib.Object {
profile.keyFile.set_integer ("preferences", "timeout", timeout);
}
- public static Preferences loadFromProfile (Profile profile) {
+ public static Preferences loadFromProfile (Profile profile)
+ {
bool useSystemMonospaceFont;
string ? font = null;
string ? fontColor = null;
diff --git a/src/PreferencesDialog.vala b/src/PreferencesDialog.vala
index c033440..a58c0e8 100644
--- a/src/PreferencesDialog.vala
+++ b/src/PreferencesDialog.vala
@@ -18,7 +18,8 @@
*/
using Gtk;
-public class moserial.PreferencesDialog : GLib.Object {
+public class moserial.PreferencesDialog : GLib.Object
+{
private Dialog dialog;
private Button cancelButton;
private Button okButton;
@@ -32,7 +33,8 @@ public class moserial.PreferencesDialog : GLib.Object {
private SpinButton timeout;
public signal void updatePreferences (Preferences preferences);
- public PreferencesDialog (Window parent) {
+ public PreferencesDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "preferences.ui");
dialog = (Dialog) builder.get_object ("preferences_dialog");
@@ -64,7 +66,8 @@ public class moserial.PreferencesDialog : GLib.Object {
dialog.delete_event.connect (hide);
}
- public void ok (Button button) {
+ public void ok (Button button)
+ {
hide ();
bool pSystemFont;
string pFont;
@@ -99,7 +102,8 @@ public class moserial.PreferencesDialog : GLib.Object {
this.updatePreferences (preferences);
}
- public void show (Preferences preferences, bool recording) {
+ public void show (Preferences preferences, bool recording)
+ {
if (preferences.useSystemMonospaceFont) {
fontButton.set_sensitive (false);
systemFont.set_active (true);
@@ -131,24 +135,28 @@ public class moserial.PreferencesDialog : GLib.Object {
dialog.show_all ();
}
- public void cancel (Widget w) {
+ public void cancel (Widget w)
+ {
// currentPreferences=null;
hide ();
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- public void systemFontToggled (ToggleButton button) {
+ public void systemFontToggled (ToggleButton button)
+ {
if (button.get_active ())
fontButton.set_sensitive (false);
else
fontButton.set_sensitive (true);
}
- public void enableTimeoutToggled (ToggleButton button) {
+ public void enableTimeoutToggled (ToggleButton button)
+ {
if (button.get_active ())
timeout.set_sensitive (true);
else
diff --git a/src/Profile.vala b/src/Profile.vala
index 8cc5db7..f533124 100644
--- a/src/Profile.vala
+++ b/src/Profile.vala
@@ -19,23 +19,27 @@
using Gtk;
-public class Profile : GLib.Object {
+public class Profile : GLib.Object
+{
public KeyFile keyFile;
construct {
keyFile = new KeyFile ();
}
- public void saveWindowSize (int w, int h) {
+ public void saveWindowSize (int w, int h)
+ {
if (w > 0)
keyFile.set_integer ("window", "width", w);
if (h > 0)
keyFile.set_integer ("window", "height", h);
}
- public void saveWindowPanedPosition (int pos) {
+ public void saveWindowPanedPosition (int pos)
+ {
keyFile.set_integer ("window", "paned_pos", pos);
}
- public int getWindowPanedPosition () {
+ public int getWindowPanedPosition ()
+ {
try {
return keyFile.get_integer ("window", "paned_pos");
} catch (GLib.KeyFileError e) {
@@ -43,7 +47,8 @@ public class Profile : GLib.Object {
}
}
- public int getWindowWidth () {
+ public int getWindowWidth ()
+ {
try {
return keyFile.get_integer ("window", "width");
} catch (GLib.KeyFileError e) {
@@ -51,7 +56,8 @@ public class Profile : GLib.Object {
}
}
- public int getWindowHeight () {
+ public int getWindowHeight ()
+ {
try {
return keyFile.get_integer ("window", "height");
} catch (GLib.KeyFileError e) {
@@ -59,7 +65,8 @@ public class Profile : GLib.Object {
}
}
- public void setNotebookTab (bool outgoing, uint tab) {
+ public void setNotebookTab (bool outgoing, uint tab)
+ {
string n = "incoming_tab";
if (outgoing) {
n = "outgoing_tab";
@@ -72,7 +79,8 @@ public class Profile : GLib.Object {
}
}
- public int getNotebookTab (bool outgoing) {
+ public int getNotebookTab (bool outgoing)
+ {
string n = "incoming_tab";
if (outgoing) {
n = "outgoing_tab";
@@ -88,11 +96,13 @@ public class Profile : GLib.Object {
}
}
- public void setInputModeHex (bool hex) {
+ public void setInputModeHex (bool hex)
+ {
keyFile.set_boolean ("window", "input_mode_hex", hex);
}
- public bool getInputModeHex () {
+ public bool getInputModeHex ()
+ {
try {
return keyFile.get_boolean ("window", "input_mode_hex");
} catch (GLib.KeyFileError e) {
@@ -100,11 +110,13 @@ public class Profile : GLib.Object {
}
}
- public void setInputLineEnd (int end) {
+ public void setInputLineEnd (int end)
+ {
keyFile.set_integer ("window", "input_line_end", end);
}
- public int getInputLineEnd () {
+ public int getInputLineEnd ()
+ {
try {
return keyFile.get_integer ("window", "input_line_end");
} catch (GLib.KeyFileError e) {
@@ -112,11 +124,13 @@ public class Profile : GLib.Object {
}
}
- public void setInputString (string s) {
+ public void setInputString (string s)
+ {
keyFile.set_string ("window", "input_string", s);
}
- public string getInputString () {
+ public string getInputString ()
+ {
try {
return keyFile.get_string ("window", "input_string");
} catch (GLib.KeyFileError e) {
@@ -124,7 +138,8 @@ public class Profile : GLib.Object {
}
}
- public bool load (string ? filename, Gtk.Window window) {
+ public bool load (string ? filename, Gtk.Window window)
+ {
string f;
bool default_profile = false;
@@ -150,12 +165,14 @@ public class Profile : GLib.Object {
}
}
- public void toString () {
+ public void toString ()
+ {
size_t s;
stdout.printf ("%s\n", keyFile.to_data (out s));
}
- public void save (string ? filename, Gtk.Window window) {
+ public void save (string ? filename, Gtk.Window window)
+ {
GLib.File ? file;
FileOutputStream ? fos;
string f;
diff --git a/src/ReceiveChooserDialog.vala b/src/ReceiveChooserDialog.vala
index 3f365b5..c841926 100644
--- a/src/ReceiveChooserDialog.vala
+++ b/src/ReceiveChooserDialog.vala
@@ -18,14 +18,16 @@
*/
using Gtk;
-public class moserial.ReceiveChooserDialog : GLib.Object {
+public class moserial.ReceiveChooserDialog : GLib.Object
+{
private FileChooserDialog dialog;
public ComboBox protocolCombo;
public signal void startTransfer ();
public string path;
- public ReceiveChooserDialog (Window parent) {
+ public ReceiveChooserDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "receive_chooser.ui");
dialog = (FileChooserDialog) builder.get_object ("receive_chooser_dialog");
@@ -40,18 +42,21 @@ public class moserial.ReceiveChooserDialog : GLib.Object {
dialog.response.connect (response);
}
- public void show (string ? folder) {
+ public void show (string ? folder)
+ {
if ((folder != null) && MoUtils.fileExists (folder))
dialog.set_current_folder (folder);
dialog.run ();
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- private void response (Widget w, int r) {
+ private void response (Widget w, int r)
+ {
if (r == Gtk.ResponseType.CANCEL) {
hide ();
} else if (r == Gtk.ResponseType.ACCEPT) {
diff --git a/src/ReceiveProgressDialog.vala b/src/ReceiveProgressDialog.vala
index 19fd77c..57619de 100644
--- a/src/ReceiveProgressDialog.vala
+++ b/src/ReceiveProgressDialog.vala
@@ -18,14 +18,16 @@
*/
using Gtk;
-public class moserial.ReceiveProgressDialog : GLib.Object {
+public class moserial.ReceiveProgressDialog : GLib.Object
+{
private Dialog dialog;
private Button cancelButton;
private Gtk.Label status;
private ProgressBar progressBar;
public signal void transferCanceled ();
- public ReceiveProgressDialog (Window parent) {
+ public ReceiveProgressDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "receive_progress.ui");
dialog = (Dialog) builder.get_object ("receive_progress_dialog");
@@ -36,23 +38,27 @@ public class moserial.ReceiveProgressDialog : GLib.Object {
progressBar = (ProgressBar) builder.get_object ("receive_progressbar");
dialog.delete_event.connect (hide);
}
-
- public void show () {
+
+ public void show ()
+ {
dialog.show_all ();
status.set_text ("");
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- public void updateStatus (GLib.Object o, string newStatus) {
+ public void updateStatus (GLib.Object o, string newStatus)
+ {
status.set_text (newStatus);
progressBar.pulse ();
}
- public void cancel (GLib.Object o) {
+ public void cancel (GLib.Object o)
+ {
// TODO: make canceling transfers actually work
transferCanceled ();
}
diff --git a/src/RecordDialog.vala b/src/RecordDialog.vala
index a2e350e..f256de3 100644
--- a/src/RecordDialog.vala
+++ b/src/RecordDialog.vala
@@ -18,7 +18,8 @@
*/
using Gtk;
-public class moserial.RecordDialog : GLib.Object {
+public class moserial.RecordDialog : GLib.Object
+{
private FileChooserDialog dialog;
private Button cancelButton;
private ComboBox streamCombo;
@@ -27,8 +28,9 @@ public class moserial.RecordDialog : GLib.Object {
public signal void stopRecording ();
public SerialStreamRecorder.Direction direction;
-
- public RecordDialog (Window parent){
+
+ public RecordDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "record_dialog.ui");
dialog = (FileChooserDialog) builder.get_object ("record_dialog");
@@ -48,18 +50,21 @@ public class moserial.RecordDialog : GLib.Object {
fileName = null;
}
- public void show (string ? folder) {
+ public void show (string ? folder)
+ {
if ((folder != null) && MoUtils.fileExists (folder))
dialog.set_current_folder (folder);
dialog.run ();
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- private void response (Widget w, int r) {
+ private void response (Widget w, int r)
+ {
if (r == Gtk.ResponseType.CANCEL) {
fileName = null;
hide ();
@@ -67,16 +72,16 @@ public class moserial.RecordDialog : GLib.Object {
} else if (r == Gtk.ResponseType.ACCEPT) {
fileName = dialog.get_filename ();
switch (streamCombo.get_active ()) {
- case 0:
- default:
- direction = SerialStreamRecorder.Direction.INCOMING;
- break;
- case 1:
- direction = SerialStreamRecorder.Direction.OUTGOING;
- break;
- case 2:
- direction = SerialStreamRecorder.Direction.BOTH;
- break;
+ case 0:
+ default:
+ direction = SerialStreamRecorder.Direction.INCOMING;
+ break;
+ case 1:
+ direction = SerialStreamRecorder.Direction.OUTGOING;
+ break;
+ case 2:
+ direction = SerialStreamRecorder.Direction.BOTH;
+ break;
}
hide ();
startRecording (this.fileName, direction);
diff --git a/src/Rzwrapper.vala b/src/Rzwrapper.vala
index 02bcd3a..f53abcb 100644
--- a/src/Rzwrapper.vala
+++ b/src/Rzwrapper.vala
@@ -18,11 +18,13 @@
*/
// Class for communicating with the rz program
-public class moserial.Rzwrapper : GLib.Object {
+public class moserial.Rzwrapper : GLib.Object
+{
public enum Protocol { XMODEM, YMODEM, ZMODEM, NULL }
public const string[] ProtocolStrings = { GLib.N_ ("Xmodem"),
GLib.N_ ("Ymodem"),
- GLib.N_ ("Zmodem") };
+ GLib.N_ ("Zmodem")
+ };
public Protocol protocol { get; construct; }
public SerialConnection ? sc { get; construct; }
@@ -39,16 +41,19 @@ public class moserial.Rzwrapper : GLib.Object {
public bool running = false;
public string ? path { get; construct; }
public string filename { get; construct; }
- public Rzwrapper (Protocol ? protocol, SerialConnection ? sc, string ? p, string ? filename) {
+ public Rzwrapper (Protocol ? protocol, SerialConnection ? sc, string ? p, string ? filename)
+ {
Protocol pro = protocol;
GLib.Object (protocol: pro,
sc: sc, path: p,
filename: filename);
}
construct {
- if (protocol == Protocol.NULL || path == null) {
+ if (protocol == Protocol.NULL || path == null)
+ {
running = false;
- } else {
+ } else
+ {
string[] argv;
if (protocol == Protocol.XMODEM)
argv = new string[4];
@@ -56,16 +61,16 @@ public class moserial.Rzwrapper : GLib.Object {
argv = new string[3];
argv[0] = "rz";
switch (protocol) {
- case Protocol.XMODEM:
- argv[1] = "--xmodem";
- break;
- case Protocol.YMODEM:
- argv[1] = "--ymodem";
- break;
- case Protocol.ZMODEM:
- default:
- argv[1] = "--zmodem";
- break;
+ case Protocol.XMODEM:
+ argv[1] = "--xmodem";
+ break;
+ case Protocol.YMODEM:
+ argv[1] = "--ymodem";
+ break;
+ case Protocol.ZMODEM:
+ default:
+ argv[1] = "--zmodem";
+ break;
}
argv[2] = "-vv";
if (protocol == Protocol.XMODEM)
@@ -102,7 +107,8 @@ public class moserial.Rzwrapper : GLib.Object {
}
}
}
- public void writeChar (uchar byte) {
+ public void writeChar (uchar byte)
+ {
if (running) {
size_t bytesWritten;
char[] b = new char[1];
@@ -121,7 +127,8 @@ public class moserial.Rzwrapper : GLib.Object {
}
}
- public void flush () {
+ public void flush ()
+ {
if (running) {
try {
if (running)
@@ -133,7 +140,8 @@ public class moserial.Rzwrapper : GLib.Object {
}
}
- private bool readError (GLib.IOChannel source, GLib.IOCondition condition) {
+ private bool readError (GLib.IOChannel source, GLib.IOCondition condition)
+ {
if (running) {
char[] m_buf = new char[1000];
string message = "";
@@ -169,7 +177,8 @@ public class moserial.Rzwrapper : GLib.Object {
return false;
}
- public void transferCanceled (GLib.Object o) {
+ public void transferCanceled (GLib.Object o)
+ {
// send cancel string to remote client and rz
if (running) {
@@ -185,12 +194,14 @@ public class moserial.Rzwrapper : GLib.Object {
}
}
- private bool shutdown_timeout () {
+ private bool shutdown_timeout ()
+ {
shutdown ();
return false;
}
- private void shutdown () {
+ private void shutdown ()
+ {
if (running) {
running = false;
GLib.Source.remove (outputChannelId);
@@ -200,7 +211,8 @@ public class moserial.Rzwrapper : GLib.Object {
}
}
- private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition) {
+ private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition)
+ {
if (running) {
char[] m_buf = new char[1000];
diff --git a/src/SendChooserDialog.vala b/src/SendChooserDialog.vala
index 812432f..3732e72 100644
--- a/src/SendChooserDialog.vala
+++ b/src/SendChooserDialog.vala
@@ -18,13 +18,15 @@
*/
using Gtk;
-public class moserial.SendChooserDialog : GLib.Object {
+public class moserial.SendChooserDialog : GLib.Object
+{
private FileChooserDialog dialog;
public ComboBox protocolCombo;
public signal void startTransfer ();
public string filename;
-
- public SendChooserDialog (Window parent) {
+
+ public SendChooserDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "send_chooser_dialog.ui");
dialog = (FileChooserDialog) builder.get_object ("send_chooser_dialog");
@@ -39,18 +41,21 @@ public class moserial.SendChooserDialog : GLib.Object {
dialog.response.connect (response);
}
- public void show (string ? folder) {
+ public void show (string ? folder)
+ {
if ((folder != null) && MoUtils.fileExists (folder))
dialog.set_current_folder (folder);
dialog.run ();
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- private void response (Widget w, int r) {
+ private void response (Widget w, int r)
+ {
if (r == Gtk.ResponseType.CANCEL) {
hide ();
} else if (r == Gtk.ResponseType.ACCEPT) {
diff --git a/src/SendProgressDialog.vala b/src/SendProgressDialog.vala
index 86a8ce8..059f4a1 100644
--- a/src/SendProgressDialog.vala
+++ b/src/SendProgressDialog.vala
@@ -18,14 +18,16 @@
*/
using Gtk;
-public class moserial.SendProgressDialog : GLib.Object {
+public class moserial.SendProgressDialog : GLib.Object
+{
private Dialog dialog;
private Button cancelButton;
private Gtk.Label status;
private ProgressBar progressBar;
public signal void transferCanceled ();
- public SendProgressDialog (Window parent) {
+ public SendProgressDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "send_progress_dialog.ui");
dialog = (Dialog) builder.get_object ("send_progress_dialog");
@@ -36,22 +38,26 @@ public class moserial.SendProgressDialog : GLib.Object {
progressBar = (ProgressBar) builder.get_object ("send_progressbar");
dialog.delete_event.connect (hide);
}
- public void show () {
+ public void show ()
+ {
dialog.show_all ();
status.set_text (_("Waiting for remote host"));
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- public void updateStatus (GLib.Object o, string newStatus) {
+ public void updateStatus (GLib.Object o, string newStatus)
+ {
status.set_text (newStatus);
progressBar.pulse ();
}
- public void cancel (GLib.Object o) {
+ public void cancel (GLib.Object o)
+ {
// TODO: make canceling transfers actually work
transferCanceled ();
}
diff --git a/src/SerialConnection.vala b/src/SerialConnection.vala
index 963b1a7..2e29e84 100644
--- a/src/SerialConnection.vala
+++ b/src/SerialConnection.vala
@@ -20,7 +20,8 @@
using Posix;
using Linux;
-public class moserial.SerialConnection : GLib.Object {
+public class moserial.SerialConnection : GLib.Object
+{
private bool connected;
public ulong tx = 0;
public ulong rx = 0;
@@ -45,14 +46,16 @@ public class moserial.SerialConnection : GLib.Object {
GLib.N_ ("LF end"),
GLib.N_ ("TAB end"),
GLib.N_ ("ESC end"),
- GLib.N_ ("No end") };
+ GLib.N_ ("No end")
+ };
public const string[] LineEndValues = { "\r\n", "\r", "\n", "\t", "\x1b", "" };
public const int max_buf_size = 128;
uint ? sourceId;
bool localEcho;
- public bool doConnect (Settings settings) {
+ public bool doConnect (Settings settings)
+ {
if (settings.accessMode == Settings.AccessMode.READWRITE)
flags = Posix.O_RDWR;
@@ -81,7 +84,8 @@ public class moserial.SerialConnection : GLib.Object {
return true;
}
- public void sendByte (uchar byte) {
+ public void sendByte (uchar byte)
+ {
if (connected) {
uchar[] b = new uchar[1];
b[0] = byte;
@@ -92,7 +96,8 @@ public class moserial.SerialConnection : GLib.Object {
}
}
- public void sendBytes (char[] bytes, size_t size) {
+ public void sendBytes (char[] bytes, size_t size)
+ {
if (connected) {
size_t x = Posix.write (m_fd, bytes, size);
Posix.tcdrain (m_fd);
@@ -100,7 +105,8 @@ public class moserial.SerialConnection : GLib.Object {
}
}
- public void doDisconnect () {
+ public void doDisconnect ()
+ {
if (connected) {
GLib.Source.remove (sourceId);
sourceId = null;
@@ -121,11 +127,13 @@ public class moserial.SerialConnection : GLib.Object {
}
}
- public bool isConnected () {
+ public bool isConnected ()
+ {
return connected;
}
- private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition) {
+ private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition)
+ {
uchar[] m_buf = new uchar[max_buf_size];
int bytesRead = (int) Posix.read (m_fd, m_buf, max_buf_size);
rx += (ulong) bytesRead;
@@ -147,64 +155,65 @@ public class moserial.SerialConnection : GLib.Object {
return connected;
}
- private void applySettings (Settings settings) {
+ private void applySettings (Settings settings)
+ {
// BaudRate
uint baudRate = 0;
switch (settings.baudRate) {
- case 300:
- baudRate = Posix.B300;
- break;
- case 600:
- baudRate = Posix.B600;
- break;
- case 1200:
- baudRate = Posix.B1200;
- break;
- case 2400:
- baudRate = Posix.B2400;
- break;
- case 4800:
- baudRate = Posix.B4800;
- break;
- case 9600:
- baudRate = Posix.B9600;
- break;
- case 19200:
- baudRate = Posix.B19200;
- break;
- case 38400:
- baudRate = Posix.B38400;
- break;
- case 57600:
- baudRate = Posix.B57600;
- break;
- case 115200:
- baudRate = Posix.B115200;
- break;
- case 230400:
- baudRate = Posix.B230400;
- break;
- case 460800:
- baudRate = Linux.Termios.B460800;
- break;
- case 576000:
- baudRate = Linux.Termios.B576000;
- break;
- case 921600:
- baudRate = Linux.Termios.B921600;
- break;
- case 1000000:
- baudRate = Linux.Termios.B1000000;
- break;
- case 2000000:
- baudRate = Linux.Termios.B2000000;
- break;
- case 3000000:
- baudRate = Linux.Termios.B3000000;
- break;
- default:
- baudRate = settings.baudRate;
- break;
+ case 300:
+ baudRate = Posix.B300;
+ break;
+ case 600:
+ baudRate = Posix.B600;
+ break;
+ case 1200:
+ baudRate = Posix.B1200;
+ break;
+ case 2400:
+ baudRate = Posix.B2400;
+ break;
+ case 4800:
+ baudRate = Posix.B4800;
+ break;
+ case 9600:
+ baudRate = Posix.B9600;
+ break;
+ case 19200:
+ baudRate = Posix.B19200;
+ break;
+ case 38400:
+ baudRate = Posix.B38400;
+ break;
+ case 57600:
+ baudRate = Posix.B57600;
+ break;
+ case 115200:
+ baudRate = Posix.B115200;
+ break;
+ case 230400:
+ baudRate = Posix.B230400;
+ break;
+ case 460800:
+ baudRate = Linux.Termios.B460800;
+ break;
+ case 576000:
+ baudRate = Linux.Termios.B576000;
+ break;
+ case 921600:
+ baudRate = Linux.Termios.B921600;
+ break;
+ case 1000000:
+ baudRate = Linux.Termios.B1000000;
+ break;
+ case 2000000:
+ baudRate = Linux.Termios.B2000000;
+ break;
+ case 3000000:
+ baudRate = Linux.Termios.B3000000;
+ break;
+ default:
+ baudRate = settings.baudRate;
+ break;
}
Posix.cfsetospeed (ref newtio, baudRate);
@@ -218,19 +227,19 @@ public class moserial.SerialConnection : GLib.Object {
dataBits = 8;
switch (dataBits) {
- case 5:
- newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS5;
- break;
- case 6:
- newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS6;
- break;
- case 7:
- newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS7;
- break;
- case 8:
- default:
- newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS8;
- break;
+ case 5:
+ newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS5;
+ break;
+ case 6:
+ newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS6;
+ break;
+ case 7:
+ newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS7;
+ break;
+ case 8:
+ default:
+ newtio.c_cflag = (newtio.c_cflag & ~Posix.CSIZE) | Posix.CS8;
+ break;
}
newtio.c_cflag |= Posix.CLOCAL | Posix.CREAD;
@@ -289,7 +298,8 @@ public class moserial.SerialConnection : GLib.Object {
Posix.ioctl (m_fd, Linux.Termios.TIOCMSET, ref mcs);
}
- public void controlDTR (bool y) {
+ public void controlDTR (bool y)
+ {
int mcs = 0;
Posix.ioctl (m_fd, Linux.Termios.TIOCMGET, out mcs);
if (y) {
@@ -300,7 +310,8 @@ public class moserial.SerialConnection : GLib.Object {
Posix.ioctl (m_fd, Linux.Termios.TIOCMSET, ref mcs);
}
- public void controlRTS (bool y) {
+ public void controlRTS (bool y)
+ {
int mcs = 0;
Posix.ioctl (m_fd, Linux.Termios.TIOCMGET, out mcs);
if (y) {
@@ -311,7 +322,8 @@ public class moserial.SerialConnection : GLib.Object {
Posix.ioctl (m_fd, Linux.Termios.TIOCMSET, ref mcs);
}
- public bool[] getStatus () {
+ public bool[] getStatus ()
+ {
bool mcs[6];
int stat;
Posix.ioctl (m_fd, Linux.Termios.TIOCMGET, out stat);
@@ -343,7 +355,8 @@ public class moserial.SerialConnection : GLib.Object {
return mcs;
}
- public string getBytecountbarString () {
+ public string getBytecountbarString ()
+ {
string r;
if (nonprintable > 0)
diff --git a/src/SerialStreamRecorder.vala b/src/SerialStreamRecorder.vala
index cf65d8e..30966c4 100644
--- a/src/SerialStreamRecorder.vala
+++ b/src/SerialStreamRecorder.vala
@@ -19,7 +19,8 @@
using Gtk;
-public class moserial.SerialStreamRecorder {
+public class moserial.SerialStreamRecorder
+{
private GLib.File ? file;
private string uri;
private bool isOpen = false;
@@ -28,17 +29,20 @@ public class moserial.SerialStreamRecorder {
public enum Direction { INCOMING, OUTGOING, BOTH }
public const string[] DirectionStrings = { GLib.N_ ("Incoming"),
GLib.N_ ("Outgoing"),
- GLib.N_ ("Incoming and Outgoing") };
+ GLib.N_ ("Incoming and Outgoing")
+ };
private Direction direction;
public void open (string filename, Direction direction) throws GLib.Error {
- try {
+ try
+ {
file = File.new_for_path (filename);
fos = file.replace (null, false, GLib.FileCreateFlags.NONE, null);
isOpen = true;
uri = file.get_uri ();
this.direction = direction;
- } catch (GLib.Error e) {
+ } catch (GLib.Error e)
+ {
isOpen = false;
file = null;
fos = null;
@@ -46,7 +50,8 @@ public class moserial.SerialStreamRecorder {
}
}
- private void write (uchar data) {
+ private void write (uchar data)
+ {
if (isOpen) {
uchar[] o = new uchar[1];
o[0] = data;
@@ -58,7 +63,8 @@ public class moserial.SerialStreamRecorder {
}
}
- private void write_array (uchar[] data) {
+ private void write_array (uchar[] data)
+ {
if (isOpen) {
try {
fos.write (data, null);
@@ -68,17 +74,20 @@ public class moserial.SerialStreamRecorder {
}
}
- public void writeOutgoing (uchar data) {
+ public void writeOutgoing (uchar data)
+ {
if (isOpen && (direction == Direction.OUTGOING || direction == Direction.BOTH))
write (data);
}
- public void writeIncoming (uchar[] data) {
+ public void writeIncoming (uchar[] data)
+ {
if (isOpen && (direction == Direction.INCOMING || direction == Direction.BOTH))
write_array (data);
}
- public void close (bool launch) {
+ public void close (bool launch)
+ {
if (isOpen) {
try {
fos.flush (null);
diff --git a/src/Settings.vala b/src/Settings.vala
index 7217d47..84794fc 100644
--- a/src/Settings.vala
+++ b/src/Settings.vala
@@ -19,20 +19,23 @@
using GLib;
-public class Settings : GLib.Object {
+public class Settings : GLib.Object
+{
public enum Parity { NONE, ODD, EVEN, MARK, SPACE }
public const string[] ParityModeStrings = { GLib.N_ ("None"),
GLib.N_ ("Odd"),
GLib.N_ ("Even"),
GLib.N_ ("Mark"),
- GLib.N_ ("Space") };
+ GLib.N_ ("Space")
+ };
public enum Handshake { NONE, HARDWARE, SOFTWARE, BOTH }
public enum AccessMode { READWRITE, READONLY, WRITEONLY }
public const string[] AccessModeStrings = { GLib.N_ ("Read and Write"),
GLib.N_ ("Read Only"),
- GLib.N_ ("Write Only") };
+ GLib.N_ ("Write Only")
+ };
public const string[] DataBitItems = { "5", "6", "7", "8" };
public const string[] StopBitItems = { "1", "2" };
@@ -41,7 +44,8 @@ public class Settings : GLib.Object {
"38400", "57600", "115200",
"230400", "460800", "576000",
"921600", "1000000", "2000000",
- "3000000" };
+ "3000000"
+ };
public static string DEFAULT_DEVICEFILE = "/dev/ttyS0";
public static int DEFAULT_BAUDRATE = 1200;
@@ -59,7 +63,8 @@ public class Settings : GLib.Object {
public Handshake handshake { get; construct; }
public AccessMode accessMode { get; construct; }
public bool localEcho { get; construct; }
- public Settings (string ? device, int baudRate, int dataBits, int stopBits, Parity parity, Handshake
handshake, AccessMode accessMode, bool localEcho) {
+ public Settings (string ? device, int baudRate, int dataBits, int stopBits, Parity parity, Handshake
handshake, AccessMode accessMode, bool localEcho)
+ {
GLib.Object (device: device,
baudRate: baudRate,
dataBits: dataBits,
@@ -81,33 +86,35 @@ public class Settings : GLib.Object {
stopBits = DEFAULT_STOPBITS;
}
- public string parityToChar () {
+ public string parityToChar ()
+ {
switch (parity) {
- case Parity.NONE: {
- /* TRANSLATORS: first letter of "None", a serial port parity setting */
- return _("N");
- }
- case Parity.ODD: {
- /* TRANSLATORS: first letter of "Odd", a serial port parity setting */
- return _("O");
- }
- case Parity.EVEN: {
- /* TRANSLATORS: first letter of "Even", a serial port parity setting */
- return _("E");
- }
- case Parity.MARK: {
- /* TRANSLATORS: first letter of "Mark", a serial port parity setting */
- return _("M");
- }
- case Parity.SPACE: {
- /* TRANSLATORS: first letter of "Space", a serial port parity setting */
- return _("S");
- }
+ case Parity.NONE: {
+ /* TRANSLATORS: first letter of "None", a serial port parity setting */
+ return _("N");
+ }
+ case Parity.ODD: {
+ /* TRANSLATORS: first letter of "Odd", a serial port parity setting */
+ return _("O");
+ }
+ case Parity.EVEN: {
+ /* TRANSLATORS: first letter of "Even", a serial port parity setting */
+ return _("E");
+ }
+ case Parity.MARK: {
+ /* TRANSLATORS: first letter of "Mark", a serial port parity setting */
+ return _("M");
+ }
+ case Parity.SPACE: {
+ /* TRANSLATORS: first letter of "Space", a serial port parity setting */
+ return _("S");
+ }
}
return "?";
}
- public string getStatusbarString (bool open) {
+ public string getStatusbarString (bool open)
+ {
string r;
r = "%s".printf (device);
if (open)
@@ -117,7 +124,8 @@ public class Settings : GLib.Object {
return r;
}
- public void saveToProfile (Profile profile) {
+ public void saveToProfile (Profile profile)
+ {
profile.keyFile.set_string ("port_settings", "device", device);
profile.keyFile.set_integer ("port_settings", "baud_rate", baudRate);
profile.keyFile.set_integer ("port_settings", "data_bits", dataBits);
@@ -128,7 +136,8 @@ public class Settings : GLib.Object {
profile.keyFile.set_boolean ("port_settings", "local_echo", localEcho);
}
- public static Settings loadFromProfile (Profile profile) {
+ public static Settings loadFromProfile (Profile profile)
+ {
string ? device = Settings.DEFAULT_DEVICEFILE;
int baudRate;
int dataBits;
diff --git a/src/SettingsDialog.vala b/src/SettingsDialog.vala
index 9209040..d9c8a2b 100644
--- a/src/SettingsDialog.vala
+++ b/src/SettingsDialog.vala
@@ -20,7 +20,8 @@
using Gtk;
using GLib;
-public class moserial.SettingsDialog : GLib.Object {
+public class moserial.SettingsDialog : GLib.Object
+{
// Does anyone have more than 32 serial ports?
const int max_devices = 32;
@@ -44,7 +45,8 @@ public class moserial.SettingsDialog : GLib.Object {
private Gtk.Entry baudRateInput;
public signal void updateSettings (Settings settings);
- public SettingsDialog (Window parent) {
+ public SettingsDialog (Window parent)
+ {
this.parent = parent;
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "settings_dialog.ui");
@@ -89,7 +91,8 @@ public class moserial.SettingsDialog : GLib.Object {
// CellRenderText on deviceCombo provided by GtkEntry field.
}
- private void populateDevices () {
+ private void populateDevices ()
+ {
List<string> deviceTypes = new List<string> ();
deviceTypes.append ("/dev/ttyAMA");
deviceTypes.append ("/dev/ttyS");
@@ -113,7 +116,8 @@ public class moserial.SettingsDialog : GLib.Object {
}
}
- public void show (Settings settings) {
+ public void show (Settings settings)
+ {
populateDevices ();
this.currentSettings = settings;
loadSettings ();
@@ -121,7 +125,8 @@ public class moserial.SettingsDialog : GLib.Object {
}
// Load the current settings into the dialog
- public void loadSettings () {
+ public void loadSettings ()
+ {
TreeModel t;
TreeIter ti;
bool success;
@@ -177,17 +182,20 @@ public class moserial.SettingsDialog : GLib.Object {
localEcho.set_active (false);
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- public void cancel (Widget w) {
+ public void cancel (Widget w)
+ {
currentSettings = null;
dialog.hide ();
}
- public void ok (Widget w) {
+ public void ok (Widget w)
+ {
string device;
int baudRate;
diff --git a/src/Szwrapper.vala b/src/Szwrapper.vala
index aa8334f..698fe2c 100644
--- a/src/Szwrapper.vala
+++ b/src/Szwrapper.vala
@@ -18,12 +18,14 @@
*/
// Class for communicating with the sz program
-public class moserial.Szwrapper : GLib.Object {
+public class moserial.Szwrapper : GLib.Object
+{
public enum Protocol { XMODEM, YMODEM, ZMODEM, RAW, NULL }
public const string[] ProtocolStrings = { GLib.N_ ("Xmodem"),
GLib.N_ ("Ymodem"),
GLib.N_ ("Zmodem"),
- GLib.N_ ("None (straight binary)") };
+ GLib.N_ ("None (straight binary)")
+ };
public Protocol protocol { get; construct; }
public SerialConnection ? sc { get; construct; }
@@ -40,16 +42,19 @@ public class moserial.Szwrapper : GLib.Object {
public bool running = false;
public string filename { get; construct; }
- public Szwrapper (Protocol ? protocol, SerialConnection ? sc, string ? filename) {
+ public Szwrapper (Protocol ? protocol, SerialConnection ? sc, string ? filename)
+ {
Protocol pro = protocol;
GLib.Object (protocol: pro,
sc: sc,
filename: filename);
}
construct {
- if (protocol == Protocol.NULL || filename == null) {
+ if (protocol == Protocol.NULL || filename == null)
+ {
running = false;
- } else {
+ } else
+ {
string[] argv;
if (protocol == Protocol.RAW) {
argv = new string[2];
@@ -59,16 +64,16 @@ public class moserial.Szwrapper : GLib.Object {
argv = new string[4];
argv[0] = "sz";
switch (protocol) {
- case Protocol.XMODEM:
- argv[1] = "--xmodem";
- break;
- case Protocol.YMODEM:
- argv[1] = "--ymodem";
- break;
- case Protocol.ZMODEM:
- default:
- argv[1] = "--zmodem";
- break;
+ case Protocol.XMODEM:
+ argv[1] = "--xmodem";
+ break;
+ case Protocol.YMODEM:
+ argv[1] = "--ymodem";
+ break;
+ case Protocol.ZMODEM:
+ default:
+ argv[1] = "--zmodem";
+ break;
}
argv[2] = "-vv";
argv[3] = filename;
@@ -106,7 +111,8 @@ public class moserial.Szwrapper : GLib.Object {
}
}
}
- public void writeChar (uchar byte) {
+ public void writeChar (uchar byte)
+ {
if (running) {
size_t bytesWritten;
char[] b = new char[1];
@@ -125,7 +131,8 @@ public class moserial.Szwrapper : GLib.Object {
}
}
- private bool readError (GLib.IOChannel source, GLib.IOCondition condition) {
+ private bool readError (GLib.IOChannel source, GLib.IOCondition condition)
+ {
while (Gtk.events_pending () || Gdk.events_pending ())
Gtk.main_iteration_do (false);
if (running) {
@@ -163,7 +170,8 @@ public class moserial.Szwrapper : GLib.Object {
return false;
}
- public void transferCanceled (GLib.Object o) {
+ public void transferCanceled (GLib.Object o)
+ {
// send cancel string to remote client and rz
if (running) {
@@ -182,12 +190,14 @@ public class moserial.Szwrapper : GLib.Object {
}
}
- private bool shutdown_timeout () {
+ private bool shutdown_timeout ()
+ {
shutdown ();
return false;
}
- private void shutdown () {
+ private void shutdown ()
+ {
if (running) {
running = false;
GLib.Source.remove (outputChannelId);
@@ -197,7 +207,8 @@ public class moserial.Szwrapper : GLib.Object {
}
}
- private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition) {
+ private bool readBytes (GLib.IOChannel source, GLib.IOCondition condition)
+ {
while (Gtk.events_pending () || Gdk.events_pending ())
Gtk.main_iteration_do (false);
if (running) {
diff --git a/src/XmodemFilenameDialog.vala b/src/XmodemFilenameDialog.vala
index 4071d2f..9d921bf 100644
--- a/src/XmodemFilenameDialog.vala
+++ b/src/XmodemFilenameDialog.vala
@@ -18,12 +18,14 @@
*/
using Gtk;
-public class moserial.XmodemFilenameDialog : GLib.Object {
+public class moserial.XmodemFilenameDialog : GLib.Object
+{
private Dialog dialog;
private Gtk.Entry xmodemFilename;
public string filename;
-
- public XmodemFilenameDialog (Window parent) {
+
+ public XmodemFilenameDialog (Window parent)
+ {
var builder = new Gtk.Builder.from_resource (Config.UIROOT + "xmodem_filename_dialog.ui");
dialog = (Dialog) builder.get_object ("xmodem_filename_dialog");
@@ -32,16 +34,19 @@ public class moserial.XmodemFilenameDialog : GLib.Object {
dialog.delete_event.connect (hide);
dialog.response.connect (response);
}
- public void show () {
+ public void show ()
+ {
dialog.run ();
}
- public bool hide () {
+ public bool hide ()
+ {
dialog.hide ();
return true;
}
- private void response (Widget w, int r) {
+ private void response (Widget w, int r)
+ {
filename = xmodemFilename.get_text ();
hide ();
if (filename == "")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]