├── po ├── LINGUAS ├── extra │ ├── LINGUAS │ ├── POTFILES │ ├── meson.build │ ├── extra.pot │ └── pt.po ├── POTFILES ├── meson.build ├── com.github.parnold-x.nasc.pot └── pt.po ├── debian ├── compat ├── source │ └── format ├── changelog ├── rules ├── control └── copyright ├── .gitignore ├── AUTHORS ├── compile.txt ├── recompile.sh ├── Screenshot.png ├── Screenshot2.png ├── Screenshot3.png ├── .gitmodules ├── icons └── meson.build ├── .gitpod.yml ├── intltool.json ├── mpfr.yml ├── cln.yml ├── src ├── config.vala.in ├── Nasc.vala ├── MathBinDialog.vala ├── ResultLine.vala ├── NascSettings.vala ├── ListFooter.vala ├── ResultBoxWidget.vala ├── OpenBox.vala ├── ResultView.vala ├── MainWindow.vala ├── Controller.vala ├── Tutorial.vala └── Calculator.vala ├── gtksourceview.yml ├── data ├── com.github.parnold_x.nasc.desktop.in ├── meson.build ├── com.github.parnold_x.nasc.gschema.xml ├── styles │ ├── language.dtd │ ├── styles.rng │ ├── nasc.xml │ ├── nasc_dark.xml │ ├── def.lang │ ├── language.rng │ └── language2.rng └── com.github.parnold_x.nasc.appdata.xml.in ├── BUILDING.md ├── meson └── post_install.py ├── com.github.parnold_x.nasc.yml ├── .github ├── ISSUE_TEMPLATE │ └── bug_report.md └── workflows │ └── main.yml ├── README.md ├── .gitpod.Dockerfile ├── vapi └── QalculateNasc.vapi └── meson.build /po/LINGUAS: -------------------------------------------------------------------------------- 1 | pt 2 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 8 2 | -------------------------------------------------------------------------------- /po/extra/LINGUAS: -------------------------------------------------------------------------------- 1 | pt 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | src/config.vala 3 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Peter Arnold -------------------------------------------------------------------------------- /compile.txt: -------------------------------------------------------------------------------- 1 | meson build --prefix=/usr 2 | ninja -C build -------------------------------------------------------------------------------- /recompile.sh: -------------------------------------------------------------------------------- 1 | rm -rf build 2 | meson build --prefix=/usr 3 | ninja -C build -------------------------------------------------------------------------------- /Screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parnoldx/nasc/HEAD/Screenshot.png -------------------------------------------------------------------------------- /Screenshot2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parnoldx/nasc/HEAD/Screenshot2.png -------------------------------------------------------------------------------- /Screenshot3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/parnoldx/nasc/HEAD/Screenshot3.png -------------------------------------------------------------------------------- /po/extra/POTFILES: -------------------------------------------------------------------------------- 1 | data/com.github.parnold-x.nasc.desktop.in 2 | data/com.github.parnold-x.nasc.appdata.xml.in 3 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "subprojects/libqalculate"] 2 | path = subprojects/libqalculate 3 | url = https://github.com/parnold-x/libqalculate.git 4 | -------------------------------------------------------------------------------- /po/POTFILES: -------------------------------------------------------------------------------- 1 | src/MainWindow.vala 2 | src/HelpBox.vala 3 | src/ListFooter.vala 4 | src/PasteBinDialog.vala 5 | src/PeriodicTable.vala 6 | src/Tutorial.vala -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | com.github.parnold_x.nasc (0.7.8) UNSTABLE; urgency=low 2 | 3 | * see apstream data 4 | 5 | -- Peter Arnold Wed, 09 Jun 2020 11:31:16 +0100 6 | -------------------------------------------------------------------------------- /po/extra/meson.build: -------------------------------------------------------------------------------- 1 | # Install metadata translations 2 | i18n.gettext ('extra', 3 | args: [ 4 | '--directory=' + meson.source_root (), 5 | '--from-code=UTF-8' 6 | ], 7 | install: false 8 | ) -------------------------------------------------------------------------------- /icons/meson.build: -------------------------------------------------------------------------------- 1 | sizes = ['16', '24', '32', '48', '64', '128'] 2 | 3 | foreach size : sizes 4 | install_data( 5 | join_paths(size, meson.project_name() + '.svg'), 6 | install_dir: join_paths(iconsdir, 'hicolor', size + 'x' + size, 'apps') 7 | ) 8 | endforeach -------------------------------------------------------------------------------- /po/meson.build: -------------------------------------------------------------------------------- 1 | # Install main translations 2 | i18n.gettext (meson.project_name (), 3 | args: [ 4 | '--directory=' + meson.source_root (), 5 | '--from-code=UTF-8', 6 | '-cTRANSLATORS' 7 | ], 8 | preset: 'glib' 9 | ) 10 | 11 | subdir ('extra') -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: 2 | file: .gitpod.Dockerfile 3 | tasks: 4 | - init: sh recompile.sh 5 | vscode: 6 | extensions: 7 | - thiagoabreu.vala@0.3.5:wpqKL9G/pGRsFlLDBLF2hA== 8 | - asabil.meson@1.2.0:sYg01j3Mm+6RJtaIRwyR5A== 9 | 10 | ports: 11 | - port: 5900 12 | onOpen: ignore 13 | - port: 6080 14 | onOpen: open-browser -------------------------------------------------------------------------------- /intltool.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "intltool", 3 | "cleanup": [ "*" ], 4 | "sources": [ 5 | { 6 | "type": "archive", 7 | "url": "https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz", 8 | "sha256": "67c74d94196b153b774ab9f89b2fa6c6ba79352407037c8c14d5aeb334e959cd" 9 | } 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /mpfr.yml: -------------------------------------------------------------------------------- 1 | name: mpfr 2 | config-opts: 3 | - --disable-static 4 | - --enable-maintainer-mode 5 | sources: 6 | - type: archive 7 | url: https://ftp.gnu.org/gnu/mpfr/mpfr-4.0.2.tar.xz 8 | sha256: 1d3be708604eae0e42d578ba93b390c2a145f17743a744d8f3f8c2ad5855a38a 9 | - type: shell 10 | commands: 11 | - cp -p /usr/share/automake-*/config.{sub,guess} .; 12 | - autoreconf -vfi; -------------------------------------------------------------------------------- /cln.yml: -------------------------------------------------------------------------------- 1 | name: cln 2 | config-opts: 3 | - --disable-static 4 | build-options: 5 | arch: 6 | arm: 7 | cppflags: -DNO_ASM 8 | sources: 9 | - type: git 10 | url: git://www.ginac.de/cln.git 11 | tag: cln_1-3-4 12 | commit: 9b86a7fc69feb1b288469982001af565f73057eb 13 | - type: shell 14 | commands: 15 | - cp -p /usr/share/automake-*/config.{sub,guess} "autoconf"/; 16 | - autoreconf -vfi; -------------------------------------------------------------------------------- /src/config.vala.in: -------------------------------------------------------------------------------- 1 | namespace Constants { 2 | public const string DATADIR = "@DATADIR@"; 3 | public const string STYLEDIR = "@STYLEDIR@"; 4 | public const string PKGDATADIR = "@PKGDATADIR@"; 5 | public const string GETTEXT_PACKAGE = "@GETTEXT_PACKAGE@"; 6 | public const string RELEASE_NAME = "@RELEASE_NAME@"; 7 | public const string VERSION = "@VERSION@"; 8 | public const string VERSION_INFO = "@VERSION_INFO@"; 9 | } 10 | -------------------------------------------------------------------------------- /gtksourceview.yml: -------------------------------------------------------------------------------- 1 | name: gtksourceview 2 | config-opts: 3 | - --disable-gtk-doc 4 | - --enable-maintainer-mode 5 | - --enable-gtk-doc=no 6 | sources: 7 | - type: archive 8 | url: https://download.gnome.org/sources/gtksourceview/3.24/gtksourceview-3.24.11.tar.xz 9 | sha256: 691b074a37b2a307f7f48edc5b8c7afa7301709be56378ccf9cc9735909077fd 10 | - type: shell 11 | commands: 12 | - cp -p /usr/share/automake-*/config.{sub,guess} .; 13 | - autoreconf -vfi; -------------------------------------------------------------------------------- /data/com.github.parnold_x.nasc.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Version=1.0 3 | Type=Application 4 | Name=NaSC 5 | Comment=Do maths like a normal person 6 | GenericName=Calculator 7 | X-GNOME-FullName=NaSC 8 | TryExec=com.github.parnold_x.nasc 9 | Exec=com.github.parnold_x.nasc 10 | Icon=com.github.parnold_x.nasc 11 | Terminal=false 12 | Categories=Utility;Calculator;Education;Math; 13 | Keywords=calculation;arithmetic;scientific;financial; 14 | X-GNOME-Gettext-Domain=com.github.parnold_x.nasc 15 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | # -*- makefile -*- 3 | # Sample debian/rules that uses debhelper. 4 | # This file was originally written by Joey Hess and Craig Small. 5 | # As a special exception, when this file is copied by dh-make into a 6 | # dh-make output file, you may use that output file without restriction. 7 | # This special exception was added by Craig Small in version 0.37 of dh-make. 8 | 9 | # Uncomment this to turn on verbose mode. 10 | #export DH_VERBOSE=1 11 | 12 | %: 13 | dh $@ --buildsystem=meson -------------------------------------------------------------------------------- /BUILDING.md: -------------------------------------------------------------------------------- 1 | ## Building 2 | 3 | Dependencies 4 | ```bash 5 | apt install -y gobject-introspection libgee-0.8-dev libwebkit2gtk-4.0-dev libgtksourceview-3.0-dev libcln-dev libgranite-dev libcurl4-openssl-dev libmpfr-dev intltool meson valac 6 | ``` 7 | 8 | Dependencies(Fedora): 9 | 10 | ```bash 11 | dnf install gobject-introspection libgee-devel webkit2gtk3-devel gtksourceview3-devel cln-devel granite-devel libcurl-devel mpfr-devel intltool meson vala 12 | ``` 13 | 14 | then build with: 15 | 16 | ```bash 17 | meson build --prefix=/usr 18 | ninja -C build install 19 | ``` 20 | -------------------------------------------------------------------------------- /meson/post_install.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import os 3 | import subprocess 4 | 5 | parser = argparse.ArgumentParser() 6 | parser.add_argument("--schemadir", action="store", required=True) 7 | parser.add_argument("--iconsdir", action="store", required=True) 8 | 9 | args = vars(parser.parse_args()) 10 | 11 | schemadir = args["schemadir"] 12 | iconsdir = args["iconsdir"] 13 | 14 | hicolordir = os.path.join(iconsdir, 'hicolor') 15 | 16 | if not os.environ.get('DESTDIR'): 17 | print('Compiling gsettings schemas ...') 18 | subprocess.run(['glib-compile-schemas', schemadir]) 19 | 20 | print('Compiling icon cache ...') 21 | subprocess.run(['gtk-update-icon-cache', hicolordir]) 22 | -------------------------------------------------------------------------------- /com.github.parnold_x.nasc.yml: -------------------------------------------------------------------------------- 1 | app-id: com.github.parnold_x.nasc 2 | 3 | runtime: io.elementary.Platform 4 | runtime-version: '6' 5 | sdk: io.elementary.Sdk 6 | 7 | command: com.github.parnold_x.nasc 8 | 9 | finish-args: 10 | - '--share=ipc' 11 | - '--socket=fallback-x11' 12 | - '--socket=wayland' 13 | - '--share=network' 14 | - '--filesystem=home' 15 | - '--filesystem=/etc:ro' 16 | - '--metadata=X-DConf=migrate-path=/com/github/parnold-x/nasc/' 17 | - '--system-talk-name=org.freedesktop.Accounts' 18 | 19 | modules: 20 | - intltool.json 21 | - mpfr.yml 22 | - cln.yml 23 | - gtksourceview.yml 24 | - name: nasc 25 | buildsystem: meson 26 | sources: 27 | - type: dir 28 | path: . 29 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: parnold-x 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. elementary OS 5.1] 28 | - Version [e.g. 0.7.3] 29 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Now as NaSC TUI App

