gnome-terminal r2656 - trunk/src



Author: chpe
Date: Thu May 29 19:42:30 2008
New Revision: 2656
URL: http://svn.gnome.org/viewvc/gnome-terminal?rev=2656&view=rev

Log:
Port to the new profile API.


Modified:
   trunk/src/terminal-screen.c
   trunk/src/terminal-screen.h
   trunk/src/terminal-window.c

Modified: trunk/src/terminal-screen.c
==============================================================================
--- trunk/src/terminal-screen.c	(original)
+++ trunk/src/terminal-screen.c	Thu May 29 19:42:30 2008
@@ -2,8 +2,6 @@
  * Copyright  2001 Havoc Pennington
  * Copyright  2007, 2008 Christian Persch
  *
- * This file is part of gnome-terminal.
- *
  * Gnome-terminal is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
  * the Free Software Foundation; either version 2 of the License, or
@@ -19,8 +17,10 @@
  */
 
 #include <config.h>
+
 #include "terminal-intl.h"
 
+// FIXMEchpe remove this crap
 /* grab gtk_style_get_font and gdk_x11_get_font_name */
 #undef GTK_DISABLE_DEPRECATED
 #undef GDK_DISABLE_DEPRECATED
@@ -39,7 +39,7 @@
 #include "terminal-profile.h"
 #include "terminal-screen-container.h"
 #include "terminal-util.h"
-#include "terminal.h"
+#include "terminal-app.h"
 #include "skey-popup.h"
 #include <libgnome/gnome-util.h> /* gnome_util_user_shell */
 #include <libgnome/gnome-url.h> /* gnome_url_show */
@@ -618,19 +618,23 @@
   return screen->priv->icon_title_set;
 }
 
-void
-terminal_screen_reread_profile (TerminalScreen *screen)
+static void
+terminal_screen_profile_notify_cb (TerminalProfile *profile,
+                                   GParamSpec *pspec,
+                                   TerminalScreen *screen)
 {
   TerminalScreenPrivate *priv = screen->priv;
   VteTerminal *vte_terminal = VTE_TERMINAL (screen);
-  TerminalProfile *profile;
-  TerminalBackgroundType bg_type;
   TerminalWindow *window;
-  
-  profile = priv->profile;  
-  
-  if (profile == NULL)
-    return;
+  const char *prop_name;
+/*  VteTerminalEraseBinding backspace_binding, delete_binding;*/
+  TerminalBackgroundType bg_type;
+//   gboolean silent_bell, scroll_on_keystroke, scroll_on_output;
+
+  if (pspec)
+    prop_name = pspec->name;
+  else
+    prop_name = NULL;
 
   terminal_screen_cook_title (screen);
   terminal_screen_cook_icon_title (screen);
@@ -650,18 +654,21 @@
 
   update_color_scheme (screen);
 
-  vte_terminal_set_audible_bell (vte_terminal,
-                                 !terminal_profile_get_silent_bell (profile));
+/*  g_object_get (profile,
+                TERMINAL_PROFILE_SILENT_BELL, &silent_bell,*/
+  if (prop_name == I_(TERMINAL_PROFILE_SILENT_BELL))
+    vte_terminal_set_audible_bell (vte_terminal, !terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SILENT_BELL));
+
   vte_terminal_set_word_chars (vte_terminal,
-                               terminal_profile_get_word_chars (profile));
+                               terminal_profile_get_property_string (profile, TERMINAL_PROFILE_WORD_CHARS));
   vte_terminal_set_scroll_on_keystroke (vte_terminal,
-                                        terminal_profile_get_scroll_on_keystroke (profile));
+                                        terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE));
   vte_terminal_set_scroll_on_output (vte_terminal,
-                                     terminal_profile_get_scroll_on_output (profile));
+                                        terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SCROLL_ON_OUTPUT));
   vte_terminal_set_scrollback_lines (vte_terminal,
-                                     terminal_profile_get_scrollback_lines (profile));
+                                     terminal_profile_get_property_int (profile, TERMINAL_PROFILE_SCROLLBACK_LINES));
 
