diff --git a/Glade/NETRAVE.glade b/Glade/NETRAVE.glade new file mode 100644 index 0000000..8e3d3fb --- /dev/null +++ b/Glade/NETRAVE.glade @@ -0,0 +1,133 @@ + + + + + + False + + + Settings + settings_menu_entry + True + True + True + + + + + main_window + False + NETRAVE + center-always + 1080 + 720 + center + + + layout_grid + True + False + False + False + natural + natural + + + title_label + 100 + 80 + True + False + NETRAVE: A Network Monitor for the Future + center + + + + + + 300 + + + + + label_separator + 1085 + 5 + True + False + False + False + + + 91 + + + + + Open the Monitor + monitor_button + 154 + 80 + True + True + False + False + + + 150 + 115 + + + + + Open the Logger + logger_button + 146 + 80 + True + True + True + + + 415 + 115 + + + + + Open the Exterminator + exterminator_button + 274 + 80 + True + True + True + + + 670 + 115 + + + + + + menu_button + 100 + 80 + True + True + True + popover1 + + + + + + 6 + 6 + + + + + + diff --git a/Glade/NETRAVE.glade~ b/Glade/NETRAVE.glade~ new file mode 100644 index 0000000..c0d954e --- /dev/null +++ b/Glade/NETRAVE.glade~ @@ -0,0 +1,134 @@ + + + + + + False + + + Settings + settings_menu_entry + True + True + True + + + + + main_window + False + NETRAVE + center-always + 1080 + 720 + center + + + layout_grid + True + False + False + False + natural + natural + + + title_label + 100 + 80 + True + False + NETRAVE: A Network Monitor for the Future + center + + + + + + 300 + + + + + label_separator + 1085 + 5 + True + False + False + False + + + 91 + + + + + Open the Monitor + monitor_button + 154 + 80 + True + True + False + False + + + 150 + 115 + + + + + Open the Logger + logger_button + 146 + 80 + True + True + True + + + 415 + 115 + + + + + Open the Exterminator + exterminator_button + 274 + 80 + True + True + True + + + 670 + 115 + + + + + + menu_button + 100 + 80 + True + True + True + right + popover1 + + + + + + 6 + 6 + + + + + + diff --git a/lib/.rubocop.yml b/lib/.rubocop.yml new file mode 100644 index 0000000..cc32da4 --- /dev/null +++ b/lib/.rubocop.yml @@ -0,0 +1 @@ +inherit_from: .rubocop_todo.yml diff --git a/lib/.rubocop_todo.yml b/lib/.rubocop_todo.yml new file mode 100644 index 0000000..f88895f --- /dev/null +++ b/lib/.rubocop_todo.yml @@ -0,0 +1,192 @@ +# This configuration was generated by +# `rubocop --auto-gen-config` +# on 2023-06-07 18:22:21 UTC using RuboCop version 1.52.0. +# The point is for the user to remove these configuration records +# one by one as the offenses are removed from the code base. +# Note that changes in the inspected code, or installation of new +# versions of RuboCop, may require this file to be generated again. + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include. +# Include: **/*.gemfile, **/Gemfile, **/gems.rb +Bundler/OrderedGems: + Exclude: + - 'Gemfile' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyleAlignWith, Severity. +# SupportedStylesAlignWith: keyword, variable, start_of_line +Layout/EndAlignment: + Exclude: + - 'utils/utilities.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: Width, AllowedPatterns. +Layout/IndentationWidth: + Exclude: + - 'utils/utilities.rb' + +# Offense count: 3 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: final_newline, final_blank_line +Layout/TrailingEmptyLines: + Exclude: + - 'utils/database_manager.rb' + - 'utils/system_information_gather.rb' + - 'utils/utilities.rb' + +# Offense count: 9 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowInHeredoc. +Layout/TrailingWhitespace: + Exclude: + - 'utils/database_manager.rb' + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + - 'utils/utilities.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods. +Lint/UnusedMethodArgument: + Exclude: + - 'utils/system_information_gather.rb' + +# Offense count: 5 +# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes. +Metrics/AbcSize: + Max: 20 + +# Offense count: 8 +# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns. +Metrics/MethodLength: + Max: 19 + +# Offense count: 1 +# Configuration parameters: AllowedNames. +# AllowedNames: module_parent +Naming/ClassAndModuleCamelCase: + Exclude: + - 'utils/GUI_launcher.rb' + +# Offense count: 1 +# Configuration parameters: ExpectMatchingDefinition, CheckDefinitionPathHierarchy, CheckDefinitionPathHierarchyRoots, Regex, IgnoreExecutableScripts, AllowedAcronyms. +# CheckDefinitionPathHierarchyRoots: lib, spec, test, src +# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS +Naming/FileName: + Exclude: + - 'utils/GUI_launcher.rb' + +# Offense count: 2 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, conditionals +Style/AndOr: + Exclude: + - 'utils/GUI_launcher.rb' + +# Offense count: 5 +# Configuration parameters: AllowedConstants. +Style/Documentation: + Exclude: + - 'spec/**/*' + - 'test/**/*' + - 'utils/GUI_launcher.rb' + - 'utils/database_manager.rb' + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + - 'utils/utilities.rb' + +# Offense count: 5 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle. +# SupportedStyles: always, always_true, never +Style/FrozenStringLiteralComment: + Exclude: + - 'utils/GUI_launcher.rb' + - 'utils/database_manager.rb' + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + - 'utils/utilities.rb' + +# Offense count: 4 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinBodyLength, AllowConsecutiveConditionals. +Style/GuardClause: + Exclude: + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + +# Offense count: 4 +# This cop supports unsafe autocorrection (--autocorrect-all). +Style/InfiniteLoop: + Exclude: + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/NegatedWhile: + Exclude: + - 'utils/first_run_init.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns. +# SupportedStyles: predicate, comparison +Style/NumericPredicate: + Exclude: + - 'spec/**/*' + - 'utils/system_information_gather.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantBegin: + Exclude: + - 'utils/database_manager.rb' + +# Offense count: 6 +# This cop supports safe autocorrection (--autocorrect). +Style/RedundantFileExtensionInRequire: + Exclude: + - 'utils/database_manager.rb' + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + +# Offense count: 1 +# This cop supports unsafe autocorrection (--autocorrect-all). +# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength. +# AllowedMethods: present?, blank?, presence, try, try! +Style/SafeNavigation: + Exclude: + - 'utils/database_manager.rb' + +# Offense count: 36 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline. +# SupportedStyles: single_quotes, double_quotes +Style/StringLiterals: + Exclude: + - 'Gemfile' + - 'utils/GUI_launcher.rb' + - 'utils/database_manager.rb' + - 'utils/first_run_init.rb' + - 'utils/system_information_gather.rb' + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: MinSize, WordRegex. +# SupportedStyles: percent, brackets +Style/WordArray: + EnforcedStyle: brackets + +# Offense count: 1 +# This cop supports safe autocorrection (--autocorrect). +# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns. +# URISchemes: http, https +Layout/LineLength: + Max: 121 diff --git a/lib/Gemfile b/lib/Gemfile index 896e437..d2a097b 100644 --- a/lib/Gemfile +++ b/lib/Gemfile @@ -16,3 +16,7 @@ gem "sequel", "~> 5.69" gem "mysql2", "~> 0.5.5" gem "yaml", "~> 0.2.1" + +gem "gtk3", "~> 4.1" + +gem "reek", "~> 6.1" diff --git a/lib/Gemfile.lock b/lib/Gemfile.lock index a6cb3ab..f332d34 100644 --- a/lib/Gemfile.lock +++ b/lib/Gemfile.lock @@ -2,29 +2,69 @@ GEM remote: https://rubygems.org/ specs: ast (2.4.2) + atk (4.1.7) + glib2 (= 4.1.7) backport (1.2.0) benchmark (0.2.1) + cairo (1.17.8) + native-package-installer (>= 1.0.3) + pkg-config (>= 1.2.2) + red-colors + cairo-gobject (4.1.7) + cairo (>= 1.16.2) + glib2 (= 4.1.7) console (1.16.2) fiber-local curses (1.4.4) diff-lcs (1.5.0) e2mmap (0.1.0) fiber-local (1.0.0) + fiddle (1.1.1) + gdk3 (4.1.7) + cairo-gobject (= 4.1.7) + gdk_pixbuf2 (= 4.1.7) + pango (= 4.1.7) + gdk_pixbuf2 (4.1.7) + gio2 (= 4.1.7) + gio2 (4.1.7) + fiddle + gobject-introspection (= 4.1.7) + glib2 (4.1.7) + native-package-installer (>= 1.0.3) + pkg-config (>= 1.3.5) + gobject-introspection (4.1.7) + glib2 (= 4.1.7) + gtk3 (4.1.7) + atk (= 4.1.7) + gdk3 (= 4.1.7) jaro_winkler (1.5.6) json (2.6.3) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) + kwalify (0.7.2) + matrix (0.4.2) mysql2 (0.5.5) + native-package-installer (1.1.5) nokogiri (1.15.2-x86_64-linux) racc (~> 1.4) + pango (4.1.7) + cairo-gobject (= 4.1.7) + gobject-introspection (= 4.1.7) parallel (1.23.0) parser (3.2.2.1) ast (~> 2.4.1) + pkg-config (1.5.1) racc (1.6.2) rainbow (3.1.1) rbs (2.8.4) + red-colors (0.3.0) + matrix + reek (6.1.4) + kwalify (~> 0.7.0) + parser (~> 3.2.0) + rainbow (>= 2.0, < 4.0) regexp_parser (2.8.0) reverse_markdown (2.1.1) nokogiri @@ -71,7 +111,9 @@ PLATFORMS DEPENDENCIES console curses (~> 1.4) + gtk3 (~> 4.1) mysql2 (~> 0.5.5) + reek (~> 6.1) rubocop (~> 1.52) sequel (~> 5.69) solargraph (~> 0.49.0) diff --git a/lib/utils/GUI_launcher.rb b/lib/utils/GUI_launcher.rb new file mode 100644 index 0000000..d3e1ea7 --- /dev/null +++ b/lib/utils/GUI_launcher.rb @@ -0,0 +1,37 @@ +require 'gtk3' + +class GUI_Launcher + def initialize + @app = Gtk::Application.new("com.netrave.gui", :flags_none) + + @app.signal_connect "activate" do |application| + builder = Gtk::Builder.new + builder.add_from_file("./Glade/NETRAVE.glade") + + window = builder.get_object("main_window") + window.application = application + + screen = Gdk::Screen.default + width = screen.width + height = screen.height + + if width >= 3840 and height >= 2160 + # 4K resolution + window.set_default_size(1200, 1000) + elsif width >= 1920 and height >= 1080 + # 1080p resolution + window.set_default_size(1080, 800) + else + # 720p or lower resolution + window.set_default_size(800, 600) + end + + window.show_all + end + end + + def run + puts "Launching GUI..." + @app.run + end +end