[epiphany/wip/exalm/gtk4: 2/2] Port a few files to gtk4
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/gtk4: 2/2] Port a few files to gtk4
- Date: Mon, 29 Nov 2021 11:58:51 +0000 (UTC)
commit 1bf10862f2944ed2e9bfba556d267a23ae024349
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Nov 29 12:52:32 2021 +0500
Port a few files to gtk4
Left out widgets/ for now as that's a lot of work and I want to port enough
of the foundation to test it first.
Also left out:
ephy-dnd.c - gtk4 dnd api is completely different, this will need a lot of changes
ephy-gui.c - ephy_gui_get_current_event() is bad, this will need a rework everywhere
ephy-suggestion.c - no libdazzle in gtk4
FIXME:
- gdk_set_program_class()
- gtk_window_set_default_icon_from_file()
embed/ephy-embed-shell.c | 2 +-
embed/ephy-embed-shell.h | 6 ++--
embed/meson.build | 28 ++++++++--------
lib/ephy-file-helpers.c | 12 +++----
lib/ephy-file-helpers.h | 2 +-
lib/ephy-flatpak-utils.c | 2 +-
lib/ephy-notification-container.c | 45 +++++++++----------------
lib/ephy-notification-container.h | 4 +--
lib/ephy-notification.c | 36 +++++++++-----------
lib/ephy-notification.h | 4 +--
lib/ephy-web-app-utils.c | 18 +++++-----
lib/meson.build | 69 ++++++++++++++++++++-------------------
meson.build | 2 +-
13 files changed, 105 insertions(+), 125 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 189370bd8..16d179d9f 100644
--- a/embed/ephy-embed-shell.c
+++ b/embed/ephy-embed-shell.c
@@ -97,7 +97,7 @@ static EphyEmbedShell *embed_shell = NULL;
static void ephy_embed_shell_tabs_catalog_iface_init (EphyTabsCatalogInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (EphyEmbedShell, ephy_embed_shell, DZL_TYPE_APPLICATION,
+G_DEFINE_TYPE_WITH_CODE (EphyEmbedShell, ephy_embed_shell, ADW_TYPE_APPLICATION,
G_ADD_PRIVATE (EphyEmbedShell)
G_IMPLEMENT_INTERFACE (EPHY_TYPE_TABS_CATALOG,
ephy_embed_shell_tabs_catalog_iface_init))
diff --git a/embed/ephy-embed-shell.h b/embed/ephy-embed-shell.h
index 9464d42d4..2815c19bd 100644
--- a/embed/ephy-embed-shell.h
+++ b/embed/ephy-embed-shell.h
@@ -21,7 +21,7 @@
#pragma once
-#include <dazzle.h>
+#include <adwaita.h>
#include <webkit2/webkit2.h>
#include "ephy-downloads-manager.h"
@@ -38,7 +38,7 @@ typedef struct _EphyFiltersManager EphyFiltersManager;
#define EPHY_TYPE_EMBED_SHELL (ephy_embed_shell_get_type ())
-G_DECLARE_DERIVABLE_TYPE (EphyEmbedShell, ephy_embed_shell, EPHY, EMBED_SHELL, DzlApplication)
+G_DECLARE_DERIVABLE_TYPE (EphyEmbedShell, ephy_embed_shell, EPHY, EMBED_SHELL, AdwApplication)
typedef enum
{
@@ -54,7 +54,7 @@ typedef enum
struct _EphyEmbedShellClass
{
- DzlApplicationClass parent_class;
+ AdwApplicationClass parent_class;
void (* restored_window) (EphyEmbedShell *shell);
};
diff --git a/embed/meson.build b/embed/meson.build
index 8ea34fd80..dd164272b 100644
--- a/embed/meson.build
+++ b/embed/meson.build
@@ -11,25 +11,25 @@ enums = gnome.mkenums_simple('ephy-embed-type-builtins',
)
libephyembed_sources = [
- 'contrib/gd-tagged-entry.c',
- 'ephy-about-handler.c',
- 'ephy-downloads-manager.c',
- 'ephy-download.c',
- 'ephy-embed.c',
- 'ephy-embed-container.c',
- 'ephy-embed-event.c',
- 'ephy-embed-prefs.c',
- 'ephy-embed-shell.c',
+# 'contrib/gd-tagged-entry.c',
+# 'ephy-about-handler.c',
+# 'ephy-downloads-manager.c',
+# 'ephy-download.c',
+# 'ephy-embed.c',
+# 'ephy-embed-container.c',
+# 'ephy-embed-event.c',
+# 'ephy-embed-prefs.c',
+# 'ephy-embed-shell.c',
'ephy-embed-utils.c',
'ephy-encoding.c',
'ephy-encodings.c',
'ephy-file-monitor.c',
'ephy-filters-manager.c',
- 'ephy-find-toolbar.c',
- 'ephy-pdf-handler.c',
- 'ephy-reader-handler.c',
- 'ephy-view-source-handler.c',
- 'ephy-web-view.c',
+# 'ephy-find-toolbar.c',
+# 'ephy-pdf-handler.c',
+# 'ephy-reader-handler.c',
+# 'ephy-view-source-handler.c',
+# 'ephy-web-view.c',
enums
]
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 8bc2a494d..33b9d5cf8 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -548,7 +548,6 @@ launch_application (GAppInfo *app,
g_autoptr (GdkAppLaunchContext) context = NULL;
g_autoptr (GError) error = NULL;
GdkDisplay *display;
- GdkScreen *screen;
gboolean res;
/* This is impossible to implement inside flatpak. Higher layers must
@@ -557,10 +556,8 @@ launch_application (GAppInfo *app,
g_assert (!ephy_is_running_inside_flatpak ());
display = gdk_display_get_default ();
- screen = gdk_screen_get_default ();
context = gdk_display_get_app_launch_context (display);
- gdk_app_launch_context_set_screen (context, screen);
gdk_app_launch_context_set_timestamp (context, user_time);
res = g_app_info_launch (app, files,
@@ -665,7 +662,7 @@ static gboolean
open_in_default_handler (const char *uri,
const char *mime_type,
guint32 timestamp,
- GdkScreen *screen,
+ GdkDisplay *display,
EphyFileHelpersNotFlatpakTag tag)
{
g_autoptr (GdkAppLaunchContext) context = NULL;
@@ -679,8 +676,7 @@ open_in_default_handler (const char *uri,
g_assert (tag == EPHY_FILE_HELPERS_I_UNDERSTAND_I_MUST_NOT_USE_THIS_FUNCTION_UNDER_FLATPAK);
g_assert (!ephy_is_running_inside_flatpak ());
- context = gdk_display_get_app_launch_context (screen ? gdk_screen_get_display (screen) :
gdk_display_get_default ());
- gdk_app_launch_context_set_screen (context, screen);
+ context = gdk_display_get_app_launch_context (display ? display : gdk_display_get_default ());
gdk_app_launch_context_set_timestamp (context, timestamp);
appinfo = g_app_info_get_default_for_type (mime_type, TRUE);
@@ -703,10 +699,10 @@ open_in_default_handler (const char *uri,
gboolean
ephy_file_open_uri_in_default_browser (const char *uri,
guint32 user_time,
- GdkScreen *screen,
+ GdkDisplay *display,
EphyFileHelpersNotFlatpakTag tag)
{
- return open_in_default_handler (uri, "x-scheme-handler/http", user_time, screen, tag);
+ return open_in_default_handler (uri, "x-scheme-handler/http", user_time, display, tag);
}
/**
diff --git a/lib/ephy-file-helpers.h b/lib/ephy-file-helpers.h
index c09d145c8..1a9eb3b25 100644
--- a/lib/ephy-file-helpers.h
+++ b/lib/ephy-file-helpers.h
@@ -82,7 +82,7 @@ gboolean ephy_file_launch_desktop_file (const char
EphyFileHelpersNotFlatpakTag tag);
gboolean ephy_file_open_uri_in_default_browser (const char *uri,
guint32 user_time,
- GdkScreen *screen,
+ GdkDisplay *screen,
EphyFileHelpersNotFlatpakTag tag);
gboolean ephy_file_browse_to (GFile *file,
guint32 user_time);
diff --git a/lib/ephy-flatpak-utils.c b/lib/ephy-flatpak-utils.c
index 818af95f4..70dfca8e4 100644
--- a/lib/ephy-flatpak-utils.c
+++ b/lib/ephy-flatpak-utils.c
@@ -29,7 +29,7 @@
#include <gio/gio.h>
#include <gio/gunixfdlist.h>
#if USE_LIBPORTAL
-#include <libportal/portal-gtk3.h>
+#include <libportal/portal-gtk4.h>
#endif
#include <string.h>
#include <sys/stat.h>
diff --git a/lib/ephy-notification-container.c b/lib/ephy-notification-container.c
index f0f31e736..8a02322f2 100644
--- a/lib/ephy-notification-container.c
+++ b/lib/ephy-notification-container.c
@@ -23,13 +23,13 @@
#include "ephy-notification-container.h"
struct _EphyNotificationContainer {
- GtkBin parent_instance;
+ AdwBin parent_instance;
GtkWidget *revealer;
GtkWidget *box;
};
-G_DEFINE_TYPE (EphyNotificationContainer, ephy_notification_container, GTK_TYPE_BIN);
+G_DEFINE_TYPE (EphyNotificationContainer, ephy_notification_container, ADW_TYPE_BIN);
static EphyNotificationContainer *notification_container = NULL;
@@ -46,10 +46,12 @@ ephy_notification_container_init (EphyNotificationContainer *self)
gtk_widget_set_valign (GTK_WIDGET (self), GTK_ALIGN_START);
self->revealer = gtk_revealer_new ();
- gtk_container_add (GTK_CONTAINER (self), self->revealer);
+ adw_bin_set_child (ADW_BIN (self), self->revealer);
self->box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
- gtk_container_add (GTK_CONTAINER (self->revealer), self->box);
+ gtk_revealer_set_child (GTK_REVEALER (self->revealer), self->box);
+
+ gtk_widget_hide (GTK_WIDGET (self));
}
static void
@@ -67,28 +69,13 @@ ephy_notification_container_get_default (void)
NULL);
}
-static guint
-get_num_children (EphyNotificationContainer *self)
-{
- GList *children;
- guint retval;
-
- g_assert (EPHY_IS_NOTIFICATION_CONTAINER (self));
-
- children = gtk_container_get_children (GTK_CONTAINER (self->box));
- retval = g_list_length (children);
- g_list_free (children);
-
- return retval;
-}
-
static void
notification_close_cb (EphyNotification *notification,
EphyNotificationContainer *self)
{
- gtk_container_remove (GTK_CONTAINER (self->box), GTK_WIDGET (notification));
+ gtk_box_remove (GTK_BOX (self->box), GTK_WIDGET (notification));
- if (get_num_children (self) == 0) {
+ if (!gtk_widget_get_first_child (self->box)) {
gtk_widget_hide (GTK_WIDGET (self));
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), FALSE);
}
@@ -98,24 +85,24 @@ void
ephy_notification_container_add_notification (EphyNotificationContainer *self,
GtkWidget *notification)
{
- g_autoptr (GList) children = NULL;
- GList *list;
+ GtkWidget *child;
g_assert (EPHY_IS_NOTIFICATION_CONTAINER (self));
g_assert (GTK_IS_WIDGET (notification));
- children = gtk_container_get_children (GTK_CONTAINER (self->box));
- for (list = children; list && list->data; list = list->next) {
- EphyNotification *child_notification = EPHY_NOTIFICATION (children->data);
+ for (child = gtk_widget_get_first_child (self->box);
+ child;
+ child = gtk_widget_get_next_sibling (child)) {
+ EphyNotification *child_notification = EPHY_NOTIFICATION (child);
if (ephy_notification_is_duplicate (child_notification, EPHY_NOTIFICATION (notification))) {
- gtk_widget_destroy (notification);
+ gtk_box_remove (GTK_BOX (self->box), notification);
return;
}
}
- gtk_container_add (GTK_CONTAINER (self->box), notification);
- gtk_widget_show_all (GTK_WIDGET (self));
+ gtk_box_append (GTK_BOX (self->box), notification);
+ gtk_widget_show (GTK_WIDGET (self));
gtk_revealer_set_reveal_child (GTK_REVEALER (self->revealer), TRUE);
g_signal_connect (notification, "close", G_CALLBACK (notification_close_cb), self);
diff --git a/lib/ephy-notification-container.h b/lib/ephy-notification-container.h
index 4444f83b7..df5fcdb36 100644
--- a/lib/ephy-notification-container.h
+++ b/lib/ephy-notification-container.h
@@ -20,13 +20,13 @@
#pragma once
-#include <gtk/gtk.h>
+#include <adwaita.h>
G_BEGIN_DECLS
#define EPHY_TYPE_NOTIFICATION_CONTAINER (ephy_notification_container_get_type ())
-G_DECLARE_FINAL_TYPE (EphyNotificationContainer, ephy_notification_container, EPHY, NOTIFICATION_CONTAINER,
GtkBin)
+G_DECLARE_FINAL_TYPE (EphyNotificationContainer, ephy_notification_container, EPHY, NOTIFICATION_CONTAINER,
AdwBin)
EphyNotificationContainer *ephy_notification_container_get_default (void);
diff --git a/lib/ephy-notification.c b/lib/ephy-notification.c
index 38ccc8829..79d7022d5 100644
--- a/lib/ephy-notification.c
+++ b/lib/ephy-notification.c
@@ -24,7 +24,7 @@
#include "ephy-notification-container.h"
struct _EphyNotification {
- GtkBin parent_instance;
+ AdwBin parent_instance;
GtkWidget *grid;
@@ -49,7 +49,7 @@ enum {
static guint signals[LAST_SIGNAL];
-G_DEFINE_TYPE (EphyNotification, ephy_notification, GTK_TYPE_BIN);
+G_DEFINE_TYPE (EphyNotification, ephy_notification, ADW_TYPE_BIN);
static void
ephy_notification_constructed (GObject *object)
@@ -125,37 +125,33 @@ close_button_clicked_cb (GtkButton *button,
static void
ephy_notification_init (EphyNotification *self)
{
- GtkWidget *image;
- GtkStyleContext *context;
-
- self->grid = gtk_grid_new ();
- context = gtk_widget_get_style_context (self->grid);
- gtk_style_context_add_class (context, "app-notification");
- gtk_container_add (GTK_CONTAINER (self), self->grid);
+ gtk_widget_add_css_class (GTK_WIDGET (self), "app-notification");
+ adw_bin_set_child (ADW_BIN (self), self->grid);
self->head = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (self->head), TRUE);
+ gtk_label_set_wrap (GTK_LABEL (self->head), TRUE);
gtk_widget_set_halign (self->head, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (self->head, TRUE);
gtk_grid_attach (GTK_GRID (self->grid), self->head, 0, 0, 1, 1);
self->body = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (self->body), TRUE);
+ gtk_label_set_wrap (GTK_LABEL (self->body), TRUE);
gtk_widget_set_halign (self->body, GTK_ALIGN_CENTER);
gtk_widget_set_hexpand (self->body, TRUE);
gtk_grid_attach (GTK_GRID (self->grid), self->body, 0, 1, 1, 1);
- self->close_button = gtk_button_new ();
- g_object_set (self->close_button,
- "relief", GTK_RELIEF_NONE,
- "focus-on-click", FALSE,
- "margin", 6,
- NULL);
+ self->close_button =
+ g_object_new (GTK_TYPE_BUTTON,
+ "has-frame", FALSE,
+ "focus-on-click", FALSE,
+ "icon-name", "window-close-symbolic",
+ "margin-top", 6,
+ "margin-bottom", 6,
+ "margin-start", 6,
+ "margin-end", 6,
+ NULL);
gtk_grid_attach (GTK_GRID (self->grid), self->close_button, 1, 0, 1, 2);
- image = gtk_image_new_from_icon_name ("window-close-symbolic", GTK_ICON_SIZE_BUTTON);
- gtk_button_set_image (GTK_BUTTON (self->close_button), image);
-
g_signal_connect (self->close_button,
"clicked",
G_CALLBACK (close_button_clicked_cb),
diff --git a/lib/ephy-notification.h b/lib/ephy-notification.h
index d3226cb68..5947cbcad 100644
--- a/lib/ephy-notification.h
+++ b/lib/ephy-notification.h
@@ -21,13 +21,13 @@
#pragma once
#include <glib-object.h>
-#include <gtk/gtk.h>
+#include <adwaita.h>
G_BEGIN_DECLS
#define EPHY_TYPE_NOTIFICATION (ephy_notification_get_type ())
-G_DECLARE_FINAL_TYPE (EphyNotification, ephy_notification, EPHY, NOTIFICATION, GtkBin)
+G_DECLARE_FINAL_TYPE (EphyNotification, ephy_notification, EPHY, NOTIFICATION, AdwBin)
EphyNotification *ephy_notification_new (const char *head,
const char *body);
diff --git a/lib/ephy-web-app-utils.c b/lib/ephy-web-app-utils.c
index d60b7dfa6..1d11751bb 100644
--- a/lib/ephy-web-app-utils.c
+++ b/lib/ephy-web-app-utils.c
@@ -507,15 +507,15 @@ ephy_web_application_setup_from_profile_directory (const char *profile_directory
}
g_set_application_name (g_app_info_get_name (G_APP_INFO (desktop_info)));
- app_icon = g_build_filename (profile_directory, EPHY_WEB_APP_ICON_NAME, NULL);
- gtk_window_set_default_icon_from_file (app_icon, NULL);
+// app_icon = g_build_filename (profile_directory, EPHY_WEB_APP_ICON_NAME, NULL);
+// gtk_window_set_default_icon_from_file (app_icon, NULL);
/* We need to re-set this because we have already parsed the
* options, which inits GTK+ and sets this as a side effect.
*/
- gdk_set_program_class (program_name);
+// FIXME gdk_set_program_class (program_name);
- g_free (app_icon);
+// g_free (app_icon);
g_free (desktop_basename);
g_free (desktop_filename);
g_object_unref (desktop_info);
@@ -525,7 +525,7 @@ void
ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info)
{
GAppInfo *app_info;
- const char *wm_class;
+// const char *wm_class;
GIcon *icon;
g_assert (G_IS_DESKTOP_APP_INFO (desktop_info));
@@ -540,7 +540,7 @@ ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info)
char *path = file ? g_file_get_path (file) : NULL;
if (path) {
- gtk_window_set_default_icon_from_file (path, NULL);
+// FIXME gtk_window_set_default_icon_from_file (path, NULL);
g_free (path);
}
g_clear_object (&file);
@@ -553,9 +553,9 @@ ephy_web_application_setup_from_desktop_file (GDesktopAppInfo *desktop_info)
/* We need to re-set this because we have already parsed the
* options, which inits GTK+ and sets this as a side effect.
*/
- wm_class = g_desktop_app_info_get_startup_wm_class (desktop_info);
- if (wm_class)
- gdk_set_program_class (wm_class);
+// wm_class = g_desktop_app_info_get_startup_wm_class (desktop_info);
+// if (wm_class)
+// FIXME gdk_set_program_class (wm_class);
}
void
diff --git a/lib/meson.build b/lib/meson.build
index 015227f14..ebcf4f0f7 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -10,42 +10,42 @@ enums = gnome.mkenums_simple('ephy-lib-type-builtins',
)
libephymisc_sources = [
-# 'contrib/gnome-languages.c',
-# 'ephy-debug.c',
+ 'contrib/gnome-languages.c',
+ 'ephy-debug.c',
# 'ephy-dnd.c',
-# 'ephy-favicon-helpers.c',
-# 'ephy-file-helpers.c',
-# 'ephy-flatpak-utils.c',
+ 'ephy-favicon-helpers.c',
+ 'ephy-file-helpers.c',
+ 'ephy-flatpak-utils.c',
# 'ephy-gui.c',
-# 'ephy-langs.c',
-# 'ephy-notification.c',
-# 'ephy-notification-container.c',
-# 'ephy-permissions-manager.c',
-# 'ephy-profile-utils.c',
-# 'ephy-search-engine-manager.c',
-# 'ephy-security-levels.c',
-# 'ephy-settings.c',
-# 'ephy-signal-accumulator.c',
-# 'ephy-smaps.c',
-# 'ephy-snapshot-service.c',
-# 'ephy-sqlite-connection.c',
-# 'ephy-sqlite-statement.c',
-# 'ephy-string.c',
+ 'ephy-langs.c',
+ 'ephy-notification.c',
+ 'ephy-notification-container.c',
+ 'ephy-permissions-manager.c',
+ 'ephy-profile-utils.c',
+ 'ephy-search-engine-manager.c',
+ 'ephy-security-levels.c',
+ 'ephy-settings.c',
+ 'ephy-signal-accumulator.c',
+ 'ephy-smaps.c',
+ 'ephy-snapshot-service.c',
+ 'ephy-sqlite-connection.c',
+ 'ephy-sqlite-statement.c',
+ 'ephy-string.c',
# 'ephy-suggestion.c',
-# 'ephy-sync-utils.c',
-# 'ephy-time-helpers.c',
-# 'ephy-uri-helpers.c',
-# 'ephy-user-agent.c',
-# 'ephy-web-app-utils.c',
-# 'ephy-zoom.c',
-# 'history/ephy-history-service.c',
-# 'history/ephy-history-service-hosts-table.c',
-# 'history/ephy-history-service-urls-table.c',
-# 'history/ephy-history-service-visits-table.c',
-# 'history/ephy-history-types.c',
-# 'safe-browsing/ephy-gsb-service.c',
-# 'safe-browsing/ephy-gsb-storage.c',
-# 'safe-browsing/ephy-gsb-utils.c',
+ 'ephy-sync-utils.c',
+ 'ephy-time-helpers.c',
+ 'ephy-uri-helpers.c',
+ 'ephy-user-agent.c',
+ 'ephy-web-app-utils.c',
+ 'ephy-zoom.c',
+ 'history/ephy-history-service.c',
+ 'history/ephy-history-service-hosts-table.c',
+ 'history/ephy-history-service-urls-table.c',
+ 'history/ephy-history-service-visits-table.c',
+ 'history/ephy-history-types.c',
+ 'safe-browsing/ephy-gsb-service.c',
+ 'safe-browsing/ephy-gsb-storage.c',
+ 'safe-browsing/ephy-gsb-utils.c',
enums
]
@@ -59,6 +59,7 @@ libephymisc_deps = [
gsettings_desktop_schemas,
gtk_dep,
json_glib_dep,
+ libadwaita_dep,
libsecret_dep,
libsoup_dep,
libxml_dep,
@@ -92,5 +93,5 @@ ephymisc_dep = declare_dependency(
sources: enums
)
-#subdir('sync')
+subdir('sync')
#subdir('widgets')
diff --git a/meson.build b/meson.build
index e7881d018..90fb49749 100644
--- a/meson.build
+++ b/meson.build
@@ -139,7 +139,7 @@ subdir('help')
subdir('po')
subdir('third-party')
subdir('lib')
-#subdir('embed')
+subdir('embed')
#subdir('src')
#subdir('tests')
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]