[epiphany/wip/exalm/gtk4: 7/7] Port a few files to gtk4
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany/wip/exalm/gtk4: 7/7] Port a few files to gtk4
- Date: Mon, 29 Nov 2021 14:43:52 +0000 (UTC)
commit 0912564558087292aa46973f5b89243664408329
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Mon Nov 29 12:52:32 2021 +0500
Port a few files to gtk4
Left out lib/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:
- lib/ephy-dnd.c - gtk4 dnd api is completely different, this will need a lot of changes
- lib/ephy-gui.c - ephy_gui_get_current_event() is bad, this will need a rework everywhere
- lib/ephy-suggestion.c - no libdazzle in gtk4
FIXMEs:
- lib/ephy-web-app-utils.c
- gdk_set_program_class()
- gtk_window_set_default_icon_from_file()
- embed/ephy-embed.c
- hover to move the floating bar, should be a controller on the bar
embed/ephy-embed-shell.c | 30 +----------------
embed/ephy-embed-shell.h | 6 ++--
embed/ephy-embed.c | 53 ++++++++++++------------------
embed/ephy-find-toolbar.c | 5 ++-
embed/ephy-find-toolbar.h | 4 +--
embed/ephy-reader-handler.c | 10 +++---
embed/ephy-web-view.c | 14 ++++----
embed/meson.build | 10 +++---
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 +-
18 files changed, 132 insertions(+), 194 deletions(-)
---
diff --git a/embed/ephy-embed-shell.c b/embed/ephy-embed-shell.c
index 189370bd8..310dc830b 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))
@@ -888,27 +888,6 @@ enable_itp_setting_changed_cb (GSettings *settings,
EPHY_PREFS_WEB_ENABLE_ITP));
}
-static void
-update_system_scrollbars (EphyEmbedShell *shell)
-{
- EphyEmbedShellPrivate *priv = ephy_embed_shell_get_instance_private (shell);
- const char *theme_name;
- gboolean enabled;
-
- g_object_get (gtk_settings_get_default (),
- "gtk-theme_name", &theme_name,
- NULL);
-
- /* Don't enable system scrollbars for Adwaita */
- enabled = g_strcmp0 (theme_name, "Adwaita") &&
- g_strcmp0 (theme_name, "Adwaita-dark") &&
- g_strcmp0 (theme_name, "HighContrast") &&
- g_strcmp0 (theme_name, "HighContrastInverse");
-
- webkit_web_context_set_use_system_appearance_for_scrollbars (priv->web_context,
- enabled);
-}
-
static void
ephy_embed_shell_startup (GApplication *application)
{
@@ -1001,13 +980,6 @@ ephy_embed_shell_startup (GApplication *application)
g_signal_connect_object (EPHY_SETTINGS_WEB, "changed::enable-itp",
G_CALLBACK (enable_itp_setting_changed_cb), shell, 0);
-
- update_system_scrollbars (shell);
-
- g_signal_connect_swapped (gtk_settings_get_default (),
- "notify::gtk-theme-name",
- G_CALLBACK (update_system_scrollbars),
- shell);
}
static void
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/ephy-embed.c b/embed/ephy-embed.c
index b6c61d205..b3307c722 100644
--- a/embed/ephy-embed.c
+++ b/embed/ephy-embed.c
@@ -245,7 +245,7 @@ ephy_embed_destroy_top_widgets (EphyEmbed *embed)
for (iter = embed->destroy_on_transition_list; iter; iter = iter->next) {
g_signal_handlers_disconnect_by_func (iter->data, remove_from_destroy_list_cb, embed);
- gtk_widget_destroy (GTK_WIDGET (iter->data));
+ gtk_box_remove (embed->top_widgets_vbox, GTK_WIDGET (iter->data));
}
embed->destroy_on_transition_list = NULL;
@@ -310,7 +310,7 @@ load_changed_cb (WebKitWebView *web_view,
}
}
-static void
+static gboolean
ephy_embed_grab_focus (GtkWidget *widget)
{
GtkWidget *child;
@@ -318,7 +318,9 @@ ephy_embed_grab_focus (GtkWidget *widget)
child = GTK_WIDGET (ephy_embed_get_web_view (EPHY_EMBED (widget)));
if (child)
- gtk_widget_grab_focus (child);
+ return gtk_widget_grab_focus (child);
+
+ return FALSE;
}
@@ -685,7 +687,7 @@ ephy_embed_mapped_cb (GtkWidget *widget,
{
ephy_embed_maybe_load_delayed_request ((EphyEmbed *)widget);
}
-
+/* FIXME
static gboolean
on_enter_notify_event (GtkWidget *widget,
GdkEventCrossing *event,
@@ -705,7 +707,7 @@ on_enter_notify_event (GtkWidget *widget,
return GDK_EVENT_PROPAGATE;
}
-
+*/
static void
ephy_embed_constructed (GObject *object)
{
@@ -721,18 +723,16 @@ ephy_embed_constructed (GObject *object)
/* Skeleton */
embed->overlay = gtk_overlay_new ();
+ gtk_widget_set_vexpand (embed->overlay, TRUE);
- gtk_widget_add_events (embed->overlay,
- GDK_ENTER_NOTIFY_MASK |
- GDK_LEAVE_NOTIFY_MASK);
- gtk_container_add (GTK_CONTAINER (embed->overlay), GTK_WIDGET (embed->web_view));
+ gtk_overlay_set_child (GTK_OVERLAY (embed->overlay), GTK_WIDGET (embed->web_view));
/* Floating message popup for fullscreen mode. */
embed->fullscreen_message_label = gtk_label_new (NULL);
gtk_widget_set_name (embed->fullscreen_message_label, "fullscreen-popup");
gtk_widget_set_halign (embed->fullscreen_message_label, GTK_ALIGN_CENTER);
gtk_widget_set_valign (embed->fullscreen_message_label, GTK_ALIGN_CENTER);
- gtk_widget_set_no_show_all (embed->fullscreen_message_label, TRUE);
+ gtk_widget_hide (embed->fullscreen_message_label);
gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), embed->fullscreen_message_label);
ephy_embed_set_fullscreen_message (embed, FALSE);
@@ -740,15 +740,14 @@ ephy_embed_constructed (GObject *object)
embed->floating_bar = nautilus_floating_bar_new (NULL, NULL, FALSE);
gtk_widget_set_halign (embed->floating_bar, GTK_ALIGN_START);
gtk_widget_set_valign (embed->floating_bar, GTK_ALIGN_END);
- gtk_widget_set_no_show_all (embed->floating_bar, TRUE);
- g_signal_connect_object (embed->overlay, "enter-notify-event", G_CALLBACK (on_enter_notify_event), embed,
0);
+ gtk_widget_hide (embed->floating_bar);
+// FIXME g_signal_connect_object (embed->overlay, "enter-notify-event", G_CALLBACK (on_enter_notify_event),
embed, 0);
gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), embed->floating_bar);
if (embed->progress_bar_enabled) {
embed->progress = gtk_progress_bar_new ();
- gtk_style_context_add_class (gtk_widget_get_style_context (embed->progress),
- GTK_STYLE_CLASS_OSD);
+ gtk_widget_add_css_class (embed->progress, "osd");
gtk_widget_set_halign (embed->progress, GTK_ALIGN_FILL);
gtk_widget_set_valign (embed->progress, GTK_ALIGN_START);
gtk_overlay_add_overlay (GTK_OVERLAY (embed->overlay), embed->progress);
@@ -759,22 +758,14 @@ ephy_embed_constructed (GObject *object)
G_CALLBACK (ephy_embed_find_toolbar_close_cb),
embed);
- gtk_box_pack_start (GTK_BOX (embed),
- GTK_WIDGET (embed->find_toolbar),
- FALSE, FALSE, 0);
+ gtk_box_append (GTK_BOX (embed), GTK_WIDGET (embed->find_toolbar));
if (embed->progress_bar_enabled)
embed->progress_update_handler_id = g_signal_connect (embed->web_view, "notify::estimated-load-progress",
G_CALLBACK (progress_update), object);
- gtk_box_pack_start (GTK_BOX (embed),
- GTK_WIDGET (embed->top_widgets_vbox),
- FALSE, FALSE, 0);
- gtk_box_pack_start (GTK_BOX (embed), embed->overlay, TRUE, TRUE, 0);
-
- gtk_widget_show (GTK_WIDGET (embed->top_widgets_vbox));
- gtk_widget_show (GTK_WIDGET (embed->web_view));
- gtk_widget_show_all (embed->overlay);
+ gtk_box_append (GTK_BOX (embed), GTK_WIDGET (embed->top_widgets_vbox));
+ gtk_box_append (GTK_BOX (embed), GTK_WIDGET (embed->overlay));
g_object_connect (embed->web_view,
"signal::notify::title", G_CALLBACK (web_view_title_changed_cb), embed,
@@ -805,11 +796,9 @@ ephy_embed_constructed (GObject *object)
gtk_info_bar_set_message_type (GTK_INFO_BAR (info_bar), GTK_MESSAGE_INFO);
/* Translators: this means WebDriver control. */
label = gtk_label_new (_("Web is being controlled by automation."));
- gtk_box_pack_start (GTK_BOX (gtk_info_bar_get_content_area (GTK_INFO_BAR (info_bar))), label, FALSE,
FALSE, 0);
- gtk_widget_show (label);
+ gtk_info_bar_add_child (GTK_INFO_BAR (info_bar), label);
ephy_embed_add_top_widget (embed, info_bar, EPHY_EMBED_TOP_WIDGET_POLICY_RETAIN_ON_TRANSITION);
- gtk_widget_show (info_bar);
}
}
@@ -883,8 +872,7 @@ ephy_embed_add_top_widget (EphyEmbed *embed,
g_signal_connect (widget, "destroy", G_CALLBACK (remove_from_destroy_list_cb), embed);
}
- gtk_box_pack_end (embed->top_widgets_vbox,
- GTK_WIDGET (widget), FALSE, FALSE, 0);
+ gtk_box_prepend (embed->top_widgets_vbox, widget);
}
/**
@@ -910,8 +898,7 @@ ephy_embed_remove_top_widget (EphyEmbed *embed,
embed->destroy_on_transition_list = list;
}
- gtk_container_remove (GTK_CONTAINER (embed->top_widgets_vbox),
- GTK_WIDGET (widget));
+ gtk_box_remove (embed->top_widgets_vbox, widget);
}
/**
@@ -1005,6 +992,6 @@ ephy_embed_detach_notification_container (EphyEmbed *embed)
* notification widget, removing it from the container will destroy the
* singleton. To prevent this, add a reference to it before removing it
* from the container. */
- gtk_container_remove (GTK_CONTAINER (embed->overlay), g_object_ref (GTK_WIDGET (container)));
+ gtk_overlay_remove_overlay (GTK_OVERLAY (embed->overlay), g_object_ref (GTK_WIDGET (container)));
}
}
diff --git a/embed/ephy-find-toolbar.c b/embed/ephy-find-toolbar.c
index 55048421f..3b15dc170 100644
--- a/embed/ephy-find-toolbar.c
+++ b/embed/ephy-find-toolbar.c
@@ -29,12 +29,11 @@
#include <gdk/gdkkeysyms.h>
#include <glib/gi18n.h>
-#include <handy.h>
#include <string.h>
#include <webkit2/webkit2.h>
struct _EphyFindToolbar {
- GtkBin parent_instance;
+ AdwBin parent_instance;
GCancellable *cancellable;
WebKitWebView *web_view;
@@ -53,7 +52,7 @@ struct _EphyFindToolbar {
gboolean typing_ahead;
};
-G_DEFINE_TYPE (EphyFindToolbar, ephy_find_toolbar, GTK_TYPE_BIN)
+G_DEFINE_TYPE (EphyFindToolbar, ephy_find_toolbar, ADW_TYPE_BIN)
enum {
PROP_0,
diff --git a/embed/ephy-find-toolbar.h b/embed/ephy-find-toolbar.h
index 829c6355d..7fabe3073 100644
--- a/embed/ephy-find-toolbar.h
+++ b/embed/ephy-find-toolbar.h
@@ -21,7 +21,7 @@
#pragma once
-#include <gtk/gtk.h>
+#include <adwaita.h>
#include "ephy-web-view.h"
@@ -29,7 +29,7 @@ G_BEGIN_DECLS
#define EPHY_TYPE_FIND_TOOLBAR (ephy_find_toolbar_get_type ())
-G_DECLARE_FINAL_TYPE (EphyFindToolbar, ephy_find_toolbar, EPHY, FIND_TOOLBAR, GtkBin)
+G_DECLARE_FINAL_TYPE (EphyFindToolbar, ephy_find_toolbar, EPHY, FIND_TOOLBAR, AdwBin)
EphyFindToolbar *ephy_find_toolbar_new (WebKitWebView *web_view);
diff --git a/embed/ephy-reader-handler.c b/embed/ephy-reader-handler.c
index 25adf90cb..98d81c5e8 100644
--- a/embed/ephy-reader-handler.c
+++ b/embed/ephy-reader-handler.c
@@ -27,9 +27,9 @@
#include "ephy-settings.h"
#include "ephy-web-view.h"
+#include <adwaita.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
-#include <handy.h>
#include <string.h>
struct _EphyReaderHandler {
@@ -164,7 +164,7 @@ readability_js_finish_cb (GObject *object,
const gchar *title;
const gchar *font_style;
const gchar *color_scheme;
- HdyStyleManager *style_manager;
+ AdwStyleManager *style_manager;
js_result = webkit_web_view_run_javascript_finish (web_view, result, &error);
if (!js_result) {
@@ -184,10 +184,10 @@ readability_js_finish_cb (GObject *object,
g_settings_get_enum (EPHY_SETTINGS_READER,
EPHY_PREFS_READER_FONT_STYLE));
- style_manager = hdy_style_manager_get_default ();
+ style_manager = adw_style_manager_get_default ();
- if (hdy_style_manager_get_system_supports_color_schemes (style_manager))
- color_scheme = hdy_style_manager_get_dark (style_manager) ? "dark" : "light";
+ if (adw_style_manager_get_system_supports_color_schemes (style_manager))
+ color_scheme = adw_style_manager_get_dark (style_manager) ? "dark" : "light";
else
color_scheme = enum_nick (EPHY_TYPE_PREFS_READER_COLOR_SCHEME,
g_settings_get_enum (EPHY_SETTINGS_READER,
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 81af0ed81..168742325 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -50,11 +50,11 @@
#include "ephy-web-app-utils.h"
#include "ephy-zoom.h"
+#include <adwaita.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
-#include <handy.h>
/**
* SECTION:ephy-web-view
@@ -2579,7 +2579,7 @@ enum_nick (GType enum_type,
static void
reader_setting_changed_cb (EphyWebView *web_view)
{
- HdyStyleManager *style_manager;
+ AdwStyleManager *style_manager;
const gchar *font_style;
const gchar *color_scheme;
gchar *js_snippet;
@@ -2591,10 +2591,10 @@ reader_setting_changed_cb (EphyWebView *web_view)
g_settings_get_enum (EPHY_SETTINGS_READER,
EPHY_PREFS_READER_FONT_STYLE));
- style_manager = hdy_style_manager_get_default ();
+ style_manager = adw_style_manager_get_default ();
- if (hdy_style_manager_get_system_supports_color_schemes (style_manager))
- color_scheme = hdy_style_manager_get_dark (style_manager) ? "dark" : "light";
+ if (adw_style_manager_get_system_supports_color_schemes (style_manager))
+ color_scheme = adw_style_manager_get_dark (style_manager) ? "dark" : "light";
else
color_scheme = enum_nick (EPHY_TYPE_PREFS_READER_COLOR_SCHEME,
g_settings_get_enum (EPHY_SETTINGS_READER,
@@ -4001,12 +4001,12 @@ ephy_web_view_init (EphyWebView *web_view)
G_CALLBACK (reader_setting_changed_cb),
web_view, G_CONNECT_SWAPPED);
- g_signal_connect_object (hdy_style_manager_get_default (),
+ g_signal_connect_object (adw_style_manager_get_default (),
"notify::system-supports-color-schemes",
G_CALLBACK (reader_setting_changed_cb),
web_view, 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 (reader_setting_changed_cb),
web_view, G_CONNECT_SWAPPED);
diff --git a/embed/meson.build b/embed/meson.build
index 68d6ec447..cbfaffa91 100644
--- a/embed/meson.build
+++ b/embed/meson.build
@@ -11,10 +11,10 @@ enums = gnome.mkenums_simple('ephy-embed-type-builtins',
)
libephyembed_sources = [
- 'contrib/gd-tagged-entry.c',
- 'ephy-about-handler.c',
+# 'contrib/gd-tagged-entry.c',
+# 'ephy-about-handler.c',
'ephy-downloads-manager.c',
- 'ephy-download.c',
+# 'ephy-download.c',
'ephy-embed.c',
'ephy-embed-container.c',
'ephy-embed-prefs.c',
@@ -24,11 +24,11 @@ libephyembed_sources = [
'ephy-encodings.c',
'ephy-file-monitor.c',
'ephy-filters-manager.c',
- 'ephy-find-toolbar.c',
+# 'ephy-find-toolbar.c',
'ephy-pdf-handler.c',
'ephy-reader-handler.c',
'ephy-view-source-handler.c',
- 'ephy-web-view.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]