Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to gtk4 #1497

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ You'll need the following dependencies:
* libgail-3-dev
* libgee-0.8-dev
* libgit2-glib-1.0-dev
* libgtksourceview-4-dev
* libgtksourceview-5-dev
* libgtkspell3-3-dev
* libgranite-dev >= 6.0.0
* libhandy-1-dev >= 0.90.0
* libpeas-dev
* libgranite-7-dev >= 6.0.0
* libadwaita-1-dev >= 1.0.0
* libsoup2.4-dev
* libvala-0.48-dev (or higher)
* libvte-2.91-dev
* libvala-0.56-dev (or higher)
* libvte-2.91-gtk4-dev
* valac

Run `meson build` to configure the build environment. Change to the build directory and run `ninja test` to build
Expand Down
87 changes: 38 additions & 49 deletions io.elementary.code.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,43 @@
app-id: io.elementary.code
runtime: io.elementary.Sdk # The outline plugin requires libvala which is only in the SDK, not the runtime
runtime-version: '7.1'
runtime-version: "7.1"
sdk: io.elementary.Sdk
command: io.elementary.code
finish-args:
- '--filesystem=xdg-run/gvfsd'
- '--filesystem=host'
- "--filesystem=xdg-run/gvfsd"
- "--filesystem=host"

- '--share=ipc'
- '--socket=fallback-x11'
- '--socket=wayland'
- "--share=ipc"
- "--socket=fallback-x11"
- "--socket=wayland"

- '--talk-name=org.gtk.vfs.*'
- '--talk-name=org.gnome.SettingsDaemon'
- '--talk-name=org.elementary.Contractor'
- "--talk-name=org.gtk.vfs.*"
- "--talk-name=org.gnome.SettingsDaemon"
- "--talk-name=org.elementary.Contractor"

- '--metadata=X-DConf=migrate-path=/io/elementary/code/'
- "--metadata=X-DConf=migrate-path=/io/elementary/code/"
cleanup:
- '/include'
- '/lib/pkgconfig'
- '/lib/cmake'
- '/lib/girepository-1.0'
- '/share/gir-1.0'
- '/share/vala'
- '*.a'
- '*.la'
- "/include"
- "/lib/pkgconfig"
- "/lib/cmake"
- "/lib/girepository-1.0"
- "/share/gir-1.0"
- "/share/vala"
- "*.a"
- "*.la"
modules:
- name: gtksourceview
buildsystem: meson
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/gtksourceview.git
tag: '4.8.4'

- name: peas
buildsystem: meson
config-opts:
- '-Dgtk_doc=false'
- '-Ddemos=false'
- '-Dvapi=true'
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/libpeas.git
tag: libpeas-1.34.0
tag: "4.8.4"

- name: git2-glib
buildsystem: meson
builddir: true
config-opts:
- '-Dpython=false'
- "-Dpython=false"
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/libgit2-glib.git
Expand All @@ -57,51 +46,51 @@ modules:
- name: ssh2
buildsystem: cmake-ninja
config-opts:
- '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
- '-DBUILD_SHARED_LIBS:BOOL=ON'
- '-DBUILD_EXAMPLES:BOOL=OFF'
- '-DBUILD_TESTING:BOOL=OFF'
- '-DCMAKE_INSTALL_LIBDIR:PATH=/app/lib'
- "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
- "-DBUILD_SHARED_LIBS:BOOL=ON"
- "-DBUILD_EXAMPLES:BOOL=OFF"
- "-DBUILD_TESTING:BOOL=OFF"
- "-DCMAKE_INSTALL_LIBDIR:PATH=/app/lib"
cleanup:
- '/share/man'
- '/share/doc'
- "/share/man"
- "/share/doc"
sources:
- type: git
url: https://github.com/libssh2/libssh2.git
tag: libssh2-1.10.0
- name: libgit2
buildsystem: cmake-ninja
config-opts:
- '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
- "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
sources:
- type: git
url: https://github.com/libgit2/libgit2.git
tag: 'v1.5.1'
tag: "v1.5.1"

- name: editorconfig
buildsystem: cmake-ninja
config-opts:
- '-DCMAKE_BUILD_TYPE=RelWithDebInfo'
- '-DBUILD_DOCUMENTATION:BOOL=OFF'
- "-DCMAKE_BUILD_TYPE=RelWithDebInfo"
- "-DBUILD_DOCUMENTATION:BOOL=OFF"
sources:
- type: git
url: https://github.com/editorconfig/editorconfig-core-c.git
tag: 'v0.12.6'
tag: "v0.12.6"
disable-submodules: true

