Skip to content

Commit

Permalink
Merge pull request #3090 from Sigma1912/2.9-fix-configs-apps-gladevcp
Browse files Browse the repository at this point in the history
2.9 fix configs apps gladevcp
  • Loading branch information
hansu authored Sep 1, 2024
2 parents 317595e + 28dfeff commit 655c4eb
Show file tree
Hide file tree
Showing 8 changed files with 334 additions and 258 deletions.
18 changes: 9 additions & 9 deletions configs/apps/gladevcp/animated-backdrop/cairodraw.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@

import gtk, sys, cairo
import cairo
from math import pi


pngfile = 'vortex.me.png'

class HandlerClass:

def on_expose(self,widget,data=None):
print("on_expose")
cr = widget.window.cairo_create()
def on_draw(self, widget, cr):
print("on_draw")

# Sets the operator to clear which deletes everything below
# where an object is drawn
cr.set_operator(cairo.OPERATOR_CLEAR)
width = widget.get_allocated_width()
height = widget.get_allocated_height()
# Makes the mask fill the entire window
cr.rectangle(0.0, 0.0, *widget.get_size())
cr.rectangle(0.0, 0.0, width, height)
# Deletes everything in the window (since the compositing
# operator is clear and mask fills the entire window
cr.fill()
# Set the compositing operator back to the default
cr.set_operator(cairo.OPERATOR_OVER)

if self.scale:
x, y, w, h = widget.allocation
w, h = widget.get_allocated_width(), widget.get_allocated_height()
cr.scale(1.0 *w / self.width, 1.0*h/self.height)

cr.set_source_surface(self.img, 0, 0)
Expand All @@ -49,8 +49,8 @@ def __init__(self, halcomp,builder,useropts):
# This sets the windows colormap, so it supports transparency.
# This will only work if the wm support alpha channel
screen = win.get_screen()
rgba = screen.get_rgba_colormap()
win.set_colormap(rgba)
rgba = screen.get_rgba_visual()
win.set_visual(rgba)

# scaling the bitmap is possible by turning this on
# however the fixed widget does NOT do proportional scaling
Expand Down
38 changes: 21 additions & 17 deletions configs/apps/gladevcp/animated-backdrop/cairodraw.ui
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<!-- interface-requires gladevcp 0.0 -->
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
<requires lib="gtk+" version="3.0"/>
<requires lib="gladevcp" version="0.0"/>
<object class="GtkWindow" id="window1">
<signal name="expose_event" handler="on_expose"/>
<property name="can-focus">False</property>
<signal name="draw" handler="on_draw" swapped="no"/>
<child>
<object class="GtkFixed" id="fixed1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="HAL_LED" id="hal_led1">
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="led-blink-rate">0</property>
</object>
<packing>
<property name="x">57</property>
Expand All @@ -22,13 +26,13 @@
<child>
<object class="HAL_Button" id="hal_button1">
<property name="label" translatable="yes">button</property>
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="has_tooltip">True</property>
<property name="tooltip_text" translatable="yes">a tooltip</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="has-tooltip">True</property>
<property name="tooltip-text" translatable="yes">a tooltip</property>
</object>
<packing>
<property name="x">250</property>
Expand All @@ -38,11 +42,11 @@
<child>
<object class="HAL_ToggleButton" id="hal_togglebutton1">
<property name="label" translatable="yes">togglebutton</property>
<property name="width_request">100</property>
<property name="height_request">80</property>
<property name="width-request">100</property>
<property name="height-request">80</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="x">29</property>
Expand Down
2 changes: 1 addition & 1 deletion configs/apps/gladevcp/by-widget/combobox.demo
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ thisfile=$(readlink -f "$0")
thisdir=$(dirname "$thisfile")
cd "$thisdir"

gladevcp_demo -u ./combobox ./combobox.ui
gladevcp_demo -u combobox.py combobox.ui
20 changes: 13 additions & 7 deletions configs/apps/gladevcp/by-widget/sourceview.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

import gtk
import gtksourceview2 as gtksourceview
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GtkSource

class HandlerClass:

