[PATCH] Next/previous tab wraparound
Juho Snellman <[email protected]>
| Newsgroups | gmane.comp.web.galeon.devel |
|---|---|
| Message-ID | <[email protected]> |
The attached patch makes the next/previous tab commands wraparound. I.e. if you're already at the last tab and try to move to the next one, it goes back to the first tab. This was the behaviour in galeon1. The patch also fixes a small memory leak that happened when using the mentioned commands under some circumstances. -- Juho Snellman
galeon-wraparound-tabs-2003-03-31.patch
(text/plain, 1.9 KB)
Index: window-commands.c
===================================================================
RCS file: /cvsroot/galeon/galeon/src/window-commands.c,v
retrieving revision 1.75
diff -u -r1.75 window-commands.c
--- window-commands.c 16 Mar 2003 17:52:57 -0000 1.75
+++ window-commands.c 31 Mar 2003 10:42:39 -0000
@@ -905,22 +905,24 @@
GaleonWindow *window,
const char* verbname)
{
- GList *tabs;
+ GList *tabs, *origtabs;
GaleonTab *tab;
tab = galeon_window_get_active_tab (window);
- tabs = galeon_window_get_tabs (window);
+ origtabs = tabs = galeon_window_get_tabs (window);
g_return_if_fail (tab != NULL);
tabs = g_list_find (tabs, (gpointer)tab);
tabs = tabs->next;
- if (tabs)
- {
- tab = GALEON_TAB (tabs->data);
- galeon_window_jump_to_tab (window, tab);
- g_list_free (tabs);
- }
+ /* Already at the rightmost tab -> wrap around to the left */
+ if (tabs == NULL) {
+ tabs = origtabs;
+ }
+
+ tab = GALEON_TAB (tabs->data);
+ galeon_window_jump_to_tab (window, tab);
+ g_list_free (origtabs);
}
void
@@ -928,22 +930,24 @@
GaleonWindow *window,
const char* verbname)
{
- GList *tabs;
+ GList *tabs, *origtabs;
GaleonTab *tab;
tab = galeon_window_get_active_tab (window);
- tabs = galeon_window_get_tabs (window);
+ origtabs = tabs = galeon_window_get_tabs (window);
g_return_if_fail (tab != NULL);
tabs = g_list_find (tabs, (gpointer)tab);
tabs = tabs->prev;
- if (tabs)
- {
- tab = GALEON_TAB (tabs->data);
- galeon_window_jump_to_tab (window, tab);
- g_list_free (tabs);
- }
+ /* Already at the leftmost tab -> wrap around to the right */
+ if (tabs == NULL) {
+ tabs = g_list_last (origtabs);
+ }
+
+ tab = GALEON_TAB (tabs->data);
+ galeon_window_jump_to_tab (window, tab);
+ g_list_free (origtabs);
}
void