From 9ee9956267315fa231fd54727e2e92a585a43bb3 Mon Sep 17 00:00:00 2001 From: Adrian Iain Lam Date: Sat, 1 Jun 2019 22:33:07 +0100 Subject: [PATCH] Previous uncommitted syntactical changes found on my local copy Also: including previously ignored icons/template.svg, because why not. --- icons/template.svg | 5 +++++ indicator-lunar-calendar.js | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 11 deletions(-) create mode 100644 icons/template.svg diff --git a/icons/template.svg b/icons/template.svg new file mode 100644 index 0000000..30aef43 --- /dev/null +++ b/icons/template.svg @@ -0,0 +1,5 @@ + + + 鼠牛虎兔龍蛇馬羊猴雞狗豬 + diff --git a/indicator-lunar-calendar.js b/indicator-lunar-calendar.js index ea4470f..16af28c 100755 --- a/indicator-lunar-calendar.js +++ b/indicator-lunar-calendar.js @@ -23,27 +23,27 @@ */ /* import dependencies */ -var GNode = require('node-gtk'); -var Gtk = GNode.importNS('Gtk'); -var AppIndicator3 = GNode.importNS('AppIndicator3'); +const gi = require('node-gtk'); +const Gtk = gi.require('Gtk', '3.0'); +const AppIndicator3 = gi.require('AppIndicator3'); var CronJob = require('cron').CronJob; var LunarCalendar = require('lunar-calendar-zh'); var DBus = require('dbus-native'); /* setup indicator object */ -GNode.startLoop(); -Gtk.init(null); +gi.startLoop(); +Gtk.init(); var indicator = AppIndicator3.Indicator.new( "lunar-indicator", __dirname + '/icons/鼠.svg', AppIndicator3.IndicatorCategory.APPLICATION_STATUS ); -indicator.set_status(AppIndicator3.IndicatorStatus.ACTIVE); +indicator.setStatus(AppIndicator3.IndicatorStatus.ACTIVE); var menu = new Gtk.Menu(); var item = new Gtk.MenuItem(); menu.append(item); -indicator.set_menu(menu); -menu.show_all(); +indicator.setMenu(menu); +menu.showAll(); function update_indicator() { /* get current time at UTC+8, add 1 to date if after 23:00 (子時) */ @@ -71,9 +71,9 @@ function update_indicator() { long_date += '\n' + lunar.hour + '時'; /* output to indicator */ - indicator.set_icon(__dirname + '/icons/' + lunar.zodiac + '.svg'); - indicator.set_label(compact_date, ''); - item.set_label(long_date); + indicator.setIcon(__dirname + '/icons/' + lunar.zodiac + '.svg'); + indicator.setLabel(compact_date, ''); + item.setLabel(long_date); console.log('Indicator updated. ' + lunar.hour + ' Time: ' + new Date()); /* DO NOT REMOVE THE ABOVE LINE. -- 2.7.4