gtranslator r3750 - in trunk/src: . dialogs



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

Log:
2008-09-02  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* dialogs/jump-dialog.c (dialog_response_handler),
	(gtranslator_jump_dialog_init),
(gtranslator_jump_dialog_finalize),
	(gtranslator_jump_dialog_class_init),
	(gtranslator_show_jump_dialog):
	* dialogs/jump-dialog.glade:
	* dialogs/jump-dialog.h:
	Forgot to add the files in the previous commit.

Added:
   trunk/src/dialogs/jump-dialog.c
   trunk/src/dialogs/jump-dialog.glade
   trunk/src/dialogs/jump-dialog.h
Modified:
   trunk/src/ChangeLog

Added: trunk/src/dialogs/jump-dialog.c
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/jump-dialog.c	Mon Sep 22 09:46:39 2008
@@ -0,0 +1,189 @@
+/*
+ * Copyright (C) 2008  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 "jump-dialog.h"
+#include "tab.h"
+#include "utils.h"
+#include "window.h"
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+
+#define GTR_JUMP_DIALOG_GET_PRIVATE(object)	(G_TYPE_INSTANCE_GET_PRIVATE ( \
+						 	(object),	\
+						 	GTR_TYPE_JUMP_DIALOG,     \
+						 	GtranslatorJumpDialogPrivate))
+
+
+G_DEFINE_TYPE(GtranslatorJumpDialog, gtranslator_jump_dialog, GTK_TYPE_DIALOG)
+
+struct _GtranslatorJumpDialogPrivate
+{
+	GtkWidget *main_box;
+	GtkWidget *jump;
+	
+	GtranslatorWindow *window;
+};
+
+static void
+dialog_response_handler (GtkDialog *dlg, 
+			 gint       res_id)
+{
+	GtranslatorJumpDialog *dialog = GTR_JUMP_DIALOG (dlg);
+	GtranslatorTab *tab;
+	gint number;
+
+	switch (res_id)
+	{
+		case GTK_RESPONSE_OK:
+			number = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (dialog->priv->jump));
+			tab = gtranslator_window_get_active_tab (dialog->priv->window);
+			gtranslator_tab_go_to_number (tab, number - 1);
+			gtk_widget_destroy (GTK_WIDGET (dlg));
+			break;
+	
+		default:
+			gtk_widget_destroy (GTK_WIDGET (dlg));
+	}
+}
+
+static void
+gtranslator_jump_dialog_init (GtranslatorJumpDialog *dlg)
+{
+	gboolean ret;
+	GtkWidget *error_widget;
+	
+	dlg->priv = GTR_JUMP_DIALOG_GET_PRIVATE (dlg);
+	
+	gtk_dialog_add_buttons (GTK_DIALOG (dlg),
+				GTK_STOCK_OK,
+				GTK_RESPONSE_OK,
+				GTK_STOCK_CANCEL,
+				GTK_RESPONSE_CANCEL,
+				NULL);
+	
+	gtk_window_set_title (GTK_WINDOW (dlg), _("Jump To"));
+	gtk_window_set_default_size(GTK_WINDOW(dlg), 300, 100);
+	gtk_window_set_resizable (GTK_WINDOW (dlg), TRUE);
+	gtk_dialog_set_has_separator (GTK_DIALOG (dlg), FALSE);
+	gtk_window_set_destroy_with_parent (GTK_WINDOW (dlg), TRUE);
+	
+	/* HIG defaults */
+	gtk_container_set_border_width (GTK_CONTAINER (dlg), 5);
+	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->vbox), 2); /* 2 * 5 + 2 = 12 */
+	gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (dlg)->action_area), 5);
+	gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dlg)->action_area), 4);
+	
+	gtk_dialog_set_default_response (GTK_DIALOG (dlg), GTK_RESPONSE_OK);
+	
+	g_signal_connect (dlg,
+			  "response",
+			  G_CALLBACK (dialog_response_handler),
+			  NULL);
+	
+	/*Glade*/
+	ret = gtranslator_utils_get_glade_widgets(PKGDATADIR "/jump-dialog.glade",
+		"main_box",
+		&error_widget,
+		
+		"main_box", &dlg->priv->main_box,
+		"jump", &dlg->priv->jump,
+		
+		NULL);
+	
+	if(!ret)
+	{
+		gtk_widget_show(error_widget);
+		gtk_box_pack_start_defaults (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+					     error_widget);
+		
+		return;
+	}
+	
+	gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
+			    dlg->priv->main_box, TRUE, TRUE, 0);
+	
+	gtk_container_set_border_width (GTK_CONTAINER (dlg->priv->main_box), 5);
+	
+	
+}
+
+static void
+gtranslator_jump_dialog_finalize (GObject *object)
+{
+	G_OBJECT_CLASS (gtranslator_jump_dialog_parent_class)->finalize (object);
+}
+
+static void
+gtranslator_jump_dialog_class_init (GtranslatorJumpDialogClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	g_type_class_add_private (klass, sizeof (GtranslatorJumpDialogPrivate));
+
+	object_class->finalize = gtranslator_jump_dialog_finalize;
+}
+
+void
+gtranslator_show_jump_dialog (GtranslatorWindow *window)
+{
+	static GtranslatorJumpDialog *dlg = NULL;
+	
+	g_return_if_fail (GTR_IS_WINDOW (window));
+	
+	if(dlg == NULL)
+	{
+		GtranslatorTab *tab;
+		GtranslatorPo *po;
+		gint messages;
+		
+		dlg = g_object_new (GTR_TYPE_JUMP_DIALOG, NULL);
+
+		g_signal_connect (dlg,
+				  "destroy",
+				  G_CALLBACK (gtk_widget_destroyed),
+				  &dlg);
+		
+		dlg->priv->window = window;
+		
+		/* Set the maximum number of the spin button */
+		tab = gtranslator_window_get_active_tab (window);
+		po = gtranslator_tab_get_po (tab);
+		messages = gtranslator_po_get_messages_count (po);
+		gtk_spin_button_set_range (GTK_SPIN_BUTTON (dlg->priv->jump),
+					   1.0,
+					   (gdouble)messages);
+
+		gtk_widget_show (GTK_WIDGET(dlg));
+	}
+	
+	if (GTK_WINDOW (window) != gtk_window_get_transient_for (GTK_WINDOW (dlg)))
+	{
+		gtk_window_set_transient_for (GTK_WINDOW (dlg),
+					      GTK_WINDOW (window));
+	}
+
+	gtk_window_present (GTK_WINDOW (dlg));
+}

