[glade/glade-3-10] Fixed bug #660874 "glade-previewer fails to open UI files without top windows" Fixed bug 660872 "gla



commit 522cee7046f763033b21d0fd5c0a08a067342bb7
Author: Juan Pablo Ugarte <juanpablougarte gmail com>
Date:   Tue Oct 4 17:43:01 2011 -0300

    Fixed bug #660874 "glade-previewer fails to open UI files without top windows"
    Fixed bug 660872 "glade-previewer crashes on non-existent files"

 ChangeLog                 |    5 +++--
 gladeui/glade-previewer.c |   45 +++++++++++++--------------------------------
 2 files changed, 16 insertions(+), 34 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index a711692..80675f9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,7 +1,8 @@
 2011-10-04  Juan Pablo Ugarte <juanpablougarte gmail com>
 
-        * gladeui/glade-previewer.c: fixed bug #660874 
-          "glade-previewer fails to open UI files without top windows"
+        * gladeui/glade-previewer.c:
+          o Fixed bug #660874 "glade-previewer fails to open UI files without top windows"
+          o Fixed bug 660872 "glade-previewer crashes on non-existent files"
           o Fixed runtime warnings in option parsing.
 
         * gladeui/glade-base-editor.c, gladeui/glade-project.c: fixed spelling errors
diff --git a/gladeui/glade-previewer.c b/gladeui/glade-previewer.c
index dee26f1..84cde24 100644
--- a/gladeui/glade-previewer.c
+++ b/gladeui/glade-previewer.c
@@ -184,20 +184,6 @@ preview_widget (gchar * name, gchar * buffer, gsize length)
   return widget;
 }
 
-static GIOChannel *
-channel_from_stream (gint stream)
-{
-  GIOChannel *channel;
-
-#ifdef WINDOWS
-  channel = g_io_channel_win32_new_fd (stream);
-#else
-  channel = g_io_channel_unix_new (stream);
-#endif
-
-  return channel;
-}
-
 static GtkWidget*
 show_widget (GtkWidget *widget)
 {
@@ -232,29 +218,22 @@ show_widget (GtkWidget *widget)
 static void
 preview_file (gchar * toplevel_name, gchar * file_name)
 {
+  GError *error = NULL;
   gchar *buffer;
   gsize length;
-  GError *error = NULL;
-  GIOChannel *input;
-  gint stream;
-  GtkWidget *widget;
-
-  stream = fileno (fopen (file_name, "r"));
-  input = channel_from_stream (stream);
 
-  if (g_io_channel_read_to_end (input, &buffer, &length, &error) !=
-      G_IO_STATUS_NORMAL)
+  if (g_file_get_contents (file_name, &buffer, &length, &error))
+    {
+      GtkWidget *widget = preview_widget (toplevel_name, buffer, length);
+      gtk_widget_show_all (show_widget (widget));
+      g_free (buffer);
+    }
+  else
     {
       g_printerr (_("Error: %s.\n"), error->message);
       g_error_free (error);
       exit (1);
     }
-
-  widget = preview_widget (toplevel_name, buffer, length);
-  gtk_widget_show_all (show_widget (widget));
-
-  g_free (buffer);
-  g_io_channel_unref (input);
 }
 
 static gchar *
@@ -395,10 +374,12 @@ static void
 start_listener (gchar * toplevel_name)
 {
   GIOChannel *input;
-  gint stream;
 
-  stream = fileno (stdin);
-  input = channel_from_stream (stream);
+#ifdef WINDOWS
+  input = g_io_channel_win32_new_fd (fileno (stdin));
+#else
+  input = g_io_channel_unix_new (fileno (stdin));
+#endif
 
   g_io_add_watch (input, G_IO_IN | G_IO_HUP, on_data_incoming, toplevel_name);
 }



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