https://github.com/parnoldx/nascTUI

2 | 3 | 4 |
5 | Icon 6 |

NaSC

7 |

Do maths like a normal person

8 |
9 | 10 | ![screenshot](Screenshot.png) 11 | 12 | NaSC is an app where you do maths like a normal person. It lets you type whatever you want and smartly figures out what is math and spits out an answer on the right pane. Then you can plug those answers in to future equations and if that answer changes, so does the equations it's used in. 13 | 14 | ## [Building](https://github.com/parnoldx/nasc/blob/master/BUILDING.md) 15 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: com.github.parnold-x.nasc 2 | Section: misc 3 | Priority: optional 4 | Maintainer: Peter Arnold 5 | Build-Depends: meson, 6 | debhelper (>= 9), 7 | libgcc1, 8 | libqalculate-dev, 9 | libgee-0.8-dev, 10 | libwebkit2gtk-4.0-dev, 11 | libglib2.0-dev (>= 2.29.0), 12 | libgranite-dev (>= 0.3.0), 13 | libgtk-3-dev (>=3.12), 14 | libgtksourceview-3.0-dev (>=3.10), 15 | libcurl4-openssl-dev, 16 | libmpfr-dev, 17 | intltool, 18 | valac 19 | Standards-Version: 3.9.3 20 | 21 | Package: com.github.parnold_x.nasc 22 | Architecture: any 23 | Depends: ${misc:Depends}, ${shlibs:Depends} 24 | Pre-Depends: dpkg (>= 1.15.6) 25 | Description: Do maths like a normal person. 26 | -------------------------------------------------------------------------------- /.gitpod.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM gitpod/workspace-full-vnc 2 | 3 | USER root 4 | ARG DEBIAN_FRONTEND=noninteractive 5 | 6 | RUN apt-get -q update 7 | 8 | RUN apt-get install software-properties-common 9 | RUN add-apt-repository ppa:vala-team 10 | 11 | RUN apt-get -q update 12 | RUN apt-get install -yq \ 13 | at-spi2-core \ 14 | dbus-x11 \ 15 | gnome-common \ 16 | libbamf3-dev \ 17 | libcairo2-dev \ 18 | libdbusmenu-gtk3-dev \ 19 | libgdk-pixbuf2.0-dev \ 20 | libgee-0.8-dev \ 21 | libglib2.0-dev \ 22 | libgnome-menu-3-dev \ 23 | libgtk-3-dev \ 24 | libgranite-dev \ 25 | libjson-glib-dev \ 26 | libsqlite3-dev \ 27 | libwnck-3-dev \ 28 | libx11-dev \ 29 | libxml2-utils \ 30 | gobject-introspection \ 31 | libwebkit2gtk-4.0-dev \ 32 | libgtksourceview-3.0-dev \ 33 | libcln-dev \ 34 | libcurl4-openssl-dev \ 35 | libmpfr-dev \ 36 | intltool \ 37 | meson \ 38 | valac \ 39 | xvfb 40 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://dep.debian.net/deps/dep5 2 | Upstream-Name: NaSC 3 | Source: https://github.com/parnold-x/nasc/tree/master 4 | 5 | Files: * 6 | Copyright: 2015 Peter Arnold 7 | License: GPL-3.0+ 8 | 9 | License: GPL-3.0+ 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | . 15 | This package is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | . 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | . 23 | On Debian systems, the complete text of the GNU General 24 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 25 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | 9 | container: 10 | image: ghcr.io/elementary/flatpak-platform/runtime:6 11 | options: --privileged 12 | 13 | # Steps represent a sequence of tasks that will be executed as part of the job 14 | steps: 15 | - uses: actions/checkout@v1 16 | with: 17 | submodules: true 18 | 19 | # Builds your flatpak manifest using the Flatpak Builder action 20 | - uses: bilelmoussaoui/flatpak-github-actions/flatpak-builder@v3 21 | with: 22 | bundle: nasc 23 | # This uses your app's RDNN ID 24 | manifest-path: com.github.parnold_x.nasc.yml 25 | 26 | # You can automatically run any of the tests you've created as part of this workflow 27 | run-tests: true 28 | 29 | # These lines specify the location of the elementary Runtime and Sdk 30 | repository-name: appcenter 31 | repository-url: https://flatpak.elementary.io/repo.flatpakrepo 32 | cache-key: "flatpak-builder-${{ github.sha }}" 33 | -------------------------------------------------------------------------------- /data/meson.build: -------------------------------------------------------------------------------- 1 | # Translate and install our .desktop file so the Applications Menu will see it 2 | i18n.merge_file ( 3 | input: meson.project_name () + '.desktop.in', 4 | output: meson.project_name () + '.desktop', 5 | po_dir: join_paths (meson.source_root (), 'po', 'extra'), 6 | type: 'desktop', 7 | install: true, 8 | install_dir: join_paths (get_option ('datadir'), 'applications') 9 | ) 10 | 11 | # Translate and install our .appdata.xml file so AppCenter will see it 12 | i18n.merge_file ( 13 | input: meson.project_name () + '.appdata.xml.in', 14 | output: meson.project_name () + '.appdata.xml', 15 | po_dir: join_paths (meson.source_root (), 'po', 'extra'), 16 | install: true, 17 | install_dir: join_paths (get_option ('datadir'), 'metainfo') 18 | ) 19 | 20 | install_data( 21 | meson.project_name() + '.gschema.xml', 22 | install_dir: schemadir, 23 | ) 24 | 25 | install_data( 26 | 'styles/def.lang', 27 | 'styles/language.dtd', 28 | 'styles/language.rng', 29 | 'styles/language2.rng', 30 | 'styles/nasc.lang', 31 | 'styles/nasc.xml', 32 | 'styles/nasc_dark.xml', 33 | 'styles/styles.rng', 34 | install_dir: style_dir 35 | ) 36 | -------------------------------------------------------------------------------- /data/com.github.parnold_x.nasc.gschema.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | Show a Tutorial at startup 7 | 8 | If the user starts the first time a tutorial is shown 9 | 10 | 11 | 12 | 13 | false 14 | If true advanced functions are shown in the help 15 | 16 | If you are a true math geek you need this set to true 17 | 18 | 19 | 20 | 21 | 850 22 | The user's last window width 23 | 24 | The user's last window width 25 | 26 | 27 | 28 | 29 | 800 30 | The user's last window height 31 | 32 | The user's last window height 33 | 34 | 35 | 36 | 37 | 445 38 | The user's last pane position 39 | 40 | The user's last pane position 41 | 42 | 43 | 44 | 45 | -1 46 | Most recent x position of nasc 47 | Most recent x position of nasc 48 | 49 | 50 | 51 | -1 52 | Most recent y position of nasc 53 | Most recent y position of nasc 54 | 55 | 56 | 57 | 0 58 | The open sheet 59 | 60 | The open sheet 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/Nasc.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | namespace Nasc { 21 | public class NascApp : Granite.Application { 22 | private MainWindow window = null; 23 | public string[] args; 24 | 25 | construct { 26 | program_name = "NaSC"; 27 | exec_name = "nasc"; 28 | 29 | build_data_dir = Constants.DATADIR; 30 | build_pkg_data_dir = Constants.PKGDATADIR; 31 | build_release_name = Constants.RELEASE_NAME; 32 | build_version = Constants.VERSION; 33 | build_version_info = Constants.VERSION_INFO; 34 | 35 | app_launcher = "com.github.parnold_x.nasc.desktop"; 36 | application_id = "com.github.parnold_x.nasc"; 37 | } 38 | 39 | public NascApp () { 40 | Granite.Services.Logger.initialize ("NaSC"); 41 | Granite.Services.Logger.DisplayLevel = Granite.Services.LogLevel.ERROR; 42 | } 43 | 44 | public override void activate () { 45 | if (get_windows () == null) { 46 | window = new MainWindow (this); 47 | } else { 48 | window.present (); 49 | } 50 | } 51 | 52 | public static void main (string[] args) { 53 | var app = new Nasc.NascApp (); 54 | app.args = args; 55 | app.run (args); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /vapi/QalculateNasc.vapi: -------------------------------------------------------------------------------- 1 | [CCode (cheader_filename = "QalculateNasc.h")] 2 | [Compact] 3 | public class QalculateNasc { 4 | 5 | [CCode (cname = "new_calculator")] 6 | public static void new_calculator(); 7 | 8 | [CCode (cname = "delete_calculator")] 9 | public static void delete_calculator(); 10 | 11 | [CCode (cname = "Calculator_calculate")] 12 | public static string calculate (string input); 13 | 14 | [CCode (cname = "Calculator_calculate_store_variable")] 15 | public static string calculate_store_variable (string input, string variable); 16 | 17 | [CCode (cname = "add_function")] 18 | public static void add_function (string name, string expr); 19 | 20 | [CCode (cname = "clear_variables")] 21 | public static void clear_variables (); 22 | 23 | [CCode (cname = "abortt")] 24 | public static void abort (); 25 | 26 | [CCode (cname = "get_function_size")] 27 | public static int get_function_size (); 28 | 29 | [CCode (cname = "get_function_name")] 30 | public static string get_function_name (int index); 31 | 32 | [CCode (cname = "get_function_description")] 33 | public static string get_function_description (int index); 34 | 35 | [CCode (cname = "get_function_category")] 36 | public static string get_function_category (int index); 37 | 38 | [CCode (cname = "get_function_title")] 39 | public static string get_function_title (int index); 40 | 41 | [CCode (cname = "get_function_arguments")] 42 | public static string get_function_arguments (int index); 43 | 44 | [CCode (cname = "get_function_arguments_list")] 45 | public static string get_function_arguments_list (int index); 46 | 47 | [CCode (cname = "get_variable_size")] 48 | public static int get_variable_size (); 49 | 50 | [CCode (cname = "get_variable_name")] 51 | public static string get_variable_name (int index); 52 | 53 | [CCode (cname = "get_variable_category")] 54 | public static string get_variable_category (int index); 55 | 56 | [CCode (cname = "get_variable_title")] 57 | public static string get_variable_title (int index); 58 | 59 | [CCode (cname = "get_exchange_rates_url")] 60 | public static string get_exchange_rates_url(); 61 | 62 | [CCode (cname = "get_exchange_rates_filename")] 63 | public static string get_exchange_rates_filename(); 64 | 65 | } -------------------------------------------------------------------------------- /data/styles/language.dtd: -------------------------------------------------------------------------------- 1 | 23 | 24 | 27 | 28 | 29 | 31 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 47 | 48 | 49 | 52 | 53 | 54 | 56 | 57 | 58 | 60 | 61 | 62 | 69 | 70 | 71 | 72 | 73 | 74 | -------------------------------------------------------------------------------- /src/MathBinDialog.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | namespace Nasc { 21 | 22 | public class MathBinDialog : Gtk.Dialog { 23 | private Controller controller; 24 | 25 | public MathBinDialog (Gtk.Window? parent, Controller controller) { 26 | this.controller = controller; 27 | 28 | if (parent != null) { 29 | this.set_transient_for (parent); 30 | } 31 | 32 | var webkit = new WebKit.WebView (); 33 | var webkit_settings = new WebKit.Settings (); 34 | webkit_settings.default_font_family = Gtk.Settings.get_default ().gtk_font_name; 35 | webkit_settings.enable_back_forward_navigation_gestures = true; 36 | webkit_settings.enable_java = true; 37 | webkit_settings.enable_javascript = true; 38 | webkit_settings.enable_mediasource = true; 39 | webkit_settings.enable_plugins = false; 40 | webkit_settings.enable_smooth_scrolling = true; 41 | 42 | webkit.settings = webkit_settings; 43 | Gtk.Box content2 = get_content_area () as Gtk.Box; 44 | content2.add (webkit); 45 | webkit.set_size_request (800,600); 46 | 47 | show_all (); 48 | 49 | string paste_code = this.controller.get_export_text (); 50 | webkit.load_uri ("http://mathb.in"); 51 | 52 | uint text_change_timeout = 0; 53 | webkit.load_changed.connect ((source, e)=> { 54 | if (text_change_timeout != 0) { 55 | GLib.Source.remove (text_change_timeout); 56 | text_change_timeout = 0; 57 | } 58 | text_change_timeout = Timeout.add (300, () => { 59 | text_change_timeout = 0; 60 | 61 | webkit.run_javascript ("document.getElementById('code').value='"+paste_code+"'"); 62 | 63 | webkit.run_javascript ("document.getElementById('title').value='"+controller.actual_sheet.name+"'"); 64 | return Source.REMOVE; 65 | }); 66 | 67 | }); 68 | } 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/ResultLine.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | public class ResultLine : GLib.Object { 21 | public int line { get; set; } 22 | public string variable_name { get; set; } 23 | public string value { get; private set; } 24 | public string full_value { get; private set; } 25 | private Cairo.Context context; 26 | private int width; 27 | 28 | public signal void changed (); 29 | public signal void destroy (); 30 | 31 | public ResultLine (int line, string name, string value, int width) { 32 | this.line = line; 33 | this.variable_name = name; 34 | this.value = value; 35 | this.width = width; 36 | Cairo.ImageSurface source = new Cairo.ImageSurface (Cairo.Format.A8, 32, 32); 37 | context = new Cairo.Context (source); 38 | context.set_font_size (16); 39 | } 40 | 41 | /* 42 | * set the value of this line, emits a change signal, 43 | * if the line value has changed true will be returned 44 | */ 45 | public bool set_value_with_notification (string value) { 46 | if (value == full_value) { 47 | return false; 48 | } 49 | 50 | this.full_value = value; 51 | set_val (value); 52 | changed (); 53 | 54 | return true; 55 | } 56 | 57 | public void set_val (string value) { 58 | Cairo.TextExtents extents; 59 | context.text_extents (value, out extents); 60 | 61 | if ((int)extents.width > width) { 62 | var tmp = value; 63 | 64 | while ((int)extents.width > 2 * width) { 65 | tmp = tmp.substring (0, tmp.length / 2); 66 | context.text_extents (tmp, out extents); 67 | } 68 | 69 | while ((int)extents.width > width) { 70 | tmp = tmp.substring (0, tmp.length - 1); 71 | context.text_extents (tmp, out extents); 72 | } 73 | 74 | tmp += "…"; 75 | this.value = tmp; 76 | } else { 77 | this.value = value; 78 | } 79 | } 80 | 81 | public void refresh_width (int width) { 82 | this.width = width; 83 | 84 | if (full_value != null) { 85 | set_val (full_value); 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /src/NascSettings.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2021 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | public class NascSettings : Object { 21 | private static NascSettings? instance = null; 22 | 23 | /* constants */ 24 | public const string variable_names = "nasc_line_"; 25 | public const string sheet_split_char = "|§§|"; 26 | public const string name_split_char = "-§-"; 27 | public const string sheet_dir = "nasc"; 28 | 29 | 30 | public bool dark_mode { get; private set; } 31 | public bool show_tutorial { get; set; } 32 | public bool advanced_mode { get; set; } 33 | public int window_width { get; set; } 34 | public int window_height { get; set; } 35 | public int pane_position { get; set; } 36 | public int opening_x { get; set; } 37 | public int opening_y { get; set; } 38 | 39 | public int open_sheet { get; set; } 40 | 41 | private NascSettings () { 42 | var settings = new GLib.Settings ("com.github.parnold_x.nasc"); 43 | settings.bind ("show-tutorial", this, "show_tutorial", SettingsBindFlags.DEFAULT); 44 | settings.bind ("advanced-mode", this, "advanced_mode", SettingsBindFlags.DEFAULT); 45 | settings.bind ("window-width", this, "window_width", SettingsBindFlags.DEFAULT); 46 | settings.bind ("window-height", this, "window_height", SettingsBindFlags.DEFAULT); 47 | settings.bind ("pane-position", this, "pane_position", SettingsBindFlags.DEFAULT); 48 | settings.bind ("opening-x", this, "opening_x", SettingsBindFlags.DEFAULT); 49 | settings.bind ("opening-y", this, "opening_y", SettingsBindFlags.DEFAULT); 50 | settings.bind ("open-sheet", this, "open_sheet", SettingsBindFlags.DEFAULT); 51 | var granite_settings = Granite.Settings.get_default (); 52 | var gtk_settings = Gtk.Settings.get_default (); 53 | 54 | // Then, we check if the user's preference is for the dark style and set it if it is 55 | gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; 56 | dark_mode = gtk_settings.gtk_application_prefer_dark_theme; 57 | 58 | // Finally, we listen to changes in Granite.Settings and update our app if the user changes their preference 59 | granite_settings.notify["prefers-color-scheme"].connect (() => { 60 | gtk_settings.gtk_application_prefer_dark_theme = granite_settings.prefers_color_scheme == Granite.Settings.ColorScheme.DARK; 61 | dark_mode = gtk_settings.gtk_application_prefer_dark_theme; 62 | }); 63 | } 64 | 65 | public static NascSettings get_instance () { 66 | if (instance == null) { 67 | instance = new NascSettings (); 68 | } 69 | 70 | return instance; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /meson.build: -------------------------------------------------------------------------------- 1 | project( 2 | 'com.github.parnold_x.nasc', 3 | 'vala', 'c', 'cpp', 4 | version: '0.8.0', 5 | default_options: ['cpp_std=c++11'] 6 | ) 7 | 8 | gettext_name = 'nasc' 9 | 10 | # check vala compiler version 11 | if meson.get_compiler('vala').version().version_compare('<0.28.0') 12 | error('vala compiler version 0.28.0 or newer is required.') 13 | endif 14 | 15 | pkg_data_dir = join_paths( 16 | get_option('prefix'), 17 | get_option('datadir'), 18 | 'nasc' 19 | ) 20 | 21 | style_dir = join_paths( 22 | get_option('prefix'), 23 | get_option('datadir'), 24 | 'nasc', 25 | 'styles' 26 | ) 27 | 28 | 29 | # Translation module 30 | i18n = import ('i18n') 31 | 32 | add_project_arguments( 33 | '-DGETTEXT_PACKAGE="@0@"'.format(gettext_name), 34 | language: ['c', 'cpp'] 35 | ) 36 | 37 | conf_data = configuration_data() 38 | conf_data.set('DATADIR', join_paths(get_option('prefix'), get_option('datadir'))) 39 | conf_data.set('STYLEDIR', style_dir) 40 | conf_data.set('PKGDATADIR', pkg_data_dir) 41 | conf_data.set('GETTEXT_PACKAGE', gettext_name) 42 | conf_data.set('RELEASE_NAME', meson.project_name()) 43 | conf_data.set('VERSION', meson.project_version()) 44 | conf_data.set('VERSION_INFO', 'Release') 45 | 46 | config_header = configure_file( 47 | input: 'src/config.vala.in', 48 | output: 'config.vala', 49 | configuration: conf_data 50 | ) 51 | 52 | # build libqalculate static library 53 | libqalculate = subproject('libqalculate') 54 | libqalculate_dep_static = libqalculate.get_variable('libqalculate_lib_static') 55 | 56 | # build com.github.parnold_x.nasc binary 57 | executable( 58 | meson.project_name(), 59 | 60 | 'src/Calculator.vala', 61 | 'src/Controller.vala', 62 | 'src/HelpBox.vala', 63 | 'src/InputView.vala', 64 | 'src/ListFooter.vala', 65 | 'src/MainWindow.vala', 66 | 'src/Nasc.vala', 67 | 'src/NascSettings.vala', 68 | 'src/OpenBox.vala', 69 | 'src/MathBinDialog.vala', 70 | 'src/PeriodicTable.vala', 71 | 'src/ResultBoxWidget.vala', 72 | 'src/ResultLine.vala', 73 | 'src/ResultView.vala', 74 | 'src/Tutorial.vala', 75 | 76 | config_header, 77 | libqalculate.get_variable('definition_resource'), 78 | 79 | include_directories: [ 80 | include_directories('subprojects/libqalculate/libqalculate') 81 | ], 82 | 83 | dependencies: [ 84 | dependency('gee-0.8'), 85 | dependency('glib-2.0'), 86 | dependency('granite', version: '>=5.4.0'), 87 | dependency('gtk+-3.0'), 88 | dependency('gtksourceview-3.0', version: '>=3.10'), 89 | dependency('webkit2gtk-4.0'), 90 | #dependency('cln'), 91 | meson.get_compiler('vala').find_library('posix'), 92 | meson.get_compiler('vala').find_library('QalculateNasc', dirs: [join_paths(meson.current_source_dir(), 'vapi')]) 93 | ], 94 | 95 | link_with: libqalculate_dep_static, 96 | 97 | install: true 98 | ) 99 | 100 | # set up post-install script 101 | 102 | python3 = find_program('python3') 103 | 104 | schemadir = join_paths(get_option('prefix'), get_option('datadir'), 'glib-2.0', 'schemas') 105 | iconsdir = join_paths(get_option('prefix'), get_option('datadir'), 'icons') 106 | 107 | meson.add_install_script( 108 | python3.path(), 109 | join_paths(meson.current_source_dir(), 'meson', 'post_install.py'), 110 | '--schemadir', schemadir, 111 | '--iconsdir', iconsdir, 112 | ) 113 | 114 | subdir('data') 115 | subdir('icons') 116 | subdir('po') 117 | -------------------------------------------------------------------------------- /src/ListFooter.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | public class ListFooter : Gtk.Toolbar { 21 | private Gtk.ToolButton button_add; 22 | private Gtk.ToolButton button_remove; 23 | private Gtk.ToolButton button_undo; 24 | 25 | public signal void add_sheet (); 26 | public signal void remove_sheet (); 27 | public signal void undo (); 28 | 29 | public Controller? controller; 30 | 31 | public ListFooter () { 32 | build_ui (); 33 | } 34 | 35 | private void build_ui () { 36 | set_style (Gtk.ToolbarStyle.ICONS); 37 | get_style_context ().add_class ("inline-toolbar"); 38 | get_style_context ().add_class (Gtk.STYLE_CLASS_INLINE_TOOLBAR); 39 | get_style_context ().set_junction_sides (Gtk.JunctionSides.TOP); 40 | set_icon_size (Gtk.IconSize.SMALL_TOOLBAR); 41 | set_show_arrow (false); 42 | hexpand = true; 43 | 44 | button_add = new Gtk.ToolButton (null, _("Create new sheet")); 45 | button_add.set_tooltip_text (_("Create new sheet")); 46 | button_add.set_icon_name ("list-add-symbolic"); 47 | button_add.clicked.connect (() => { 48 | add_sheet (); 49 | }); 50 | insert (button_add, -1); 51 | 52 | button_remove = new Gtk.ToolButton (null, _("Remove sheet")); 53 | button_remove.set_tooltip_text (_("Remove sheet")); 54 | button_remove.set_icon_name ("list-remove-symbolic"); 55 | button_remove.set_sensitive (false); 56 | button_remove.clicked.connect (() => { 57 | remove_sheet (); 58 | }); 59 | insert (button_remove, -1); 60 | 61 | var separator = new Gtk.SeparatorToolItem (); 62 | separator.set_draw (false); 63 | separator.set_expand (true); 64 | insert (separator, -1); 65 | 66 | button_undo = new Gtk.ToolButton (null, _("Undo last sheet removal")); 67 | button_undo.set_tooltip_text (_("Undo last sheet removal")); 68 | button_undo.set_icon_name ("edit-undo-symbolic"); 69 | button_undo.set_no_show_all (true); 70 | button_undo.clicked.connect (() => { 71 | undo (); 72 | }); 73 | insert (button_undo, -1); 74 | 75 | update_ui (); 76 | } 77 | 78 | public void update_ui () { 79 | if (controller == null) { 80 | return; 81 | } 82 | 83 | if (controller.get_sheets ().size > 1) { 84 | button_remove.set_sensitive (true); 85 | } else { 86 | button_remove.set_sensitive (false); 87 | } 88 | 89 | if (controller.get_removal_list ().size == 0) { 90 | button_undo.set_no_show_all (true); 91 | button_undo.hide (); 92 | } else { 93 | button_undo.set_no_show_all (false); 94 | } 95 | 96 | show_all (); 97 | } 98 | } -------------------------------------------------------------------------------- /po/extra/extra.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the extra package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: extra\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2020-05-30 13:51+0200\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: data/com.github.parnold-x.nasc.desktop.in:5 21 | #: data/com.github.parnold-x.nasc.appdata.xml.in:7 22 | msgid "NaSC" 23 | msgstr "" 24 | 25 | #: data/com.github.parnold-x.nasc.desktop.in:6 26 | #: data/com.github.parnold-x.nasc.appdata.xml.in:8 27 | msgid "Do maths like a normal person" 28 | msgstr "" 29 | 30 | #: data/com.github.parnold-x.nasc.desktop.in:7 31 | msgid "Calculator" 32 | msgstr "" 33 | 34 | #: data/com.github.parnold-x.nasc.desktop.in:11 35 | msgid "com.github.parnold-x.nasc" 36 | msgstr "" 37 | 38 | #: data/com.github.parnold-x.nasc.desktop.in:14 39 | msgid "calculation;arithmetic;scientific;financial;" 40 | msgstr "" 41 | 42 | #: data/com.github.parnold-x.nasc.appdata.xml.in:10 43 | msgid "" 44 | "It’s an app where you do maths like a normal person. It lets you type " 45 | "whatever you want and smartly figures out what is math and spits out an " 46 | "answer on the right pane. Then you can plug those answers in to future " 47 | "equations and if that answer changes, so does the equations it’s used in." 48 | msgstr "" 49 | 50 | #: data/com.github.parnold-x.nasc.appdata.xml.in:19 51 | msgid "" 52 | "Build libqalculate as submodule - This means better calculation results and " 53 | "more functions" 54 | msgstr "" 55 | 56 | #: data/com.github.parnold-x.nasc.appdata.xml.in:20 57 | msgid "Added convert to different number bases. E.g. 16734003 to hex" 58 | msgstr "" 59 | 60 | #: data/com.github.parnold-x.nasc.appdata.xml.in:21 61 | msgid "" 62 | "Available number bases: hex bin dec oct duo roman bijective roman sexa fp32 " 63 | "fp64 fp16 fp80 fp128" 64 | msgstr "" 65 | 66 | #: data/com.github.parnold-x.nasc.appdata.xml.in:22 67 | msgid "Improved scroll behavior when using long equations or results" 68 | msgstr "" 69 | 70 | #: data/com.github.parnold-x.nasc.appdata.xml.in:23 71 | msgid "Ctrl + Shift + C copys result when nothing is marked in the input pane" 72 | msgstr "" 73 | 74 | #: data/com.github.parnold-x.nasc.appdata.xml.in:24 75 | msgid "Right click on a result copies it to the clipboard" 76 | msgstr "" 77 | 78 | #: data/com.github.parnold-x.nasc.appdata.xml.in:25 79 | msgid "Auto complete functions with parenthesis" 80 | msgstr "" 81 | 82 | #: data/com.github.parnold-x.nasc.appdata.xml.in:26 83 | msgid "Quit on Ctrl + Q" 84 | msgstr "" 85 | 86 | #: data/com.github.parnold-x.nasc.appdata.xml.in:27 87 | msgid "Fix of a parsing error in the help pane" 88 | msgstr "" 89 | 90 | #: data/com.github.parnold-x.nasc.appdata.xml.in:32 91 | msgid "Update desktop file." 92 | msgstr "" 93 | 94 | #: data/com.github.parnold-x.nasc.appdata.xml.in:37 95 | msgid "Fix double NaSC icon." 96 | msgstr "" 97 | 98 | #: data/com.github.parnold-x.nasc.appdata.xml.in:42 99 | msgid "Fix linking of qalculatenasc lib." 100 | msgstr "" 101 | 102 | #: data/com.github.parnold-x.nasc.appdata.xml.in:47 103 | msgid "Update Debian control file." 104 | msgstr "" 105 | 106 | #: data/com.github.parnold-x.nasc.appdata.xml.in:52 107 | msgid "Release for Juno." 108 | msgstr "" 109 | 110 | #: data/com.github.parnold-x.nasc.appdata.xml.in:58 111 | msgid "Main view" 112 | msgstr "" 113 | 114 | #: data/com.github.parnold-x.nasc.appdata.xml.in:62 115 | msgid "Help pane" 116 | msgstr "" 117 | 118 | #: data/com.github.parnold-x.nasc.appdata.xml.in:66 119 | msgid "Periodic table" 120 | msgstr "" 121 | 122 | #: data/com.github.parnold-x.nasc.appdata.xml.in:99 123 | msgid "Peter Arnold" 124 | msgstr "" 125 | -------------------------------------------------------------------------------- /data/styles/styles.rng: -------------------------------------------------------------------------------- 1 | 2 | 23 | 25 | 26 | 27 | 28 | 29 | 30 | ([a-zA-Z0-9_]|-)+ 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 1.0 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | ([a-zA-Z0-9_]|-)+ 72 | 73 | 74 | 75 | 76 | #.* 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | true 103 | false 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /src/ResultBoxWidget.vala: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2015 Peter Arnold 3 | * 4 | * This program is free software; you can redistribute it and/or 5 | * modify it under the terms of the GNU General Public 6 | * License as published by the Free Software Foundation; either 7 | * version 2 of the License, or (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | * General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public 15 | * License along with this program; if not, write to the 16 | * Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 | * Boston, MA 02111-1307, USA. 18 | */ 19 | 20 | public class ResultBoxWidget : Gtk.DrawingArea { 21 | public int line_number { get; set; } 22 | public ResultLine result; 23 | 24 | public ResultBoxWidget (int line_number, ResultLine result) { 25 | this.line_number = line_number; 26 | this.result = result; 27 | this.set_size_request (15, 15); 28 | show (); 29 | this.result.changed.connect (() => { 30 | queue_draw (); 31 | }); 32 | result.destroy.connect (() => { 33 | this.destroy (); 34 | }); 35 | } 36 | 37 | public string get_variable_name () { 38 | return this.result.variable_name; 39 | } 40 | 41 | public override bool draw (Cairo.Context context) { 42 | context.set_font_size (16); 43 | Cairo.TextExtents extents; 44 | context.text_extents (this.result.value, out extents); 45 | int box_width = ((int)extents.width) + 2 * 8; 46 | this.set_size_request (box_width, 15); 47 | 48 | return true; 49 | } 50 | 51 | public bool draw_content (Cairo.Context context, int x, int y) { 52 | context.set_font_size (16); 53 | Cairo.TextExtents extents; 54 | context.text_extents (this.result.value, out extents); 55 | /* set and calculate sizes of the box */ 56 | int dy = -2; 57 | int box_dx_text = 8; 58 | int box_mdy_text = 5; 59 | int box_height = 22; 60 | int box_width = ((int)extents.width) + 2 * box_dx_text; 61 | /* draw box */ 62 | if (NascSettings.get_instance ().dark_mode) { 63 | context.set_source_rgba (0.854901961, 0.933333333, 0.984313725, 0.9); 64 | } else { 65 | context.set_source_rgba (0.854901961, 0.933333333, 0.984313725, 0.6); 66 | } 67 | context.set_line_width (1); 68 | roundedrec (context, x, y + dy, box_width, box_height, 4, true); 69 | roundedrec (context, x, y + dy, box_width, box_height, 4, false); 70 | context.move_to (x + box_dx_text - 1, y + dy + box_height - box_mdy_text); 71 | /* draw text */ 72 | context.set_source_rgba (0.145098039, 0.42745098, 0.615686275, 1); 73 | context.show_text (this.result.value); 74 | context.stroke (); 75 | 76 | return true; 77 | } 78 | 79 | private void roundedrec (Cairo.Context cr, int x, int y, int width, int height, int radius = 5, bool fill = false) { 80 | int x0 = x + radius / 2; 81 | int y0 = y + radius / 2; 82 | int rect_width = width - radius; 83 | int rect_height = height - radius; 84 | 85 | cr.save (); 86 | 87 | int x1 = x0 + rect_width; 88 | int y1 = y0 + rect_height; 89 | 90 | if (rect_width / 2 < radius) { 91 | if (rect_height / 2 < radius) { 92 | cr.move_to (x0, (y0 + y1) / 2); 93 | cr.curve_to (x0, y0, x0, y0, (x0 + x1) / 2, y0); 94 | cr.curve_to (x1, y0, x1, y0, x1, (y0 + y1) / 2); 95 | cr.curve_to (x1, y1, x1, y1, (x1 + x0) / 2, y1); 96 | cr.curve_to (x0, y1, x0, y1, x0, (y0 + y1) / 2); 97 | } else { 98 | cr.move_to (x0, y0 + radius); 99 | cr.curve_to (x0, y0, x0, y0, (x0 + x1) / 2, y0); 100 | cr.curve_to (x1, y0, x1, y0, x1, y0 + radius); 101 | cr.line_to (x1, y1 - radius); 102 | cr.curve_to (x1, y1, x1, y1, (x1 + x0) / 2, y1); 103 | cr.curve_to (x0, y1, x0, y1, x0, y1 - radius); 104 | } 105 | } else { 106 | if (rect_height / 2 < radius) { 107 | cr.move_to (x0, (y0 + y1) / 2); 108 | cr.curve_to (x0, y0, x0, y0, x0 + radius, y0); 109 | cr.line_to (x1 - radius, y0); 110 | cr.curve_to (x1, y0, x1, y0, x1, (y0 + y1) / 2); 111 | cr.curve_to (x1, y1, x1, y1, x1 - radius, y1); 112 | cr.line_to (x0 + radius, y1); 113 | cr.curve_to (x0, y1, x0, y1, x0, (y0 + y1) / 2); 114 | } else { 115 | cr.move_to (x0, y0 + radius); 116 | cr.curve_to (x0, y0, x0, y0, x0 + radius, y0); 117 | cr.line_to (x1 - radius, y0); 118 | cr.curve_to (x1, y0, x1, y0, x1, y0 + radius); 119 | cr.line_to (x1, y1 - radius); 120 | cr.curve_to (x1, y1, x1, y1, x1 - radius, y1); 121 | cr.line_to (x0 + radius, y1); 122 | cr.curve_to (x0, y1, x0, y1, x0, y1 - radius); 123 | } 124 | } 125 | 126 | cr.close_path (); 127 | 128 | if (fill) { 129 | cr.fill (); 130 | } 131 | 132 | cr.restore (); 133 | } 134 | } -------------------------------------------------------------------------------- /data/styles/nasc.xml: -------------------------------------------------------------------------------- 1 | 2 | 25 | 26 | 27 | 28 | Matthew Cantelon 29 | <_description>Adapted Solarized Light for NaSC 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 |