[gnome-builder/wip/gtk4-port] libide/gui: port IdeApplication over
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/gtk4-port] libide/gui: port IdeApplication over
- Date: Sun, 27 Mar 2022 08:09:11 +0000 (UTC)
commit 6455aafdf37b103d7baed1b1bf1293b2f48e85e3
Author: Christian Hergert <chergert redhat com>
Date: Sun Mar 27 01:09:03 2022 -0700
libide/gui: port IdeApplication over
We alsy remove the custom shortcuts window now that we cannot subclass it.
We can just rely on the internal GTK actions to display that later on
until we have a way to dynamically generate them from keybindings.
.../{ide-shortcuts-window.ui => help-overlay.ui} | 6 +-
src/libide/gui/ide-application-actions.c | 51 ++------------
src/libide/gui/ide-application-color.c | 19 +++---
src/libide/gui/ide-application-plugins.c | 16 +----
src/libide/gui/ide-application-private.h | 1 -
src/libide/gui/ide-application-shortcuts.c | 79 ----------------------
src/libide/gui/ide-application.c | 4 --
src/libide/gui/ide-shortcuts-window-private.h | 31 ---------
src/libide/gui/ide-shortcuts-window.c | 48 -------------
src/libide/gui/libide-gui.gresource.xml | 4 +-
src/libide/gui/meson.build | 3 -
11 files changed, 21 insertions(+), 241 deletions(-)
---
diff --git a/src/libide/gui/ide-shortcuts-window.ui b/src/libide/gui/help-overlay.ui
similarity index 99%
rename from src/libide/gui/ide-shortcuts-window.ui
rename to src/libide/gui/help-overlay.ui
index 4d0b02ec3..a00110fd2 100644
--- a/src/libide/gui/ide-shortcuts-window.ui
+++ b/src/libide/gui/help-overlay.ui
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface>
- <!-- interface-requires gtk+ 3.19 -->
- <template class="IdeShortcutsWindow">
+ <requires lib="gtk" version="4.0"/>
+ <object class="GtkShortcutsWindow" id="help_overlay">
<property name="modal">true</property>
<child>
<object class="GtkShortcutsSection">
@@ -677,7 +677,7 @@
</child>
</object>
</child>
- </template>
+ </object>
<object class="GThemedIcon" id="swipe_right">
<property name="name">gesture-three-finger-swipe-right-symbolic</property>
</object>
diff --git a/src/libide/gui/ide-application-actions.c b/src/libide/gui/ide-application-actions.c
index bc7ba5945..4d69b5025 100644
--- a/src/libide/gui/ide-application-actions.c
+++ b/src/libide/gui/ide-application-actions.c
@@ -24,7 +24,7 @@
#include "config.h"
#include <glib/gi18n.h>
-#include <handy.h>
+
#include <ide-build-ident.h>
#include <libide-projects.h>
@@ -33,7 +33,6 @@
#include "ide-application-private.h"
#include "ide-gui-global.h"
#include "ide-preferences-window.h"
-#include "ide-shortcuts-window-private.h"
static void
ide_application_actions_preferences (GSimpleAction *action,
@@ -77,7 +76,6 @@ ide_application_actions_preferences (GSimpleAction *action,
"default-width", 1300,
"default-height", 800,
"title", _("Builder — Preferences"),
- "window-position", GTK_WIN_POS_CENTER_ON_PARENT,
NULL);
gtk_application_add_window (GTK_APPLICATION (self), window);
ide_gtk_window_present (window);
@@ -157,7 +155,7 @@ ide_application_actions_about (GSimpleAction *action,
_("Funded By"),
ide_application_credits_funders);
- g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL);
+ g_signal_connect (dialog, "response", G_CALLBACK (gtk_window_destroy), NULL);
ide_gtk_window_present (GTK_WINDOW (dialog));
}
@@ -253,46 +251,6 @@ ide_application_actions_help (GSimpleAction *action,
IDE_EXIT;
}
-static void
-ide_application_actions_shortcuts (GSimpleAction *action,
- GVariant *variant,
- gpointer user_data)
-{
- IdeApplication *self = user_data;
- GtkWindow *window;
- GtkWindow *parent = NULL;
- GList *list;
-
- g_assert (IDE_IS_APPLICATION (self));
-
- list = gtk_application_get_windows (GTK_APPLICATION (self));
-
- for (; list; list = list->next)
- {
- window = list->data;
-
- if (IDE_IS_SHORTCUTS_WINDOW (window))
- {
- ide_gtk_window_present (window);
- return;
- }
-
- if (IDE_IS_WORKBENCH (window))
- {
- parent = window;
- break;
- }
- }
-
- window = g_object_new (IDE_TYPE_SHORTCUTS_WINDOW,
- "application", self,
- "window-position", GTK_WIN_POS_CENTER,
- "transient-for", parent,
- NULL);
-
- ide_gtk_window_present (GTK_WINDOW (window));
-}
-
static void
ide_application_actions_nighthack (GSimpleAction *action,
GVariant *variant,
@@ -375,13 +333,13 @@ ide_application_actions_stats (GSimpleAction *action,
scroller = g_object_new (GTK_TYPE_SCROLLED_WINDOW,
"visible", TRUE,
NULL);
- gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (scroller));
+ gtk_window_set_child (window, GTK_WIDGET (scroller));
text_view = g_object_new (GTK_TYPE_TEXT_VIEW,
"editable", FALSE,
"monospace", TRUE,
"visible", TRUE,
NULL);
- gtk_container_add (GTK_CONTAINER (scroller), GTK_WIDGET (text_view));
+ gtk_scrolled_window_set_child(scroller, GTK_WIDGET (text_view));
buffer = gtk_text_view_get_buffer (text_view);
gtk_text_buffer_insert_at_cursor (buffer, "Count | Type\n", -1);
@@ -421,7 +379,6 @@ static const GActionEntry IdeApplicationActions[] = {
{ "load-project", ide_application_actions_load_project, "s"},
{ "preferences", ide_application_actions_preferences },
{ "quit", ide_application_actions_quit },
- { "shortcuts", ide_application_actions_shortcuts },
{ "help", ide_application_actions_help },
};
diff --git a/src/libide/gui/ide-application-color.c b/src/libide/gui/ide-application-color.c
index ff5e8c1d5..e631e8ab3 100644
--- a/src/libide/gui/ide-application-color.c
+++ b/src/libide/gui/ide-application-color.c
@@ -23,7 +23,6 @@
#include "config.h"
#include <gtksourceview/gtksource.h>
-#include <handy.h>
#include "ide-application.h"
#include "ide-application-private.h"
@@ -93,7 +92,7 @@ static void
_ide_application_update_color (IdeApplication *self)
{
static gboolean ignore_reentrant = FALSE;
- HdyStyleManager *manager;
+ AdwStyleManager *manager;
g_autofree char *style_variant = NULL;
g_assert (IDE_IS_APPLICATION (self));
@@ -109,14 +108,14 @@ _ide_application_update_color (IdeApplication *self)
g_assert (G_IS_SETTINGS (self->settings));
style_variant = g_settings_get_string (self->settings, "style-variant");
- manager = hdy_style_manager_get_default ();
+ manager = adw_style_manager_get_default ();
if (!g_strcmp0 (style_variant, "follow"))
- hdy_style_manager_set_color_scheme (manager, HDY_COLOR_SCHEME_PREFER_LIGHT);
+ adw_style_manager_set_color_scheme (manager, ADW_COLOR_SCHEME_PREFER_LIGHT);
else if (!g_strcmp0 (style_variant, "dark"))
- hdy_style_manager_set_color_scheme (manager, HDY_COLOR_SCHEME_FORCE_DARK);
+ adw_style_manager_set_color_scheme (manager, ADW_COLOR_SCHEME_FORCE_DARK);
else
- hdy_style_manager_set_color_scheme (manager, HDY_COLOR_SCHEME_FORCE_LIGHT);
+ adw_style_manager_set_color_scheme (manager, ADW_COLOR_SCHEME_FORCE_LIGHT);
ignore_reentrant = FALSE;
}
@@ -124,12 +123,12 @@ _ide_application_update_color (IdeApplication *self)
static void
_ide_application_update_style_scheme (IdeApplication *self)
{
- HdyStyleManager *manager;
+ AdwStyleManager *manager;
g_autoptr(GSettings) editor_settings = NULL;
g_autofree gchar *old_name = NULL;
g_autofree gchar *new_name = NULL;
- manager = hdy_style_manager_get_default ();
+ manager = adw_style_manager_get_default ();
/*
* Now that we have our color up to date, we need to possibly update the
@@ -143,7 +142,7 @@ _ide_application_update_style_scheme (IdeApplication *self)
editor_settings = g_settings_new ("org.gnome.builder.editor");
old_name = g_settings_get_string (editor_settings, "style-scheme-name");
- new_name = find_similar_style_scheme (old_name, hdy_style_manager_get_dark (manager));
+ new_name = find_similar_style_scheme (old_name, adw_style_manager_get_dark (manager));
if (new_name != NULL)
g_settings_set_string (editor_settings, "style-scheme-name", new_name);
@@ -162,7 +161,7 @@ _ide_application_init_color (IdeApplication *self)
G_CALLBACK (_ide_application_update_color),
self,
G_CONNECT_SWAPPED);
- g_signal_connect_object (hdy_style_manager_get_default (),
+ g_signal_connect_object (adw_style_manager_get_default (),
"notify::dark",
G_CALLBACK (_ide_application_update_style_scheme),
self,
diff --git a/src/libide/gui/ide-application-plugins.c b/src/libide/gui/ide-application-plugins.c
index ff27b1aa7..e225b805e 100644
--- a/src/libide/gui/ide-application-plugins.c
+++ b/src/libide/gui/ide-application-plugins.c
@@ -106,10 +106,6 @@ ide_application_can_load_plugin (IdeApplication *self,
module_dir = peas_plugin_info_get_module_dir (plugin_info);
module_name = peas_plugin_info_get_module_name (plugin_info);
- /* Short-circuit for single-plugin mode */
- if (self->plugin != NULL)
- return ide_str_equal0 (module_name, self->plugin);
-
if (g_hash_table_contains (circular, module_name))
{
g_warning ("Circular dependency found in module %s", module_name);
@@ -123,14 +119,6 @@ ide_application_can_load_plugin (IdeApplication *self,
if (!g_settings_get_boolean (settings, "enabled"))
return FALSE;
-#if 0
- if (self->mode == IDE_APPLICATION_MODE_WORKER)
- {
- if (self->worker != plugin_info)
- return FALSE;
- }
-#endif
-
/*
* If the plugin is not bundled within the Builder executable, then we
* require that an X-Builder-ABI=major.minor style extended data be
@@ -216,7 +204,7 @@ ide_application_load_plugin_resources (IdeApplication *self,
g_resources_register (resource);
resource_path = g_strdup_printf ("resource:///plugins/%s", module_name);
- dzl_application_add_resources (DZL_APPLICATION (self), resource_path);
+ _ide_application_add_resources (self, resource_path);
}
}
@@ -273,7 +261,7 @@ ide_application_plugins_load_plugin_cb (IdeApplication *self,
*/
if (g_str_has_prefix (data_dir, "resource://") ||
!peas_plugin_info_is_builtin (plugin_info))
- dzl_application_add_resources (DZL_APPLICATION (self), data_dir);
+ _ide_application_add_resources (self, data_dir);
}
static void
diff --git a/src/libide/gui/ide-application-private.h b/src/libide/gui/ide-application-private.h
index 65efe9d2c..2f4be0108 100644
--- a/src/libide/gui/ide-application-private.h
+++ b/src/libide/gui/ide-application-private.h
@@ -95,7 +95,6 @@ struct _IdeApplication
IdeApplication *_ide_application_new (gboolean standalone);
void _ide_application_init_color (IdeApplication *self);
void _ide_application_init_actions (IdeApplication *self);
-void _ide_application_init_shortcuts (IdeApplication *self);
void _ide_application_load_addins (IdeApplication *self);
void _ide_application_unload_addins (IdeApplication *self);
void _ide_application_load_plugin (IdeApplication *self,
diff --git a/src/libide/gui/ide-application.c b/src/libide/gui/ide-application.c
index f0337c5b5..2301c2ca7 100644
--- a/src/libide/gui/ide-application.c
+++ b/src/libide/gui/ide-application.c
@@ -27,7 +27,6 @@
#endif
#include <glib/gi18n.h>
-#include <handy.h>
#include <libpeas/peas-autocleanups.h>
#include <libide-themes.h>
@@ -154,9 +153,6 @@ ide_application_startup (GApplication *app)
/* And now we can load the rest of our plugins for startup. */
_ide_application_load_plugins (self);
- /* Make sure our shorcuts are registered */
- _ide_application_init_shortcuts (self);
-
/* Load keybindings from plugins and what not */
ide_application_register_keybindings (self);
diff --git a/src/libide/gui/libide-gui.gresource.xml b/src/libide/gui/libide-gui.gresource.xml
index 27586bcab..a5e4b1246 100644
--- a/src/libide/gui/libide-gui.gresource.xml
+++ b/src/libide/gui/libide-gui.gresource.xml
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
+ <gresource prefix="/org/gnome/builder/ui">
+ <file preprocess="xml-stripblanks">help-overlay.ui</file>
+ </gresource>
<gresource prefix="/org/gnome/libide-gui">
<file preprocess="xml-stripblanks">gtk/menus.ui</file>
</gresource>
@@ -14,7 +17,6 @@
<file preprocess="xml-stripblanks">ide-preferences-window.ui</file>
<file preprocess="xml-stripblanks">ide-primary-workspace.ui</file>
<file preprocess="xml-stripblanks">ide-run-button.ui</file>
- <file preprocess="xml-stripblanks">ide-shortcuts-window.ui</file>
<file preprocess="xml-stripblanks">ide-workspace.ui</file>
</gresource>
</gresources>
diff --git a/src/libide/gui/meson.build b/src/libide/gui/meson.build
index 0568755d2..eafcfc4a9 100644
--- a/src/libide/gui/meson.build
+++ b/src/libide/gui/meson.build
@@ -65,13 +65,11 @@ libide_gui_private_headers = [
'ide-session-private.h',
'ide-window-settings-private.h',
'ide-shortcut-label-private.h',
- 'ide-shortcuts-window-private.h',
]
libide_gui_private_sources = [
'ide-application-actions.c',
'ide-application-color.c',
- 'ide-application-shortcuts.c',
'ide-application-plugins.c',
'ide-environment-editor-row.c',
'ide-header-bar-shortcuts.c',
@@ -84,7 +82,6 @@ libide_gui_private_sources = [
'ide-primary-workspace-actions.c',
'ide-run-button.c',
'ide-session.c',
- 'ide-shortcuts-window.c',
'ide-window-settings.c',
'ide-workspace-actions.c',
]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]