SlideShare a Scribd company logo
手把手教你寫
Pre GNOME shell
   view
        擴充套件
                  tools, hollyladd, by-nc-nd
即時討論
https://convore.com/gnome-taiwan/gnome-shell/


or 短網址
http://j.mp/gs-ext
簡報作者
●   Yuren Ju <yurenju@gmail.com>
●   Blog: Yuren's Info Area
●   社群: Hacking Thursday
step by step to write a gnome-shell extension
gnome-shell include...
●   GNOME3 user experience desktop
●   Shell Tookit (similar GTK+)
●   More...
Web Browser extension
Important!
You can write gnome-shell extension with

                       Javascript!
How


 Gnome-shell core       C Launguage


GObject Introspection   <interface>


Gnome-shell widgets      Javascript
How?

 Gobject-based library           Gnome-shell core

               Gobject Introspection (GI)

overview      workspace    calendar    ...   extension

gnome-shell widgets
GObject Introspection



 JS     Java     Python      Perl     Ruby   PHP?

                        GI
 GTK   Clutter    VTE        notify    GStreamer

                 Native C API
Getting started!

                                            LiveUSB
                           http://gnome3.org/tryit.html




$ gnome-shell-extension-tool --create-extension
Create extension
Restart gnome-shell




    alt+F2 and press "r"
Default extension
     Click panel




  Show Hello world, and destroy after 5sec
Default extension code
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;

const Main = imports.ui.main;

function _showHello() {
    let text = new St.Label({ style_class: 'helloworld-label',
                              text: "Hello, world!" });
    let monitor = global.get_primary_monitor();
    global.stage.add_actor(text);
    text.set_position(Math.floor (monitor.width / 2 - text.width / 2),
                      Math.floor(monitor.height / 2 - text.height / 2));
    Mainloop.timeout_add(3000, function () { text.destroy(); });
}

// Put your extension initialization code here
function main() {
    Main.panel.actor.reactive = true;
    Main.panel.actor.connect('button-release-event', _showHello);
}
Global (1/2)
●   Monitor                     ●   Pointer:
    ●   get_monitors()              ●   get_pointer()
    ●   get_primary_monito      ●   Window/Screen:
        r()                         ●   get_gdk_screen()
    ●   get_primary_monito
        r_index()
                                    ●   get_screen()
    ●   get_focus_monitor()
                                    ●   get_window_actors()


         return MetaRectangle
Global (2/2)
●   Properties
    ●   stage
    ●   screen-width/screen-height
    ●   window-group
    ●   settings
    ●   datadir
    ●   userdatadir
Looking glass




 alt+F2 and press "lg"
Default extension code
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;

const Main = imports.ui.main;

function _showHello() {
    let text = new St.Label({ style_class: 'helloworld-label',
                              text: "Hello, world!" });
    let monitor = global.get_primary_monitor();
    global.stage.add_actor(text);
    text.set_position(Math.floor (monitor.width / 2 - text.width / 2),
                      Math.floor(monitor.height / 2 - text.height / 2));
    Mainloop.timeout_add(3000, function () { text.destroy(); });
}

// Put your extension initialization code here
function main() {
    Main.panel.actor.reactive = true;
    Main.panel.actor.connect('button-release-event', _showHello);
}

   http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html
Main
Main
●   Main.panel
    ●     button
    ●     _leftBox, _centerBox, _rightBox
    ●     _dateMenu
    ●     ...
●   Main.overview
●   Main.runDialog
●   Main.uiGroup
●   ...
Default extension code
// Sample extension code, makes clicking on the panel show a message
const St = imports.gi.St;
const Mainloop = imports.mainloop;

const Main = imports.ui.main;

function _showHello() {
    let text = new St.Label({ style_class: 'helloworld-label',
                              text: "Hello, world!" });
    let monitor = global.get_primary_monitor();
    global.stage.add_actor(text);
    text.set_position(Math.floor (monitor.width / 2 - text.width / 2),
                      Math.floor(monitor.height / 2 - text.height / 2));
    Mainloop.timeout_add(3000, function () { text.destroy(); });
}

// Put your extension initialization code here
function main() {
    Main.panel.actor.reactive = true;
    Main.panel.actor.connect('button-release-event', _showHello);
}
Try it
●   Main.panel._dateMenu.menu.actor.set_opacity(100)
●   Main.panel._dateMenu.actor.set_scale(1.5, 1.5)
●   Main.panel._dateMenu.menu.actor.set_z_rotation_from_
    gravity(45.0, Clutter.Gravity.CENTER)
