[glade3/glade-3-8] * gladeui/glade-project.[ch]: Removed dialog and added "load-progress" signal
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glade3/glade-3-8] * gladeui/glade-project.[ch]: Removed dialog and added "load-progress" signal
- Date: Wed, 22 Dec 2010 03:34:42 +0000 (UTC)
commit 20f158b9b0ea4e9a16bd5fbbaaf0c15b8d798369
Author: Tristan Van Berkom <tristan van berkom gmail com>
Date: Wed Dec 22 12:40:50 2010 +0900
* gladeui/glade-project.[ch]: Removed dialog and added "load-progress" signal
* gladeui/glade-app.c: Protect against commands executed on loading projects
* src/glade-window.c: Added load progressbar to notebook tabs.
ChangeLog | 8 ++
gladeui/glade-app.c | 21 +++-
gladeui/glade-marshallers.list | 1 +
gladeui/glade-project.c | 224 +++++++++++++++++++++-------------------
gladeui/glade-project.h | 3 +
src/glade-window.c | 172 ++++++++++++++++++++++++-------
6 files changed, 280 insertions(+), 149 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index f3e9dd6..7a87eb1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-12-22 Tristan Van Berkom <tristanvb openismus com>
+
+ * gladeui/glade-project.[ch]: Removed dialog and added "load-progress" signal
+
+ * gladeui/glade-app.c: Protect against commands executed on loading projects
+
+ * src/glade-window.c: Added load progressbar to notebook tabs.
+
2010-12-21 Tristan Van Berkom <tristanvb openismus com>
Added loading objects dialog with progress and cancel.
diff --git a/gladeui/glade-app.c b/gladeui/glade-app.c
index d409e00..cc08215 100644
--- a/gladeui/glade-app.c
+++ b/gladeui/glade-app.c
@@ -1128,10 +1128,9 @@ glade_app_command_copy (void)
gboolean failed = FALSE;
app = glade_app_get();
- if (app->priv->active_project == NULL)
- {
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
return;
- }
for (list = glade_app_get_selection ();
list && list->data; list = list->next)
@@ -1171,7 +1170,8 @@ glade_app_command_cut (void)
gboolean failed = FALSE;
app = glade_app_get();
- if (app->priv->active_project == NULL)
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
return;
for (list = glade_app_get_selection ();
@@ -1213,9 +1213,17 @@ glade_app_command_paste (GladePlaceholder *placeholder)
GladeFixed *fixed = NULL;
app = glade_app_get();
- if (app->priv->active_project == NULL)
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
return;
+ if (placeholder)
+ {
+ if (glade_placeholder_get_project (placeholder) == NULL ||
+ glade_project_is_loading (glade_placeholder_get_project (placeholder)))
+ return;
+ }
+
list = glade_project_selection_get (app->priv->active_project);
clipboard = glade_app_get_clipboard ();
@@ -1336,7 +1344,8 @@ glade_app_command_delete (void)
gboolean failed = FALSE;
app = glade_app_get();
- if (app->priv->active_project == NULL)
+ if (app->priv->active_project == NULL ||
+ glade_project_is_loading (app->priv->active_project))
return;
for (list = glade_app_get_selection ();
diff --git a/gladeui/glade-marshallers.list b/gladeui/glade-marshallers.list
index 88879b1..4b727dd 100644
--- a/gladeui/glade-marshallers.list
+++ b/gladeui/glade-marshallers.list
@@ -3,6 +3,7 @@ VOID:POINTER
VOID:STRING,ULONG,UINT,STRING
VOID:OBJECT
VOID:STRING
+VOID:INT,INT
VOID:OBJECT,OBJECT
VOID:OBJECT,BOOLEAN
VOID:STRING,STRING,STRING
diff --git a/gladeui/glade-project.c b/gladeui/glade-project.c
index 1a2774d..7ab7b37 100644
--- a/gladeui/glade-project.c
+++ b/gladeui/glade-project.c
@@ -64,6 +64,7 @@ enum
PARSE_FINISHED,
CONVERT_FINISHED,
TARGETS_CHANGED,
+ LOAD_PROGRESS,
LAST_SIGNAL
};
@@ -157,9 +158,7 @@ struct _GladeProjectPrivate
GtkWidget *relative_path_entry;
GtkWidget *full_path_button;
- /* For the loading progress dialog */
- GtkWidget *progress_dialog;
- GtkWidget *progress;
+ /* For the loading progress bars ("load-progress" signal) */
gint progress_step;
gint progress_full;
gboolean load_cancel;
@@ -332,7 +331,6 @@ glade_project_finalize (GObject *object)
GladeProject *project = GLADE_PROJECT (object);
GList *list;
TopLevelInfo *tinfo;
-
/* XXX FIXME: Destroy dialog related sizegroups here... */
gtk_widget_destroy (project->priv->prefs_dialog);
@@ -912,21 +910,36 @@ glade_project_class_init (GladeProjectClass *klass)
G_TYPE_NONE,
0);
-
- /**
+ /**
* GladeProject::targets-changed:
+ * @gladeproject: the #GladeProject which received the signal.
+ *
+ * Emitted when @gladeproject target versions change.
+ */
+ glade_project_signals[TARGETS_CHANGED] =
+ g_signal_new ("targets-changed",
+ G_TYPE_FROM_CLASS (object_class),
+ G_SIGNAL_RUN_FIRST,
+ 0, NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ /**
+ * GladeProject::load-progress:
* @gladeproject: the #GladeProject which received the signal.
+ * @objects_total: the total amount of objects to load
+ * @objects_loaded: the current amount of loaded objects
*
- * Emitted when @gladeproject target versions change.
+ * Emitted while @project is loading.
*/
- glade_project_signals[TARGETS_CHANGED] =
- g_signal_new ("targets-changed",
+ glade_project_signals[LOAD_PROGRESS] =
+ g_signal_new ("load-progress",
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
0, NULL, NULL,
- g_cclosure_marshal_VOID__VOID,
- G_TYPE_NONE,
- 0);
+ glade_marshal_VOID__INT_INT,
+ G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_INT);
g_object_class_install_property (object_class,
PROP_MODIFIED,
@@ -1439,69 +1452,14 @@ glade_project_count_xml_objects (GladeProject *project, GladeXmlNode *root, gint
return count;
}
-static gboolean
-glade_progress_dialog_show_on_delete (GtkWidget *widget,
- GdkEvent *event,
- gpointer nothing)
+void
+glade_project_cancel_load (GladeProject *project)
{
- gtk_widget_show (widget);
- return TRUE;
-}
+ g_return_if_fail (GLADE_IS_PROJECT (project));
-static void
-project_load_cancelled (GtkWidget *button,
- GladeProject *project)
-{
project->priv->load_cancel = TRUE;
}
-static void
-glade_project_loading_dialog (GladeProject *project, gint count)
-{
- GtkWidget *content, *cancel;
- gchar *str, *name;
-
- project->priv->progress_dialog = gtk_dialog_new ();
- content = gtk_dialog_get_content_area (GTK_DIALOG (project->priv->progress_dialog));
-
- gtk_window_set_default_size (GTK_WINDOW (project->priv->progress_dialog), 400, -1);
- gtk_window_set_deletable (GTK_WINDOW (project->priv->progress_dialog), FALSE);
- g_signal_connect (project->priv->progress_dialog, "delete-event",
- G_CALLBACK (glade_progress_dialog_show_on_delete), NULL);
-
- project->priv->progress = gtk_progress_bar_new ();
- name = glade_project_get_name (project);
- str = g_strdup_printf (_("Loading project %s"), name);
- gtk_window_set_title (GTK_WINDOW (project->priv->progress_dialog), str);
- g_free (str);
- g_free (name);
-
- gtk_box_pack_start (GTK_BOX (content), project->priv->progress, FALSE, FALSE, 2);
- gtk_widget_show (project->priv->progress);
-
- cancel = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_widget_show (cancel);
- gtk_dialog_add_action_widget (GTK_DIALOG (project->priv->progress_dialog),
- cancel, GTK_RESPONSE_CANCEL);
- g_signal_connect (cancel, "clicked", G_CALLBACK (project_load_cancelled), project);
-
- project->priv->progress_full = count;
- project->priv->progress_step = 0;
-
- gtk_widget_show (project->priv->progress_dialog);
-}
-
-static void
-glade_project_destroy_loading_dialog (GladeProject *project)
-{
- if (project->priv->progress_dialog)
- {
- gtk_widget_destroy (project->priv->progress_dialog);
- project->priv->progress_dialog = NULL;
- project->priv->progress = NULL;
- }
-}
-
gboolean
glade_project_load_cancelled (GladeProject *project)
{
@@ -1515,6 +1473,13 @@ glade_project_push_progress (GladeProject *project)
{
g_return_if_fail (GLADE_IS_PROJECT (project));
+ project->priv->progress_step++;
+
+ g_signal_emit (project, glade_project_signals [LOAD_PROGRESS], 0,
+ project->priv->progress_full,
+ project->priv->progress_step);
+
+#if 0
if (project->priv->progress)
{
gchar *text;
@@ -1533,10 +1498,11 @@ glade_project_push_progress (GladeProject *project)
while (gtk_events_pending ())
gtk_main_iteration ();
}
+#endif
}
static gboolean
-glade_project_load_from_file (GladeProject *project, const gchar *path)
+glade_project_load_internal (GladeProject *project)
{
GladeXmlContext *context;
GladeXmlDoc *doc;
@@ -1551,15 +1517,13 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
project->priv->objects = NULL;
project->priv->loading = TRUE;
- project->priv->path = glade_util_canonical_path (path);
-
/* get the context & root node of the catalog file */
if (!(context =
- glade_xml_context_new_from_path (path,
+ glade_xml_context_new_from_path (project->priv->path,
NULL,
NULL)))
{
- g_warning ("Couldn't open glade file [%s].", path);
+ g_warning ("Couldn't open glade file [%s].", project->priv->path);
return FALSE;
}
@@ -1572,7 +1536,8 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
glade_project_set_format (project, GLADE_PROJECT_FORMAT_GTKBUILDER);
else
{
- g_warning ("Couldnt determine project format, skipping %s", path);
+ g_warning ("Couldnt determine project format, skipping %s",
+ project->priv->path);
glade_xml_context_free (context);
return FALSE;
}
@@ -1580,7 +1545,7 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
/* XXX Need to load project->priv->comment ! */
glade_project_read_comment (project, doc);
- if (glade_project_read_requires (project, root, path, &has_gtk_dep) == FALSE)
+ if (glade_project_read_requires (project, root, project->priv->path, &has_gtk_dep) == FALSE)
{
glade_xml_context_free (context);
return FALSE;
@@ -1593,8 +1558,8 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
/* Launch a dialog if it's going to take enough time to be
* worth showing at all */
count = glade_project_count_xml_objects (project, root, 0);
- if (count > GLADE_PROJECT_LARGE_PROJECT)
- glade_project_loading_dialog (project, count);
+ project->priv->progress_full = count;
+ project->priv->progress_step = 0;
for (node = glade_xml_node_get_children (root);
node; node = glade_xml_node_next (node))
@@ -1614,10 +1579,11 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
/* Finished with the xml context */
glade_xml_context_free (context);
- glade_project_destroy_loading_dialog (project);
-
if (project->priv->load_cancel)
+ {
+ project->priv->loading = FALSE;
return FALSE;
+ }
if (!has_gtk_dep)
glade_project_introspect_gtk_version (project);
@@ -1651,6 +1617,33 @@ glade_project_load_from_file (GladeProject *project, const gchar *path)
}
+gboolean
+glade_project_load_from_file (GladeProject *project,
+ const gchar *path)
+{
+ gboolean retval;
+
+ g_return_val_if_fail (path != NULL, FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (project), FALSE);
+
+ project->priv->path = glade_util_canonical_path (path);
+
+ retval = glade_project_load_internal (project);
+
+ if (retval)
+ {
+ gchar *name, *title;
+
+ /* Update prefs dialogs here... */
+ name = glade_project_get_name (project);
+ title = g_strdup_printf (_("%s preferences"), name);
+ gtk_window_set_title (GTK_WINDOW (project->priv->prefs_dialog), title);
+ g_free (title);
+ g_free (name);
+ }
+ return retval;
+}
+
/**
* glade_project_load:
* @path:
@@ -1669,8 +1662,10 @@ glade_project_load (const gchar *path)
g_return_val_if_fail (path != NULL, NULL);
project = g_object_new (GLADE_TYPE_PROJECT, NULL);
+
+ project->priv->path = glade_util_canonical_path (path);
- retval = glade_project_load_from_file (project, path);
+ retval = glade_project_load_internal (project);
if (retval)
{
@@ -3033,6 +3028,47 @@ glade_project_update_previewable (GladeProject *project)
g_object_notify (G_OBJECT (project), "previewable");
}
+static void
+glade_project_notify_row_inserted (GladeProject *project,
+ GladeWidget *gwidget)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ /* The state of old iters go invalid and then the new iter is valid
+ * until the next change */
+ project->priv->stamp++;
+
+ glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+ gtk_tree_model_row_inserted (GTK_TREE_MODEL (project), path, &iter);
+ gtk_tree_path_free (path);
+
+ /* XXX Need to check and call this
+ * gtk_tree_model_row_has_child_toggled
+ */
+}
+
+static void
+glade_project_notify_row_deleted (GladeProject *project,
+ GladeWidget *gwidget)
+{
+ GtkTreeIter iter;
+ GtkTreePath *path;
+
+ glade_project_model_get_iter_for_object (project, gwidget->object, &iter);
+ path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
+ gtk_tree_model_row_deleted (GTK_TREE_MODEL (project), path);
+ gtk_tree_path_free (path);
+
+ /* XXX Need to check and call this
+ * gtk_tree_model_row_has_child_toggled
+ */
+
+
+ project->priv->stamp++;
+}
+
/**
* glade_project_add_object:
* @project: the #GladeProject the widget is added to
@@ -3050,8 +3086,6 @@ glade_project_add_object (GladeProject *project,
GladeWidget *gwidget;
GList *list, *children;
gchar *name;
- GtkTreeIter iter;
- GtkTreePath *path;
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (G_IS_OBJECT (object));
@@ -3106,17 +3140,7 @@ glade_project_add_object (GladeProject *project,
project->priv->objects = g_list_prepend (project->priv->objects, object);
- if (!project->priv->loading)
- {
- /* The state of old iters go invalid and then the new iter is valid
- * until the next change */
- project->priv->stamp++;
-
- glade_project_model_get_iter_for_object (project, object, &iter);
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
- gtk_tree_model_row_inserted (GTK_TREE_MODEL (project), path, &iter);
- gtk_tree_path_free (path);
- }
+ glade_project_notify_row_inserted (project, gwidget);
/* NOTE: Sensitive ordering here, we need to recurse after updating
* the tree model listeners (and update those listeners after our
@@ -3171,8 +3195,6 @@ glade_project_remove_object (GladeProject *project, GObject *object)
{
GladeWidget *gwidget;
GList *list, *children;
- GtkTreeIter iter;
- GtkTreePath *path;
g_return_if_fail (GLADE_IS_PROJECT (project));
g_return_if_fail (G_IS_OBJECT (object));
@@ -3193,11 +3215,7 @@ glade_project_remove_object (GladeProject *project, GObject *object)
}
/* Notify views that the row is being deleted *before* deleting it */
- glade_project_model_get_iter_for_object (project, object, &iter);
-
- path = gtk_tree_model_get_path (GTK_TREE_MODEL (project), &iter);
- gtk_tree_model_row_deleted (GTK_TREE_MODEL (project), path);
- gtk_tree_path_free (path);
+ glade_project_notify_row_deleted (project, gwidget);
/* Remove selection and release name from the name context */
glade_project_selection_remove (project, object, TRUE);
@@ -3214,8 +3232,6 @@ glade_project_remove_object (GladeProject *project, GObject *object)
project->priv->objects = g_list_remove (project->priv->objects, object);
g_object_unref (gwidget);
- project->priv->stamp++;
-
glade_project_update_previewable (project);
}
diff --git a/gladeui/glade-project.h b/gladeui/glade-project.h
index cfc6447..99f20b8 100644
--- a/gladeui/glade-project.h
+++ b/gladeui/glade-project.h
@@ -91,6 +91,8 @@ GType glade_project_get_type (void) G_GNUC_CONST;
GladeProject *glade_project_new (void);
GladeProject *glade_project_load (const gchar *path);
+gboolean glade_project_load_from_file (GladeProject *project,
+ const gchar *path);
gboolean glade_project_save (GladeProject *project,
const gchar *path,
@@ -219,6 +221,7 @@ gchar *glade_project_display_dependencies (GladeProject *project);
void glade_project_push_progress (GladeProject *project);
gboolean glade_project_load_cancelled (GladeProject *project);
+void glade_project_cancel_load (GladeProject *project);
G_END_DECLS
diff --git a/src/glade-window.c b/src/glade-window.c
index 4031f85..a86ce53 100644
--- a/src/glade-window.c
+++ b/src/glade-window.c
@@ -370,13 +370,13 @@ get_default_path (GladeWindow *window)
}
static void
-update_default_path (GladeWindow *window, GladeProject *project)
+update_default_path (GladeWindow *window, const gchar *filename)
{
gchar *path;
- g_return_if_fail (glade_project_get_path (project) != NULL);
+ g_return_if_fail (filename != NULL);
- path = g_path_get_dirname (glade_project_get_path (project));
+ path = g_path_get_dirname (filename);
g_free (window->priv->default_path);
window->priv->default_path = g_strdup (path);
@@ -958,7 +958,7 @@ switch_to_project (GladeWindow *window, GladeProject *project)
/* increase project popularity */
recent_add (window, glade_project_get_path (project));
- update_default_path (window, project);
+ update_default_path (window, glade_project_get_path (project));
for (i = 0; i < n; i++)
{
@@ -1192,7 +1192,7 @@ save (GladeWindow *window, GladeProject *project, const gchar *path)
display_name = glade_project_get_name (project);
recent_add (window, glade_project_get_path (project));
- update_default_path (window, project);
+ update_default_path (window, glade_project_get_path (project));
/* refresh names */
refresh_title (window);
@@ -1450,9 +1450,18 @@ confirm_close_project (GladeWindow *window, GladeProject *project)
}
static void
-do_close (GladeWindow *window, GladeDesignView *view)
+do_close (GladeWindow *window, GladeProject *project)
{
+ GladeDesignView *view;
gint n;
+
+ view = glade_design_view_get_from_project (project);
+
+ if (glade_project_is_loading (project))
+ {
+ glade_project_cancel_load (project);
+ return;
+ }
n = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view));
@@ -1483,15 +1492,17 @@ close_cb (GtkAction *action, GladeWindow *window)
if (!close)
return;
}
- do_close (window, view);
+ do_close (window, project);
}
static void
quit_cb (GtkAction *action, GladeWindow *window)
{
- GList *list;
+ GList *list, *projects;
- for (list = glade_app_get_projects (); list; list = list->next)
+ projects = g_list_copy (glade_app_get_projects ());
+
+ for (list = projects; list; list = list->next)
{
GladeProject *project = GLADE_PROJECT (list->data);
@@ -1499,20 +1510,24 @@ quit_cb (GtkAction *action, GladeWindow *window)
{
gboolean quit = confirm_close_project (window, project);
if (!quit)
+ {
+ g_list_free (projects);
return;
+ }
}
}
- while (glade_app_get_projects ())
+ for (list = projects; list; list = list->next)
{
GladeProject *project = GLADE_PROJECT (glade_app_get_projects ()->data);
- do_close (window, glade_design_view_get_from_project (project));
+ do_close (window, project);
}
glade_window_config_save (window);
- gtk_main_quit ();
+ g_list_free (projects);
+ gtk_main_quit ();
}
static void
@@ -1648,6 +1663,13 @@ notebook_switch_page_cb (GtkNotebook *notebook,
}
static void
+set_widget_sensitive_on_load (GladeProject *project,
+ GtkWidget *widget)
+{
+ gtk_widget_set_sensitive (widget, TRUE);
+}
+
+static void
notebook_tab_added_cb (GtkNotebook *notebook,
GladeDesignView *view,
guint page_num,
@@ -1686,7 +1708,14 @@ notebook_tab_added_cb (GtkNotebook *notebook,
inspector = glade_inspector_new ();
gtk_widget_show (inspector);
glade_inspector_set_project (GLADE_INSPECTOR (inspector), project);
-
+
+ if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (view), "view-added-while-loading")))
+ {
+ gtk_widget_set_sensitive (inspector, FALSE);
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (set_widget_sensitive_on_load), inspector);
+ }
+
gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->inspectors_notebook), inspector, NULL);
@@ -2447,25 +2476,59 @@ static void
tab_close_button_clicked_cb (GtkWidget *close_button,
GladeProject *project)
{
- GladeDesignView *view;
GladeWindow *window = GLADE_WINDOW (glade_app_get_window ());
gboolean close;
- view = glade_design_view_get_from_project (project);
-
if (glade_project_get_modified (project))
{
close = confirm_close_project (window, project);
if (!close)
return;
}
- do_close (window, view);
+ do_close (window, project);
+}
+
+static void
+project_load_progress_cb (GladeProject *project,
+ gint total,
+ gint step,
+ GtkProgressBar *progress)
+{
+ gchar *text;
+ gchar *name;
+
+ name = glade_project_get_name (project);
+
+ /* translators: "project name (objects loaded in total objects)" */
+ text = g_strdup_printf (_("%s (%d of %d)"), name, step, total);
+ gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progress), text);
+ g_free (text);
+ g_free (name);
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (progress), step * 1.0 / total);
+
+ while (gtk_events_pending ())
+ gtk_main_iteration ();
+}
+
+static void
+project_load_finished_cb (GladeProject *project,
+ GtkWidget *tab_label)
+{
+ GtkWidget *progress, *label;
+
+ progress = g_object_get_data (G_OBJECT (tab_label), "tab-progress");
+ label = g_object_get_data (G_OBJECT (tab_label), "tab-label");
+
+ gtk_widget_hide (progress);
+ gtk_widget_show (label);
}
static GtkWidget *
-create_notebook_tab (GladeWindow *window, GladeProject *project)
+create_notebook_tab (GladeWindow *window, GladeProject *project, gboolean for_file)
{
GtkWidget *tab_label, *ebox, *hbox, *close_button, *label, *dummy_label;
+ GtkWidget *progress;
tab_label = gtk_hbox_new (FALSE, 4);
@@ -2490,15 +2553,31 @@ create_notebook_tab (GladeWindow *window, GladeProject *project)
gtk_misc_set_padding (GTK_MISC (label), 0, 0);
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ progress = gtk_progress_bar_new ();
+ gtk_widget_set_name (progress, "glade-tab-label-progress");
+ gtk_box_pack_start (GTK_BOX (hbox), progress, FALSE, FALSE, 0);
+ g_signal_connect (project, "load-progress",
+ G_CALLBACK (project_load_progress_cb), progress);
+
dummy_label = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), dummy_label, TRUE, TRUE, 0);
gtk_widget_show (ebox);
gtk_widget_show (hbox);
gtk_widget_show (close_button);
- gtk_widget_show (label);
gtk_widget_show (dummy_label);
+ if (for_file)
+ {
+ gtk_widget_show (progress);
+
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (project_load_finished_cb), tab_label);
+ }
+ else
+ gtk_widget_show (label);
+
+ g_object_set_data (G_OBJECT (tab_label), "tab-progress", progress);
g_object_set_data (G_OBJECT (tab_label), "tab-event-box", ebox);
g_object_set_data (G_OBJECT (tab_label), "tab-label", label);
@@ -2506,7 +2585,7 @@ create_notebook_tab (GladeWindow *window, GladeProject *project)
}
static void
-add_project (GladeWindow *window, GladeProject *project)
+add_project (GladeWindow *window, GladeProject *project, gboolean for_file)
{
GtkWidget *view, *label;
@@ -2515,24 +2594,30 @@ add_project (GladeWindow *window, GladeProject *project)
view = glade_design_view_new (project);
gtk_widget_show (view);
+ if (for_file)
+ {
+ g_object_set_data (G_OBJECT (view), "view-added-while-loading", GINT_TO_POINTER (1));
+
+ gtk_widget_set_sensitive (view, FALSE);
+ g_signal_connect (project, "parse-finished",
+ G_CALLBACK (set_widget_sensitive_on_load), view);
+ }
+
/* Pass ownership of the project to the app */
glade_app_add_project (project);
g_object_unref (project);
/* Custom notebook tab label (will be refreshed later) */
- label = create_notebook_tab (window, project);
+ label = create_notebook_tab (window, project, for_file);
gtk_notebook_append_page (GTK_NOTEBOOK (window->priv->notebook), GTK_WIDGET (view), label);
gtk_notebook_set_current_page (GTK_NOTEBOOK (window->priv->notebook), -1);
refresh_notebook_tab_for_project (window, project);
- /* Kick the inspector in the balls here... */
- glade_project_selection_changed (project);
-
/* Update preview button */
- gtk_widget_set_sensitive ( GTK_WIDGET (window->priv->preview_button),
- glade_project_get_previewable (project));
+ gtk_widget_set_sensitive (GTK_WIDGET (window->priv->preview_button),
+ glade_project_get_previewable (project));
}
void
@@ -2550,7 +2635,7 @@ glade_window_new_project (GladeWindow *window)
_("Could not create a new project."));
return;
}
- add_project (window, project);
+ add_project (window, project, FALSE);
}
static gboolean
@@ -2558,30 +2643,30 @@ open_project (GladeWindow *window, const gchar *path)
{
GladeProject *project;
- project = glade_project_load (path);
- if (!project)
+ project = glade_project_new ();
+
+ add_project (window, project, TRUE);
+ update_default_path (window, path);
+
+ if (!glade_project_load_from_file (project, path))
{
+ do_close (window, project);
+
recent_remove (window, path);
return FALSE;
}
-
- add_project (window, project);
/* increase project popularity */
recent_add (window, glade_project_get_path (project));
- update_default_path (window, project);
return TRUE;
-
}
static void
check_reload_project (GladeWindow *window, GladeProject *project)
{
- GladeDesignView *view;
- gchar *path;
- gint ret;
-
+ gchar *path;
+ gint ret;
GtkWidget *dialog;
GtkWidget *button;
gint response;
@@ -2650,10 +2735,9 @@ check_reload_project (GladeWindow *window, GladeProject *project)
}
/* Reopen */
- view = glade_design_view_get_from_project (project);
path = g_strdup (glade_project_get_path (project));
- do_close (window, view);
+ do_close (window, project);
ret = open_project (window, path);
g_free (path);
}
@@ -3447,6 +3531,16 @@ glade_window_class_init (GladeWindowClass *klass)
widget_class->configure_event = glade_window_configure_event;
widget_class->window_state_event = glade_window_state_event;
+ gtk_rc_parse_string ("style \"short_progress\"\n"
+ " { \n"
+ " GtkProgressBar::min-horizontal-bar-height = 1\n"
+ " GtkProgressBar::yspacing = 0\n"
+ " xthickness = 0\n"
+ " ythickness = 0\n"
+ " }\n"
+ "\n"
+ "widget \"*.glade-tab-label-progress\" style \"short_progress\"");
+
g_type_class_add_private (klass, sizeof (GladeWindowPrivate));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]