[gitg] Added missing set_auto_utf8



commit 97c92cbbf68291cfc2660164b029451098de7e12
Author: Jesse van den Kieboom <jesse vandenkieboom epfl ch>
Date:   Sun Mar 27 11:19:09 2011 +0200

    Added missing set_auto_utf8

 libgitg/gitg-io.c     |   42 +++++++++++++++++++++++++++++++++++++++++-
 libgitg/gitg-io.h     |    3 +++
 libgitg/gitg-runner.c |   17 ++++++++++++-----
 3 files changed, 56 insertions(+), 6 deletions(-)
---
diff --git a/libgitg/gitg-io.c b/libgitg/gitg-io.c
index d0d1972..c6fbcb7 100644
--- a/libgitg/gitg-io.c
+++ b/libgitg/gitg-io.c
@@ -33,6 +33,7 @@ struct _GitgIOPrivate
 
 	guint cancelled : 1;
 	guint running : 1;
+	guint auto_utf8 : 1;
 };
 
 enum
@@ -43,7 +44,8 @@ enum
 	PROP_OUTPUT,
 	PROP_CANCELLED,
 	PROP_EXIT_STATUS,
-	PROP_RUNNING
+	PROP_RUNNING,
+	PROP_AUTO_UTF8
 };
 
 enum
@@ -100,6 +102,9 @@ gitg_io_set_property (GObject      *object,
 		case PROP_RUNNING:
 			gitg_io_set_running (self, g_value_get_boolean (value));
 			break;
+		case PROP_AUTO_UTF8:
+			gitg_io_set_auto_utf8 (self, g_value_get_boolean (value));
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -131,6 +136,9 @@ gitg_io_get_property (GObject    *object,
 		case PROP_RUNNING:
 			g_value_set_boolean (value, self->priv->running);
 			break;
+		case PROP_AUTO_UTF8:
+			g_value_set_boolean (value, self->priv->auto_utf8);
+			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 		break;
@@ -237,6 +245,14 @@ gitg_io_class_init (GitgIOClass *klass)
 		              G_TYPE_ERROR);
 
 	g_type_class_add_private (object_class, sizeof (GitgIOPrivate));
+
+	g_object_class_install_property (object_class,
+	                                 PROP_AUTO_UTF8,
+	                                 g_param_spec_boolean ("auto-utf8",
+	                                                       "Auto Utf8",
+	                                                       "Auto utf8",
+	                                                       TRUE,
+	                                                       G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
 }
 
 static void
@@ -425,3 +441,27 @@ gitg_io_set_running (GitgIO   *io,
 		g_object_notify (G_OBJECT (io), "running");
 	}
 }
+
+void
+gitg_io_set_auto_utf8 (GitgIO   *io,
+                       gboolean  auto_utf8)
+{
+	g_return_if_fail (GITG_IS_IO (io));
+
+	if (io->priv->auto_utf8 == auto_utf8)
+	{
+		return;
+	}
+
+	io->priv->auto_utf8 = auto_utf8;
+
+	g_object_notify (G_OBJECT (io), "auto-utf8");
+}
+
+gboolean
+gitg_io_get_auto_utf8 (GitgIO *io)
+{
+	g_return_val_if_fail (GITG_IS_IO (io), FALSE);
+
+	return io->priv->auto_utf8;
+}
diff --git a/libgitg/gitg-io.h b/libgitg/gitg-io.h
index 43afead..620b43c 100644
--- a/libgitg/gitg-io.h
+++ b/libgitg/gitg-io.h
@@ -87,6 +87,9 @@ void gitg_io_set_exit_status (GitgIO *io, gint status);
 gboolean gitg_io_get_running (GitgIO *io);
 void gitg_io_set_running (GitgIO *io, gboolean running);
 
+void gitg_io_set_auto_utf8 (GitgIO *io, gboolean auto_utf8);
+gboolean gitg_io_get_auto_utf8 (GitgIO *io);
+
 G_END_DECLS
 
 #endif /* __GITG_IO_H__ */
diff --git a/libgitg/gitg-runner.c b/libgitg/gitg-runner.c
index 6bd2b76..46883a9 100644
--- a/libgitg/gitg-runner.c
+++ b/libgitg/gitg-runner.c
@@ -496,13 +496,20 @@ gitg_runner_run (GitgRunner *runner)
 	output = G_INPUT_STREAM (g_unix_input_stream_new (stdoutf,
 	                                                  TRUE));
 
-	smart = gitg_smart_charset_converter_new (gitg_encoding_get_candidates ());
+	if (gitg_io_get_auto_utf8 (GITG_IO (runner)))
+	{
+		smart = gitg_smart_charset_converter_new (gitg_encoding_get_candidates ());
 
-	runner->priv->stdout = g_converter_input_stream_new (output,
-	                                                     G_CONVERTER (smart));
+		runner->priv->stdout = g_converter_input_stream_new (output,
+		                                                     G_CONVERTER (smart));
 
-	g_object_unref (smart);
-	g_object_unref (output);
+		g_object_unref (smart);
+		g_object_unref (output);
+	}
+	else
+	{
+		runner->priv->stdout = output;
+	}
 
 	end_output = gitg_io_get_output (GITG_IO (runner));
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]