gtranslator r3712 - trunk/src



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

Log:
2008-08-22  Ignacio Casal Quinteiro  <nacho resa gmail com>

	* notebook.c (gtranslator_notebook_add_page),
	(gtranslator_notebook_remove_page),
	(gtranslator_notebook_get_page):
	* notebook.h:
	* window.c (_gtranslator_window_close_tab):
	Now tabs are only shown if there are more than one file opened.

Modified:
   trunk/src/ChangeLog
   trunk/src/notebook.c
   trunk/src/notebook.h
   trunk/src/window.c

Modified: trunk/src/notebook.c
==============================================================================
--- trunk/src/notebook.c	(original)
+++ trunk/src/notebook.c	Mon Sep 22 09:44:21 2008
@@ -280,6 +280,38 @@
 	gtk_notebook_append_page (GTK_NOTEBOOK (notebook),
 				  GTK_WIDGET (tab), label);
 	priv->pages = g_list_append (priv->pages, tab);
+	
+	if (g_list_length (notebook->priv->pages) == 1)
+		gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
+	else
+		gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), TRUE);
+}
+
+/**
+ * gtranslator_notebook_remove_page:
+ * @notebook: a #GtranslatorNotebook
+ * @page_num: the index of a notebook page, starting from 0.
+ *
+ * Removes a page from the notebook given its index in the notebook.
+ */
+void
+gtranslator_notebook_remove_page (GtranslatorNotebook *notebook,
+				  gint page_num)
+{
+	GtkWidget *tab;
+	
+	g_return_if_fail (GTR_IS_NOTEBOOK (notebook));
+	
+	tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (notebook), page_num);
+	
+	if (page_num != -1)
+		gtk_notebook_remove_page (GTK_NOTEBOOK (notebook), page_num);
+	
+	notebook->priv->pages = g_list_remove (notebook->priv->pages,
+					       tab);
+	
+	if (g_list_length (notebook->priv->pages) == 1)
+		gtk_notebook_set_show_tabs (GTK_NOTEBOOK (notebook), FALSE);
 }
 
 /**
@@ -299,5 +331,3 @@
 	
 	return GTR_TAB(gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), num));
 }
-
-

Modified: trunk/src/notebook.h
==============================================================================
--- trunk/src/notebook.h	(original)
+++ trunk/src/notebook.h	Mon Sep 22 09:44:21 2008
@@ -79,6 +79,9 @@
 void             gtranslator_notebook_add_page             (GtranslatorNotebook *notebook,
 							    GtranslatorTab *pax);
 
+void             gtranslator_notebook_remove_page          (GtranslatorNotebook *notebook,
+							    gint i);
+
 GtranslatorTab  *gtranslator_notebook_get_page             (GtranslatorNotebook *notebook);
 
 G_END_DECLS

Modified: trunk/src/window.c
==============================================================================
--- trunk/src/window.c	(original)
+++ trunk/src/window.c	Mon Sep 22 09:44:21 2008
@@ -1879,7 +1879,7 @@
 	i = gtk_notebook_page_num (GTK_NOTEBOOK (window->priv->notebook),
 				   GTK_WIDGET (tab));
 	if (i != -1)
-		gtk_notebook_remove_page (GTK_NOTEBOOK (window->priv->notebook), i);
+		gtranslator_notebook_remove_page (GTR_NOTEBOOK (window->priv->notebook), i);
 	
 	set_sensitive_according_to_window (window);
 }



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