Commit 0ab641a9 authored by Danial Behzadi's avatar Danial Behzadi
Browse files

update ui based on libhandy

parent aabf905b
......@@ -3,35 +3,12 @@
# Danial Behzadi<dani.behzi@ubuntu.com>, 2019-2020
import gi
gi.require_versions({'Gdk': '3.0', 'Gtk': '3.0'})
from gi.repository import Gdk, Gtk
gi.require_versions({'Gtk': '3.0'})
from gi.repository import Gtk
from sys import argv
from . import ui
from . import actions
class AppWindow(Gtk.ApplicationWindow):#TODO: Use Handy.ApplicationWindow
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.set_icon_name("carburetor")
self.load_css()
self.connect("key-press-event", self.on_key_press)
header_bar = ui.get('HeaderBar')
self.set_titlebar(header_bar)
main_container = ui.get('MainContainer')
self.add(main_container)
def load_css(self):
ui.css()
def on_key_press(self, widget, event):
if event.keyval == Gdk.KEY_F10:
menu_button = ui.get('MenuButton')
if not menu_button.get_active():
menu_button.activate()
return False
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
......@@ -46,10 +23,16 @@ class Application(Gtk.Application):
def do_activate(self):
if not self.window:
window = AppWindow(application=self)
window = self.get_window('MainWindow')
self.add_window(window)
self.window = window
self.window.present()
def get_window(self, element):
ui.css()
window = ui.get(element)
return window
def main():
ui.initialize_builder()
......
......@@ -58,6 +58,9 @@ def set_to_stopped(app):
button = ui.get('ConnectButton')
text_start = _("_Connect")
button.set_label(text_start)
style = button.get_style_context()
style.remove_class('red')
style.add_class('green')
button = ui.get('ActionMenuButton')
button.set_sensitive(False)
if app:
......@@ -71,6 +74,9 @@ def set_to_running(app):
label.set_label(_("Running"))
button = ui.get('ConnectButton')
text_stop = _("_Disconnect")
style = button.get_style_context()
style.remove_class('green')
style.add_class('red')
button.set_label(text_stop)
button = ui.get('ActionMenuButton')
button.set_sensitive(True)
......
......@@ -24,6 +24,7 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
<interface domain="messages">
<requires lib="gtk+" version="3.24"/>
<requires lib="libhandy" version="1.0"/>
<!-- interface-css-provider-path style.css -->
<!-- interface-license-type gplv3 -->
<!-- interface-name Carburetor -->
<!-- interface-description Settings for Tractor -->
......@@ -59,185 +60,202 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
</object>
</child>
</object>
<object class="GtkScrolledWindow" id="MainContainer">
<object class="GtkImage" id="MenuIcon">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<property name="can-focus">False</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
<object class="HdyApplicationWindow" id="MainWindow">
<property name="can-focus">False</property>
<property name="default-width">425</property>
<property name="icon-name">carburetor</property>
<child>
<object class="GtkViewport" id="MainViewport">
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid" id="MainGrid">
<object class="GtkScrolledWindow" id="MainContainer">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-homogeneous">True</property>
<property name="column-homogeneous">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkBox" id="MainBox">
<object class="GtkViewport" id="MainViewport">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<signal name="realize" handler="on_MainBox_realize" swapped="no"/>
<child>
<object class="GtkBox">
<!-- n-columns=3 n-rows=3 -->
<object class="GtkGrid" id="MainGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-homogeneous">True</property>
<property name="column-homogeneous">True</property>
<child>
<object class="GtkImage" id="MainImage">
<object class="GtkBox" id="MainBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">process-stop</property>
<property name="icon_size">6</property>
<property name="orientation">vertical</property>
<signal name="realize" handler="on_MainBox_realize" swapped="no"/>
<child>
<object class="GtkOverlay">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage" id="MainImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">process-stop</property>
<property name="icon_size">6</property>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="GtkSpinner" id="Spinner">
<property name="can-focus">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MainLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stopped</property>
<property name="wrap">True</property>
<property name="ellipsize">middle</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkSpinner" id="Spinner">
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="maincontainer"/>
</style>
</object>
<packing>
<property name="index">-1</property>
</packing>
</child>
<child type="overlay">
<object class="HdyHeaderBar" id="HeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="valign">start</property>
<property name="title" translatable="yes">Carburetor</property>
<property name="subtitle" translatable="yes">Settings for Tractor</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkButtonBox" id="ActionButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">expand</property>
<child>
<object class="GtkButton" id="ConnectButton">
<property name="label" translatable="yes">_Connect</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">app.connect</property>
<property name="use-underline">True</property>
<style>
<class name="connectbutton"/>
<class name="green"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="MainLabel">
<object class="GtkMenuButton" id="ActionMenuButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Stopped</property>
<property name="wrap">True</property>
<property name="ellipsize">middle</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="popup">ActionMenu</property>
<property name="use-popover">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">pan-down-symbolic</property>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</child>
<style>
<class name="maincontainer"/>
</style>
</object>
<object class="GtkImage" id="MenuIcon">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">open-menu-symbolic</property>
</object>
<object class="HdyHeaderBar" id="HeaderBar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="title" translatable="yes">Carburetor</property>
<property name="subtitle" translatable="yes">Settings for Tractor</property>
<property name="show-close-button">True</property>
<child>
<object class="GtkButtonBox" id="ActionButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="layout-style">expand</property>
<child>
<object class="GtkButton" id="ConnectButton">
<property name="label" translatable="yes">_Connect</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="action-name">app.connect</property>
<property name="use-underline">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="ActionMenuButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="halign">start</property>
<property name="popup">ActionMenu</property>
<property name="use-popover">False</property>
<child>
<object class="GtkImage">
<object class="GtkMenuButton" id="MenuButton">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">pan-down-symbolic</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">MenuIcon</property>
<property name="popover">MenuPopover</property>
<accelerator key="F10" signal="activate"/>
</object>
<packing>
<property name="pack-type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="non-homogeneous">True</property>
</packing>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkMenuButton" id="MenuButton">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">MenuIcon</property>
<property name="popover">MenuPopover</property>
</object>
<packing>
<property name="pack-type">end</property>
<property name="position">3</property>
</packing>
</child>
</object>
<object class="GtkPopover" id="MenuPopover">
......@@ -251,7 +269,7 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
<child>
<object class="GtkModelButton" id="MenuPreferences">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="action-name">app.preferences</property>
<property name="text" translatable="yes">Preferences</property>
......@@ -266,7 +284,7 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
<child>
<object class="GtkModelButton" id="MenuAbout">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="action-name">app.about</property>
<property name="text" translatable="yes">About Carburetor</property>
......@@ -281,7 +299,7 @@ Author: Danial Behzadi <dani.behzi@ubuntu.com>
<child>
<object class="GtkModelButton" id="MenuQuit">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="action-name">app.quit</property>
<property name="text" translatable="yes">Quit</property>
......
stack box {
margin: 0.2em;
.maincontainer {
min-height: 25em;
}
.listboxrow {
padding: 0.7em;
min-width: 10em;
.connectbutton {
min-width: 5em;
}
.maincontainer {
min-height : 25em;
.green {
background: darkgreen;
}
popover {
padding: 0.6em;
.red {
background: darkred;
}
progressbar {
min-width: 20em;
popover {
padding: 0.6em;
}
.circularbutton {
border-radius: 10em;
}
.bridgeslist {
min-height: 15em;
}
Supports Markdown
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