diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9090e51f0..173e73096 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,7 +22,7 @@ jobs: - name: Install Dependencies run: | apt update - apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgit2-glib-1.0-dev libgranite-dev libgtk-3-dev libgtksourceview-4-dev libgtkspell3-3-dev libhandy-1-dev libpeas-dev libsoup2.4-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev + apt install -y exuberant-ctags libeditorconfig-dev libgail-3-dev libgee-0.8-dev libgranite-7-dev libgtk-4-dev libgtksourceview-5-dev libgtkspell3-3-dev libadwaita-1-dev libpeas-2-dev libsoup2.4-dev libvala-dev libvte-2.91-dev meson valac polkitd libpolkit-gobject-1-dev - name: Build env: DESTDIR: out diff --git a/README.md b/README.md index 9f440e8b3..0b26b050e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/io.elementary.code.yml b/io.elementary.code.yml index c0764fbf4..77e4ffaff 100644 --- a/io.elementary.code.yml +++ b/io.elementary.code.yml @@ -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 @@ -57,14 +46,14 @@ 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 @@ -72,28 +61,28 @@ modules: - 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 @@ -101,7 +90,7 @@ modules: modules: - name: intltool cleanup: - - '*' + - "*" sources: - type: archive url: https://launchpad.net/intltool/trunk/0.51.0/+download/intltool-0.51.0.tar.gz @@ -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: @@ -125,7 +114,7 @@ modules: - name: code buildsystem: meson config-opts: - - '-Dhave_pkexec=false' + - "-Dhave_pkexec=false" sources: - type: dir path: . diff --git a/meson.build b/meson.build index b600a8066..17b277171 100644 --- a/meson.build +++ b/meson.build @@ -12,7 +12,7 @@ add_project_arguments([ ) add_project_arguments( - ['--vapidir', meson.project_source_root() / 'vapi'], + ['--vapidir', meson.global_source_root() / 'vapi'], language: 'vala' ) @@ -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', @@ -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, diff --git a/plugins/detect-indent/detect-indent.vala b/plugins/detect-indent/detect-indent.vala index 09fe9c1d2..9f079e4d4 100644 --- a/plugins/detect-indent/detect-indent.vala +++ b/plugins/detect-indent/detect-indent.vala @@ -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); diff --git a/plugins/fuzzy-search/meson.build b/plugins/fuzzy-search/meson.build index 5a717fcd1..29f14c1e8 100644 --- a/plugins/fuzzy-search/meson.build +++ b/plugins/fuzzy-search/meson.build @@ -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@', ], diff --git a/plugins/highlight-word-selection/highlight-word-selection.vala b/plugins/highlight-word-selection/highlight-word-selection.vala index 5896b5d43..be17df4ac 100644 --- a/plugins/highlight-word-selection/highlight-word-selection.vala +++ b/plugins/highlight-word-selection/highlight-word-selection.vala @@ -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 = ""; diff --git a/plugins/spell/spell.vala b/plugins/spell/spell.vala index 6e90e60e2..4c9d03e88 100644 --- a/plugins/spell/spell.vala +++ b/plugins/spell/spell.vala @@ -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 (); diff --git a/src/FolderManager/FileItem.vala b/src/FolderManager/FileItem.vala index 03d728927..ede06f7b0 100644 --- a/src/FolderManager/FileItem.vala +++ b/src/FolderManager/FileItem.vala @@ -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 { @@ -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) { diff --git a/src/FolderManager/FolderItem.vala b/src/FolderManager/FolderItem.vala index 33f8e130d..31dc92b85 100644 --- a/src/FolderManager/FolderItem.vala +++ b/src/FolderManager/FolderItem.vala @@ -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 ( @@ -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) { diff --git a/src/FolderManager/ProjectFolderItem.vala b/src/FolderManager/ProjectFolderItem.vala index 9998db6be..697d4ab6b 100644 --- a/src/FolderManager/ProjectFolderItem.vala +++ b/src/FolderManager/ProjectFolderItem.vala @@ -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; @@ -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 () { diff --git a/src/MainWindow.vala b/src/MainWindow.vala index 34fe7d93d..3825e549c 100644 --- a/src/MainWindow.vala +++ b/src/MainWindow.vala @@ -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; @@ -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 (); @@ -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); @@ -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); } } diff --git a/src/Services/CommentToggler.vala b/src/Services/CommentToggler.vala index 56e721f44..12a5fe4b2 100644 --- a/src/Services/CommentToggler.vala +++ b/src/Services/CommentToggler.vala @@ -24,7 +24,7 @@ public class Scratch.CommentToggler { BLOCK } - private static CommentType get_comment_tags_for_lang (Gtk.SourceLanguage lang, + private static CommentType get_comment_tags_for_lang (GtkSource.Language lang, CommentType type, out string? start, out string? end) { @@ -64,7 +64,7 @@ public class Scratch.CommentToggler { return CommentType.NONE; } - public static bool language_has_comments (Gtk.SourceLanguage? lang) { + public static bool language_has_comments (GtkSource.Language? lang) { if (lang == null) { return false; } @@ -77,11 +77,11 @@ public class Scratch.CommentToggler { // This is to detect whether to toggle comments on or off. If all lines are commented, then we want to remove // those comments. If only some are commented, then the user likely selected a chunk of code that already contained // a couple of comments. In that case, we still want to insert comments. - private static CommentType lines_already_commented (Gtk.SourceBuffer buffer, + private static CommentType lines_already_commented (GtkSource.Buffer buffer, Gtk.TextIter start, Gtk.TextIter end, uint num_lines, - Gtk.SourceLanguage lang) { + GtkSource.Language lang) { string start_tag, end_tag; var type = get_comment_tags_for_lang (lang, CommentType.BLOCK, out start_tag, out end_tag); @@ -118,7 +118,7 @@ public class Scratch.CommentToggler { return CommentType.NONE; } - private static void remove_comments (Gtk.SourceBuffer buffer, + private static void remove_comments (GtkSource.Buffer buffer, Gtk.TextIter start, Gtk.TextIter end, uint num_lines, @@ -199,7 +199,7 @@ public class Scratch.CommentToggler { buffer.end_user_action (); } - private static void add_comments (Gtk.SourceBuffer buffer, + private static void add_comments (GtkSource.Buffer buffer, Gtk.TextIter start, Gtk.TextIter end, uint num_lines, @@ -297,7 +297,7 @@ public class Scratch.CommentToggler { buffer.delete_mark (emark); } - public static void toggle_comment (Gtk.SourceBuffer? buffer) { + public static void toggle_comment (GtkSource.Buffer? buffer) { if (buffer != null) { Gtk.TextIter start, end; var sel = buffer.get_selection_bounds (out start, out end); diff --git a/src/Services/Document.vala b/src/Services/Document.vala index 2505959e1..0cdb492de 100644 --- a/src/Services/Document.vala +++ b/src/Services/Document.vala @@ -37,7 +37,7 @@ namespace Scratch.Services { public unowned SimpleActionGroup actions { get; set construct; } // The TabPage that this document is a child of - public unowned Hdy.TabPage tab { get; private set; } + public unowned Adw.TabPage tab { get; private set; } public bool is_file_temporary { get { @@ -51,7 +51,7 @@ namespace Scratch.Services { } } - private Gtk.SourceFile source_file; + private GtkSource.File source_file; public GLib.File file { get { return source_file.location; @@ -163,7 +163,7 @@ namespace Scratch.Services { private bool completion_shown = false; private Gtk.ScrolledWindow scroll; - private Gtk.SourceMap source_map; + private GtkSource.Map source_map; private Gtk.Paned outline_widget_pane; private GLib.Cancellable save_cancellable; @@ -210,8 +210,8 @@ namespace Scratch.Services { expand = true }; scroll.add (source_view); - source_file = new Gtk.SourceFile (); - source_map = new Gtk.SourceMap (); + source_file = new GtkSource.File (); + source_map = new GtkSource.Map (); outline_widget_pane = new Gtk.Paned (Gtk.Orientation.HORIZONTAL); if (builder_blocks_font != null && builder_font_map != null) { @@ -293,7 +293,7 @@ namespace Scratch.Services { this.show_all (); } - public void init_tab (Hdy.TabPage tab) { + public void init_tab (Adw.TabPage tab) { this.tab = tab; notify["tab.loading"].connect (on_tab_loading_change); @@ -386,7 +386,7 @@ namespace Scratch.Services { Gtk.main_iteration (); } - var buffer = new Gtk.SourceBuffer (null); /* Faster to load into a separate buffer */ + var buffer = new GtkSource.Buffer (null); /* Faster to load into a separate buffer */ load_timout_id = Timeout.add_seconds_full (GLib.Priority.HIGH, 5, () => { if (load_cancellable != null && !load_cancellable.is_cancelled ()) { @@ -411,9 +411,9 @@ namespace Scratch.Services { }); try { - var source_file_loader = new Gtk.SourceFileLoader (buffer, source_file); + var source_file_loader = new GtkSource.FileLoader (buffer, source_file); yield source_file_loader.load_async (GLib.Priority.LOW, load_cancellable, null); - var source_buffer = source_view.buffer as Gtk.SourceBuffer; + var source_buffer = source_view.buffer as GtkSource.Buffer; if (source_buffer != null) { source_buffer.begin_not_undoable_action (); source_buffer.text = buffer.text; @@ -593,7 +593,7 @@ namespace Scratch.Services { save_cancellable.cancel (); save_cancellable = new GLib.Cancellable (); - var source_file_saver = new Gtk.SourceFileSaver ((Gtk.SourceBuffer) source_view.buffer, source_file); + var source_file_saver = new GtkSource.FileSaver ((GtkSource.Buffer) source_view.buffer, source_file); var success = false; var error = ""; try { @@ -802,7 +802,7 @@ namespace Scratch.Services { // Get language name public string get_language_name () { - var source_buffer = (Gtk.SourceBuffer) source_view.buffer; + var source_buffer = (GtkSource.Buffer) source_view.buffer; var lang = source_buffer.language; if (lang != null) { return lang.name; @@ -813,7 +813,7 @@ namespace Scratch.Services { // Get language id public string get_language_id () { - var source_buffer = (Gtk.SourceBuffer) source_view.buffer; + var source_buffer = (GtkSource.Buffer) source_view.buffer; var lang = source_buffer.language; if (lang != null) { return lang.id; @@ -898,8 +898,8 @@ namespace Scratch.Services { // If user selects to continue regardless then no further // check made for this document // External changes will be overwritten on next (auto) save - var new_buffer = new Gtk.SourceBuffer (null); - var source_file_loader = new Gtk.SourceFileLoader ( + var new_buffer = new GtkSource.Buffer (null); + var source_file_loader = new GtkSource.FileLoader ( new_buffer, source_file ); @@ -1073,7 +1073,7 @@ namespace Scratch.Services { } // Set Undo/Redo action sensitive property public void check_undoable_actions () { - var source_buffer = (Gtk.SourceBuffer) source_view.buffer; + var source_buffer = (GtkSource.Buffer) source_view.buffer; Utils.action_from_group (MainWindow.ACTION_UNDO, actions).set_enabled (source_buffer.can_undo); Utils.action_from_group (MainWindow.ACTION_REDO, actions).set_enabled (source_buffer.can_redo); Utils.action_from_group (MainWindow.ACTION_REVERT, actions).set_enabled ( @@ -1250,7 +1250,7 @@ namespace Scratch.Services { return; } - var source_buffer = (Gtk.SourceBuffer)source_view.buffer; + var source_buffer = (GtkSource.Buffer)source_view.buffer; Gtk.TextIter iter; var cursor_pos = source_buffer.cursor_position; diff --git a/src/SymbolPane/SymbolOutline.vala b/src/SymbolPane/SymbolOutline.vala index a42a79f28..b6fc4b77c 100644 --- a/src/SymbolPane/SymbolOutline.vala +++ b/src/SymbolPane/SymbolOutline.vala @@ -237,11 +237,11 @@ public class Scratch.Services.SymbolOutline : Gtk.Box { ); // Add a class to distinguish from foldermanager sourcelist get_style_context ().add_class ("symbol-outline"); - update_style_scheme (((Gtk.SourceBuffer)(doc.source_view.buffer)).style_scheme); + update_style_scheme (((GtkSource.Buffer)(doc.source_view.buffer)).style_scheme); doc.source_view.style_changed.connect (update_style_scheme); } - protected void update_style_scheme (Gtk.SourceStyleScheme style_scheme) { + protected void update_style_scheme (GtkSource.StyleScheme style_scheme) { var text_color_data = style_scheme.get_style ("text"); // Default gtksourceview background color is white diff --git a/src/Widgets/ChooseProjectButton.vala b/src/Widgets/ChooseProjectButton.vala index 79f597435..7d39a79bc 100644 --- a/src/Widgets/ChooseProjectButton.vala +++ b/src/Widgets/ChooseProjectButton.vala @@ -16,11 +16,13 @@ * */ +// TODO: make CheckButton radio buttons + public class Code.ChooseProjectButton : Gtk.MenuButton { private const string NO_PROJECT_SELECTED = N_("No Project Selected"); private Gtk.Label label_widget; private Gtk.ListBox project_listbox; - public unowned Gtk.RadioButton? group_source { + public unowned Gtk.CheckButton? group_source { get { var first_row = project_listbox.get_row_at_index (0); if (first_row != null) { @@ -188,12 +190,12 @@ public class Code.ChooseProjectButton : Gtk.MenuButton { } } - public Gtk.RadioButton project_radio { get; construct; } + public Gtk.CheckButton project_radio { get; construct; } - public ProjectRow (string project_path, Gtk.RadioButton? group_source ) { + public ProjectRow (string project_path, Gtk.CheckButton? group_source ) { Object ( project_path: project_path, - project_radio: new Gtk.RadioButton.with_label_from_widget (group_source, Path.get_basename (project_path)) + project_radio: new Gtk.CheckButton.with_label_from_widget (group_source, Path.get_basename (project_path)) ); } diff --git a/src/Widgets/DocumentView.vala b/src/Widgets/DocumentView.vala index ed19bb651..84e82ee14 100644 --- a/src/Widgets/DocumentView.vala +++ b/src/Widgets/DocumentView.vala @@ -59,9 +59,9 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { public bool outline_visible { get; set; default = false; } public int outline_width { get; set; } - private Hdy.TabView tab_view; - private Hdy.TabBar tab_bar; - private weak Hdy.TabPage? tab_menu_target = null; + private Adw.TabView tab_view; + private Adw.TabBar tab_bar; + private weak Adw.TabPage? tab_menu_target = null; private Gtk.CssProvider style_provider; private Gtk.MenuButton tab_history_button; @@ -186,12 +186,12 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { style_scheme = Scratch.settings.get_string ("style-scheme"); } - var sssm = Gtk.SourceStyleSchemeManager.get_default (); + var sssm = GtkSource.StyleSchemeManager.get_default (); if (style_scheme in sssm.scheme_ids) { var theme = sssm.get_scheme (style_scheme); var text_color_data = theme.get_style ("text"); - // Default gtksourceview background color is white + // Default GtkSource.view background color is white var color = "#FFFFFF"; if (text_color_data != null) { // If the current style has a background color, use that @@ -423,7 +423,7 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { } // This is called when tab context menu is opened or closed - private void tab_view_setup_menu (Hdy.TabPage? page) { + private void tab_view_setup_menu (Adw.TabPage? page) { tab_menu_target = page; var close_other_tabs_action = Utils.action_from_group (MainWindow.ACTION_CLOSE_OTHER_TABS, window.actions); @@ -467,7 +467,7 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { on_doc_removed_shared (doc); } - private void on_doc_removed (Hdy.TabPage tab, int position) { + private void on_doc_removed (Adw.TabPage tab, int position) { var doc = tab.get_child () as Services.Document; if (doc == null) { return; @@ -545,7 +545,7 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { } } - private void on_doc_reordered (Hdy.TabPage tab, int new_position) { + private void on_doc_reordered (Adw.TabPage tab, int new_position) { var doc = tab.child as Services.Document; if (doc != null) { docs.remove (doc); @@ -556,12 +556,12 @@ public class Scratch.Widgets.DocumentView : Gtk.Box { save_opened_files (); } - private unowned Hdy.TabView? on_doc_to_new_window (Hdy.TabView tab_view) { + private unowned Adw.TabView? on_doc_to_new_window (Adw.TabView tab_view) { var other_window = new MainWindow (false); return other_window.document_view.tab_view; } - private void on_doc_added (Hdy.TabPage page, int position) { + private void on_doc_added (Adw.TabPage page, int position) { var doc = page.get_child () as Services.Document; doc.init_tab (page); diff --git a/src/Widgets/FormatBar.vala b/src/Widgets/FormatBar.vala index 53d4673ee..8f6f8228c 100644 --- a/src/Widgets/FormatBar.vala +++ b/src/Widgets/FormatBar.vala @@ -17,6 +17,8 @@ * Authored by: Corentin Noël */ +// TODO: make CheckButton radio buttons + public class Code.FormatBar : Gtk.Box { public bool tab_style_set_by_editor_config { get; set; default = false; } public bool tab_width_set_by_editor_config { get; set; default = false; } @@ -31,7 +33,7 @@ public class Code.FormatBar : Gtk.Box { private Gtk.Entry goto_entry; private Gtk.ListBox lang_selection_listbox; private Gtk.SearchEntry lang_selection_filter; - private Gtk.SourceLanguageManager manager; + private GtkSource.LanguageManager manager; private LangEntry normal_entry; private unowned Scratch.Services.Document? doc = null; @@ -39,7 +41,7 @@ public class Code.FormatBar : Gtk.Box { construct { get_style_context ().add_class (Gtk.STYLE_CLASS_LINKED); - manager = Gtk.SourceLanguageManager.get_default (); + manager = GtkSource.LanguageManager.get_default (); tab_menubutton = new FormatButton () { icon = new ThemedIcon ("format-indent-more-symbolic") @@ -100,9 +102,9 @@ public class Code.FormatBar : Gtk.Box { lang_scrolled.add (lang_selection_listbox); unowned string[]? ids = manager.get_language_ids (); - unowned SList group = null; + unowned SList group = null; foreach (unowned string id in ids) { - weak Gtk.SourceLanguage lang = manager.get_language (id); + weak GtkSource.Language lang = manager.get_language (id); var entry = new LangEntry (id, lang.name, group); group = entry.get_radio_group (); lang_selection_listbox.add (entry); @@ -351,7 +353,7 @@ public class Code.FormatBar : Gtk.Box { public class LangEntry : Gtk.ListBoxRow { public string? lang_id { get; construct; } public string lang_name { get; construct; } - public unowned SList group { get; construct; } + public unowned SList group { get; construct; } public bool active { get { @@ -375,8 +377,8 @@ public class Code.FormatBar : Gtk.Box { } } - private Gtk.RadioButton lang_radio; - public LangEntry (string? lang_id, string lang_name, SList group) { + private Gtk.CheckButton lang_radio; + public LangEntry (string? lang_id, string lang_name, SList group) { Object (group: group, lang_id: lang_id, lang_name: lang_name); } @@ -385,7 +387,7 @@ public class Code.FormatBar : Gtk.Box { } construct { - lang_radio = new Gtk.RadioButton.with_label (group, lang_name); + lang_radio = new Gtk.CheckButton.with_label (group, lang_name); add (lang_radio); lang_radio.toggled.connect (radio_toggled); @@ -397,7 +399,7 @@ public class Code.FormatBar : Gtk.Box { } } - public unowned SList get_radio_group () { + public unowned SList get_radio_group () { return lang_radio.get_group (); } } diff --git a/src/Widgets/HeaderBar.vala b/src/Widgets/HeaderBar.vala index 791361442..4f52a0e96 100644 --- a/src/Widgets/HeaderBar.vala +++ b/src/Widgets/HeaderBar.vala @@ -4,7 +4,9 @@ * 2013 Mario Guerriero */ -public class Scratch.HeaderBar : Hdy.HeaderBar { +// TODO: make CheckButton radio buttons + +public class Scratch.HeaderBar : Adw.HeaderBar { // Plugins segfault without full access public Code.FormatBar format_bar; public GLib.Menu share_menu; @@ -147,19 +149,19 @@ public class Scratch.HeaderBar : Hdy.HeaderBar { }; // Intentionally never attached so we can have a non-selected state - var color_button_none = new Gtk.RadioButton (null); + var color_button_none = new Gtk.CheckButton (null); - var color_button_white = new Gtk.RadioButton.from_widget (color_button_none) { + var color_button_white = new Gtk.CheckButton.from_widget (color_button_none) { halign = Gtk.Align.CENTER }; style_color_button (color_button_white, STYLE_SCHEME_HIGH_CONTRAST); - var color_button_light = new Gtk.RadioButton.from_widget (color_button_none) { + var color_button_light = new Gtk.CheckButton.from_widget (color_button_none) { halign = Gtk.Align.CENTER }; style_color_button (color_button_light, STYLE_SCHEME_LIGHT); - var color_button_dark = new Gtk.RadioButton.from_widget (color_button_none) { + var color_button_dark = new Gtk.CheckButton.from_widget (color_button_none) { halign = Gtk.Align.CENTER }; style_color_button (color_button_dark, STYLE_SCHEME_DARK); @@ -324,7 +326,7 @@ public class Scratch.HeaderBar : Hdy.HeaderBar { string background = "#FFF"; string foreground = "#333"; - var sssm = Gtk.SourceStyleSchemeManager.get_default (); + var sssm = GtkSourceStyleSchemeManager.get_default (); if (style_id in sssm.scheme_ids) { var scheme = sssm.get_scheme (style_id); color_button.tooltip_text = scheme.name; diff --git a/src/Widgets/SearchBar.vala b/src/Widgets/SearchBar.vala index 5f43f0015..645ed1999 100644 --- a/src/Widgets/SearchBar.vala +++ b/src/Widgets/SearchBar.vala @@ -50,7 +50,7 @@ namespace Scratch.Widgets { private Scratch.Widgets.SourceView? text_view = null; private Gtk.TextBuffer? text_buffer = null; - public Gtk.SourceSearchContext? search_context { get; private set; default = null; } + public GtkSource.SearchContext? search_context { get; private set; default = null; } public signal void search_empty (); @@ -240,7 +240,7 @@ namespace Scratch.Widgets { this.text_view.selection_changed.connect (on_selection_changed); this.text_buffer = text_view.get_buffer (); this.text_buffer.changed.connect (on_text_buffer_changed); - this.search_context = new Gtk.SourceSearchContext (text_buffer as Gtk.SourceBuffer, null); + this.search_context = new GtkSource.SearchContext (text_buffer as GtkSource.Buffer, null); search_context.settings.wrap_around = cycle_search_button.active; search_context.settings.regex_enabled = regex_search_button.active; search_context.settings.search_text = search_entry.text; diff --git a/src/Widgets/Sidebar.vala b/src/Widgets/Sidebar.vala index 209548d2c..dc67ccc92 100644 --- a/src/Widgets/Sidebar.vala +++ b/src/Widgets/Sidebar.vala @@ -24,7 +24,7 @@ public class Code.Sidebar : Gtk.Grid { public Gtk.Stack stack { get; private set; } public Code.ChooseProjectButton choose_project_button { get; private set; } - public Hdy.HeaderBar headerbar { get; private set; } + public Adw.HeaderBar headerbar { get; private set; } public GLib.MenuModel project_menu_model { get; construct; } private Gtk.StackSwitcher stack_switcher; diff --git a/src/Widgets/SourceGutterRenderer.vala b/src/Widgets/SourceGutterRenderer.vala index 19b6683c0..958e14e13 100644 --- a/src/Widgets/SourceGutterRenderer.vala +++ b/src/Widgets/SourceGutterRenderer.vala @@ -1,4 +1,4 @@ -public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { +public class Scratch.Widgets.SourceGutterRenderer : GtkSource.GutterRenderer { // These style_ids must be present in the "classic" SourceStyleScheme (or allowed Code SourceStyleSchemes) to avoid terminal spam) public const string ADDED_STYLE_ID = "diff:added-line"; public const string REMOVED_STYLE_ID = "diff:removed-line"; @@ -6,14 +6,14 @@ public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { public const string REPLACES_DELETED_STYLE_ID = "diff:special-case"; public const string NONE_STYLE_ID = "background-pattern"; - private static Gtk.SourceStyleScheme? fallback_scheme; + private static GtkSource.StyleScheme? fallback_scheme; public Gee.HashMap line_status_map; public Gee.HashMap status_color_map; public FolderManager.ProjectFolderItem? project { get; set; default = null; } static construct { - fallback_scheme = Gtk.SourceStyleSchemeManager.get_default ().get_scheme ("classic"); // We can assume this always exists + fallback_scheme = GtkSource.StyleSchemeManager.get_default ().get_scheme ("classic"); // We can assume this always exists } construct { @@ -24,7 +24,7 @@ public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { set_visible (true); } - public void set_style_scheme (Gtk.SourceStyleScheme? scheme) { + public void set_style_scheme (GtkSource.StyleScheme? scheme) { update_status_color_map (Services.VCStatus.ADDED, scheme, ADDED_STYLE_ID); update_status_color_map (Services.VCStatus.REMOVED, scheme, REMOVED_STYLE_ID); update_status_color_map (Services.VCStatus.CHANGED, scheme, CHANGED_STYLE_ID); @@ -33,11 +33,11 @@ public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { } private void update_status_color_map (Services.VCStatus status, - Gtk.SourceStyleScheme? scheme, + GtkSource.StyleScheme? scheme, string style_id, bool use_foreground = true) { - Gtk.SourceStyle style = null; + GtkSource.Style style = null; if (scheme != null) { style = scheme.get_style (style_id); if (style != null) { @@ -60,8 +60,7 @@ public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { Gdk.Rectangle bg, Gdk.Rectangle area, Gtk.TextIter start, - Gtk.TextIter end, - Gtk.SourceGutterRendererState state) { + Gtk.TextIter end) { //Gutter and diff lines numbers start at one, source lines start at 0 var gutter_line_no = start.get_line () + 1; @@ -71,6 +70,6 @@ public class Scratch.Widgets.SourceGutterRenderer : Gtk.SourceGutterRenderer { set_background (status_color_map [Services.VCStatus.NONE]); } - base.draw (cr, bg, area, start, end, state); + base.draw (cr, bg, area, start, end); } } diff --git a/src/Widgets/SourceList/SourceList.vala b/src/Widgets/SourceList/SourceList.vala index 0ecff6dae..0f1f17d53 100644 --- a/src/Widgets/SourceList/SourceList.vala +++ b/src/Widgets/SourceList/SourceList.vala @@ -425,7 +425,7 @@ public class SourceList : Gtk.ScrolledWindow { * @return A {@link Gtk.Menu} or //null// if nothing should be displayed. * @since 0.2 */ - public virtual Gtk.Menu? get_context_menu () { + public virtual GLib.Menu? get_context_menu () { return null; } } diff --git a/src/Widgets/SourceView.vala b/src/Widgets/SourceView.vala index 2759b98bf..cdb03c44f 100644 --- a/src/Widgets/SourceView.vala +++ b/src/Widgets/SourceView.vala @@ -20,9 +20,9 @@ */ namespace Scratch.Widgets { - public class SourceView : Gtk.SourceView { - public Gtk.SourceLanguageManager manager; - public Gtk.SourceStyleSchemeManager style_scheme_manager; + public class SourceView : GtkSource.View { + public GtkSource.LanguageManager manager; + public GtkSource.StyleSchemeManager style_scheme_manager; public Gtk.CssProvider font_css_provider; public Gtk.TextTag warning_tag; public Gtk.TextTag error_tag; @@ -42,18 +42,18 @@ namespace Scratch.Widgets { private double total_delta = 0; private const double SCROLL_THRESHOLD = 1.0; - public signal void style_changed (Gtk.SourceStyleScheme style); + public signal void style_changed (GtkSource.StyleScheme style); // "selection_changed" signal now only emitted when the selected text changes (position ignored). Listened to by searchbar and highlight word selection plugin public signal void selection_changed (Gtk.TextIter start_iter, Gtk.TextIter end_iter); public signal void deselected (); //lang can be null, in the case of *No highlight style* aka Normal text - public Gtk.SourceLanguage? language { + public GtkSource.Language? language { set { - ((Gtk.SourceBuffer) buffer).language = value; + ((GtkSource.Buffer) buffer).language = value; } get { - return ((Gtk.SourceBuffer) buffer).language; + return ((GtkSource.Buffer) buffer).language; } } @@ -77,7 +77,7 @@ namespace Scratch.Widgets { Object ( show_line_numbers: true, smart_backspace: true, - smart_home_end: Gtk.SourceSmartHomeEndType.BEFORE, + smart_home_end: GtkSource.SmartHomeEndType.BEFORE, wrap_mode: Gtk.WrapMode.WORD ); } @@ -90,23 +90,23 @@ namespace Scratch.Widgets { space_drawer.enable_matrix = true; expand = true; - manager = Gtk.SourceLanguageManager.get_default (); - style_scheme_manager = new Gtk.SourceStyleSchemeManager (); + manager = GtkSource.LanguageManager.get_default (); + style_scheme_manager = new GtkSource.StyleSchemeManager (); font_css_provider = new Gtk.CssProvider (); get_style_context ().add_provider (font_css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION); - var source_buffer = new Gtk.SourceBuffer (null); + var source_buffer = new GtkSource.Buffer (null); set_buffer (source_buffer); source_buffer.highlight_syntax = true; source_buffer.mark_set.connect (on_mark_set); highlight_current_line = true; - var draw_spaces_tag = new Gtk.SourceTag ("draw_spaces"); + var draw_spaces_tag = new GtkSource.Tag ("draw_spaces"); draw_spaces_tag.draw_spaces = true; source_buffer.tag_table.add (draw_spaces_tag); - smart_home_end = Gtk.SourceSmartHomeEndType.AFTER; + smart_home_end = GtkSource.SmartHomeEndType.AFTER; // Create common tags warning_tag = new Gtk.TextTag ("warning_bg"); @@ -155,7 +155,7 @@ namespace Scratch.Widgets { Gtk.TextIter iter_start, iter_end; if (get_current_line (out iter_start, out iter_end)) { - var clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); + var clipboard = Gdk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); string cut_text = iter_start.get_slice (iter_end); buffer.begin_user_action (); @@ -176,7 +176,7 @@ namespace Scratch.Widgets { Gtk.TextIter iter_start, iter_end; if (get_current_line (out iter_start, out iter_end)) { - var clipboard = Gtk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); + var clipboard = Gdk.Clipboard.get_for_display (get_display (), Gdk.SELECTION_CLIPBOARD); string copy_text = iter_start.get_slice (iter_end); clipboard.set_text (copy_text, -1); @@ -242,31 +242,31 @@ namespace Scratch.Widgets { show_right_margin = Scratch.settings.get_boolean ("show-right-margin"); right_margin_position = Scratch.settings.get_int ("right-margin-position"); insert_spaces_instead_of_tabs = Scratch.settings.get_boolean ("spaces-instead-of-tabs"); - var source_buffer = (Gtk.SourceBuffer) buffer; + var source_buffer = (GtkSource.Buffer) buffer; source_buffer.highlight_matching_brackets = Scratch.settings.get_boolean ("highlight-matching-brackets"); space_drawer.enable_matrix = false; switch ((ScratchDrawSpacesState) Scratch.settings.get_enum ("draw-spaces")) { case ScratchDrawSpacesState.ALWAYS: space_drawer.set_types_for_locations ( - Gtk.SourceSpaceLocationFlags.ALL, - Gtk.SourceSpaceTypeFlags.SPACE | Gtk.SourceSpaceTypeFlags.TAB + GtkSource.SpaceLocationFlags.ALL, + GtkSource.SpaceTypeFlags.SPACE | GtkSource.SpaceTypeFlags.TAB ); break; case ScratchDrawSpacesState.FOR_SELECTION: case ScratchDrawSpacesState.CURRENT: space_drawer.set_types_for_locations ( - Gtk.SourceSpaceLocationFlags.ALL, - Gtk.SourceSpaceTypeFlags.NONE + GtkSource.SpaceLocationFlags.ALL, + GtkSource.SpaceTypeFlags.NONE ); space_drawer.set_types_for_locations ( - Gtk.SourceSpaceLocationFlags.TRAILING, - Gtk.SourceSpaceTypeFlags.SPACE | Gtk.SourceSpaceTypeFlags.TAB + GtkSource.SpaceLocationFlags.TRAILING, + GtkSource.SpaceTypeFlags.SPACE | GtkSource.SpaceTypeFlags.TAB ); break; default: space_drawer.set_types_for_locations ( - Gtk.SourceSpaceLocationFlags.ALL, - Gtk.SourceSpaceTypeFlags.NONE + GtkSource.SpaceLocationFlags.ALL, + GtkSource.SpaceTypeFlags.NONE ); break; } @@ -507,7 +507,7 @@ namespace Scratch.Widgets { } public void set_text (string text, bool opening = true) { - var source_buffer = (Gtk.SourceBuffer) buffer; + var source_buffer = (GtkSource.Buffer) buffer; if (opening) { source_buffer.begin_not_undoable_action (); } @@ -551,7 +551,7 @@ namespace Scratch.Widgets { } } - private void on_context_menu (Gtk.Menu menu) { + private void on_context_menu (GLib.Menu menu) { var sort_item = new Gtk.MenuItem (); sort_item.sensitive = get_selected_line_count () > 1; sort_item.add (new Granite.AccelLabel.from_action_name ( @@ -562,8 +562,8 @@ namespace Scratch.Widgets { menu.add (sort_item); - if (buffer is Gtk.SourceBuffer) { - var can_comment = CommentToggler.language_has_comments (((Gtk.SourceBuffer) buffer).get_language ()); + if (buffer is GtkSource.Buffer) { + var can_comment = CommentToggler.language_has_comments (((GtkSource.Buffer) buffer).get_language ()); var comment_item = new Gtk.MenuItem (); comment_item.sensitive = can_comment; @@ -572,7 +572,7 @@ namespace Scratch.Widgets { MainWindow.ACTION_PREFIX + MainWindow.ACTION_TOGGLE_COMMENT )); comment_item.activate.connect (() => { - CommentToggler.toggle_comment ((Gtk.SourceBuffer) buffer); + CommentToggler.toggle_comment ((GtkSource.Buffer) buffer); }); menu.add (comment_item); diff --git a/src/Widgets/Terminal.vala b/src/Widgets/Terminal.vala index 2219769a5..156c4b996 100644 --- a/src/Widgets/Terminal.vala +++ b/src/Widgets/Terminal.vala @@ -19,7 +19,7 @@ public class Code.Terminal : Gtk.Box { public SimpleActionGroup actions { get; construct; } private GLib.Pid child_pid; - private Gtk.Clipboard current_clipboard; + private Gdk.Clipboard current_clipboard; construct { terminal = new Vte.Terminal () { diff --git a/src/Widgets/WelcomeView.vala b/src/Widgets/WelcomeView.vala index 23ffaeef9..e91bf7356 100644 --- a/src/Widgets/WelcomeView.vala +++ b/src/Widgets/WelcomeView.vala @@ -17,7 +17,7 @@ * Authored by: Corentin Noël */ -public class Code.WelcomeView : Granite.Widgets.Welcome { +public class Code.WelcomeView : Granite.Placeholder { public unowned Scratch.MainWindow window { get; construct; } public WelcomeView (Scratch.MainWindow window) { diff --git a/src/codecore.deps b/src/codecore.deps index dcfdbb461..a33d680b3 100644 --- a/src/codecore.deps +++ b/src/codecore.deps @@ -1,8 +1,7 @@ codecore -gtksourceview-4 +gtksourceview-5 gee-0.8 gobject-2.0 gio-2.0 -gtk+-3.0 -granite -libpeas-1.0 +gtk4 +granite-7