Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: adw 1.6 deprecations #479

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion .github/workflows/flatpak.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 600
container:
image: bilelmoussaoui/flatpak-github-actions:gnome-45
image: bilelmoussaoui/flatpak-github-actions:gnome-46
options: --privileged
strategy:
matrix:
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project('clapper', 'c',
glib_req = '>= 2.76.0'
gst_req = '>= 1.20.0'
gtk4_req = '>= 4.10.0'
adw_req = '>= 1.4.0'
adw_req = '>= 1.5.0'

clapper_version = meson.project_version().split('-')[0]
version_array = clapper_version.split('.')
Expand Down
2 changes: 1 addition & 1 deletion pkgs/flatpak/com.github.rafostar.Clapper.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"app-id": "com.github.rafostar.Clapper",
"runtime": "org.gnome.Platform",
"runtime-version": "45",
"runtime-version": "46",
"sdk": "org.gnome.Sdk",
"add-extensions": {
"org.freedesktop.Platform.ffmpeg-full": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,24 @@
#include <clapper/clapper.h>
#include <adwaita.h>

#include "clapper-app-about-window.h"
#include "clapper-app-about-dialog.h"

GtkWidget *
clapper_app_about_window_new (GtkApplication *gtk_app)
clapper_app_about_dialog_new ()
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
{
AdwAboutWindow *about;
GtkWindow *window;
AdwAboutDialog *about;
GString *string;
gchar *gst_ver, *debug_info;

about = ADW_ABOUT_WINDOW (adw_about_window_new_from_appdata (
about = ADW_ABOUT_DIALOG (adw_about_dialog_new_from_appdata (
CLAPPER_APP_RESOURCE_PREFIX "/data/metainfo/" CLAPPER_APP_ID ".metainfo.xml",
NULL));
window = gtk_application_get_active_window (gtk_app);

gtk_window_set_modal (GTK_WINDOW (about), TRUE);
gtk_window_set_transient_for (GTK_WINDOW (about), window);

/* Also show development versions */
adw_about_window_set_version (about, CLAPPER_VERSION_S);
adw_about_dialog_set_version (about, CLAPPER_VERSION_S);

/* TRANSLATORS: Put your name(s) here for credits or leave untranslated */
adw_about_window_set_translator_credits (about, _("translator-credits"));
adw_about_dialog_set_translator_credits (about, _("translator-credits"));

string = g_string_new (NULL);

Expand All @@ -66,7 +61,7 @@ clapper_app_about_window_new (GtkApplication *gtk_app)
g_free (gst_ver);

debug_info = g_string_free_and_steal (string);
adw_about_window_set_debug_info (about, debug_info);
adw_about_dialog_set_debug_info (about, debug_info);
g_free (debug_info);

return GTK_WIDGET (about);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
G_BEGIN_DECLS

G_GNUC_INTERNAL
GtkWidget * clapper_app_about_window_new (GtkApplication *gtk_app);
GtkWidget * clapper_app_about_dialog_new ();
GeopJr marked this conversation as resolved.
Show resolved Hide resolved

G_END_DECLS
10 changes: 6 additions & 4 deletions src/bin/clapper-app/clapper-app-application.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "clapper-app-uri-dialog.h"
#include "clapper-app-info-window.h"
#include "clapper-app-preferences-window.h"
#include "clapper-app-about-window.h"
#include "clapper-app-about-dialog.h"
#include "clapper-app-utils.h"

#define PERCENTAGE_ROUND(a) (round ((gdouble) a / 0.01) * 0.01)
Expand Down Expand Up @@ -378,10 +378,12 @@ static void
show_about (GSimpleAction *action, GVariant *param, gpointer user_data)
{
GtkApplication *gtk_app = GTK_APPLICATION (user_data);
GtkWidget *about_window;
GtkWindow *window;
GtkWidget *about_dialog;

about_window = clapper_app_about_window_new (gtk_app);
gtk_window_present (GTK_WINDOW (about_window));
window = gtk_application_get_active_window (gtk_app);
about_dialog = clapper_app_about_dialog_new ();
adw_dialog_present (ADW_DIALOG (about_dialog), GTK_WIDGET (window));
}

GApplication *
Expand Down
42 changes: 20 additions & 22 deletions src/bin/clapper-app/clapper-app-uri-dialog.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@
#include "clapper-app-utils.h"

static void
_entry_text_changed_cb (GtkEntry *entry,
GParamSpec *pspec G_GNUC_UNUSED, AdwMessageDialog *dialog)
_entry_text_changed_cb (AdwEntryRow *entry,
GParamSpec *pspec G_GNUC_UNUSED, AdwAlertDialog *dialog)
{
GtkEntryBuffer *buffer = gtk_entry_get_buffer (entry);
guint text_length = gtk_entry_buffer_get_length (buffer);
const gchar *text = gtk_editable_get_text (GTK_EDITABLE (entry));
gboolean enabled = FALSE;

if (text_length > 0) {
const gchar *text = gtk_entry_buffer_get_text (buffer);
if (strlen (text) > 0) {
enabled = (text && gst_uri_is_valid (text));
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
}

adw_message_dialog_set_response_enabled (dialog, "add", enabled);
adw_alert_dialog_set_response_enabled (dialog, "add", enabled);
}

static void
_open_uri_cb (AdwMessageDialog *dialog, GAsyncResult *result, GtkApplication *gtk_app)
_open_uri_cb (AdwAlertDialog *dialog, GAsyncResult *result, GtkApplication *gtk_app)
{
const gchar *response = adw_message_dialog_choose_finish (dialog, result);
const gchar *response = adw_alert_dialog_choose_finish (dialog, result);

if (strcmp (response, "add") == 0) {
GtkWidget *extra_child = adw_message_dialog_get_extra_child (dialog);
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (extra_child));
const gchar *text = gtk_entry_buffer_get_text (buffer);
GtkWidget *extra_child = adw_alert_dialog_get_extra_child (dialog);
GtkListBoxRow *list_row = gtk_list_box_get_row_at_index (GTK_LIST_BOX (extra_child), 0);
AdwEntryRow *entry_row = ADW_ENTRY_ROW (list_row);

const gchar *text = gtk_editable_get_text (GTK_EDITABLE (entry_row));
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
GFile **files = NULL;
gint n_files = 0;

Expand All @@ -62,7 +62,7 @@ _open_uri_cb (AdwMessageDialog *dialog, GAsyncResult *result, GtkApplication *gt
static void
_read_text_cb (GdkClipboard *clipboard, GAsyncResult *result, GtkWidget *extra_child)
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
{
GtkEntry *entry = GTK_ENTRY (extra_child);
AdwEntryRow *entry = ADW_ENTRY_ROW (extra_child);
GeopJr marked this conversation as resolved.
Show resolved Hide resolved
GError *error = NULL;
gchar *text = gdk_clipboard_read_text_finish (clipboard, result, &error);

Expand All @@ -89,30 +89,28 @@ clapper_app_uri_dialog_open_uri (GtkApplication *gtk_app)
{
GtkWindow *window = gtk_application_get_active_window (gtk_app);
GtkBuilder *builder;
AdwMessageDialog *dialog;
GtkWidget *extra_child;
AdwAlertDialog *dialog;
GtkWidget *entry_row;
GdkDisplay *display;

builder = gtk_builder_new_from_resource (
CLAPPER_APP_RESOURCE_PREFIX "/ui/clapper-app-uri-dialog.ui");

dialog = ADW_MESSAGE_DIALOG (gtk_builder_get_object (builder, "dialog"));
gtk_window_set_transient_for (GTK_WINDOW (dialog), window);

extra_child = adw_message_dialog_get_extra_child (dialog);
dialog = ADW_ALERT_DIALOG (gtk_builder_get_object (builder, "dialog"));
entry_row = GTK_WIDGET (gtk_builder_get_object (builder, "entry_row"));

g_signal_connect (GTK_ENTRY (extra_child), "notify::text",
g_signal_connect (GTK_EDITABLE (entry_row), "notify::text",
G_CALLBACK (_entry_text_changed_cb), dialog);

if ((display = gdk_display_get_default ())) {
GdkClipboard *clipboard = gdk_display_get_clipboard (display);

gdk_clipboard_read_text_async (clipboard, NULL,
(GAsyncReadyCallback) _read_text_cb, extra_child);
(GAsyncReadyCallback) _read_text_cb, entry_row);
}

/* NOTE: Dialog will automatically unref itself after response */
adw_message_dialog_choose (dialog, NULL,
adw_alert_dialog_choose (dialog, GTK_WIDGET (window), NULL,
(GAsyncReadyCallback) _open_uri_cb,
gtk_app);

Expand Down
2 changes: 1 addition & 1 deletion src/bin/clapper-app/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ configure_file(
)

clapperapp_sources = [
'clapper-app-about-window.c',
'clapper-app-about-dialog.c',
'clapper-app-application.c',
'clapper-app-file-dialog.c',
'clapper-app-headerbar.c',
Expand Down
28 changes: 17 additions & 11 deletions src/bin/clapper-app/ui/clapper-app-uri-dialog.ui
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="clapper-app">
<object class="AdwMessageDialog" id="dialog">
<property name="modal">true</property>
<property name="width-request">420</property>
<object class="AdwAlertDialog" id="dialog">
<property name="heading" translatable="yes">Add URI</property>
<property name="body" translatable="yes">Insert an URI to be added to playback queue</property>
<property name="close-response">cancel</property>
<property name="default-response">add</property>
<property name="follows-content-size">false</property>
<property name="extra-child">
<object class="GtkEntry">
<property name="halign">fill</property>
<property name="valign">center</property>
<property name="hexpand">true</property>
<property name="activates-default">true</property>
<property name="truncate-multiline">true</property>
<property name="input-purpose">url</property>
<property name="placeholder-text" translatable="yes">Enter or drop URI here</property>
<object class="GtkListBox">
<property name="selection-mode">none</property>
<style>
<class name="boxed-list"/>
</style>
<child>
<object class="AdwEntryRow" id="entry_row">
<property name="halign">fill</property>
<property name="valign">center</property>
<property name="hexpand">true</property>
<property name="activates-default">true</property>
<property name="input-purpose">url</property>
<property name="title" translatable="yes">Enter or drop URI here</property>
</object>
</child>
</object>
</property>
<responses>
Expand Down