generated from pongloongyeat/wingpanel-indicator-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from jdmg94/develop
Develop
- Loading branch information
Showing
7 changed files
with
128 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
*~ | ||
build/ | ||
build/ | ||
|
||
debian | ||
|
||
obj-x86_64-linux-gnu |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
namespace TimeOptions { | ||
private int minutes_to_milis (int minutes) { | ||
int one_second = 1000; | ||
int one_minute = 60 * one_second; | ||
|
||
return minutes * one_minute; | ||
} | ||
|
||
private class Value { | ||
public string label; | ||
public int timeout; | ||
|
||
public Value (string label, int timeout) { | ||
this.label = label; | ||
this.timeout = timeout; | ||
} | ||
|
||
} | ||
|
||
public class ComboBox : Gtk.ComboBox { | ||
private Gtk.ListStore data; | ||
|
||
public ComboBox () { | ||
Gtk.TreeIter iterator; | ||
Gtk.CellRendererText renderer = new Gtk.CellRendererText (); | ||
|
||
this.data = new Gtk.ListStore (2, typeof (string), typeof (int)); | ||
|
||
TimeOptions.Value[] options = { | ||
new TimeOptions.Value ("30 Minutes", minutes_to_milis (30)), | ||
new TimeOptions.Value ("1 Hour", minutes_to_milis (60)), | ||
new TimeOptions.Value ("2 Hours", minutes_to_milis (120)), | ||
new TimeOptions.Value ("4 Hours", minutes_to_milis (240)), | ||
new TimeOptions.Value ("5 Hours", minutes_to_milis (300)), | ||
}; | ||
|
||
foreach (TimeOptions.Value item in options) { | ||
data.append (out iterator); | ||
data.set (iterator, 0, item.label, 1, item.timeout, -1); | ||
} | ||
|
||
this.set_model (data); | ||
this.set_active (0); | ||
this.pack_start (renderer, true); | ||
this.add_attribute (renderer, "text", 0); | ||
} | ||
|
||
public int get_selected_value () { | ||
int result = 0; | ||
Gtk.TreeIter iterator; | ||
|
||
if (this.get_active_iter (out iterator)) { | ||
this.data.get (iterator, 1, out result, -1); | ||
} | ||
|
||
return result; | ||
} | ||
|
||
} | ||
} |