[Xfce4-commits] r30182 - terminal/trunk/terminal

Nick Schermer nick at xfce.org
Fri Jul 3 11:15:56 CEST 2009


Author: nick
Date: 2009-07-03 09:15:56 +0000 (Fri, 03 Jul 2009)
New Revision: 30182

Modified:
   terminal/trunk/terminal/terminal-screen.c
Log:
Reduce code duplication.

Modified: terminal/trunk/terminal/terminal-screen.c
===================================================================
--- terminal/trunk/terminal/terminal-screen.c	2009-07-03 08:46:03 UTC (rev 30181)
+++ terminal/trunk/terminal/terminal-screen.c	2009-07-03 09:15:56 UTC (rev 30182)
@@ -565,66 +565,52 @@
 
 
 
-static void
-terminal_screen_update_binding_backspace (TerminalScreen *screen)
+static VteTerminalEraseBinding
+terminal_screen_binding_vte (TerminalEraseBinding binding)
 {
-  TerminalEraseBinding binding;
-
-  g_object_get (G_OBJECT (screen->preferences), "binding-backspace", &binding, NULL);
-
   switch (binding)
     {
     case TERMINAL_ERASE_BINDING_AUTO:
-      vte_terminal_set_backspace_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_AUTO);
-      break;
+      return VTE_ERASE_AUTO;
 
     case TERMINAL_ERASE_BINDING_ASCII_BACKSPACE:
-      vte_terminal_set_backspace_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_ASCII_BACKSPACE);
-      break;
+      return VTE_ERASE_ASCII_BACKSPACE;
 
     case TERMINAL_ERASE_BINDING_ASCII_DELETE:
-      vte_terminal_set_backspace_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_ASCII_DELETE);
-      break;
+      return VTE_ERASE_ASCII_DELETE;
 
     case TERMINAL_ERASE_BINDING_DELETE_SEQUENCE:
-      vte_terminal_set_backspace_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_DELETE_SEQUENCE);
-      break;
+      return VTE_ERASE_DELETE_SEQUENCE;
 
     default:
       terminal_assert_not_reached ();
     }
+
+  return VTE_ERASE_AUTO;
 }
 
 
 
 static void
-terminal_screen_update_binding_delete (TerminalScreen *screen)
+terminal_screen_update_binding_backspace (TerminalScreen *screen)
 {
   TerminalEraseBinding binding;
 
-  g_object_get (G_OBJECT (screen->preferences), "binding-delete", &binding, NULL);
+  g_object_get (G_OBJECT (screen->preferences), "binding-backspace", &binding, NULL);
+  vte_terminal_set_backspace_binding (VTE_TERMINAL (screen->terminal),
+      terminal_screen_binding_vte (binding));
+}
 
-  switch (binding)
-    {
-    case TERMINAL_ERASE_BINDING_AUTO:
-      vte_terminal_set_delete_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_AUTO);
-      break;
 
-    case TERMINAL_ERASE_BINDING_ASCII_BACKSPACE:
-      vte_terminal_set_delete_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_ASCII_BACKSPACE);
-      break;
 
-    case TERMINAL_ERASE_BINDING_ASCII_DELETE:
-      vte_terminal_set_delete_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_ASCII_DELETE);
-      break;
+static void
+terminal_screen_update_binding_delete (TerminalScreen *screen)
+{
+  TerminalEraseBinding binding;
 
-    case TERMINAL_ERASE_BINDING_DELETE_SEQUENCE:
-      vte_terminal_set_delete_binding (VTE_TERMINAL (screen->terminal), VTE_ERASE_DELETE_SEQUENCE);
-      break;
-
-    default:
-      terminal_assert_not_reached ();
-    }
+  g_object_get (G_OBJECT (screen->preferences), "binding-delete", &binding, NULL);
+  vte_terminal_set_delete_binding (VTE_TERMINAL (screen->terminal),
+      terminal_screen_binding_vte (binding));
 }
 
 




More information about the Xfce4-commits mailing list