[gtranslator] Removed comment dialog.



commit 0675cd73f7c00369188686e53a943cf6428ae495
Author: Ignacio Casal Quinteiro <icq gnome org>
Date:   Thu Apr 15 17:54:59 2010 +0200

    Removed comment dialog.
    
    Now the custom comments are shown in the context panel. It also has
    the ability to add new comments.

 data/gtranslator-ui.xml                            |    2 -
 .../source-code-view/gtr-source-code-view-plugin.c |   17 +-
 src/dialogs/Makefile.am                            |    3 -
 src/dialogs/gtr-comment-dialog.c                   |  183 ---------
 src/dialogs/gtr-comment-dialog.h                   |   77 ----
 src/dialogs/gtr-comment-dialog.ui                  |  122 ------
 src/gtr-actions-edit.c                             |    7 -
 src/gtr-actions.h                                  |    2 -
 src/gtr-context.c                                  |  421 ++++++++++++++++++--
 src/gtr-context.h                                  |   18 +-
 src/gtr-tab.c                                      |   57 +---
 src/gtr-window.c                                   |    3 -
 12 files changed, 411 insertions(+), 501 deletions(-)
---
diff --git a/data/gtranslator-ui.xml b/data/gtranslator-ui.xml
index 83d0f20..c78c242 100644
--- a/data/gtranslator-ui.xml
+++ b/data/gtranslator-ui.xml
@@ -22,8 +22,6 @@
       <separator/>
       <menuitem name="EditHeaderMenu" action="EditHeader"/>
       <separator/>
-      <menuitem name="EditCommentMenu" action="EditComment"/>
-      <separator/>
       <menuitem name="EditMessage2TransMenu" action="EditMessage2Trans"/>
       <separator/>
       <menuitem name="EditFuzzyMenu" action="EditFuzzy"/>
diff --git a/plugins/source-code-view/gtr-source-code-view-plugin.c b/plugins/source-code-view/gtr-source-code-view-plugin.c
index 062bf54..1ad8a29 100644
--- a/plugins/source-code-view/gtr-source-code-view-plugin.c
+++ b/plugins/source-code-view/gtr-source-code-view-plugin.c
@@ -445,8 +445,7 @@ showed_message_cb (GtrTab * tab,
   path_start = gtk_text_buffer_create_mark (buffer,
                                             "path_start", &iter, TRUE);
 
-  if (gtk_text_buffer_get_char_count (buffer) != 0)
-    gtk_text_buffer_insert (buffer, &iter, "\n", 1);
+  gtk_text_buffer_insert (buffer, &iter, "\n", 1);
   gtk_text_buffer_insert_with_tags (buffer, &iter, _("Paths:"), -1, bold, NULL);
   gtk_text_buffer_insert (buffer, &iter, "\n", 1);
 
@@ -522,6 +521,18 @@ message_edition_finished_cb (GtrTab * tab,
 }
 
 static void
+on_context_panel_reloaded (GtrContextPanel         *panel,
+                           GtrMsg                  *msg,
+                           GtrSourceCodeViewPlugin *plugin)
+{
+  GtrTab *tab;
+
+  tab = gtr_window_get_active_tab (plugin->priv->window);
+
+  showed_message_cb (tab, msg, plugin);
+}
+
+static void
 page_added_cb (GtkNotebook * notebook,
                GtkWidget * child,
                guint page_num, GtrSourceCodeViewPlugin * plugin)
@@ -544,6 +555,8 @@ page_added_cb (GtkNotebook * notebook,
                     G_CALLBACK (motion_notify_event), NULL);
   g_signal_connect (view, "visibility-notify-event",
                     G_CALLBACK (visibility_notify_event), NULL);
+  g_signal_connect (panel, "reloaded",
+                    G_CALLBACK (on_context_panel_reloaded), plugin);
 }
 
 static void
diff --git a/src/dialogs/Makefile.am b/src/dialogs/Makefile.am
index 2a4a8d9..3e1ebc4 100644
--- a/src/dialogs/Makefile.am
+++ b/src/dialogs/Makefile.am
@@ -24,8 +24,6 @@ libdialogs_la_SOURCES = \
 	gtr-search-dialog.h \
 	gtr-header-dialog.c \
 	gtr-header-dialog.h \
-	gtr-comment-dialog.c \
-	gtr-comment-dialog.h \
 	gtr-profile-dialog.c \
 	gtr-profile-dialog.h \
 	gtr-assistant.c \
