Skip to content
This repository has been archived by the owner on Jun 14, 2020. It is now read-only.

Commit

Permalink
1.2.4 - New change ticker // Add Bitcoin Cash option
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Sep 7, 2018
1 parent 5750220 commit 21e6c7f
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 30 deletions.
9 changes: 9 additions & 0 deletions data/com.github.lainsce.coin.appdata.xml
Expand Up @@ -55,6 +55,15 @@
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<releases>
<release version="1.2.4" date="2018-09-07">
<description>
<p>Release: Ticker Ticking</p>
<ul>
<li>A new change of value ticker for the day.</li>
<li>Added Bitcoin Cash virtual currency.</li>
</ul>
</description>
</release>
<release version="1.2.3" date="2018-07-13">
<description>
<p>Release: 1 2 3, hello Juno!</p>
Expand Down
Binary file modified data/shot.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 24 additions & 1 deletion data/stylesheet.css
@@ -1,9 +1,32 @@
@define-color colorPrimary #badbad;
@define-color textColorPrimary #113311;
@define-color borderPrimary #445533;
@define-color textColorPrimary #223311;

.titlebar,
.background {
background-color: @colorPrimary;
border: none;
color: @textColorPrimary;
}

.coin-toolbar {
background: @colorPrimary;
color: @textColorPrimary;
}

combobox > box > button {
background: @colorPrimary;
color: @textColorPrimary;
}

cellview {
color: @textColorPrimary;
}

.negative-icon {
color: @STRAWBERRY_500;
}

.positive-icon {
color: @LIME_500;
}
7 changes: 7 additions & 0 deletions debian/changelog
@@ -1,3 +1,10 @@
com.github.lainsce.coin (1.2.4) xenial; urgency=low

* New change ticker.
* Add Bitcoin Cash.

-- Lains <lainsce@airmail.cc> Fri, 7 Sep 2018 17:00:00 -0300

com.github.lainsce.coin (1.2.3) xenial; urgency=low

* Translations.
Expand Down
2 changes: 1 addition & 1 deletion meson.build
@@ -1,6 +1,6 @@
# Name our project
project('com.github.lainsce.coin', ['vala', 'c'],
version: '1.2.1'
version: '1.2.2'
)

# Import main lib files
Expand Down
3 changes: 3 additions & 0 deletions meson/post_install.py
Expand Up @@ -7,3 +7,6 @@
if not os.environ.get('DESTDIR'):
print('Compiling gsettings schemas...')
subprocess.call(['glib-compile-schemas', schemadir], shell=False)

print('Rebuilding desktop icons cache...')
subprocess.call(['gtk-update-icon-cache', '/usr/share/icons/hicolor/'], shell=False)
141 changes: 113 additions & 28 deletions src/MainWindow.vala
Expand Up @@ -20,28 +20,27 @@ using Soup;
using Json;

