gnome-terminal r2748 - trunk/src



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

Log:
Replace the kb spinbutton with a label showing the approx. memory use corresponding to the number of scrollback lines selected in the other spin button.


Modified:
   trunk/src/profile-editor.c
   trunk/src/profile-preferences.glade
   trunk/src/terminal-util.c
   trunk/src/terminal-util.h

Modified: trunk/src/profile-editor.c
==============================================================================
--- trunk/src/profile-editor.c	(original)
+++ trunk/src/profile-editor.c	Thu May 29 19:50:33 2008
@@ -26,14 +26,15 @@
 #include <gio/gio.h>
 
 #include "terminal-intl.h"
-
 #include "profile-editor.h"
 #include "terminal-util.h"
 
 #include <libgnomeui/gnome-icon-entry.h>
 #include <libgnomeui/gnome-thumbnail.h>
 
-// FIXMEchpe make the kb spinbutton a label instead since changing it really isn't right
+/* One slot in the ring buffer, plus the array which holds the data for
+  * the line, plus about 80 vte_charcell structures. */
+#define BYTES_PER_LINE (sizeof(gpointer) + sizeof(GArray) + (80 * (sizeof(gunichar) + 4)))
 
 typedef struct _TerminalColorScheme TerminalColorScheme;
 
@@ -231,8 +232,8 @@
     {
       scrollback_lines_locked = terminal_profile_property_locked (profile, TERMINAL_PROFILE_SCROLLBACK_LINES);
 
-      SET_SENSITIVE ("scrollback-lines-spinbutton", !scrollback_lines_locked);
-      SET_SENSITIVE ("scrollback-kilobytes-spinbutton", !scrollback_lines_locked);
+      SET_SENSITIVE ("scrollback-label", !scrollback_lines_locked);
+      SET_SENSITIVE ("scrollback-box", !scrollback_lines_locked);
     }
   
   if (!prop_name || prop_name == I_(TERMINAL_PROFILE_SCROLL_ON_KEYSTROKE))
@@ -463,6 +464,23 @@
 }
 
 static void
