Verified Commit 051160d9 authored by tallero's avatar tallero

css:(almost) theme independent colors

parent 9c801852
......@@ -26,6 +26,7 @@ from gi import require_version
require_version('Gtk', '3.0')
from gi.repository.Gtk import CssProvider, StyleContext, STYLE_PROVIDER_PRIORITY_APPLICATION, Button, IconTheme, Template
from .util import set_style
#from .wikidata import Wikidata
@Template.from_resource("/ml/prevete/Daty/gtk/property.ui")
......@@ -33,6 +34,8 @@ class Property(Button):
__gtype_name__ = "Property"
property_label = Template.Child("property_label")
popover = Template.Child("popover")
description = Template.Child("description")
#values = Template.Child("values")
def __init__(self, prop, *args, **kwargs):
......@@ -41,14 +44,25 @@ class Property(Button):
# Styling
context = self.get_style_context()
provider = CssProvider()
provider.load_from_resource('/ml/prevete/Daty/gtk/property.css')
resource = 'ml/prevete/Daty/gtk/property.css'
provider.load_from_resource(resource)
context.add_provider(provider, STYLE_PROVIDER_PRIORITY_APPLICATION)
context = self.description.get_style_context()
set_style(context, resource, 'popover_description', True)
#wikidata = Wikidata()
#label, tooltip = wikidata.get_label(prop), wikidata.get_description(prop)
self.set_label(prop["Label"], prop["Description"])
self.description.set_text(prop['Description'])
self.description.set_line_wrap(True)
#del prop
def set_label(self, label, tooltip):
self.property_label.set_text(label)
self.property_label.set_tooltip_text(tooltip)
@Template.Callback()
def clicked_cb(self, widget):
print("hi")
self.popover.popup()
......@@ -23,7 +23,7 @@
.search_entry {
/* background-color:#fdefee */
background:#f6f6f6;
/*background:#f6f6f6;*/
padding-left:8px;
padding-right:8px;
......
......@@ -26,3 +26,15 @@
border-bottom-right-radius: 0px;
border-right-width:0px;
}
@define-color bg_color alpha(currentColor, 0.05);
@define-color bd_color alpha(currentColor, 0.10);
.popover_description {
background:@bg_color;
padding:5px;
border-radius:5px;
border-style:solid;
border-color:@bd_color;
border-width:1px;
}
......@@ -11,6 +11,7 @@
<property name="halign">end</property>
<property name="valign">start</property>
<property name="relief">none</property>
<signal name="clicked" handler="clicked_cb" swapped="no"/>
<child>
<object class="GtkLabel" id="property_label">
<property name="visible">True</property>
......@@ -31,4 +32,60 @@
<class name="property_button"/>
</style>
</template>
<object class="GtkPopover" id="popover">
<property name="width_request">250</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="relative_to">Property</property>
<property name="position">bottom</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_start">8</property>
<property name="margin_end">8</property>
<property name="margin_top">8</property>
<property name="margin_bottom">8</property>
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
<object class="GtkLabel" id="description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Description</property>
<property name="wrap">True</property>
<property name="selectable">True</property>
<property name="max_width_chars">30</property>
<attributes>
<attribute name="font-desc" value="Cantarell 8"/>
</attributes>
<style>
<class name="popover_description"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkModelButton" id="value_new">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="text" translatable="yes">Add value</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
</interface>
......@@ -17,6 +17,7 @@
<property name="valign">start</property>
<property name="hexpand">True</property>
<property name="row_spacing">3</property>
<property name="column_spacing">8</property>
<property name="column_homogeneous">True</property>
<child>
<placeholder/>
......
......@@ -22,18 +22,17 @@
*/
.unreferenced {
background-color:#ffe0e0; /*#fff0f0;*/
background:alpha(red, 0.11);
}
.loading {
background-color:#fffae2;
background-color:alpha(yellow, 0.08); /*#fffae2;*/
}
.expanded {
/* background-color:#fdefee */
background-color:#e0e0e0;
background-color:alpha(black, 0.08);
}
.separator {
background-color:#cfc8c3;
background-color:alpha(black, 0.15);
}
......@@ -224,11 +224,12 @@ class Value(Grid):
self.emit("new-window-clicked", payload)
def clicked_cb(self, widget, event):
print(event.button)
if hasattr(self, 'references'):
if event.type == EventType(5): #double click
if event.type == EventType(4) and event.button == 1: #double click
self.references_expand_clicked_cb(widget, event)
if event.type == EventType(4): #single click
if event.type == EventType(4) and event.button == 3: #single right click
self.reference_new_clicked_cb(widget, event)
def reference_new_clicked_cb(self, widget, event):
......
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