-  if (terminal_profile_get_use_skey (priv->profile))
+  if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_SKEY))
     {
       terminal_screen_skey_match_add (screen,
 				      "s/key [0-9]* [-A-Za-z0-9]*",
@@ -675,14 +682,14 @@
     {
       terminal_screen_skey_match_remove (screen);
     }
-  bg_type = terminal_profile_get_background_type (profile);
+  bg_type = terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKGROUND_TYPE);
   
   if (bg_type == TERMINAL_BACKGROUND_IMAGE)
     {
       set_background_image_file (vte_terminal,
-                                 terminal_profile_get_background_image_file (profile));
+                                 terminal_profile_get_property_string (profile, TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE));
       vte_terminal_set_scroll_background (vte_terminal,
-                                          terminal_profile_get_scroll_background (profile));
+                                          terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_SCROLL_BACKGROUND));
     }
   else
     {
@@ -694,10 +701,10 @@
       bg_type == TERMINAL_BACKGROUND_TRANSPARENT)
     {
       vte_terminal_set_background_saturation (vte_terminal,
-                                              1.0 - terminal_profile_get_background_darkness (profile));
+                                              1.0 - terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS));
       vte_terminal_set_opacity (vte_terminal,
-                                terminal_profile_get_background_darkness (profile) * 0xffff);
-    }      
+                                0xffff * terminal_profile_get_property_double (profile, TERMINAL_PROFILE_BACKGROUND_DARKNESS));
+    }
   else
     {
       vte_terminal_set_background_saturation (vte_terminal, 1.0); /* normal color */
@@ -711,10 +718,10 @@
                                            (!window || !terminal_window_uses_argb_visual (window)));
 
   vte_terminal_set_backspace_binding (vte_terminal,
-                                      terminal_profile_get_backspace_binding (profile));
+                                      terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_BACKSPACE_BINDING));
   
   vte_terminal_set_delete_binding (vte_terminal,
-                                   terminal_profile_get_delete_binding (profile));
+                                   terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_DELETE_BINDING));
 }
 
 /**
@@ -739,7 +746,7 @@
   g_return_val_if_fail (old_cooked_title != NULL, FALSE);
 
   if (priv->profile)
-    mode = terminal_profile_get_title_mode (priv->profile);
+    mode = terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_TITLE_MODE);
   else
     mode = TERMINAL_TITLE_REPLACE;
 
@@ -747,7 +754,7 @@
   if (priv->title_from_arg)
     static_title_piece = priv->title_from_arg;
   else
-    static_title_piece = terminal_profile_get_title (priv->profile);
+    static_title_piece = terminal_profile_get_property_string (priv->profile, TERMINAL_PROFILE_TITLE);
 
   switch (mode)
     {
@@ -812,41 +819,46 @@
 }
 
 static void
-profile_changed_callback (TerminalProfile           *profile,
-                          const TerminalSettingMask *mask,
-                          TerminalScreen            *screen)
-{
-  terminal_screen_reread_profile (screen);
-}
-
-static void
 update_color_scheme (TerminalScreen *screen)
 {
   TerminalScreenPrivate *priv = screen->priv;
-  GdkColor fg, bg;
-  GdkColor palette[TERMINAL_PALETTE_SIZE];
   GtkStyle *style;
+  GdkColor colors[TERMINAL_PALETTE_SIZE];
+  GdkColor *fg_color, *bg_color;
+  GdkColor fg, bg;
+  guint n_colors;
+  gboolean use_theme_colors;
 
   style = gtk_widget_get_style (GTK_WIDGET (screen));
   if (!style)
     return;
 
-  terminal_profile_get_palette (priv->profile,
-                                palette);
+  fg = style->text[GTK_STATE_NORMAL];
+  bg = style->base[GTK_STATE_NORMAL];
+
+  g_object_get (priv->profile,
+                TERMINAL_PROFILE_USE_THEME_COLORS, &use_theme_colors,
+                TERMINAL_PROFILE_FOREGROUND_COLOR, &fg_color,
+                TERMINAL_PROFILE_BACKGROUND_COLOR, &bg_color,
+                NULL);
 
-  if (terminal_profile_get_use_theme_colors (priv->profile))
+  if (fg_color)
     {
-      fg = style->text[GTK_STATE_NORMAL];
-      bg = style->base[GTK_STATE_NORMAL];
+      if (!use_theme_colors)
+        fg = *fg_color;
+      gdk_color_free (fg_color);
     }
-  else
+  if (bg_color)
     {
-      terminal_profile_get_color_scheme (priv->profile,
-                                         &fg, &bg);
+      if (!use_theme_colors)
+        bg = *bg_color;
+      gdk_color_free (bg_color);
     }
 
+  n_colors = G_N_ELEMENTS (colors);
+  terminal_profile_get_palette (priv->profile, colors, &n_colors);
   vte_terminal_set_colors (VTE_TERMINAL (screen), &fg, &bg,
-                           palette, TERMINAL_PALETTE_SIZE);
+                           colors, n_colors);
   vte_terminal_set_background_tint_color (VTE_TERMINAL (screen), &bg);
 }
 
@@ -899,16 +911,16 @@
   profile = priv->profile;
   
   /* FIXMEchpe make this use a get_font_desc on TerminalProfile */
