Patch: Don't close last tab

<[email protected]>
Newsgroups gmane.comp.web.galeon.devel
Message-ID <[email protected]>
hi all,

as i mentioned earlier i wrote a little patch for galeon.
It changes the behaviour of galeon (if you enable
/apps/galeon/UI/Tabs/tabbed_blank_last) as follows:
if you perform window_cmd_file_close ( i.e.: you chose file/close tab or
perform the mouse-gesture for close tab - but NOT clicking on the close button
of the last tab, if you enabled "always show tabs" ) and the current window
has a visible toolbar (i.e. it is not a popup), the window is not closed, but
will instead be redirected to about:blank.

i hope this patch makes it into CVS :)

best regards,
erwin
galeon_blank_last_tab.patch (application/octet-stream, 5.5 KB)
diff -Naurbw galeon-1.3.2/galeon.schemas.in galeon-1.3.2-patched/galeon.schemas.in
--- galeon-1.3.2/galeon.schemas.in	2003-02-14 20:10:57.000000000 +0100
+++ galeon-1.3.2-patched/galeon.schemas.in	2003-03-09 15:42:47.000000000 +0100
@@ -436,6 +436,17 @@
         </locale>
       </schema>
       <schema>
+        <key>/schemas/apps/galeon/UI/Tabs/tabbed_blank_last</key>
+        <applyto>/apps/galeon/UI/Tabs/tabbed_blank_last</applyto>
+        <owner>galeon</owner>
+        <type>bool</type>
+        <default>false</default>
+        <locale name="C">
+        <short>Don't close last Tab</short>
+        <long>Instead of closing the last Tab, go to about:blank.</long>
+        </locale>
+      </schema>
+      <schema>
         <key>/schemas/apps/galeon/UI/Tabs/tabbed_always_show</key>
         <applyto>/apps/galeon/UI/Tabs/tabbed_always_show</applyto>
         <owner>galeon</owner>
diff -Naurbw galeon-1.3.2/src/galeon-window.c galeon-1.3.2-patched/src/galeon-window.c
--- galeon-1.3.2/src/galeon-window.c	2003-02-06 17:24:38.000000000 +0100
+++ galeon-1.3.2-patched/src/galeon-window.c	2003-03-09 20:32:47.000000000 +0100
@@ -1041,6 +1041,12 @@
 	return get_tab_from_page_num (window->priv->notebook, page_num);
 }
 
+gboolean
+galeon_window_is_last_tab( GaleonWindow *window )
+{
+        return gul_notebook_is_last_tab( GUL_NOTEBOOK (window->priv->notebook) );
+}
+
 void 
 galeon_window_remove_tab (GaleonWindow *window, 
 		          GaleonTab *tab)
@@ -1050,6 +1056,27 @@
 	g_return_if_fail (IS_GALEON_WINDOW (window));
 	g_return_if_fail (IS_GALEON_TAB (tab));
 
+	gboolean blank_last_tab;
+	blank_last_tab = eel_gconf_get_boolean (CONF_TABS_TABBED_BLANK_LAST);
+
+	gboolean last_tab;
+        last_tab = galeon_window_is_last_tab( window );
+
+	//check if toolbar is visible
+	gboolean toolbar_visible;
+	Toolbar* toolbar = galeon_window_get_toolbar( window );
+	toolbar_visible = toolbar_get_visibility( toolbar );
+
+
+        if ( last_tab && blank_last_tab && toolbar_visible )
+        {
+                embed = galeon_window_get_active_embed (window);
+                g_return_if_fail (embed != NULL);
+
+                galeon_embed_load_url (embed, "about:blank");
+        }
+	else
+	{
 	window->priv->active_tab = NULL;
 	
 	embed  = GTK_WIDGET (galeon_tab_get_embed (tab));
@@ -1057,6 +1084,7 @@
 	gul_notebook_remove_page (GUL_NOTEBOOK (window->priv->notebook), 
 				  embed);
 }
