Conversation
|
Please review this PR @MostlyKIGuess @chimosky . @MostlyKIGuess shared this commit sugarlabs/sugar-toolkit-gtk4@9be4b2e with me for reference, but it did not work in my case. I tried both approaches — using hardcoded CSS priority values and using GTK4 constants — but neither worked as expected. As discussed in the meeting, we should not apply hardcoded CSS like this:- If this approach is not correct, could you please recommend a better solution to resolve this styling issue? |
|
This should be a draft PR until Sugar is ported and this can be tested. Also drop the merge commit, not sure why that's there.
sugar-artwork already contains the necessary css definitions for Sugar, have you checked to be sure that what you need doesn't already exist, the odds of that being the case is pretty slim. |
Got it , I will drop the merge commit and check out artwork one more time |
|
How to test this on Ubuntu 24.04? Which of these two pull requests are to be worked further? See #81 |
Hey @quozl — continuing from #81. If you want to test it on Ubuntu 24.04, you can run the activity using the SUGAR_BUNDLE_PATH=$(pwd) SUGAR_BUNDLE_NAME="Calculate" SUGAR_BUNDLE_ID="org.laptop.Calculate" SUGAR_ACTIVITY_ROOT=/tmp GDK_BACKEND=x11 python3 main.py I also pushed an update to #81 that addresses the CSS feedback from @chimosky. The hardcoded Let me know if this works for you on 24.04. |
|
Taken an Ubuntu 24.04 with working Sugar, then did this;
Looks like more needs to be done to run this. |
|
@quozl Just a quick heads-up regarding that ValueError. It usually happens because standard Sugar installations only include the GTK3 bindings. sudo apt install gir1.2-gtk-4.0 After that, the standalone main.py command should run correctly. |
You need to install GTK4 locally and other dependencies through Nix. Then run python main.py. I can also provide the necessary commands if you need them |
|
@Inuth0603 @Dakshsharma1108 If Gtk4 is currently installed in a running sugar environment, it won't be able to be loaded, so installing Gtk4 isn't the answer, Sugar hasn't been ported to Gtk4 and until that happens, testing these changes within sugar can't happen, which is the first thing I'd said in my first comment. |
|
Sorry for that 😅 |
|
Okay, can't be tested yet. |
Port Calculate Activity to GTK4
This PR migrates the activity from GTK3 → GTK4 and replaces deprecated GTK3 APIs with GTK4 equivalents.
The Terminal activity GTK4 port was used as a reference while making these changes to follow Sugar GTK4
migration patterns.
Key Replacements
gi.require_version("Gtk", "3.0")→"4.0"sugar3→sugar4connect("key_press_event", ...)→Gtk.EventControllerKeyGtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)→Gdk.Display.get_default().get_clipboard()modify_bg()/modify_base()→ CSS styling usingGtk.CssProviderGdk.Cursor.new()→Gdk.Cursor.new_from_name()set_border_window_size()→ margin properties (set_left_margin(),set_right_margin(), etc.)add()→set_child()pack_start()/pack_end()→append()Updated
Gtk.Boxchild management:box.pack_start(widget, ...)→box.append(widget)expand,fill, andpaddingargumentsReplace
show_all()toshow()Replaced deprecated
Gdk.Screenusage withGdk.DisplayAdded
set_default_size()for proper window sizing in GTK4Visual Changes:
After porting testing without sugar:
