]> git.street.me.uk Git - andy/viking.git/blobdiff - src/viklayer.h
[QA] Replace specific code by GObject macro
[andy/viking.git] / src / viklayer.h
index 25092962fa5c919509dae3b3faff158e1e03ad57..69da91d7eca8dc76f679bd2d18de0559446bf5a4 100644 (file)
@@ -31,6 +31,8 @@
 #include "viktreeview.h"
 #include "vikviewport.h"
 
 #include "viktreeview.h"
 #include "vikviewport.h"
 
+G_BEGIN_DECLS
+
 #define VIK_LAYER_TYPE            (vik_layer_get_type ())
 #define VIK_LAYER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_LAYER_TYPE, VikLayer))
 #define VIK_LAYER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_LAYER_TYPE, VikLayerClass))
 #define VIK_LAYER_TYPE            (vik_layer_get_type ())
 #define VIK_LAYER(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), VIK_LAYER_TYPE, VikLayer))
 #define VIK_LAYER_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), VIK_LAYER_TYPE, VikLayerClass))
@@ -101,7 +103,7 @@ typedef gboolean (*VikToolKeyFunc) (VikLayer *, GdkEventKey *, gpointer);
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
 
 typedef struct _VikToolInterface VikToolInterface;
 struct _VikToolInterface {
-  gchar *name;
+  GtkRadioActionEntry radioActionEntry;
   VikToolConstructorFunc create;
   VikToolDestructorFunc destroy;
   VikToolActivationFunc activate;
   VikToolConstructorFunc create;
   VikToolDestructorFunc destroy;
   VikToolActivationFunc activate;
@@ -109,7 +111,8 @@ struct _VikToolInterface {
   VikToolMouseFunc click;
   VikToolMouseMoveFunc move;
   VikToolMouseFunc release;
   VikToolMouseFunc click;
   VikToolMouseMoveFunc move;
   VikToolMouseFunc release;
-  VikToolKeyFunc key_press; /* return FALSE if we don't use the key press -- should return AFLSE most of the time if we want any shortcuts / UI keybindings to work! use sparingly. */
+  VikToolKeyFunc key_press; /* return FALSE if we don't use the key press -- should return FALSE most of the time if we want any shortcuts / UI keybindings to work! use sparingly. */
+  gboolean pan_handler; // Call click & release funtions even when 'Pan Mode' is on
   GdkCursorType cursor_type;
   const GdkPixdata *cursor_data;
   const GdkCursor *cursor;
   GdkCursorType cursor_type;
   const GdkPixdata *cursor_data;
   const GdkCursor *cursor;
@@ -147,11 +150,13 @@ typedef guint16          (*VikLayerFuncGetMenuItemsSelection)          (VikLayer
 
 typedef void          (*VikLayerFuncAddMenuItems)          (VikLayer *,GtkMenu *,gpointer); /* gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerAddMenuItems)  (VikLayer *,GtkMenu *,gpointer, /* first gpointer is a VikLayersPanel */
 
 typedef void          (*VikLayerFuncAddMenuItems)          (VikLayer *,GtkMenu *,gpointer); /* gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerAddMenuItems)  (VikLayer *,GtkMenu *,gpointer, /* first gpointer is a VikLayersPanel */
-                                                            gint,gpointer,GtkTreeIter *);
+                                                            gint,gpointer,GtkTreeIter *,VikViewport *);
 typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gchar *,gpointer,
                                                             gint,VikViewport *,GtkTreeIter *); /* first gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
 typedef const gchar * (*VikLayerFuncSublayerTooltip)       (VikLayer *,gint,gpointer);
 typedef const gchar * (*VikLayerFuncSublayerRenameRequest) (VikLayer *,const gchar *,gpointer,
                                                             gint,VikViewport *,GtkTreeIter *); /* first gpointer is a VikLayersPanel */
 typedef gboolean      (*VikLayerFuncSublayerToggleVisible) (VikLayer *,gint,gpointer);
 typedef const gchar * (*VikLayerFuncSublayerTooltip)       (VikLayer *,gint,gpointer);
+typedef const gchar * (*VikLayerFuncLayerTooltip)          (VikLayer *);
+typedef gboolean      (*VikLayerFuncLayerSelected)         (VikLayer *,gint,gpointer,gint,gpointer); /* 2nd gpointer is a VikLayersPanel */
 
 typedef void          (*VikLayerFuncMarshall)              (VikLayer *, guint8 **, gint *);
 typedef VikLayer *    (*VikLayerFuncUnmarshall)            (guint8 *, gint, VikViewport *);
 
 typedef void          (*VikLayerFuncMarshall)              (VikLayer *, guint8 **, gint *);
 typedef VikLayer *    (*VikLayerFuncUnmarshall)            (guint8 *, gint, VikViewport *);
@@ -164,12 +169,13 @@ typedef gboolean      (*VikLayerFuncSetParam)              (VikLayer *, guint16,
 typedef VikLayerParamData
                       (*VikLayerFuncGetParam)              (VikLayer *, guint16, gboolean);
 
 typedef VikLayerParamData
                       (*VikLayerFuncGetParam)              (VikLayer *, guint16, gboolean);
 
-typedef void          (*VikLayerFuncReadFileData)          (VikLayer *, FILE *);
+typedef gboolean      (*VikLayerFuncReadFileData)          (VikLayer *, FILE *); // Should report success or failure
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
 /* item manipulation */
 typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
                                                          /*      layer, subtype, pointer to sub-item */
 typedef void          (*VikLayerFuncWriteFileData)         (VikLayer *, FILE *);
 
 /* item manipulation */
 typedef void          (*VikLayerFuncDeleteItem)            (VikLayer *, gint, gpointer);
                                                          /*      layer, subtype, pointer to sub-item */
+typedef void          (*VikLayerFuncCutItem)               (VikLayer *, gint, gpointer);
 typedef void          (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer, guint8 **, guint *);
                                                          /*      layer, subtype, pointer to sub-item, return pointer, return len */
 typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, guint8 *, guint);
 typedef void          (*VikLayerFuncCopyItem)              (VikLayer *, gint, gpointer, guint8 **, guint *);
                                                          /*      layer, subtype, pointer to sub-item, return pointer, return len */
 typedef gboolean      (*VikLayerFuncPasteItem)             (VikLayer *, gint, guint8 *, guint);
