[gtranslator: 1/2] Open message notes in a modal window.
- From: Daniel Garcia Moreno <danigm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtranslator: 1/2] Open message notes in a modal window.
- Date: Tue, 6 Nov 2018 09:22:02 +0000 (UTC)
commit f6bc3d284d5b0377cf7eaf1be79796b60e8ca9a6
Author: Teja Cetinski <teja cetinski eu>
Date: Tue Nov 6 10:10:00 2018 +0100
Open message notes in a modal window.
src/gtr-context.c | 66 +++++++++++++++++++++++++++++++++---------------------
src/gtr-context.ui | 27 +---------------------
2 files changed, 41 insertions(+), 52 deletions(-)
---
diff --git a/src/gtr-context.c b/src/gtr-context.c
index 76be7bb5..735dd983 100644
--- a/src/gtr-context.c
+++ b/src/gtr-context.c
@@ -33,8 +33,6 @@ typedef struct
{
GtkWidget *sw;
GtkWidget *context;
- GtkWidget *button_box;
- GtkWidget *button;
GtkWidget *translation_memory_box;
GdkCursor *hand_cursor;
@@ -65,19 +63,51 @@ enum
static guint signals[LAST_SIGNAL] = { 0 };
+static void buffer_end_user_action (GtkTextBuffer *buffer, GtrContextPanel *panel);
+static void reload_values (GtrContextPanel *panel);
+
static void
setup_notes_edition (GtrContextPanel *panel)
{
- GtkTextBuffer *buffer;
GtrContextPanelPrivate *priv;
+ GtkWidget *dialog;
+ GtkBox *dialog_area;
+ GtkWidget *text_view;
+ GtkTextBuffer *text_buffer;
+ gint result;
+
+ priv = gtr_context_panel_get_instance_private (panel);
+
+ dialog = gtk_dialog_new_with_buttons (_("Edit notes"),
+ GTK_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (panel))),
+ GTK_DIALOG_MODAL,
+ _("_Save"),
+ GTK_RESPONSE_ACCEPT,
+ _("_Cancel"),
+ GTK_RESPONSE_REJECT,
+ NULL);
+
+ dialog_area = GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog)));
+ text_view = gtk_text_view_new ();
+ gtk_box_pack_start (dialog_area, text_view, TRUE, TRUE, 6);
+
+ text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
+ gtk_text_buffer_set_text (text_buffer, gtr_msg_get_comment (priv->current_msg), -1);
+
+ gtk_widget_show_all (dialog);
+ result = gtk_dialog_run (GTK_DIALOG (dialog));
+
+ switch (result)
+ {
+ case GTK_RESPONSE_ACCEPT:
+ buffer_end_user_action (text_buffer, panel);
+ break;
+ default:
+ break;
+ }
- priv = gtr_context_panel_get_instance_private(panel);
-
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->context));
- gtk_text_buffer_set_text (buffer, gtr_msg_get_comment (priv->current_msg), -1);
-
- gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->context), TRUE);
- gtk_widget_show (priv->button_box);
+ gtk_widget_destroy (dialog);
+ reload_values(panel);
}
static void
@@ -314,7 +344,6 @@ reload_values (GtrContextPanel *panel)
priv = gtr_context_panel_get_instance_private(panel);
showed_message_cb (priv->tab, priv->current_msg, panel);
- gtk_widget_hide (priv->button_box);
gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->context), FALSE);
g_signal_emit (G_OBJECT (panel), signals[RELOADED], 0, priv->current_msg);
@@ -331,8 +360,6 @@ buffer_end_user_action (GtkTextBuffer *buffer, GtrContextPanel *panel)
priv = gtr_context_panel_get_instance_private(panel);
- buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->context));
-
gtk_text_buffer_get_bounds (buffer, &start, &end);
text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
@@ -348,12 +375,6 @@ buffer_end_user_action (GtkTextBuffer *buffer, GtrContextPanel *panel)
gtr_po_set_state (po, GTR_PO_STATE_MODIFIED);
}
-static void
-on_done_button_clicked (GtkButton *button, GtrContextPanel *panel)
-{
- reload_values (panel);
-}
-
static void
gtr_context_panel_init (GtrContextPanel *panel)
{
@@ -382,11 +403,6 @@ gtr_context_panel_init (GtrContextPanel *panel)
buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->context));
g_signal_connect (buffer, "end-user-action",
G_CALLBACK (buffer_end_user_action), panel);
-
- g_signal_connect (priv->button, "clicked",
- G_CALLBACK (on_done_button_clicked), panel);
-
- gtk_widget_hide (priv->button_box);
}
static void
@@ -504,8 +520,6 @@ gtr_context_panel_class_init (GtrContextPanelClass * klass)
gtk_widget_class_bind_template_child_private (widget_class, GtrContextPanel, sw);
gtk_widget_class_bind_template_child_private (widget_class, GtrContextPanel, context);
- gtk_widget_class_bind_template_child_private (widget_class, GtrContextPanel, button_box);
- gtk_widget_class_bind_template_child_private (widget_class, GtrContextPanel, button);
gtk_widget_class_bind_template_child_private (widget_class, GtrContextPanel, translation_memory_box);
}
diff --git a/src/gtr-context.ui b/src/gtr-context.ui
index a93b4d71..851944d2 100644
--- a/src/gtr-context.ui
+++ b/src/gtr-context.ui
@@ -41,31 +41,6 @@
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButtonBox" id="button_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="layout_style">end</property>
- <child>
- <object class="GtkButton" id="button">
- <property name="label" translatable="yes">D_one</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_underline">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">0</property>
- </packing>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
</template>
</interface>
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]