Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "SWT/Devel/Gtk"

< SWT‎ | Devel
m
(How to identify if your app runs on Wayland as backend)
 
(66 intermediate revisions by 2 users not shown)
Line 1: Line 1:
= SWT Gtk Development =
+
= Getting started =
Here are links to sections that are too big for this page:
+
If you are new to or want to learn SWT-GTK development, please see the [[SWT/Devel/Gtk/Dev_guide | comprehensive SWT-GTK development guide]]
# [https://wiki.eclipse.org/SWT/Devel/Gtk/Compiling_Gtk Compiling various versions of Gtk]
+
# [https://wiki.eclipse.org/SWT/Devel/Gtk/Version_specific_macro Defining a version specific Gtk macro to prevent compilation errors]
+
# [https://wiki.eclipse.org/SWT/Devel/Gtk/Sentinel_warning Eliminating "sentinel" warnings on SWT JNI compilation]
+
  
= Launching Eclipse with SWT source code =  
+
= SWT-GTK development articles =
To test SWT snippets, it's useful to launch a child Eclipse with your patch to see how it looks and feels.
+
* [[SWT/Devel/Gtk/Dev_guide | Comprehensive SWT development guide]]
To do so, under run-configurations, right click on "Eclipse Application" and select "new".
+
[[File:RunConfigurationWithEclipseApplication.png|thumbnail|center|Eclipse Application]]
+
  
== Common troubleshooting ==
+
== GTK compilation ==
Often Eclipse won't launch with various errors. Below are common steps to troubleshoot.
+
* [[SWT/Devel/Gtk/Compiling_Gtk | Compiling various versions of GTK]]
 +
