chiark / gitweb /
Fix defect 16 (GTK assertion due to config->password being NULL).
[disorder] / disobedience / login.c
index e53e9473f90e7075d5ca861719c641a2fc004b3a..8dc8f0af9a73e234ff73e5b49d23530cd2e6073a 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * This file is part of DisOrder
- * Copyright (C) 2007 Richard Kettlewell
+ * Copyright (C) 2007, 2008 Richard Kettlewell
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -66,7 +66,7 @@ static void default_connect(void) {
 static const char *get_hostname(void) { return config->connect.s[0]; }
 static const char *get_service(void) { return config->connect.s[1]; }
 static const char *get_username(void) { return config->username; }
-static const char *get_password(void) { return config->password; }
+static const char *get_password(void) { return config->password ? config->password : ""; }
 
 static void set_hostname(const char *s) { config->connect.s[0] = (char *)s; }
 static void set_service(const char *s) { config->connect.s[1] = (char *)s; }
@@ -215,16 +215,16 @@ void login_box(void) {
   default_connect();
   /* Create a new login window */
   login_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-  gtk_widget_modify_bg(login_window, GTK_STATE_NORMAL, &tool_bg);
+  gtk_widget_set_style(login_window, tool_style);
   g_signal_connect(login_window, "destroy",
                   G_CALLBACK(gtk_widget_destroyed), &login_window);
   gtk_window_set_title(GTK_WINDOW(login_window), "Login Details");
   /* Construct the form */
   table = gtk_table_new(NLWIS + 1/*rows*/, 2/*columns*/, FALSE/*homogenous*/);
-  gtk_widget_modify_bg(table, GTK_STATE_NORMAL, &tool_bg);
+  gtk_widget_set_style(table, tool_style);
   for(n = 0; n < NLWIS; ++n) {
     label = gtk_label_new(lwis[n].description);
-    gtk_widget_modify_fg(table, GTK_STATE_NORMAL, &tool_fg);
+    gtk_widget_set_style(label, tool_style);
     gtk_misc_set_alignment(GTK_MISC(label), 1/*right*/, 0/*bottom*/);
     gtk_table_attach(GTK_TABLE(table), label,
                     0, 1,              /* left/right_attach */
@@ -232,6 +232,7 @@ void login_box(void) {
                     GTK_FILL, 0,       /* x/yoptions */
                     1, 1);             /* x/ypadding */
     entry = gtk_entry_new();
+    gtk_widget_set_style(entry, tool_style);
     gtk_entry_set_visibility(GTK_ENTRY(entry),
                              lwis[n].flags & LWI_HIDDEN ? FALSE : TRUE);
     gtk_entry_set_text(GTK_ENTRY(entry), lwis[n].get());