gtranslator r3649 - in trunk: . plugins/source-code-view src src/dialogs



Author: icq
Date: Mon Sep 22 09:40:58 2008
New Revision: 3649
URL: http://svn.gnome.org/viewvc/gtranslator?rev=3649&view=rev

Log:
Squashed commit of the following:

commit 5afbd4d2b12590fb0da9e95f8642158bbeb06832
Author: Ignacio Casal Quinteiro <nacho resa gmail com>
Date:   Mon Aug 4 10:44:52 2008 +0200

    2008-08-04  Ignacio Casal Quinteiro  <nacho resa gmail com>

            * plugins/source-code-view/source-code-view-plugin.c:
            Changed to new context.ch API.

    	* src/
    	* comment.c:
    	* comment.h:
    	* context.c (showed_message_cb),
    (gtranslator_context_panel_draw),
    	(gtranslator_context_panel_init),
    	(gtranslator_context_panel_finalize),
    	(gtranslator_context_panel_class_init),
    	(gtranslator_context_panel_new),
    	(gtranslator_context_panel_get_context_text_view):
    	* context.h:
    	* dialogs/comment-dialog.c:
    	* tab.c:
    	* tab.h:
    	* Makefile.am:
    	Renamed comment.ch as context.ch and removed the custom comment
    view.

Added:
   trunk/src/context.c
   trunk/src/context.h
Removed:
   trunk/src/comment.c
   trunk/src/comment.h
Modified:
   trunk/ChangeLog
   trunk/plugins/source-code-view/source-code-view-plugin.c
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/dialogs/comment-dialog.c
   trunk/src/tab.c
   trunk/src/tab.h

Modified: trunk/plugins/source-code-view/source-code-view-plugin.c
==============================================================================
--- trunk/plugins/source-code-view/source-code-view-plugin.c	(original)
+++ trunk/plugins/source-code-view/source-code-view-plugin.c	Mon Sep 22 09:40:58 2008
@@ -21,7 +21,7 @@
 #endif
 
 #include "source-code-view-plugin.h"
-#include "comment.h"
+#include "context.h"
 #include "utils.h"
 #include "viewer.h"
 #include "window.h"
@@ -366,10 +366,10 @@
 	GtkTextIter iter;
 	GtkTextBuffer *buffer;
 	GtkTextView *view;
-	GtranslatorCommentPanel *panel;
+	GtranslatorContextPanel *panel;
 
-	panel = gtranslator_tab_get_comment_panel (tab);
-	view = gtranslator_comment_panel_get_extracted_text_view (panel);
+	panel = gtranslator_tab_get_context_panel (tab);
+	view = gtranslator_context_panel_get_extracted_text_view (panel);
 	
 	buffer = gtk_text_view_get_buffer (view);
 	
@@ -398,11 +398,11 @@
 	GtkTextIter iter;
 	GtkTextBuffer *buffer;
 	gint i = 0;
-	GtranslatorCommentPanel *panel;
+	GtranslatorContextPanel *panel;
 	GtkTextView *view;
 
-	panel = gtranslator_tab_get_comment_panel (tab);
-	view = gtranslator_comment_panel_get_extracted_text_view (panel);
+	panel = gtranslator_tab_get_context_panel (tab);
+	view = gtranslator_context_panel_get_context_text_view (panel);
 
 	buffer = gtk_text_view_get_buffer (view);
 	
