[glade/glade-3-8] * Backed out 'preview' feature from glade-3-8 branch.



commit 6280a622f4e72c5df253a620a2f03d243cbe395f
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date:   Mon Apr 4 16:39:07 2011 +0900

    	* Backed out 'preview' feature from glade-3-8 branch.

 ChangeLog                     |    4 +
 gladeui/Makefile.am           |   35 +----
 gladeui/glade-previewer.c     |  333 -----------------------------------------
 gladeui/glade-previewer.rc.in |   29 ----
 gladeui/glade-project.c       |  239 +-----------------------------
 gladeui/glade-project.h       |    4 -
 plugins/gtk+/glade-gtk.c      |    9 +-
 plugins/gtk+/gtk+.xml.in      |    1 -
 src/glade-window.c            |   79 ----------
 9 files changed, 8 insertions(+), 725 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 403b418..0692c46 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2011-04-04  Tristan Van Berkom <tristanvb openismus com>
+
+	* Backed out 'preview' feature from glade-3-8 branch.
+
 2011-02-05  Tristan Van Berkom <tristanvb openismus com>
 
 	* plugins/gtk+/gtk+.xml.in: Disabling irrelevant properties for GtkScaleButton
diff --git a/gladeui/Makefile.am b/gladeui/Makefile.am
index aea3df9..c2ef6e4 100644
--- a/gladeui/Makefile.am
+++ b/gladeui/Makefile.am
@@ -1,39 +1,6 @@
-## Previewer
 
-bin_PROGRAMS = glade-3-previewer
 lib_LTLIBRARIES = libgladeui-1.la
 
-glade_3_previewer_CPPFLAGS = \
-	-I$(top_srcdir)    \
-	-I$(top_builddir)  \
-	-DGLADE_GNOMEHELPDIR="\"$(HELP_DIR)\"" \
-	$(GTK_CFLAGS)      \
-	$(IGE_MAC_CFLAGS)  \
-	$(WARN_CFLAGS)     \
-	$(AM_CPPFLAGS)
-
-glade_3_previewer_CFLAGS =   \
-	$(AM_CFLAGS)
-
-glade_3_previewer_LDFLAGS = $(AM_LDFLAGS)
-
-glade_3_previewer_LDADD = libgladeui-1.la $(IGE_MAC_LIBS)
-
-glade_3_previewer_SOURCES = \
-	glade-previewer.c
-
-if NATIVE_WIN32
-glade_3_previewer_LDADD += glade-win32-res.o
-if !GLADE_UNSTABLE
-glade_3_previewer_LDFLAGS += -mwindows
-endif
-endif
-
-glade-win32-res.o: glade-previewer.rc
-	$(WINDRES) $< $@
-
-## Rest of the UI ;)
-
 common_defines = \
 	-DG_LOG_DOMAIN=\"GladeUI\"                      \
 	-DGLADE_DATADIR="\"$(pkgdatadir)\""		\
@@ -47,7 +14,7 @@ common_defines = \
 
 BUILT_SOURCES = glade-marshallers.c glade-marshallers.h
 
-EXTRA_DIST = glade-marshallers.list gladeui.rc.in icon-naming-spec.c glade-previewer.rc.in
+EXTRA_DIST = glade-marshallers.list gladeui.rc.in icon-naming-spec.c
 
 # The glade-3 core library
 libgladeui_1_la_SOURCES = \
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index d8744db..a48d9c1 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -76,8 +76,7 @@ enum
 	PROP_HAS_SELECTION,
 	PROP_PATH,
 	PROP_READ_ONLY,
-	PROP_FORMAT,
-	PROP_PREVIEWABLE
+	PROP_FORMAT
 };
 
 struct _GladeProjectPrivate
@@ -96,8 +95,6 @@ struct _GladeProjectPrivate
 			       * requested
 			       */
 
-	gboolean previewable;
-
 	gint   stamp;     /* A a random int per instance of project used to stamp/check the
 			   * GtkTreeIter->stamps */
 	GList *tree;      /* List of toplevel Objects in this projects */
@@ -163,9 +160,6 @@ struct _GladeProjectPrivate
 	gint       progress_step;
 	gint       progress_full;
 	gboolean   load_cancel;
-
-	/* Store preview processes, so we can kill them on close */
-	GHashTable *preview_channels;
 };
 
 typedef struct {
@@ -384,9 +378,6 @@ glade_project_get_property (GObject    *object,
 		case PROP_FORMAT:
 			g_value_set_int (value, project->priv->format);
 			break;
-		case PROP_PREVIEWABLE:
-			g_value_set_boolean (value, project->priv->previewable);
-			break;
 		default:
 			G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
 			break;			
@@ -595,70 +586,6 @@ glade_project_push_undo_impl (GladeProject *project, GladeCommand *cmd)
 }
 
 static void
-glade_project_preview_exits (GPid pid, gint status, gpointer data)
-{
-	GladeProject *project = (GladeProject *)data;
-	ChannelWatchPair *channel_watch;
-	GIOChannel *channel;
-	gchar *pidstr = g_strdup_printf ("%d", pid);
-
-	channel_watch = g_hash_table_lookup (project->priv->preview_channels, pidstr);
-	channel = channel_watch->channel;
-	g_io_channel_unref (channel);
-	g_hash_table_remove (project->priv->preview_channels, pidstr);
-
-	g_free (pidstr);
-	g_free (channel_watch);
-}
-
-static void
-glade_project_kill_previews (gpointer key,
-			     gpointer value,
-			     gpointer user_data)
-{
-	const gchar *quit = "<quit>";
-	GIOChannel *channel;
-	ChannelWatchPair *channel_watch = (ChannelWatchPair *) value;
-	GError *error = NULL;
-	gsize size;
-
-	channel = channel_watch->channel;
-	/* Removing watch, since the child will commit suicide */
-	g_source_remove (channel_watch->watch);
-	g_io_channel_write_chars (channel, quit, strlen (quit), &size, &error);
-
-	if (size != strlen (quit) && error != NULL)
-	{
-		g_printerr ("Error passing quit signal trough pipe: %s", error->message);
-		g_error_free (error);
-	}
-
-	g_io_channel_flush (channel, &error);
-	if (error != NULL)
-	{
-		g_printerr ("Error flushing channel: %s", error->message);
-		g_error_free (error);
-	}
-
-	g_io_channel_shutdown (channel, TRUE, &error);
-	if (error != NULL)
-	{
-		g_printerr ("Error shutting down channel: %s", error->message);
-		g_error_free (error);
-	}
-
-	g_io_channel_unref (channel);
-	g_free (channel_watch);
-}
-
-static void
-glade_project_close_impl (GladeProject *project)
-{
-	g_hash_table_foreach (project->priv->preview_channels, glade_project_kill_previews, project);
-	g_hash_table_unref (project->priv->preview_channels);
-}
-
-static void
 glade_project_changed_impl (GladeProject *project, 
 			    GladeCommand *command,
 			    gboolean      forward)
@@ -700,8 +627,6 @@ glade_project_init (GladeProject *project)
 	priv->first_modification = NULL;
 	priv->first_modification_is_na = FALSE;
 
-	priv->preview_channels = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
-	priv->previewable = FALSE;
 	priv->toplevel_names = glade_name_context_new ();
 	priv->naming_policy = GLADE_POLICY_PROJECT_WIDE;
 
@@ -762,7 +687,7 @@ glade_project_class_init (GladeProjectClass *klass)
 
 	klass->widget_name_changed = NULL;
 	klass->selection_changed   = NULL;
-	klass->close               = glade_project_close_impl;
+	klass->close               = NULL;
 	klass->changed             = glade_project_changed_impl;
 
 	/**
@@ -999,15 +924,6 @@ glade_project_class_init (GladeProjectClass *klass)
 							   GLADE_PROJECT_FORMAT_GTKBUILDER,
 							   G_PARAM_READABLE));
 
-	g_object_class_install_property (object_class,
-					 PROP_PREVIEWABLE,
-					 g_param_spec_boolean ("previewable",
-							      _("Previewable"),
-							      _("Wether the project can be previewed"),
-							      FALSE,
-							      G_PARAM_READABLE));
-
-
 
 	g_type_class_add_private (klass, sizeof (GladeProjectPrivate));
 }
@@ -1973,121 +1889,6 @@ glade_project_save (GladeProject *project, const gchar *path, GError **error)
 	return ret > 0;
 }
 
-static GPid
-glade_project_launch_preview (GladeProject *project, gchar *buffer, GtkWidget *widget)
-{
-	GPid pid;
-	GError *error = NULL;
-	gchar *argv[4];
-	gint child_stdin;
-	GIOChannel *output;
-	guint watch;
-	ChannelWatchPair *channel_watch;
-	GladeWidget *glade_widget;
-	
-
-	#ifdef WINDOWS
-	argv[0] = g_build_filename (glade_app_get_bin_dir(), "glade-3-previewer.exe", NULL);
-	#else
-	argv[0] = g_build_filename (glade_app_get_bin_dir(), "glade-3-previewer", NULL);
-	#endif
-
-
-	argv[1] = "--listen";
-
-	if (widget != NULL)
-	{
-		glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
-		argv[2] = g_strdup_printf ("--toplevel=%s", glade_widget->name);
-		argv[3] = NULL;
-	}
-
-	if (g_spawn_async_with_pipes (NULL,
-				      argv,
-				      NULL, G_SPAWN_DO_NOT_REAP_CHILD, NULL, NULL,
-				      &pid, &child_stdin, NULL, NULL, &error) == FALSE)
-	{
-		g_printerr (_("Error launching previewer: %s\n"), error->message);
-		glade_util_ui_message (glade_app_get_window(),
-				       GLADE_UI_ERROR, NULL,
-				       _("Failed to launch preview: %s.\n"),
-				       error->message);
-		g_error_free (error);
-		pid = 0;
-		goto end;
-	}
-
-	/* Store watch so we can remove it later */
-	watch = g_child_watch_add (pid, glade_project_preview_exits, project);
-
-	#ifdef WINDOWS
-	output = g_io_channel_win32_new_fd (child_stdin);
-	#else
-	output = g_io_channel_unix_new (child_stdin);
-	#endif
-
-	gsize bytes_written;
-	g_io_channel_write_chars (output, buffer, strlen (buffer), &bytes_written, &error);
-
-	if (bytes_written != strlen (buffer) && error != NULL)
-	{
-		g_printerr ("Error passing UI trough pipe: %s", error->message);
-		g_error_free (error);
-	}
-
-	g_io_channel_flush (output, &error);
-	if (error != NULL)
-	{
-		g_printerr ("Error flushing UI trough pipe: %s", error->message);
-		g_error_free (error);
-	}
-
-	if (widget != NULL) g_free (argv[2]);
-
-	/* Adding channel to list of channels */
-	channel_watch = g_new (ChannelWatchPair, 1);
-	channel_watch->channel = output;
-	channel_watch->watch = watch;
-	g_hash_table_insert (project->priv->preview_channels, g_strdup_printf("%d", pid),
-							      channel_watch);
-
-	end:
-	g_free (argv[0]);
-	return pid;
-}
-
-/**
- * glade_project_preview:
- * @project: a #GladeProject
- * @gwidget: a #GladeWidget
- * 
- * Creates and displays a preview window holding a snapshot of @gwidget's
- * toplevel window in @project. Note that the preview window is only a snapshot
- * of the current state of the project, there is no limit on how many preview
- * snapshots can be taken.
- */
-void
-glade_project_preview (GladeProject *project, GladeWidget *gwidget)
-{
-	GladeXmlContext *context;
-	gchar *text;
-	GtkWidget *widget;
-
-	g_return_if_fail (GLADE_IS_PROJECT (project));
-
-	context = glade_project_write (project);
-
-	text = glade_xml_dump_from_context (context);
-
-	gwidget = glade_widget_get_toplevel (gwidget);
-	if (!GTK_IS_WIDGET (gwidget->object)) return;
-	widget = GTK_WIDGET (gwidget->object);
-
-	glade_project_launch_preview (project, text, widget);
-
-	g_free (text);
-}
-
 /*******************************************************************
      Verify code here (versioning, incompatability checks)
  *******************************************************************/
