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

Commit

Permalink
added refresh interval option, integrated glade
Browse files Browse the repository at this point in the history
  • Loading branch information
Rolandas Barysas committed Mar 20, 2015
1 parent 46132b5 commit 2efc147
Show file tree
Hide file tree
Showing 3 changed files with 159 additions and 26 deletions.
6 changes: 6 additions & 0 deletions apps.twitch-indicator.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,11 @@
<summary>Enable live stream notifications</summary>
<description>When followed channel goes live, will show a notification.</description>
</key>

<key type="i" name="refresh-interval">
<default>5</default>
<summary>Refresh interval.</summary>
<description>How many minutes should indicator wait between refreshing your followed channels.</description>
</key>
</schema>
</schemalist>
36 changes: 10 additions & 26 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def refresh_streams_init(self, widget, button_activate=False):
self.t.start()

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

def settings_dialog(self, widget):
Expand All @@ -143,37 +143,21 @@ def settings_dialog(self, widget):
gtk.STOCK_OK, gtk.ResponseType.OK)
)

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

self.username_label = gtk.Label("Twitch username:", xalign=1)
self.username_input = gtk.Entry()
self.username_input.set_text(self.settings.get_string("twitch-username"))

self.notifications_label = gtk.Label("Enable notifications:", xalign=1)
self.notifications_checkbox = gtk.Switch()
self.notifications_checkbox.set_active(self.settings.get_boolean("enable-notifications"))

self.table.attach(self.username_label, 0, 1, 0, 1, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 4)
self.table.attach(self.username_input, 1, 2, 0, 1, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 4)
self.table.attach(self.notifications_label, 0, 1, 1, 2, gtk.AttachOptions.FILL, gtk.AttachOptions.FILL, 10, 6)
self.table.attach(self.notifications_checkbox, 1, 2, 1, 2, gtk.AttachOptions.EXPAND, gtk.AttachOptions.FILL, 10, 6)

self.grid = gtk.Grid.new()
self.grid.attach(self.table, 0, 0, 0, 0)

self.username_label.show()
self.username_input.show()
self.notifications_label.show()
self.notifications_checkbox.show()
self.table.show()
self.builder.get_object("twitch_username").set_text(self.settings.get_string("twitch-username"))
self.builder.get_object("show_notifications").set_active(self.settings.get_boolean("enable-notifications"))
self.builder.get_object("refresh_interval").set_value(self.settings.get_int("refresh-interval"))

self.box = self.dialog.get_content_area()
self.box.add(self.table)
self.box.add(self.builder.get_object("box1"))
self.response = self.dialog.run()

if self.response == gtk.ResponseType.OK:
self.settings.set_string("twitch-username", self.username_input.get_text())
self.settings.set_boolean("enable-notifications", self.notifications_checkbox.get_active())
self.settings.set_string("twitch-username", self.builder.get_object("twitch_username").get_text())
self.settings.set_boolean("enable-notifications", self.builder.get_object("show_notifications").get_active())
self.settings.set_int("refresh-interval", self.builder.get_object("refresh_interval").get_value_as_int())
elif self.response == gtk.ResponseType.CANCEL:
pass

Expand Down
143 changes: 143 additions & 0 deletions twitch-indicator.glade
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.18.3 -->
<interface>
<requires lib="gtk+" version="3.12"/>
<object class="GtkAdjustment" id="adjustment1">
<property name="lower">1</property>
<property name="upper">60</property>
<property name="value">1</property>
<property name="step_increment">1</property>
<property name="page_increment">1</property>
</object>
<object class="GtkBox" id="box1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">15</property>
<property name="margin_right">15</property>
<property name="margin_top">10</property>
<property name="margin_bottom">10</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child>
<object class="GtkGrid" id="grid1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Your twitch.tv username.</property>
<property name="margin_left">7</property>
<property name="xalign">1</property>
<property name="label" translatable="yes">Twitch username:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="twitch_username">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">Shows notifications when your followed channels go live.</property>
<property name="label" translatable="yes">Show notifications:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSwitch" id="show_notifications">
<property name="visible">True</property>
<property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="column_spacing">10</property>
<child>
<object class="GtkLabel" id="label3">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="tooltip_text" translatable="yes">How many minutes should indicator wait between refreshing your followed channels.</property>
<property name="margin_left">16</property>
<property name="label" translatable="yes">Refresh interval:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">min.</property>
<property name="ellipsize">start</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="refresh_interval">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="progress_pulse_step">1</property>
<property name="adjustment">adjustment1</property>
<property name="climb_rate">1</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
</interface>

0 comments on commit 2efc147

Please sign in to comment.