Skip to content
This repository was archived by the owner on Mar 3, 2018. It is now read-only.

Commit 2efc147

Browse files
author
Rolandas Barysas
committed
added refresh interval option, integrated glade
1 parent 46132b5 commit 2efc147

File tree

3 files changed

+159
-26
lines changed

3 files changed

+159
-26
lines changed

apps.twitch-indicator.gschema.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,11 @@
1212
<summary>Enable live stream notifications</summary>
1313
<description>When followed channel goes live, will show a notification.</description>
1414
</key>
15+
16+
<key type="i" name="refresh-interval">
17+
<default>5</default>
18+
<summary>Refresh interval.</summary>
19+
<description>How many minutes should indicator wait between refreshing your followed channels.</description>
20+
</key>
1521
</schema>
1622
</schemalist>

run.py

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ def refresh_streams_init(self, widget, button_activate=False):
130130
self.t.start()
131131

132132
if (button_activate is False):
133-
self.timeout_thread = threading.Timer(360, self.refresh_streams_init, [None])
133+
self.timeout_thread = threading.Timer(self.settings.get_int("refresh-interval")*60, self.refresh_streams_init, [None])
134134
self.timeout_thread.start()
135135

136136
def settings_dialog(self, widget):
@@ -143,37 +143,21 @@ def settings_dialog(self, widget):
143143
gtk.STOCK_OK, gtk.ResponseType.OK)
144144
)
145145

146-
self.table = gtk.Table(2, 2, False)
146+
self.builder = gtk.Builder()
147+
self.builder.add_from_file("twitch-indicator.glade")
147148

148-
self.username_label = gtk.Label("Twitch username:", xalign=1)
149-
self.username_input = gtk.Entry()
150-
self.username_input.set_text(self.settings.get_string("twitch-username"))
151-
152-
self.notifications_label = gtk.Label("Enable notifications:", xalign=1)
153-
self.notifications_checkbox = gtk.Switch()
154-
self.notifications_checkbox.set_active(self.settings.get_boolean("enable-notifications"))
155-
156-
self.table.attach(self.username_label, 0, 1, 0, 1, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 4)
157-
self.table.attach(self.username_input, 1, 2, 0, 1, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 4)
158-
self.table.attach(self.notifications_label, 0, 1, 1, 2, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 6)
159-
self.table.attach(self.notifications_checkbox, 1, 2, 1, 2, gtk.AttachOptions.EXPAND, gtk.AttachOptions.FILL, 10, 6)
160-
161-
self.grid = gtk.Grid.new()
162-
self.grid.attach(self.table, 0, 0, 0, 0)
163-
164-
self.username_label.show()
165-
self.username_input.show()
166-
self.notifications_label.show()
167-
self.notifications_checkbox.show()
168-
self.table.show()
149+
self.builder.get_object("twitch_username").set_text(self.settings.get_string("twitch-username"))
150+
self.builder.get_object("show_notifications").set_active(self.settings.get_boolean("enable-notifications"))
151+
self.builder.get_object("refresh_interval").set_value(self.settings.get_int("refresh-interval"))
169152

170153
self.box = self.dialog.get_content_area()
171-
self.box.add(self.table)
154+
self.box.add(self.builder.get_object("box1"))
172155
self.response = self.dialog.run()
173156

174157
if self.response == gtk.ResponseType.OK:
175-
self.settings.set_string("twitch-username", self.username_input.get_text())
176-
self.settings.set_boolean("enable-notifications", self.notifications_checkbox.get_active())
158+
self.settings.set_string("twitch-username", self.builder.get_object("twitch_username").get_text())
159+
self.settings.set_boolean("enable-notifications", self.builder.get_object("show_notifications").get_active())
160+
self.settings.set_int("refresh-interval", self.builder.get_object("refresh_interval").get_value_as_int())
177161
elif self.response == gtk.ResponseType.CANCEL:
178162
pass
179163

