so, Now time have come around to give you basic idea or overview about xfce-panel-plugin development in programming language other than C.
With the release of Xfce-panel 4.4, support have been added to create plugin in two ways: Internal and External Plugin.
Internal Plugins are loadable plugins that are developed using GModule Interface.
External Plugins are individuals program which are embedded into Xfce-Panel through GtkSocket and GtkPlug concept.
Here is list of Internal and External plugins.
Xfce4-Panel Internal Plugin
- Workspace Switcher – Switch between virtual desktops
- Launcher – Program launcher with optional menu
- Notification Area – Area where notification icons appear.
- Clock – a clock for the panel.
- Application Menu – Adds a menu containing categories of installed applications
Xfce4-Panel External Plugin
- Calculator – a calculator plugin for the Xfce4 panel.
- Clipman – A clipboard manager for Xfce
- Eyes – Eyes that spy on you.
- Notes – provides sticky notes for your desktop.
- Weather – Shows the current temperature and weather condition, using weather data provided by xoap.weather.com
If you are working with C or Vala programming language, You can go out for plugin development using both of methods, it just a matter of your choice.
Example for Gtk Socket and Gtk Plug using python
#!/usr/bin/python """ General flow of program Entry widget -> GtkPlug -> GtkSocket -> Window """ import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk import sys def perform_embed_event(widget): print("This will get called when plug will emit embedded signal") # initialize GtkSocket window = Gtk.Window() window.show() # initialize GtkSocket socket = Gtk.Socket() socket.show() window.add(socket) # store socket id in socket_id variable socket_id = socket.get_id() print("socket", socket_id) # initialize GtkPlug plug = Gtk.Plug.new(socket_id) # Different Plug signals plug.connect("embedded", perform_embed_event) plug.connect("destroy", Gtk.main_quit) print("Plug ID:", plug.get_id()) # Entry Widget entry = Gtk.Entry() entry.set_text("Xfce GSoC 2021") # Add entry widget into plug plug.add(entry) plug.show_all() Gtk.main()
Above mentioned example contain four different things i.e GtkPlug, GtkSocket, Entry Widget and window.
In general term, Entry widget is added to GtkPlug. Through GtkSocket ID, GtkPlug have been added to it. And GtkSocket have been added to the window.
One tryout If you want to.
GtkSocket is dependent on window, If you don’t add socket to window, you would not be able to generate socket id through ‘get_id’, logic is very simple behind this thing, I want to you think about the logic behind it :).
Through this program, I have tried to give you an idea how does GtkPlug and GtkSocket works inside a single window. This program is totally based on single programming language that is python, In the next blog post we will try out GtkSocket in one programming language and GtkPlug in other programming. It will be a combination of GtkSocket in C and GtkPlug in Python and After That, Dbus concept is coming up next.
Update: Special Thanks to @dmytrokyrychuk for making me notice some bug inside a attached code snippet.