A bit code cleanup

parent cdac7d6d
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<template class="RemotelyVncBox" parent="GtkBox">
......@@ -123,7 +123,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">No connection could be established.</property>
<property name="label" translatable="yes">No connection could be established</property>
<style>
<class name="dim-label"/>
</style>
......@@ -249,7 +249,7 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="spacing">10</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
......@@ -268,7 +268,6 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="margin_bottom">6</property>
<property name="label" translatable="yes">Authentication</property>
<attributes>
<attribute name="weight" value="bold"/>
......@@ -299,114 +298,90 @@
</packing>
</child>
<child>
<object class="GtkBox" id="clientname_box">
<object class="GtkGrid" id="auth_grid">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<property name="row_spacing">6</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="label3">
<object class="GtkEntry" id="clientname_entry">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Client</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="clientname_entry">
<object class="GtkEntry" id="username_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="input_purpose">password</property>
<property name="hexpand">True</property>
<property name="input_purpose">name</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="username_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label1">
<object class="GtkEntry" id="password_entry">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">User</property>
<property name="justify">right</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="visibility">False</property>
<property name="input_purpose">password</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">1</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="username_entry">
<object class="GtkLabel" id="clientname_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="input_purpose">name</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Clientname</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkBox" id="password_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="label2">
<object class="GtkLabel" id="username_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Password</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Username</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="password_entry">
<object class="GtkLabel" id="password_label">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="visibility">False</property>
<property name="input_purpose">password</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Password</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="left_attach">0</property>
<property name="top_attach">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">4</property>
<property name="position">2</property>
</packing>
</child>
<child>
......@@ -489,12 +464,5 @@
</packing>
</child>
</template>
<object class="GtkSizeGroup" id="sz">
<property name="ignore_hidden">True</property>
<widgets>
<widget name="label3"/>
<widget name="label1"/>
<widget name="label2"/>
</widgets>
</object>
<object class="GtkSizeGroup"/>
</interface>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.0 -->
<!-- Generated with glade 3.22.1 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkPopoverMenu" id="connection_menu_popover">
......@@ -60,7 +60,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Create new connection</property>
<property name="label" translatable="yes">Connect to client</property>
</object>
<packing>
<property name="expand">False</property>
......@@ -184,112 +184,10 @@
</child>
</object>
<template class="RemotelyWindow" parent="GtkApplicationWindow">
<property name="width_request">600</property>
<property name="height_request">500</property>
<property name="height_request">400</property>
<property name="can_focus">False</property>
<child>
<object class="GtkStack" id="vnc_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hhomogeneous">False</property>
<property name="vhomogeneous">False</property>
<property name="transition_type">crossfade</property>
<property name="interpolate_size">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">192</property>
<property name="icon_name">computer-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Not connected</property>
<attributes>
<attribute name="font-desc" value="Cantarell Bold 24"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">You can connect to a remote screen</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">no-connection</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="vnc_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="name">notebook</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<property name="default_width">700</property>
<property name="default_height">600</property>
<child type="titlebar">
<object class="GtkHeaderBar" id="header_bar">
<property name="visible">True</property>
......@@ -485,5 +383,108 @@
</child>
</object>
</child>
<child>
<object class="GtkStack" id="vnc_stack">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hhomogeneous">False</property>
<property name="vhomogeneous">False</property>
<property name="transition_type">crossfade</property>
<property name="interpolate_size">True</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">12</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">192</property>
<property name="icon_name">computer-symbolic</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Not connected</property>
<attributes>
<attribute name="font-desc" value="Cantarell Bold 24"/>
</attributes>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">You can connect to a remote screen</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="name">no-connection</property>
<property name="title" translatable="yes">page0</property>
</packing>
</child>
<child>
<object class="GtkNotebook" id="vnc_notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="show_tabs">False</property>
<property name="show_border">False</property>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child type="tab">
<placeholder/>
</child>
</object>
<packing>
<property name="name">notebook</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</template>
</interface>
......@@ -39,12 +39,11 @@ public class Remotely.VncBox : Box {
[GtkChild] Label notification_label;
[GtkChild] Entry username_entry;
[GtkChild] Label username_label;
[GtkChild] Entry clientname_entry;
[GtkChild] Label clientname_label;
[GtkChild] Entry password_entry;
[GtkChild] Box username_box;
[GtkChild] Box clientname_box;
[GtkChild] Box password_box;
[GtkChild] Label password_label;
public string host;
public string port;
......@@ -60,7 +59,7 @@ public class Remotely.VncBox : Box {
//display.lossy_encoding = true;
vnc_box.add(display);
connect();
connect_to_client();
connect_signals();
this.show_all();
......@@ -95,12 +94,12 @@ public class Remotely.VncBox : Box {
});
}
private void connect(){
private void connect_to_client(){
status_label.set_text("Establishing connection...");
display.open_host(host,port);
}
public void disconnect(){
public void disconnect_from_client(){
display.close();
this.destroy();
}
......@@ -155,23 +154,26 @@ public class Remotely.VncBox : Box {
notification_revealer.set_reveal_child(true);
notification_stack.set_visible_child_name("auth");
password_box.set_visible(false);
username_box.set_visible(false);
clientname_box.set_visible(false);
username_entry.set_visible(false);
username_label.set_visible(false);
clientname_entry.set_visible(false);
clientname_label.set_visible(false);
password_entry.set_visible(false);
password_label.set_visible(false);
foreach (Value val in authlist.values) {
DisplayCredential cred = (DisplayCredential)val.get_enum();
switch(cred){
case DisplayCredential.PASSWORD: password_box.set_visible(true); break;
case DisplayCredential.USERNAME: username_box.set_visible(true); break;
case DisplayCredential.CLIENTNAME: clientname_box.set_visible(true); break;
case DisplayCredential.PASSWORD: password_entry.set_visible(true); password_label.set_visible(true); break;
case DisplayCredential.USERNAME: username_entry.set_visible(true); username_label.set_visible(true); break;
case DisplayCredential.CLIENTNAME: clientname_entry.set_visible(true); clientname_label.set_visible(true); break;
}
}
}
[GtkCallback]
private void reconnect_button_clicked(){
connect();
connect_to_client();
}
[GtkCallback]
......@@ -197,5 +199,4 @@ public class Remotely.VncBox : Box {
private void optiscale(int box_width, int box_heigth, int image_width, int image_heigth, out int newwidth, out int newheigth){
}
}
......@@ -34,9 +34,6 @@ public class Remotely.Window : Gtk.ApplicationWindow {
public Window (Gtk.Application app) {
Object (application: app);
var gtk_settings = Gtk.Settings.get_default ();
gtk_settings.gtk_application_prefer_dark_theme = true;
vnc_notebook.page_added.connect(update_view);
vnc_notebook.page_removed.connect(update_view);
vnc_notebook.switch_page.connect((page, num) => {
......@@ -58,7 +55,7 @@ public class Remotely.Window : Gtk.ApplicationWindow {
title.expand = true;
Gtk.Button close_button = new Gtk.Button.from_icon_name("window-close-symbolic", IconSize.MENU);
close_button.clicked.connect(() => {cbox.disconnect();});
close_button.clicked.connect(() => {cbox.disconnect_from_client();});
close_button.relief = ReliefStyle.NONE;
titlebox.add(title);
......@@ -76,51 +73,49 @@ public class Remotely.Window : Gtk.ApplicationWindow {
[GtkCallback]
private void disconnect_button_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
cbox.disconnect();
get_current_vnc_box().disconnect_from_client();
}
[GtkCallback]
private void zoom_fit_window_button_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
cbox.set_zoom_mode(ZoomMode.FIT_WINDOW);
get_current_vnc_box().set_zoom_mode(ZoomMode.FIT_WINDOW);
}
[GtkCallback]
private void zoom_best_fit_button_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
cbox.set_zoom_mode(ZoomMode.BEST_FIT);
get_current_vnc_box().set_zoom_mode(ZoomMode.BEST_FIT);
}
[GtkCallback]
private void zoom_original_button_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
cbox.set_zoom_mode(ZoomMode.ORIGINAL_SIZE);
get_current_vnc_box().set_zoom_mode(ZoomMode.ORIGINAL_SIZE);
}
[GtkCallback]
private void view_only_checkbutton_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
cbox.set_view_only(view_only_checkbutton.active);
get_current_vnc_box().set_view_only(view_only_checkbutton.active);
}
[GtkCallback]
private void ctrlaltdel_clicked(){
VncBox cbox = (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
uint[] keys = {0xFFE3, 0xFFE9, 0xFFFF};
get_current_vnc_box().send_keys(keys);
}
cbox.send_keys(keys);
private VncBox get_current_vnc_box() {
return (VncBox)vnc_notebook.get_nth_page(vnc_notebook.get_current_page());
}
private void update_view(){
if(vnc_notebook.get_n_pages() > 1) vnc_notebook.show_tabs = true;
else vnc_notebook.show_tabs = false;
// Hide notebook bar if there is only one connection
if(vnc_notebook.get_n_pages() == 0){
vnc_stack.set_visible_child_name("no-connection");
header_bar.set_subtitle("");
connection_revealer.set_reveal_child(false);
// Show notebook bar to switch between connections
}else{
vnc_stack.set_visible_child_name("notebook");
connection_revealer.set_reveal_child(true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment