Changeset 173560 in webkit


Ignore:
Timestamp:
Sep 12, 2014 8:59:12 AM (10 years ago)
Author:
commit-queue@webkit.org
Message:

[GTK] Use a nicer HTTP authentication dialog
https://bugs.webkit.org/show_bug.cgi?id=136615

Patch by Michael Catanzaro <Michael Catanzaro> on 2014-09-12
Reviewed by Carlos Garcia Campos.

  • UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:

(webkitAuthenticationDialogInitialize): Use a nicer layout.
(packTwoColumnLayoutInBox): Deleted.
(createLabel): Deleted.
(createEntry): Deleted.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r173558 r173560  
     12014-09-12  Michael Catanzaro  <mcatanzaro@igalia.com>
     2
     3        [GTK] Use a nicer HTTP authentication dialog
     4        https://bugs.webkit.org/show_bug.cgi?id=136615
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * UIProcess/API/gtk/WebKitAuthenticationDialog.cpp:
     9        (webkitAuthenticationDialogInitialize): Use a nicer layout.
     10        (packTwoColumnLayoutInBox): Deleted.
     11        (createLabel): Deleted.
     12        (createEntry): Deleted.
     13
    1142014-09-12  Carlos Garcia Campos  <cgarcia@igalia.com>
    215
  • trunk/Source/WebKit2/UIProcess/API/gtk/WebKitAuthenticationDialog.cpp

    r173510 r173560  
    7272}
    7373
    74 static void packTwoColumnLayoutInBox(GtkWidget* box, ...)
    75 {
    76     va_list argumentList;
    77     va_start(argumentList, box);
    78 
    79     GtkWidget* grid = gtk_grid_new();
    80     gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
    81     gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
    82     gtk_grid_set_column_homogeneous(GTK_GRID(grid), TRUE);
    83 
    84     GtkWidget* firstColumnWidget = va_arg(argumentList, GtkWidget*);
    85     int rowNumber = 0;
    86     while (firstColumnWidget) {
    87         GtkWidget* secondColumnWidget = va_arg(argumentList, GtkWidget*);
    88         int firstWidgetWidth = secondColumnWidget ? 1 : 2;
    89 
    90         gtk_grid_attach(GTK_GRID(grid), firstColumnWidget, 0, rowNumber, firstWidgetWidth, 1);
    91         gtk_widget_set_hexpand(firstColumnWidget, TRUE);
    92         gtk_widget_set_vexpand(firstColumnWidget, TRUE);
    93         gtk_widget_show(firstColumnWidget);
    94 
    95         if (secondColumnWidget) {
    96             gtk_grid_attach(GTK_GRID(grid), secondColumnWidget, 1, rowNumber, 1, 1);
    97             gtk_widget_set_hexpand(secondColumnWidget, TRUE);
    98             gtk_widget_set_vexpand(secondColumnWidget, TRUE);
    99             gtk_widget_show(secondColumnWidget);
    100         }
    101 
    102         firstColumnWidget = va_arg(argumentList, GtkWidget*);
    103         rowNumber++;
    104     }
    105 
    106     va_end(argumentList);
    107 
    108     gtk_box_pack_start(GTK_BOX(box), grid, FALSE, FALSE, 0);
    109     gtk_widget_show(grid);
    110 }
    111 
    112 static GtkWidget* createLabel(const char* labelString, int horizontalPadding = 0)
    113 {
    114     GtkWidget* label = gtk_label_new(labelString);
     74static GtkWidget* createLabelWithLineWrap(const char* text)
     75{
     76    GtkWidget* label = gtk_label_new(text);
    11577    gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
    116     if (horizontalPadding)
    117         gtk_misc_set_padding(GTK_MISC(label), 0, horizontalPadding);
     78    gtk_label_set_line_wrap(GTK_LABEL(label), TRUE);
     79    gtk_label_set_max_width_chars(GTK_LABEL(label), 40);
    11880    return label;
    119 }
    120 
    121 static GtkWidget* createEntry(GtkWidget** member)
    122 {
    123     *member = gtk_entry_new();
    124     gtk_entry_set_activates_default(GTK_ENTRY(*member), TRUE);
    125     return *member;
    12681}
    12782
     
    13287
    13388    GtkWidget* vBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 6);
    134     gtk_container_set_border_width(GTK_CONTAINER(vBox), 5);
     89    gtk_container_set_border_width(GTK_CONTAINER(vBox), 12);
    13590
    13691    GtkWidget* buttonBox = gtk_button_box_new(GTK_ORIENTATION_HORIZONTAL);
     
    152107    gtk_widget_show(button);
    153108
    154     GtkWidget* authBox = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 12);
     109    GtkWidget* authBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 12);
    155110    gtk_container_set_border_width(GTK_CONTAINER(authBox), 5);
    156111
    157     GtkWidget* icon = gtk_image_new_from_stock(GTK_STOCK_DIALOG_AUTHENTICATION, GTK_ICON_SIZE_DIALOG);
    158     gtk_misc_set_alignment(GTK_MISC(icon), 0.5, 0.0);
    159     gtk_box_pack_start(GTK_BOX(authBox), icon, FALSE, FALSE, 0);
    160     gtk_widget_show(icon);
    161 
    162112    const WebCore::AuthenticationChallenge& challenge = webkitAuthenticationRequestGetAuthenticationChallenge(priv->request.get())->core();
     113    // Prompt on the HTTP authentication dialog.
    163114    GUniquePtr<char> prompt(g_strdup_printf(_("The site %s:%i requests a username and password"),
    164115        challenge.protectionSpace().host().utf8().data(), challenge.protectionSpace().port()));
     116    GtkWidget* label = createLabelWithLineWrap(prompt.get());
     117    gtk_widget_show(label);
     118    gtk_box_pack_start(GTK_BOX(authBox), label, FALSE, FALSE, 0);
     119
     120    String realm = challenge.protectionSpace().realm();
     121    if (!realm.isEmpty()) {
     122        GUniquePtr<char> message(g_strdup_printf("%s “%s”", _("Server message:"), realm.utf8().data()));
     123        label = createLabelWithLineWrap(message.get());
     124        gtk_widget_show(label);
     125        gtk_box_pack_start(GTK_BOX(authBox), label, FALSE, FALSE, 0);
     126    }
     127
     128    // Check button on the HTTP authentication dialog.
    165129    priv->rememberCheckButton = gtk_check_button_new_with_mnemonic(_("_Remember password"));
    166130    gtk_label_set_line_wrap(GTK_LABEL(gtk_bin_get_child(GTK_BIN(priv->rememberCheckButton))), TRUE);
    167131
    168     String realm = challenge.protectionSpace().realm();
    169     if (!realm.isEmpty()) {
    170         packTwoColumnLayoutInBox(
    171             authBox,
    172             createLabel(prompt.get(), 6), nullptr,
    173             createLabel(_("Server message:")), createLabel(realm.utf8().data()),
    174             createLabel(_("Username:")), createEntry(&priv->loginEntry),
    175             createLabel(_("Password:")), createEntry(&priv->passwordEntry),
    176             priv->rememberCheckButton, nullptr,
    177             nullptr);
    178 
    179     } else {
    180         packTwoColumnLayoutInBox(
    181             authBox,
    182             createLabel(prompt.get(), 6), nullptr,
    183             createLabel(_("Username:")), createEntry(&priv->loginEntry),
    184             createLabel(_("Password:")), createEntry(&priv->passwordEntry),
    185             priv->rememberCheckButton, nullptr, nullptr,
    186             nullptr);
    187     }
     132    // Entry on the HTTP authentication dialog.
     133    GtkWidget* loginLabel = gtk_label_new(_("Username:"));
     134    gtk_widget_set_halign(loginLabel, GTK_ALIGN_END);
     135    gtk_style_context_add_class(gtk_widget_get_style_context(loginLabel), GTK_STYLE_CLASS_DIM_LABEL);
     136    gtk_widget_show(loginLabel);
     137
     138    priv->loginEntry = gtk_entry_new();
     139    gtk_widget_set_hexpand(priv->loginEntry, TRUE);
     140    gtk_entry_set_activates_default(GTK_ENTRY(priv->loginEntry), TRUE);
     141    gtk_widget_show(priv->loginEntry);
     142
     143    // Entry on the HTTP authentication dialog.
     144    GtkWidget* passwordLabel = gtk_label_new(_("Password:"));
     145    gtk_widget_set_halign(passwordLabel, GTK_ALIGN_END);
     146    gtk_style_context_add_class(gtk_widget_get_style_context(passwordLabel), GTK_STYLE_CLASS_DIM_LABEL);
     147    gtk_widget_show(passwordLabel);
     148
     149    priv->passwordEntry = gtk_entry_new();
     150    gtk_widget_set_hexpand(priv->passwordEntry, TRUE);
     151    gtk_entry_set_activates_default(GTK_ENTRY(priv->passwordEntry), TRUE);
     152    gtk_widget_show(priv->passwordEntry);
     153
     154    GtkWidget* grid = gtk_grid_new();
     155    gtk_grid_set_column_spacing(GTK_GRID(grid), 6);
     156    gtk_grid_set_row_spacing(GTK_GRID(grid), 6);
     157    gtk_grid_attach(GTK_GRID(grid), loginLabel, 0, 0, 1, 1);
     158    gtk_grid_attach(GTK_GRID(grid), priv->loginEntry, 1, 0, 1, 1);
     159    gtk_grid_attach(GTK_GRID(grid), passwordLabel, 0, 1, 1, 1);
     160    gtk_grid_attach(GTK_GRID(grid), priv->passwordEntry, 1, 1, 1, 1);
     161    gtk_grid_attach(GTK_GRID(grid), priv->rememberCheckButton, 1, 2, 1, 1);
     162    gtk_widget_show(grid);
     163    gtk_box_pack_start(GTK_BOX(authBox), grid, FALSE, FALSE, 0);
     164
    188165    gtk_entry_set_visibility(GTK_ENTRY(priv->passwordEntry), FALSE);
    189166    gtk_widget_set_visible(priv->rememberCheckButton, priv->credentialStorageMode != DisallowPersistentStorage);
Note: See TracChangeset for help on using the changeset viewer.