Merge lp:~fabiozaramella/scratch/fix-1313440 into lp:~elementary-apps/scratch/scratch

Proposed by Fabio Zaramella
Status: Merged
Merged at revision: 1351
Proposed branch: lp:~fabiozaramella/scratch/fix-1313440
Merge into: lp:~elementary-apps/scratch/scratch
Diff against target: 165 lines (+64/-38)
1 file modified
src/Dialogs/PreferencesDialog.vala (+64/-38)
To merge this branch: bzr merge lp:~fabiozaramella/scratch/fix-1313440
Reviewer Review Type Date Requested Status
xapantu (community) Approve
Review via email: mp+228417@code.launchpad.net

Commit message

Fix bug #1313440 and don't use a deprecated staticnotebook in the settings dialog + hig fixes.

To post a comment you must log in.
Revision history for this message
xapantu (xapantu) wrote :

It looks good, thanks for your work!

review: Approve
Revision history for this message
xapantu (xapantu) wrote :

I forgot to say that I will not merge the "allow move window" thing, it is a bit hacky and shouldn't be done at our level. The rest is good though.

Revision history for this message
xapantu (xapantu) wrote :

Oh, and I also forgot to say that you needed to put widgets name in the stack, or there will be gtk warnings (wich is not good because it hides the real warnings). I will do it when I merge this.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/Dialogs/PreferencesDialog.vala'
--- src/Dialogs/PreferencesDialog.vala 2014-07-12 05:58:27 +0000
+++ src/Dialogs/PreferencesDialog.vala 2014-07-27 09:18:08 +0000
@@ -4,6 +4,8 @@
44
5 Copyright (C) 2011-2012 Giulio Collura <random.cpp@gmail.com>5 Copyright (C) 2011-2012 Giulio Collura <random.cpp@gmail.com>
6 2013 Mario Guerriero <mario@elementaryos.org>6 2013 Mario Guerriero <mario@elementaryos.org>
7 2014 Fabio Zaramella <ffabio.96.x@gmail.com>
8
7 This program is free software: you can redistribute it and/or modify it9 This program is free software: you can redistribute it and/or modify it
8 under the terms of the GNU Lesser General Public License version 3, as published10 under the terms of the GNU Lesser General Public License version 3, as published
9 by the Free Software Foundation.11 by the Free Software Foundation.
@@ -27,7 +29,8 @@
2729
28 public class Preferences : Gtk.Dialog {30 public class Preferences : Gtk.Dialog {
2931
30 public StaticNotebook main_static_notebook;32 private Gtk.Stack main_stack;
33 private StackSwitcher main_stackswitcher;
31 34
32 ComboBoxText start;35 ComboBoxText start;
33 Switch highlight_current_line;36 Switch highlight_current_line;
@@ -41,54 +44,77 @@
41 Switch use_custom_font;44 Switch use_custom_font;
42 FontButton select_font;45 FontButton select_font;
43 46
44 public Preferences (Gtk.Window? parent, PluginsManager plugins) {47 public Preferences (Gtk.Window? parent, PluginsManager plugins) {
48 Object (use_header_bar: 1);
4549
46 if (parent != null)50 if (parent != null)
47 this.set_transient_for (parent);51 set_transient_for (parent);
48 this.title = _("Preferences");52 title = _("Preferences");
49 this.border_width = 5;
50 set_default_size (630, 330);53 set_default_size (630, 330);
51 resizable = false;54 resizable = false;
52 55
53 main_static_notebook = new StaticNotebook (false);56 (get_header_bar () as Gtk.HeaderBar).show_close_button = false;
54 57 get_header_bar ().get_style_context ().remove_class ("header-bar");
58
59 main_stack = new Gtk.Stack ();
60 main_stackswitcher = new Gtk.StackSwitcher ();
61 main_stackswitcher.set_stack (main_stack);
62 main_stackswitcher.halign = Gtk.Align.CENTER;
63
55 create_layout (plugins);64 create_layout (plugins);
5665
66 /*
67 * Allow moving the window
68 */
69 this.button_press_event.connect ( (e) => {
70 if (e.button == 1) {
71 this.begin_move_drag ((int) e.button, (int) e.x_root, (int) e.y_root, e.time);
72 return true;
73 }
74 return false;
75 });
76
57 }77 }
5878
59 private void create_layout (PluginsManager plugins) {79 private void create_layout (PluginsManager plugins) {
60 80
61 //create static notebook Behavior tab81 //create Behavior tab
62 var behavior_label = new Label (_("Behavior"));82 this.main_stack.add_titled (get_general_box (), "", _("Behavior"));
63 main_static_notebook.append_page (get_general_box (), behavior_label);83
64 84 //create Interface tab
65 //create static notebook Interface tab85 this.main_stack.add_titled (get_editor_box (), "", _("Interface"));
66 var interface_label = new Label (_("Interface"));
67 main_static_notebook.append_page (get_editor_box (), interface_label);
68 86
69 // Plugin hook function87 // Plugin hook function
70 plugins.hook_preferences_dialog (this);88 plugins.hook_preferences_dialog (this);
71 89
72 if (Peas.Engine.get_default ().get_plugin_list ().length () > 0) {90 if (Peas.Engine.get_default ().get_plugin_list ().length () > 0) {
73 //create static notebook Extensions tab
74 var extensions_label = new Label (_("Extensions"));
75
76 //var pbox = plugins.get_view ();91 //var pbox = plugins.get_view ();
77 var pbox = new Box (Orientation.HORIZONTAL, 5);92 var pbox = new Box (Orientation.HORIZONTAL, 12);
78 pbox.pack_start (plugins.get_view (), true, true, 5);93 pbox.margin_top = 12;
79 94 pbox.margin_bottom = 12;
80 main_static_notebook.append_page (pbox, extensions_label);95 pbox.pack_start (plugins.get_view (), true, true, 12);
96
97 //create Extensions tab
98 this.main_stack.add_titled (pbox, "", _("Extensions"));
81 }99 }
82 100
83 // Close button101 // Close button
84 this.response.connect ((response_id) => { 102 var close_button = new Gtk.Button.with_label (_("Close"));
85 this.destroy();103 close_button.clicked.connect (() => {this.destroy ();});
86 });
87 add_button ("_Close", Gtk.ResponseType.CLOSE);
88 104
105 var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
106 button_box.set_layout (Gtk.ButtonBoxStyle.END);
107 button_box.pack_end (close_button);
108 button_box.margin_right = 12;
109
89 // Pack everything into the dialog110 // Pack everything into the dialog
90 Gtk.Box content = get_content_area () as Gtk.Box;111 Gtk.Grid main_grid = new Gtk.Grid ();
91 content.pack_start (main_static_notebook, true, true, 0);112 main_grid.attach (this.main_stackswitcher, 0, 0, 1, 1);
113 main_grid.attach (this.main_stack, 0, 1, 1, 1);
114 main_grid.attach (button_box, 0, 2, 1, 1);
115
116 ((Gtk.Container) get_content_area ()).add (main_grid);
117
92 }118 }
93119
94 void add_section (Gtk.Grid grid, Gtk.Label name, ref int row) {120 void add_section (Gtk.Grid grid, Gtk.Label name, ref int row) {
@@ -128,10 +154,10 @@
128 var general_grid = new Gtk.Grid ();154 var general_grid = new Gtk.Grid ();
129 general_grid.row_spacing = 5;155 general_grid.row_spacing = 5;
130 general_grid.column_spacing = 5;156 general_grid.column_spacing = 5;
131 general_grid.margin_left = 15;157 general_grid.margin_left = 12;
132 general_grid.margin_right = 5;158 general_grid.margin_right = 12;
133 general_grid.margin_top = 15;159 general_grid.margin_top = 12;
134 general_grid.margin_bottom = 15; 160 general_grid.margin_bottom = 12;
135 161
136 int row = 0;162 int row = 0;
137 // General163 // General
@@ -178,10 +204,10 @@
178 var content = new Gtk.Grid ();204 var content = new Gtk.Grid ();
179 content.row_spacing = 5;205 content.row_spacing = 5;
180 content.column_spacing = 5;206 content.column_spacing = 5;
181 content.margin_left = 15;207 content.margin_left = 12;
182 content.margin_right = 5;208 content.margin_right = 12;
183 content.margin_top = 15;209 content.margin_top = 12;
184 content.margin_bottom = 15;210 content.margin_bottom = 12;
185 211
186 int row = 0;212 int row = 0;
187 213
@@ -280,4 +306,4 @@
280306
281 }307 }
282308
283} // Namespace309} // Namespace
284\ No newline at end of file310\ No newline at end of file

Subscribers

People subscribed via source and target branches