]> git.street.me.uk Git - andy/viking.git/blobdiff - src/uibuilder.h
Make more portable .vik file, as don't save the map cache directory if it's the map...
[andy/viking.git] / src / uibuilder.h
index 531159ad21ca56da8e99629e45b7004f7111d471..9c147267dc2b7ac5f18b35dfc31dbefab09386d3 100644 (file)
@@ -73,7 +73,25 @@ VIK_LAYER_PARAM_COLOR,
 VIK_LAYER_PARAM_STRING_LIST,
 } VikLayerParamType;
 
+typedef enum {
+  VIK_LAYER_AGGREGATE = 0,
+  VIK_LAYER_TRW,
+  VIK_LAYER_COORD,
+  VIK_LAYER_GEOREF,
+  VIK_LAYER_GPS,
+  VIK_LAYER_MAPS,
+  VIK_LAYER_DEM,
+  VIK_LAYER_NUM_TYPES // Also use this value to indicate no layer association
+} VikLayerTypeEnum;
+
+// Default value has to be returned via a function
+//  because certain types value are can not be statically allocated
+//  (i.e. a string value that is dependent on other functions)
+// Also easier for colours to be set via a function call rather than a static assignment
+typedef VikLayerParamData (*VikLayerDefaultFunc) ( void );
+
 typedef struct {
+  VikLayerTypeEnum layer;
   const gchar *name;
   VikLayerParamType type;
   gint16 group;
@@ -82,6 +100,7 @@ typedef struct {
   gpointer widget_data;
   gpointer extra_widget_data;
   const gchar *tooltip;
+  VikLayerDefaultFunc default_value;
 } VikLayerParam;
 
 enum {
@@ -97,8 +116,24 @@ typedef struct {
 } VikLayerParamScale;
 
 
+  /* Annoyingly 'C' cannot initialize unions properly */
+  /* It's dependent on the standard used or the compiler support... */
+#if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L || __GNUC__
+#define VIK_LPD_BOOLEAN(X)     (VikLayerParamData) { .b = (X) }
+#define VIK_LPD_INT(X)         (VikLayerParamData) { .u = (X) }
+#define VIK_LPD_UINT(X)        (VikLayerParamData) { .i = (X) }
+#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { .c = (GdkColor){ (X), (Y), (Z), (A) } }
+#define VIK_LPD_DOUBLE(X)      (VikLayerParamData) { .d = (X) }
+#else
+#define VIK_LPD_BOOLEAN(X)     (VikLayerParamData) { (X) }
+#define VIK_LPD_INT(X)         (VikLayerParamData) { (X) }
+#define VIK_LPD_UINT(X)        (VikLayerParamData) { (X) }
+#define VIK_LPD_COLOR(X,Y,Z,A) (VikLayerParamData) { (X), (Y), (Z), (A) }
+#define VIK_LPD_DOUBLE(X)      (VikLayerParamData) { (X) }
+#endif
 
-
+VikLayerParamData vik_lpd_true_default ( void );
+VikLayerParamData vik_lpd_false_default ( void );
 
 GtkWidget *a_uibuilder_new_widget ( VikLayerParam *param, VikLayerParamData data );
 VikLayerParamData a_uibuilder_widget_get_value ( GtkWidget *widget, VikLayerParam *param );
@@ -122,6 +157,18 @@ VikLayerParamData *a_uibuilder_run_dialog ( const gchar *dialog_name, GtkWindow
 /* frees data from last (if ness) */
 void a_uibuilder_free_paramdatas ( VikLayerParamData *paramdatas, VikLayerParam *params, guint16 params_count );
 
+/*
+ * Since combo boxes are used in various places
+ * keep the code reasonably tidy and only have one ifdef to cater for the naming variances
+ */
+#if GTK_CHECK_VERSION (2, 24, 0)
+#define vik_combo_box_text_new gtk_combo_box_text_new
+#define vik_combo_box_text_append(X,Y) gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(X),Y)
+#else
+#define vik_combo_box_text_new gtk_combo_box_new_text
+#define vik_combo_box_text_append(X,Y) gtk_combo_box_append_text(GTK_COMBO_BOX(X),Y)
+#endif
+
 G_END_DECLS
 
 #endif