| 1 |
/* rdp-preferences-window.vala |
| 2 |
* |
| 3 |
* Copyright (C) Red Hat, Inc |
| 4 |
* |
| 5 |
* This program is free software: you can redistribute it and/or modify |
| 6 |
* it under the terms of the GNU General Public License as published by |
| 7 |
* the Free Software Foundation, either version 3 of the License, or |
| 8 |
* (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, |
| 11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
* GNU General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
* |
| 18 |
* Author: Felipe Borges <[email protected]> |
| 19 |
* |
| 20 |
*/ |
| 21 |
|
| 22 |
namespace Connections { |
| 23 |
[GtkTemplate (ui = "/org/gnome/Connections/ui/rdp-preferences.ui")] |
| 24 |
private class RdpPreferencesWindow : Connections.PreferencesWindow { |
| 25 |
[GtkChild] |
| 26 |
private unowned Gtk.Entry connection_name_entry; |
| 27 |
[GtkChild] |
| 28 |
private unowned Gtk.Label host_address_label; |
| 29 |
[GtkChild] |
| 30 |
private unowned Gtk.ComboBoxText scale_mode_combo; |
| 31 |
|
| 32 |
public RdpPreferencesWindow (Connection connection) { |
| 33 |
this.connection = connection; |
| 34 |
|
| 35 |
update_scale_mode_combo (); |
| 36 |
|
| 37 |
bind_widget_property (connection_name_entry, "text", "display_name"); |
| 38 |
bind_widget_property (host_address_label, "label", "uri"); |
| 39 |
bind_widget_property (scale_mode_combo, "active_id", "scale-mode"); |
| 40 |
|
| 41 |
connection.notify["resize-supported"].connect (update_scale_mode_combo); |
| 42 |
} |
| 43 |
|
| 44 |
private void update_scale_mode_combo () { |
| 45 |
if ((((RdpConnection) connection).resize_supported || |
| 46 |
((RdpConnection) connection).scale_mode == "resize-desktop") && |
| 47 |
!combo_contains_item (scale_mode_combo, "resize-desktop")) { |
| 48 |
// Translators: Combo item for resizing remote desktop to window's size |
| 49 |
scale_mode_combo.insert (0, "resize-desktop", _("Resize desktop")); |
| 50 |
} |
| 51 |
} |
| 52 |
|
| 53 |
private bool combo_contains_item (Gtk.ComboBoxText combo_box, string item_id) { |
| 54 |
Gtk.TreeIter iter; |
| 55 |
string mode; |
| 56 |
|
| 57 |
if (scale_mode_combo.model.get_iter_first (out iter)) { |
| 58 |
scale_mode_combo.model.get (iter, 1, out mode); |
| 59 |
if (mode == item_id) { |
| 60 |
return true; |
| 61 |
} else { |
| 62 |
while (scale_mode_combo.model.iter_next (ref iter)) { |
| 63 |
scale_mode_combo.model.get (iter, 1, out mode); |
| 64 |
if (mode == item_id) |
| 65 |
return true; |
| 66 |
} |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
return false; |
| 71 |
} |
| 72 |
} |
| 73 |
} |