Split out includes of <gtk/gtk.h> into a new header file so the GTK+ versioning macros can be included in all Go files, not just area_unix.go.

This commit is contained in:
Pietro Gagliardi 2014-03-16 10:34:12 -04:00
parent 7b95e735d6
commit 63f8033f49
7 changed files with 22 additions and 11 deletions

View File

@ -10,12 +10,7 @@ import (
)
// #cgo pkg-config: gtk+-3.0
// /* GTK+ 3.8 deprecates gtk_scrolled_window_add_with_viewport(); we need 3.4 miniimum though
// setting MIN_REQUIRED ensures nothing older; setting MAX_ALLOWED disallows newer functions - thanks to desrt in irc.gimp.net/#gtk+
// TODO add this to the other files too */
// #define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
// #define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_4
// #include <gtk/gtk.h>
// #include "gtk_unix.h"
// extern gboolean our_area_draw_callback(GtkWidget *, cairo_t *, gpointer);
// extern gboolean our_area_button_press_event_callback(GtkWidget *, GdkEvent *, gpointer);
// extern gboolean our_area_button_release_event_callback(GtkWidget *, GdkEvent *, gpointer);

View File

@ -15,7 +15,7 @@ while we're at it the callback for our idle function will be handled here too
*/
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include "gtk_unix.h"
// #include <stdlib.h>
// extern gboolean our_window_delete_event_callback(GtkWidget *, GdkEvent *, gpointer);
// extern gboolean our_window_configure_event_callback(GtkWidget *, GdkEvent *, gpointer);

View File

@ -10,7 +10,7 @@ import (
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #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; }

16
gtk_unix.h Normal file
View File

@ -0,0 +1,16 @@
/* 16 march 2014 */
/* This header file is a convenience to ensure that the compatibility flags below are included in all Go files that include <gtk/gtk.h> */
/*
MIN_REQUIRED signals that programs are expected to run on at least GTK+ 3 .4 and thus deprectation warnings for newer versions (such as gtk_scrolled_window_add_with_viewport() being deprecated in GTK+ 3.8) should be suppressed.
MAX_ALLOWED signals that programs will not use features introduced in newer versions of GTK+ and that the compiler should warn us if we slip.
Thanks to desrt in irc.gimp.net/#gtk+
*/
#define GDK_VERSION_MIN_REQUIRED GDK_VERSION_3_4
#define GDK_VERSION_MAX_ALLOWED GDK_VERSION_3_4
/* TODO are there equivalent compatibility macros for the other components of GTK+? */
#include <gtk/gtk.h>
/* TODO include <stdlib.h> too */

View File

@ -11,7 +11,7 @@ import (
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_unix.h"
import "C"
type (

View File

@ -14,7 +14,7 @@ import (
// Listbox casts are stored in listbox_unix.go
// #cgo pkg-config: gtk+-3.0
// #include <gtk/gtk.h>
// #include "gtk_unix.h"
import "C"
func fromgbool(b C.gboolean) bool {

View File

@ -30,7 +30,7 @@ and the GTK+ reference documentation.
// #cgo pkg-config: gtk+-3.0
// #include <stdlib.h>
// #include <gtk/gtk.h>
// #include "gtk_unix.h"
// /* because cgo seems to choke on ... */
// void gtkTreeModelGet(GtkTreeModel *model, GtkTreeIter *iter, gchar **gs)
// {