aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2012-10-08 04:40:41 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2012-10-08 07:29:58 +0200
commit492daa3ce371f150ab927ceb22d95bf09f372812 (patch)
tree92ec1b1378a1114bdf2c5bebd0d1d7a83f1f85c7
parent24b4e9956b381fe0f9447a6c35ae72ca3e0caabc (diff)
downloadlogdiag-492daa3ce371f150ab927ceb22d95bf09f372812.tar.gz
logdiag-492daa3ce371f150ab927ceb22d95bf09f372812.tar.xz
logdiag-492daa3ce371f150ab927ceb22d95bf09f372812.zip
Show symbol names in the statusbar again..
Not very clean but serves its purpose.
-rw-r--r--liblogdiag/ld-category-symbol-view.c45
-rw-r--r--liblogdiag/ld-category-symbol-view.h3
-rw-r--r--liblogdiag/ld-category-view.c58
-rw-r--r--liblogdiag/ld-category-view.h3
-rw-r--r--src/ld-window-main.c29
5 files changed, 136 insertions, 2 deletions
diff --git a/liblogdiag/ld-category-symbol-view.c b/liblogdiag/ld-category-symbol-view.c
index 365be62..6116566 100644
--- a/liblogdiag/ld-category-symbol-view.c
+++ b/liblogdiag/ld-category-symbol-view.c
@@ -93,6 +93,36 @@ ld_category_symbol_view_class_init (LdCategorySymbolViewClass *klass)
object_class->finalize = ld_category_symbol_view_finalize;
/**
+ * LdCategorySymbolView::symbol-selected:
+ * @self: an #LdCategorySymbolView object.
+ * @symbol: the selected #LdSymbol object.
+ * @path: location of the symbol within the library.
+ *
+ * A symbol has been selected.
+ */
+ klass->symbol_selected_signal = g_signal_new
+ ("symbol-selected", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ ld_marshal_VOID__OBJECT_STRING,
+ G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+/**
+ * LdCategorySymbolView::symbol-deselected:
+ * @self: an #LdCategorySymbolView object.
+ * @symbol: the deselected #LdSymbol object.
+ * @path: location of the symbol within the library.
+ *
+ * A symbol has been deselected.
+ */
+ klass->symbol_deselected_signal = g_signal_new
+ ("symbol-deselected", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ ld_marshal_VOID__OBJECT_STRING,
+ G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+/**
* LdCategorySymbolView:category:
*
* The underlying #LdCategory object of this view.
@@ -118,10 +148,16 @@ symbol_redraw (LdCategorySymbolView *self, SymbolData *symbol)
static void
symbol_deselect (LdCategorySymbolView *self)
{
- if (!self->priv->preselected)
+ SymbolData *preselected;
+
+ preselected = self->priv->preselected;
+ if (!preselected)
return;
- symbol_redraw (self, self->priv->preselected);
+ g_signal_emit (self, LD_CATEGORY_SYMBOL_VIEW_GET_CLASS (self)->
+ symbol_deselected_signal, 0, preselected->symbol, preselected->path);
+
+ symbol_redraw (self, preselected);
self->priv->preselected = NULL;
gtk_drag_source_unset (GTK_WIDGET (self));
}
@@ -164,6 +200,9 @@ on_motion_notify (GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
gtk_drag_source_set (widget,
GDK_BUTTON1_MASK, &target, 1, GDK_ACTION_COPY);
+
+ g_signal_emit (self, LD_CATEGORY_SYMBOL_VIEW_GET_CLASS (self)->
+ symbol_selected_signal, 0, data->symbol, data->path);
}
return FALSE;
}
@@ -253,6 +292,8 @@ symbol_data_free (SymbolData *self)
static void
layout_destroy (LdCategorySymbolView *self)
{
+ symbol_deselect (self);
+
g_slist_foreach (self->priv->layout, (GFunc) symbol_data_free, NULL);
g_slist_free (self->priv->layout);
self->priv->layout = NULL;
diff --git a/liblogdiag/ld-category-symbol-view.h b/liblogdiag/ld-category-symbol-view.h
index 80e6aaa..bc41657 100644
--- a/liblogdiag/ld-category-symbol-view.h
+++ b/liblogdiag/ld-category-symbol-view.h
@@ -45,6 +45,9 @@ struct _LdCategorySymbolViewClass
{
/*< private >*/
GtkDrawingAreaClass parent_class;
+
+ guint symbol_selected_signal;
+ guint symbol_deselected_signal;
};
diff --git a/liblogdiag/ld-category-view.c b/liblogdiag/ld-category-view.c
index 7abf35c..6314cd5 100644
--- a/liblogdiag/ld-category-view.c
+++ b/liblogdiag/ld-category-view.c
@@ -62,6 +62,36 @@ ld_category_view_class_init (LdCategoryViewClass *klass)
object_class->dispose = ld_category_view_dispose;
/**
+ * LdCategoryView::symbol-selected:
+ * @self: an #LdCategoryView object.
+ * @symbol: the selected #LdSymbol object.
+ * @path: location of the symbol within the library.
+ *
+ * A symbol has been selected.
+ */
+ klass->symbol_selected_signal = g_signal_new
+ ("symbol-selected", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ ld_marshal_VOID__OBJECT_STRING,
+ G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+/**
+ * LdCategoryView::symbol-deselected:
+ * @self: an #LdCategoryView object.
+ * @symbol: the deselected #LdSymbol object.
+ * @path: location of the symbol within the library.
+ *
+ * A symbol has been deselected.
+ */
+ klass->symbol_deselected_signal = g_signal_new
+ ("symbol-deselected", G_TYPE_FROM_CLASS (klass),
+ G_SIGNAL_RUN_LAST, 0, NULL, NULL,
+ ld_marshal_VOID__OBJECT_STRING,
+ G_TYPE_NONE, 2, LD_TYPE_SYMBOL,
+ G_TYPE_STRING | G_SIGNAL_TYPE_STATIC_SCOPE);
+
+/**
* LdCategoryView:category:
*
* The #LdCategory this widget retrieves content from.
@@ -258,6 +288,22 @@ reconstruct_prefix (LdCategoryView *self)
}
static void
+on_symbol_selected (GObject *source,
+ LdSymbol *symbol, const gchar *path, LdCategoryView *self)
+{
+ g_signal_emit (self, LD_CATEGORY_VIEW_GET_CLASS (self)->
+ symbol_selected_signal, 0, symbol, path);
+}
+
+static void
+on_symbol_deselected (GObject *source,
+ LdSymbol *symbol, const gchar *path, LdCategoryView *self)
+{
+ g_signal_emit (self, LD_CATEGORY_VIEW_GET_CLASS (self)->
+ symbol_deselected_signal, 0, symbol, path);
+}
+
+static void
reload_category (LdCategoryView *self)
{
g_return_if_fail (LD_IS_CATEGORY_VIEW (self));
@@ -266,6 +312,8 @@ reload_category (LdCategoryView *self)
gtk_container_foreach (GTK_CONTAINER (self),
(GtkCallback) gtk_widget_destroy, NULL);
+ /* XXX: We might want to disconnect signal handlers. */
+
if (self->priv->category)
{
GSList *symbols, *children;
@@ -279,6 +327,11 @@ reload_category (LdCategoryView *self)
symbol_view = ld_category_symbol_view_new (self->priv->category);
gtk_box_pack_start (GTK_BOX (self), symbol_view, FALSE, FALSE, 0);
+
+ g_signal_connect_after (symbol_view, "symbol-selected",
+ G_CALLBACK (on_symbol_selected), self);
+ g_signal_connect_after (symbol_view, "symbol-deselected",
+ G_CALLBACK (on_symbol_deselected), self);
}
if (children)
@@ -318,5 +371,10 @@ load_category_cb (gpointer data, gpointer user_data)
child = ld_category_view_new (cat);
gtk_container_add (GTK_CONTAINER (expander), child);
gtk_box_pack_start (GTK_BOX (self), expander, FALSE, FALSE, 0);
+
+ g_signal_connect_after (child, "symbol-selected",
+ G_CALLBACK (on_symbol_selected), self);
+ g_signal_connect_after (child, "symbol-deselected",
+ G_CALLBACK (on_symbol_deselected), self);
}
diff --git a/liblogdiag/ld-category-view.h b/liblogdiag/ld-category-view.h
index 5b5c81e..af4904e 100644
--- a/liblogdiag/ld-category-view.h
+++ b/liblogdiag/ld-category-view.h
@@ -45,6 +45,9 @@ struct _LdCategoryViewClass
{
/*< private >*/
GtkVBoxClass parent_class;
+
+ guint symbol_selected_signal;
+ guint symbol_deselected_signal;
};
diff --git a/src/ld-window-main.c b/src/ld-window-main.c
index 0be7700..698ffc5 100644
--- a/src/ld-window-main.c
+++ b/src/ld-window-main.c
@@ -90,6 +90,11 @@ static gboolean may_close_diagram (LdWindowMain *self,
const gchar *dialog_message);
static gboolean may_quit (LdWindowMain *self);
+static void on_symbol_selected (LdCategoryView *view,
+ LdSymbol *symbol, const gchar *path, LdWindowMain *self);
+static void on_symbol_deselected (LdCategoryView *view,
+ LdSymbol *symbol, const gchar *path, LdWindowMain *self);
+
static void on_action_new (GtkAction *action, LdWindowMain *self);
static void on_action_open (GtkAction *action, LdWindowMain *self);
static void on_action_save (GtkAction *action, LdWindowMain *self);
@@ -341,6 +346,11 @@ ld_window_main_init (LdWindowMain *self)
ld_category_view_set_category (LD_CATEGORY_VIEW (priv->library_view),
ld_library_get_root (priv->library));
+ g_signal_connect_after (priv->library_view, "symbol-selected",
+ G_CALLBACK (on_symbol_selected), self);
+ g_signal_connect_after (priv->library_view, "symbol-deselected",
+ G_CALLBACK (on_symbol_deselected), self);
+
diagram_set_filename (self, NULL);
priv->statusbar_hint_drag = gtk_statusbar_push
@@ -842,6 +852,25 @@ may_quit (LdWindowMain *self)
/* ===== User interface actions ============================================ */
static void
+on_symbol_selected (LdCategoryView *view,
+ LdSymbol *symbol, const gchar *path, LdWindowMain *self)
+{
+ const gchar *symbol_name;
+
+ symbol_name = ld_symbol_get_human_name (symbol);
+ gtk_statusbar_push (GTK_STATUSBAR (self->priv->statusbar),
+ self->priv->statusbar_menu_context_id, symbol_name);
+}
+
+static void
+on_symbol_deselected (LdCategoryView *view,
+ LdSymbol *symbol, const gchar *path, LdWindowMain *self)
+{
+ gtk_statusbar_pop (GTK_STATUSBAR (self->priv->statusbar),
+ self->priv->statusbar_menu_context_id);
+}
+
+static void
on_view_zoom_changed (LdDiagramView *view, GParamSpec *pspec,
LdWindowMain *self)
{