- name: gtkspell
config-opts:
- '--disable-gtk-doc-html'
- "--disable-gtk-doc-html"
cleanup:
- '/share/gtk-doc' # for some reason, it still install the html folder.
- "/share/gtk-doc" # for some reason, it still install the html folder.
sources:
- type: archive
url: https://downloads.sourceforge.net/gtkspell/gtkspell3-3.0.10.tar.xz
sha256: b040f63836b347eb344f5542443dc254621805072f7141d49c067ecb5a375732
modules:
- name: intltool
cleanup:
- '*'
- "*"
sources:
- type: archive
url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz
Expand All @@ -110,11 +99,11 @@ modules:
- name: vte
buildsystem: meson
config-opts:
- '-Dbuildtype=debugoptimized'
- "-Dbuildtype=debugoptimized"
sources:
- type: git
url: https://gitlab.gnome.org/GNOME/vte.git
branch: '0.70.2'
branch: "0.70.2"

- name: universal-ctags
sources:
Expand All @@ -125,7 +114,7 @@ modules:
- name: code
buildsystem: meson
config-opts:
- '-Dhave_pkexec=false'
- "-Dhave_pkexec=false"
sources:
- type: dir
path: .
20 changes: 8 additions & 12 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_project_arguments([
)

add_project_arguments(
['--vapidir', meson.project_source_root() / 'vapi'],
['--vapidir', meson.global_source_root() / 'vapi'],
language: 'vala'
)

Expand All @@ -26,20 +26,18 @@ pluginsdir = get_option('prefix') / get_option('libdir') / meson.project_name()
gnome = import('gnome')
i18n = import('i18n')

glib_dep = dependency('glib-2.0', version: '>=2.30.0')
glib_dep = dependency('glib-2.0', version: '>=2.74.0')
gio_unix_dep = dependency('gio-unix-2.0', version: '>=2.20')
gee_dep = dependency('gee-0.8', version: '>=0.8.5')
gtk_dep = dependency('gtk+-3.0', version: '>=3.6.0')
granite_dep = dependency('granite', version: '>=6.0.0')
handy_dep = dependency('libhandy-1', version: '>=0.90.0')
gtksourceview_dep = dependency('gtksourceview-4')
peas_dep = dependency('libpeas-1.0')
peasgtk_dep = dependency('libpeas-gtk-1.0')
gtk_dep = dependency('gtk4', version: '>=4.14.2')
granite_dep = dependency('granite-7', version: '>=7.0.0')
adwaita_dep = dependency('libadwaita-1', version: '>=1.0.0')
gtksourceview_dep = dependency('gtksourceview-5')
git_dep = dependency('libgit2-glib-1.0')
fontconfig_dep = dependency('fontconfig')
pangofc_dep = dependency('pangoft2')
posix_dep = meson.get_compiler('vala').find_library('posix')
vte_dep = dependency('vte-2.91')
vte_dep = dependency('vte-2.91-gtk4', version: '>=0.76')

code_resources = gnome.compile_resources(
'code-resources', 'data/' + meson.project_name() + '.gresource.xml',
Expand All @@ -56,10 +54,8 @@ dependencies = [
gee_dep,
gtk_dep,
granite_dep,
handy_dep,
adwaita_dep,
gtksourceview_dep,
peas_dep,
peasgtk_dep,
git_dep,
fontconfig_dep,
pangofc_dep,
Expand Down
2 changes: 1 addition & 1 deletion plugins/detect-indent/detect-indent.vala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Scratch.Plugins.DetectIndent: Peas.ExtensionBase, Peas.Activatable
return;
}

var source_buffer = (Gtk.SourceBuffer) view.buffer;
var source_buffer = (GtkSource.Buffer) view.buffer;
Gtk.TextIter it;
source_buffer.get_iter_at_line (out it, 0);

Expand Down
2 changes: 1 addition & 1 deletion plugins/fuzzy-search/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ custom_target(module_name + '.plugin_merge',
'--desktop',
'--keyword=Description',
'--keyword=Name',
'-d' + join_paths(meson.source_root (), 'po', 'plugins'),
'-d' + join_paths(meson.global_source_root (), 'po', 'plugins'),
'--template=@INPUT@',
'-o@OUTPUT@',
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class Scratch.Plugins.HighlightSelectedWords : Peas.ExtensionBase, Peas.A
window_search_context.get_occurrences_count () == 0) {
// Perform plugin selection when there is no ongoing and successful search
current_search_context = new Gtk.SourceSearchContext (
(Gtk.SourceBuffer)current_source.buffer,
(GtkSource.Buffer)current_source.buffer,
null
);
current_search_context.settings.search_text = "";
Expand Down
2 changes: 1 addition & 1 deletion plugins/spell/spell.vala
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public class Scratch.Plugins.Spell: Peas.ExtensionBase, Peas.Activatable {
});

// Deactivate Spell checker when we are editing a code file
var source_buffer = (Gtk.SourceBuffer) d.source_view.buffer;
var source_buffer = (GtkSource.Buffer) d.source_view.buffer;
var lang = source_buffer.language;
if (lang != null && lang.id != "markdown") {
spell.detach ();
Expand Down
6 changes: 2 additions & 4 deletions src/FolderManager/FileItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Scratch.FolderManager {
view.activate (file.path);
}

public override Gtk.Menu? get_context_menu () {
public override GLib.Menu? get_context_menu () {
GLib.FileInfo info = null;

try {
Expand Down Expand Up @@ -88,9 +88,7 @@ namespace Scratch.FolderManager {
menu_model.append_section (null, external_actions_section);
menu_model.append_section (null, direct_actions_section);

var menu = new Gtk.Menu.from_model (menu_model);
menu.insert_action_group (FileView.ACTION_GROUP, view.actions);
return menu;
return menu_model;
}

private GLib.MenuItem create_submenu_for_open_in (string? file_type) {
Expand Down
6 changes: 2 additions & 4 deletions src/FolderManager/FolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ namespace Scratch.FolderManager {
}
}

public override Gtk.Menu? get_context_menu () {
public override GLib.Menu? get_context_menu () {
var open_in_terminal_pane_item = new GLib.MenuItem (
(_("Open in Terminal Pane")),
GLib.Action.print_detailed_name (
Expand Down Expand Up @@ -152,9 +152,7 @@ namespace Scratch.FolderManager {
menu_model.append_section (null, direct_actions_section);
menu_model.append_section (null, search_section);

var menu = new Gtk.Menu.from_model (menu_model);
menu.insert_action_group (FileView.ACTION_GROUP, view.actions);
return menu;
return menu_model;
}

protected GLib.MenuItem create_submenu_for_open_in (string? file_type) {
Expand Down
6 changes: 2 additions & 4 deletions src/FolderManager/ProjectFolderItem.vala
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ namespace Scratch.FolderManager {
}
}

public override Gtk.Menu? get_context_menu () {
public override GLib.Menu? get_context_menu () {
GLib.FileInfo info = null;
unowned string? file_type = null;

Expand Down Expand Up @@ -296,9 +296,7 @@ namespace Scratch.FolderManager {
menu_model.append_section (null, delete_actions_section);
menu_model.append_section (null, search_actions_section);

var menu = new Gtk.Menu.from_model (menu_model);
menu.insert_action_group (FileView.ACTION_GROUP, view.actions);
return menu;
return menu_model;
}

protected GLib.MenuItem create_submenu_for_branch () {
Expand Down
10 changes: 5 additions & 5 deletions src/MainWindow.vala
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/

namespace Scratch {
public class MainWindow : Hdy.Window {
public class MainWindow : Adw.Window {
public const int FONT_SIZE_MAX = 72;
public const int FONT_SIZE_MIN = 7;
private const uint MAX_SEARCH_TEXT_LENGTH = 255;
Expand Down Expand Up @@ -50,7 +50,7 @@ namespace Scratch {
private Gtk.Paned vp;
private Gtk.Stack content_stack;

public Gtk.Clipboard clipboard;
public Gdk.Clipboard clipboard;

// Delegates
delegate void HookFunc ();
Expand Down Expand Up @@ -279,7 +279,7 @@ namespace Scratch {
update_style ();
});

clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD);
clipboard = Gdk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD);

plugins = new Scratch.Services.PluginsManager (this);

Expand Down Expand Up @@ -1318,8 +1318,8 @@ namespace Scratch {
}

var buffer = doc.source_view.buffer;
if (buffer is Gtk.SourceBuffer) {
CommentToggler.toggle_comment (buffer as Gtk.SourceBuffer);
if (buffer is GtkSource.Buffer) {
CommentToggler.toggle_comment (buffer as GtkSource.Buffer);
}
}

Expand Down
Loading
Loading