2005-12-02 [paul] 1.9.100cvs55
[claws.git] / src / plugins / pgpcore / passphrase.c
index 913b0ba7d97e5f56b67634435308246228b8c6fb..6935c2277dfff8b9050b267008dd042a6bc59e33 100644 (file)
@@ -13,7 +13,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -50,6 +50,8 @@
 #include "prefs_gpg.h"
 #include "manage_window.h"
 #include "utils.h"
+#include "mainwindow.h"
+#include "summaryview.h"
 
 static gboolean grab_all = FALSE;
 
@@ -78,13 +80,17 @@ static gchar*
 passphrase_mbox(const gchar *uid_hint, const gchar *pass_hint, gint prev_bad)
 {
     gchar *the_passphrase = NULL;
-    GtkWidget *vbox;
+    GtkWidget *vbox, *hbox;
     GtkWidget *confirm_box;
     GtkWidget *window;
     GtkWidget *pass_entry;
     GtkWidget *ok_button;
     GtkWidget *cancel_button;
 
+    SummaryView *summaryview = mainwindow_get_mainwindow()->summaryview;
+    
+    gtk_menu_popdown(GTK_MENU(summaryview->popupmenu));
+
     window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
     gtk_window_set_title(GTK_WINDOW(window), _("Passphrase"));
     gtk_widget_set_size_request(window, 450, -1);
@@ -103,9 +109,17 @@ passphrase_mbox(const gchar *uid_hint, const gchar *pass_hint, gint prev_bad)
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 8);
 
     if (uid_hint || pass_hint) {
-        GtkWidget *label;
+        GtkWidget *label, *icon;
         label = create_description (uid_hint, pass_hint, prev_bad);
-        gtk_box_pack_start (GTK_BOX(vbox), label, FALSE, FALSE, 0);
+       icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION,
+                               GTK_ICON_SIZE_DIALOG); 
+
+       hbox = gtk_hbox_new (FALSE, 12);
+       gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+       gtk_widget_show (hbox);
+        gtk_box_pack_start (GTK_BOX(hbox), icon, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX(hbox), label, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
     }
 
     pass_entry = gtk_entry_new();
@@ -136,23 +150,20 @@ passphrase_mbox(const gchar *uid_hint, const gchar *pass_hint, gint prev_bad)
         int err = 0, cnt = 0;
         /* make sure that window is viewable */
         gtk_widget_show_now(window);
+       gdk_window_process_updates(window->window, TRUE);
        gdk_flush();
-       while(gtk_events_pending())
+       while(gtk_events_pending()) {
                gtk_main_iteration();
-#ifdef GDK_WINDOWING_X11
-       gdk_x11_display_grab(gdk_display_get_default());
-#endif /* GDK_WINDOWING_X11 */
+       }
 try_again:
         if ((err = gdk_pointer_grab(window->window, TRUE, 0,
                              window->window, NULL, GDK_CURRENT_TIME))) {
            if (err == GDK_GRAB_NOT_VIEWABLE && cnt < 10) {
                cnt++;
                g_warning("trying to grab mouse again\n");
+               gtk_main_iteration();
                goto try_again;
             } else {
-#ifdef GDK_WINDOWING_X11
-                gdk_x11_display_ungrab(gdk_display_get_default());
-#endif /* GDK_WINDOWING_X11 */
                 g_warning("OOPS: Could not grab mouse\n");
                 gtk_widget_destroy(window);
                 return NULL;
@@ -161,9 +172,6 @@ try_again:
         if (gdk_keyboard_grab(window->window, FALSE, GDK_CURRENT_TIME)) {
             gdk_display_pointer_ungrab(gdk_display_get_default(),
                                       GDK_CURRENT_TIME);
-#ifdef GDK_WINDOWING_X11
-            gdk_x11_display_ungrab(gdk_display_get_default());
-#endif /* GDK_WINDOWING_X11 */
             g_warning("OOPS: Could not grab keyboard\n");
             gtk_widget_destroy(window);
             return NULL;
@@ -176,9 +184,6 @@ try_again:
         gdk_display_keyboard_ungrab(gdk_display_get_default(),
                                    GDK_CURRENT_TIME);
         gdk_display_pointer_ungrab(gdk_display_get_default(), GDK_CURRENT_TIME);
-#ifdef GDK_WINDOWING_X11
-        gdk_x11_display_ungrab(gdk_display_get_default());
-#endif /* GDK_WINDOWING_X11 */
         gdk_flush();
     }
 
@@ -244,7 +249,7 @@ create_description(const gchar *uid_hint, const gchar *pass_hint, gint prev_bad)
     const gchar *uid = NULL, *info = NULL;
     gchar *buf;
     GtkWidget *label;
-
+    gchar *my_uid = NULL;
     if (!uid_hint)
         uid = _("[no user id]");
     else
@@ -254,14 +259,20 @@ create_description(const gchar *uid_hint, const gchar *pass_hint, gint prev_bad)
     else
         info = pass_hint;
 
-    buf = g_strdup_printf (_("%sPlease enter the passphrase for:\n\n"
-                           "  %.*s  \n"
-                           "(%.*s)\n"),
-                           prev_bad ?
-                           _("Bad passphrase! Try again...\n\n") : "",
-                           linelen (uid), uid, linelen (info), info);
+    my_uid = g_strdup(uid);
+    while (strchr(my_uid, '<')) 
+       *(strchr(my_uid, '<')) = '(';
+    while (strchr(my_uid, '>')) 
+       *(strchr(my_uid, '>')) = ')';
 
+    buf = g_strdup_printf (_("<span weight=\"bold\" size=\"larger\">%sPlease enter the passphrase for:</span>\n\n"
+                           "%.*s\n"),
+                           prev_bad ?
+                           _("Bad passphrase.\n") : "",
+                           linelen (my_uid), my_uid);
+    g_free(my_uid);
     label = gtk_label_new (buf);
+    gtk_label_set_use_markup(GTK_LABEL (label), TRUE);
     gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_LEFT);
     g_free (buf);
 
@@ -320,7 +331,7 @@ gpgmegtk_passphrase_cb(void *opaque, const char *uid_hint,
 
 void gpgmegtk_free_passphrase()
 {
-    (void)free_passphrase(NULL); // could be inline
+    (void)free_passphrase(NULL); /* could be inline */
 }
 
 #endif /* USE_GPGME */