-  if (terminal_profile_get_use_system_font (profile))
+  if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_SYSTEM_FONT))
     desc = get_system_monospace_font ();
   else
-    desc = pango_font_description_copy (terminal_profile_get_font (profile));
+    desc = pango_font_description_copy (terminal_profile_get_property_boxed (profile, TERMINAL_PROFILE_FONT));
 
   pango_font_description_set_size (desc,
 				   priv->font_scale *
 				   pango_font_description_get_size (desc));
 
-  no_aa_without_render = terminal_profile_get_no_aa_without_render (profile);
+  no_aa_without_render = terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_NO_AA_WITHOUT_RENDER);
   if (!no_aa_without_render)
     {
       vte_terminal_set_font (VTE_TERMINAL (screen), desc);
@@ -948,7 +960,7 @@
 
   /* FIXMEchpe: why do this on realize? */
   vte_terminal_set_allow_bold (vte_terminal,
-                               terminal_profile_get_allow_bold (profile));
+                               terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_ALLOW_BOLD));
   terminal_window_set_size (priv->window, screen, TRUE);
 }
 
@@ -1003,9 +1015,8 @@
     {
       g_object_ref (G_OBJECT (profile));
       priv->profile_changed_id =
-        g_signal_connect (G_OBJECT (profile),
-                          "changed",
-                          G_CALLBACK (profile_changed_callback),
+        g_signal_connect (profile, "notify",
+                          G_CALLBACK (terminal_screen_profile_notify_cb),
                           screen);
       priv->profile_forgotten_id =
         g_signal_connect (G_OBJECT (profile),
@@ -1023,10 +1034,11 @@
   
   priv->profile = profile;
 
-  terminal_screen_reread_profile (screen);
-
   if (priv->profile)
-    g_signal_emit (G_OBJECT (screen), signals[PROFILE_SET], 0, old_profile);
+    {
+      terminal_screen_profile_notify_cb (profile, NULL, screen);
+      g_signal_emit (G_OBJECT (screen), signals[PROFILE_SET], 0, old_profile);
+    }
 
   if (old_profile)
     g_object_unref (old_profile);
@@ -1095,9 +1107,9 @@
       file = g_strdup (priv->override_command[0]);
       argv = g_strdupv (priv->override_command);
     }
-  else if (terminal_profile_get_use_custom_command (profile))
+  else if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_USE_CUSTOM_COMMAND))
     {
-      if (!g_shell_parse_argv (terminal_profile_get_custom_command (profile),
+      if (!g_shell_parse_argv (terminal_profile_get_property_string (profile, TERMINAL_PROFILE_CUSTOM_COMMAND),
                                NULL, &argv,
                                err))
         return FALSE;
@@ -1121,7 +1133,7 @@
 
       argv = g_new (char*, 2);
 
-      if (terminal_profile_get_login_shell (profile))
+      if (terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_LOGIN_SHELL))
         argv[0] = g_strconcat ("-", only_name, NULL);
       else
         argv[0] = g_strdup (only_name);
@@ -1323,14 +1335,14 @@
   
   env = get_child_environment (screen);
 
-  update_records = terminal_profile_get_update_records (profile);
+  update_records = terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_UPDATE_RECORDS);
 
   priv->child_pid = vte_terminal_fork_command (VTE_TERMINAL (screen),
                                                path,
                                                argv,
                                                env,
                                                terminal_screen_get_working_dir (screen),
-                                               terminal_profile_get_login_shell (profile),
+                                               terminal_profile_get_property_boolean (profile, TERMINAL_PROFILE_LOGIN_SHELL),
                                                update_records,
                                                update_records);
 
@@ -1434,7 +1446,7 @@
 
   if (dingus_button &&
       (state & GDK_CONTROL_MASK) &&
-      terminal_profile_get_use_skey (priv->profile))
+      terminal_profile_get_property_boolean (priv->profile, TERMINAL_PROFILE_USE_SKEY))
     {
       gchar *skey_match;
 
@@ -1729,7 +1741,7 @@
   
   action = TERMINAL_EXIT_CLOSE;
   if (priv->profile)
-    action = terminal_profile_get_exit_action (priv->profile);
+    action = terminal_profile_get_property_enum (priv->profile, TERMINAL_PROFILE_EXIT_ACTION);
   
   switch (action)
     {
@@ -1919,7 +1931,6 @@
       {
         guint16 *data = (guint16 *)selection_data->data;
         GdkColor color;
-        GdkColor fg;
         TerminalProfile *profile;
 
         /* We accept drops with the wrong format, since the KDE color
@@ -1940,14 +1951,11 @@
 
         if (profile)
           {
-            terminal_profile_set_background_type (profile,
-                                                  TERMINAL_BACKGROUND_SOLID);
-            terminal_profile_set_use_theme_colors (profile, FALSE);
-            
-            terminal_profile_get_color_scheme (profile,
-                                               &fg, NULL);
-            
-            terminal_profile_set_color_scheme (profile, &fg, &color);
+            g_object_set (profile,
+                          TERMINAL_PROFILE_BACKGROUND_TYPE, TERMINAL_BACKGROUND_SOLID,
+                          TERMINAL_PROFILE_USE_THEME_COLORS, FALSE,
+                          TERMINAL_PROFILE_BACKGROUND_COLOR, &color,
+                          NULL);
           }
       }
       break;
@@ -2047,10 +2055,10 @@
             
             if (filename && profile)
               {
-                terminal_profile_set_background_type (profile,
-                                                      TERMINAL_BACKGROUND_IMAGE);
-                terminal_profile_set_background_image_file (profile,
-                                                            filename);
+                g_object_set (profile,
+                              TERMINAL_PROFILE_BACKGROUND_TYPE, TERMINAL_BACKGROUND_IMAGE,
+                              TERMINAL_PROFILE_BACKGROUND_IMAGE_FILE, filename,
+                              NULL);
               }
 
             g_free (filename);
@@ -2068,8 +2076,9 @@
         
         if (profile)
           {
-            terminal_profile_set_background_type (profile,
-                                                  TERMINAL_BACKGROUND_SOLID);
+                g_object_set (profile,
+                              TERMINAL_PROFILE_BACKGROUND_TYPE, TERMINAL_BACKGROUND_SOLID,
+                              NULL);
           }
       }
       break;
@@ -2125,7 +2134,7 @@
   if (!parent)
     return;
 
-  switch (terminal_profile_get_scrollbar_position (profile))
+  switch (terminal_profile_get_property_enum (profile, TERMINAL_PROFILE_SCROLLBAR_POSITION))
     {
     case TERMINAL_SCROLLBAR_HIDDEN:
       policy = GTK_POLICY_NEVER;

Modified: trunk/src/terminal-screen.h
==============================================================================
--- trunk/src/terminal-screen.h	(original)
+++ trunk/src/terminal-screen.h	Thu May 29 19:42:30 2008
@@ -78,8 +78,6 @@
                                   TerminalProfile *profile);
 TerminalProfile* terminal_screen_get_profile (TerminalScreen *screen);
 
-void terminal_screen_reread_profile (TerminalScreen *screen);
-
 void         terminal_screen_set_override_command (TerminalScreen  *screen,
                                                    char           **argv);
 const char** terminal_screen_get_override_command (TerminalScreen  *screen);
@@ -135,8 +133,6 @@
 #define TERMINAL_SCALE_MINIMUM     (TERMINAL_SCALE_XXXXX_SMALL/1.2)
 #define TERMINAL_SCALE_MAXIMUM     (TERMINAL_SCALE_XXXXX_LARGE*1.2)
 
-#include "terminal.h"
-
 struct _TerminalScreenPopupInfo {
   int ref_count;
   TerminalWindow *window;

Modified: trunk/src/terminal-window.c
==============================================================================
--- trunk/src/terminal-window.c	(original)
+++ trunk/src/terminal-window.c	Thu May 29 19:42:30 2008
@@ -29,7 +29,6 @@
 #include "terminal-screen-container.h"
 #include "terminal-tabs-menu.h"
 #include "terminal-util.h"
-#include "terminal.h"
 #include "encoding.h"
 #include <string.h>
 #include <stdlib.h>
@@ -274,7 +273,7 @@
   profile = g_object_get_data (G_OBJECT (action), PROFILE_DATA_KEY);
   g_assert (profile);
 
-  if (terminal_profile_get_forgotten (profile))
+  if (_terminal_profile_get_forgotten (profile))
     return;
 
   /* FIXMEchpe why block here? */
@@ -335,12 +334,15 @@
   for (p = profiles; p != NULL; p = p->next)
     {
       TerminalProfile *profile = (TerminalProfile *) p->data;
+      const char *visible_name;
       GtkRadioAction *profile_action;
       char name[32];
       char *display_name;
 
       g_snprintf (name, sizeof (name), "TerminalSetProfile%u", n++);
-      display_name = escape_underscores (terminal_profile_get_visible_name (profile));
+
+      visible_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_VISIBLE_NAME);
+      display_name = escape_underscores (visible_name);
       profile_action = gtk_radio_action_new (name,
                                              display_name,
                                              NULL,
@@ -388,9 +390,11 @@
 {
   TerminalWindowPrivate *priv = window->priv;
   GtkAction *action;
+  const char *visible_name;
   char *profile_name, *display_name;
 
-  profile_name = escape_underscores (terminal_profile_get_visible_name (profile));
+  visible_name = terminal_profile_get_property_string (profile, TERMINAL_PROFILE_VISIBLE_NAME);
+  profile_name = escape_underscores (visible_name);
   if (num < 10)
     {
       display_name = g_strdup_printf (_("_%d. %s"), num, profile_name);
@@ -1851,7 +1855,7 @@
   if (priv->use_default_menubar_visibility)
     {
       gboolean setting =
-        terminal_profile_get_default_show_menubar (terminal_screen_get_profile (screen));
+        terminal_profile_get_property_boolean (terminal_screen_get_profile (screen), TERMINAL_PROFILE_DEFAULT_SHOW_MENUBAR);
 
       terminal_window_set_menubar_visible (window, setting);
     }
@@ -2048,6 +2052,7 @@
 void
 terminal_window_update_icon (TerminalWindow *window)
 {
+#if 0
   TerminalWindowPrivate *priv = window->priv;
   TerminalProfile *profile;
 
@@ -2061,6 +2066,7 @@
 
   gtk_window_set_icon (GTK_WINDOW (window),
                        terminal_profile_get_icon (profile));
+#endif
 }
 
 void
@@ -2149,7 +2155,7 @@
   if (!profile)
     return;
 
-  if (terminal_profile_get_forgotten (profile))
+  if (_terminal_profile_get_forgotten (profile))
     return;
 
   new_window (window, NULL, profile);
@@ -2206,7 +2212,7 @@
   if (!profile)
     return;
 
-  if (terminal_profile_get_forgotten (profile))
+  if (_terminal_profile_get_forgotten (profile))
     return;
       
   dir = terminal_screen_get_working_dir (priv->active_term);
@@ -2584,7 +2590,7 @@
 
   g_assert (profile);
 
-  if (terminal_profile_get_forgotten (profile))
+  if (_terminal_profile_get_forgotten (profile))
     return;
       
   new_window (window, screen, profile);
@@ -2664,6 +2670,7 @@
   g_free (license_text);
 }
 
+#if 0
 static void
 default_profile_changed (TerminalProfile           *profile,
                          const TerminalSettingMask *mask,
@@ -2720,11 +2727,12 @@
 
   g_list_free (profiles);
 }
+#endif
 
 void
 terminal_window_reread_profile_list (TerminalWindow *window)
 {
-  monitor_profiles_for_is_default_change (window);
+//   monitor_profiles_for_is_default_change (window);
   
   terminal_window_update_set_profile_menu (window);
   terminal_window_update_new_terminal_menus (window);



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