●   Don's you like status-menu?
    ●   Main.panel._statusmenu.actor.hide()
Example extension –
fancy screenshot tool




    http://www.youtube.com/watch?v=epKssSQpfLQ


$ sudo zypper refresh && sudo zypper install ImageMagick
(Because GdkPixbuf.savev function is broken)
Step 1: PanelButton
_leftBox   _centerBox   _rightBox
Step 2: PopupMenu
Step 3: Handle Click
Tweener
●   transition
    ●   linear, easeInQuad, … (reference python-
        clutter)
●   onComplete/onCompleteScope
●   scale_x, scale_y, opacity
Animation

Counting down


  Shotting


    Zoom
Step 4: Animation (1/3)
Step 4: Animation (2/3)
Step 4: Animation (3/3)
Step 5: Save screenshot
Source Code
https://gist.github.com/9c29efaa9b00a75db81f
Big issue!
No document
    sad...
              Sad Zeb, by-nc,sa
Reference
●   gnome-shell source code
●   mutter source code
●   http://git.gnome.org/browse/
●   ZZzzzz
We need you!
Q&A
    Slides Download
http://j.mp/gs-ext-slides

More Related Content

PDF
LCU14 500 ARM Trusted Firmware
PDF
Board Bringup
PPTX
How to do Cryptography right in Android Part Two
PPTX
Presentation on iOS
PDF
XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
PDF
Python GTK (Hacking Camp)
PDF
Python-GTK
LCU14 500 ARM Trusted Firmware
Board Bringup
How to do Cryptography right in Android Part Two
Presentation on iOS
XPDDS17: Reworking the ARM GIC Emulation & Xen Challenges in the ARM ITS Emu...
Python GTK (Hacking Camp)
Python-GTK

Similar to step by step to write a gnome-shell extension (11)

ODP
Javascript in Linux Desktop
PDF
Javascript in linux desktop (ICOS ver.)
PDF
Making the GNOME 3.0 desktop accessible: building accessibility into GNOME Sh...
PDF
Basics of gtk_ilugc
PDF
An introduction to Gnome An introdu.pptx
PPTX
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
PDF
Javascript, the GNOME way (JSConf EU 2011)
PPT
Sense and sense ability - TU100 13J
PDF
Inside Android's UI
PDF
제 2회 한국 EFL 세미나 - 5. Elm Theme Viewer (서주영)
PDF
Gtk development-using-glade-3
Javascript in Linux Desktop
Javascript in linux desktop (ICOS ver.)
Making the GNOME 3.0 desktop accessible: building accessibility into GNOME Sh...
Basics of gtk_ilugc
An introduction to Gnome An introdu.pptx
East Coast DevCon 2014: The Slate UI Framework - Architecture & Tools
Javascript, the GNOME way (JSConf EU 2011)
Sense and sense ability - TU100 13J
Inside Android's UI
제 2회 한국 EFL 세미나 - 5. Elm Theme Viewer (서주영)
Gtk development-using-glade-3
Ad

More from Yuren Ju (6)

PDF
捷克之旅
PDF
Ksdg customize-your-firefoxos
PDF
Python and GObject Introspection
PDF
GNOME3 延伸套件教學
ODP
Ibus pinyin
ODP
Ibus pinyin
捷克之旅
Ksdg customize-your-firefoxos
Python and GObject Introspection
GNOME3 延伸套件教學
Ibus pinyin
Ibus pinyin
Ad

Recently uploaded (20)

PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
KodekX | Application Modernization Development
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
Encapsulation_ Review paper, used for researhc scholars
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Cloud computing and distributed systems.
PDF
cuic standard and advanced reporting.pdf
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
NewMind AI Weekly Chronicles - August'25 Week I
20250228 LYD VKU AI Blended-Learning.pptx
KodekX | Application Modernization Development
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Understanding_Digital_Forensics_Presentation.pptx
MYSQL Presentation for SQL database connectivity
Unlocking AI with Model Context Protocol (MCP)
Encapsulation_ Review paper, used for researhc scholars
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
Reach Out and Touch Someone: Haptics and Empathic Computing
Cloud computing and distributed systems.
cuic standard and advanced reporting.pdf
Review of recent advances in non-invasive hemoglobin estimation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
How UI/UX Design Impacts User Retention in Mobile Apps.pdf

