[gnome-commander] Made password input dialog returning a const string, bgo#653573



commit 00e1e0e0441cc94e60cd588e13289ad88f85fbcf
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Sun Apr 26 22:18:09 2015 +0200

    Made password input dialog returning a const string, bgo#653573

 src/gnome-cmd-con.cc       |   21 ++++++---------------
 src/gnome-cmd-con.h        |    3 ++-
 src/gnome-cmd-file-list.cc |    3 +--
 3 files changed, 9 insertions(+), 18 deletions(-)
---
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index 77eddbe..9b105ac 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -618,14 +618,14 @@ GnomeKeyringAttributeList *gnome_cmd_con_create_keyring_attributes (const gchar
     return attributes;
 }
 
-static void response_callback (GtkDialog *dialog, int response_id, std::string &password)
+void response_callback (GtkDialog *dialog, int response_id, std::string *password)
 {
     switch (response_id)
     {
         case GTK_RESPONSE_OK:
        {
            const gchar *entry = gtk_entry_get_text (GTK_ENTRY (lookup_widget (GTK_WIDGET (dialog), 
"password")));
-           password.assign(entry);
+           password->assign(entry);
        }
             break;
 
@@ -639,18 +639,12 @@ static void response_callback (GtkDialog *dialog, int response_id, std::string &
     }
 }
 
-const char* enter_callback( GtkWidget *widget, GtkWidget *entry )
-{
-    const gchar *entry_text;
-    entry_text = gtk_entry_get_text (GTK_ENTRY (entry));
-    return entry_text;
-}
-
 /**
  * A small dialog for setting the password
  */
-int GnomeCmdCon::gnome_cmd_con_set_password(std::string *password)
+const std::string* GnomeCmdCon::gnome_cmd_con_set_password()
 {
+    std::string password;
     GtkWidget *table;
     GtkWidget *entry;
     GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
@@ -659,7 +653,6 @@ int GnomeCmdCon::gnome_cmd_con_set_password(std::string *password)
                                                      GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                                      GTK_STOCK_OK, GTK_RESPONSE_OK,
                                                      NULL);
-    //essentially, the following was copied from gnome_cmd_mkdir_dialog_new()
 #if GTK_CHECK_VERSION (2, 14, 0)
     GtkWidget *content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
 #endif
@@ -702,13 +695,11 @@ int GnomeCmdCon::gnome_cmd_con_set_password(std::string *password)
 
     gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
 
-    g_signal_connect (dialog, "response", G_CALLBACK (response_callback), password);
-    
-    g_signal_connect (G_OBJECT (entry), "activate", G_CALLBACK (enter_callback), (gpointer) entry);
+    g_signal_connect (dialog, "response", G_CALLBACK (response_callback), &password);
     
     gint result = gtk_dialog_run (GTK_DIALOG (dialog));
 
     gtk_widget_destroy (dialog);
 
-    return result==GTK_RESPONSE_OK;
+    return &password;
 }
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index 0ee052a..d203724 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -121,7 +121,8 @@ struct GnomeCmdCon
     GnomeKeyringAttributeList *create_keyring_attributes();
 
     friend XML::xstream &operator << (XML::xstream &xml, GnomeCmdCon &con);
-    int gnome_cmd_con_set_password(std::string *password);
+    const std::string   *password;
+    const std::string   *gnome_cmd_con_set_password();
 };
 
 struct GnomeCmdConClass
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index f943824..1ca4d41 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -2516,10 +2516,9 @@ void GnomeCmdFileList::set_connection (GnomeCmdCon *new_con, GnomeCmdDir *start_
         g_signal_connect (new_con, "open-failed", G_CALLBACK (on_con_open_failed), this);
         priv->con_opening = new_con;
 
-       std::string password;
        if (new_con->auth != GnomeCmdCon::NOT_REQUIRED)
        {
-           new_con->gnome_cmd_con_set_password(&password);
+           new_con->password = new_con->gnome_cmd_con_set_password(); //TODO: password should be a private 
member variable of GnomeCmdCon someday!
        }
         create_con_open_progress_dialog (this);
         g_timeout_add (gnome_cmd_data.gui_update_rate, (GSourceFunc) update_con_open_progress, this);


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