[gnome-software: 34/110] Replace GtkEntry APIs with GtkEditable's counterparts




commit ad653c720575fab0a9872792161b4dacf626030f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Sun Aug 22 22:25:10 2021 -0300

    Replace GtkEntry APIs with GtkEditable's counterparts

 src/gs-basic-auth-dialog.c | 8 ++++----
 src/gs-review-dialog.c     | 8 +++++---
 src/gs-shell.c             | 6 +++---
 3 files changed, 12 insertions(+), 10 deletions(-)
---
diff --git a/src/gs-basic-auth-dialog.c b/src/gs-basic-auth-dialog.c
index 4c3f0b003..cff85845c 100644
--- a/src/gs-basic-auth-dialog.c
+++ b/src/gs-basic-auth-dialog.c
@@ -45,8 +45,8 @@ login_button_clicked_cb (GsBasicAuthDialog *dialog)
        const gchar *user;
        const gchar *password;
 
-       user = gtk_entry_get_text (dialog->user_entry);
-       password = gtk_entry_get_text (dialog->password_entry);
+       user = gtk_editable_get_text (GTK_EDITABLE (dialog->user_entry));
+       password = gtk_editable_get_text (GTK_EDITABLE (dialog->password_entry));
 
        /* submit the user/password to basic auth */
        dialog->callback (user, password, dialog->callback_data);
@@ -63,11 +63,11 @@ dialog_validate (GsBasicAuthDialog *dialog)
        gboolean valid_password;
 
        /* require user */
-       user = gtk_entry_get_text (dialog->user_entry);
+       user = gtk_editable_get_text (GTK_EDITABLE (dialog->user_entry));
        valid_user = user != NULL && strlen (user) != 0;
 
        /* require password */
-       password = gtk_entry_get_text (dialog->password_entry);
+       password = gtk_editable_get_text (GTK_EDITABLE (dialog->password_entry));
        valid_password = password != NULL && strlen (password) != 0;
 
        gtk_widget_set_sensitive (GTK_WIDGET (dialog->login_button), valid_user && valid_password);
diff --git a/src/gs-review-dialog.c b/src/gs-review-dialog.c
index 686209e3f..8446f0568 100644
--- a/src/gs-review-dialog.c
+++ b/src/gs-review-dialog.c
@@ -53,7 +53,7 @@ gs_review_dialog_set_rating (GsReviewDialog *dialog, gint rating)
 const gchar *
 gs_review_dialog_get_summary (GsReviewDialog *dialog)
 {
-       return gtk_entry_get_text (GTK_ENTRY (dialog->summary_entry));
+       return gtk_editable_get_text (GTK_EDITABLE (dialog->summary_entry));
 }
 
 gchar *
@@ -109,12 +109,14 @@ gs_review_dialog_changed_cb (GsReviewDialog *dialog)
        GtkTextBuffer *buffer;
        gboolean all_okay = TRUE;
        const gchar *msg = NULL;
+       glong summary_length;
 
        /* update review text */
        gs_review_dialog_update_review_comment (dialog);
 
        /* require rating, summary and long review */
        buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (dialog->text_view));
+       summary_length = g_utf8_strlen (gtk_editable_get_text (GTK_EDITABLE (dialog->summary_entry)), -1);
        if (dialog->timer_id != 0) {
                /* TRANSLATORS: the review can't just be copied and pasted */
                msg = _("Please take more time writing the review");
@@ -123,11 +125,11 @@ gs_review_dialog_changed_cb (GsReviewDialog *dialog)
                /* TRANSLATORS: the review is not acceptable */
                msg = _("Please choose a star rating");
                all_okay = FALSE;
-       } else if (gtk_entry_get_text_length (GTK_ENTRY (dialog->summary_entry)) < SUMMARY_LENGTH_MIN) {
+       } else if (summary_length < SUMMARY_LENGTH_MIN) {
                /* TRANSLATORS: the review is not acceptable */
                msg = _("The summary is too short");
                all_okay = FALSE;
-       } else if (gtk_entry_get_text_length (GTK_ENTRY (dialog->summary_entry)) > SUMMARY_LENGTH_MAX) {
+       } else if (summary_length > SUMMARY_LENGTH_MAX) {
                /* TRANSLATORS: the review is not acceptable */
                msg = _("The summary is too long");
                all_okay = FALSE;
diff --git a/src/gs-shell.c b/src/gs-shell.c
index 0d0de233e..75830debe 100644
--- a/src/gs-shell.c
+++ b/src/gs-shell.c
@@ -613,7 +613,7 @@ gs_shell_change_mode (GsShell *shell,
 
        if (mode == GS_SHELL_MODE_SEARCH) {
                gs_search_page_set_text (GS_SEARCH_PAGE (page), data);
-               gtk_entry_set_text (GTK_ENTRY (shell->entry_search), data);
+               gtk_editable_set_text (GTK_EDITABLE (shell->entry_search), data);
                gtk_editable_set_position (GTK_EDITABLE (shell->entry_search), -1);
        } else if (mode == GS_SHELL_MODE_DETAILS) {
                app = GS_APP (data);
@@ -802,7 +802,7 @@ gs_shell_go_back (GsShell *shell)
 
                /* set the text in the entry and move cursor to the end */
                block_changed_signal (GTK_SEARCH_ENTRY (shell->entry_search));
-               gtk_entry_set_text (GTK_ENTRY (shell->entry_search), entry->search);
+               gtk_editable_set_text (GTK_EDITABLE (shell->entry_search), entry->search);
                gtk_editable_set_position (GTK_EDITABLE (shell->entry_search), -1);
                unblock_changed_signal (GTK_SEARCH_ENTRY (shell->entry_search));
 
@@ -947,7 +947,7 @@ search_changed_handler (GObject *entry, GsShell *shell)
 {
        const gchar *text;
 
-       text = gtk_entry_get_text (GTK_ENTRY (entry));
+       text = gtk_editable_get_text (GTK_EDITABLE (entry));
        if (strlen (text) >= 2) {
                if (gs_shell_get_mode (shell) != GS_SHELL_MODE_SEARCH) {
                        save_back_entry (shell);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]