-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Prayer Time #35
base: master
Are you sure you want to change the base?
add Prayer Time #35
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,6 +125,33 @@ const App = new Lang.Class({ | |
this.vbox2.add(item); | ||
Schema.bind('event-world', item, 'active', Gio.SettingsBindFlags.DEFAULT); | ||
|
||
//PrayTimes | ||
this.vbox2.add(new Gtk.Label({ | ||
label: _('PrayTime:\n<span size="x-small">("PrayTime" based on geographical location)</span>'), | ||
use_markup: true | ||
})); | ||
item = new Gtk.CheckButton({label: _('Show Pray Time')}); | ||
this.vbox2.add(item); | ||
Schema.bind('praytime-visible', item, 'active', Gio.SettingsBindFlags.DEFAULT); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please disable this and Azaan options, by default. |
||
|
||
item = new Gtk.CheckButton({label: _('Play Azaan')}); | ||
this.vbox2.add(item); | ||
Schema.bind('praytime-play', item, 'active', Gio.SettingsBindFlags.DEFAULT); | ||
|
||
|
||
let _item = this.createTextEntry('praytime-lat', 'Latitude: '); | ||
this.vbox2.add(_item.hbox); | ||
if(_item.comment) this.vbox2.add(_item.comment); | ||
|
||
_item = this.createTextEntry('praytime-lng', 'Longitude: '); | ||
this.vbox2.add(_item.hbox); | ||
if(_item.comment) this.vbox2.add(_item.comment); | ||
|
||
_item = this.createTextEntry('praytime-timezone', 'Timezone: '); | ||
this.vbox2.add(_item.hbox); | ||
if(_item.comment) this.vbox2.add(_item.comment); | ||
|
||
|
||
// COLOR | ||
this.vbox3.add(new Gtk.Label({label: _('Widget Properties:')})); | ||
|
||
|
@@ -194,6 +221,25 @@ const App = new Lang.Class({ | |
|
||
this.main_hbox.show_all(); | ||
}, | ||
createTextEntry: function(value, labelText, commentText){ | ||
let label = new Gtk.Label({label: labelText}); | ||
let format = new Gtk.Entry(); | ||
let hbox = new Gtk.HBox(); | ||
hbox.add(label); | ||
hbox.add(format); | ||
let comment = null; | ||
if(commentText) | ||
comment = new Gtk.Label({ | ||
label: _(commentText), | ||
use_markup: true | ||
}); | ||
format.set_text(Schema.get_double(value).toString()); | ||
format.connect('changed', function (innerFormat) { | ||
Schema.set_string(value, innerFormat.text); | ||
}); | ||
|
||
return {hbox:hbox,comment:comment}; | ||
}, | ||
|
||
_scaleRound: function (value) { | ||
// Based on gtk/gtkcoloreditor.c | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,6 +60,31 @@ | |
<summary>Display official international events</summary> | ||
<description>Display official international events.</description> | ||
</key> | ||
<key name="praytime-visible" type="b"> | ||
<default>true</default> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
<summary>Display PrayTime</summary> | ||
<description>Display Pray time based on location</description> | ||
</key> | ||
<key name="praytime-play" type="b"> | ||
<default>true</default> | ||
<summary>Play Call to prayer song (Azaan)</summary> | ||
<description>Play Azan</description> | ||
</key> | ||
<key name="praytime-lat" type="d"> | ||
<default>35.689202</default> | ||
<summary>Latitude</summary> | ||
<description>your location latitude</description> | ||
</key> | ||
<key name="praytime-lng" type="d"> | ||
<default>51.388973</default> | ||
<summary>Latitude</summary> | ||
<description>your location latitude</description> | ||
</key> | ||
<key name="praytime-timezone" type="d"> | ||
<default>3.5</default> | ||
<summary>Timezone</summary> | ||
<description>Your timezone based on GMT</description> | ||
</key> | ||
<key name="widget-format" type="s"> | ||
<default>'%d'</default> | ||
<summary>Widget date format</summary> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
/* sound.js | ||
* | ||
* Copyright (C) 2017 Felipe Borges <[email protected]> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
|
||
const Gst = imports.gi.Gst; | ||
const GstAudio = imports.gi.GstAudio; | ||
|
||
const DEFAULT_VOLUME = 1; | ||
Gst.init(null); | ||
const SoundPlayer = class SoundPlayer { | ||
constructor(sound) { | ||
this.playbin = Gst.ElementFactory.make("playbin", sound.name); | ||
this.playbin.set_property("uri", this.getUri(sound)); | ||
this.sink = Gst.ElementFactory.make("pulsesink", "sink"); | ||
this.playbin.set_property("audio-sink", this.sink); | ||
|
||
this.prerolled = false; | ||
let bus = this.playbin.get_bus(); | ||
bus.add_signal_watch(); | ||
bus.connect("message", (bus, msg) => { | ||
if (msg != null) this._onMessageReceived(msg); | ||
}); | ||
} | ||
|
||
isPlaying() { | ||
let [rv, state, pstate] = this.playbin.get_state(Gst.State.NULL); | ||
return state === Gst.State.PLAYING; | ||
} | ||
|
||
|
||
play() { | ||
this.playbin.set_state(Gst.State.PLAYING); | ||
|
||
} | ||
|
||
pause() { | ||
this.playbin.set_state(Gst.State.NULL); | ||
this.prerolled = false; | ||
} | ||
|
||
setVolume(value) { | ||
this.playbin.set_volume(GstAudio.StreamVolumeFormat.LINEAR, value); | ||
if (value == 0) { | ||
this.playbin.set_state(Gst.State.NULL); | ||
} else if (!this.isPlaying()) { | ||
this.play(); | ||
} | ||
} | ||
|
||
_onMessageReceived(message) { | ||
if (message.type == Gst.MessageType.SEGMENT_DONE) { | ||
this.playbin.seek_simple(Gst.Format.TIME, Gst.SeekFlags.SEGMENT, 0); | ||
} | ||
if (message.type == Gst.MessageType.ASYNC_DONE) { | ||
if (!this.prerolled) { | ||
this.playbin.seek_simple( | ||
Gst.Format.TIME, | ||
Gst.SeekFlags.FLUSH | Gst.SeekFlags.SEGMENT, | ||
0 | ||
); | ||
this.prerolled = true; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
getUri(sound) { | ||
/* All URIs are relative to $HOME. */ | ||
return Gst.filename_to_uri(sound.uri); | ||
} | ||
}; | ||
|
||
var player = new SoundPlayer({name:"test",uri:".local/share/gnome-shell/extensions/[email protected]/sounds/azan.mp3"}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should remove this in the "disable" function.
And I would suggest adding it to the "enable" function.
Another suggestion is to ignore adding timeout when the feature is disabled.