@@ -180,6 +186,11 @@ typedef void          (*VikLayerFuncFreeCopiedItem)        (gint, gpointer);
  */
 typedef void         (*VikLayerFuncDragDropRequest)       (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
 
  */
 typedef void         (*VikLayerFuncDragDropRequest)       (VikLayer *, VikLayer *, GtkTreeIter *, GtkTreePath *);
 
+typedef gboolean      (*VikLayerFuncSelectClick)           (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectMove)            (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectRelease)         (VikLayer *, GdkEventButton *, VikViewport *, tool_ed_t*);
+typedef gboolean      (*VikLayerFuncSelectedViewportMenu)  (VikLayer *, GdkEventButton *, VikViewport *);
+
 typedef enum {
   VIK_MENU_ITEM_PROPERTY=1,
   VIK_MENU_ITEM_CUT=2,
 typedef enum {
   VIK_MENU_ITEM_PROPERTY=1,
   VIK_MENU_ITEM_CUT=2,
@@ -193,7 +204,9 @@ typedef struct _VikLayerInterface VikLayerInterface;
 
 /* See vik_layer_* for function parameter names */
 struct _VikLayerInterface {
 
 /* See vik_layer_* for function parameter names */
 struct _VikLayerInterface {
-  const gchar *                     name;
+  const gchar *                     fixed_layer_name; // Used in .vik files - this should never change to maintain file compatibility
+  const gchar *                     name;             // Translate-able name used for display purposes
+  const gchar *                     accelerator;
   const GdkPixdata *                icon;
 
   VikToolInterface *                tools;
   const GdkPixdata *                icon;
 
   VikToolInterface *                tools;
@@ -225,6 +238,8 @@ struct _VikLayerInterface {
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
   VikLayerFuncSublayerTooltip       sublayer_tooltip;
   VikLayerFuncSublayerRenameRequest sublayer_rename_request;
   VikLayerFuncSublayerToggleVisible sublayer_toggle_visible;
   VikLayerFuncSublayerTooltip       sublayer_tooltip;
+  VikLayerFuncLayerTooltip          layer_tooltip;
+  VikLayerFuncLayerSelected         layer_selected;
 
   VikLayerFuncMarshall              marshall;
   VikLayerFuncUnmarshall            unmarshall;
 
   VikLayerFuncMarshall              marshall;
   VikLayerFuncUnmarshall            unmarshall;
@@ -238,11 +253,17 @@ struct _VikLayerInterface {
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncDeleteItem            delete_item;
   VikLayerFuncWriteFileData         write_file_data;
 
   VikLayerFuncDeleteItem            delete_item;
+  VikLayerFuncCutItem               cut_item;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
 
   VikLayerFuncDragDropRequest       drag_drop_request;
   VikLayerFuncCopyItem              copy_item;
   VikLayerFuncPasteItem             paste_item;
   VikLayerFuncFreeCopiedItem        free_copied_item;
 
   VikLayerFuncDragDropRequest       drag_drop_request;
+
+  VikLayerFuncSelectClick           select_click;
+  VikLayerFuncSelectMove            select_move;
+  VikLayerFuncSelectRelease         select_release;
+  VikLayerFuncSelectedViewportMenu  show_viewport_menu;
 };
 
 VikLayerInterface *vik_layer_get_interface ( gint type );
 };
 
 VikLayerInterface *vik_layer_get_interface ( gint type );
@@ -257,7 +278,7 @@ const gchar *vik_layer_get_name ( VikLayer *l );
 
 gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData data, gpointer vp, gboolean is_file_operation);
 
 
 gboolean vik_layer_set_param (VikLayer *layer, guint16 id, VikLayerParamData data, gpointer vp, gboolean is_file_operation);
 
-void vik_layer_emit_update ( VikLayer *vl );
+void vik_layer_emit_update ( VikLayer *vl, gboolean from_background );
 
 /* GUI */
 void vik_layer_set_menu_items_selection(VikLayer *l, guint16 selection);
 
 /* GUI */
 void vik_layer_set_menu_items_selection(VikLayer *l, guint16 selection);
@@ -269,7 +290,7 @@ gboolean vik_layer_properties ( VikLayer *layer, gpointer vp );
 void vik_layer_realize ( VikLayer *l, VikTreeview *vt, GtkTreeIter * layer_iter );
 void vik_layer_post_read ( VikLayer *layer, VikViewport *vp, gboolean from_file );
 
 void vik_layer_realize ( VikLayer *l, VikTreeview *vt, GtkTreeIter * layer_iter );
 void vik_layer_post_read ( VikLayer *layer, VikViewport *vp, gboolean from_file );
 
-gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter );
+gboolean vik_layer_sublayer_add_menu_items ( VikLayer *l, GtkMenu *menu, gpointer vlp, gint subtype, gpointer sublayer, GtkTreeIter *iter, VikViewport *vvp );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
 void      vik_layer_marshall ( VikLayer *vl, guint8 **data, gint *len );
 
 VikLayer *vik_layer_copy ( VikLayer *vl, gpointer vp );
 void      vik_layer_marshall ( VikLayer *vl, guint8 **data, gint *len );
@@ -283,6 +304,10 @@ gboolean vik_layer_sublayer_toggle_visible ( VikLayer *l, gint subtype, gpointer
 
 const gchar* vik_layer_sublayer_tooltip ( VikLayer *l, gint subtype, gpointer sublayer );
 
 
 const gchar* vik_layer_sublayer_tooltip ( VikLayer *l, gint subtype, gpointer sublayer );
 
+const gchar* vik_layer_layer_tooltip ( VikLayer *l );
+
+gboolean vik_layer_selected ( VikLayer *l, gint subtype, gpointer sublayer, gint type, gpointer vlp );
+
 /* TODO: put in layerspanel */
 GdkPixbuf *vik_layer_load_icon ( gint type );
 
 /* TODO: put in layerspanel */
 GdkPixbuf *vik_layer_load_icon ( gint type );
 
@@ -290,4 +315,6 @@ VikLayer *vik_layer_get_and_reset_trigger();
 void vik_layer_emit_update_secondary ( VikLayer *vl ); /* to be called by aggregate layer only. doesn't set the trigger */
 void vik_layer_emit_update_although_invisible ( VikLayer *vl );
 
 void vik_layer_emit_update_secondary ( VikLayer *vl ); /* to be called by aggregate layer only. doesn't set the trigger */
 void vik_layer_emit_update_although_invisible ( VikLayer *vl );
 
+G_END_DECLS
+
 #endif
 #endif