twitch-indicator.glade

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Generated with glade 3.18.3 -->
3+
<interface>
4+
<requires lib="gtk+" version="3.12"/>
5+
<object class="GtkAdjustment" id="adjustment1">
6+
<property name="lower">1</property>
7+
<property name="upper">60</property>
8+
<property name="value">1</property>
9+
<property name="step_increment">1</property>
10+
<property name="page_increment">1</property>
11+
</object>
12+
<object class="GtkBox" id="box1">
13+
<property name="visible">True</property>
14+
<property name="can_focus">False</property>
15+
<property name="margin_left">15</property>
16+
<property name="margin_right">15</property>
17+
<property name="margin_top">10</property>
18+
<property name="margin_bottom">10</property>
19+
<property name="orientation">vertical</property>
20+
<property name="spacing">10</property>
21+
<child>
22+
<object class="GtkGrid" id="grid1">
23+
<property name="visible">True</property>
24+
<property name="can_focus">False</property>
25+
<property name="column_spacing">10</property>
26+
<child>
27+
<object class="GtkLabel" id="label1">
28+
<property name="visible">True</property>
29+
<property name="can_focus">False</property>
30+
<property name="tooltip_text" translatable="yes">Your twitch.tv username.</property>
31+
<property name="margin_left">7</property>
32+
<property name="xalign">1</property>
33+
<property name="label" translatable="yes">Twitch username:</property>
34+
</object>
35+
<packing>
36+
<property name="left_attach">0</property>
37+
<property name="top_attach">0</property>
38+
</packing>
39+
</child>
40+
<child>
41+
<object class="GtkEntry" id="twitch_username">
42+
<property name="visible">True</property>
43+
<property name="can_focus">True</property>
44+
</object>
45+
<packing>
46+
<property name="left_attach">1</property>
47+
<property name="top_attach">0</property>
48+
</packing>
49+
</child>
50+
</object>
51+
<packing>
52+
<property name="expand">False</property>
53+
<property name="fill">True</property>
54+
<property name="position">0</property>
55+
</packing>
56+
</child>
57+
<child>
58+
<object class="GtkGrid" id="grid2">
59+
<property name="visible">True</property>
60+
<property name="can_focus">False</property>
61+
<property name="column_spacing">10</property>
62+
<child>
63+
<object class="GtkLabel" id="label2">
64+
<property name="visible">True</property>
65+
<property name="can_focus">False</property>
66+
<property name="tooltip_text" translatable="yes">Shows notifications when your followed channels go live.</property>
67+
<property name="label" translatable="yes">Show notifications:</property>
68+
</object>
69+
<packing>
70+
<property name="left_attach">0</property>
71+
<property name="top_attach">0</property>
72+
</packing>
73+
</child>
74+
<child>
75+
<object class="GtkSwitch" id="show_notifications">
76+
<property name="visible">True</property>
77+
<property name="can_focus">True</property>
78+
</object>
79+
<packing>
80+
<property name="left_attach">1</property>
81+
<property name="top_attach">0</property>
82+
</packing>
83+
</child>
84+
</object>
85+
<packing>
86+
<property name="expand">False</property>
87+
<property name="fill">True</property>
88+
<property name="position">1</property>
89+
</packing>
90+
</child>
91+
<child>
92+
<object class="GtkGrid" id="grid3">
93+
<property name="visible">True</property>
94+
<property name="can_focus">False</property>
95+
<property name="column_spacing">10</property>
96+
<child>
97+
<object class="GtkLabel" id="label3">
98+
<property name="visible">True</property>
99+
<property name="can_focus">False</property>
100+
<property name="tooltip_text" translatable="yes">How many minutes should indicator wait between refreshing your followed channels.</property>
101+
<property name="margin_left">16</property>
102+
<property name="label" translatable="yes">Refresh interval:</property>
103+
</object>
104+
<packing>
105+
<property name="left_attach">0</property>
106+
<property name="top_attach">0</property>
107+
</packing>
108+
</child>
109+
<child>
110+
<object class="GtkLabel" id="label4">
111+
<property name="visible">True</property>
112+
<property name="can_focus">False</property>
113+
<property name="xalign">0</property>
114+
<property name="label" translatable="yes">min.</property>
115+
<property name="ellipsize">start</property>
116+
</object>
117+
<packing>
118+
<property name="left_attach">2</property>
119+
<property name="top_attach">0</property>
120+
</packing>
121+
</child>
122+
<child>
123+
<object class="GtkSpinButton" id="refresh_interval">
124+
<property name="visible">True</property>
125+
<property name="can_focus">True</property>
126+
<property name="progress_pulse_step">1</property>
127+
<property name="adjustment">adjustment1</property>
128+
<property name="climb_rate">1</property>
129+
</object>
130+
<packing>
131+
<property name="left_attach">1</property>
132+
<property name="top_attach">0</property>
133+
</packing>
134+
</child>
135+
</object>
136+
<packing>
137+
<property name="expand">False</property>
138+
<property name="fill">True</property>
139+
<property name="position">2</property>
140+
</packing>
141+
</child>
142+
</object>
143+
</interface>

0 commit comments

Comments
 (0)