@@ -436,11 +436,11 @@
 	       guint page_num,
 	       GtranslatorSourceCodeViewPlugin *plugin)
 {	
-	GtranslatorCommentPanel *panel;
+	GtranslatorContextPanel *panel;
 	GtkTextView *view;
 
-	panel = gtranslator_tab_get_comment_panel (GTR_TAB (child));
-	view = gtranslator_comment_panel_get_extracted_text_view (panel);
+	panel = gtranslator_tab_get_context_panel (GTR_TAB (child));
+	view = gtranslator_context_panel_get_context_text_view (panel);
 
 	g_signal_connect_after (child, "showed-message",
 				G_CALLBACK (showed_message_cb), plugin);
@@ -565,7 +565,7 @@
 {
 	GList *tabs, *l;
 	GtkTextView *view;
-	GtranslatorCommentPanel *panel;
+	GtranslatorContextPanel *panel;
 	GtkWidget *notebook;
 	
 	tabs = gtranslator_window_get_all_tabs (window);
@@ -573,8 +573,8 @@
 	
 	for (l = tabs; l != NULL; l = g_list_next (l))
 	{
-		panel = gtranslator_tab_get_comment_panel (GTR_TAB (l->data));
-		view = gtranslator_comment_panel_get_extracted_text_view (panel);
+		panel = gtranslator_tab_get_context_panel (GTR_TAB (l->data));
+		view = gtranslator_context_panel_get_extracted_text_view (panel);
 		
 		g_signal_handlers_disconnect_by_func (l->data,
 						      showed_message_cb,

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Sep 22 09:40:58 2008
@@ -53,7 +53,7 @@
 
 INST_H_FILES =				\
 	application.h \
-	comment.h \
+	context.h \
 	header.h \
 	io-error-message-area.h \
 	message-area.h \
@@ -106,7 +106,7 @@
 	actions-search.c \
 	header.c \
 	statusbar.c \
-	comment.c \
+	context.c \
 	$(INST_H_FILES) 
 
 libgtranslator_la_LIBADD = \

Added: trunk/src/context.c
==============================================================================
--- (empty file)
+++ trunk/src/context.c	Mon Sep 22 09:40:58 2008
@@ -0,0 +1,169 @@
+/*
+ * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
+ * 
+ *     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
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ * 
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "context.h"
+#include "tab.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+#define GTR_CONTEXT_PANEL_GET_PRIVATE(object)	(G_TYPE_INSTANCE_GET_PRIVATE ( \
+						 (object),		       \
+						 GTR_TYPE_CONTEXT_PANEL,     \
+						 GtranslatorContextPanelPrivate))
+
+G_DEFINE_TYPE(GtranslatorContextPanel, gtranslator_context_panel, GTK_TYPE_VBOX)
+
+
+struct _GtranslatorContextPanelPrivate
+{
+	GtkWidget *context;
+
+	GtranslatorTab *tab;
+};
+
+static void
+showed_message_cb (GtranslatorTab *tab,
+		   GtranslatorMsg *msg,
+		   GtranslatorContextPanel *panel)
+{
+	GtkTextBuffer *buffer;
+	GtkTextIter iter;
+	gchar *extracted;
+	gchar *context;
+	gchar *format;
+    	gchar *toset;
+
+	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (panel->priv->context));
+	gtk_text_buffer_set_text (buffer, "", 0);
+	gtk_text_buffer_get_iter_at_offset (buffer, &iter, 0);
+
+	format = g_strconcat (_("Format: "), gtranslator_msg_get_format (msg), NULL);
+    	context = g_strconcat (_("Context:"), gtranslator_msg_get_msgctxt (msg), NULL);
+    	extracted = g_strconcat (_("Extracted comments:"),
+				 gtranslator_msg_get_extracted_comments(msg), NULL);
+    
+   	toset = g_strdup_printf("%s\n%s\n%s", format, context, extracted);
+    
+    	g_free (format);
+    	g_free (context);
+    	g_free (extracted);
+
+	gtk_text_buffer_insert (buffer, &iter, toset, -1);
+    
+    	g_free (toset);
+}
+
+static void
+gtranslator_context_panel_draw (GtranslatorContextPanel *panel)
+{
+	GtranslatorContextPanelPrivate *priv = panel->priv;
+	GtkWidget *context_scrolled_window;
+	
+	/*
+	 * 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),
+				        GTK_POLICY_AUTOMATIC,
+				        GTK_POLICY_AUTOMATIC);
+	gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (context_scrolled_window),
+					     GTK_SHADOW_IN);
+	gtk_box_pack_start (GTK_BOX (panel), context_scrolled_window, TRUE, TRUE, 0);
+	gtk_widget_show (context_scrolled_window);
+
+	/*
+	 * Context
+	 */	
+	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_WIDGET (priv->context));
+	gtk_widget_show (priv->context);
+}
+
+
+static void
+gtranslator_context_panel_init (GtranslatorContextPanel *panel)
+{
+	panel->priv = GTR_CONTEXT_PANEL_GET_PRIVATE (panel);
+	
+	gtranslator_context_panel_draw (panel);
+}
+
+static void
+gtranslator_context_panel_finalize (GObject *object)
+{
+	G_OBJECT_CLASS (gtranslator_context_panel_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_context_panel_class_init (GtranslatorContextPanelClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	g_type_class_add_private (klass, sizeof (GtranslatorContextPanelPrivate));
+
+	object_class->finalize = gtranslator_context_panel_finalize;
+}
+
+/**
+ * gtranslator_context_panel_new:
+ * @tab: a #GtranslatorTab
+ * 
+ * Creates a new #GtranslatorContextPanel object.
+ * 
+ * Returns: a new #GtranslatorContextPanel object
+ */
+GtkWidget *
+gtranslator_context_panel_new (GtkWidget *tab)
+{
+	GtranslatorContextPanel *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);
+}
+
+/**
+ * gtranslator_context_panel_get_extracted_text_view:
+ * @panel: a #GtranslatorContextPanel
+ *
+ * Returns: the context #GtkTextView
+ */
+GtkTextView *
+gtranslator_context_panel_get_context_text_view (GtranslatorContextPanel *panel)
+{
+	g_return_if_fail (GTR_IS_CONTEXT_PANEL (panel));
+	
+	return GTK_TEXT_VIEW (panel->priv->context);
+}
+							    

Added: trunk/src/context.h
==============================================================================
--- (empty file)
+++ trunk/src/context.h	Mon Sep 22 09:40:58 2008
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2007  Ignacio Casal Quinteiro <nacho resa gmail com>
+ * 
+ *     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
+ *     the Free Software Foundation, either version 3 of the License, or
+ *     (at your option) any later version.
+ * 
+ *     This program is distributed in the hope that it will be useful,
+ *     but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *     GNU General Public License for more details.
+ * 
+ *     You should have received a copy of the GNU General Public License
+ *     along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __CONTEXT_PANEL_H__
+#define __CONTEXT_PANEL_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_CONTEXT_PANEL		(gtranslator_context_panel_get_type ())
+#define GTR_CONTEXT_PANEL(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_CONTEXT_PANEL, GtranslatorContextPanel))
+#define GTR_CONTEXT_PANEL_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_CONTEXT_PANEL, GtranslatorContextPanelClass))
+#define GTR_IS_CONTEXT_PANEL(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_CONTEXT_PANEL))
+#define GTR_IS_CONTEXT_PANEL_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_CONTEXT_PANEL))
+#define GTR_CONTEXT_PANEL_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_CONTEXT_PANEL, GtranslatorContextPanelClass))
+
+/* Private structure type */
+typedef struct _GtranslatorContextPanelPrivate	GtranslatorContextPanelPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorContextPanel		GtranslatorContextPanel;
+
+struct _GtranslatorContextPanel
+{
+	GtkVBox parent_instance;
+	
+	/*< private > */
+	GtranslatorContextPanelPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorContextPanelClass	GtranslatorContextPanelClass;
+
+struct _GtranslatorContextPanelClass
+{
+	GtkVBoxClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType		 gtranslator_context_panel_get_type	   (void) G_GNUC_CONST;
+
+GType		 gtranslator_context_panel_register_type   (GTypeModule * module);
+
+GtkWidget	*gtranslator_context_panel_new	           (GtkWidget *tab);
+							    
+GtkTextView     *gtranslator_context_panel_get_context_text_view (GtranslatorContextPanel *panel);
+
+G_END_DECLS
+
+#endif /* __CONTEXT_PANEL_H__ */

Modified: trunk/src/dialogs/comment-dialog.c
==============================================================================
--- trunk/src/dialogs/comment-dialog.c	(original)
+++ trunk/src/dialogs/comment-dialog.c	Mon Sep 22 09:40:58 2008
@@ -21,7 +21,6 @@
 #endif
 
 #include "comment-dialog.h"
-#include "comment.h"
 #include "tab.h"
 #include "utils.h"
 #include "window.h"
@@ -45,7 +44,7 @@
 	GtkWidget *main_box;
 	GtkWidget *comment;
 };
-
+		    
 static void
 comment_changed_cb (GtkTextBuffer *buffer,
 		    GtranslatorWindow *window)
@@ -53,23 +52,18 @@
 	gchar *text;
 	GtkTextIter start, end;
 	GtranslatorTab *tab;
-	GtranslatorCommentPanel *comment;
 	GtranslatorPo *po;
 	GList *msg;
 	
 	tab = gtranslator_window_get_active_tab(window);
 	po = gtranslator_tab_get_po(tab);
-	comment = gtranslator_tab_get_comment_panel(tab);
 	msg = gtranslator_po_get_current_message(po);
 	
 	gtk_text_buffer_get_bounds(buffer, &start, &end);
 	text = gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
 	
 	gtranslator_msg_set_comment(msg->data, text);
-
-	gtranslator_comment_panel_set_comments(comment, text);
 }
-		    
 
 static void
 dialog_response_handler (GtkDialog *dlg, 
@@ -173,11 +167,12 @@
 				  "destroy",
 				  G_CALLBACK (gtk_widget_destroyed),
 				  &dlg);
-		g_signal_connect(buf,
-				 "changed",
-				 G_CALLBACK (comment_changed_cb),
-				 window);
-		gtk_widget_show_all(GTK_WIDGET(dlg));
+		g_signal_connect (buf,
+				  "changed",
+				  G_CALLBACK (comment_changed_cb),
+				  window);
+
+		gtk_widget_show (GTK_WIDGET(dlg));
 	}
 	
 	gtk_text_buffer_set_text(buf, gtranslator_msg_get_comment(msg->data), -1); 

Modified: trunk/src/tab.c
==============================================================================
--- trunk/src/tab.c	(original)
+++ trunk/src/tab.c	Mon Sep 22 09:40:58 2008
@@ -24,7 +24,7 @@
 #include <config.h>
 #endif
 
-#include "comment.h"
+#include "context.h"
 #include "io-error-message-area.h"
 #include "message-area.h"
 #include "message-table.h"
@@ -62,7 +62,7 @@
 	GtkWidget *lateral_panel; //TM, Comments, etc.
 
 	GtkWidget *comment_pane;
-	GtkWidget *comment;
+	GtkWidget *context;
         GtkWidget *translation_memory;
 	
 	/*Message area*/
@@ -556,12 +556,12 @@
 			TRUE, TRUE);
 	
 	/*
-	 * Comment
+	 * Context
 	 */
-	priv->comment = gtranslator_comment_panel_new (GTK_WIDGET (tab));
-	gtk_widget_show (priv->comment);
-	gtranslator_tab_add_widget_to_lateral_panel (tab, priv->comment,
-						     _("Comments"));
+	priv->context = gtranslator_context_panel_new (GTK_WIDGET (tab));
+	gtk_widget_show (priv->context);
+	gtranslator_tab_add_widget_to_lateral_panel (tab, priv->context,
+						     _("Context"));
 
 	/*
 	 * TM
@@ -856,15 +856,15 @@
 }
 
 /**
- * gtranslator_tab_get_comment_panel:
+ * gtranslator_tab_get_context_panel:
  * @tab: a #GtranslatorTab
  *
- * Return value: the #GtranslaorCommentPanel
+ * Return value: the #GtranslaorContextPanel
  */
-GtranslatorCommentPanel *
-gtranslator_tab_get_comment_panel(GtranslatorTab *tab)
+GtranslatorContextPanel *
+gtranslator_tab_get_context_panel(GtranslatorTab *tab)
 {
-	return GTR_COMMENT_PANEL(tab->priv->comment);
+	return GTR_CONTEXT_PANEL(tab->priv->context);
 }
 
 /**

Modified: trunk/src/tab.h
==============================================================================
--- trunk/src/tab.h	(original)
+++ trunk/src/tab.h	Mon Sep 22 09:40:58 2008
@@ -23,7 +23,7 @@
 #include <glib-object.h>
 #include <gtk/gtk.h>
 
-#include "comment.h"
+#include "context.h"
 #include "msg.h"
 #include "po.h"
 #include "view.h"
@@ -90,7 +90,7 @@
 
 gint                   gtranslator_tab_get_active_trans_tab(GtranslatorTab *tab);
 
-GtranslatorCommentPanel *gtranslator_tab_get_comment_panel   (GtranslatorTab *tab);
+GtranslatorContextPanel *gtranslator_tab_get_context_panel (GtranslatorTab *tab);
 
 GtranslatorView       *gtranslator_tab_get_active_view     (GtranslatorTab *tab);
 



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