Move lines around. No functional change.

This commit is contained in:
Přemysl Eric Janouch 2011-01-04 14:52:57 +01:00
parent d3e5483c84
commit fdf1ddbbb1
10 changed files with 117 additions and 124 deletions

View File

@ -47,15 +47,20 @@
*/ */
typedef void (*OperationEnd) (LdCanvas *self); typedef void (*OperationEnd) (LdCanvas *self);
enum
{
OPER_0,
OPER_ADD_OBJECT
};
typedef struct _AddObjectData AddObjectData;
struct _AddObjectData struct _AddObjectData
{ {
LdDiagramObject *object; LdDiagramObject *object;
gboolean visible; gboolean visible;
}; };
typedef struct _AddObjectData AddObjectData;
/* /*
* LdCanvasPrivate: * LdCanvasPrivate:
* @diagram: A diagram object assigned to this canvas as a model. * @diagram: A diagram object assigned to this canvas as a model.
@ -82,31 +87,16 @@ struct _LdCanvasPrivate
gdouble zoom; gdouble zoom;
gint operation; gint operation;
OperationEnd operation_end;
union union
{ {
AddObjectData add_object; AddObjectData add_object;
} }
operation_data; operation_data;
OperationEnd operation_end;
}; };
#define OPER_DATA(self, member) ((self)->priv->operation_data.member) #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: * DrawData:
* @self: Our #LdCanvas. * @self: Our #LdCanvas.
@ -114,6 +104,8 @@ enum
* @exposed_rect: The area that is to be redrawn. * @exposed_rect: The area that is to be redrawn.
* @scale: Computed size of one diagram unit in pixels. * @scale: Computed size of one diagram unit in pixels.
*/ */
typedef struct _DrawData DrawData;
struct _DrawData struct _DrawData
{ {
LdCanvas *self; LdCanvas *self;
@ -122,8 +114,12 @@ struct _DrawData
gdouble scale; gdouble scale;
}; };
typedef struct _DrawData DrawData; enum
{
PROP_0,
PROP_DIAGRAM,
PROP_LIBRARY
};
static void ld_canvas_get_property (GObject *object, guint property_id, static void ld_canvas_get_property (GObject *object, guint property_id,
GValue *value, GParamSpec *pspec); 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); static void draw_symbol (LdDiagramSymbol *diagram_symbol, DrawData *data);
G_DEFINE_TYPE (LdCanvas, ld_canvas, GTK_TYPE_DRAWING_AREA);
static void static void
ld_canvas_class_init (LdCanvasClass *klass) ld_canvas_class_init (LdCanvasClass *klass)
{ {
@ -252,10 +250,10 @@ ld_canvas_init (LdCanvas *self)
self->priv->y = 0; self->priv->y = 0;
self->priv->zoom = 1; self->priv->zoom = 1;
g_signal_connect (self, "expose-event",
G_CALLBACK (on_expose_event), NULL);
g_signal_connect (self, "size-allocate", g_signal_connect (self, "size-allocate",
G_CALLBACK (on_size_allocate), NULL); 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_signal_connect (self, "motion-notify-event",
G_CALLBACK (on_motion_notify), NULL); G_CALLBACK (on_motion_notify), NULL);

View File

@ -34,8 +34,6 @@ struct _LdDiagramObjectPrivate
gdouble y; gdouble y;
}; };
G_DEFINE_ABSTRACT_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT);
enum enum
{ {
PROP_0, PROP_0,
@ -49,6 +47,8 @@ static void ld_diagram_object_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);
G_DEFINE_ABSTRACT_TYPE (LdDiagramObject, ld_diagram_object, G_TYPE_OBJECT);
static void static void
ld_diagram_object_class_init (LdDiagramObjectClass *klass) ld_diagram_object_class_init (LdDiagramObjectClass *klass)
{ {

View File

@ -33,11 +33,11 @@ struct _LdDiagramSymbolPrivate
gchar *klass; gchar *klass;
}; };
G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);
static void ld_diagram_symbol_finalize (GObject *gobject); static void ld_diagram_symbol_finalize (GObject *gobject);
G_DEFINE_TYPE (LdDiagramSymbol, ld_diagram_symbol, LD_TYPE_DIAGRAM_OBJECT);
static void static void
ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass) ld_diagram_symbol_class_init (LdDiagramSymbolClass *klass)
{ {

View File

@ -41,8 +41,6 @@ struct _LdDiagramPrivate
GSList *connections; GSList *connections;
}; };
G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT);
enum enum
{ {
PROP_0, PROP_0,
@ -60,6 +58,8 @@ static void ld_diagram_real_changed (LdDiagram *self);
static void ld_diagram_clear_internal (LdDiagram *self); static void ld_diagram_clear_internal (LdDiagram *self);
G_DEFINE_TYPE (LdDiagram, ld_diagram, G_TYPE_OBJECT);
static void static void
ld_diagram_class_init (LdDiagramClass *klass) ld_diagram_class_init (LdDiagramClass *klass)
{ {

View File

@ -41,8 +41,6 @@ struct _LdLibraryPrivate
GSList *children; GSList *children;
}; };
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT);
static void ld_library_finalize (GObject *gobject); static void ld_library_finalize (GObject *gobject);
static LdSymbolCategory *load_category (LdLibrary *self, static LdSymbolCategory *load_category (LdLibrary *self,
@ -60,6 +58,8 @@ static gboolean ld_library_load_cb
(const gchar *base, const gchar *filename, gpointer userdata); (const gchar *base, const gchar *filename, gpointer userdata);
G_DEFINE_TYPE (LdLibrary, ld_library, G_TYPE_OBJECT);
static void static void
ld_library_class_init (LdLibraryClass *klass) ld_library_class_init (LdLibraryClass *klass)
{ {

View File

@ -31,8 +31,6 @@
* #LdLuaSymbol is an implementation of #LdSymbol. * #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 void ld_lua_symbol_finalize (GObject *gobject);
static const gchar *ld_lua_symbol_real_get_name (LdSymbol *symbol); 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); static void ld_lua_symbol_real_draw (LdSymbol *symbol, cairo_t *cr);
G_DEFINE_TYPE (LdLuaSymbol, ld_lua_symbol, LD_TYPE_SYMBOL);
static void static void
ld_lua_symbol_class_init (LdLuaSymbolClass *klass) ld_lua_symbol_class_init (LdLuaSymbolClass *klass)
{ {

View File

@ -33,13 +33,6 @@
* #LdLua is a symbol engine that uses Lua scripts to manage symbols. * #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: * LdLuaPrivate:
* @L: Lua state. * @L: Lua state.
@ -51,12 +44,15 @@ struct _LdLuaPrivate
lua_State *L; lua_State *L;
}; };
G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT); /* registry.logdiag_symbols
* -> table indexed by pointers to LdLuaSymbol objects
static void ld_lua_finalize (GObject *gobject); * registry.logdiag_symbols.object.render(cr)
* -> rendering function
static void *ld_lua_alloc (void *ud, void *ptr, size_t osize, size_t nsize); */
#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: * 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. * Full user data to be stored in Lua registry.
*/ */
typedef struct typedef struct _LdLuaData LdLuaData;
struct _LdLuaData
{ {
LdLua *self; LdLua *self;
LdLuaLoadCallback load_callback; LdLuaLoadCallback load_callback;
gpointer load_user_data; gpointer load_user_data;
} };
LdLuaData;
#define LD_LUA_LIBRARY_NAME "logdiag" typedef struct _LdLuaDrawData LdLuaDrawData;
#define LD_LUA_DATA_INDEX LD_LUA_LIBRARY_NAME "_data"
#define LD_LUA_SYMBOLS_INDEX LD_LUA_LIBRARY_NAME "_symbols"
struct _LdLuaDrawData
typedef struct
{ {
LdLuaSymbol *symbol; LdLuaSymbol *symbol;
cairo_t *cr; 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_draw_cb (lua_State *L);
static int ld_lua_private_unregister_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 ld_lua_logdiag_register (lua_State *L);
static int process_registration (lua_State *L); static int process_registration (lua_State *L);
static gchar *get_translation (lua_State *L, int index); static gchar *get_translation (lua_State *L, int index);
static gboolean read_symbol_area (lua_State *L, int index, LdSymbolArea *area); 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 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_move_to (lua_State *L);
static int ld_lua_cairo_line_to (lua_State *L); static int ld_lua_cairo_line_to (lua_State *L);
static int ld_lua_cairo_stroke (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 (lua_State *L);
static int ld_lua_cairo_fill_preserve (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[] = static luaL_Reg ld_lua_cairo_table[] =
{ {
{"move_to", ld_lua_cairo_move_to}, {"move_to", ld_lua_cairo_move_to},
@ -126,6 +120,8 @@ static luaL_Reg ld_lua_cairo_table[] =
/* ===== Generic =========================================================== */ /* ===== Generic =========================================================== */
G_DEFINE_TYPE (LdLua, ld_lua, G_TYPE_OBJECT);
static void static void
ld_lua_class_init (LdLuaClass *klass) ld_lua_class_init (LdLuaClass *klass)
{ {

View File

@ -39,8 +39,6 @@ struct _LdSymbolCategoryPrivate
GSList *children; GSList *children;
}; };
G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
enum enum
{ {
PROP_0, 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); static void ld_symbol_category_finalize (GObject *gobject);
G_DEFINE_TYPE (LdSymbolCategory, ld_symbol_category, G_TYPE_OBJECT);
static void static void
ld_symbol_category_class_init (LdSymbolCategoryClass *klass) ld_symbol_category_class_init (LdSymbolCategoryClass *klass)
{ {

View File

@ -17,55 +17,6 @@
#include "ld-library.h" #include "ld-library.h"
/**
* 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 * SECTION:ld-symbol
* @short_description: A symbol. * @short_description: A symbol.
@ -78,8 +29,6 @@ ld_symbol_area_get_type (void)
* cairo_save() and cairo_restore() when drawing to store the state. * cairo_save() and cairo_restore() when drawing to store the state.
*/ */
G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
enum enum
{ {
PROP_0, PROP_0,
@ -94,6 +43,8 @@ static void ld_symbol_set_property (GObject *object, guint property_id,
const GValue *value, GParamSpec *pspec); const GValue *value, GParamSpec *pspec);
G_DEFINE_ABSTRACT_TYPE (LdSymbol, ld_symbol, G_TYPE_OBJECT);
static void static void
ld_symbol_class_init (LdSymbolClass *klass) 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); g_return_if_fail (klass->draw != NULL);
klass->draw (self, cr); 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;
}

View File

@ -35,14 +35,13 @@
* the documentation or the static library. * the documentation or the static library.
*/ */
typedef struct _SymbolMenuItem SymbolMenuItem;
typedef struct _SymbolMenuData SymbolMenuData;
/* /*
* SymbolMenuItem: * SymbolMenuItem:
* *
* Data related to a symbol in an open symbol menu. * Data related to a symbol in an open symbol menu.
*/ */
typedef struct _SymbolMenuItem SymbolMenuItem;
struct _SymbolMenuItem struct _SymbolMenuItem
{ {
LdSymbol *symbol; LdSymbol *symbol;
@ -56,6 +55,8 @@ struct _SymbolMenuItem
* *
* Data related to the currently opened symbol menu. * Data related to the currently opened symbol menu.
*/ */
typedef struct _SymbolMenuData SymbolMenuData;
struct _SymbolMenuData struct _SymbolMenuData
{ {
gulong expose_handler; gulong expose_handler;
@ -99,9 +100,6 @@ struct _LdWindowMainPrivate
SymbolMenuData symbol_menu; SymbolMenuData symbol_menu;
}; };
/* Define the type. */
G_DEFINE_TYPE (LdWindowMain, ld_window_main, GTK_TYPE_WINDOW);
#define LIBRARY_TOOLBAR_ICON_WIDTH 32 #define LIBRARY_TOOLBAR_ICON_WIDTH 32
@ -220,6 +218,8 @@ ld_window_main_new (void)
return g_object_new (LD_TYPE_WINDOW_MAIN, NULL); return g_object_new (LD_TYPE_WINDOW_MAIN, NULL);
} }
G_DEFINE_TYPE (LdWindowMain, ld_window_main, GTK_TYPE_WINDOW);
static void static void
ld_window_main_class_init (LdWindowMainClass *klass) ld_window_main_class_init (LdWindowMainClass *klass)
{ {