[gnome-terminal] window: Add some more functions to the MDI container
- From: Christian Persch <chpe src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-terminal] window: Add some more functions to the MDI container
- Date: Fri, 21 Jun 2013 13:22:08 +0000 (UTC)
commit 84b1046e0650b99bd62deb3fe267aa88a57bdea0
Author: Christian Persch <chpe gnome org>
Date: Fri Jun 21 14:33:12 2013 +0200
window: Add some more functions to the MDI container
src/terminal-mdi-container.c | 32 +++++++++++++++++++++++++++++++-
src/terminal-mdi-container.h | 8 ++++++++
src/terminal-notebook.c | 12 +++++++++++-
3 files changed, 50 insertions(+), 2 deletions(-)
---
diff --git a/src/terminal-mdi-container.c b/src/terminal-mdi-container.c
index edeb7b9..66d506e 100644
--- a/src/terminal-mdi-container.c
+++ b/src/terminal-mdi-container.c
@@ -166,7 +166,16 @@ terminal_mdi_container_get_active_screen_num (TerminalMdiContainer *container)
return TERMINAL_MDI_CONTAINER_GET_IFACE (container)->get_active_screen_num (container);
}
-void
+void
+terminal_mdi_container_set_active_screen_num (TerminalMdiContainer *container,
+ int position)
+{
+ g_return_if_fail (TERMINAL_IS_MDI_CONTAINER (container));
+
+ TERMINAL_MDI_CONTAINER_GET_IFACE (container)->set_active_screen_num (container, position);
+}
+
+void
terminal_mdi_container_reorder_screen (TerminalMdiContainer *container,
TerminalScreen *screen,
int new_position)
@@ -175,3 +184,24 @@ terminal_mdi_container_reorder_screen (TerminalMdiContainer *container,
return TERMINAL_MDI_CONTAINER_GET_IFACE (container)->reorder_screen (container, screen, new_position);
}
+
+void
+terminal_mdi_container_change_screen (TerminalMdiContainer *container,
+ int change)
+{
+ int active, n;
+
+ g_return_if_fail (TERMINAL_IS_MDI_CONTAINER (container));
+ g_return_if_fail (change == -1 || change == 1);
+
+ n = terminal_mdi_container_get_n_screens (container);
+ active = terminal_mdi_container_get_active_screen_num (container);
+
+ active += change;
+ if (active < 0)
+ active = n - 1;
+ else if (active >= n)
+ active = 0;
+
+ terminal_mdi_container_set_active_screen_num (container, active);
+}
diff --git a/src/terminal-mdi-container.h b/src/terminal-mdi-container.h
index 724f8e7..c64154c 100644
--- a/src/terminal-mdi-container.h
+++ b/src/terminal-mdi-container.h
@@ -47,6 +47,8 @@ struct _TerminalMdiContainerInterface {
GList * (* list_screen_containers) (TerminalMdiContainer *container);
int (* get_n_screens) (TerminalMdiContainer *container);
int (* get_active_screen_num) (TerminalMdiContainer *container);
+ void (* set_active_screen_num) (TerminalMdiContainer *container,
+ int position);
void (* reorder_screen) (TerminalMdiContainer *container,
TerminalScreen *screen,
int new_position);
@@ -77,6 +79,9 @@ TerminalScreen *terminal_mdi_container_get_active_screen (TerminalMdiContainer *
void terminal_mdi_container_set_active_screen (TerminalMdiContainer *container,
TerminalScreen *screen);
+void terminal_mdi_container_set_active_screen_num (TerminalMdiContainer *container,
+ int position);
+
GList *terminal_mdi_container_list_screens (TerminalMdiContainer *container);
GList *terminal_mdi_container_list_screen_containers (TerminalMdiContainer *container);
@@ -89,6 +94,9 @@ void terminal_mdi_container_reorder_screen (TerminalMdiContainer *container,
TerminalScreen *screen,
int new_position);
+void terminal_mdi_container_change_screen (TerminalMdiContainer *container,
+ int change);
+
G_END_DECLS
#endif /* TERMINAL_MDI_CONTAINER_H */
diff --git a/src/terminal-notebook.c b/src/terminal-notebook.c
index a63a2b7..5862949 100644
--- a/src/terminal-notebook.c
+++ b/src/terminal-notebook.c
@@ -178,6 +178,15 @@ terminal_notebook_get_active_screen_num (TerminalMdiContainer *container)
}
static void
+terminal_notebook_set_active_screen_num (TerminalMdiContainer *container,
+ int position)
+{
+ GtkNotebook *gtk_notebook = GTK_NOTEBOOK (container);
+
+ gtk_notebook_set_current_page (gtk_notebook, position);
+}
+
+static void
terminal_notebook_reorder_screen (TerminalMdiContainer *container,
TerminalScreen *screen,
int new_position)
@@ -193,7 +202,7 @@ terminal_notebook_reorder_screen (TerminalMdiContainer *container,
pos = gtk_notebook_page_num (notebook, child);
pos += new_position;
- gtk_notebook_reorder_child (notebook, child,
+ gtk_notebook_reorder_child (notebook, child,
pos < 0 ? n - 1 : pos < n ? pos : 0);
}
@@ -208,6 +217,7 @@ terminal_notebook_mdi_iface_init (TerminalMdiContainerInterface *iface)
iface->list_screen_containers = terminal_notebook_list_screen_containers;
iface->get_n_screens = terminal_notebook_get_n_screens;
iface->get_active_screen_num = terminal_notebook_get_active_screen_num;
+ iface->set_active_screen_num = terminal_notebook_set_active_screen_num;
iface->reorder_screen = terminal_notebook_reorder_screen;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]