diff options
| author | Pietro Gagliardi <[email protected]> | 2014-04-10 12:34:30 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-04-10 12:35:37 -0400 |
| commit | 013e8707dac20dee4c72840989b69757bf26e72b (patch) | |
| tree | 48da8ee617708a48e031d8cf2a7a21cdfb0205a8 /dialog_unix.go | |
| parent | 9e185d815eec14ea9f50ffbbbf171cf78e597808 (diff) | |
Removed unnecessary space if the secondaryText argument to MsgBox***() is an empty string. This doesn't change much on Mac OS X; it always shows the informational text field, showing an empty string by default. On GTK+ it seems to get rid of the bold over the primary text; I'm going to assume this is intentional (it looks that way on GTK+ 2; the HIG docs have outdated screenshots...).
Diffstat (limited to 'dialog_unix.go')
| -rw-r--r-- | dialog_unix.go | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/dialog_unix.go b/dialog_unix.go index 3889086..ec1a4e1 100644 --- a/dialog_unix.go +++ b/dialog_unix.go @@ -12,7 +12,15 @@ import ( // #include "gtk_unix.h" // /* because cgo seems to choke on ... */ // /* TODO does NULL parent make the box application-global? docs are unclear */ -// GtkWidget *gtkNewMsgBox(GtkMessageType type, GtkButtonsType buttons, char *title, char *text) { GtkWidget *k = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type, buttons, "%s", (gchar *) title); gtk_message_dialog_format_secondary_text((GtkMessageDialog *) k, "%s", (gchar *) text); return k; } +// GtkWidget *gtkNewMsgBox(GtkMessageType type, GtkButtonsType buttons, char *title, char *text) +// { +// GtkWidget *k; +// +// k = gtk_message_dialog_new(NULL, GTK_DIALOG_MODAL, type, buttons, "%s", (gchar *) title); +// if (text != NULL) +// gtk_message_dialog_format_secondary_text((GtkMessageDialog *) k, "%s", (gchar *) text); +// return k; +// } import "C" func _msgBox(primarytext string, secondarytext string, msgtype C.GtkMessageType, buttons C.GtkButtonsType) (result C.gint) { @@ -21,8 +29,11 @@ func _msgBox(primarytext string, secondarytext string, msgtype C.GtkMessageType, uitask <- func() { cprimarytext := C.CString(primarytext) defer C.free(unsafe.Pointer(cprimarytext)) - csecondarytext := C.CString(secondarytext) - defer C.free(unsafe.Pointer(csecondarytext)) + csecondarytext := (*C.char)(nil) + if secondarytext != "" { + csecondarytext = C.CString(secondarytext) + defer C.free(unsafe.Pointer(csecondarytext)) + } box := C.gtkNewMsgBox(msgtype, buttons, cprimarytext, csecondarytext) response := C.gtk_dialog_run((*C.GtkDialog)(unsafe.Pointer(box))) C.gtk_widget_destroy(box) |
