diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ld-canvas.c | 44 | ||||
-rw-r--r-- | src/ld-diagram-object.c | 4 | ||||
-rw-r--r-- | src/ld-diagram-symbol.c | 4 | ||||
-rw-r--r-- | src/ld-diagram.c | 4 | ||||
-rw-r--r-- | src/ld-library.c | 4 | ||||
-rw-r--r-- | src/ld-lua-symbol.c | 4 | ||||
-rw-r--r-- | src/ld-lua.c | 60 | ||||
-rw-r--r-- | src/ld-symbol-category.c | 4 | ||||
-rw-r--r-- | src/ld-symbol.c | 101 | ||||
-rw-r--r-- | src/ld-window-main.c | 12 |
10 files changed, 117 insertions, 124 deletions
diff --git a/src/ld-canvas.c b/src/ld-canvas.c index e8c6021..03a8285 100644 --- a/src/ld-canvas.c +++ b/src/ld-canvas.c @@ -47,14 +47,19 @@ */ typedef void (*OperationEnd) (LdCanvas *self); -struct _AddObjectData +enum { - LdDiagramObject *object; - gboolean visible; + OPER_0, + OPER_ADD_OBJECT }; typedef struct _AddObjectData AddObjectData; +struct _AddObjectData +{ + LdDiagramObject *object; + gboolean visible; +}; /* * LdCanvasPrivate: @@ -82,31 +87,16 @@ struct _LdCanvasPrivate gdouble zoom; gint operation; - OperationEnd operation_end; union { AddObjectData add_object; } operation_data; + OperationEnd operation_end; }; #define OPER_DATA(self, member) ((self)->priv->operation_data.member) -G_DEFINE_TYPE (LdCanvas, ld_canvas, GTK_TYPE_DRAWING_AREA); - -enum -{ - PROP_0, - PROP_DIAGRAM, - PROP_LIBRARY -}; - -enum -{ - OPER_0, - OPER_ADD_OBJECT -}; - /* * DrawData: * @self: Our #LdCanvas. @@ -114,6 +104,8 @@ enum * @exposed_rect: The area that is to be redrawn. * @scale: Computed size of one diagram unit in pixels. */ +typedef struct _DrawData DrawData; + struct _DrawData { LdCanvas *self; @@ -122,8 +114,12 @@ struct _DrawData gdouble scale; }; -typedef struct _DrawData DrawData; - +enum +{ + PROP_0, + PROP_DIAGRAM, + PROP_LIBRARY +}; static void ld_canvas_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); @@ -170,6 +166,8 @@ static void draw_object (LdDiagramObject *diagram_object, DrawData *data); static void draw_symbol (LdDiagramSymbol *diagram_symbol, DrawData *data); +G_DEFINE_TYPE (LdCanvas, ld_canvas, GTK_TYPE_DRAWING_AREA); + static void ld_canvas_class_init (LdCanvasClass *klass) { @@ -252,10 +250,10 @@ ld_canvas_init (LdCanvas *self) self->priv->y = 0; self->priv->zoom = 1; - g_signal_connect (self, "expose-event", - G_CALLBACK (on_expose_event), NULL); g_signal_connect (self, "size-allocate", G_CALLBACK (on_size_allocate), NULL); + g_signal_connect (self, "expose-event", + G_CALLBACK (on_expose_event), NULL); g_signal_connect (self, "motion-notify-event", G_CALLBACK (on_motion_notify), NULL); diff --git a/src/ld-diagram-object.c b/src/ld-diagram-object.c index fea70c0..a9f87ba 100644 --- a/src/ld-diagram-object.c +++ b/src/ld-diagram-object.c @@ -34,8 +34,6 @@ struct _LdDiagramObjectPrivate gdouble y; }; -G_DEFINE_ABSTRACT_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT); - enum { PROP_0, @@ -49,6 +47,8 @@ static void ld_diagram_object_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +G_DEFINE_ABSTRACT_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT); + static void ld_diagram_object_class_init (LdDiagramObjectClass *klass) { diff --git a/src/ld-diagram-symbol.c b/src/ld-diagram-symbol.c index aafcb67..9653626 100644 --- a/src/ld-diagram-symbol.c +++ b/src/ld-diagram-symbol.c @@ -33,11 +33,11 @@ struct _LdDiagramSymbolPrivate gchar *klass; }; -G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT); - static void ld_diagram_symbol_finalize (GObject *gobject); +G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT); + static void ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass) { diff --git a/src/ld-diagram.c b/src/ld-diagram.c index e19a6d5..db66858 100644 --- a/src/ld-diagram.c +++ b/src/ld-diagram.c @@ -41,8 +41,6 @@ struct _LdDiagramPrivate GSList *connections; }; -G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT); - enum { PROP_0, @@ -60,6 +58,8 @@ static void ld_diagram_real_changed (LdDiagram *self); static void ld_diagram_clear_internal (LdDiagram *self); +G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT); + static void ld_diagram_class_init (LdDiagramClass *klass) { diff --git a/src/ld-library.c b/src/ld-library.c index 4c980d0..73c40ef 100644 --- a/src/ld-library.c +++ b/src/ld-library.c @@ -41,8 +41,6 @@ struct _LdLibraryPrivate GSList *children; }; -G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT); - static void ld_library_finalize (GObject *gobject); static LdSymbolCategory *load_category (LdLibrary *self, @@ -60,6 +58,8 @@ static gboolean ld_library_load_cb (const gchar *base, const gchar *filename, gpointer userdata); +G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT); + static void ld_library_class_init (LdLibraryClass *klass) { diff --git a/src/ld-lua-symbol.c b/src/ld-lua-symbol.c index f7e37a4..5626761 100644 --- a/src/ld-lua-symbol.c +++ b/src/ld-lua-symbol.c @@ -31,8 +31,6 @@ * #LdLuaSymbol is an implementation of #LdSymbol. */ -G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL); - static void ld_lua_symbol_finalize (GObject *gobject); static const gchar *ld_lua_symbol_real_get_name (LdSymbol *symbol); @@ -41,6 +39,8 @@ static void ld_lua_symbol_real_get_area (LdSymbol *symbol, LdSymbolArea *area); static void ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr); +G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL); + static void ld_lua_symbol_class_init (LdLuaSymbolClass *klass) { diff --git a/src/ld-lua.c b/src/ld-lua.c index f51ab1c..66b1d1f 100644 --- a/src/ld-lua.c +++ b/src/ld-lua.c @@ -33,13 +33,6 @@ * #LdLua is a symbol engine that uses Lua scripts to manage symbols. */ -/* How does the application call the function for rendering? - * registry.logdiag_symbols - * -> table indexed by pointers to LdLuaSymbol objects - * registry.logdiag_symbols.object.render(cr) - * -> rendering function - */ - /* * LdLuaPrivate: * @L: Lua state. @@ -51,12 +44,15 @@ struct _LdLuaPrivate lua_State *L; }; -G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT); - -static void ld_lua_finalize (GObject *gobject); - -static void *ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize); +/* registry.logdiag_symbols + * -> table indexed by pointers to LdLuaSymbol objects + * registry.logdiag_symbols.object.render(cr) + * -> rendering function + */ +#define LD_LUA_LIBRARY_NAME "logdiag" +#define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data" +#define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols" /* * LdLuaData: @@ -66,45 +62,36 @@ static void *ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize); * * Full user data to be stored in Lua registry. */ -typedef struct +typedef struct _LdLuaData LdLuaData; + +struct _LdLuaData { LdLua *self; LdLuaLoadCallback load_callback; gpointer load_user_data; -} -LdLuaData; - -#define LD_LUA_LIBRARY_NAME "logdiag" -#define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data" -#define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols" +}; +typedef struct _LdLuaDrawData LdLuaDrawData; -typedef struct +struct _LdLuaDrawData { LdLuaSymbol *symbol; cairo_t *cr; -} -LdLuaDrawData; +}; + +static void ld_lua_finalize (GObject *gobject); + +static void *ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize); static int ld_lua_private_draw_cb (lua_State *L); static int ld_lua_private_unregister_cb (lua_State *L); - static int ld_lua_logdiag_register (lua_State *L); - static int process_registration (lua_State *L); static gchar *get_translation (lua_State *L, int index); static gboolean read_symbol_area (lua_State *L, int index, LdSymbolArea *area); -static luaL_Reg ld_lua_logdiag_lib[] = -{ - {"register", ld_lua_logdiag_register}, - {NULL, NULL} -}; - - static void push_cairo_object (lua_State *L, cairo_t *cr); - static int ld_lua_cairo_move_to (lua_State *L); static int ld_lua_cairo_line_to (lua_State *L); static int ld_lua_cairo_stroke (lua_State *L); @@ -112,6 +99,13 @@ static int ld_lua_cairo_stroke_preserve (lua_State *L); static int ld_lua_cairo_fill (lua_State *L); static int ld_lua_cairo_fill_preserve (lua_State *L); + +static luaL_Reg ld_lua_logdiag_lib[] = +{ + {"register", ld_lua_logdiag_register}, + {NULL, NULL} +}; + static luaL_Reg ld_lua_cairo_table[] = { {"move_to", ld_lua_cairo_move_to}, @@ -126,6 +120,8 @@ static luaL_Reg ld_lua_cairo_table[] = /* ===== Generic =========================================================== */ +G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT); + static void ld_lua_class_init (LdLuaClass *klass) { diff --git a/src/ld-symbol-category.c b/src/ld-symbol-category.c index b7963aa..2ca2693 100644 --- a/src/ld-symbol-category.c +++ b/src/ld-symbol-category.c @@ -39,8 +39,6 @@ struct _LdSymbolCategoryPrivate GSList *children; }; -G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT); - enum { PROP_0, @@ -56,6 +54,8 @@ static void ld_symbol_category_set_property (GObject *object, guint property_id, static void ld_symbol_category_finalize (GObject *gobject); +G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT); + static void ld_symbol_category_class_init (LdSymbolCategoryClass *klass) { diff --git a/src/ld-symbol.c b/src/ld-symbol.c index 6cffee0..45f11c9 100644 --- a/src/ld-symbol.c +++ b/src/ld-symbol.c @@ -18,55 +18,6 @@ /** - * ld_symbol_area_copy: - * @self: An #LdSymbolArea structure. - * - * Makes a copy of the structure. - * The result must be freed by ld_symbol_area_free(). - * - * Return value: A copy of @self. - **/ -LdSymbolArea * -ld_symbol_area_copy (const LdSymbolArea *self) -{ - LdSymbolArea *new_area; - - g_return_val_if_fail (self != NULL, NULL); - - new_area = g_slice_new (LdSymbolArea); - *new_area = *self; - return new_area; -} - -/** - * ld_symbol_area_free: - * @self: An #LdSymbolArea structure. - * - * Frees the structure created with ld_symbol_area_copy(). - **/ -void -ld_symbol_area_free (LdSymbolArea *self) -{ - g_return_if_fail (self != NULL); - - g_slice_free (LdSymbolArea, self); -} - -GType -ld_symbol_area_get_type (void) -{ - static GType our_type = 0; - - if (our_type == 0) - our_type = g_boxed_type_register_static - (g_intern_static_string ("LdSymbolArea"), - (GBoxedCopyFunc) ld_symbol_area_copy, - (GBoxedFreeFunc) ld_symbol_area_free); - return our_type; -} - - -/** * SECTION:ld-symbol * @short_description: A symbol. * @see_also: #LdDiagram, #LdCanvas @@ -78,8 +29,6 @@ ld_symbol_area_get_type (void) * cairo_save() and cairo_restore() when drawing to store the state. */ -G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT); - enum { PROP_0, @@ -94,6 +43,8 @@ static void ld_symbol_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec); +G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT); + static void ld_symbol_class_init (LdSymbolClass *klass) { @@ -251,3 +202,51 @@ ld_symbol_draw (LdSymbol *self, cairo_t *cr) g_return_if_fail (klass->draw != NULL); klass->draw (self, cr); } + +/** + * ld_symbol_area_copy: + * @self: An #LdSymbolArea structure. + * + * Makes a copy of the structure. + * The result must be freed by ld_symbol_area_free(). + * + * Return value: A copy of @self. + **/ +LdSymbolArea * +ld_symbol_area_copy (const LdSymbolArea *self) +{ + LdSymbolArea *new_area; + + g_return_val_if_fail (self != NULL, NULL); + + new_area = g_slice_new (LdSymbolArea); + *new_area = *self; + return new_area; +} + +/** + * ld_symbol_area_free: + * @self: An #LdSymbolArea structure. + * + * Frees the structure created with ld_symbol_area_copy(). + **/ +void +ld_symbol_area_free (LdSymbolArea *self) +{ + g_return_if_fail (self != NULL); + + g_slice_free (LdSymbolArea, self); +} + +GType +ld_symbol_area_get_type (void) +{ + static GType our_type = 0; + + if (our_type == 0) + our_type = g_boxed_type_register_static + (g_intern_static_string ("LdSymbolArea"), + (GBoxedCopyFunc) ld_symbol_area_copy, + (GBoxedFreeFunc) ld_symbol_area_free); + return our_type; +} diff --git a/src/ld-window-main.c b/src/ld-window-main.c index 32212a1..296bee5 100644 --- a/src/ld-window-main.c +++ b/src/ld-window-main.c @@ -35,14 +35,13 @@ * the documentation or the static library. */ -typedef struct _SymbolMenuItem SymbolMenuItem; -typedef struct _SymbolMenuData SymbolMenuData; - /* * SymbolMenuItem: * * Data related to a symbol in an open symbol menu. */ +typedef struct _SymbolMenuItem SymbolMenuItem; + struct _SymbolMenuItem { LdSymbol *symbol; @@ -56,6 +55,8 @@ struct _SymbolMenuItem * * Data related to the currently opened symbol menu. */ +typedef struct _SymbolMenuData SymbolMenuData; + struct _SymbolMenuData { gulong expose_handler; @@ -99,9 +100,6 @@ struct _LdWindowMainPrivate SymbolMenuData symbol_menu; }; -/* Define the type. */ -G_DEFINE_TYPE (LdWindowMain, ld_window_main, GTK_TYPE_WINDOW); - #define LIBRARY_TOOLBAR_ICON_WIDTH 32 @@ -220,6 +218,8 @@ ld_window_main_new (void) return g_object_new (LD_TYPE_WINDOW_MAIN, NULL); } +G_DEFINE_TYPE (LdWindowMain, ld_window_main, GTK_TYPE_WINDOW); + static void ld_window_main_class_init (LdWindowMainClass *klass) { |