@@ -38,7 +36,6 @@ ui_DATA =  \
 		gtr-preferences-dialog.ui \
 		gtr-search-dialog.ui \
 		gtr-header-dialog.ui \
-		gtr-comment-dialog.ui \
 		gtr-profile-dialog.ui \
 		gtr-jump-dialog.ui
 
diff --git a/src/gtr-actions-edit.c b/src/gtr-actions-edit.c
index 39380a6..8446b9b 100644
--- a/src/gtr-actions-edit.c
+++ b/src/gtr-actions-edit.c
@@ -25,7 +25,6 @@
 #include <glib/gi18n.h>
 
 #include "dialogs/gtr-header-dialog.h"
-#include "dialogs/gtr-comment-dialog.h"
 #include "dialogs/gtr-preferences-dialog.h"
 #include "gtr-actions.h"
 #include "gtr-msg.h"
@@ -164,12 +163,6 @@ gtr_actions_edit_header (GtkAction * action, GtrWindow * window)
 }
 
 void
-gtr_edit_message_comment (GtkAction * action, GtrWindow * window)
-{
-  gtr_show_comment_dialog (window);
-}
-
-void
 gtr_actions_edit_clear (GtkAction * action, GtrWindow * window)
 {
   GtrTab *tab;
diff --git a/src/gtr-actions.h b/src/gtr-actions.h
index ef7e00e..0c33d00 100644
--- a/src/gtr-actions.h
+++ b/src/gtr-actions.h
@@ -60,8 +60,6 @@ void gtr_actions_edit_paste (GtkAction * action, GtrWindow * window);
 
 void gtr_actions_edit_header (GtkAction * action, GtrWindow * window);
 
-void gtr_edit_message_comment (GtkAction * action, GtrWindow * window);
-
 void gtr_message_copy_to_translation (GtkAction * action, GtrWindow * window);
 
 void gtr_message_status_toggle_fuzzy (GtkAction * action, GtrWindow * window);
diff --git a/src/gtr-context.c b/src/gtr-context.c
index fbd6a5b..1c373a1 100644
--- a/src/gtr-context.c
+++ b/src/gtr-context.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Copyright (C) 2007  Ignacio Casal Quinteiro <icq gnome org>
  * 
  *     This program is free software: you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -36,30 +36,239 @@ G_DEFINE_TYPE (GtrContextPanel, gtr_context_panel, GTK_TYPE_VBOX)
 
 struct _GtrContextPanelPrivate
 {
+  GtkWidget *sw;
   GtkWidget *context;
+  GtkWidget *button_box;
+
+  GdkCursor *hand_cursor;
+  GdkCursor *regular_cursor;
+  gboolean hovering_over_link;
 
   GtrTab *tab;
+  GtrMsg *current_msg;
+};
+
+enum
+{
+  PROP_0,
+  PROP_TAB
+};
+
+/* Signals */
+enum
+{
+	RELOADED,
+	LAST_SIGNAL
 };
 
+static guint signals[LAST_SIGNAL] = { 0 };
+
+static void
+setup_notes_edition (GtrContextPanel *panel)
+{
+  GtkTextBuffer *buffer;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
+  gtk_text_buffer_set_text (buffer, gtr_msg_get_comment (panel->priv->current_msg), -1);
+
+  gtk_text_view_set_editable (GTK_TEXT_VIEW (panel->priv->context), TRUE);
+  gtk_widget_show (panel->priv->button_box);
+}
+
+static void
+follow_if_link (GtrContextPanel *panel, GtkWidget *text_view, GtkTextIter *iter)
+{
+  GSList *tags = NULL, *tagp = NULL;
+
+  tags = gtk_text_iter_get_tags (iter);
+  for (tagp = tags; tagp != NULL; tagp = tagp->next)
+    {
+      GtkTextTag *tag = tagp->data;
+      gint *is_path = g_object_get_data (G_OBJECT (tag), "is_path");
+
+      if (is_path)
+        {
+          setup_notes_edition (panel);
+          break;
+        }
+    }
+
+  if (tags)
+    g_slist_free (tags);
+}
+
+static gboolean
+event_after (GtkWidget *text_view,
+             GdkEvent *ev, GtrContextPanel *panel)
+{
+  GtkTextIter start, end, iter;
+  GtkTextBuffer *buffer;
+  GdkEventButton *event;
+  gint x, y;
+
+  if (ev->type != GDK_BUTTON_RELEASE)
+    return FALSE;
+
+  event = (GdkEventButton *) ev;
+
+  if (event->button != 1)
+    return FALSE;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view));
+
+  /* we shouldn't follow a link if the user has selected something */
+  gtk_text_buffer_get_selection_bounds (buffer, &start, &end);
+  if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end))
+    return FALSE;
+
+  gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+                                         GTK_TEXT_WINDOW_WIDGET,
+                                         event->x, event->y, &x, &y);
+
+  gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y);
+
+  follow_if_link (panel, text_view, &iter);
+
+  return FALSE;
+}
+
+/* Looks at all tags covering the position (x, y) in the text view, 
+ * and if one of them is a link, change the cursor to the "hands" cursor
+ * typically used by web browsers.
+ */
+static void
+set_cursor_if_appropriate (GtkTextView * text_view, gint x, gint y,
+                           GtrContextPanel *panel)
+{
+  GSList *tags = NULL, *tagp = NULL;
+  GtkTextIter iter;
+  gboolean hovering = FALSE;
+
+  gtk_text_view_get_iter_at_location (text_view, &iter, x, y);
+
+  tags = gtk_text_iter_get_tags (&iter);
+  for (tagp = tags; tagp != NULL; tagp = tagp->next)
+    {
+      GtkTextTag *tag = tagp->data;
+      gint *is_path = g_object_get_data (G_OBJECT (tag), "is_path");
+
+      if (is_path)
+        {
+          hovering = TRUE;
+          break;
+        }
+    }
+
+  if (hovering != panel->priv->hovering_over_link)
+    {
+      panel->priv->hovering_over_link = hovering;
+
+      if (panel->priv->hovering_over_link)
+        gdk_window_set_cursor (gtk_text_view_get_window (text_view,
+                                                         GTK_TEXT_WINDOW_TEXT),
+                               panel->priv->hand_cursor);
+      else
+        gdk_window_set_cursor (gtk_text_view_get_window (text_view,
+                                                         GTK_TEXT_WINDOW_TEXT),
+                               panel->priv->regular_cursor);
+    }
+
+  if (tags)
+    g_slist_free (tags);
+}
+
+/* Update the cursor image if the pointer moved. */
+static gboolean
+motion_notify_event (GtkWidget *text_view, GdkEventMotion *event,
+                     GtrContextPanel *panel)
+{
+  gint x, y;
+
+  gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+                                         GTK_TEXT_WINDOW_WIDGET,
+                                         event->x, event->y, &x, &y);
+
+  set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), x, y, panel);
+
+  gdk_window_get_pointer (text_view->window, NULL, NULL, NULL);
+  return FALSE;
+}
+
+/* Also update the cursor image if the window becomes visible
+ * (e.g. when a window covering it got iconified). */
+static gboolean
+visibility_notify_event (GtkWidget *text_view, GdkEventVisibility *event,
+                         GtrContextPanel *panel)
+{
+  gint wx, wy, bx, by;
+
+  gdk_window_get_pointer (text_view->window, &wx, &wy, NULL);
+
+  gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view),
+                                         GTK_TEXT_WINDOW_WIDGET,
+                                         wx, wy, &bx, &by);
+
+  set_cursor_if_appropriate (GTK_TEXT_VIEW (text_view), bx, by, panel);
+
+  return FALSE;
+}
+
+static void
+add_notes (GtkTextBuffer *buffer, GtkTextIter *pos, GtkTextTag *header_tag,
+           GtrMsg *msg)
+{
+  GtkTextTag *tag;
+  const gchar *comments;
+
+  tag = gtk_text_buffer_create_tag (buffer, NULL,
+                                    "foreground", "blue",
+                                    "underline", PANGO_UNDERLINE_SINGLE,
+                                    NULL);
+
+  gtk_text_buffer_insert_with_tags (buffer, pos, _("Notes:"), -1, header_tag, NULL);
+  gtk_text_buffer_insert (buffer, pos, "\n", 1);
+
+  g_object_set_data (G_OBJECT (tag), "is_path", GINT_TO_POINTER (1));
+
+  comments = gtr_msg_get_comment (msg);
+
+  if (comments == NULL || *comments == '\0')
+    gtk_text_buffer_insert_with_tags (buffer, pos, _("Add Note"), -1, tag, NULL);
+  else
+    {
+      gtk_text_buffer_insert (buffer, pos, comments, -1);
+      gtk_text_buffer_insert (buffer, pos, "(", 1);
+      gtk_text_buffer_insert_with_tags (buffer, pos, _("Edit"), -1, tag, NULL);
+      gtk_text_buffer_insert (buffer, pos, ")", 1);
+    }
+
+  gtk_text_buffer_insert (buffer, pos, "\n", 1);
+}
+
 static void
 add_text (GtkTextBuffer *buffer, GtkTextTag *tag, GtkTextIter *pos,
           const gchar *header, const gchar *text)
 {
   if (text && *text != '\0')
     {
+      gtk_text_buffer_insert (buffer, pos, "\n", 1);
       gtk_text_buffer_insert_with_tags (buffer, pos, header, -1, tag, NULL);
       gtk_text_buffer_insert (buffer, pos, "\n", 1);
       gtk_text_buffer_insert (buffer, pos, text, -1);
+      gtk_text_buffer_insert (buffer, pos, "\n", 1);
     }
 }
 
 static void
-showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrContextPanel * panel)
+showed_message_cb (GtrTab *tab, GtrMsg *msg, GtrContextPanel *panel)
 {
   GtkTextBuffer *buffer;
   GtkTextIter iter;
   GtkTextTag *bold;
 
+  /* Update current msg */
+  panel->priv->current_msg = msg;
+
   buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
   gtk_text_buffer_set_text (buffer, "", 0);
   gtk_text_buffer_get_start_iter (buffer, &iter);
@@ -68,6 +277,9 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrContextPanel * panel)
   bold = gtk_text_buffer_create_tag (buffer, NULL, "weight", PANGO_WEIGHT_BOLD,
                                      "weight-set", TRUE, NULL);
 
+  /* Add custom comments */
+  add_notes (buffer, &iter, bold, msg);
+
   /* Extracted comments */
   add_text (buffer, bold, &iter, _("Extracted comments:"),
             gtr_msg_get_extracted_comments (msg));
@@ -82,50 +294,174 @@ showed_message_cb (GtrTab * tab, GtrMsg * msg, GtrContextPanel * panel)
 }
 
 static void
-gtr_context_panel_draw (GtrContextPanel * panel)
+reload_values (GtrContextPanel *panel)
 {
-  GtrContextPanelPrivate *priv = panel->priv;
-  GtkWidget *context_scrolled_window;
+  showed_message_cb (panel->priv->tab, panel->priv->current_msg, panel);
+  gtk_widget_hide (panel->priv->button_box);
+  gtk_text_view_set_editable (GTK_TEXT_VIEW (panel->priv->context), FALSE);
+
+  g_signal_emit (G_OBJECT (panel), signals[RELOADED], 0, panel->priv->current_msg);
+}
+
+static void
+on_accept_button_clicked (GtkButton *button, GtrContextPanel *panel)
+{
+  GtkTextBuffer *buffer;
+  GtkTextIter start, end;
+  gchar *text;
+
+  buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
+
+  gtk_text_buffer_get_bounds (buffer, &start, &end);
 
-  /*
-   * Set up the scrolling window for the extracted context display
-   */
-  context_scrolled_window = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW
-                                  (context_scrolled_window),
+  text = gtk_text_buffer_get_text (buffer, &start, &end, FALSE);
+
+  gtr_msg_set_comment (panel->priv->current_msg, text);
+
+  g_free (text);
+
+  reload_values (panel);
+}
+
+static void
+on_cancel_button_clicked (GtkButton *button, GtrContextPanel *panel)
+{
+  reload_values (panel);
+}
+
+static void
+gtr_context_panel_init (GtrContextPanel *panel)
+{
+  GtrContextPanelPrivate *priv;
+  GtkWidget *button;
+
+  panel->priv = GTR_CONTEXT_PANEL_GET_PRIVATE (panel);
+  priv = panel->priv;
+
+  priv->hovering_over_link = FALSE;
+
+  priv->hand_cursor = gdk_cursor_new (GDK_HAND2);
+  priv->regular_cursor = gdk_cursor_new (GDK_XTERM);
+
+  /* Set up the scrolling window for the extracted context display */
+  priv->sw = gtk_scrolled_window_new (NULL, NULL);
+  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->sw),
                                   GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
