[gnome-builder] glade: add helper to save project for view
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] glade: add helper to save project for view
- Date: Mon, 22 Oct 2018 20:58:14 +0000 (UTC)
commit 536a5936af34be5c5eeaa1ea3b0ff5823d325241
Author: Christian Hergert <chergert redhat com>
Date: Mon Oct 22 13:56:54 2018 -0700
glade: add helper to save project for view
src/plugins/glade/gbp-glade-private.h | 6 ++++--
src/plugins/glade/gbp-glade-view-actions.c | 9 +--------
src/plugins/glade/gbp-glade-view.c | 22 ++++++++++++++++++++++
3 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/src/plugins/glade/gbp-glade-private.h b/src/plugins/glade/gbp-glade-private.h
index b66bb3008..debbbea8c 100644
--- a/src/plugins/glade/gbp-glade-private.h
+++ b/src/plugins/glade/gbp-glade-private.h
@@ -37,7 +37,9 @@ struct _GbpGladeView
GladeAdaptorChooser *chooser;
};
-void _gbp_glade_view_init_actions (GbpGladeView *self);
-void _gbp_glade_view_init_shortcuts (GtkWidget *widget);
+void _gbp_glade_view_init_actions (GbpGladeView *self);
+void _gbp_glade_view_init_shortcuts (GtkWidget *widget);
+gboolean _gbp_glade_view_save (GbpGladeView *self,
+ GError **error);
G_END_DECLS
diff --git a/src/plugins/glade/gbp-glade-view-actions.c b/src/plugins/glade/gbp-glade-view-actions.c
index 143b3b38e..41f5105dd 100644
--- a/src/plugins/glade/gbp-glade-view-actions.c
+++ b/src/plugins/glade/gbp-glade-view-actions.c
@@ -33,18 +33,11 @@ gbp_glade_view_action_save (GSimpleAction *action,
{
GbpGladeView *self = user_data;
g_autoptr(GError) error = NULL;
- const gchar *path;
g_assert (G_IS_SIMPLE_ACTION (action));
g_assert (GBP_IS_GLADE_VIEW (self));
- if (self->file == NULL || !(path = g_file_peek_path (self->file)))
- {
- g_warning ("GbpGladeView is missing a file");
- return;
- }
-
- if (!glade_project_save (self->project, path, &error))
+ if (!_gbp_glade_view_save (self, &error))
/* translators: %s is replaced with the specific error message */
ide_widget_warning (self, _("Failed to save glade document: %s"), error->message);
}
diff --git a/src/plugins/glade/gbp-glade-view.c b/src/plugins/glade/gbp-glade-view.c
index f14556051..f7e77f7e4 100644
--- a/src/plugins/glade/gbp-glade-view.c
+++ b/src/plugins/glade/gbp-glade-view.c
@@ -42,6 +42,28 @@ gbp_glade_view_new (void)
return g_object_new (GBP_TYPE_GLADE_VIEW, NULL);
}
+gboolean
+_gbp_glade_view_save (GbpGladeView *self,
+ GError **error)
+{
+ const gchar *path;
+
+ g_return_val_if_fail (GBP_IS_GLADE_VIEW (self), FALSE);
+ g_return_val_if_fail (GLADE_IS_PROJECT (self->project), FALSE);
+
+ if (self->file == NULL || !(path = g_file_peek_path (self->file)))
+ {
+ /* Implausible path */
+ g_set_error (error,
+ G_IO_ERROR,
+ G_IO_ERROR_NOT_FOUND,
+ "No file has been set for the view");
+ return FALSE;
+ }
+
+ return glade_project_save (self->project, path, error);
+}
+
static void
viewport_style_changed_cb (GbpGladeView *self,
GtkStyleContext *style_context)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]