Skip to content

Commit

Permalink
1.1.0 - Conversions added // Port to GLib.Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Jan 27, 2020
1 parent 7352c8c commit 81bfc83
Show file tree
Hide file tree
Showing 11 changed files with 315 additions and 143 deletions.
9 changes: 9 additions & 0 deletions data/com.github.lainsce.niu.appdata.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@
<content_attribute id="money-gambling">none</content_attribute>
</content_rating>
<releases>
<release version="1.1.0" date="2020-01-30">
<description>
<p>Release: Conversion of Energy</p>
<ul>
<li>Added: Converters of Date and Time to the Nataniev System</li>
<li>Minor backend fixes</li>
</ul>
</description>
</release>
<release version="1.0.4" date="2019-08-08">
<description>
<p>Release: World Clock</p>
Expand Down
Binary file modified data/shot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions data/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,16 @@
font-weight: 300;
font-size: 3.33em;
}

.niu-sts {
background-color: #666;
border: 1px solid transparent;
}

.niu-sts > * {
box-shadow: none;
}

.niu-sts > * > * {
color: #CCC;
}
13 changes: 10 additions & 3 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Name our project
project('com.github.lainsce.niu', ['vala', 'c'],
version: '1.0.4'
version: '1.1.0'
)

# Import main lib files
Expand Down Expand Up @@ -56,7 +56,6 @@ executable(
'src/DBusServer.vala',
'src/Updater.vala',
'src/Utils.vala',
'src/Constants/AppSettings.vala',
asresources,
c_args: c_args,
dependencies: [
Expand All @@ -72,6 +71,7 @@ executable(
install : true
)

# If there's a better way to sync GLib.Settings between modules, tell me!
shared_module(
'niu',
'src/Indicator/Indicator.vala',
Expand All @@ -81,7 +81,10 @@ shared_module(
'src/Indicator/Widgets/Time.vala',
'src/Indicator/Widgets/Cal.vala',
'src/Utils.vala',
'src/Constants/AppSettings.vala',
'src/Application.vala',
'src/MainWindow.vala',
'src/Updater.vala',
'src/DBusServer.vala',
icon_resources,
c_args: c_args,
dependencies: [
Expand All @@ -90,6 +93,10 @@ shared_module(
dependency('gtk+-3.0'),
dependency('wingpanel-2.0')
],
vala_args: [
meson.source_root() + '/vapi/config.vapi',
'--vapidir=' + meson.source_root() + '/vapi/',
],
install: true,
install_dir : '/usr/lib/x86_64-linux-gnu/wingpanel/'
)
Expand Down
14 changes: 9 additions & 5 deletions src/Application.vala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace Niu {
private static bool status_background = false;
private static bool start_in_background = false;
public string[] args;
public static GLib.Settings gsettings;

private const GLib.OptionEntry[] cmd_options = {
// --start-in-background
Expand All @@ -37,8 +38,11 @@ namespace Niu {
status_background = status_indicator;
}

static construct {
gsettings = new GLib.Settings ("com.github.lainsce.niu");
}

protected override void activate () {
var settings = AppSettings.get_default ();
app_window = new MainWindow (this);
// only have one window
if (get_windows () != null) {
Expand All @@ -48,13 +52,13 @@ namespace Niu {
}

// start in background with indicator
if (status_background || settings.background_state) {
if (!settings.indicator_state) {
settings.indicator_state = true;
if (status_background || gsettings.get_boolean ("background_state")) {
if (!gsettings.get_boolean ("indicator_state")) {
gsettings.set_boolean ("indicator_state", true);
}

app_window.hide ();
settings.background_state = true;
gsettings.set_boolean ("background_state", true);
} else {
app_window.show_all ();
}
Expand Down
40 changes: 0 additions & 40 deletions src/Constants/AppSettings.vala

This file was deleted.

33 changes: 20 additions & 13 deletions src/Indicator/Indicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,43 @@ public class Niu.Indicator : Wingpanel.Indicator {
private DBusClient dbusclient;

construct {
var settings = AppSettings.get_default ();
this.visible = false;
display_widget = new Widgets.DisplayWidget ();
popover_widget = new Widgets.PopoverWidget ();

dbusclient = DBusClient.get_default ();
dbusclient.niu_vanished.connect (() => this.visible = false);
dbusclient.niu_appeared.connect (() => this.visible = settings.indicator_state);
dbusclient.niu_appeared.connect (() => this.visible = Niu.Application.gsettings.get_boolean ("indicator_state"));
dbusclient.interface.indicator_state.connect((state) => this.visible = state);
dbusclient.interface.update.connect((res) => {
if (settings.beats) {
if (Niu.Application.gsettings.get_boolean ("beats")) {
display_widget.time.time_str = res.bt;
} else {
display_widget.time.time_str = res.ne;
}
popover_widget.cal.cal_str = res.ar;
if (res.po) {
settings.pomodoro = res.po;
Niu.Application.gsettings.set_boolean ("pomodoro", res.po);
}
});

popover_widget.quit_niu.connect (() => {
dbusclient.interface.quit_niu ();
this.visible = false;
});
popover_widget.show_niu.connect (() => {
close ();
dbusclient.interface.show_niu ();
});
popover_widget.show_all ();
try {
try {
popover_widget.quit_niu.connect (() => {
dbusclient.interface.quit_niu ();
this.visible = false;
});
popover_widget.show_niu.connect (() => {
close ();
dbusclient.interface.show_niu ();
});
popover_widget.show_all ();
} catch (GLib.IOError err) {
warning (err.message);
}
} catch (GLib.DBusError err) {
warning (err.message);
}
}

/* Constructor */
Expand Down
9 changes: 4 additions & 5 deletions src/Indicator/Widgets/PopoverWidget.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ public class Niu.Widgets.PopoverWidget : Gtk.Grid {
show_niu_button.hexpand = true;
show_niu_button.clicked.connect (() => show_niu ());

var settings = AppSettings.get_default ();
start_pomodore_button = new Wingpanel.Widgets.Switch (_("Start Pomodoro…"), settings.pomodoro);
start_pomodore_button = new Wingpanel.Widgets.Switch (_("Start Pomodoro…"), Niu.Application.gsettings.get_boolean ("pomodoro"));
start_pomodore_button.get_switch ().notify["active"].connect (() => {
settings.pomodoro = start_pomodore_button.get_switch ().state;
Niu.Application.gsettings.set_boolean ("pomodoro", start_pomodore_button.get_switch ().state);
});

beats_button = new Wingpanel.Widgets.Switch (_("Show Only Beats"), settings.beats);
beats_button = new Wingpanel.Widgets.Switch (_("Show Only Beats"), Niu.Application.gsettings.get_boolean ("beats"));
beats_button.margin_bottom = 6;
beats_button.get_switch ().notify["active"].connect (() => {
settings.beats = beats_button.get_switch ().state;
Niu.Application.gsettings.set_boolean ("beats", beats_button.get_switch ().state);
});

quit_niu_button = new Gtk.ModelButton ();
Expand Down
7 changes: 3 additions & 4 deletions src/Indicator/Widgets/Time.vala
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ public class Niu.Widgets.TimeWidget : Gtk.Box {
Gtk.IconTheme.get_default().add_resource_path("/com/github/lainsce/niu/icons");

var icon = new Gtk.Image ();
var settings = AppSettings.get_default ();
if (settings.pomodoro) {
if (Niu.Application.gsettings.get_boolean ("pomodoro")) {
icon.set_from_icon_name ("pomodoro-symbolic", (Gtk.IconSize)3);
} else {
icon.set_from_icon_name ("no-pomodoro-symbolic", (Gtk.IconSize)3);
}
settings.changed.connect (() => {
if (settings.pomodoro) {
Niu.Application.gsettings.changed.connect (() => {
if (Niu.Application.gsettings.get_boolean ("pomodoro")) {
icon.set_from_icon_name ("pomodoro-symbolic", (Gtk.IconSize)3);
} else {
icon.set_from_icon_name ("no-pomodoro-symbolic", (Gtk.IconSize)3);
Expand Down
Loading

0 comments on commit 81bfc83

Please sign in to comment.