Added: trunk/src/dialogs/jump-dialog.glade
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/jump-dialog.glade	Mon Sep 22 09:46:39 2008
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
+<!--Generated with glade3 3.4.5 on Tue Sep  2 11:07:43 2008 -->
+<glade-interface>
+  <widget class="GtkDialog" id="dialog1">
+    <property name="border_width">5</property>
+    <property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
+    <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
+    <property name="has_separator">False</property>
+    <child internal-child="vbox">
+      <widget class="GtkVBox" id="dialog-vbox1">
+        <property name="visible">True</property>
+        <property name="spacing">2</property>
+        <child>
+          <widget class="GtkVBox" id="main_box">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
+            <child>
+              <widget class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">&lt;b&gt;Enter message number:&lt;/b&gt;</property>
+                <property name="use_markup">True</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+              </packing>
+            </child>
+            <child>
+              <widget class="GtkSpinButton" id="jump">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="activates_default">True</property>
+                <property name="adjustment">0 0 100 1 10 10</property>
+              </widget>
+              <packing>
+                <property name="expand">False</property>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child internal-child="action_area">
+          <widget class="GtkHButtonBox" id="dialog-action_area1">
+            <property name="visible">True</property>
+            <property name="layout_style">GTK_BUTTONBOX_END</property>
+            <child>
+              <widget class="GtkButton" id="button1">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-ok</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+            </child>
+            <child>
+              <widget class="GtkButton" id="button2">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">True</property>
+                <property name="label" translatable="yes">gtk-cancel</property>
+                <property name="use_stock">True</property>
+                <property name="response_id">0</property>
+              </widget>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+          </widget>
+          <packing>
+            <property name="expand">False</property>
+            <property name="pack_type">GTK_PACK_END</property>
+          </packing>
+        </child>
+      </widget>
+    </child>
+  </widget>
+</glade-interface>

Added: trunk/src/dialogs/jump-dialog.h
==============================================================================
--- (empty file)
+++ trunk/src/dialogs/jump-dialog.h	Mon Sep 22 09:46:39 2008
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2008  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 __JUMP_DIALOG_H__
+#define __JUMP_DIALOG_H__
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gtk/gtk.h>
+#include "window.h"
+
+G_BEGIN_DECLS
+
+/*
+ * Type checking and casting macros
+ */
+#define GTR_TYPE_JUMP_DIALOG		(gtranslator_jump_dialog_get_type ())
+#define GTR_JUMP_DIALOG(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), GTR_TYPE_JUMP_DIALOG, GtranslatorJumpDialog))
+#define GTR_JUMP_DIALOG_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), GTR_TYPE_JUMP_DIALOG, GtranslatorJumpDialogClass))
+#define GTR_IS_JUMP_DIALOG(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), GTR_TYPE_JUMP_DIALOG))
+#define GTR_IS_JUMP_DIALOG_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), GTR_TYPE_JUMP_DIALOG))
+#define GTR_JUMP_DIALOG_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), GTR_TYPE_JUMP_DIALOG, GtranslatorJumpDialogClass))
+
+/* Private structure type */
+typedef struct _GtranslatorJumpDialogPrivate	GtranslatorJumpDialogPrivate;
+
+/*
+ * Main object structure
+ */
+typedef struct _GtranslatorJumpDialog		GtranslatorJumpDialog;
+
+struct _GtranslatorJumpDialog
+{
+	GtkDialog parent_instance;
+	
+	/*< private > */
+	GtranslatorJumpDialogPrivate *priv;
+};
+
+/*
+ * Class definition
+ */
+typedef struct _GtranslatorJumpDialogClass	GtranslatorJumpDialogClass;
+
+struct _GtranslatorJumpDialogClass
+{
+	GtkDialogClass parent_class;
+};
+
+/*
+ * Public methods
+ */
+GType		 gtranslator_jump_dialog_get_type               (void) G_GNUC_CONST;
+
+GType		 gtranslator_jump_dialog_register_type          (GTypeModule * module);
+
+void	         gtranslator_show_jump_dialog                   (GtranslatorWindow *window);
+
+G_END_DECLS
+
+#endif /* __JUMP_DIALOG_H__ */



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