-  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW
-                                       (context_scrolled_window),
+  gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->sw),
                                        GTK_SHADOW_IN);
-  gtk_box_pack_start (GTK_BOX (panel), context_scrolled_window, TRUE, TRUE,
+  gtk_box_pack_start (GTK_BOX (panel), priv->sw, TRUE, TRUE,
                       0);
-  gtk_widget_show (context_scrolled_window);
+  gtk_widget_show (priv->sw);
 
-  /*
-   * Context
-   */
+  /* Context text view */
   priv->context = gtk_text_view_new ();
 
   gtk_text_view_set_editable (GTK_TEXT_VIEW (priv->context), FALSE);
   gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->context), GTK_WRAP_WORD);
-  gtk_container_add (GTK_CONTAINER (context_scrolled_window),
+  gtk_container_add (GTK_CONTAINER (priv->sw),
                      GTK_WIDGET (priv->context));
   gtk_widget_show (priv->context);
+
+  g_signal_connect (priv->context, "event-after",
+                    G_CALLBACK (event_after), panel);
+  g_signal_connect (priv->context, "motion-notify-event",
+                    G_CALLBACK (motion_notify_event), panel);
+  g_signal_connect (priv->context, "visibility-notify-event",
+                    G_CALLBACK (visibility_notify_event), panel);
+
+  /* Buttons */
+  priv->button_box = gtk_hbutton_box_new ();
+  gtk_box_pack_start (GTK_BOX (panel), priv->button_box, FALSE, FALSE, 0);
+
+  button = gtk_button_new_from_stock (GTK_STOCK_OK);
+  gtk_widget_show (button);
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (on_accept_button_clicked), panel);
+
+  gtk_box_pack_start (GTK_BOX (priv->button_box), button, FALSE, FALSE, 0);
+
+  button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+  gtk_widget_show (button);
+  g_signal_connect (button, "clicked",
+                    G_CALLBACK (on_cancel_button_clicked), panel);
+
+  gtk_box_pack_start (GTK_BOX (priv->button_box), button, FALSE, FALSE, 0);
 }
 
+static void
+gtr_context_panel_set_property (GObject      *object,
+                                guint         prop_id,
+                                const GValue *value,
+                                GParamSpec   *pspec)
+{
+  GtrContextPanel *panel = GTR_CONTEXT_PANEL (object);
+
+  switch (prop_id)
+    {
+    case PROP_TAB:
+      panel->priv->tab = GTR_TAB (g_value_get_object (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
 
 static void
-gtr_context_panel_init (GtrContextPanel * panel)
+gtr_context_panel_get_property (GObject    *object,
+                                guint       prop_id,
+                                GValue     *value,
+                                GParamSpec *pspec)
 {
-  panel->priv = GTR_CONTEXT_PANEL_GET_PRIVATE (panel);
+  GtrContextPanel *panel = GTR_CONTEXT_PANEL (object);
+
+  switch (prop_id)
+    {
+    case PROP_TAB:
+      g_value_set_object (value, panel->priv->tab);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+gtr_context_panel_constructed (GObject *object)
+{
+  GtrContextPanel *panel = GTR_CONTEXT_PANEL (object);
+
+  if (!panel->priv->tab)
+    {
+      g_critical ("The context was not constructed well, this shouldn't happen!");
+      return;
+    }
 
-  gtr_context_panel_draw (panel);
+  g_signal_connect (panel->priv->tab,
+                    "showed-message",
+                    G_CALLBACK (showed_message_cb), panel);
 }
 
 static void
-gtr_context_panel_finalize (GObject * object)
+gtr_context_panel_dispose (GObject *object)
 {
-  G_OBJECT_CLASS (gtr_context_panel_parent_class)->finalize (object);
+  GtrContextPanel *panel = GTR_CONTEXT_PANEL (object);
+
+  if (panel->priv->hand_cursor != NULL)
+    {
+      gdk_cursor_unref (panel->priv->hand_cursor);
+      panel->priv->hand_cursor = NULL;
+    }
+
+  if (panel->priv->regular_cursor != NULL)
+    {
+      gdk_cursor_unref (panel->priv->regular_cursor);
+      panel->priv->regular_cursor = NULL;
+    }
+
+  G_OBJECT_CLASS (gtr_context_panel_parent_class)->dispose (object);
 }
 
 static void
@@ -135,7 +471,30 @@ gtr_context_panel_class_init (GtrContextPanelClass * klass)
 
   g_type_class_add_private (klass, sizeof (GtrContextPanelPrivate));
 
-  object_class->finalize = gtr_context_panel_finalize;
+  object_class->dispose = gtr_context_panel_dispose;
+  object_class->set_property = gtr_context_panel_set_property;
+  object_class->get_property = gtr_context_panel_get_property;
+  object_class->constructed = gtr_context_panel_constructed;
+
+  signals[RELOADED] =
+    g_signal_new ("reloaded",
+                  G_OBJECT_CLASS_TYPE (object_class),
+                  G_SIGNAL_RUN_LAST,
+                  G_STRUCT_OFFSET (GtrContextPanelClass, reloaded),
+                  NULL, NULL,
+                  g_cclosure_marshal_VOID__OBJECT,
+                  G_TYPE_NONE,
+                  1,
+                  GTR_TYPE_MSG);
+
+  g_object_class_install_property (object_class,
+                                   PROP_TAB,
+                                   g_param_spec_object ("tab",
+                                                        "TAB",
+                                                        "The active tab",
+                                                        GTR_TYPE_TAB,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY));
 }
 
 /**
@@ -147,17 +506,9 @@ gtr_context_panel_class_init (GtrContextPanelClass * klass)
  * Returns: a new #GtrContextPanel object
  */
 GtkWidget *
-gtr_context_panel_new (GtkWidget * tab)
+gtr_context_panel_new (GtkWidget *tab)
 {
-  GtrContextPanel *context;
-  context = g_object_new (GTR_TYPE_CONTEXT_PANEL, NULL);
-
-  context->priv->tab = GTR_TAB (tab);
-  g_signal_connect (tab,
-                    "showed-message",
-                    G_CALLBACK (showed_message_cb), context);
-
-  return GTK_WIDGET (context);
+  return g_object_new (GTR_TYPE_CONTEXT_PANEL, "tab", tab, NULL);
 }
 
 /**
diff --git a/src/gtr-context.h b/src/gtr-context.h
index 75e3b6a..8aa37ff 100644
--- a/src/gtr-context.h
+++ b/src/gtr-context.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
+ * Copyright (C) 2007  Ignacio Casal Quinteiro <icq gnome org>
  * 
  *     This program is free software: you can redistribute it and/or modify
  *     it under the terms of the GNU General Public License as published by
@@ -22,6 +22,8 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
+#include "gtr-msg.h"
+
 G_BEGIN_DECLS
 /*
  * Type checking and casting macros
@@ -56,21 +58,19 @@ typedef struct _GtrContextPanelClass GtrContextPanelClass;
 struct _GtrContextPanelClass
 {
   GtkVBoxClass parent_class;
+
+  void (* reloaded) (GtrContextPanel *panel,
+                     GtrMsg          *msg);
 };
 
 /*
  * Public methods
  */
-GType
-gtr_context_panel_get_type (void)
-  G_GNUC_CONST;
-
-     GType gtr_context_panel_register_type (GTypeModule * module);
+GType             gtr_context_panel_get_type              (void) G_GNUC_CONST;
 
-     GtkWidget *gtr_context_panel_new (GtkWidget * tab);
+GtkWidget        *gtr_context_panel_new                   (GtkWidget *tab);
 
-GtkTextView
-  * gtr_context_panel_get_context_text_view (GtrContextPanel * panel);
+GtkTextView      *gtr_context_panel_get_context_text_view (GtrContextPanel *panel);
 
 G_END_DECLS
 #endif /* __CONTEXT_PANEL_H__ */
diff --git a/src/gtr-tab.c b/src/gtr-tab.c
index e3061b9..f4d7a01 100644
--- a/src/gtr-tab.c
+++ b/src/gtr-tab.c
@@ -32,7 +32,6 @@
 #include <config.h>
 #endif
 
-#include "dialogs/gtr-comment-dialog.h"
 #include "gtr-application.h"
 #include "gtr-context.h"
 #include "gtr-io-error-info-bar.h"
@@ -77,9 +76,6 @@ struct _GtrTabPrivate
   GtkWidget *context;
   GtkWidget *translation_memory;
 
-  /*Comment button */
-  GtkWidget *comment_button;
-
   /*Info bar */
   GtkWidget *infobar;
 
@@ -189,15 +185,6 @@ remove_autosave_timeout (GtrTab * tab)
 }
 
 static void
-gtr_tab_showed_message (GtrTab * tab, GtrMsg * msg)
-{
-  if (strcmp (gtr_msg_get_comment (msg), "") != 0)
-    gtk_widget_show (tab->priv->comment_button);
-  else
-    gtk_widget_hide (tab->priv->comment_button);
-}
-
-static void
 gtr_tab_edition_finished (GtrTab * tab, GtrMsg * msg)
 {
   GtrTranslationMemory *tm;
@@ -376,35 +363,6 @@ gtr_message_plural_forms (GtrTab * tab, GtrMsg * msg)
     }
 }
 
-static GtkWidget *
-gtr_tab_create_comment_button ()
-{
-  GtkWidget *button;
-  GtkWidget *image;
-
-  /* setup close button */
-  button = gtk_button_new ();
-  gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
-  /* don't allow focus on the close button */
-  gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
-
-  image = gtk_image_new_from_stock (GTK_STOCK_INDEX, GTK_ICON_SIZE_MENU);
-  gtk_widget_show (image);
-  gtk_container_add (GTK_CONTAINER (button), image);
-
-  gtk_widget_set_tooltip_text (button, _("Open comment dialog"));
-
-  return button;
-}
-
-static void
-on_comment_button_clicked (GtkButton * button, gpointer useless)
-{
-  GtrWindow *window = gtr_application_get_active_window (GTR_APP);
-
-  gtr_show_comment_dialog (window);
-}
-
 /*
  * gtr_tab_show_message:
  * @tab: a #GtranslationTab
@@ -732,9 +690,6 @@ gtr_tab_draw (GtrTab * tab)
   /*
    * Translation widgets
    */
-  priv->msgstr_hbox = gtk_hbox_new (FALSE, 0);
-  gtk_widget_show (priv->msgstr_hbox);
-
   priv->msgstr_label = gtk_label_new (NULL);
   gtk_label_set_markup_with_mnemonic (GTK_LABEL (priv->msgstr_label),
                                       _("<b>Translate_d Text:</b>"));
@@ -742,20 +697,11 @@ gtr_tab_draw (GtrTab * tab)
   gtk_misc_set_alignment (GTK_MISC (priv->msgstr_label), 0, 0.5);
   gtk_widget_show (priv->msgstr_label);
 
-  gtk_box_pack_start (GTK_BOX (priv->msgstr_hbox), priv->msgstr_label, TRUE,
-                      TRUE, 0);
-
-  priv->comment_button = gtr_tab_create_comment_button ();
-  gtk_box_pack_start (GTK_BOX (priv->msgstr_hbox), priv->comment_button,
-                      FALSE, FALSE, 0);
-  g_signal_connect (priv->comment_button, "clicked",
-                    G_CALLBACK (on_comment_button_clicked), NULL);
-
   priv->trans_notebook = gtk_notebook_new ();
   gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->trans_notebook), FALSE);
   gtk_widget_show (priv->trans_notebook);
 
-  gtk_box_pack_start (GTK_BOX (vertical_box), priv->msgstr_hbox, FALSE, FALSE,
+  gtk_box_pack_start (GTK_BOX (vertical_box), priv->msgstr_label, FALSE, FALSE,
                       0);
   gtk_box_pack_start (GTK_BOX (vertical_box), priv->trans_notebook, TRUE,
                       TRUE, 0);
@@ -851,7 +797,6 @@ gtr_tab_class_init (GtrTabClass * klass)
   object_class->finalize = gtr_tab_finalize;
   object_class->set_property = gtr_tab_set_property;
   object_class->get_property = gtr_tab_get_property;
-  klass->showed_message = gtr_tab_showed_message;
   klass->message_edition_finished = gtr_tab_edition_finished;
 
   /* Signals */
diff --git a/src/gtr-window.c b/src/gtr-window.c
index 0037f3a..accee7d 100644
--- a/src/gtr-window.c
+++ b/src/gtr-window.c
@@ -192,9 +192,6 @@ static const GtkActionEntry entries[] = {
    G_CALLBACK (gtr_actions_edit_clear)},
   {"EditHeader", GTK_STOCK_PROPERTIES, N_("_Header..."), NULL, NULL,
    G_CALLBACK (gtr_actions_edit_header)},
-  {"EditComment", GTK_STOCK_INDEX, N_("C_omment..."), NULL,
-   N_("Edit message comment"),
-   G_CALLBACK (gtr_edit_message_comment)},
   {"EditMessage2Trans", NULL, N_("Copy _Message to Translation"),
    "<control>space",
    N_("Copy original message contents to the translation field"),



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