From 069be3022578bbd6bae84b9a1323aa247a6fa414 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Wed, 12 Feb 2025 17:49:22 +0200 Subject: [PATCH 1/2] clapper-app: fix adw 1.6 deprecations --- ...ut-window.c => clapper-app-about-dialog.c} | 19 +++----- ...ut-window.h => clapper-app-about-dialog.h} | 2 +- src/bin/clapper-app/clapper-app-application.c | 10 ++-- src/bin/clapper-app/clapper-app-uri-dialog.c | 47 +++++++++---------- src/bin/clapper-app/meson.build | 2 +- .../clapper-app/ui/clapper-app-uri-dialog.ui | 28 ++++++----- 6 files changed, 53 insertions(+), 55 deletions(-) rename src/bin/clapper-app/{clapper-app-about-window.c => clapper-app-about-dialog.c} (76%) rename src/bin/clapper-app/{clapper-app-about-window.h => clapper-app-about-dialog.h} (92%) diff --git a/src/bin/clapper-app/clapper-app-about-window.c b/src/bin/clapper-app/clapper-app-about-dialog.c similarity index 76% rename from src/bin/clapper-app/clapper-app-about-window.c rename to src/bin/clapper-app/clapper-app-about-dialog.c index 8362576c..1e4b6901 100644 --- a/src/bin/clapper-app/clapper-app-about-window.c +++ b/src/bin/clapper-app/clapper-app-about-dialog.c @@ -22,29 +22,24 @@ #include #include -#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 (void) { - 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); @@ -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); diff --git a/src/bin/clapper-app/clapper-app-about-window.h b/src/bin/clapper-app/clapper-app-about-dialog.h similarity index 92% rename from src/bin/clapper-app/clapper-app-about-window.h rename to src/bin/clapper-app/clapper-app-about-dialog.h index 2051d0ff..4658c8f4 100644 --- a/src/bin/clapper-app/clapper-app-about-window.h +++ b/src/bin/clapper-app/clapper-app-about-dialog.h @@ -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 (void); G_END_DECLS diff --git a/src/bin/clapper-app/clapper-app-application.c b/src/bin/clapper-app/clapper-app-application.c index 0e5ab8ba..fbea6a02 100644 --- a/src/bin/clapper-app/clapper-app-application.c +++ b/src/bin/clapper-app/clapper-app-application.c @@ -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) @@ -399,10 +399,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 * diff --git a/src/bin/clapper-app/clapper-app-uri-dialog.c b/src/bin/clapper-app/clapper-app-uri-dialog.c index a452f1e7..16078b24 100644 --- a/src/bin/clapper-app/clapper-app-uri-dialog.c +++ b/src/bin/clapper-app/clapper-app-uri-dialog.c @@ -25,30 +25,28 @@ #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); - enabled = (text && gst_uri_is_valid (text)); + if (text && *text != '\0') { + enabled = gst_uri_is_valid (text); } - 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); + AdwEntryRow *entry_row = ADW_ENTRY_ROW (gtk_list_box_get_row_at_index (GTK_LIST_BOX (extra_child), 0)); + const gchar *text = gtk_editable_get_text (GTK_EDITABLE (entry_row)); GFile **files = NULL; gint n_files = 0; @@ -60,16 +58,15 @@ _open_uri_cb (AdwMessageDialog *dialog, GAsyncResult *result, GtkApplication *gt } static void -_read_text_cb (GdkClipboard *clipboard, GAsyncResult *result, GtkWidget *extra_child) +_read_text_cb (GdkClipboard *clipboard, GAsyncResult *result, GtkWidget *entry_row) { - GtkEntry *entry = GTK_ENTRY (extra_child); GError *error = NULL; gchar *text = gdk_clipboard_read_text_finish (clipboard, result, &error); if (G_LIKELY (error == NULL)) { if (gst_uri_is_valid (text)) { - gtk_editable_set_text (GTK_EDITABLE (entry), text); - gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1); + gtk_editable_set_text (GTK_EDITABLE (entry_row), text); + gtk_editable_select_region (GTK_EDITABLE (entry_row), 0, -1); } } else { /* Common error when clipboard is empty or has unsupported content. @@ -89,30 +86,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); + dialog = ADW_ALERT_DIALOG (gtk_builder_get_object (builder, "dialog")); + entry_row = GTK_WIDGET (gtk_builder_get_object (builder, "entry_row")); - extra_child = adw_message_dialog_get_extra_child (dialog); - - 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); diff --git a/src/bin/clapper-app/meson.build b/src/bin/clapper-app/meson.build index 220b66c0..96021cee 100644 --- a/src/bin/clapper-app/meson.build +++ b/src/bin/clapper-app/meson.build @@ -67,7 +67,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', diff --git a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui index 4ab5b3e6..faa10cb9 100644 --- a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui +++ b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui @@ -1,21 +1,27 @@ - - true - 420 + Add URI Insert an URI to be added to playback queue cancel add + false - - fill - center - true - true - true - url - Enter or drop URI here + + none + + + + fill + center + true + true + url + Enter or drop URI here + + From a5bc1b5578b4ec97f6488925d190a315aabd82b3 Mon Sep 17 00:00:00 2001 From: Evan Paterakis Date: Sat, 15 Feb 2025 19:17:04 +0200 Subject: [PATCH 2/2] clapper-app: set uri-dialog's content width to 420 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rafał Dzięgiel <40623528+Rafostar@users.noreply.github.com> --- src/bin/clapper-app/ui/clapper-app-uri-dialog.ui | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui index faa10cb9..a36ddc53 100644 --- a/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui +++ b/src/bin/clapper-app/ui/clapper-app-uri-dialog.ui @@ -6,6 +6,7 @@ cancel add false + 420 none