-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1594b4e
commit 8d6d258
Showing
5 changed files
with
166 additions
and
7 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 |
---|---|---|
@@ -0,0 +1,83 @@ | ||
public class ScreenCast.Dialog : Granite.Dialog { | ||
public SourceType source_types { get; construct; } | ||
public bool allow_multiple { get; construct; } | ||
|
||
public Dialog (SourceType source_types, bool allow_multiple) { | ||
Object (source_types: source_types, allow_multiple: allow_multiple); | ||
} | ||
|
||
private List<SelectionRow> window_rows; | ||
private List<SelectionRow> monitor_rows; | ||
|
||
construct { | ||
window_rows = new List<SelectionRow> (); | ||
monitor_rows = new List<SelectionRow> (); | ||
|
||
var list_box = new Gtk.ListBox () { | ||
selection_mode = MULTIPLE, | ||
vexpand = true | ||
}; | ||
list_box.add_css_class ("boxed-list"); | ||
list_box.add_css_class (Granite.STYLE_CLASS_RICH_LIST); | ||
list_box.set_header_func (header_func); | ||
|
||
Gtk.CheckButton? group = null; | ||
|
||
if (WINDOW in source_types) { | ||
//TODO: populate windows | ||
} | ||
|
||
if (MONITOR in source_types) { | ||
var monitor_tracker = new MonitorTracker (); | ||
|
||
foreach (var monitor in monitor_tracker.monitors) { | ||
var row = new SelectionRow (MONITOR, monitor.connector, | ||
monitor.display_name, null, allow_multiple ? null : group); | ||
|
||
monitor_rows.append (row); | ||
|
||
group = row.check_button; | ||
|
||
list_box.append (row); | ||
} | ||
} | ||
|
||
get_content_area ().append (list_box); | ||
|
||
add_button (_("Cancel"), Gtk.ResponseType.CANCEL); | ||
add_button (_("Share"), Gtk.ResponseType.ACCEPT).add_css_class (Granite.STYLE_CLASS_SUGGESTED_ACTION); | ||
} | ||
|
||
private void header_func (Gtk.ListBoxRow row, Gtk.ListBoxRow? prev) { | ||
if (!(row is SelectionRow) && prev != null && !(prev is SelectionRow)) { | ||
return; | ||
} | ||
|
||
var selection_row = (SelectionRow) row; | ||
|
||
if (prev == null || ((SelectionRow) prev).source_type != selection_row.source_type) { | ||
var label = selection_row.source_type == WINDOW ? _("Windows") : _("Monitors"); | ||
selection_row.set_header (new Granite.HeaderLabel (label)); | ||
} | ||
} | ||
|
||
public uint64[] get_selected_windows () { | ||
uint64[] result = {}; | ||
foreach (var row in window_rows) { | ||
if (row.selected) { | ||
result += (uint64) row.id; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public string[] get_selected_monitors () { | ||
string[] result = {}; | ||
foreach (var row in monitor_rows) { | ||
if (row.selected) { | ||
result += (string) row.id; | ||
} | ||
} | ||
return result; | ||
} | ||
} |
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,39 @@ | ||
public class ScreenCast.SelectionRow : Gtk.ListBoxRow { | ||
public SourceType source_type { get; construct; } | ||
public Variant id { get; construct; } | ||
public string label { get; construct; } | ||
public Icon? icon { get; construct; } | ||
public Gtk.CheckButton? group { get; construct; } | ||
|
||
public Gtk.CheckButton check_button { get; construct; } | ||
|
||
public bool selected { get; set; default = false; } | ||
|
||
public SelectionRow (SourceType source_type, Variant id, string label, Icon? icon, Gtk.CheckButton? group) { | ||
Object ( | ||
source_type: source_type, | ||
id: id, | ||
label: label, | ||
icon: icon, | ||
group: group | ||
); | ||
} | ||
|
||
construct { | ||
var box = new Gtk.Box (HORIZONTAL, 6); | ||
|
||
check_button = new Gtk.CheckButton (); | ||
box.append (check_button); | ||
check_button.set_group (group); | ||
|
||
if (icon != null) { | ||
box.append (new Gtk.Image.from_gicon (icon)); | ||
} | ||
|
||
box.append (new Gtk.Label (label)); | ||
|
||
child = box; | ||
|
||
check_button.bind_property ("active", this, "selected", DEFAULT); | ||
} | ||
} |
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