step by step to write a gnome-shell extension

  • 1. 手把手教你寫 Pre GNOME shell view 擴充套件 tools, hollyladd, by-nc-nd
  • 3. 簡報作者 ● Yuren Ju <yurenju@gmail.com> ● Blog: Yuren's Info Area ● 社群: Hacking Thursday
  • 5. gnome-shell include... ● GNOME3 user experience desktop ● Shell Tookit (similar GTK+) ● More...
  • 7. Important! You can write gnome-shell extension with Javascript!
  • 8. How Gnome-shell core C Launguage GObject Introspection <interface> Gnome-shell widgets Javascript
  • 9. How? Gobject-based library Gnome-shell core Gobject Introspection (GI) overview workspace calendar ... extension gnome-shell widgets
  • 10. GObject Introspection JS Java Python Perl Ruby PHP? GI GTK Clutter VTE notify GStreamer Native C API
  • 11. Getting started! LiveUSB http://gnome3.org/tryit.html $ gnome-shell-extension-tool --create-extension
  • 13. Restart gnome-shell alt+F2 and press "r"
  • 14. Default extension Click panel Show Hello world, and destroy after 5sec
  • 15. Default extension code // Sample extension code, makes clicking on the panel show a message const St = imports.gi.St; const Mainloop = imports.mainloop; const Main = imports.ui.main; function _showHello() { let text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" }); let monitor = global.get_primary_monitor(); global.stage.add_actor(text); text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2)); Mainloop.timeout_add(3000, function () { text.destroy(); }); } // Put your extension initialization code here function main() { Main.panel.actor.reactive = true; Main.panel.actor.connect('button-release-event', _showHello); }
  • 16. Global (1/2) ● Monitor ● Pointer: ● get_monitors() ● get_pointer() ● get_primary_monito ● Window/Screen: r() ● get_gdk_screen() ● get_primary_monito r_index() ● get_screen() ● get_focus_monitor() ● get_window_actors() return MetaRectangle
  • 17. Global (2/2) ● Properties ● stage ● screen-width/screen-height ● window-group ● settings ● datadir ● userdatadir
  • 18. Looking glass alt+F2 and press "lg"
  • 19. Default extension code // Sample extension code, makes clicking on the panel show a message const St = imports.gi.St; const Mainloop = imports.mainloop; const Main = imports.ui.main; function _showHello() { let text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" }); let monitor = global.get_primary_monitor(); global.stage.add_actor(text); text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2)); Mainloop.timeout_add(3000, function () { text.destroy(); }); } // Put your extension initialization code here function main() { Main.panel.actor.reactive = true; Main.panel.actor.connect('button-release-event', _showHello); } http://library.gnome.org/devel/glib/unstable/glib-The-Main-Event-Loop.html
  • 20. Main
  • 21. Main ● Main.panel ● button ● _leftBox, _centerBox, _rightBox ● _dateMenu ● ... ● Main.overview ● Main.runDialog ● Main.uiGroup ● ...
  • 22. Default extension code // Sample extension code, makes clicking on the panel show a message const St = imports.gi.St; const Mainloop = imports.mainloop; const Main = imports.ui.main; function _showHello() { let text = new St.Label({ style_class: 'helloworld-label', text: "Hello, world!" }); let monitor = global.get_primary_monitor(); global.stage.add_actor(text); text.set_position(Math.floor (monitor.width / 2 - text.width / 2), Math.floor(monitor.height / 2 - text.height / 2)); Mainloop.timeout_add(3000, function () { text.destroy(); }); } // Put your extension initialization code here function main() { Main.panel.actor.reactive = true; Main.panel.actor.connect('button-release-event', _showHello); }
  • 23. Try it ● Main.panel._dateMenu.menu.actor.set_opacity(100) ● Main.panel._dateMenu.actor.set_scale(1.5, 1.5) ● Main.panel._dateMenu.menu.actor.set_z_rotation_from_ gravity(45.0, Clutter.Gravity.CENTER) ● Don's you like status-menu? ● Main.panel._statusmenu.actor.hide()
  • 24. Example extension – fancy screenshot tool http://www.youtube.com/watch?v=epKssSQpfLQ $ sudo zypper refresh && sudo zypper install ImageMagick (Because GdkPixbuf.savev function is broken)
  • 26. _leftBox _centerBox _rightBox
  • 28. Step 3: Handle Click
  • 29. Tweener ● transition ● linear, easeInQuad, … (reference python- clutter) ● onComplete/onCompleteScope ● scale_x, scale_y, opacity
  • 30. Animation Counting down Shotting Zoom
  • 34. Step 5: Save screenshot
  • 37. No document sad... Sad Zeb, by-nc,sa
  • 38. Reference ● gnome-shell source code ● mutter source code ● http://git.gnome.org/browse/ ● ZZzzzz
  • 40. Q&A Slides Download http://j.mp/gs-ext-slides