Bug 545506 - Fix the custom header/footer dialog in GTK's print dialog r=roc
authorMichael Ventnor <mventnor@mozilla.com>
Fri, 12 Feb 2010 11:40:03 +1300
changeset 38089 6f676b618380fae9de7641ce1c0af84f5eaa45d8
parent 38088 e9d0fbad2ddfc44234ac338cf48cfa7dc9c5a883
child 38091 f12473882d84252401d963ec0a2898f79274559e
push id11615
push usermventnor@mozilla.com
push dateThu, 11 Feb 2010 22:50:19 +0000
treeherdermozilla-central@6f676b618380 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs545506
milestone1.9.3a2pre
Bug 545506 - Fix the custom header/footer dialog in GTK's print dialog r=roc
widget/src/gtk2/nsPrintDialogGTK.cpp
--- a/widget/src/gtk2/nsPrintDialogGTK.cpp
+++ b/widget/src/gtk2/nsPrintDialogGTK.cpp
@@ -126,26 +126,27 @@ get_gtk_window_for_nsiwidget(nsIWidget *
 static void
 ShowCustomDialog(GtkComboBox *changed_box, gpointer user_data)
 {
   if (gtk_combo_box_get_active(changed_box) != CUSTOM_VALUE_INDEX) {
     g_object_set_data(G_OBJECT(changed_box), "previous-active", GINT_TO_POINTER(gtk_combo_box_get_active(changed_box)));
     return;
   }
 
+  GtkWindow* printDialog = GTK_WINDOW(user_data);
   nsCOMPtr<nsIStringBundleService> bundleSvc =
        do_GetService(NS_STRINGBUNDLE_CONTRACTID);
 
   nsCOMPtr<nsIStringBundle> printBundle;
   bundleSvc->CreateBundle("chrome://global/locale/printdialog.properties", getter_AddRefs(printBundle));
   nsXPIDLString intlString;
 
   printBundle->GetStringFromName(NS_LITERAL_STRING("headerFooterCustom").get(), getter_Copies(intlString));
-  GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), NULL,
-                                                         GTK_DIALOG_MODAL,
+  GtkWidget* prompt_dialog = gtk_dialog_new_with_buttons(NS_ConvertUTF16toUTF8(intlString).get(), printDialog,
+                                                         (GtkDialogFlags)(GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR),
                                                          GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT,
                                                          GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
                                                          NULL);
   gtk_dialog_set_default_response(GTK_DIALOG(prompt_dialog), GTK_RESPONSE_ACCEPT);
   gtk_dialog_set_alternative_button_order(GTK_DIALOG(prompt_dialog),
                                           GTK_RESPONSE_ACCEPT,
                                           GTK_RESPONSE_REJECT,
                                           -1);
@@ -157,16 +158,17 @@ ShowCustomDialog(GtkComboBox *changed_bo
 
   // To be convenient, prefill the textbox with the existing value, if any, and select it all so they can easily
   // both edit it and type in a new one.
   const char* current_text = (const char*) g_object_get_data(G_OBJECT(changed_box), "custom-text");
   if (current_text) {
     gtk_entry_set_text(GTK_ENTRY(custom_entry), current_text);
     gtk_editable_select_region(GTK_EDITABLE(custom_entry), 0, -1);
   }
+  gtk_entry_set_activates_default(GTK_ENTRY(custom_entry), TRUE);
 
   GtkWidget* custom_vbox = gtk_vbox_new(TRUE, 2);
   gtk_box_pack_start(GTK_BOX(custom_vbox), custom_label, FALSE, FALSE, 0);
   gtk_box_pack_start(GTK_BOX(custom_vbox), custom_entry, FALSE, FALSE, 5); // Make entry 5px underneath label
   GtkWidget* custom_hbox = gtk_hbox_new(FALSE, 2);
   gtk_box_pack_start(GTK_BOX(custom_hbox), question_icon, FALSE, FALSE, 0);
   gtk_box_pack_start(GTK_BOX(custom_hbox), custom_vbox, FALSE, FALSE, 10); // Make question icon 10px away from content
   gtk_container_set_border_width(GTK_CONTAINER(custom_hbox), 2);
@@ -562,17 +564,17 @@ nsPrintDialogWidgetGTK::ConstructHeaderF
 
   if (shouldBeCustom) {
     gtk_combo_box_set_active(GTK_COMBO_BOX(dropdown), CUSTOM_VALUE_INDEX);
     g_object_set_data(G_OBJECT(dropdown), "previous-active", GINT_TO_POINTER(CUSTOM_VALUE_INDEX));
     char* custom_string = strdup(currentStringUTF8.get());
     g_object_set_data_full(G_OBJECT(dropdown), "custom-text", custom_string, (GDestroyNotify) free);
   }
 
-  g_signal_connect(dropdown, "changed", (GCallback) ShowCustomDialog, NULL);
+  g_signal_connect(dropdown, "changed", (GCallback) ShowCustomDialog, dialog);
   return dropdown;
 }
 
 NS_IMPL_ISUPPORTS1(nsPrintDialogServiceGTK, nsIPrintDialogService)
 
 nsPrintDialogServiceGTK::nsPrintDialogServiceGTK()
 {
 }