Expand All @@ -17,7 +19,7 @@ def _set_line(self,l):
else:
self.textbuffer.move_mark(self.mark, line)
self.sourceview.scroll_to_mark(self.mark, 0, True, 0, 0.5)

def file_set(self,widget,data=None):
filename = widget.get_filename()
print("file_set",filename)
Expand All @@ -39,14 +41,18 @@ def __init__(self, halcomp,builder,useropts):

self.line = 1
self.sourceview = builder.get_object('gtksourceview1')
self.textbuffer = gtksourceview.Buffer()
self.textbuffer = GtkSource.Buffer()
self.sourceview.set_buffer(self.textbuffer)

self.sourceview.set_show_line_numbers(True)
self.sourceview.set_show_line_marks(True)
self.sourceview.set_highlight_current_line(True)
self.sourceview.set_mark_category_icon_from_icon_name('highlight', 'gtk-forward')
self.sourceview.set_mark_category_background('highlight', gtk.gdk.Color('yellow'))

att = GtkSource.MarkAttributes()
color = Gdk.RGBA()
color.parse('yellow')
att.set_background(color)
self.sourceview.set_mark_attributes('highlight', att, 1)
self.mark = None

def get_handlers(halcomp,builder,useropts):
Expand Down
72 changes: 43 additions & 29 deletions configs/apps/gladevcp/by-widget/sourceview.ui
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<?xml version="1.0"?>
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.38.2 -->
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-requires gtksourceview 0.0 -->
<!-- interface-naming-policy project-wide -->
<requires lib="gtk+" version="3.0"/>
<requires lib="gtksourceview" version="0.0"/>
<object class="GtkWindow" id="window1">
<property name="can-focus">False</property>
<child>
<object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkFrame" id="frame1">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkAlignment" id="alignment1">
<property name="visible">True</property>
<property name="left_padding">12</property>
<property name="can-focus">False</property>
<property name="left-padding">12</property>
<child>
<object class="GtkHButtonBox" id="hbuttonbox1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkFileChooserButton" id="filechooserbutton1">
<property name="visible">True</property>
<signal name="file_set" handler="file_set"/>
<property name="can-focus">False</property>
<signal name="file-set" handler="file_set" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -34,9 +40,9 @@
<object class="GtkButton" id="down">
<property name="label" translatable="yes">Down</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="receives_default">False</property>
<signal name="pressed" handler="on_down"/>
<property name="can-focus">False</property>
<property name="receives-default">False</property>
<signal name="pressed" handler="on_down" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -48,9 +54,9 @@
<object class="GtkButton" id="up">
<property name="label" translatable="yes">Up</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<signal name="pressed" handler="on_up"/>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="pressed" handler="on_up" swapped="no"/>
</object>
<packing>
<property name="expand">False</property>
Expand All @@ -65,41 +71,46 @@
<child type="label">
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">&lt;b&gt;File&lt;/b&gt;</property>
<property name="use_markup">True</property>
<property name="use-markup">True</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="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<property name="can-focus">False</property>
<property name="label-xalign">0</property>
<property name="shadow-type">none</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="width_request">300</property>
<property name="height_request">400</property>
<property name="width-request">300</property>
<property name="height-request">400</property>
<property name="visible">True</property>
<property name="left_padding">12</property>
<property name="can-focus">False</property>
<property name="left-padding">12</property>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">automatic</property>
<property name="vscrollbar_policy">automatic</property>
<property name="can-focus">True</property>
<child>
<object class="GtkSourceView" id="gtksourceview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="tab_width">4</property>
<property name="auto_indent">True</property>
<property name="indent_on_tab">False</property>
<property name="can-focus">True</property>
<property name="left-margin">2</property>
<property name="right-margin">2</property>
<property name="show-line-numbers">True</property>
<property name="show-line-marks">True</property>
<property name="tab-width">4</property>
<property name="auto-indent">True</property>
<property name="indent-on-tab">False</property>
</object>
</child>
</object>
Expand All @@ -109,11 +120,14 @@
<child type="label">
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Sourceview Widget</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
Expand Down
Loading

0 comments on commit 655c4eb

Please sign in to comment.