namespace Coin {
public class MainWindow : Gtk.Dialog {
public class MainWindow : Gtk.ApplicationWindow {
public Gtk.Label label_result;
public Gtk.Label label_info;
public Gtk.Label label_eth_result;
public Gtk.Label label_history;
public Gtk.ComboBoxText base_currency;
public Gtk.ComboBoxText base_vcurrency;
public Gtk.Stack stack;
public Gtk.Image aicon;

public double avg;
public string time;
public double avg_history;
public string coin_iso;
public string vcoin_iso;

public MainWindow (Gtk.Application application) {
GLib.Object (application: application,
icon_name: "com.github.lainsce.coin",
resizable: false,
title: ("Coin"),
height_request: 280,
width_request: 500,
border_width: 0,
window_position: Gtk.WindowPosition.CENTER
icon_name: "com.github.lainsce.coin",
resizable: false,
height_request: 280,
width_request: 500,
border_width: 6
);
}

Expand All @@ -52,6 +51,18 @@ namespace Coin {
set_keep_below (true);
stick ();

var titlebar = new Gtk.HeaderBar ();
titlebar.has_subtitle = false;
titlebar.show_close_button = true;


var titlebar_style_context = titlebar.get_style_context ();
titlebar_style_context.add_class (Gtk.STYLE_CLASS_FLAT);
titlebar_style_context.add_class ("default-decoration");
titlebar_style_context.add_class ("coin-toolbar");

this.set_titlebar (titlebar);

var settings = AppSettings.get_default ();
this.get_style_context ().add_class ("rounded");

Expand All @@ -62,14 +73,14 @@ namespace Coin {
base_currency.append_text(_("Euro"));
base_currency.append_text(_("British Pound"));
base_currency.append_text(_("Australian Dollar"));
base_currency.append_text(_("Brazilian Real"));
base_currency.append_text(_("Canadian Dollar"));
base_currency.append_text(_("Chinese Yuan"));
base_currency.append_text(_("Indian Rupee"));
base_currency.append_text(_("Japanese Yen"));
base_currency.append_text(_("Russian Ruble"));
base_currency.append_text(_("Brazilian Real"));
base_currency.append_text(_("Canadian Dollar"));
base_currency.append_text(_("Chinese Yuan"));
base_currency.append_text(_("Indian Rupee"));
base_currency.append_text(_("Japanese Yen"));
base_currency.append_text(_("Russian Ruble"));
base_currency.append_text(_("S. African Rand"));
base_currency.margin = 6;
base_currency.margin = 6;

if (settings.coin == 0) {
base_currency.set_active(0);
Expand Down Expand Up @@ -110,15 +121,16 @@ namespace Coin {
}

base_vcurrency = new Gtk.ComboBoxText();
base_vcurrency.append_text("Bitcoin");
base_vcurrency.append_text("Dashcoin");
base_vcurrency.append_text("Ethereum");
base_vcurrency.append_text("Litecoin");
base_vcurrency.append_text("Peercoin");
base_vcurrency.append_text("Ripple");
base_vcurrency.append_text("ZCash");
base_vcurrency.append_text("Bitcoin");
base_vcurrency.append_text("Dashcoin");
base_vcurrency.append_text("Ethereum");
base_vcurrency.append_text("Litecoin");
base_vcurrency.append_text("Peercoin");
base_vcurrency.append_text("Ripple");
base_vcurrency.append_text("ZCash");
base_vcurrency.append_text("Monero");
base_vcurrency.margin = 6;
base_vcurrency.append_text("Bitcoin Cash");
base_vcurrency.margin = 6;

if (settings.virtualcoin == 0) {
base_vcurrency.set_active(0);
Expand All @@ -144,6 +156,9 @@ namespace Coin {
} else if (settings.virtualcoin == 7) {
base_vcurrency.set_active(7);
vcoin_iso = "XMR";
} else if (settings.virtualcoin == 8) {
base_vcurrency.set_active(8);
vcoin_iso = "BCH";
} else {
base_vcurrency.set_active(0);
vcoin_iso = "BTC";
Expand All @@ -155,9 +170,34 @@ namespace Coin {
label_info = new Gtk.Label (_("Updated every 10 seconds"));
label_info.set_halign (Gtk.Align.END);
label_info.hexpand = true;
label_history = new Gtk.Label ("");
label_result.set_halign (Gtk.Align.START);

aicon = new Gtk.Image ();
aicon.icon_size = Gtk.IconSize.SMALL_TOOLBAR;

if (avg_history <= 0.0) {
aicon.icon_name = "go-down-symbolic";
var context = aicon.get_style_context ();
context.add_class ("negative-icon");
context.remove_class ("positive-icon");
} else {
aicon.icon_name = "go-up-symbolic";
var context = aicon.get_style_context ();
context.remove_class ("negative-icon");
context.add_class ("positive-icon");
}

get_values ();
set_labels ();

var avg_grid = new Gtk.Grid ();
avg_grid.margin_top = 0;
avg_grid.margin_start = 6;
avg_grid.column_spacing = 6;
avg_grid.attach (aicon, 0, 0, 1, 1);
avg_grid.attach (label_history, 1, 0, 1, 1);

var grid = new Gtk.Grid ();
grid.margin_top = 0;
grid.column_homogeneous = true;
Expand All @@ -167,6 +207,7 @@ namespace Coin {
grid.attach (base_currency, 0, 1, 2, 1);
grid.attach (base_vcurrency, 2, 1, 2, 1);
grid.attach (label_result, 1, 2, 3, 2);
grid.attach (avg_grid, 0, 4, 1, 1);
grid.attach (label_info, 1, 4, 3, 2);

stack = new Gtk.Stack ();
Expand All @@ -176,22 +217,58 @@ namespace Coin {
stack.homogeneous = true;
stack.add_named (grid, "money");

((Gtk.Container) get_content_area ()).add (stack);
this.add (stack);
stack.show_all ();

base_currency.changed.connect (() => {
get_values ();
set_labels ();

if (avg_history <= 0.0) {
aicon.icon_name = "go-down-symbolic";
var context = aicon.get_style_context ();
context.add_class ("negative-icon");
context.remove_class ("positive-icon");
} else {
aicon.icon_name = "go-up-symbolic";
var context = aicon.get_style_context ();
context.remove_class ("negative-icon");
context.add_class ("positive-icon");
}
});

base_vcurrency.changed.connect (() => {
get_values ();
set_labels ();

if (avg_history <= 0.0) {
aicon.icon_name = "go-down-symbolic";
var context = aicon.get_style_context ();
context.add_class ("negative-icon");
context.remove_class ("positive-icon");
} else {
aicon.icon_name = "go-up-symbolic";
var context = aicon.get_style_context ();
context.remove_class ("negative-icon");
context.add_class ("positive-icon");
}
});

Timeout.add_seconds (10, () => {
get_values ();
set_labels ();

if (avg_history <= 0.0) {
aicon.icon_name = "go-down-symbolic";
var context = aicon.get_style_context ();
context.add_class ("negative-icon");
context.remove_class ("positive-icon");
} else {
aicon.icon_name = "go-up-symbolic";
var context = aicon.get_style_context ();
context.remove_class ("negative-icon");
context.add_class ("positive-icon");
}
});

int x = settings.window_x;
Expand Down Expand Up @@ -276,6 +353,8 @@ namespace Coin {
vcoin_iso = "ZEC";
} else if (settings.virtualcoin == 7) {
vcoin_iso = "XMR";
} else if (settings.virtualcoin == 8) {
vcoin_iso = "BCH";
}
debug ("Chose %s".printf(vcoin_iso));

Expand All @@ -293,6 +372,7 @@ namespace Coin {
var from_object = response_object.get_object_member ("%s".printf(vcoin_iso));
var to_object = from_object.get_object_member ("%s".printf(coin_iso));
avg = to_object.get_double_member("PRICE");
avg_history = to_object.get_double_member("CHANGE24HOUR");
} catch (Error e) {
warning ("Failed to connect to service: %s", e.message);
}
Expand Down Expand Up @@ -334,7 +414,7 @@ namespace Coin {
break;
default:
curr_symbol = "¤";
break;
break;
}

var vcurr_symbol = "";
Expand Down Expand Up @@ -364,12 +444,17 @@ namespace Coin {
case 7:
vcurr_symbol = "ɱ";
break;
case 8:
vcurr_symbol = "BC";
break;
default:
curr_symbol = "¬";
break;
break;
}

label_result.set_markup ("""<span font="22">%s</span> <span font="30">%.1f</span> <span font="18">/ 1 %s</span>""".printf(curr_symbol, avg, vcurr_symbol));

label_history.set_markup ("""<span font="10">%.1f</span>""".printf(avg_history));
}
}
}

0 comments on commit 21e6c7f

Please sign in to comment.