Permalink
Browse files

Add default geometry option in preferences. Closes #6

  • Loading branch information...
1 parent 1e71340 commit 06509bc0e1b266aadd7e483e6edb1f559667295d @medicalwei medicalwei committed Nov 5, 2015
Showing with 137 additions and 23 deletions.
  1. +106 −17 data/lxterminal-preferences.glade
  2. +3 −2 src/lxterminal.c
  3. +14 −4 src/preferences.c
  4. +10 −0 src/setting.c
  5. +4 −0 src/setting.h
@@ -2,6 +2,18 @@
<interface>
<requires lib="gtk+" version="2.18"/>
<!-- interface-naming-policy toplevel-contextual -->
+ <object class="GtkAdjustment" id="geometry_columns_adjustment">
+ <property name="upper">1000</property>
+ <property name="value">80</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
+ <object class="GtkAdjustment" id="geometry_rows_adjustment">
+ <property name="upper">1000</property>
+ <property name="value">24</property>
+ <property name="step_increment">1</property>
+ <property name="page_increment">10</property>
+ </object>
<object class="GtkAdjustment" id="scrollback_lines_adjustment">
<property name="upper">100000</property>
<property name="value">1000</property>
@@ -611,7 +623,7 @@
<object class="GtkTable" id="table_display">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="n_rows">6</property>
+ <property name="n_rows">7</property>
<property name="n_columns">2</property>
<property name="column_spacing">5</property>
<property name="row_spacing">3</property>
@@ -647,8 +659,8 @@
<property name="label" translatable="yes">Hide scroll bar</property>
</object>
<packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -660,8 +672,8 @@
<property name="label" translatable="yes">Hide menu bar</property>
</object>
<packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -675,8 +687,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -703,6 +715,7 @@
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
+ <property name="width_chars">6</property>
<property name="primary_icon_activatable">False</property>
<property name="secondary_icon_activatable">False</property>
<property name="primary_icon_sensitive">True</property>
@@ -727,8 +740,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -740,8 +753,8 @@
<property name="label" translatable="yes">Hide Close buttons</property>
</object>
<packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -755,8 +768,8 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -768,8 +781,8 @@
<property name="label" translatable="yes">Hide mouse pointer</property>
</object>
<packing>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
<property name="y_options">GTK_FILL</property>
</packing>
</child>
@@ -783,8 +796,84 @@
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_default_geometry">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="xalign">1</property>
+ <property name="label" translatable="yes">Default window size</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox_default_geometry">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkSpinButton" id="geometry_columns">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="width_chars">4</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">geometry_columns_adjustment</property>
+ <property name="snap_to_ticks">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_default_geometry_times">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes">x</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSpinButton" id="geometry_rows">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="width_chars">4</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ <property name="adjustment">geometry_rows_adjustment</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_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">GTK_FILL</property>
</packing>
</child>
View
@@ -1486,9 +1486,10 @@ LXTerminal * lxterminal_initialize(LXTermWindow * lxtermwin, CommandArguments *
gtk_window_set_title(GTK_WINDOW(terminal->window), gtk_label_get_text(GTK_LABEL(term->label)));
/* Set the terminal geometry. */
- if ((arguments->geometry_columns != 0) && (arguments->geometry_rows != 0))
- {
+ if ((arguments->geometry_columns != 0) && (arguments->geometry_rows != 0)) {
vte_terminal_set_size(VTE_TERMINAL(term->vte), arguments->geometry_columns, arguments->geometry_rows);
+ } else {
+ vte_terminal_set_size(VTE_TERMINAL(term->vte), setting->geometry_columns, setting->geometry_rows);
}
/* Add the first terminal to the notebook and the data structures. */
View
@@ -186,10 +186,10 @@ static void preferences_dialog_tab_position_changed_event(GtkComboBox * widget,
//terminal_settings_apply_to_all(terminal);
}
-/* Handler for "value-changed" signal on Scrollback spin button. */
-static void preferences_dialog_scrollback_value_changed_event(GtkSpinButton * widget, Setting * setting)
+/* Handler for "value-changed" signal on spin button. */
+static void preferences_dialog_int_value_changed_event(GtkSpinButton * widget, gint * value)
{
- setting->scrollback = gtk_spin_button_get_value_as_int(widget);
+ *value = gtk_spin_button_get_value_as_int(widget);
}
/* Convert the user preference on tab position, expressed as a string, to the internal representation.
@@ -369,7 +369,17 @@ void terminal_preferences_dialog(GtkAction * action, LXTerminal * terminal)
w = GTK_WIDGET(gtk_builder_get_object(builder, "scrollback_lines"));
gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->scrollback);
g_signal_connect(G_OBJECT(w), "value-changed",
- G_CALLBACK(preferences_dialog_scrollback_value_changed_event), setting);
+ G_CALLBACK(preferences_dialog_int_value_changed_event), &setting->scrollback);
+
+ w = GTK_WIDGET(gtk_builder_get_object(builder, "geometry_columns"));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->geometry_columns);
+ g_signal_connect(G_OBJECT(w), "value-changed",
+ G_CALLBACK(preferences_dialog_int_value_changed_event), &setting->geometry_columns);
+
+ w = GTK_WIDGET(gtk_builder_get_object(builder, "geometry_rows"));
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(w), setting->geometry_rows);
+ g_signal_connect(G_OBJECT(w), "value-changed",
+ G_CALLBACK(preferences_dialog_int_value_changed_event), &setting->geometry_rows);
w = GTK_WIDGET(gtk_builder_get_object(builder, "hide_scroll_bar"));
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(w), setting->hide_scroll_bar);
View
@@ -195,6 +195,8 @@ void save_setting()
g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, AUDIBLE_BELL, setting->audible_bell);
g_key_file_set_string(setting->keyfile, GENERAL_GROUP, TAB_POS, setting->tab_position);
g_key_file_set_integer(setting->keyfile, GENERAL_GROUP, SCROLLBACK, setting->scrollback);
+ g_key_file_set_integer(setting->keyfile, GENERAL_GROUP, GEOMETRY_COLUMNS, setting->geometry_columns);
+ g_key_file_set_integer(setting->keyfile, GENERAL_GROUP, GEOMETRY_ROWS, setting->geometry_rows);
g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, HIDE_SCROLLBAR, setting->hide_scroll_bar);
g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, HIDE_MENUBAR, setting->hide_menu_bar);
g_key_file_set_boolean(setting->keyfile, GENERAL_GROUP, HIDE_CLOSE_BUTTON, setting->hide_close_button);
@@ -403,6 +405,14 @@ Setting * load_setting()
/* Set default value if key not found! */
setting->scrollback = 1000;
}
+ setting->geometry_columns = g_key_file_get_integer(setting->keyfile, GENERAL_GROUP, GEOMETRY_COLUMNS, &error);
+ if (error && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
+ setting->geometry_columns = 80;
+ }
+ setting->geometry_rows = g_key_file_get_integer(setting->keyfile, GENERAL_GROUP, GEOMETRY_ROWS, &error);
+ if (error && (error->code == G_KEY_FILE_ERROR_KEY_NOT_FOUND)) {
+ setting->geometry_rows = 24;
+ }
setting->hide_scroll_bar = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, HIDE_SCROLLBAR, NULL);
setting->hide_menu_bar = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, HIDE_MENUBAR, NULL);
setting->hide_close_button = g_key_file_get_boolean(setting->keyfile, GENERAL_GROUP, HIDE_CLOSE_BUTTON, NULL);
View
@@ -35,6 +35,8 @@
#define AUDIBLE_BELL "audiblebell"
#define TAB_POS "tabpos"
#define SCROLLBACK "scrollback"
+#define GEOMETRY_COLUMNS "geometry_columns"
+#define GEOMETRY_ROWS "geometry_rows"
#define HIDE_SCROLLBAR "hidescrollbar"
#define HIDE_MENUBAR "hidemenubar"
#define HIDE_CLOSE_BUTTON "hideclosebutton"
@@ -98,6 +100,8 @@ typedef struct _setting {
gboolean audible_bell; /* True if audible bell */
char * tab_position; /* Position of tabs on main window (top, bottom, left, right) */
gint scrollback; /* Scrollback buffer size in lines */
+ gint geometry_columns;
+ gint geometry_rows;
gboolean hide_scroll_bar; /* True if scroll bar is NOT visible */
gboolean hide_menu_bar; /* True if menu bar is NOT visible */
gboolean hide_close_button; /* True if close buttons are NOT visible */

0 comments on commit 06509bc

Please sign in to comment.