mirror of
https://github.com/Rafostar/clapper.git
synced 2025-08-30 16:02:00 +02:00
Merge pull request #479 from geopjr-forks/fix/adw-1-6-deprecations
clapper-app: Fix libadwaita 1.6 deprecations
This commit is contained in:
@@ -22,29 +22,24 @@
|
|||||||
#include <clapper/clapper.h>
|
#include <clapper/clapper.h>
|
||||||
#include <adwaita.h>
|
#include <adwaita.h>
|
||||||
|
|
||||||
#include "clapper-app-about-window.h"
|
#include "clapper-app-about-dialog.h"
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
clapper_app_about_window_new (GtkApplication *gtk_app)
|
clapper_app_about_dialog_new (void)
|
||||||
{
|
{
|
||||||
AdwAboutWindow *about;
|
AdwAboutDialog *about;
|
||||||
GtkWindow *window;
|
|
||||||
GString *string;
|
GString *string;
|
||||||
gchar *gst_ver, *debug_info;
|
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",
|
CLAPPER_APP_RESOURCE_PREFIX "/data/metainfo/" CLAPPER_APP_ID ".metainfo.xml",
|
||||||
NULL));
|
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 */
|
/* 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 */
|
/* 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);
|
string = g_string_new (NULL);
|
||||||
|
|
||||||
@@ -66,7 +61,7 @@ clapper_app_about_window_new (GtkApplication *gtk_app)
|
|||||||
g_free (gst_ver);
|
g_free (gst_ver);
|
||||||
|
|
||||||
debug_info = g_string_free_and_steal (string);
|
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);
|
g_free (debug_info);
|
||||||
|
|
||||||
return GTK_WIDGET (about);
|
return GTK_WIDGET (about);
|
@@ -24,6 +24,6 @@
|
|||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
GtkWidget * clapper_app_about_window_new (GtkApplication *gtk_app);
|
GtkWidget * clapper_app_about_dialog_new (void);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
@@ -28,7 +28,7 @@
|
|||||||
#include "clapper-app-uri-dialog.h"
|
#include "clapper-app-uri-dialog.h"
|
||||||
#include "clapper-app-info-window.h"
|
#include "clapper-app-info-window.h"
|
||||||
#include "clapper-app-preferences-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"
|
#include "clapper-app-utils.h"
|
||||||
|
|
||||||
#define PERCENTAGE_ROUND(a) (round ((gdouble) a / 0.01) * 0.01)
|
#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)
|
show_about (GSimpleAction *action, GVariant *param, gpointer user_data)
|
||||||
{
|
{
|
||||||
GtkApplication *gtk_app = GTK_APPLICATION (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);
|
window = gtk_application_get_active_window (gtk_app);
|
||||||
gtk_window_present (GTK_WINDOW (about_window));
|
about_dialog = clapper_app_about_dialog_new ();
|
||||||
|
adw_dialog_present (ADW_DIALOG (about_dialog), GTK_WIDGET (window));
|
||||||
}
|
}
|
||||||
|
|
||||||
GApplication *
|
GApplication *
|
||||||
|
@@ -25,30 +25,28 @@
|
|||||||
#include "clapper-app-utils.h"
|
#include "clapper-app-utils.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
_entry_text_changed_cb (GtkEntry *entry,
|
_entry_text_changed_cb (AdwEntryRow *entry,
|
||||||
GParamSpec *pspec G_GNUC_UNUSED, AdwMessageDialog *dialog)
|
GParamSpec *pspec G_GNUC_UNUSED, AdwAlertDialog *dialog)
|
||||||
{
|
{
|
||||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (entry);
|
const gchar *text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||||
guint text_length = gtk_entry_buffer_get_length (buffer);
|
|
||||||
gboolean enabled = FALSE;
|
gboolean enabled = FALSE;
|
||||||
|
|
||||||
if (text_length > 0) {
|
if (text && *text != '\0') {
|
||||||
const gchar *text = gtk_entry_buffer_get_text (buffer);
|
enabled = gst_uri_is_valid (text);
|
||||||
enabled = (text && 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
|
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) {
|
if (strcmp (response, "add") == 0) {
|
||||||
GtkWidget *extra_child = adw_message_dialog_get_extra_child (dialog);
|
GtkWidget *extra_child = adw_alert_dialog_get_extra_child (dialog);
|
||||||
GtkEntryBuffer *buffer = gtk_entry_get_buffer (GTK_ENTRY (extra_child));
|
AdwEntryRow *entry_row = ADW_ENTRY_ROW (gtk_list_box_get_row_at_index (GTK_LIST_BOX (extra_child), 0));
|
||||||
const gchar *text = gtk_entry_buffer_get_text (buffer);
|
const gchar *text = gtk_editable_get_text (GTK_EDITABLE (entry_row));
|
||||||
GFile **files = NULL;
|
GFile **files = NULL;
|
||||||
gint n_files = 0;
|
gint n_files = 0;
|
||||||
|
|
||||||
@@ -60,16 +58,15 @@ _open_uri_cb (AdwMessageDialog *dialog, GAsyncResult *result, GtkApplication *gt
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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;
|
GError *error = NULL;
|
||||||
gchar *text = gdk_clipboard_read_text_finish (clipboard, result, &error);
|
gchar *text = gdk_clipboard_read_text_finish (clipboard, result, &error);
|
||||||
|
|
||||||
if (G_LIKELY (error == NULL)) {
|
if (G_LIKELY (error == NULL)) {
|
||||||
if (gst_uri_is_valid (text)) {
|
if (gst_uri_is_valid (text)) {
|
||||||
gtk_editable_set_text (GTK_EDITABLE (entry), text);
|
gtk_editable_set_text (GTK_EDITABLE (entry_row), text);
|
||||||
gtk_editable_select_region (GTK_EDITABLE (entry), 0, -1);
|
gtk_editable_select_region (GTK_EDITABLE (entry_row), 0, -1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Common error when clipboard is empty or has unsupported content.
|
/* 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);
|
GtkWindow *window = gtk_application_get_active_window (gtk_app);
|
||||||
GtkBuilder *builder;
|
GtkBuilder *builder;
|
||||||
AdwMessageDialog *dialog;
|
AdwAlertDialog *dialog;
|
||||||
GtkWidget *extra_child;
|
GtkWidget *entry_row;
|
||||||
GdkDisplay *display;
|
GdkDisplay *display;
|
||||||
|
|
||||||
builder = gtk_builder_new_from_resource (
|
builder = gtk_builder_new_from_resource (
|
||||||
CLAPPER_APP_RESOURCE_PREFIX "/ui/clapper-app-uri-dialog.ui");
|
CLAPPER_APP_RESOURCE_PREFIX "/ui/clapper-app-uri-dialog.ui");
|
||||||
|
|
||||||
dialog = ADW_MESSAGE_DIALOG (gtk_builder_get_object (builder, "dialog"));
|
dialog = ADW_ALERT_DIALOG (gtk_builder_get_object (builder, "dialog"));
|
||||||
gtk_window_set_transient_for (GTK_WINDOW (dialog), window);
|
entry_row = GTK_WIDGET (gtk_builder_get_object (builder, "entry_row"));
|
||||||
|
|
||||||
extra_child = adw_message_dialog_get_extra_child (dialog);
|
g_signal_connect (GTK_EDITABLE (entry_row), "notify::text",
|
||||||
|
|
||||||
g_signal_connect (GTK_ENTRY (extra_child), "notify::text",
|
|
||||||
G_CALLBACK (_entry_text_changed_cb), dialog);
|
G_CALLBACK (_entry_text_changed_cb), dialog);
|
||||||
|
|
||||||
if ((display = gdk_display_get_default ())) {
|
if ((display = gdk_display_get_default ())) {
|
||||||
GdkClipboard *clipboard = gdk_display_get_clipboard (display);
|
GdkClipboard *clipboard = gdk_display_get_clipboard (display);
|
||||||
|
|
||||||
gdk_clipboard_read_text_async (clipboard, NULL,
|
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 */
|
/* 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,
|
(GAsyncReadyCallback) _open_uri_cb,
|
||||||
gtk_app);
|
gtk_app);
|
||||||
|
|
||||||
|
@@ -67,7 +67,7 @@ configure_file(
|
|||||||
)
|
)
|
||||||
|
|
||||||
clapperapp_sources = [
|
clapperapp_sources = [
|
||||||
'clapper-app-about-window.c',
|
'clapper-app-about-dialog.c',
|
||||||
'clapper-app-application.c',
|
'clapper-app-application.c',
|
||||||
'clapper-app-file-dialog.c',
|
'clapper-app-file-dialog.c',
|
||||||
'clapper-app-headerbar.c',
|
'clapper-app-headerbar.c',
|
||||||
|
@@ -1,21 +1,28 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<interface domain="clapper-app">
|
<interface domain="clapper-app">
|
||||||
<object class="AdwMessageDialog" id="dialog">
|
<object class="AdwAlertDialog" id="dialog">
|
||||||
<property name="modal">true</property>
|
|
||||||
<property name="width-request">420</property>
|
|
||||||
<property name="heading" translatable="yes">Add URI</property>
|
<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="body" translatable="yes">Insert an URI to be added to playback queue</property>
|
||||||
<property name="close-response">cancel</property>
|
<property name="close-response">cancel</property>
|
||||||
<property name="default-response">add</property>
|
<property name="default-response">add</property>
|
||||||
|
<property name="follows-content-size">false</property>
|
||||||
|
<property name="content-width">420</property>
|
||||||
<property name="extra-child">
|
<property name="extra-child">
|
||||||
<object class="GtkEntry">
|
<object class="GtkListBox">
|
||||||
<property name="halign">fill</property>
|
<property name="selection-mode">none</property>
|
||||||
<property name="valign">center</property>
|
<style>
|
||||||
<property name="hexpand">true</property>
|
<class name="boxed-list"/>
|
||||||
<property name="activates-default">true</property>
|
</style>
|
||||||
<property name="truncate-multiline">true</property>
|
<child>
|
||||||
<property name="input-purpose">url</property>
|
<object class="AdwEntryRow" id="entry_row">
|
||||||
<property name="placeholder-text" translatable="yes">Enter or drop URI here</property>
|
<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>
|
</object>
|
||||||
</property>
|
</property>
|
||||||
<responses>
|
<responses>
|
||||||
|
Reference in New Issue
Block a user