+scrollback_lines_spin_button_changed_cb (GtkSpinButton *button,
+                                         GParamSpec *pspec,
+                                         GtkLabel *label)
+{
+  double lines;
+  char *kbtext, *text;
+
+  lines = gtk_spin_button_get_value (button);
+  kbtext = g_format_size_for_display (lines * BYTES_PER_LINE);
+  /* Translators: %s will be a data size, e.g. "(about 500kB)" */
+  text = g_strdup_printf (_("(about %s)"), kbtext);
+  gtk_label_set_text (label, text);
+  g_free (kbtext);
+  g_free (text);
+}
+
+static void
 reset_compat_defaults_cb (GtkWidget       *button,
                           TerminalProfile *profile)
 {
@@ -654,8 +672,6 @@
   GtkBuilder *builder;
   GError *error = NULL;
   GtkWidget *editor, *w;
-  GtkSizeGroup *size_group;
-  double num1, num2;
   guint i;
 
   editor = g_object_get_data (G_OBJECT (profile), "editor-window");
@@ -768,21 +784,10 @@
   g_signal_connect (GTK_WIDGET (gtk_builder_get_object (builder, "profile-name-entry")),
                     "changed",
                     G_CALLBACK (visible_name_entry_changed_cb), editor);
-
-  size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-  w = (GtkWidget *) gtk_builder_get_object  (builder, "scrollback-lines-spinbutton");
-  gtk_size_group_add_widget (size_group, w);
-  gtk_spin_button_get_range (GTK_SPIN_BUTTON (w), &num1, &num2);
-
-  w = (GtkWidget *) gtk_builder_get_object  (builder, "scrollback-kilobytes-spinbutton");
-
-  /* Sync kilobytes spinbutton range with the lines spinbutton */
-  gtk_spin_button_set_range (GTK_SPIN_BUTTON (w),
-                             terminal_util_get_estimated_scrollback_buffer_size (num1),
-                             terminal_util_get_estimated_scrollback_buffer_size (num2));
-
-  gtk_size_group_add_widget (size_group, w);
-  g_object_unref (size_group);
+  g_signal_connect (GTK_WIDGET (gtk_builder_get_object  (builder, "scrollback-lines-spinbutton")),
+                    "notify::value",
+                    G_CALLBACK (scrollback_lines_spin_button_changed_cb),
+                    GTK_WIDGET (gtk_builder_get_object  (builder, "scrollback-kb-label")));
 
   g_signal_connect (gtk_builder_get_object  (builder, "reset-compat-defaults-button"),
                     "clicked",
@@ -820,7 +825,6 @@
   CONNECT ("use-theme-colors-checkbutton", TERMINAL_PROFILE_USE_THEME_COLORS);
   CONNECT ("word-chars-entry", TERMINAL_PROFILE_WORD_CHARS);
   CONNECT_WITH_FLAGS ("bell-checkbutton", TERMINAL_PROFILE_SILENT_BELL, FLAG_INVERT_BOOL);
-  CONNECT_WITH_FLAGS ("scrollback-kilobytes-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES, FLAG_SCROLLBACK);
   CONNECT_WITH_FLAGS ("scrollback-lines-spinbutton", TERMINAL_PROFILE_SCROLLBACK_LINES, 0);
 
 #undef CONNECT

Modified: trunk/src/profile-preferences.glade
==============================================================================
--- trunk/src/profile-preferences.glade	(original)
+++ trunk/src/profile-preferences.glade	Thu May 29 19:50:33 2008
@@ -127,6 +127,7 @@
 		      <property name="max_length">0</property>
 		      <property name="text" translatable="yes"></property>
 		      <property name="has_frame">True</property>
+		      <property name="invisible_char">*</property>
 		      <property name="activates_default">False</property>
 		    </widget>
 		    <packing>
@@ -331,6 +332,7 @@
 		      <property name="max_length">0</property>
 		      <property name="text" translatable="yes"></property>
 		      <property name="has_frame">True</property>
+		      <property name="invisible_char">*</property>
 		      <property name="activates_default">False</property>
 		    </widget>
 		    <packing>
@@ -473,6 +475,7 @@
 				  <property name="max_length">0</property>
 				  <property name="text" translatable="yes"></property>
 				  <property name="has_frame">True</property>
+				  <property name="invisible_char">*</property>
 				  <property name="activates_default">False</property>
 				</widget>
 				<packing>
@@ -726,6 +729,7 @@
 					  <property name="max_length">0</property>
 					  <property name="text" translatable="yes"></property>
 					  <property name="has_frame">True</property>
+					  <property name="invisible_char">*</property>
 					  <property name="activates_default">False</property>
 					</widget>
 					<packing>
@@ -1967,71 +1971,86 @@
 	      <property name="border_width">12</property>
 	      <property name="visible">True</property>
 	      <property name="n_rows">4</property>
-	      <property name="n_columns">3</property>
+	      <property name="n_columns">2</property>
 	      <property name="homogeneous">False</property>
 	      <property name="row_spacing">6</property>
 	      <property name="column_spacing">12</property>
 
 	      <child>
-		<widget class="GtkLabel" id="label466">
+		<widget class="GtkCheckButton" id="scroll-on-keystroke-checkbutton">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">Scr_ollback:</property>
+		  <property name="can_focus">True</property>
+		  <property name="label" translatable="yes">Scroll on _keystroke</property>
 		  <property name="use_underline">True</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_CENTER</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		  <property name="mnemonic_widget">scrollback-lines-spinbutton</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		  <property name="active">False</property>
+		  <property name="inconsistent">False</property>
+		  <property name="draw_indicator">True</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_options">fill</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">3</property>
+		  <property name="bottom_attach">4</property>
 		  <property name="y_options"></property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkLabel" id="scrollbar-position-combobox-label">
+		<widget class="GtkCheckButton" id="scroll-on-output-checkbutton">
 		  <property name="visible">True</property>
-		  <property name="label" translatable="yes">_Scrollbar is:</property>
+		  <property name="can_focus">True</property>
+		  <property name="label" translatable="yes">Sc_roll on output</property>
 		  <property name="use_underline">True</property>
-		  <property name="use_markup">False</property>
-		  <property name="justify">GTK_JUSTIFY_CENTER</property>
-		  <property name="wrap">False</property>
-		  <property name="selectable">False</property>
-		  <property name="xalign">0</property>
-		  <property name="yalign">0.5</property>
-		  <property name="xpad">0</property>
-		  <property name="ypad">0</property>
-		  <property name="mnemonic_widget">scrollbar-position-combobox</property>
-		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
-		  <property name="width_chars">-1</property>
-		  <property name="single_line_mode">False</property>
-		  <property name="angle">0</property>
+		  <property name="relief">GTK_RELIEF_NORMAL</property>
+		  <property name="focus_on_click">True</property>
+		  <property name="active">False</property>
+		  <property name="inconsistent">False</property>
+		  <property name="draw_indicator">True</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">1</property>
+		  <property name="right_attach">2</property>
+		  <property name="top_attach">2</property>
+		  <property name="bottom_attach">3</property>
+		  <property name="y_options"></property>
+		</packing>
+	      </child>
+
+	      <child>
+		<widget class="GtkHBox" id="hbox139">
+		  <property name="visible">True</property>
+		  <property name="homogeneous">False</property>
+		  <property name="spacing">0</property>
+
+		  <child>
+		    <widget class="GtkComboBox" id="scrollbar-position-combobox">
+		      <property name="visible">True</property>
+		      <property name="items" translatable="yes">On the left side
+On the right side
+Disabled</property>
+		      <property name="add_tearoffs">False</property>
+		      <property name="focus_on_click">True</property>
+		    </widget>
+		    <packing>
+		      <property name="padding">0</property>
+		      <property name="expand">False</property>
+		      <property name="fill">True</property>
+		    </packing>
+		  </child>
+		</widget>
+		<packing>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
 		  <property name="top_attach">0</property>
 		  <property name="bottom_attach">1</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
+		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkHBox" id="hbox22">
+		<widget class="GtkHBox" id="scrollback-box">
 		  <property name="visible">True</property>
 		  <property name="homogeneous">False</property>
 		  <property name="spacing">6</property>
@@ -2077,59 +2096,23 @@
 		    <packing>
 		      <property name="padding">0</property>
 		      <property name="expand">False</property>
-		      <property name="fill">True</property>
-		    </packing>
-		  </child>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">2</property>
-		  <property name="top_attach">1</property>
-		  <property name="bottom_attach">2</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options">fill</property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkHBox" id="hbox23">
-		  <property name="visible">True</property>
-		  <property name="homogeneous">False</property>
-		  <property name="spacing">6</property>
-
-		  <child>
-		    <widget class="GtkSpinButton" id="scrollback-kilobytes-spinbutton">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="climb_rate">1</property>
-		      <property name="digits">0</property>
-		      <property name="numeric">True</property>
-		      <property name="update_policy">GTK_UPDATE_ALWAYS</property>
-		      <property name="snap_to_ticks">False</property>
-		      <property name="wrap">False</property>
-		      <property name="adjustment">1 1 100000 1 5 0</property>
-		    </widget>
-		    <packing>
-		      <property name="padding">0</property>
-		      <property name="expand">False</property>
-		      <property name="fill">True</property>
+		      <property name="fill">False</property>
 		    </packing>
 		  </child>
 
 		  <child>
-		    <widget class="GtkLabel" id="label57">
+		    <widget class="GtkLabel" id="scrollback-kb-label">
 		      <property name="visible">True</property>
-		      <property name="label" translatable="yes">kilo_bytes</property>
-		      <property name="use_underline">True</property>
+		      <property name="label">(about 120kB)</property>
+		      <property name="use_underline">False</property>
 		      <property name="use_markup">False</property>
-		      <property name="justify">GTK_JUSTIFY_CENTER</property>
+		      <property name="justify">GTK_JUSTIFY_LEFT</property>
 		      <property name="wrap">False</property>
 		      <property name="selectable">False</property>
-		      <property name="xalign">0</property>
+		      <property name="xalign">0.5</property>
 		      <property name="yalign">0.5</property>
 		      <property name="xpad">0</property>
 		      <property name="ypad">0</property>
-		      <property name="mnemonic_widget">scrollback-kilobytes-spinbutton</property>
 		      <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
 		      <property name="width_chars">-1</property>
 		      <property name="single_line_mode">False</property>
@@ -2138,13 +2121,13 @@
 		    <packing>
 		      <property name="padding">0</property>
 		      <property name="expand">False</property>
-		      <property name="fill">True</property>
+		      <property name="fill">False</property>
 		    </packing>
 		  </child>
 		</widget>
 		<packing>
-		  <property name="left_attach">2</property>
-		  <property name="right_attach">3</property>
+		  <property name="left_attach">1</property>
+		  <property name="right_attach">2</property>
 		  <property name="top_attach">1</property>
 		  <property name="bottom_attach">2</property>
 		  <property name="x_options">fill</property>
@@ -2153,91 +2136,58 @@
 	      </child>
 
 	      <child>
-		<widget class="GtkAlignment" id="alignment14">
+		<widget class="GtkLabel" id="scrollbar-position-combobox-label">
 		  <property name="visible">True</property>
-		  <property name="xalign">1.49012002737e-08</property>
+		  <property name="label" translatable="yes">_Scrollbar is:</property>
+		  <property name="use_underline">True</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_CENTER</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
 		  <property name="yalign">0.5</property>
-		  <property name="xscale">0</property>
-		  <property name="yscale">1</property>
-		  <property name="top_padding">0</property>
-		  <property name="bottom_padding">0</property>
-		  <property name="left_padding">0</property>
-		  <property name="right_padding">0</property>
-
-		  <child>
-		    <widget class="GtkCheckButton" id="scroll-on-output-checkbutton">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">Sc_roll on output</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="focus_on_click">True</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		  </child>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="mnemonic_widget">scrollbar-position-combobox</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">3</property>
-		  <property name="top_attach">2</property>
-		  <property name="bottom_attach">3</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">0</property>
+		  <property name="bottom_attach">1</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>
 	      </child>
 
 	      <child>
-		<widget class="GtkAlignment" id="alignment13">
+		<widget class="GtkLabel" id="scrollback-label">
 		  <property name="visible">True</property>
-		  <property name="xalign">1.49012002737e-08</property>
+		  <property name="label" translatable="yes">Scr_ollback:</property>
+		  <property name="use_underline">True</property>
+		  <property name="use_markup">False</property>
+		  <property name="justify">GTK_JUSTIFY_CENTER</property>
+		  <property name="wrap">False</property>
+		  <property name="selectable">False</property>
+		  <property name="xalign">0</property>
 		  <property name="yalign">0.5</property>
-		  <property name="xscale">0</property>
-		  <property name="yscale">1</property>
-		  <property name="top_padding">0</property>
-		  <property name="bottom_padding">0</property>
-		  <property name="left_padding">0</property>
-		  <property name="right_padding">0</property>
-
-		  <child>
-		    <widget class="GtkCheckButton" id="scroll-on-keystroke-checkbutton">
-		      <property name="visible">True</property>
-		      <property name="can_focus">True</property>
-		      <property name="label" translatable="yes">Scroll on _keystroke</property>
-		      <property name="use_underline">True</property>
-		      <property name="relief">GTK_RELIEF_NORMAL</property>
-		      <property name="focus_on_click">True</property>
-		      <property name="active">False</property>
-		      <property name="inconsistent">False</property>
-		      <property name="draw_indicator">True</property>
-		    </widget>
-		  </child>
+		  <property name="xpad">0</property>
+		  <property name="ypad">0</property>
+		  <property name="mnemonic_widget">scrollback-lines-spinbutton</property>
+		  <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property>
+		  <property name="width_chars">-1</property>
+		  <property name="single_line_mode">False</property>
+		  <property name="angle">0</property>
 		</widget>
 		<packing>
 		  <property name="left_attach">0</property>
-		  <property name="right_attach">3</property>
-		  <property name="top_attach">3</property>
-		  <property name="bottom_attach">4</property>
-		  <property name="x_options">fill</property>
-		  <property name="y_options"></property>
-		</packing>
-	      </child>
-
-	      <child>
-		<widget class="GtkComboBox" id="scrollbar-position-combobox">
-		  <property name="visible">True</property>
-		  <property name="items" translatable="yes">On the left side
-On the right side
-Disabled</property>
-		  <property name="add_tearoffs">False</property>
-		  <property name="focus_on_click">True</property>
-		</widget>
-		<packing>
-		  <property name="left_attach">1</property>
-		  <property name="right_attach">3</property>
-		  <property name="top_attach">0</property>
-		  <property name="bottom_attach">1</property>
+		  <property name="right_attach">1</property>
+		  <property name="top_attach">1</property>
+		  <property name="bottom_attach">2</property>
 		  <property name="x_options">fill</property>
 		  <property name="y_options">fill</property>
 		</packing>

Modified: trunk/src/terminal-util.c
==============================================================================
--- trunk/src/terminal-util.c	(original)
+++ trunk/src/terminal-util.c	Thu May 29 19:50:33 2008
@@ -39,10 +39,6 @@
 #include <stdlib.h>
 #include <time.h>
 
-/* One slot in the ring buffer, plus the array which holds the data for
-  * the line, plus about 80 vte_charcell structures. */
-#define BYTES_PER_LINE (sizeof(gpointer) + sizeof(GArray) + (80 * (sizeof(gunichar) + 4)))
-
 void
 terminal_util_set_unique_role (GtkWindow *window, const char *prefix)
 {
@@ -280,12 +276,6 @@
   return object_name == NULL;
 }
 
-int
-terminal_util_get_estimated_scrollback_buffer_size (int lines)
-{
-  return (lines * BYTES_PER_LINE) / 1024;
-}
-
 /* Bidirectional object/widget binding */
 
 typedef struct {
@@ -314,22 +304,6 @@
 
   return input;
 }
-  
-static int
-transform_spinbutton_value (int input,
-                            PropertyChangeFlags flags,
-                            gboolean from)
-{
-  if ((flags & FLAG_SCROLLBACK) == 0)
-    return input;
-
-  if (from) /* value from spin button */
-    input = input * 1024 / BYTES_PER_LINE;
-  else /* value to set in the spin button */
-    input = input * BYTES_PER_LINE / 1024;
-
-  return input;
-}
 
 static void
 object_change_notify_cb (PropertyChange *change)
@@ -361,7 +335,7 @@
       int value;
 
       g_object_get (object, object_prop, &value, NULL);
-      gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), transform_spinbutton_value (value, change->flags, FALSE));
+      gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
     }
   else if (GTK_IS_ENTRY (widget))
     {
@@ -462,10 +436,10 @@
     }
   else if (GTK_IS_SPIN_BUTTON (widget))
     {
-      double value;
+      int value;
 
-      value = gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
-      g_object_set (object, object_prop, transform_spinbutton_value (value, change->flags, TRUE), NULL);
+      value = (int) gtk_spin_button_get_value (GTK_SPIN_BUTTON (widget));
+      g_object_set (object, object_prop, value, NULL);
     }
   else if (GTK_IS_ENTRY (widget))
     {

Modified: trunk/src/terminal-util.h
==============================================================================
--- trunk/src/terminal-util.h	(original)
+++ trunk/src/terminal-util.h	Thu May 29 19:50:33 2008
@@ -51,11 +51,8 @@
                                           const char *object_name,
                                           ...);
 
-int terminal_util_get_estimated_scrollback_buffer_size (int lines);
-
 typedef enum {
   FLAG_INVERT_BOOL  = 1 << 0,
-  FLAG_SCROLLBACK   = 1 << 1,
 } PropertyChangeFlags;
 
 void terminal_util_bind_object_property_to_widget (GObject *object,



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