* [[SWT/Devel/Gtk/jhbuild | JHBuild : Compile newest GTK+ versions and it's dependencies with with jhbuild]]
 +
* [[SWT/Devel/Gtk/Version_specific_macro | Defining a version specific GTK macro to prevent compilation errors]]
 +
* [[SWT/Devel/Gtk/pkg-config_compiled_GTK | Using locally compiled GTK libraries with native GTK snippets]]
  
* '''API Baseline: ''' Make sure API Base line is set. If you updated Eclipse (e.g Luna to Mars), you may need to re-create the baseline.
+
== SWT JNI compilation and os_custom development==
* '''Enable Execution Environments: ''' Make sure that relevant Execution Environments are enabled. (1.5, 1.6 etc..)
+
* [[SWT/Devel/Gtk/Sentinel_warning | Eliminating "sentinel" warnings on SWT JNI compilation]]
[[File:Eclipse Preference Executin Environments.png|thumbnail|center|Eclipse Execution Environments]]
+
* [[SWT/Devel/Gtk/os_custom | os_custom development (SwtFixed implementation)]]
* '''Target Platform: ''' Make sure to have an Target Platform set. Try re-creating it with Default for running platform.
+
* '''Validate Plugins: ''' In the run-time configuration for a Child Eclipse, under the 'Plug-ins' tab, instead of launching all plugins, try to select only SWT and it's binaries. Try to Validate the setup to see if there are missing dependencies.
+
* '''re-create new run-time configuration: ''' Often after updating Eclipse version,  I have to create new "Eclipse Application" run time configurations for the child Eclipse to launch propertly
+
  
== Tips ==
+
== GTK CSS ==
* '''Choice of child Eclipse Workspace:''' Instead of using a blank workspace, copy your exiting workspace, append '-runtime' and use that for your child Eclipse.
+
* [[SWT/Devel/Gtk/CSS_selector | Avoid "expected valid selector" warnings in console output]]
  
= Patch Submission guidelines =
+
== Debugging ==
When submitting patches, you should consider the following:
+
* [[SWT/Devel/Gtk/crashstack | Getting more information from a jvm crash ]]
  
== General checklist ==
+
== Accessibility ==
* Your patches must compile/build on both Gtk2 and Gtk3.
+
* [[SWT/Devel/Gtk/Atk | ATK Introduction]]
  
== Also keep in mind ==
+
== Equinox launcher ==
* Avoid refactoring code in the same patch as a bug-fix. Instead split it up into two commits. <ref> This makes it easier to rollback broken commits and avoids merge conflicts.
+
* For GTK related Equinox launcher information, refer to the [[Equinox/dev/gtk | Equinox documentation]].
</ref>
+
* Please avoid removing white spaces in the same commit as a bugfix. <ref> Reviewing patches that consist of a lot of white space removal and a few actual code changes is tedious and causes merge conflicts. Instead submit white space removal in a separate patch. </ref>
+
* Your code should follow SWT code style. See the code in other widgets for guidance. <ref> E.g use '!=' instead of '>' for bit checks. (TODO, add wiki page on SWT code style) </ref>
+
* Avoid introducing methods that are only called once. But if you see the same code many times, it makes sense to add a method for it.
+
* When removing code that calls internal functions, check that those functions are actually still called else where. Avoid leaving dead methods in the code.
+
  
== General etiquette ==
+
== Coding ==  
* Description : It's recommended to mention how you tested your patch at the end of the description. <ref>E.g "Tested on Gtk2.24, Gtk3.14, Gtk3.16 on Snippet123. Also tested with child Eclipse on Luna and Mars"</ref>
+
* [[SWT/Devel/Gtk/PI | Prototyping GTK snippets via Program Interface (PI) Snippets ]]
* When you submit new patch sets, in the comment please describe what you improved on (unless it's a trivial thing). Often when reviewing multiple patch sets it's easy to loose track what was done in each patch set.
+
  
{{reflist}}
+
== Testing ==
 +
* [[SWT/Devel/Gtk/JUnitTests | SWT JUnit tests]]
 +
* [[SWT/Devel/Gtk/platformTests | Platform UI/JFace tests for SWT developers]]
  
= Wayland Development =
+
== Uploading your patch ==
 +
* [[SWT/Devel/Gtk/Patch_guidelines | Patch submission guidelines]]
 +
 
 +
== Miscellaneous ==
 +
* [[SWT/Devel/Gtk/GtkVersion | Finding which version of GTK your Eclipse runs on]]
 +
* [[SWT/Devel/Gtk/GNOME_icons | Enabling icons in menus, buttons, and more in GNOME3]]
 +
* [[SWT/Devel/Gtk/GtkPackageFedora | Determining what version of GTK shipped with Fedora]]
 +
* [https://developer.gnome.org/gtk3/stable/ch25s02.html GNOME documentation on changes from GTK2 to GTK3]
 +
* [[SWT/Devel/Gtk/Errors after repository reset | How to fix massive import errors after repository reset]]
 +
* [[SWT/Devel/Gtk/Missing so file errors | Fix "missing gtk-*.so" file errors when launching a child Eclipse]]
 +
 
 +
= Wayland specific development articles =
 
Wayland [https://en.wikipedia.org/wiki/Wayland_(display_server_protocol) (wiki)] is a rendering engine, intended to be a replacement for X Window System [https://en.wikipedia.org/wiki/X_Window_System (wiki)].
 
Wayland [https://en.wikipedia.org/wiki/Wayland_(display_server_protocol) (wiki)] is a rendering engine, intended to be a replacement for X Window System [https://en.wikipedia.org/wiki/X_Window_System (wiki)].
  
== Launching wayland ==
+
== Launching Wayland ==
In fedora 21+, you can run things on Wayland. There are several ways:
+
In Fedora 21+, you can run things on Wayland. There are several ways:
  
== Log into Gnome Wayland ==
+
== Log into GNOME Wayland ==
Log out and then on the logon screen, click on the gear icon and select "Gnome Wayland". [http://fedoramagazine.org/wp-content/uploads/2014/10/gdm-wayland.png  See example screenshot]. At the time of writing (2015.07.21) things like drag and drop and copy and paste did not work. So using Gnome-Wayland full time is difficult.
+
Log out and then on the logon screen, click on the gear icon and select "Gnome Wayland". [http://fedoramagazine.org/wp-content/uploads/2014/10/gdm-wayland.png  See example screenshot]. As of 4.8 Eclipse is very usable on Wayland full time, barring a few smaller issues.
  
 
== Launch Gnome Wayland in other Virtual Console ==
 
== Launch Gnome Wayland in other Virtual Console ==
Line 58: Line 60:
 
     gnome-session --session gnome-wayland
 
     gnome-session --session gnome-wayland
  
Then you can press Ctrl+Alt+F2 to get back to your original session.
+
== Kill unresponsive Wayland session ==
 +
You may find sometimes that Wayland with GNOME becomes unresponsive. In this case, switch back to your original virtual terminal (using Ctlr + Alt + F[1,2,3,4...]).
 +
 
 +
Running the following command will give you the PID of the process that needs to be killed in order to end the GNOME Wayland session:
 +
  ps aux | grep <TTY_NUMBER> | grep "gnome-session --session gnome-wayland" | grep -v dbus | awk '{print $2}'                # where <TTY_NUMBER> is the tty Wayland is running on (i.e. tty[1,2,3,4...])
 +
 
 +
You can then kill it using:
 +
  sudo kill PID              # where PID is the PID of process found from the step above
 +
 
 +
To make this a bit easier I have written a script that does this all in one step.
 +
  export PID="$(ps aux | grep $1 | grep "gnome-session --session gnome-wayland" | grep -v dbus | awk '{print $2}')"
 +
  kill $PID
 +
 
 +
Simply run the script using:
 +
  kill_gnome_wayland <TTY_NUMBER>            # where <TTY_NUMBER> is the tty Wayland is running on (i.e. tty[1,2,3,4...])
 +
 
 +
Note: to kill the process you may/may not need to use sudo.
  
 
== How to identify if your app runs on Wayland as backend ==
 
== How to identify if your app runs on Wayland as backend ==
Wayland has a notion of XWayland. This is so that you can run Gtk2 apps on Wayland.
+
Wayland has a notion of XWayland. This is so that you can run GTK2 apps on Wayland.
Since Wayland and X applications look almost the same, it's tricky to tell them appart.
+
Since Wayland and X applications look almost the same, it's tricky to tell them apart.
  
 
There are several ways to tell.
 
There are several ways to tell.
* Launch Gtk Inspector. Under "General" tab, look under "Gdk Backend".
+
* Launch Gtk Inspector. Under "General" tab, look under "GDK Backend".
* Launch looking glass "lg", top left click on "Windows" Tab, then click on one of the appliactions in the list, inspect 'Gtype'. E.g
+
* Launch looking glass "lg", top left click on "Windows" Tab, then click on one of the applications in the list, inspect 'Gtype'. E.g
 
             Gtype:MetaWindowX11          # X11
 
             Gtype:MetaWindowX11          # X11
 
             Gtype:MetaWindowWayland      # Wayland
 
             Gtype:MetaWindowWayland      # Wayland
  
= See Also Eclipse Wiki Pages =
+
= Useful Eclipse wiki pages =
 
These are pages mostly for special interest.
 
These are pages mostly for special interest.
* [https://wiki.eclipse.org/SWT/Devel/Gtk/Atk Atk development]
+
* Useful tools/shortcuts within Eclipse to make SWT development easier [[SWT/Devel/Gtk/Useful_Eclipse_shortcuts | Useful Eclipse Shortcuts ]]
* Useful tools/shortcuts within Eclipse to make SWT development easier [[SWT/Devel/Gtk/Useful_Eclipse_shortcuts]]
+
  
= See Also External =  
+
= Further reading beyond this wiki =  
* How to update Eclipse to Rawhide (Alpha versions of Eclipse on Fedora). [https://coffeeorientedprogramming.wordpress.com/2015/07/27/how-to-update-eclipse-to-bleeding-edge-rawhide/ Eclipse to Rawhide]
+
* SWT tagged posts on Leo's blog: [https://coffeeorientedprogramming.com/category/programming/swt/ CoffeeOrientedProgramming.com ]
 +
* How to update Fedora Eclipse to from stable to rawhide [https://coffeeorientedprogramming.wordpress.com/2015/07/27/how-to-update-eclipse-to-bleeding-edge-rawhide/ Eclipse to Rawhide]
 
* Introduction to bash scripting [http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html Bash for Beginners Guide]
 
* Introduction to bash scripting [http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html Bash for Beginners Guide]

Latest revision as of 15:59, 22 August 2018

Getting started

If you are new to or want to learn SWT-GTK development, please see the comprehensive SWT-GTK development guide

SWT-GTK development articles

GTK compilation

SWT JNI compilation and os_custom development

GTK CSS

Debugging

Accessibility

Equinox launcher

Coding

Testing

Uploading your patch

Miscellaneous

Wayland specific development articles

Wayland (wiki) is a rendering engine, intended to be a replacement for X Window System (wiki).

Launching Wayland

In Fedora 21+, you can run things on Wayland. There are several ways:

Log into GNOME Wayland

Log out and then on the logon screen, click on the gear icon and select "Gnome Wayland". See example screenshot. As of 4.8 Eclipse is very usable on Wayland full time, barring a few smaller issues.

Launch Gnome Wayland in other Virtual Console

Alternatively, you can press Ctl+Alt+F3 etc.. to launch a virtual console. You login with your own user. Then run Gnome Wayland via:

   gnome-session --session gnome-wayland

Kill unresponsive Wayland session

You may find sometimes that Wayland with GNOME becomes unresponsive. In this case, switch back to your original virtual terminal (using Ctlr + Alt + F[1,2,3,4...]).

Running the following command will give you the PID of the process that needs to be killed in order to end the GNOME Wayland session:

  ps aux | grep <TTY_NUMBER> | grep "gnome-session --session gnome-wayland" | grep -v dbus | awk '{print $2}'                # where <TTY_NUMBER> is the tty Wayland is running on (i.e. tty[1,2,3,4...])

You can then kill it using:

 sudo kill PID               # where PID is the PID of process found from the step above

To make this a bit easier I have written a script that does this all in one step.

 export PID="$(ps aux | grep $1 | grep "gnome-session --session gnome-wayland" | grep -v dbus | awk '{print $2}')"
 kill $PID

Simply run the script using:

 kill_gnome_wayland <TTY_NUMBER>            # where <TTY_NUMBER> is the tty Wayland is running on (i.e. tty[1,2,3,4...])

Note: to kill the process you may/may not need to use sudo.

How to identify if your app runs on Wayland as backend

Wayland has a notion of XWayland. This is so that you can run GTK2 apps on Wayland. Since Wayland and X applications look almost the same, it's tricky to tell them apart.

There are several ways to tell.

  • Launch Gtk Inspector. Under "General" tab, look under "GDK Backend".
  • Launch looking glass "lg", top left click on "Windows" Tab, then click on one of the applications in the list, inspect 'Gtype'. E.g
           Gtype:MetaWindowX11          # X11
           Gtype:MetaWindowWayland      # Wayland

Useful Eclipse wiki pages

These are pages mostly for special interest.

Further reading beyond this wiki

Back to the top