From 341f51eb415c98c201b7744cea9ebc1fff321ad4 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Fri, 17 Sep 2010 19:03:03 +0200
Subject: Renamed source files.
Also a little change in CMakeLists.txt.
The next commit is going to change the object prefix.
---
src/canvas.c | 99 -------------
src/canvas.h | 59 --------
src/document.c | 0
src/document.h | 91 ------------
src/ld-canvas.c | 99 +++++++++++++
src/ld-canvas.h | 59 ++++++++
src/ld-document.c | 0
src/ld-document.h | 91 ++++++++++++
src/ld-symbol-category.h | 68 +++++++++
src/ld-symbol-library.c | 373 +++++++++++++++++++++++++++++++++++++++++++++++
src/ld-symbol-library.h | 69 +++++++++
src/ld-symbol.h | 69 +++++++++
src/ld-window-main.c | 351 ++++++++++++++++++++++++++++++++++++++++++++
src/ld-window-main.h | 60 ++++++++
src/logdiag.c | 39 +++++
src/main.c | 39 -----
src/symbol-category.h | 68 ---------
src/symbol-library.c | 373 -----------------------------------------------
src/symbol-library.h | 69 ---------
src/symbol.h | 69 ---------
src/window-main.c | 351 --------------------------------------------
src/window-main.h | 60 --------
22 files changed, 1278 insertions(+), 1278 deletions(-)
delete mode 100644 src/canvas.c
delete mode 100644 src/canvas.h
delete mode 100644 src/document.c
delete mode 100644 src/document.h
create mode 100644 src/ld-canvas.c
create mode 100644 src/ld-canvas.h
create mode 100644 src/ld-document.c
create mode 100644 src/ld-document.h
create mode 100644 src/ld-symbol-category.h
create mode 100644 src/ld-symbol-library.c
create mode 100644 src/ld-symbol-library.h
create mode 100644 src/ld-symbol.h
create mode 100644 src/ld-window-main.c
create mode 100644 src/ld-window-main.h
create mode 100644 src/logdiag.c
delete mode 100644 src/main.c
delete mode 100644 src/symbol-category.h
delete mode 100644 src/symbol-library.c
delete mode 100644 src/symbol-library.h
delete mode 100644 src/symbol.h
delete mode 100644 src/window-main.c
delete mode 100644 src/window-main.h
(limited to 'src')
diff --git a/src/canvas.c b/src/canvas.c
deleted file mode 100644
index 0168639..0000000
--- a/src/canvas.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * canvas.c
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#include
-
-#include "config.h"
-
-#include "canvas.h"
-#include "document.h"
-
-/* http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28 */
-
-/**
- * SECTION:canvas
- * @short_description: A canvas.
- * @see_also: #LogdiagDocument
- *
- * #LogdiagCanvas is used for displaying #LogdiagDocument objects.
- */
-
-/*
- * LogdiagCanvasPrivate:
- * @document: A document object assigned to this canvas as a model.
- */
-struct _LogdiagCanvasPrivate
-{
- LogdiagDocument *document;
-};
-
-G_DEFINE_TYPE (LogdiagCanvas, logdiag_canvas, GTK_TYPE_DRAWING_AREA);
-
-static void
-logdiag_canvas_finalize (GObject *gobject);
-
-
-static void
-logdiag_canvas_class_init (LogdiagCanvasClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = logdiag_canvas_finalize;
-
- widget_class = GTK_WIDGET_CLASS (klass);
-
-/**
- * LogdiagCanvas::set-scroll-adjustments:
- * @canvas: The canvas object.
- *
- * Contents of the library have changed.
- */
-/*
- widget_class->set_scroll_adjustments_signal = g_signal_new
- ("set-scroll-adjustments", G_TYPE_FROM_CLASS (widget_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
- 0, // G_STRUCT_OFFSET (LogdiagCanvasClass, ...)
- NULL, NULL,
- gtk_marshal_NONE__POINTER_POINTER,
- G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
-*/
- g_type_class_add_private (klass, sizeof (LogdiagCanvasPrivate));
-}
-
-static void
-logdiag_canvas_init (LogdiagCanvas *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LOGDIAG_TYPE_CANVAS, LogdiagCanvasPrivate);
-}
-
-static void
-logdiag_canvas_finalize (GObject *gobject)
-{
- LogdiagCanvas *self;
-
- self = LOGDIAG_CANVAS (gobject);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (logdiag_canvas_parent_class)->finalize (gobject);
-}
-
-/**
- * logdiag_canvas_new:
- *
- * Create an instance.
- */
-LogdiagCanvas *
-logdiag_canvas_new (void)
-{
- return g_object_new (LOGDIAG_TYPE_CANVAS, NULL);
-}
diff --git a/src/canvas.h b/src/canvas.h
deleted file mode 100644
index be3539a..0000000
--- a/src/canvas.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * canvas.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __CANVAS_H__
-#define __CANVAS_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_CANVAS (logdiag_canvas_get_type ())
-#define LOGDIAG_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_CANVAS, LogdiagCanvas))
-#define LOGDIAG_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_CANVAS, LogdiagCanvasClass))
-#define LOGDIAG_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_CANVAS))
-#define LOGDIAG_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_CANVAS))
-#define LOGDIAG_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_CANVAS, LogdiagCanvasClass))
-
-typedef struct _LogdiagCanvas LogdiagCanvas;
-typedef struct _LogdiagCanvasPrivate LogdiagCanvasPrivate;
-typedef struct _LogdiagCanvasClass LogdiagCanvasClass;
-
-
-/**
- * LogdiagCanvas:
- */
-struct _LogdiagCanvas
-{
-/*< private >*/
- GtkDrawingArea parent_instance;
- LogdiagCanvasPrivate *priv;
-
-/*< public >*/
-};
-
-struct _LogdiagCanvasClass
-{
- GtkDrawingAreaClass parent_class;
-};
-
-
-GType logdiag_canvas_get_type (void) G_GNUC_CONST;
-
-LogdiagCanvas *logdiag_canvas_new (void);
-
-
-G_END_DECLS
-
-#endif /* ! __CANVAS_H__ */
diff --git a/src/document.c b/src/document.c
deleted file mode 100644
index e69de29..0000000
diff --git a/src/document.h b/src/document.h
deleted file mode 100644
index 198d8f8..0000000
--- a/src/document.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * document.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __DOCUMENT_H__
-#define __DOCUMENT_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_DOCUMENT (logdiag_symbol_library_get_type ())
-#define LOGDIAG_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_DOCUMENT, LogdiagDocument))
-#define LOGDIAG_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_DOCUMENT, LogdiagDocumentClass))
-#define LOGDIAG_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_DOCUMENT))
-#define LOGDIAG_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_DOCUMENT))
-#define LOGDIAG_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_DOCUMENT, LogdiagDocumentClass))
-
-typedef struct _LogdiagDocument LogdiagDocument;
-/*typedef struct _LogdiagDocumentPrivate LogdiagDocumentPrivate;*/
-typedef struct _LogdiagDocumentClass LogdiagDocumentClass;
-
-
-/**
- * LogdiagDocument:
- */
-struct _LogdiagDocument
-{
-/*< private >*/
- GObject parent_instance;
-
-/*< public >*/
-};
-
-struct _LogdiagDocumentClass
-{
- GObjectClass parent_class;
-};
-
-
-GType logdiag_document_get_type (void) G_GNUC_CONST;
-
-LogdiagDocument *logdiag_document_new (void);
-gboolean logdiag_document_new_from_file (const char *file_name, GError *error);
-gboolean logdiag_document_save_to_file (const char *file_name, GError *error);
-
-#if 0
-/*
- * LogdiagDocumentPrivate:
- * @objects: All the objects in the document.
- */
-struct _LogdiagDocumentPrivate
-{
- GSList *objects;
-};
-
-/** The contents of the document have changed. */
-signal documentChanged (...);
-
-/* TODO: A list of objects: */
-LogdiagDocumentSymbol
-LogdiagDocumentLabel
-
-logdiag_document_add_symbol (LogdiagSymbol *symbol, x, y);
-
-/* XXX: Separated lists of objects
- * or a single list for all objects?
- */
-/* TODO: Wires. */
-logdiag_document_selection_...
-logdiag_document_selection_get_json (LogdiagDocument *self);
-logdiag_document_insert_json (LogdiagDocument *self);
-/** Go back or forward in the history of changes. */
-/* TODO: An interface that informs about the history. */
-logdiag_document_history_go (LogdiagDocument *self);
-#endif /* 0 */
-
-
-G_END_DECLS
-
-#endif /* ! __DOCUMENT_H__ */
diff --git a/src/ld-canvas.c b/src/ld-canvas.c
new file mode 100644
index 0000000..17e38a4
--- /dev/null
+++ b/src/ld-canvas.c
@@ -0,0 +1,99 @@
+/*
+ * ld-canvas.c
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#include
+
+#include "config.h"
+
+#include "ld-canvas.h"
+#include "ld-document.h"
+
+/* http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28 */
+
+/**
+ * SECTION:ld-canvas
+ * @short_description: A canvas.
+ * @see_also: #LogdiagDocument
+ *
+ * #LogdiagCanvas is used for displaying #LogdiagDocument objects.
+ */
+
+/*
+ * LogdiagCanvasPrivate:
+ * @document: A document object assigned to this canvas as a model.
+ */
+struct _LogdiagCanvasPrivate
+{
+ LogdiagDocument *document;
+};
+
+G_DEFINE_TYPE (LogdiagCanvas, logdiag_canvas, GTK_TYPE_DRAWING_AREA);
+
+static void
+logdiag_canvas_finalize (GObject *gobject);
+
+
+static void
+logdiag_canvas_class_init (LogdiagCanvasClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = logdiag_canvas_finalize;
+
+ widget_class = GTK_WIDGET_CLASS (klass);
+
+/**
+ * LogdiagCanvas::set-scroll-adjustments:
+ * @canvas: The canvas object.
+ *
+ * Contents of the library have changed.
+ */
+/*
+ widget_class->set_scroll_adjustments_signal = g_signal_new
+ ("set-scroll-adjustments", G_TYPE_FROM_CLASS (widget_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ 0, // G_STRUCT_OFFSET (LogdiagCanvasClass, ...)
+ NULL, NULL,
+ gtk_marshal_NONE__POINTER_POINTER,
+ G_TYPE_NONE, 2, GTK_TYPE_ADJUSTMENT, GTK_TYPE_ADJUSTMENT);
+*/
+ g_type_class_add_private (klass, sizeof (LogdiagCanvasPrivate));
+}
+
+static void
+logdiag_canvas_init (LogdiagCanvas *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LOGDIAG_TYPE_CANVAS, LogdiagCanvasPrivate);
+}
+
+static void
+logdiag_canvas_finalize (GObject *gobject)
+{
+ LogdiagCanvas *self;
+
+ self = LOGDIAG_CANVAS (gobject);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (logdiag_canvas_parent_class)->finalize (gobject);
+}
+
+/**
+ * logdiag_canvas_new:
+ *
+ * Create an instance.
+ */
+LogdiagCanvas *
+logdiag_canvas_new (void)
+{
+ return g_object_new (LOGDIAG_TYPE_CANVAS, NULL);
+}
diff --git a/src/ld-canvas.h b/src/ld-canvas.h
new file mode 100644
index 0000000..7dfd539
--- /dev/null
+++ b/src/ld-canvas.h
@@ -0,0 +1,59 @@
+/*
+ * ld-canvas.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __CANVAS_H__
+#define __CANVAS_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_CANVAS (logdiag_canvas_get_type ())
+#define LOGDIAG_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_CANVAS, LogdiagCanvas))
+#define LOGDIAG_CANVAS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_CANVAS, LogdiagCanvasClass))
+#define LOGDIAG_IS_CANVAS(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_CANVAS))
+#define LOGDIAG_IS_CANVAS_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_CANVAS))
+#define LOGDIAG_CANVAS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_CANVAS, LogdiagCanvasClass))
+
+typedef struct _LogdiagCanvas LogdiagCanvas;
+typedef struct _LogdiagCanvasPrivate LogdiagCanvasPrivate;
+typedef struct _LogdiagCanvasClass LogdiagCanvasClass;
+
+
+/**
+ * LogdiagCanvas:
+ */
+struct _LogdiagCanvas
+{
+/*< private >*/
+ GtkDrawingArea parent_instance;
+ LogdiagCanvasPrivate *priv;
+
+/*< public >*/
+};
+
+struct _LogdiagCanvasClass
+{
+ GtkDrawingAreaClass parent_class;
+};
+
+
+GType logdiag_canvas_get_type (void) G_GNUC_CONST;
+
+LogdiagCanvas *logdiag_canvas_new (void);
+
+
+G_END_DECLS
+
+#endif /* ! __CANVAS_H__ */
diff --git a/src/ld-document.c b/src/ld-document.c
new file mode 100644
index 0000000..e69de29
diff --git a/src/ld-document.h b/src/ld-document.h
new file mode 100644
index 0000000..b40db52
--- /dev/null
+++ b/src/ld-document.h
@@ -0,0 +1,91 @@
+/*
+ * ld-document.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __DOCUMENT_H__
+#define __DOCUMENT_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_DOCUMENT (logdiag_symbol_library_get_type ())
+#define LOGDIAG_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_DOCUMENT, LogdiagDocument))
+#define LOGDIAG_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_DOCUMENT, LogdiagDocumentClass))
+#define LOGDIAG_IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_DOCUMENT))
+#define LOGDIAG_IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_DOCUMENT))
+#define LOGDIAG_DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_DOCUMENT, LogdiagDocumentClass))
+
+typedef struct _LogdiagDocument LogdiagDocument;
+/*typedef struct _LogdiagDocumentPrivate LogdiagDocumentPrivate;*/
+typedef struct _LogdiagDocumentClass LogdiagDocumentClass;
+
+
+/**
+ * LogdiagDocument:
+ */
+struct _LogdiagDocument
+{
+/*< private >*/
+ GObject parent_instance;
+
+/*< public >*/
+};
+
+struct _LogdiagDocumentClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType logdiag_document_get_type (void) G_GNUC_CONST;
+
+LogdiagDocument *logdiag_document_new (void);
+gboolean logdiag_document_new_from_file (const char *file_name, GError *error);
+gboolean logdiag_document_save_to_file (const char *file_name, GError *error);
+
+#if 0
+/*
+ * LogdiagDocumentPrivate:
+ * @objects: All the objects in the document.
+ */
+struct _LogdiagDocumentPrivate
+{
+ GSList *objects;
+};
+
+/** The contents of the document have changed. */
+signal documentChanged (...);
+
+/* TODO: A list of objects: */
+LogdiagDocumentSymbol
+LogdiagDocumentLabel
+
+logdiag_document_add_symbol (LogdiagSymbol *symbol, x, y);
+
+/* XXX: Separated lists of objects
+ * or a single list for all objects?
+ */
+/* TODO: Wires. */
+logdiag_document_selection_...
+logdiag_document_selection_get_json (LogdiagDocument *self);
+logdiag_document_insert_json (LogdiagDocument *self);
+/** Go back or forward in the history of changes. */
+/* TODO: An interface that informs about the history. */
+logdiag_document_history_go (LogdiagDocument *self);
+#endif /* 0 */
+
+
+G_END_DECLS
+
+#endif /* ! __DOCUMENT_H__ */
diff --git a/src/ld-symbol-category.h b/src/ld-symbol-category.h
new file mode 100644
index 0000000..48c2701
--- /dev/null
+++ b/src/ld-symbol-category.h
@@ -0,0 +1,68 @@
+/*
+ * ld-symbol-category.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __SYMBOL_CATEGORY_H__
+#define __SYMBOL_CATEGORY_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_SYMBOL_CATEGORY (logdiag_symbol_category_get_type ())
+#define LOGDIAG_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_SYMBOL_CATEGORY, LogdiagSymbolCategory))
+#define LOGDIAG_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_SYMBOL_CATEGORY, LogdiagSymbolCategoryClass))
+#define LOGDIAG_IS_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_SYMBOL_CATEGORY))
+#define LOGDIAG_IS_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_SYMBOL_CATEGORY))
+#define LOGDIAG_SYMBOL_CATEGORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_SYMBOL_CATEGORY, LogdiagSymbolCategoryClass))
+
+typedef struct _LogdiagSymbolCategory LogdiagSymbolCategory;
+typedef struct _LogdiagSymbolCategoryClass LogdiagSymbolCategoryClass;
+
+
+/**
+ * LogdiagSymbolCategory:
+ * @parent: The parent object, may be LogdiagSymbolLibrary
+ * or another LogdiagSymbolCategory.
+ * @name: The name of the category.
+ * @image_path: Path to the image for this category.
+ * @children: Children of this category.
+ */
+struct _LogdiagSymbolCategory
+{
+/*< private >*/
+ GObject parent_instance;
+
+/*< public >*/
+ gpointer parent;
+ gchar *name;
+ gchar *image_path;
+ GHashTable *children;
+};
+
+struct _LogdiagSymbolCategoryClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType logdiag_symbol_category_get_type (void) G_GNUC_CONST;
+
+LogdiagSymbolCategory *
+logdiag_symbol_category_new (LogdiagSymbolLibrary *parent);
+
+
+G_END_DECLS
+
+#endif /* ! __SYMBOL_CATEGORY_H__ */
+
diff --git a/src/ld-symbol-library.c b/src/ld-symbol-library.c
new file mode 100644
index 0000000..8876dd8
--- /dev/null
+++ b/src/ld-symbol-library.c
@@ -0,0 +1,373 @@
+/*
+ * ld-symbol-library.c
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#include
+#include
+/* #include */
+
+#include "config.h"
+
+#include "ld-symbol-library.h"
+#include "ld-symbol-category.h"
+#include "ld-symbol.h"
+
+/* ===== Symbol library ==================================================== */
+
+/**
+ * SECTION:ld-symbol-library
+ * @short_description: A symbol library.
+ * @see_also: #LogdiagSymbol, #LogdiagSymbolCategory
+ *
+ * #LogdiagSymbolLibrary is used for loading symbols from their files.
+ */
+
+/*
+ * LogdiagSymbolLibraryPrivate:
+ * @lua_state: Lua state.
+ */
+struct _LogdiagSymbolLibraryPrivate
+{
+ lua_State *lua_state;
+};
+
+G_DEFINE_TYPE (LogdiagSymbolLibrary, logdiag_symbol_library, G_TYPE_OBJECT);
+
+static void
+logdiag_symbol_library_finalize (GObject *gobject);
+
+
+static void
+logdiag_symbol_library_class_init (LogdiagSymbolLibraryClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = logdiag_symbol_library_finalize;
+
+/**
+ * LogdiagSymbolLibrary::changed:
+ * @library: The library object.
+ *
+ * Contents of the library have changed.
+ */
+ klass->changed_signal = g_signal_new
+ ("changed", G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
+ 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
+
+ g_type_class_add_private (klass, sizeof (LogdiagSymbolLibraryPrivate));
+}
+
+static void
+logdiag_symbol_library_init (LogdiagSymbolLibrary *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibraryPrivate);
+
+ /* TODO: lua */
+ self->priv->lua_state = NULL;
+
+ self->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
+ (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
+}
+
+static void
+logdiag_symbol_library_finalize (GObject *gobject)
+{
+ LogdiagSymbolLibrary *self;
+
+ self = LOGDIAG_SYMBOL_LIBRARY (gobject);
+
+ g_hash_table_destroy (self->categories);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (logdiag_symbol_library_parent_class)->finalize (gobject);
+}
+
+/**
+ * logdiag_symbol_library_new:
+ *
+ * Create an instance.
+ */
+LogdiagSymbolLibrary *
+logdiag_symbol_library_new (void)
+{
+ return g_object_new (LOGDIAG_TYPE_SYMBOL_LIBRARY, NULL);
+}
+
+/*
+ * load_category:
+ * @self: A symbol library object.
+ * @path: The path to the category.
+ * @name: The default name of the category.
+ *
+ * Loads a category into the library.
+ */
+static LogdiagSymbolCategory *
+load_category (LogdiagSymbolLibrary *self, const char *path, const char *name)
+{
+ LogdiagSymbolCategory *cat;
+ gchar *icon_file;
+
+ g_return_val_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self), NULL);
+ g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (name != NULL, NULL);
+
+ if (!g_file_test (path, G_FILE_TEST_IS_DIR))
+ return NULL;
+
+ icon_file = g_build_filename (path, "icon.svg", NULL);
+ if (!g_file_test (icon_file, G_FILE_TEST_IS_REGULAR))
+ {
+ g_warning ("The category in %s has no icon.", path);
+ g_free (icon_file);
+ return NULL;
+ }
+
+ /* TODO: Search for category.json and read the category name from it. */
+ /* TODO: Search for xyz.lua and load the objects into the category. */
+
+ cat = logdiag_symbol_category_new (self);
+ cat->name = g_strdup (name);
+ cat->image_path = icon_file;
+ return cat;
+}
+
+/**
+ * logdiag_symbol_library_load:
+ * @self: A symbol library object.
+ * @directory: A directory to be loaded.
+ *
+ * Load the contents of a directory into the library.
+ */
+gboolean
+logdiag_symbol_library_load (LogdiagSymbolLibrary *self, const char *path)
+{
+ GDir *dir;
+ const gchar *item;
+
+ g_return_val_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self), FALSE);
+ g_return_val_if_fail (path != NULL, FALSE);
+
+ dir = g_dir_open (path, 0, NULL);
+ if (!dir)
+ return FALSE;
+
+ while ((item = g_dir_read_name (dir)))
+ {
+ LogdiagSymbolCategory *cat;
+ gchar *categ_path;
+
+ categ_path = g_build_filename (path, item, NULL);
+ cat = load_category (self, categ_path, item);
+ if (cat)
+ g_hash_table_insert (self->categories, cat->name, cat);
+ g_free (categ_path);
+ }
+ g_dir_close (dir);
+ return TRUE;
+}
+
+/**
+ * logdiag_symbol_library_clear:
+ * @self: A symbol library object.
+ *
+ * Clears all the contents.
+ */
+void
+logdiag_symbol_library_clear (LogdiagSymbolLibrary *self)
+{
+ g_return_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self));
+
+ g_hash_table_remove_all (self->categories);
+ return;
+}
+
+
+/* ===== Symbol category =================================================== */
+
+/**
+ * SECTION:ld-symbol-category
+ * @short_description: A category of symbols.
+ * @see_also: #LogdiagSymbol, #LogdiagSymbolLibrary
+ *
+ * #LogdiagSymbolCategory represents a category of #LogdiagSymbol objects.
+ */
+
+G_DEFINE_TYPE (LogdiagSymbolCategory, logdiag_symbol_category, G_TYPE_OBJECT);
+
+static void
+logdiag_symbol_category_finalize (GObject *gobject);
+
+
+static void
+logdiag_symbol_category_class_init (LogdiagSymbolCategoryClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = logdiag_symbol_category_finalize;
+}
+
+static void
+logdiag_symbol_category_init (LogdiagSymbolCategory *self)
+{
+ /* TODO: use _new_full, correct equal and specify destroy functions. */
+ /* XXX: How's the situation with subcategory names and symbol names
+ * within the same hashtable?
+ */
+ self->children = g_hash_table_new (g_str_hash, g_str_equal);
+}
+
+static void
+logdiag_symbol_category_finalize (GObject *gobject)
+{
+ LogdiagSymbolCategory *self;
+
+ self = LOGDIAG_SYMBOL_CATEGORY (gobject);
+
+ if (self->name)
+ g_free (self->name);
+ if (self->image_path)
+ g_free (self->image_path);
+
+ g_object_unref (self->parent);
+ g_hash_table_destroy (self->children);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (logdiag_symbol_category_parent_class)->finalize (gobject);
+}
+
+/**
+ * logdiag_symbol_category_new:
+ * @parent: The parent library for this category.
+ *
+ * Create an instance.
+ */
+LogdiagSymbolCategory *
+logdiag_symbol_category_new (LogdiagSymbolLibrary *parent)
+{
+ LogdiagSymbolCategory *cat;
+
+ cat = g_object_new (LOGDIAG_TYPE_SYMBOL_CATEGORY, NULL);
+
+ cat->parent = parent;
+ g_object_ref (parent);
+
+ return cat;
+}
+
+
+/* ===== Symbol ============================================================ */
+
+/**
+ * SECTION:ld-symbol
+ * @short_description: A symbol.
+ * @see_also: #LogdiagDocument, #LogdiagCanvas
+ *
+ * #LogdiagSymbol represents a symbol in the #LogdiagDocument that is in turn
+ * drawn onto the #LogdiagCanvas.
+ */
+
+/*
+ * LogdiagSymbolPrivate:
+ * @library: The parent LogdiagSymbolLibrary.
+ * The library contains the real function for rendering.
+ */
+struct _LogdiagSymbolPrivate
+{
+ LogdiagSymbolLibrary *library;
+};
+
+G_DEFINE_TYPE (LogdiagSymbol, logdiag_symbol, G_TYPE_OBJECT);
+
+static void
+logdiag_symbol_finalize (GObject *gobject);
+
+
+static void
+logdiag_symbol_class_init (LogdiagSymbolClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = logdiag_symbol_finalize;
+
+ g_type_class_add_private (klass, sizeof (LogdiagSymbolPrivate));
+}
+
+static void
+logdiag_symbol_init (LogdiagSymbol *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolPrivate);
+}
+
+static void
+logdiag_symbol_finalize (GObject *gobject)
+{
+ LogdiagSymbol *self;
+
+ self = LOGDIAG_SYMBOL (gobject);
+ g_object_unref (self->priv->library);
+
+ /* Chain up to the parent class. */
+ G_OBJECT_CLASS (logdiag_symbol_parent_class)->finalize (gobject);
+}
+
+/**
+ * logdiag_symbol_new:
+ * @library: A library object.
+ * @filename: The file from which the symbol will be loaded.
+ *
+ * Load a symbol from a file into the library.
+ */
+LogdiagSymbol *logdiag_symbol_new (LogdiagSymbolLibrary *library,
+ const gchar *filename)
+{
+ LogdiagSymbol *symbol;
+
+ symbol = g_object_new (LOGDIAG_TYPE_SYMBOL, NULL);
+ /* TODO: Use the filename, Luke. */
+
+ symbol->priv->library = library;
+ g_object_ref (library);
+}
+
+/**
+ * logdiag_symbol_build_identifier:
+ * @self: A symbol object.
+ *
+ * Build an identifier for the symbol.
+ * The identifier is in the format "Category/Category/Symbol".
+ */
+char *
+logdiag_symbol_build_identifier (LogdiagSymbol *self)
+{
+ return NULL;
+}
+
+/**
+ * logdiag_symbol_draw:
+ * @self: A symbol object.
+ * @surface: A cairo surface to be drawn on.
+ * @param: Parameters for the symbol in a table.
+ * @x: The X coordinate on the surface.
+ * @y: The Y coordinate on the surface.
+ * @zoom: Zoom ratio.
+ *
+ * Draw the symbol onto a Cairo surface.
+ */
+void
+logdiag_symbol_draw (LogdiagSymbol *self, cairo_t *surface,
+ GHashTable *param, gint x, gint y, gdouble zoom)
+{
+ return;
+}
diff --git a/src/ld-symbol-library.h b/src/ld-symbol-library.h
new file mode 100644
index 0000000..11350ba
--- /dev/null
+++ b/src/ld-symbol-library.h
@@ -0,0 +1,69 @@
+/*
+ * ld-symbol-library.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __SYMBOL_LIBRARY_H__
+#define __SYMBOL_LIBRARY_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_SYMBOL_LIBRARY (logdiag_symbol_library_get_type ())
+#define LOGDIAG_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibrary))
+#define LOGDIAG_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibraryClass))
+#define LOGDIAG_IS_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_SYMBOL_LIBRARY))
+#define LOGDIAG_IS_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_SYMBOL_LIBRARY))
+#define LOGDIAG_SYMBOL_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_SYMBOL_LIBRARY, LogdiagSymbolLibraryClass))
+
+typedef struct _LogdiagSymbolLibrary LogdiagSymbolLibrary;
+typedef struct _LogdiagSymbolLibraryPrivate LogdiagSymbolLibraryPrivate;
+typedef struct _LogdiagSymbolLibraryClass LogdiagSymbolLibraryClass;
+
+
+/**
+ * LogdiagSymbolLibrary:
+ * @categories: Lists all the categories (#LogdiagSymbolCategory).
+ *
+ * Object structure.
+ */
+struct _LogdiagSymbolLibrary
+{
+/*< private >*/
+ GObject parent_instance;
+ LogdiagSymbolLibraryPrivate *priv;
+
+/*< public >*/
+ GHashTable *categories;
+};
+
+struct _LogdiagSymbolLibraryClass
+{
+/*< private >*/
+ GObjectClass parent_class;
+ guint changed_signal;
+};
+
+
+GType logdiag_symbol_library_get_type (void) G_GNUC_CONST;
+
+LogdiagSymbolLibrary *logdiag_symbol_library_new (void);
+gboolean logdiag_symbol_library_load (LogdiagSymbolLibrary *self,
+ const char *directory);
+void logdiag_symbol_library_clear (LogdiagSymbolLibrary *self);
+
+
+G_END_DECLS
+
+#endif /* ! __SYMBOL_LIBRARY_H__ */
+
diff --git a/src/ld-symbol.h b/src/ld-symbol.h
new file mode 100644
index 0000000..c1fd65c
--- /dev/null
+++ b/src/ld-symbol.h
@@ -0,0 +1,69 @@
+/*
+ * ld-symbol.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __SYMBOL_H__
+#define __SYMBOL_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_SYMBOL (logdiag_symbol_get_type ())
+#define LOGDIAG_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_SYMBOL, LogdiagSymbol))
+#define LOGDIAG_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_SYMBOL, LogdiagSymbolClass))
+#define LOGDIAG_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_SYMBOL))
+#define LOGDIAG_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_SYMBOL))
+#define LOGDIAG_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_SYMBOL, LogdiagSymbolClass))
+
+typedef struct _LogdiagSymbol LogdiagSymbol;
+typedef struct _LogdiagSymbolPrivate LogdiagSymbolPrivate;
+typedef struct _LogdiagSymbolClass LogdiagSymbolClass;
+
+
+/**
+ * LogdiagSymbol:
+ * @name: The name of this symbol.
+ */
+struct _LogdiagSymbol
+{
+/*< private >*/
+ GObject parent_instance;
+ LogdiagSymbolPrivate *priv;
+
+/*< public >*/
+ gchar *name;
+};
+
+struct _LogdiagSymbolClass
+{
+ GObjectClass parent_class;
+};
+
+
+GType logdiag_symbol_get_type (void) G_GNUC_CONST;
+
+LogdiagSymbol *logdiag_symbol_new (LogdiagSymbolLibrary *library,
+ const gchar *filename);
+char *logdiag_symbol_build_identifier (LogdiagSymbol *self);
+void logdiag_symbol_draw (LogdiagSymbol *self, cairo_t *surface,
+ GHashTable *param, gint x, gint y, gdouble zoom);
+
+/* TODO: Funkce pro získání terminálů. */
+
+
+
+G_END_DECLS
+
+#endif /* ! __SYMBOL_H__ */
+
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
new file mode 100644
index 0000000..db83869
--- /dev/null
+++ b/src/ld-window-main.c
@@ -0,0 +1,351 @@
+/*
+ * window-main.c
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#include
+
+#include "config.h"
+
+#include "ld-window-main.h"
+#include "ld-canvas.h"
+#include "ld-document.h"
+#include "ld-symbol-library.h"
+#include "ld-symbol-category.h"
+#include "ld-symbol.h"
+
+
+/**
+ * SECTION:ld-window-main
+ * @short_description: The main application window.
+ *
+ * #LogdiagWindowMain is the main window of the application.
+ */
+/* NOTE: The main window should not maybe be included in either
+ * the documentation or the static library.
+ */
+
+
+/* Private members of the window. */
+struct _LogdiagWindowMainPrivate
+{
+ GtkWidget *vbox;
+ GtkWidget *hbox;
+ GtkWidget *menu;
+ GtkWidget *toolbar;
+
+ LogdiagSymbolLibrary *library;
+ LogdiagCanvas *canvas;
+
+ GtkWidget *statusbar;
+ guint statusbar_menu_context_id;
+};
+
+struct DocumentData
+{
+ LogdiagDocument *document;
+ const gchar *file_name;
+ /* Canvas viewport settings (for multitabbed) */
+};
+
+/* Define the type. */
+G_DEFINE_TYPE (LogdiagWindowMain, logdiag_window_main, GTK_TYPE_WINDOW);
+
+
+/* ===== Local functions =================================================== */
+
+/*
+ * cb_load_category:
+ *
+ * A hashtable foreach callback for adding categories into the toolbar.
+ */
+static void
+cb_load_category (gpointer key, gpointer value, gpointer user_data);
+
+/*
+ * load_toolbar:
+ *
+ * Load symbols from the library into the toolbar.
+ */
+static void
+load_toolbar (LogdiagWindowMain *self);
+
+/*
+ * cb_ui_proxy_connected:
+ *
+ * An item was connected to the manager.
+ */
+static void
+cb_ui_proxy_connected (GtkUIManager *ui, GtkAction *action,
+ GtkWidget *proxy, LogdiagWindowMain *window);
+
+/*
+ * cb_ui_proxy_disconnected:
+ *
+ * An item was disconnected from the manager.
+ */
+static void
+cb_ui_proxy_disconnected (GtkUIManager *ui, GtkAction *action,
+ GtkWidget *proxy, LogdiagWindowMain *window);
+
+/* A menu item was selected. */
+static void
+cb_menu_item_selected (GtkWidget *item, LogdiagWindowMain *window);
+
+/* A menu item was deselected. */
+static void
+cb_menu_item_deselected (GtkItem *item, LogdiagWindowMain *window);
+
+/* Show the about dialog. */
+static void
+cb_show_about_dialog (GtkAction *action, LogdiagWindowMain *window);
+
+
+/* ===== Local variables =================================================== */
+
+/* Actions for menus, toolbars, accelerators. */
+static GtkActionEntry mw_actionEntries[] =
+{
+ {"FileMenu", NULL, Q_("_File")},
+ {"New", GTK_STOCK_NEW, NULL, NULL,
+ Q_("Create a new document"), NULL},
+ {"Open", GTK_STOCK_OPEN, NULL, NULL,
+ Q_("Open a document"), NULL},
+ {"Save", GTK_STOCK_SAVE, NULL, NULL,
+ Q_("Save the current document"), NULL},
+ {"SaveAs", GTK_STOCK_SAVE_AS, NULL, NULL,
+ Q_("Save the current document with another name"), NULL},
+ {"Export", NULL, Q_("_Export"), NULL,
+ Q_("Export the document"), NULL},
+ {"Quit", GTK_STOCK_QUIT, NULL, NULL,
+ Q_("Quit the program"), NULL},
+
+ {"EditMenu", NULL, Q_("_Edit")},
+ {"Cut", GTK_STOCK_CUT, NULL, NULL, NULL, NULL},
+ {"Copy", GTK_STOCK_COPY, NULL, NULL, NULL, NULL},
+ {"Paste", GTK_STOCK_PASTE, NULL, NULL, NULL, NULL},
+ {"Delete", GTK_STOCK_DELETE, NULL, NULL, NULL, NULL},
+ {"SelectAll", GTK_STOCK_SELECT_ALL, NULL, NULL, NULL, NULL},
+
+ {"HelpMenu", NULL, Q_("_Help")},
+ {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL,
+ G_CALLBACK(cb_show_about_dialog)}
+};
+
+
+
+/**
+ * logdiag_window_main_new:
+ *
+ * Create an instance.
+ */
+GtkWidget *
+logdiag_window_main_new (void)
+{
+ return g_object_new (LOGDIAG_TYPE_WINDOW_MAIN, NULL);
+}
+
+static void
+logdiag_window_main_class_init (LogdiagWindowMainClass *klass)
+{
+ GObjectClass *object_class;
+ GtkWidgetClass *widget_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ widget_class = GTK_WIDGET_CLASS (klass);
+
+ g_type_class_add_private (klass, sizeof (LogdiagWindowMainPrivate));
+}
+
+static void
+logdiag_window_main_init (LogdiagWindowMain *self)
+{
+ LogdiagWindowMainPrivate *priv;
+ GtkActionGroup *action_group;
+ GtkUIManager *ui_manager;
+ GError *error;
+
+ self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE
+ (self, LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMainPrivate);
+
+ priv->vbox = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (self), priv->vbox);
+
+
+ ui_manager = gtk_ui_manager_new ();
+
+ /* TODO: Show tooltips in the statusbar:
+ * http://git.gnome.org/browse/glade3/tree/src/glade-window.c : 2165
+ */
+ g_signal_connect (ui_manager, "connect-proxy",
+ G_CALLBACK (cb_ui_proxy_connected), self);
+ g_signal_connect (ui_manager, "disconnect-proxy",
+ G_CALLBACK (cb_ui_proxy_disconnected), self);
+
+ /* Prepare our actions. */
+ action_group = gtk_action_group_new ("MainActions");
+ gtk_action_group_add_actions (action_group,
+ mw_actionEntries, G_N_ELEMENTS (mw_actionEntries), self);
+ gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
+
+ error = NULL;
+ gtk_ui_manager_add_ui_from_file
+ (ui_manager, PROJECT_SHARE_DIR "gui/window-main.ui", &error);
+ if (error)
+ {
+ g_message (_("Building UI failed: %s"), error->message);
+ g_error_free (error);
+ }
+
+ /* Load keyboard accelerators into the window. */
+ gtk_window_add_accel_group
+ (GTK_WINDOW (self), gtk_ui_manager_get_accel_group (ui_manager));
+
+ priv->menu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
+ gtk_box_pack_start (GTK_BOX (priv->vbox), priv->menu, FALSE, FALSE, 0);
+
+ priv->hbox = gtk_hbox_new(FALSE, 0);
+ gtk_box_pack_start (GTK_BOX (priv->vbox), priv->hbox, TRUE, TRUE, 0);
+
+ /* Add the symbol toolbar. */
+ priv->toolbar = gtk_toolbar_new ();
+ /* NOTE: For GTK 2.16+, s/toolbar/orientable/ */
+ gtk_toolbar_set_orientation
+ (GTK_TOOLBAR (priv->toolbar), GTK_ORIENTATION_VERTICAL);
+ gtk_toolbar_set_icon_size
+ (GTK_TOOLBAR (priv->toolbar), GTK_ICON_SIZE_LARGE_TOOLBAR);
+ gtk_toolbar_set_style
+ (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
+
+ gtk_box_pack_start (GTK_BOX (priv->hbox), priv->toolbar, FALSE, FALSE, 0);
+
+ /* Symbol library. */
+ priv->library = logdiag_symbol_library_new ();
+ logdiag_symbol_library_load (priv->library, PROJECT_SHARE_DIR "library");
+
+ load_toolbar (self);
+
+ /* Canvas. */
+ priv->canvas = logdiag_canvas_new ();
+ gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->canvas),
+ FALSE, FALSE, 0);
+
+ /* TODO: GtkHPaned */
+
+ priv->statusbar = gtk_statusbar_new ();
+ priv->statusbar_menu_context_id = gtk_statusbar_get_context_id
+ (GTK_STATUSBAR (priv->statusbar), "menu");
+ gtk_box_pack_end (GTK_BOX (priv->vbox), priv->statusbar, FALSE, FALSE, 0);
+
+
+ /* TODO: Do this on disposal. */
+ /* g_object_unref(ui_manager); */
+
+ /* Proceed to showing the window. */
+ g_signal_connect (self, "destroy", G_CALLBACK (gtk_main_quit), NULL);
+ gtk_window_set_default_size (GTK_WINDOW (self), 500, 400);
+ gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+static void
+cb_load_category (gpointer key, gpointer value, gpointer user_data)
+{
+ const gchar *name;
+ LogdiagSymbolCategory *cat;
+ LogdiagWindowMain *self;
+ GdkPixbuf *pbuf;
+ GtkWidget *img;
+ GtkToolItem *item;
+
+ name = key;
+ cat = value;
+ self = user_data;
+
+ g_return_if_fail (key != NULL);
+ g_return_if_fail (LOGDIAG_IS_SYMBOL_CATEGORY (cat));
+
+ /* XXX: Hardcoded icon width, unref? */
+ pbuf = gdk_pixbuf_new_from_file_at_size (cat->image_path, 32, -1, NULL);
+ if (!pbuf)
+ return;
+ img = gtk_image_new_from_pixbuf (pbuf);
+ g_object_unref (pbuf);
+
+ item = gtk_tool_button_new (img, name);
+ gtk_tool_item_set_tooltip_text (item, name);
+ gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0);
+}
+
+static void
+load_toolbar (LogdiagWindowMain *self)
+{
+ /* TODO: Clear the toolbar first, if there was already something in it. */
+
+ g_hash_table_foreach (self->priv->library->categories,
+ cb_load_category, self);
+}
+
+static void
+cb_ui_proxy_connected (GtkUIManager *ui, GtkAction *action,
+ GtkWidget *proxy, LogdiagWindowMain *window)
+{
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_connect (proxy, "select",
+ G_CALLBACK (cb_menu_item_selected), window);
+ g_signal_connect (proxy, "deselect",
+ G_CALLBACK (cb_menu_item_deselected), window);
+ }
+}
+
+static void
+cb_ui_proxy_disconnected (GtkUIManager *ui, GtkAction *action,
+ GtkWidget *proxy, LogdiagWindowMain *window)
+{
+ if (GTK_IS_MENU_ITEM (proxy))
+ {
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (cb_menu_item_selected), window);
+ g_signal_handlers_disconnect_by_func
+ (proxy, G_CALLBACK (cb_menu_item_deselected), window);
+ }
+}
+
+static void
+cb_menu_item_selected (GtkWidget *item, LogdiagWindowMain *window)
+{
+ GtkAction *action;
+ gchar *tooltip;
+
+ action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
+ g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
+
+ if (tooltip != NULL)
+ gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->statusbar_menu_context_id, tooltip);
+
+ g_free (tooltip);
+}
+
+static void
+cb_menu_item_deselected (GtkItem *item, LogdiagWindowMain *window)
+{
+ gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
+ window->priv->statusbar_menu_context_id);
+}
+
+static void
+cb_show_about_dialog (GtkAction *action, LogdiagWindowMain *window)
+{
+ gtk_show_about_dialog (GTK_WINDOW (window),
+ "program-name", PROJECT_NAME,
+ "version", PROJECT_VERSION,
+ "copyright", "Copyright Přemysl Janouch 2010",
+ NULL);
+}
+
diff --git a/src/ld-window-main.h b/src/ld-window-main.h
new file mode 100644
index 0000000..a637a1b
--- /dev/null
+++ b/src/ld-window-main.h
@@ -0,0 +1,60 @@
+/*
+ * ld-window-main.h
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#ifndef __WINDOW_MAIN_H__
+#define __WINDOW_MAIN_H__
+
+G_BEGIN_DECLS
+
+
+#define LOGDIAG_TYPE_WINDOW_MAIN (logdiag_window_main_get_type ())
+#define LOGDIAG_WINDOW_MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST \
+ ((obj), LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMain))
+#define LOGDIAG_WINDOW_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
+ ((klass), LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMainClass))
+#define LOGDIAG_IS_WINDOW_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((obj), LOGDIAG_TYPE_WINDOW_MAIN))
+#define LOGDIAG_IS_WINDOW_MAIN_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
+ ((klass), LOGDIAG_TYPE_WINDOW_MAIN))
+#define LOGDIAG_WINDOW_MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
+ ((obj), LOGDIAG_WINDOW_MAIN, LogdiagWindowMainClass))
+
+typedef struct _LogdiagWindowMain LogdiagWindowMain;
+typedef struct _LogdiagWindowMainPrivate LogdiagWindowMainPrivate;
+typedef struct _LogdiagWindowMainClass LogdiagWindowMainClass;
+
+
+/**
+ * LogdiagWindowMain:
+ *
+ * Object structure.
+ */
+struct _LogdiagWindowMain
+{
+/*< private >*/
+ GtkWindow parent_instance;
+ LogdiagWindowMainPrivate *priv;
+};
+
+struct _LogdiagWindowMainClass
+{
+ GtkWindowClass parent_class;
+};
+
+
+GType logdiag_window_main_get_type (void) G_GNUC_CONST;
+
+GtkWidget *logdiag_window_main_new (void);
+
+
+G_END_DECLS
+
+#endif /* ! __WINDOW_MAIN_H__ */
+
diff --git a/src/logdiag.c b/src/logdiag.c
new file mode 100644
index 0000000..4f69916
--- /dev/null
+++ b/src/logdiag.c
@@ -0,0 +1,39 @@
+/*
+ * logdiag.c -- logdiag main source file.
+ *
+ * This file is a part of logdiag.
+ * Copyright Přemysl Janouch 2010. All rights reserved.
+ *
+ * See the file LICENSE for licensing information.
+ *
+ */
+
+#include
+
+#include "config.h"
+
+#include "ld-window-main.h"
+
+
+int main (int argc, char *argv[])
+{
+ GtkWidget *wnd;
+
+#ifdef HAVE_GETTEXT
+ setlocale (LC_ALL, "");
+
+ bindtextdomain (GETTEXT_DOMAIN, GETTEXT_DIRNAME);
+ textdomain (GETTEXT_DOMAIN);
+#endif
+
+ /* For custom command line arguments, see:
+ * http://git.gnome.org/browse/glade3/tree/src/main.c
+ */
+
+ gtk_init (&argc, &argv);
+ wnd = logdiag_window_main_new ();
+ gtk_main ();
+
+ return 0;
+}
+
diff --git a/src/main.c b/src/main.c
deleted file mode 100644
index 5c9723f..0000000
--- a/src/main.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * main.c -- logdiag main source file.
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#include
-
-#include "config.h"
-
-#include "window-main.h"
-
-
-int main (int argc, char *argv[])
-{
- GtkWidget *wnd;
-
-#ifdef HAVE_GETTEXT
- setlocale (LC_ALL, "");
-
- bindtextdomain (GETTEXT_DOMAIN, GETTEXT_DIRNAME);
- textdomain (GETTEXT_DOMAIN);
-#endif
-
- /* For custom command line arguments, see:
- * http://git.gnome.org/browse/glade3/tree/src/main.c
- */
-
- gtk_init (&argc, &argv);
- wnd = logdiag_window_main_new ();
- gtk_main ();
-
- return 0;
-}
-
diff --git a/src/symbol-category.h b/src/symbol-category.h
deleted file mode 100644
index 51ccb78..0000000
--- a/src/symbol-category.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * symbol-category.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __SYMBOL_CATEGORY_H__
-#define __SYMBOL_CATEGORY_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_SYMBOL_CATEGORY (logdiag_symbol_category_get_type ())
-#define LOGDIAG_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_SYMBOL_CATEGORY, LogdiagSymbolCategory))
-#define LOGDIAG_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_SYMBOL_CATEGORY, LogdiagSymbolCategoryClass))
-#define LOGDIAG_IS_SYMBOL_CATEGORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_SYMBOL_CATEGORY))
-#define LOGDIAG_IS_SYMBOL_CATEGORY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_SYMBOL_CATEGORY))
-#define LOGDIAG_SYMBOL_CATEGORY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_SYMBOL_CATEGORY, LogdiagSymbolCategoryClass))
-
-typedef struct _LogdiagSymbolCategory LogdiagSymbolCategory;
-typedef struct _LogdiagSymbolCategoryClass LogdiagSymbolCategoryClass;
-
-
-/**
- * LogdiagSymbolCategory:
- * @parent: The parent object, may be LogdiagSymbolLibrary
- * or another LogdiagSymbolCategory.
- * @name: The name of the category.
- * @image_path: Path to the image for this category.
- * @children: Children of this category.
- */
-struct _LogdiagSymbolCategory
-{
-/*< private >*/
- GObject parent_instance;
-
-/*< public >*/
- gpointer parent;
- gchar *name;
- gchar *image_path;
- GHashTable *children;
-};
-
-struct _LogdiagSymbolCategoryClass
-{
- GObjectClass parent_class;
-};
-
-
-GType logdiag_symbol_category_get_type (void) G_GNUC_CONST;
-
-LogdiagSymbolCategory *
-logdiag_symbol_category_new (LogdiagSymbolLibrary *parent);
-
-
-G_END_DECLS
-
-#endif /* ! __SYMBOL_CATEGORY_H__ */
-
diff --git a/src/symbol-library.c b/src/symbol-library.c
deleted file mode 100644
index 679a068..0000000
--- a/src/symbol-library.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * symbol-library.c
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#include
-#include
-/* #include */
-
-#include "config.h"
-
-#include "symbol-library.h"
-#include "symbol-category.h"
-#include "symbol.h"
-
-/* ===== Symbol library ==================================================== */
-
-/**
- * SECTION:symbol-library
- * @short_description: A symbol library.
- * @see_also: #LogdiagSymbol, #LogdiagSymbolCategory
- *
- * #LogdiagSymbolLibrary is used for loading symbols from their files.
- */
-
-/*
- * LogdiagSymbolLibraryPrivate:
- * @lua_state: Lua state.
- */
-struct _LogdiagSymbolLibraryPrivate
-{
- lua_State *lua_state;
-};
-
-G_DEFINE_TYPE (LogdiagSymbolLibrary, logdiag_symbol_library, G_TYPE_OBJECT);
-
-static void
-logdiag_symbol_library_finalize (GObject *gobject);
-
-
-static void
-logdiag_symbol_library_class_init (LogdiagSymbolLibraryClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = logdiag_symbol_library_finalize;
-
-/**
- * LogdiagSymbolLibrary::changed:
- * @library: The library object.
- *
- * Contents of the library have changed.
- */
- klass->changed_signal = g_signal_new
- ("changed", G_TYPE_FROM_CLASS (object_class),
- G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
- 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
-
- g_type_class_add_private (klass, sizeof (LogdiagSymbolLibraryPrivate));
-}
-
-static void
-logdiag_symbol_library_init (LogdiagSymbolLibrary *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibraryPrivate);
-
- /* TODO: lua */
- self->priv->lua_state = NULL;
-
- self->categories = g_hash_table_new_full (g_str_hash, g_str_equal,
- (GDestroyNotify) g_free, (GDestroyNotify) g_object_unref);
-}
-
-static void
-logdiag_symbol_library_finalize (GObject *gobject)
-{
- LogdiagSymbolLibrary *self;
-
- self = LOGDIAG_SYMBOL_LIBRARY (gobject);
-
- g_hash_table_destroy (self->categories);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (logdiag_symbol_library_parent_class)->finalize (gobject);
-}
-
-/**
- * logdiag_symbol_library_new:
- *
- * Create an instance.
- */
-LogdiagSymbolLibrary *
-logdiag_symbol_library_new (void)
-{
- return g_object_new (LOGDIAG_TYPE_SYMBOL_LIBRARY, NULL);
-}
-
-/*
- * load_category:
- * @self: A symbol library object.
- * @path: The path to the category.
- * @name: The default name of the category.
- *
- * Loads a category into the library.
- */
-static LogdiagSymbolCategory *
-load_category (LogdiagSymbolLibrary *self, const char *path, const char *name)
-{
- LogdiagSymbolCategory *cat;
- gchar *icon_file;
-
- g_return_val_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self), NULL);
- g_return_val_if_fail (path != NULL, NULL);
- g_return_val_if_fail (name != NULL, NULL);
-
- if (!g_file_test (path, G_FILE_TEST_IS_DIR))
- return NULL;
-
- icon_file = g_build_filename (path, "icon.svg", NULL);
- if (!g_file_test (icon_file, G_FILE_TEST_IS_REGULAR))
- {
- g_warning ("The category in %s has no icon.", path);
- g_free (icon_file);
- return NULL;
- }
-
- /* TODO: Search for category.json and read the category name from it. */
- /* TODO: Search for xyz.lua and load the objects into the category. */
-
- cat = logdiag_symbol_category_new (self);
- cat->name = g_strdup (name);
- cat->image_path = icon_file;
- return cat;
-}
-
-/**
- * logdiag_symbol_library_load:
- * @self: A symbol library object.
- * @directory: A directory to be loaded.
- *
- * Load the contents of a directory into the library.
- */
-gboolean
-logdiag_symbol_library_load (LogdiagSymbolLibrary *self, const char *path)
-{
- GDir *dir;
- const gchar *item;
-
- g_return_val_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self), FALSE);
- g_return_val_if_fail (path != NULL, FALSE);
-
- dir = g_dir_open (path, 0, NULL);
- if (!dir)
- return FALSE;
-
- while ((item = g_dir_read_name (dir)))
- {
- LogdiagSymbolCategory *cat;
- gchar *categ_path;
-
- categ_path = g_build_filename (path, item, NULL);
- cat = load_category (self, categ_path, item);
- if (cat)
- g_hash_table_insert (self->categories, cat->name, cat);
- g_free (categ_path);
- }
- g_dir_close (dir);
- return TRUE;
-}
-
-/**
- * logdiag_symbol_library_clear:
- * @self: A symbol library object.
- *
- * Clears all the contents.
- */
-void
-logdiag_symbol_library_clear (LogdiagSymbolLibrary *self)
-{
- g_return_if_fail (LOGDIAG_IS_SYMBOL_LIBRARY (self));
-
- g_hash_table_remove_all (self->categories);
- return;
-}
-
-
-/* ===== Symbol category =================================================== */
-
-/**
- * SECTION:symbol-category
- * @short_description: A category of symbols.
- * @see_also: #LogdiagSymbol, #LogdiagSymbolLibrary
- *
- * #LogdiagSymbolCategory represents a category of #LogdiagSymbol objects.
- */
-
-G_DEFINE_TYPE (LogdiagSymbolCategory, logdiag_symbol_category, G_TYPE_OBJECT);
-
-static void
-logdiag_symbol_category_finalize (GObject *gobject);
-
-
-static void
-logdiag_symbol_category_class_init (LogdiagSymbolCategoryClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = logdiag_symbol_category_finalize;
-}
-
-static void
-logdiag_symbol_category_init (LogdiagSymbolCategory *self)
-{
- /* TODO: use _new_full, correct equal and specify destroy functions. */
- /* XXX: How's the situation with subcategory names and symbol names
- * within the same hashtable?
- */
- self->children = g_hash_table_new (g_str_hash, g_str_equal);
-}
-
-static void
-logdiag_symbol_category_finalize (GObject *gobject)
-{
- LogdiagSymbolCategory *self;
-
- self = LOGDIAG_SYMBOL_CATEGORY (gobject);
-
- if (self->name)
- g_free (self->name);
- if (self->image_path)
- g_free (self->image_path);
-
- g_object_unref (self->parent);
- g_hash_table_destroy (self->children);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (logdiag_symbol_category_parent_class)->finalize (gobject);
-}
-
-/**
- * logdiag_symbol_category_new:
- * @parent: The parent library for this category.
- *
- * Create an instance.
- */
-LogdiagSymbolCategory *
-logdiag_symbol_category_new (LogdiagSymbolLibrary *parent)
-{
- LogdiagSymbolCategory *cat;
-
- cat = g_object_new (LOGDIAG_TYPE_SYMBOL_CATEGORY, NULL);
-
- cat->parent = parent;
- g_object_ref (parent);
-
- return cat;
-}
-
-
-/* ===== Symbol ============================================================ */
-
-/**
- * SECTION:symbol
- * @short_description: A symbol.
- * @see_also: #LogdiagDocument, #LogdiagCanvas
- *
- * #LogdiagSymbol represents a symbol in the #LogdiagDocument that is in turn
- * drawn onto the #LogdiagCanvas.
- */
-
-/*
- * LogdiagSymbolPrivate:
- * @library: The parent LogdiagSymbolLibrary.
- * The library contains the real function for rendering.
- */
-struct _LogdiagSymbolPrivate
-{
- LogdiagSymbolLibrary *library;
-};
-
-G_DEFINE_TYPE (LogdiagSymbol, logdiag_symbol, G_TYPE_OBJECT);
-
-static void
-logdiag_symbol_finalize (GObject *gobject);
-
-
-static void
-logdiag_symbol_class_init (LogdiagSymbolClass *klass)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = logdiag_symbol_finalize;
-
- g_type_class_add_private (klass, sizeof (LogdiagSymbolPrivate));
-}
-
-static void
-logdiag_symbol_init (LogdiagSymbol *self)
-{
- self->priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolPrivate);
-}
-
-static void
-logdiag_symbol_finalize (GObject *gobject)
-{
- LogdiagSymbol *self;
-
- self = LOGDIAG_SYMBOL (gobject);
- g_object_unref (self->priv->library);
-
- /* Chain up to the parent class. */
- G_OBJECT_CLASS (logdiag_symbol_parent_class)->finalize (gobject);
-}
-
-/**
- * logdiag_symbol_new:
- * @library: A library object.
- * @filename: The file from which the symbol will be loaded.
- *
- * Load a symbol from a file into the library.
- */
-LogdiagSymbol *logdiag_symbol_new (LogdiagSymbolLibrary *library,
- const gchar *filename)
-{
- LogdiagSymbol *symbol;
-
- symbol = g_object_new (LOGDIAG_TYPE_SYMBOL, NULL);
- /* TODO: Use the filename, Luke. */
-
- symbol->priv->library = library;
- g_object_ref (library);
-}
-
-/**
- * logdiag_symbol_build_identifier:
- * @self: A symbol object.
- *
- * Build an identifier for the symbol.
- * The identifier is in the format "Category/Category/Symbol".
- */
-char *
-logdiag_symbol_build_identifier (LogdiagSymbol *self)
-{
- return NULL;
-}
-
-/**
- * logdiag_symbol_draw:
- * @self: A symbol object.
- * @surface: A cairo surface to be drawn on.
- * @param: Parameters for the symbol in a table.
- * @x: The X coordinate on the surface.
- * @y: The Y coordinate on the surface.
- * @zoom: Zoom ratio.
- *
- * Draw the symbol onto a Cairo surface.
- */
-void
-logdiag_symbol_draw (LogdiagSymbol *self, cairo_t *surface,
- GHashTable *param, gint x, gint y, gdouble zoom)
-{
- return;
-}
diff --git a/src/symbol-library.h b/src/symbol-library.h
deleted file mode 100644
index 5091453..0000000
--- a/src/symbol-library.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * symbol-library.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __SYMBOL_LIBRARY_H__
-#define __SYMBOL_LIBRARY_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_SYMBOL_LIBRARY (logdiag_symbol_library_get_type ())
-#define LOGDIAG_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibrary))
-#define LOGDIAG_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_SYMBOL_LIBRARY, LogdiagSymbolLibraryClass))
-#define LOGDIAG_IS_SYMBOL_LIBRARY(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_SYMBOL_LIBRARY))
-#define LOGDIAG_IS_SYMBOL_LIBRARY_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_SYMBOL_LIBRARY))
-#define LOGDIAG_SYMBOL_LIBRARY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_SYMBOL_LIBRARY, LogdiagSymbolLibraryClass))
-
-typedef struct _LogdiagSymbolLibrary LogdiagSymbolLibrary;
-typedef struct _LogdiagSymbolLibraryPrivate LogdiagSymbolLibraryPrivate;
-typedef struct _LogdiagSymbolLibraryClass LogdiagSymbolLibraryClass;
-
-
-/**
- * LogdiagSymbolLibrary:
- * @categories: Lists all the categories (#LogdiagSymbolCategory).
- *
- * Object structure.
- */
-struct _LogdiagSymbolLibrary
-{
-/*< private >*/
- GObject parent_instance;
- LogdiagSymbolLibraryPrivate *priv;
-
-/*< public >*/
- GHashTable *categories;
-};
-
-struct _LogdiagSymbolLibraryClass
-{
-/*< private >*/
- GObjectClass parent_class;
- guint changed_signal;
-};
-
-
-GType logdiag_symbol_library_get_type (void) G_GNUC_CONST;
-
-LogdiagSymbolLibrary *logdiag_symbol_library_new (void);
-gboolean logdiag_symbol_library_load (LogdiagSymbolLibrary *self,
- const char *directory);
-void logdiag_symbol_library_clear (LogdiagSymbolLibrary *self);
-
-
-G_END_DECLS
-
-#endif /* ! __SYMBOL_LIBRARY_H__ */
-
diff --git a/src/symbol.h b/src/symbol.h
deleted file mode 100644
index 046786a..0000000
--- a/src/symbol.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * symbol.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __SYMBOL_H__
-#define __SYMBOL_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_SYMBOL (logdiag_symbol_get_type ())
-#define LOGDIAG_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_SYMBOL, LogdiagSymbol))
-#define LOGDIAG_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_SYMBOL, LogdiagSymbolClass))
-#define LOGDIAG_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_SYMBOL))
-#define LOGDIAG_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_SYMBOL))
-#define LOGDIAG_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_SYMBOL, LogdiagSymbolClass))
-
-typedef struct _LogdiagSymbol LogdiagSymbol;
-typedef struct _LogdiagSymbolPrivate LogdiagSymbolPrivate;
-typedef struct _LogdiagSymbolClass LogdiagSymbolClass;
-
-
-/**
- * LogdiagSymbol:
- * @name: The name of this symbol.
- */
-struct _LogdiagSymbol
-{
-/*< private >*/
- GObject parent_instance;
- LogdiagSymbolPrivate *priv;
-
-/*< public >*/
- gchar *name;
-};
-
-struct _LogdiagSymbolClass
-{
- GObjectClass parent_class;
-};
-
-
-GType logdiag_symbol_get_type (void) G_GNUC_CONST;
-
-LogdiagSymbol *logdiag_symbol_new (LogdiagSymbolLibrary *library,
- const gchar *filename);
-char *logdiag_symbol_build_identifier (LogdiagSymbol *self);
-void logdiag_symbol_draw (LogdiagSymbol *self, cairo_t *surface,
- GHashTable *param, gint x, gint y, gdouble zoom);
-
-/* TODO: Funkce pro získání terminálů. */
-
-
-
-G_END_DECLS
-
-#endif /* ! __SYMBOL_H__ */
-
diff --git a/src/window-main.c b/src/window-main.c
deleted file mode 100644
index 89714a5..0000000
--- a/src/window-main.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * window-main.c
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#include
-
-#include "config.h"
-
-#include "window-main.h"
-#include "canvas.h"
-#include "document.h"
-#include "symbol-library.h"
-#include "symbol-category.h"
-#include "symbol.h"
-
-
-/**
- * SECTION:window-main
- * @short_description: The main application window.
- *
- * #LogdiagWindowMain is the main window of the application.
- */
-/* NOTE: The main window should not maybe be included in either
- * the documentation or the static library.
- */
-
-
-/* Private members of the window. */
-struct _LogdiagWindowMainPrivate
-{
- GtkWidget *vbox;
- GtkWidget *hbox;
- GtkWidget *menu;
- GtkWidget *toolbar;
-
- LogdiagSymbolLibrary *library;
- LogdiagCanvas *canvas;
-
- GtkWidget *statusbar;
- guint statusbar_menu_context_id;
-};
-
-struct DocumentData
-{
- LogdiagDocument *document;
- const gchar *file_name;
- /* Canvas viewport settings (for multitabbed) */
-};
-
-/* Define the type. */
-G_DEFINE_TYPE (LogdiagWindowMain, logdiag_window_main, GTK_TYPE_WINDOW);
-
-
-/* ===== Local functions =================================================== */
-
-/*
- * cb_load_category:
- *
- * A hashtable foreach callback for adding categories into the toolbar.
- */
-static void
-cb_load_category (gpointer key, gpointer value, gpointer user_data);
-
-/*
- * load_toolbar:
- *
- * Load symbols from the library into the toolbar.
- */
-static void
-load_toolbar (LogdiagWindowMain *self);
-
-/*
- * cb_ui_proxy_connected:
- *
- * An item was connected to the manager.
- */
-static void
-cb_ui_proxy_connected (GtkUIManager *ui, GtkAction *action,
- GtkWidget *proxy, LogdiagWindowMain *window);
-
-/*
- * cb_ui_proxy_disconnected:
- *
- * An item was disconnected from the manager.
- */
-static void
-cb_ui_proxy_disconnected (GtkUIManager *ui, GtkAction *action,
- GtkWidget *proxy, LogdiagWindowMain *window);
-
-/* A menu item was selected. */
-static void
-cb_menu_item_selected (GtkWidget *item, LogdiagWindowMain *window);
-
-/* A menu item was deselected. */
-static void
-cb_menu_item_deselected (GtkItem *item, LogdiagWindowMain *window);
-
-/* Show the about dialog. */
-static void
-cb_show_about_dialog (GtkAction *action, LogdiagWindowMain *window);
-
-
-/* ===== Local variables =================================================== */
-
-/* Actions for menus, toolbars, accelerators. */
-static GtkActionEntry mw_actionEntries[] =
-{
- {"FileMenu", NULL, Q_("_File")},
- {"New", GTK_STOCK_NEW, NULL, NULL,
- Q_("Create a new document"), NULL},
- {"Open", GTK_STOCK_OPEN, NULL, NULL,
- Q_("Open a document"), NULL},
- {"Save", GTK_STOCK_SAVE, NULL, NULL,
- Q_("Save the current document"), NULL},
- {"SaveAs", GTK_STOCK_SAVE_AS, NULL, NULL,
- Q_("Save the current document with another name"), NULL},
- {"Export", NULL, Q_("_Export"), NULL,
- Q_("Export the document"), NULL},
- {"Quit", GTK_STOCK_QUIT, NULL, NULL,
- Q_("Quit the program"), NULL},
-
- {"EditMenu", NULL, Q_("_Edit")},
- {"Cut", GTK_STOCK_CUT, NULL, NULL, NULL, NULL},
- {"Copy", GTK_STOCK_COPY, NULL, NULL, NULL, NULL},
- {"Paste", GTK_STOCK_PASTE, NULL, NULL, NULL, NULL},
- {"Delete", GTK_STOCK_DELETE, NULL, NULL, NULL, NULL},
- {"SelectAll", GTK_STOCK_SELECT_ALL, NULL, NULL, NULL, NULL},
-
- {"HelpMenu", NULL, Q_("_Help")},
- {"About", GTK_STOCK_ABOUT, NULL, NULL, NULL,
- G_CALLBACK(cb_show_about_dialog)}
-};
-
-
-
-/**
- * logdiag_window_main_new:
- *
- * Create an instance.
- */
-GtkWidget *
-logdiag_window_main_new (void)
-{
- return g_object_new (LOGDIAG_TYPE_WINDOW_MAIN, NULL);
-}
-
-static void
-logdiag_window_main_class_init (LogdiagWindowMainClass *klass)
-{
- GObjectClass *object_class;
- GtkWidgetClass *widget_class;
-
- object_class = G_OBJECT_CLASS (klass);
- widget_class = GTK_WIDGET_CLASS (klass);
-
- g_type_class_add_private (klass, sizeof (LogdiagWindowMainPrivate));
-}
-
-static void
-logdiag_window_main_init (LogdiagWindowMain *self)
-{
- LogdiagWindowMainPrivate *priv;
- GtkActionGroup *action_group;
- GtkUIManager *ui_manager;
- GError *error;
-
- self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE
- (self, LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMainPrivate);
-
- priv->vbox = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (self), priv->vbox);
-
-
- ui_manager = gtk_ui_manager_new ();
-
- /* TODO: Show tooltips in the statusbar:
- * http://git.gnome.org/browse/glade3/tree/src/glade-window.c : 2165
- */
- g_signal_connect (ui_manager, "connect-proxy",
- G_CALLBACK (cb_ui_proxy_connected), self);
- g_signal_connect (ui_manager, "disconnect-proxy",
- G_CALLBACK (cb_ui_proxy_disconnected), self);
-
- /* Prepare our actions. */
- action_group = gtk_action_group_new ("MainActions");
- gtk_action_group_add_actions (action_group,
- mw_actionEntries, G_N_ELEMENTS (mw_actionEntries), self);
- gtk_ui_manager_insert_action_group (ui_manager, action_group, 0);
-
- error = NULL;
- gtk_ui_manager_add_ui_from_file
- (ui_manager, PROJECT_SHARE_DIR "gui/window-main.ui", &error);
- if (error)
- {
- g_message (_("Building UI failed: %s"), error->message);
- g_error_free (error);
- }
-
- /* Load keyboard accelerators into the window. */
- gtk_window_add_accel_group
- (GTK_WINDOW (self), gtk_ui_manager_get_accel_group (ui_manager));
-
- priv->menu = gtk_ui_manager_get_widget (ui_manager, "/MenuBar");
- gtk_box_pack_start (GTK_BOX (priv->vbox), priv->menu, FALSE, FALSE, 0);
-
- priv->hbox = gtk_hbox_new(FALSE, 0);
- gtk_box_pack_start (GTK_BOX (priv->vbox), priv->hbox, TRUE, TRUE, 0);
-
- /* Add the symbol toolbar. */
- priv->toolbar = gtk_toolbar_new ();
- /* NOTE: For GTK 2.16+, s/toolbar/orientable/ */
- gtk_toolbar_set_orientation
- (GTK_TOOLBAR (priv->toolbar), GTK_ORIENTATION_VERTICAL);
- gtk_toolbar_set_icon_size
- (GTK_TOOLBAR (priv->toolbar), GTK_ICON_SIZE_LARGE_TOOLBAR);
- gtk_toolbar_set_style
- (GTK_TOOLBAR (priv->toolbar), GTK_TOOLBAR_ICONS);
-
- gtk_box_pack_start (GTK_BOX (priv->hbox), priv->toolbar, FALSE, FALSE, 0);
-
- /* Symbol library. */
- priv->library = logdiag_symbol_library_new ();
- logdiag_symbol_library_load (priv->library, PROJECT_SHARE_DIR "library");
-
- load_toolbar (self);
-
- /* Canvas. */
- priv->canvas = logdiag_canvas_new ();
- gtk_box_pack_start (GTK_BOX (priv->hbox), GTK_WIDGET (priv->canvas),
- FALSE, FALSE, 0);
-
- /* TODO: GtkHPaned */
-
- priv->statusbar = gtk_statusbar_new ();
- priv->statusbar_menu_context_id = gtk_statusbar_get_context_id
- (GTK_STATUSBAR (priv->statusbar), "menu");
- gtk_box_pack_end (GTK_BOX (priv->vbox), priv->statusbar, FALSE, FALSE, 0);
-
-
- /* TODO: Do this on disposal. */
- /* g_object_unref(ui_manager); */
-
- /* Proceed to showing the window. */
- g_signal_connect (self, "destroy", G_CALLBACK (gtk_main_quit), NULL);
- gtk_window_set_default_size (GTK_WINDOW (self), 500, 400);
- gtk_widget_show_all (GTK_WIDGET (self));
-}
-
-static void
-cb_load_category (gpointer key, gpointer value, gpointer user_data)
-{
- const gchar *name;
- LogdiagSymbolCategory *cat;
- LogdiagWindowMain *self;
- GdkPixbuf *pbuf;
- GtkWidget *img;
- GtkToolItem *item;
-
- name = key;
- cat = value;
- self = user_data;
-
- g_return_if_fail (key != NULL);
- g_return_if_fail (LOGDIAG_IS_SYMBOL_CATEGORY (cat));
-
- /* XXX: Hardcoded icon width, unref? */
- pbuf = gdk_pixbuf_new_from_file_at_size (cat->image_path, 32, -1, NULL);
- if (!pbuf)
- return;
- img = gtk_image_new_from_pixbuf (pbuf);
- g_object_unref (pbuf);
-
- item = gtk_tool_button_new (img, name);
- gtk_tool_item_set_tooltip_text (item, name);
- gtk_toolbar_insert (GTK_TOOLBAR (self->priv->toolbar), item, 0);
-}
-
-static void
-load_toolbar (LogdiagWindowMain *self)
-{
- /* TODO: Clear the toolbar first, if there was already something in it. */
-
- g_hash_table_foreach (self->priv->library->categories,
- cb_load_category, self);
-}
-
-static void
-cb_ui_proxy_connected (GtkUIManager *ui, GtkAction *action,
- GtkWidget *proxy, LogdiagWindowMain *window)
-{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_connect (proxy, "select",
- G_CALLBACK (cb_menu_item_selected), window);
- g_signal_connect (proxy, "deselect",
- G_CALLBACK (cb_menu_item_deselected), window);
- }
-}
-
-static void
-cb_ui_proxy_disconnected (GtkUIManager *ui, GtkAction *action,
- GtkWidget *proxy, LogdiagWindowMain *window)
-{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (cb_menu_item_selected), window);
- g_signal_handlers_disconnect_by_func
- (proxy, G_CALLBACK (cb_menu_item_deselected), window);
- }
-}
-
-static void
-cb_menu_item_selected (GtkWidget *item, LogdiagWindowMain *window)
-{
- GtkAction *action;
- gchar *tooltip;
-
- action = gtk_activatable_get_related_action (GTK_ACTIVATABLE (item));
- g_object_get (G_OBJECT (action), "tooltip", &tooltip, NULL);
-
- if (tooltip != NULL)
- gtk_statusbar_push (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->statusbar_menu_context_id, tooltip);
-
- g_free (tooltip);
-}
-
-static void
-cb_menu_item_deselected (GtkItem *item, LogdiagWindowMain *window)
-{
- gtk_statusbar_pop (GTK_STATUSBAR (window->priv->statusbar),
- window->priv->statusbar_menu_context_id);
-}
-
-static void
-cb_show_about_dialog (GtkAction *action, LogdiagWindowMain *window)
-{
- gtk_show_about_dialog (GTK_WINDOW (window),
- "program-name", PROJECT_NAME,
- "version", PROJECT_VERSION,
- "copyright", "Copyright Přemysl Janouch 2010",
- NULL);
-}
-
diff --git a/src/window-main.h b/src/window-main.h
deleted file mode 100644
index 28b3024..0000000
--- a/src/window-main.h
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * window-main.h
- *
- * This file is a part of logdiag.
- * Copyright Přemysl Janouch 2010. All rights reserved.
- *
- * See the file LICENSE for licensing information.
- *
- */
-
-#ifndef __WINDOW_MAIN_H__
-#define __WINDOW_MAIN_H__
-
-G_BEGIN_DECLS
-
-
-#define LOGDIAG_TYPE_WINDOW_MAIN (logdiag_window_main_get_type ())
-#define LOGDIAG_WINDOW_MAIN(obj) (G_TYPE_CHECK_INSTANCE_CAST \
- ((obj), LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMain))
-#define LOGDIAG_WINDOW_MAIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST \
- ((klass), LOGDIAG_TYPE_WINDOW_MAIN, LogdiagWindowMainClass))
-#define LOGDIAG_IS_WINDOW_MAIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((obj), LOGDIAG_TYPE_WINDOW_MAIN))
-#define LOGDIAG_IS_WINDOW_MAIN_CLASS(klass) (G_TYPE_CHECK_INSTANCE_TYPE \
- ((klass), LOGDIAG_TYPE_WINDOW_MAIN))
-#define LOGDIAG_WINDOW_MAIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS \
- ((obj), LOGDIAG_WINDOW_MAIN, LogdiagWindowMainClass))
-
-typedef struct _LogdiagWindowMain LogdiagWindowMain;
-typedef struct _LogdiagWindowMainPrivate LogdiagWindowMainPrivate;
-typedef struct _LogdiagWindowMainClass LogdiagWindowMainClass;
-
-
-/**
- * LogdiagWindowMain:
- *
- * Object structure.
- */
-struct _LogdiagWindowMain
-{
-/*< private >*/
- GtkWindow parent_instance;
- LogdiagWindowMainPrivate *priv;
-};
-
-struct _LogdiagWindowMainClass
-{
- GtkWindowClass parent_class;
-};
-
-
-GType logdiag_window_main_get_type (void) G_GNUC_CONST;
-
-GtkWidget *logdiag_window_main_new (void);
-
-
-G_END_DECLS
-
-#endif /* ! __WINDOW_MAIN_H__ */
-
--
cgit v1.2.3-70-g09d2