[gnome-text-editor] propertiesdialog: rescan when the document is saved
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-text-editor] propertiesdialog: rescan when the document is saved
- Date: Mon, 10 Jan 2022 20:35:36 +0000 (UTC)
commit 186c14d7cdc7922882911587ca2f35a85168f027
Author: Christian Hergert <chergert redhat com>
Date: Mon Jan 10 12:34:26 2022 -0800
propertiesdialog: rescan when the document is saved
Instead of showing an "Update" button, we can just update the document
when the file is saved to storage (or the drafts directory).
Fixes #282
src/editor-properties-dialog.c | 27 +++++----------------------
src/editor-properties-dialog.ui | 11 +----------
2 files changed, 6 insertions(+), 32 deletions(-)
---
diff --git a/src/editor-properties-dialog.c b/src/editor-properties-dialog.c
index 463f5d0..1a9a3c1 100644
--- a/src/editor-properties-dialog.c
+++ b/src/editor-properties-dialog.c
@@ -40,7 +40,6 @@ struct _EditorPropertiesDialog
GtkLabel *location;
GtkLabel *name;
GtkLabel *words;
- GtkButton *rescan;
};
G_DEFINE_TYPE (EditorPropertiesDialog, editor_properties_dialog, GTK_TYPE_WINDOW)
@@ -201,18 +200,16 @@ editor_properties_dialog_rescan (EditorPropertiesDialog *self)
str = g_strdup_printf("%'d", chars - white_chars);
gtk_label_set_label (self->chars, str);
g_free (str);
-
- gtk_widget_hide (GTK_WIDGET (self->rescan));
}
static void
-editor_properties_dialog_changed_cb (EditorPropertiesDialog *self,
- EditorDocument *document)
+editor_properties_dialog_save_cb (EditorPropertiesDialog *self,
+ EditorDocument *document)
{
g_assert (EDITOR_IS_PROPERTIES_DIALOG (self));
g_assert (EDITOR_IS_DOCUMENT (document));
- gtk_widget_show (GTK_WIDGET (self->rescan));
+ editor_properties_dialog_rescan (self);
}
static void
@@ -232,8 +229,8 @@ editor_properties_dialog_set_document (EditorPropertiesDialog *self,
G_BINDING_SYNC_CREATE,
file_to_location, NULL, NULL, NULL);
g_signal_connect_object (self->document,
- "changed",
- G_CALLBACK (editor_properties_dialog_changed_cb),
+ "save",
+ G_CALLBACK (editor_properties_dialog_save_cb),
self,
G_CONNECT_SWAPPED);
editor_properties_dialog_rescan (self);
@@ -285,18 +282,6 @@ win_close_cb (GtkWidget *widget,
gtk_window_close (GTK_WINDOW (widget));
}
-static void
-win_rescan_cb (GtkWidget *widget,
- const char *action_name,
- GVariant *param)
-{
- EditorPropertiesDialog *self = EDITOR_PROPERTIES_DIALOG (widget);
-
- g_assert (EDITOR_IS_PROPERTIES_DIALOG (self));
-
- editor_properties_dialog_rescan (self);
-}
-
static void
editor_properties_dialog_dispose (GObject *object)
{
@@ -370,12 +355,10 @@ editor_properties_dialog_class_init (EditorPropertiesDialogClass *klass)
gtk_widget_class_bind_template_child (widget_class, EditorPropertiesDialog, lines);
gtk_widget_class_bind_template_child (widget_class, EditorPropertiesDialog, location);
gtk_widget_class_bind_template_child (widget_class, EditorPropertiesDialog, name);
- gtk_widget_class_bind_template_child (widget_class, EditorPropertiesDialog, rescan);
gtk_widget_class_bind_template_child (widget_class, EditorPropertiesDialog, words);
gtk_widget_class_bind_template_callback (widget_class, activate_link_cb);
gtk_widget_class_install_action (widget_class, "win.close", NULL, win_close_cb);
- gtk_widget_class_install_action (widget_class, "win.rescan", NULL, win_rescan_cb);
gtk_widget_class_add_binding_action (widget_class, GDK_KEY_Escape, 0, "win.close", NULL);
}
diff --git a/src/editor-properties-dialog.ui b/src/editor-properties-dialog.ui
index cf1952e..e8e472f 100644
--- a/src/editor-properties-dialog.ui
+++ b/src/editor-properties-dialog.ui
@@ -10,16 +10,7 @@
<class name="properties-dialog"/>
</style>
<child type="titlebar">
- <object class="GtkHeaderBar">
- <child type="start">
- <object class="GtkButton" id="rescan">
- <property name="label" translatable="yes">_Update</property>
- <property name="use-underline">true</property>
- <property name="visible">false</property>
- <property name="action-name">win.rescan</property>
- </object>
- </child>
- </object>
+ <object class="GtkHeaderBar"/>
</child>
<child>
<object class="GtkBox">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]