[krb5-auth-dialog] Add and use ka_editable_{get,set}_text()
- From: Guido Günther <guidog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [krb5-auth-dialog] Add and use ka_editable_{get,set}_text()
- Date: Fri, 14 Oct 2022 19:53:25 +0000 (UTC)
commit cb16079a96b0dfb2ac97f5cb8baa17c9a1b4bb37
Author: Guido Günther <agx sigxcpu org>
Date: Fri Oct 14 10:38:38 2022 +0200
Add and use ka_editable_{get,set}_text()
This eases the GTK4 migration since we can keep the GTK3 working before
making the switch.
src/ka-preferences.c | 36 ++++++++++++++++++------------------
src/ka-pwdialog.c | 5 +++--
src/ka-tools.c | 23 ++++++++++++++++++++++-
src/ka-tools.h | 4 ++++
4 files changed, 47 insertions(+), 21 deletions(-)
---
diff --git a/src/ka-preferences.c b/src/ka-preferences.c
index 611bea4..81a9a54 100644
--- a/src/ka-preferences.c
+++ b/src/ka-preferences.c
@@ -148,13 +148,13 @@ ka_preferences_principal_notify (KaPreferences *self,
principal = g_settings_get_string (self->priv->settings, key);
if (!principal || !strlen(principal))
- gtk_entry_set_text (GTK_ENTRY (self->priv->principal_entry), "");
+ ka_editable_set_text (self->priv->principal_entry, "");
else {
const char *old_principal;
- old_principal = gtk_entry_get_text (GTK_ENTRY (self->priv->principal_entry));
+ old_principal = ka_editable_get_text (self->priv->principal_entry);
if (!old_principal || (old_principal && strcmp (old_principal, principal)))
- gtk_entry_set_text (GTK_ENTRY (self->priv->principal_entry), principal);
+ ka_editable_set_text (self->priv->principal_entry, principal);
}
}
@@ -165,7 +165,7 @@ ka_preferences_principal_changed (GtkEntry *entry,
const char *principal;
KaPreferences *self = KA_PREFERENCES (userdata);
- principal = gtk_entry_get_text (entry);
+ principal = ka_editable_get_text (entry);
if (principal && strlen(principal))
g_object_set (self->priv->applet, KA_PROP_NAME_PRINCIPAL, principal, NULL);
@@ -183,7 +183,7 @@ ka_preferences_setup_principal_entry (KaPreferences *self)
if (!principal)
g_warning ("Getting principal failed");
if (principal && strlen(principal))
- gtk_entry_set_text (GTK_ENTRY (self->priv->principal_entry), principal);
+ ka_editable_set_text (self->priv->principal_entry, principal);
g_free (principal);
g_signal_connect (self->priv->principal_entry, "changed",
@@ -202,11 +202,11 @@ ka_preferences_pkuserid_notify (KaPreferences *self,
if (pkuserid && strlen(pkuserid)) {
const char *old_pkuserid;
- old_pkuserid = gtk_entry_get_text (GTK_ENTRY (self->priv->pkuserid_entry));
+ old_pkuserid = ka_editable_get_text (self->priv->pkuserid_entry);
if (!old_pkuserid || (old_pkuserid && strcmp (old_pkuserid, pkuserid)))
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkuserid_entry), pkuserid);
+ ka_editable_set_text (self->priv->pkuserid_entry, pkuserid);
} else {
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkuserid_entry), "");
+ ka_editable_set_text (self->priv->pkuserid_entry, "");
}
}
@@ -218,7 +218,7 @@ ka_preferences_pkuserid_changed (GtkEntry *entry,
const char *pkuserid;
KaPreferences *self = KA_PREFERENCES (userdata);
- pkuserid = gtk_entry_get_text (entry);
+ pkuserid = ka_editable_get_text (entry);
if (pkuserid && strlen(pkuserid))
g_object_set (self->priv->applet, KA_PROP_NAME_PK_USERID, pkuserid, NULL);
@@ -236,7 +236,7 @@ ka_preferences_setup_pkuserid_entry (KaPreferences *self)
if (!pkuserid)
g_warning ("Getting pkuserid failed");
if (pkuserid && strlen(pkuserid))
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkuserid_entry), pkuserid);
+ ka_editable_set_text (self->priv->pkuserid_entry, pkuserid);
if (pkuserid)
g_free (pkuserid);
@@ -255,12 +255,12 @@ ka_preferences_pkanchors_notify (KaPreferences *self,
if (pkanchors && strlen(pkanchors)) {
const char *old_pkanchors;
- old_pkanchors = gtk_entry_get_text (GTK_ENTRY (self->priv->pkanchors_entry));
+ old_pkanchors = ka_editable_get_text (self->priv->pkanchors_entry);
if (!old_pkanchors || (old_pkanchors && strcmp (old_pkanchors,
pkanchors)))
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkanchors_entry), pkanchors);
+ ka_editable_set_text (self->priv->pkanchors_entry, pkanchors);
} else {
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkanchors_entry), "");
+ ka_editable_set_text (self->priv->pkanchors_entry, "");
}
}
@@ -271,7 +271,7 @@ ka_preferences_pkanchors_changed (GtkEntry *entry,
const char *pkanchors;
KaPreferences *self = KA_PREFERENCES (userdata);
- pkanchors = gtk_entry_get_text (entry);
+ pkanchors = ka_editable_get_text (entry);
if (pkanchors && strlen(pkanchors))
g_object_set (self->priv->applet, KA_PROP_NAME_PK_ANCHORS, pkanchors, NULL);
@@ -290,7 +290,7 @@ ka_preferences_setup_pkanchors_entry (KaPreferences *self)
g_warning ("Getting pkanchors failed");
if (pkanchors && strlen(pkanchors))
- gtk_entry_set_text (GTK_ENTRY (self->priv->pkanchors_entry), pkanchors);
+ ka_editable_set_text (self->priv->pkanchors_entry, pkanchors);
if (pkanchors)
g_free (pkanchors);
@@ -318,7 +318,7 @@ ka_preferences_smartcard_toggled (GtkToggleButton *toggle,
if (smartcard) {
const char *path;
- path = gtk_entry_get_text (GTK_ENTRY(self->priv->pkuserid_entry));
+ path = ka_editable_get_text (self->priv->pkuserid_entry);
if (g_strcmp0 (path, PKINIT_SMARTCARD)) {
g_free (old_path);
old_path = g_strdup (path);
@@ -373,7 +373,7 @@ on_file_chooser_response (GtkDialog* dialog, gint response_id, gpointer user_dat
if (filename) {
g_autofree gchar *cert = g_strconcat (PKINIT_FILE, filename, NULL);
- gtk_entry_set_text (entry, cert);
+ ka_editable_set_text (entry, cert);
}
}
@@ -393,7 +393,7 @@ ka_preferences_browse_certs (KaPreferences *self, GtkEntry *entry)
_("_Open"), GTK_RESPONSE_ACCEPT,
NULL);
- current = gtk_entry_get_text (entry);
+ current = ka_editable_get_text (entry);
if (current && g_str_has_prefix (current, PKINIT_FILE) &&
strlen(current) > strlen (PKINIT_FILE)) {
g_autoptr(GFile) file = g_file_new_for_path (
diff --git a/src/ka-pwdialog.c b/src/ka-pwdialog.c
index 606cbe5..5f57ee6 100644
--- a/src/ka-pwdialog.c
+++ b/src/ka-pwdialog.c
@@ -24,6 +24,7 @@
#include "ka-applet-priv.h"
#include "ka-kerberos.h"
#include "ka-pwdialog.h"
+#include "ka-tools.h"
#define GCR_API_SUBJECT_TO_CHANGE
#include <gcr/gcr.h>
@@ -275,7 +276,7 @@ ka_pwdialog_hide (const KaPwDialog *pwdialog, gboolean force)
const gchar *
ka_pwdialog_get_password (KaPwDialog *pwdialog)
{
- return gtk_entry_get_text (GTK_ENTRY (pwdialog->priv->pw_entry));
+ return ka_editable_get_text (pwdialog->priv->pw_entry);
}
gboolean
@@ -338,7 +339,7 @@ ka_pwdialog_setup (KaPwDialog *pwdialog, const gchar *krb5prompt,
}
/* Clear the password entry field */
- gtk_entry_set_text (GTK_ENTRY (priv->pw_entry), "");
+ ka_editable_set_text (priv->pw_entry, "");
/* Use the prompt label that krb5 provides us */
gtk_label_set_text (GTK_LABEL (priv->krb_label), prompt);
diff --git a/src/ka-tools.c b/src/ka-tools.c
index 69c0980..754653c 100644
--- a/src/ka-tools.c
+++ b/src/ka-tools.c
@@ -55,7 +55,7 @@ ka_show_help (GtkWindow* window, const char* chapter)
}
-void
+void
ka_show_about (KaApplet *applet)
{
GtkWindow *parent = ka_applet_last_focused_window (applet);
@@ -91,3 +91,24 @@ ka_window_destroy (gpointer window)
g_assert (GTK_IS_WINDOW (window));
gtk_widget_destroy (GTK_WIDGET (window));
}
+
+
+void
+ka_editable_set_text (gpointer editable, const char *text)
+{
+#if GTK_CHECK_VERSION(4,0,0)
+ gtk_editable_set_text (GTK_EDITABLE(editable), text);
+#else
+ gtk_entry_set_text (GTK_ENTRY(editable), text);
+#endif
+}
+
+const char *
+ka_editable_get_text (gpointer editable)
+{
+#if GTK_CHECK_VERSION(4,0,0)
+ return gtk_editable_get_text (GTK_EDITABLE (editable));
+#else
+ return gtk_entry_get_text (GTK_ENTRY (editable));
+#endif
+}
diff --git a/src/ka-tools.h b/src/ka-tools.h
index a4992ed..4f98938 100644
--- a/src/ka-tools.h
+++ b/src/ka-tools.h
@@ -29,6 +29,10 @@ void ka_show_help (GtkWindow* window, const char* section);
void ka_show_about (KaApplet *applet);
void ka_window_destroy (gpointer window);
+/* To ease GTK4 migration */
+void ka_editable_set_text (gpointer editable, const char *text);
+const char *ka_editable_get_text (gpointer editable);
+
G_END_DECLS
#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]