[latexila/wip/latexila-next: 2/2] PostProcessor: replace show-details property by function parameter
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila/wip/latexila-next: 2/2] PostProcessor: replace show-details property by function parameter
- Date: Tue, 30 Sep 2014 11:59:18 +0000 (UTC)
commit b6c9bd21874c6cfb44eb61b5e57f6908f5d35d47
Author: Sébastien Wilmet <swilmet gnome org>
Date: Tue Sep 30 13:08:09 2014 +0200
PostProcessor: replace show-details property by function parameter
src/liblatexila/latexila-build-job.c | 48 +++++++++++++++-----
.../latexila-post-processor-all-output.c | 3 +-
src/liblatexila/latexila-post-processor-latex.c | 3 +-
src/liblatexila/latexila-post-processor-latexmk.c | 13 +++++-
src/liblatexila/latexila-post-processor.c | 38 +++++-----------
src/liblatexila/latexila-post-processor.h | 6 ++-
6 files changed, 69 insertions(+), 42 deletions(-)
---
diff --git a/src/liblatexila/latexila-build-job.c b/src/liblatexila/latexila-build-job.c
index 78f3664..cc40629 100644
--- a/src/liblatexila/latexila-build-job.c
+++ b/src/liblatexila/latexila-build-job.c
@@ -116,8 +116,8 @@ latexila_build_job_dispose (GObject *object)
g_clear_object (&build_job->priv->task);
g_clear_object (&build_job->priv->file);
- g_clear_object (&build_job->priv->build_view);
- g_clear_object (&build_job->priv->post_processor);
+
+ latexila_build_job_clear (build_job);
G_OBJECT_CLASS (latexila_build_job_parent_class)->dispose (object);
}
@@ -387,23 +387,45 @@ display_command_line (LatexilaBuildJob *build_job)
}
static void
-post_processor_cb (LatexilaPostProcessor *pp,
- GAsyncResult *result,
- LatexilaBuildJob *build_job)
+show_details_notify_cb (LatexilaBuildView *build_view,
+ GParamSpec *pspec,
+ LatexilaBuildJob *build_job)
{
const GQueue *messages;
+ gboolean show_details;
- latexila_post_processor_process_finish (pp, result);
+ latexila_build_view_remove_children (build_view,
+ &build_job->priv->job_title);
+
+ g_object_get (build_view, "show-details", &show_details, NULL);
- messages = latexila_post_processor_get_messages (pp);
+ messages = latexila_post_processor_get_messages (build_job->priv->post_processor,
+ show_details);
- latexila_build_view_append_messages (build_job->priv->build_view,
+ latexila_build_view_append_messages (build_view,
&build_job->priv->job_title,
messages,
TRUE);
}
static void
+post_processor_cb (LatexilaPostProcessor *pp,
+ GAsyncResult *result,
+ LatexilaBuildJob *build_job)
+{
+ latexila_post_processor_process_finish (pp, result);
+
+ g_signal_connect (build_job->priv->build_view,
+ "notify::show-details",
+ G_CALLBACK (show_details_notify_cb),
+ build_job);
+
+ show_details_notify_cb (build_job->priv->build_view,
+ NULL,
+ build_job);
+}
+
+static void
subprocess_wait_cb (GSubprocess *subprocess,
GAsyncResult *result,
LatexilaBuildJob *build_job)
@@ -547,10 +569,9 @@ latexila_build_job_run_async (LatexilaBuildJob *build_job,
g_clear_object (&build_job->priv->file);
build_job->priv->file = g_object_ref (file);
- g_clear_object (&build_job->priv->build_view);
- build_job->priv->build_view = g_object_ref (build_view);
+ latexila_build_job_clear (build_job);
- g_clear_object (&build_job->priv->post_processor);
+ build_job->priv->build_view = g_object_ref (build_view);
if (!display_command_line (build_job))
{
@@ -610,6 +631,11 @@ latexila_build_job_run_finish (LatexilaBuildJob *build_job,
void
latexila_build_job_clear (LatexilaBuildJob *build_job)
{
+ if (build_job->priv->build_view != NULL)
+ g_signal_handlers_disconnect_by_func (build_job->priv->build_view,
+ show_details_notify_cb,
+ build_job);
+
g_clear_object (&build_job->priv->build_view);
g_clear_object (&build_job->priv->post_processor);
}
diff --git a/src/liblatexila/latexila-post-processor-all-output.c
b/src/liblatexila/latexila-post-processor-all-output.c
index 942bcbb..b2107ac 100644
--- a/src/liblatexila/latexila-post-processor-all-output.c
+++ b/src/liblatexila/latexila-post-processor-all-output.c
@@ -56,7 +56,8 @@ latexila_post_processor_all_output_process_line (LatexilaPostProcessor *post_pro
}
static const GQueue *
-latexila_post_processor_all_output_get_messages (LatexilaPostProcessor *post_processor)
+latexila_post_processor_all_output_get_messages (LatexilaPostProcessor *post_processor,
+ gboolean show_details)
{
LatexilaPostProcessorAllOutput *pp = LATEXILA_POST_PROCESSOR_ALL_OUTPUT (post_processor);
diff --git a/src/liblatexila/latexila-post-processor-latex.c b/src/liblatexila/latexila-post-processor-latex.c
index f795a23..3c4eb25 100644
--- a/src/liblatexila/latexila-post-processor-latex.c
+++ b/src/liblatexila/latexila-post-processor-latex.c
@@ -1363,7 +1363,8 @@ latexila_post_processor_latex_process_line (LatexilaPostProcessor *post_processo
}
static const GQueue *
-latexila_post_processor_latex_get_messages (LatexilaPostProcessor *post_processor)
+latexila_post_processor_latex_get_messages (LatexilaPostProcessor *post_processor,
+ gboolean show_details)
{
LatexilaPostProcessorLatex *pp = LATEXILA_POST_PROCESSOR_LATEX (post_processor);
diff --git a/src/liblatexila/latexila-post-processor-latexmk.c
b/src/liblatexila/latexila-post-processor-latexmk.c
index 806117d..56181eb 100644
--- a/src/liblatexila/latexila-post-processor-latexmk.c
+++ b/src/liblatexila/latexila-post-processor-latexmk.c
@@ -590,9 +590,20 @@ latexila_post_processor_latexmk_end (LatexilaPostProcessor *post_processor)
}
static const GQueue *
-latexila_post_processor_latexmk_get_messages (LatexilaPostProcessor *post_processor)
+latexila_post_processor_latexmk_get_messages (LatexilaPostProcessor *post_processor,
+ gboolean show_details)
{
LatexilaPostProcessorLatexmk *pp = LATEXILA_POST_PROCESSOR_LATEXMK (post_processor);
+ gboolean has_details;
+
+ g_object_get (pp, "has-details", &has_details, NULL);
+
+ if (has_details && !show_details)
+ {
+ /* TODO don't display the command line */
+ g_assert (pp->priv->last_latex_sub_command != NULL);
+ return pp->priv->last_latex_sub_command->children;
+ }
return pp->priv->messages;
}
diff --git a/src/liblatexila/latexila-post-processor.c b/src/liblatexila/latexila-post-processor.c
index 4ac8516..5f4daf5 100644
--- a/src/liblatexila/latexila-post-processor.c
+++ b/src/liblatexila/latexila-post-processor.c
@@ -56,14 +56,12 @@ struct _LatexilaPostProcessorPrivate
GString *line_buffer;
guint has_details : 1;
- guint show_details : 1;
};
enum
{
PROP_0,
- PROP_HAS_DETAILS,
- PROP_SHOW_DETAILS
+ PROP_HAS_DETAILS
};
G_DEFINE_TYPE_WITH_PRIVATE (LatexilaPostProcessor, latexila_post_processor, G_TYPE_OBJECT)
@@ -153,10 +151,6 @@ latexila_post_processor_get_property (GObject *object,
g_value_set_boolean (value, pp->priv->has_details);
break;
- case PROP_SHOW_DETAILS:
- g_value_set_boolean (value, pp->priv->show_details);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -177,10 +171,6 @@ latexila_post_processor_set_property (GObject *object,
pp->priv->has_details = g_value_get_boolean (value);
break;
- case PROP_SHOW_DETAILS:
- pp->priv->show_details = g_value_get_boolean (value);
- break;
-
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -233,7 +223,8 @@ latexila_post_processor_end_default (LatexilaPostProcessor *pp)
}
static const GQueue *
-latexila_post_processor_get_messages_default (LatexilaPostProcessor *pp)
+latexila_post_processor_get_messages_default (LatexilaPostProcessor *pp,
+ gboolean show_details)
{
return NULL;
}
@@ -269,16 +260,6 @@ latexila_post_processor_class_init (LatexilaPostProcessorClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT |
G_PARAM_STATIC_STRINGS));
-
- g_object_class_install_property (object_class,
- PROP_SHOW_DETAILS,
- g_param_spec_boolean ("show-details",
- "Show details",
- "",
- FALSE,
- G_PARAM_READWRITE |
- G_PARAM_CONSTRUCT |
- G_PARAM_STATIC_STRINGS));
}
static void
@@ -536,6 +517,8 @@ latexila_post_processor_end (LatexilaPostProcessor *pp)
/**
* latexila_post_processor_get_messages:
* @pp: a post-processor.
+ * @show_details: whether to show the details. Has no effect if
+ * #LatexilaPostProcessor:has-details is %FALSE.
*
* Gets the filtered messages. Call this function only after calling
* latexila_post_processor_process_finish() or latexila_post_processor_end().
@@ -563,19 +546,22 @@ latexila_post_processor_end (LatexilaPostProcessor *pp)
* Element types: #LatexilaBuildMsg.
*/
const GQueue *
-latexila_post_processor_get_messages (LatexilaPostProcessor *pp)
+latexila_post_processor_get_messages (LatexilaPostProcessor *pp,
+ gboolean show_details)
{
g_return_val_if_fail (LATEXILA_IS_POST_PROCESSOR (pp), NULL);
- return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->get_messages (pp);
+ show_details = show_details != FALSE;
+
+ return LATEXILA_POST_PROCESSOR_GET_CLASS (pp)->get_messages (pp, show_details);
}
/**
* latexila_post_processor_take_messages: (skip)
* @pp: a #LatexilaPostProcessor.
*
- * Takes ownership of the messages. Since #GQueue is not reference counted, @pp
- * is emptied and is thus useless after calling this function.
+ * Takes ownership of all the messages. Since #GQueue is not reference counted,
+ * @pp is emptied and is thus useless after calling this function.
*
* Returns: (transfer full) (nullable): the tree of filtered messages, or %NULL.
* Element types: #LatexilaBuildMsg.
diff --git a/src/liblatexila/latexila-post-processor.h b/src/liblatexila/latexila-post-processor.h
index 269bddc..8d98bd3 100644
--- a/src/liblatexila/latexila-post-processor.h
+++ b/src/liblatexila/latexila-post-processor.h
@@ -73,7 +73,8 @@ struct _LatexilaPostProcessorClass
void (* end) (LatexilaPostProcessor *pp);
- const GQueue * (* get_messages) (LatexilaPostProcessor *pp);
+ const GQueue * (* get_messages) (LatexilaPostProcessor *pp,
+ gboolean show_details);
GQueue * (* take_messages) (LatexilaPostProcessor *pp);
};
@@ -103,7 +104,8 @@ void latexila_post_processor_process_line (LatexilaP
void latexila_post_processor_end (LatexilaPostProcessor *pp);
-const GQueue * latexila_post_processor_get_messages (LatexilaPostProcessor *pp);
+const GQueue * latexila_post_processor_get_messages (LatexilaPostProcessor *pp,
+ gboolean show_details);
GQueue * latexila_post_processor_take_messages (LatexilaPostProcessor *pp);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]