Set background color to white only on Windows
authorDan Breslau <dbreslau@painless-security.com>
Fri, 7 Oct 2016 03:10:30 +0000 (23:10 -0400)
committerDan Breslau <dbreslau@painless-security.com>
Fri, 7 Oct 2016 03:10:30 +0000 (23:10 -0400)
src/moonshot-identity-dialog.vala
src/moonshot-identity-management-view.vala
src/moonshot-password-dialog.vala
src/moonshot-trust-anchor-dialog.vala
src/moonshot-utils.vala
src/moonshot-warning-dialog.vala

index 2213f9b..315f586 100644 (file)
@@ -196,7 +196,7 @@ class IdentityDialog : Dialog
 
         this.set_border_width(6);
         this.set_resizable(false);
-        this.modify_bg(StateType.NORMAL, white);
+        set_bg_color(this);
         this.show_all();
     }
 
@@ -370,7 +370,7 @@ class IdentityDialog : Dialog
         var services_table = new Table(card.services.size, 1, false);
         services_table.set_row_spacings(1);
         services_table.set_col_spacings(0);
-        services_table.modify_bg(StateType.NORMAL, white);
+        set_bg_color(services_table);
 
         var table_button_hbox = new HBox(false, 6);
         table_button_hbox.pack_start(services_vscroll, true, true, 4);
@@ -383,7 +383,7 @@ class IdentityDialog : Dialog
         // A table doesn't have a background color, so put it in an EventBox, and
         // set the EventBox's background color instead.
         EventBox table_bg = new EventBox();
-        table_bg.modify_bg(StateType.NORMAL, white);
+        set_bg_color(table_bg);
         table_bg.add(services_table);
         services_vbox_alignment.add(table_bg);
 
index f67a1af..1185487 100644 (file)
@@ -634,7 +634,7 @@ SUCH DAMAGE.
         about.set_modal(true);
         about.set_transient_for(this);
         about.response.connect((a, b) => {about.destroy();});
-        about.modify_bg(StateType.NORMAL, white);
+        set_bg_color(about);
         
         about.run();
     }
@@ -682,8 +682,7 @@ SUCH DAMAGE.
 
     private void build_ui()
     {
-        // Note: On Debian7/Gtk+2, the menu bar remains gray. This doesn't happen on Debian8/Gtk+3.
-        this.modify_bg(StateType.NORMAL, white);
+        set_bg_color(this);
 
         create_ui_manager();
 
@@ -791,7 +790,6 @@ SUCH DAMAGE.
 //        quit_item.hide();
         
         Gtk.MenuShell menushell = this.ui_manager.get_widget("/MenuBar") as Gtk.MenuShell;
-        menushell.modify_bg(StateType.NORMAL, white);
 
         osxApp.set_menu_bar(menushell);
         osxApp.set_use_quartz_accelerators(true);
@@ -800,7 +798,7 @@ SUCH DAMAGE.
 #else
         var menubar = this.ui_manager.get_widget("/MenuBar");
         main_vbox.pack_start(menubar, false, false, 0);
-        menubar.modify_bg(StateType.NORMAL, white);
+        set_bg_color(menubar);
 #endif
         main_vbox.pack_start(top_table, true, true, 6);
 
index 52e8c5a..15f3fa6 100644 (file)
@@ -50,7 +50,7 @@ class AddPasswordDialog : Dialog
     {
         this.set_title(_("Moonshot - Password"));
         this.set_modal(true);
-        this.modify_bg(StateType.NORMAL, white);
+        set_bg_color(this);
 
         this.add_buttons(_("Cancel"), ResponseType.CANCEL,
                          _("Connect"), ResponseType.OK);
@@ -59,7 +59,7 @@ class AddPasswordDialog : Dialog
 
         var content_area = this.get_content_area();
         ((Box) content_area).set_spacing(12);
-        content_area.modify_bg(StateType.NORMAL, white);
+        set_bg_color(content_area);
 
         Label dialog_label = new Label(_("Enter the password for " + id_card.display_name));
         dialog_label.set_alignment(0, 0);
index 7c1ea3e..28169d2 100644 (file)
@@ -139,7 +139,7 @@ class TrustAnchorDialog : Dialog
         this.set_title(_("Trust Anchor"));
         this.set_modal(true);
 //        this.set_transient_for(parent);
-        this.modify_bg(StateType.NORMAL, white);
+        set_bg_color(this);
 
         this.add_buttons(_("Cancel"), ResponseType.CANCEL,
                          _("Confirm"), ResponseType.OK);
@@ -148,7 +148,7 @@ class TrustAnchorDialog : Dialog
 
         var content_area = this.get_content_area();
         ((Box) content_area).set_spacing(12);
-        content_area.modify_bg(StateType.NORMAL, white);
+        set_bg_color(content_area);
 
         Label dialog_label = new Label("");
         dialog_label.set_alignment(0, 0);
index e26b881..156263a 100644 (file)
@@ -173,3 +173,17 @@ internal static string colonize(string input, int bytes_per_line) {
     }
     return result;
 }
+
+static Gdk.Color white;
+static void set_bg_color(Widget w)
+{
+#if OS_WIN32
+
+    if (white == null) {
+        white = make_color(65535, 65535, 65535);
+    }
+
+    w.modify_bg(StateType.NORMAL, white);
+
+#endif
+}
index 72233a4..43f7aa3 100644 (file)
@@ -98,10 +98,10 @@ class WarningDialog
 
         // dialog.set_modal(true);
         dialog.set_title(_("Warning"));
-        dialog.modify_bg(StateType.NORMAL, white);
+        set_bg_color(dialog);
 
         // ((Box) content_area).set_spacing(12);
-        content_area.modify_bg(StateType.NORMAL, white);
+        set_bg_color(content_area);
 
         content_area.show_all();