+}
 
 void 
 galeon_window_move_tab (GaleonWindow *window, 
diff -Naurbw galeon-1.3.2/src/galeon-window.h galeon-1.3.2-patched/src/galeon-window.h
--- galeon-1.3.2/src/galeon-window.h	2003-02-06 13:47:03.000000000 +0100
+++ galeon-1.3.2-patched/src/galeon-window.h	2003-03-09 15:25:53.000000000 +0100
@@ -95,6 +95,7 @@
 EmbedChromeMask  galeon_window_get_chrome	  (GaleonWindow *window);
 
 /* Tabs */
+gboolean	galeon_window_is_last_tab	(GaleonWindow *window);
 
 void          	 galeon_window_add_tab      	  (GaleonWindow *window, 
 					     	   GaleonTab *tab,
diff -Naurbw galeon-1.3.2/src/toolbar.c galeon-1.3.2-patched/src/toolbar.c
--- galeon-1.3.2/src/toolbar.c	2003-01-01 22:48:27.000000000 +0100
+++ galeon-1.3.2-patched/src/toolbar.c	2003-03-09 20:32:57.000000000 +0100
@@ -556,6 +556,12 @@
 	return t;
 }
 
+gboolean toolbar_get_visibility( Toolbar *t )
+{
+	g_return_val_if_fail( t != NULL, FALSE );
+	return t->priv->visibility;
+}
+
 void
 toolbar_set_visibility (Toolbar *t, gboolean visibility)
 {
diff -Naurbw galeon-1.3.2/src/toolbar.h galeon-1.3.2-patched/src/toolbar.h
--- galeon-1.3.2/src/toolbar.h	2002-09-02 16:31:53.000000000 +0200
+++ galeon-1.3.2-patched/src/toolbar.h	2003-03-09 20:32:57.000000000 +0100
@@ -61,6 +61,8 @@
 
 void          toolbar_set_visibility  		(Toolbar *t, 
 				       		 gboolean visibility);
+gboolean	 toolbar_get_visibility		( Toolbar *t );
+
 
 void	      toolbar_button_set_sensitive	(Toolbar *t,
 						 ToolbarButtonID id,
diff -Naurbw galeon-1.3.2/utils/gul-notebook.c galeon-1.3.2-patched/utils/gul-notebook.c
--- galeon-1.3.2/utils/gul-notebook.c	2003-02-10 12:09:49.000000000 +0100
+++ galeon-1.3.2-patched/utils/gul-notebook.c	2003-03-09 15:26:50.000000000 +0100
@@ -318,6 +318,16 @@
 	tab_label_set_size (window, hbox);
 }
 
+gboolean
+gul_notebook_is_last_tab( GulNotebook *nb )
+{
+        gboolean last_tab;
+
+        last_tab = gtk_notebook_get_nth_page (GTK_NOTEBOOK (nb), 1) == NULL;
+        return last_tab;
+}
+
+
 
 void
 gul_notebook_move_page (GulNotebook *src, GulNotebook *dest, 
diff -Naurbw galeon-1.3.2/utils/gul-notebook.h galeon-1.3.2-patched/utils/gul-notebook.h
--- galeon-1.3.2/utils/gul-notebook.h	2003-02-06 17:24:38.000000000 +0100
+++ galeon-1.3.2-patched/utils/gul-notebook.h	2003-03-09 15:27:04.000000000 +0100
@@ -66,6 +66,7 @@
 
 GtkWidget      *gul_notebook_new 		(void);
 
+gboolean	gul_notebook_is_last_tab	(GulNotebook *nb);
 void		gul_notebook_insert_page	(GulNotebook *nb,
 						 GtkWidget *child,
 						 int position,
diff -Naurbw galeon-1.3.2/utils/prefs-strings.h galeon-1.3.2-patched/utils/prefs-strings.h
--- galeon-1.3.2/utils/prefs-strings.h	2002-11-06 22:22:19.000000000 +0100
+++ galeon-1.3.2-patched/utils/prefs-strings.h	2003-03-09 15:43:46.000000000 +0100
@@ -32,6 +32,7 @@
 #define CONF_TABS_TABBED_LOADING_COLOR "/apps/galeon/UI/Tabs/tabbed_loading_color"
 #define CONF_TABS_TABBED_NEW_COLOR "/apps/galeon/UI/Tabs/tabbed_new_color"
 #define CONF_TABS_TABBED_ALWAYS_SHOW "/apps/galeon/UI/Tabs/tabbed_always_show"
+#define CONF_TABS_TABBED_BLANK_LAST "/apps/galeon/UI/Tabs/tabbed_blank_last"
 
 /* Window appeareance */
 #define CONF_WINDOWS_SIDEBAR_PAGE "/apps/galeon/UI/Windows/sidebar_page"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.