@@ -3010,34 +2811,6 @@ glade_project_set_widget_name (GladeProject *project,
 	gtk_tree_path_free (path);
 }
 
-static gboolean
-glade_project_has_widget (GladeProject *project)
-{
-	GtkWidget *widget = NULL;
-	const GList *objects;
-
-	objects = glade_project_get_objects (project);
-
-	while (objects != NULL)
-	{
-		if (GTK_IS_WIDGET (objects->data))
-		{
-			widget = GTK_WIDGET(objects->data);
-			break;
-		}
-		objects = objects->next;
-	}
-
-	return widget != NULL;
-}
-
-static void
-glade_project_update_previewable (GladeProject *project)
-{
-	project->priv->previewable = glade_project_has_widget (project);
-	g_object_notify (G_OBJECT (project), "previewable");
-}
-
 static void 
 glade_project_notify_row_inserted (GladeProject *project,
 				   GladeWidget  *gwidget)
@@ -3168,7 +2941,6 @@ glade_project_add_object (GladeProject *project,
 
 	/* Update user visible compatibility info */
 	glade_project_verify_properties (gwidget);
-	glade_project_update_previewable (project);
 	
 	g_signal_emit (G_OBJECT (project),
 		       glade_project_signals [ADD_WIDGET],
@@ -3256,7 +3028,6 @@ glade_project_remove_object (GladeProject *project, GObject *object)
 	gwidget->in_project = FALSE;
 	g_object_unref (gwidget);
 
-	glade_project_update_previewable (project);
 }
 
 static void
@@ -4018,12 +3789,6 @@ glade_project_set_naming_policy (GladeProject       *project,
 
 }
 
-gboolean
-glade_project_get_previewable (GladeProject *project)
-{
-	return project->priv->previewable;
-}
-
 GladeNamingPolicy
 glade_project_get_naming_policy (GladeProject *project)
 {
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index 99f20b8..ab6b744 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -98,8 +98,6 @@ gboolean       glade_project_save                (GladeProject *project,
 						  const gchar   *path, 
 						  GError       **error);
 
-void           glade_project_preview             (GladeProject *project, GladeWidget *gwidget);
-
 const gchar   *glade_project_get_path            (GladeProject *project);
 
 gchar         *glade_project_get_name            (GladeProject *project);
@@ -186,8 +184,6 @@ time_t         glade_project_get_file_mtime       (GladeProject *project);
 
 gboolean       glade_project_get_modified         (GladeProject *project);
 
-gboolean       glade_project_get_previewable      (GladeProject *project);
-
 void           glade_project_set_format      	  (GladeProject *project, GladeProjectFormat format);
 
 GladeProjectFormat glade_project_get_format  	  (GladeProject *project);
diff --git a/plugins/gtk+/glade-gtk.c b/plugins/gtk+/glade-gtk.c
index 725cd08..4a3c893 100644
--- a/plugins/gtk+/glade-gtk.c
+++ b/plugins/gtk+/glade-gtk.c
@@ -1037,14 +1037,7 @@ glade_gtk_widget_action_activate (GladeWidgetAdaptor *adaptor,
 	else
 		gparent = NULL;
 
-	if (strcmp (action_path, "preview") == 0)
-	{
-		project = glade_widget_get_project (gwidget);
-		glade_project_preview (project,
-				       glade_widget_get_from_gobject((gpointer)object)
-				      );
-	}
-	else if (strcmp (action_path, "edit_separate") == 0)
+	if (strcmp (action_path, "edit_separate") == 0)
 	{
 		GtkWidget *dialog = 
 			glade_editor_dialog_for_widget (gwidget);
diff --git a/plugins/gtk+/gtk+.xml.in b/plugins/gtk+/gtk+.xml.in
index b8946b0..5456c7e 100644
--- a/plugins/gtk+/gtk+.xml.in
+++ b/plugins/gtk+/gtk+.xml.in
@@ -30,7 +30,6 @@
       </signals>
 
       <actions>
-	<action id="preview" _name="Preview snapshot"/>
         <action id="edit_separate" _name="Edit Separately" stock="gtk-edit"/>
         <action id="remove_parent" _name="Remove Parent" stock="gtk-remove"/>
         <action id="add_parent" _name="Add Parent" stock="gtk-add">
diff --git a/src/glade-window.c b/src/glade-window.c
index 93c0a51..b21dba7 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -118,7 +118,6 @@ struct _GladeWindowPrivate
 	gchar               *default_path;         /* the default path for open/save operations */
 	
 	GtkToggleToolButton *selector_button;      /* the widget selector button (replaces the one in the palette) */
-	GtkToolButton       *preview_button;	   /* the project preview button (replaces the one in the palette) */
 	GtkToggleToolButton *drag_resize_button;   /* sets the pointer to drag/resize mode */
 	gboolean             setting_pointer_mode; /* avoid feedback signal loops */
 
@@ -735,49 +734,6 @@ on_selector_button_toggled (GtkToggleToolButton *button, GladeWindow *window)
 		gtk_toggle_tool_button_set_active (window->priv->selector_button, TRUE);
 }
 
-static void
-on_preview_button_clicked (GtkToggleToolButton *button, GladeWindow *window)
-{
-	GladeProject *project;
-
-	const GList *objects;
-
-	GtkWidget *widget = NULL;
-	GtkWidget *window_to_preview = NULL;
-	GladeWidget *glade_widget = NULL;
-
-	project = glade_design_view_get_project (window->priv->active_view);
-
-	if (project == NULL)
-		return;
-
-	objects = glade_project_get_objects (project);
-
-	while (objects != NULL)
-	{
-		if (GTK_IS_WIDGET (objects->data))
-		{
-			widget = GTK_WIDGET(objects->data);
-			if (GTK_IS_WINDOW (widget)) 
-			{
-				window_to_preview = widget;
-				break;
-			}
-		}
-		objects = objects->next;
-	}
-
-	if (widget != NULL)
-	{
-		glade_widget = glade_widget_get_from_gobject (G_OBJECT (widget));
-	}
-
-	if (window_to_preview != NULL) widget = window_to_preview;
-	glade_project_preview (project,
-			       glade_widget_get_from_gobject((gpointer)widget)
-			      );
-}
-
 
 static void
 on_drag_resize_button_toggled (GtkToggleToolButton *button, GladeWindow *window)
@@ -2385,24 +2341,6 @@ create_selector_tool_button (GtkToolbar *toolbar)
 }
 
 static GtkWidget *
-create_preview_tool_button (GtkToolbar *toolbar)
-{
-	GtkToolItem  *button;
-	button = gtk_tool_button_new_from_stock (GTK_STOCK_EXECUTE);
-	gtk_tool_button_set_label (GTK_TOOL_BUTTON(button), _("Preview snapshot"));
-
-	gtk_tool_item_set_tooltip (GTK_TOOL_ITEM (button),
-				   toolbar->tooltips,
-				   _("Previews snapshot of project"),
-				   NULL);
-
-	gtk_widget_show (GTK_WIDGET (button));
-
-	return GTK_WIDGET (button);
-}
-
-
-static GtkWidget *
 create_drag_resize_tool_button (GtkToolbar *toolbar)
 {
 	GtkToolItem  *button;
@@ -2551,9 +2489,6 @@ add_project (GladeWindow *window, GladeProject *project, gboolean for_file)
 
 	g_object_set_data (G_OBJECT (view), "view-added-while-loading", GINT_TO_POINTER (for_file));
 
-	/* Update preview button */
-	gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button), FALSE);
-
 	/* Pass ownership of the project to the app */
 	glade_app_add_project (project);
 	g_object_unref (project);
@@ -2803,14 +2738,8 @@ refresh_undo_redo (GladeWindow *window)
 static void
 update_ui (GladeApp *app, GladeWindow *window)
 {
-	GladeProject *project;
 	if (window->priv->active_view)
-	{
-		project = glade_design_view_get_project (window->priv->active_view);
-		gtk_widget_set_sensitive ( GTK_WIDGET (window->priv->preview_button),
-					   glade_project_get_previewable (project));
 		gtk_widget_queue_draw (GTK_WIDGET (window->priv->active_view));
-	}
 
 	refresh_undo_redo (window);
 
@@ -3375,12 +3304,6 @@ glade_window_init (GladeWindow *window)
 	gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar), 
 			    GTK_TOOL_ITEM (priv->selector_button), -1);
 
-	priv->preview_button =
-		GTK_TOOL_BUTTON (create_preview_tool_button (GTK_TOOLBAR (priv->toolbar)));
-	gtk_toolbar_insert (GTK_TOOLBAR (priv->toolbar),
-			    GTK_TOOL_ITEM (priv->preview_button), -1);
-	gtk_widget_set_sensitive (GTK_WIDGET (priv->preview_button), FALSE);
-
 	priv->drag_resize_button = 
 		GTK_TOGGLE_TOOL_BUTTON (create_drag_resize_tool_button 
 					(GTK_TOOLBAR (priv->toolbar)));	
@@ -3392,8 +3315,6 @@ glade_window_init (GladeWindow *window)
 
 	g_signal_connect (G_OBJECT (priv->selector_button), "toggled",
 			  G_CALLBACK (on_selector_button_toggled), window);
-	g_signal_connect (G_OBJECT (priv->preview_button), "clicked",
-			  G_CALLBACK (on_preview_button_clicked), window);
 	g_signal_connect (G_OBJECT (priv->drag_resize_button), "toggled",
 			  G_CALLBACK (on_drag_resize_button_toggled), window);
 	g_signal_connect (G_OBJECT (glade_app_get()), "notify::pointer-mode",



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