Closed yursan9 closed 7 years ago
Hi - you should never create a new Budgie.PopoverManager. You override the register_popovers
virtual method to register with the existing PopoverManager. In fact I'll see if I can hide the constructor for BudgiePopoverManager because this possibility frightens me.
Okay, sorry I put wrong example too.
So I redo the code for a little bit, and It's getting somewhere.
import gi.repository
gi.require_version('Budgie', '1.0')
from gi.repository import Budgie, GObject, Gtk, Gdk
class PyShowDesktop(GObject.GObject, Budgie.Plugin):
""" This is simply an entry point into your Budgie Applet implementation.
Note you must always override Object, and implement Plugin.
"""
# Good manners, make sure we have unique name in GObject type system
__gtype_name__ = "PyShowDesktop"
def __init__(self):
""" Initialisation is important.
"""
GObject.Object.__init__(self)
def do_get_panel_widget(self, uuid):
""" This is where the real fun happens. Return a new Budgie.Applet
instance with the given UUID. The UUID is determined by the
BudgiePanelManager, and is used for lifetime tracking.
"""
return PyShowDesktopApplet(uuid)
class PyShowDesktopApplet(Budgie.Applet):
""" Budgie.Applet is in fact a Gtk.Bin """
manager = None
def __init__(self, uuid):
Budgie.Applet.__init__(self)
self.box = Gtk.EventBox()
self.label = Gtk.Label("Hello")
self.box.add(self.label)
self.add(self.box)
self.popover = Budgie.Popover(self.box)
self.hello = Gtk.Label("World!")
self.popover.add(self.hello)
self.popover.get_child().show_all()
self.box.show_all()
self.show_all()
self.box.connect("button-press-event", self.on_press)
def on_press(self, box, e):
if e.button != 1:
return Gdk.EVENT_PROPAGATE
if self.popover.get_visible():
self.popover.hide()
else:
self.manager.show_popover(self.box)
return Gdk.EVENT_STOP
def do_update_popovers(self, manager):
self.manager = manager
self.manager.register_popover(self.box, self.popover)
But I got error when creating new Budgie.Popover`.
Traceback (most recent call last):
File "/home/yurizal/.local/share/budgie-desktop/plugins/pydesktop/pyshowdesktop.py", line 45, in do_get_panel_widget
return PyShowDesktopApplet(uuid)
File "/home/yurizal/.local/share/budgie-desktop/plugins/pydesktop/pyshowdesktop.py", line 59, in __init__
self.popover = Budgie.Popover(self.box)
File "/usr/lib/python3.5/site-packages/gi/overrides/__init__.py", line 326, in new_init
return super_init_func(self, **new_kwargs)
TypeError: could not convert value for property `type' from EventBox to GtkWindowType
sys:1: Warning: invalid (NULL) pointer instance
sys:1: Warning: g_signal_emit_by_name: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
I imagine you need to use the explicit constructor Budgie.Popover.new
Yep. That's fixed it. Thank you Ikey. I'll close this.
Thanks bud, I'll get the docs updated before we finalise the release. BTW can you link me to any of your applets? We need to do some migration code in Budgie to handle name -> description fixes..
This is my first time messing around trying to make Budgie Applet. I'll wait for the documentation to be up to date to try making more complete one.
p.s: Why don't you put a developer section in Budgie website later?
Yeah we're planning on centralizing the documentation to make it easier, much nicer than random assorted bits of info across GitHub :)
Great. I'll wait first, in the meantime I'll go to eat dinner. Thanks for your excellent work!
@ikeydoherty It keeps telling me AttributeError: 'gi.repository.Budgie' object has no attribute 'Popover'
. What am I doing wrong? First time playin with Gtk; so bear with me ;P. It's strange since Budgie.Applet.__init__(self)
is at the same level and works without any problems.
PS:
Budgie 17.04 isn't a thing. Budgie 10.3.1 is a thing. If you're not using Budgie git then BudgiePopover doesn't exist, its what will exist in Budgie 10.4
@ikeydoherty ooppsy doopsy thanks for that quick response. Yeah,I confused Ubuntu Budgie versioning with Budgie :( lol. I'm trying to code a dilbert applet in Ubuntu budgie and having some difficulty creating that popover effect. I'll stick to creating a separate window maybe.
Yeah,I confused Ubuntu Budgie versioning with Budgie
Yer I'm well used to that by now.
Honestly I'd recommend holding off until 10.4 which is really REALLY close - the API is way more sane, and you'll have no bugs from Budgie affecting your popover usage :]
@ikeydoherty lol. Great,I'll wait for that. Keep up the good work brother. Have a wonderful day/Night.
@ikeydoherty, @yursan9, @Majed6 thanks for your comments. This is my first applet for brightness (working with xrandr) https://github.com/serdarsen/UBrightnessController
Hello, I'm kinda confused how to use the new Budgie Popover. I tried to modify the python example, and looking at the source code for clock applet. This is what I got so far...