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
1=== modified file 'src/Dialogs/PreferencesDialog.vala'
2--- src/Dialogs/PreferencesDialog.vala 2014-07-12 05:58:27 +0000
3+++ src/Dialogs/PreferencesDialog.vala 2014-07-27 09:18:08 +0000
4@@ -4,6 +4,8 @@
5
6 Copyright (C) 2011-2012 Giulio Collura <random.cpp@gmail.com>
7 2013 Mario Guerriero <mario@elementaryos.org>
8+ 2014 Fabio Zaramella <ffabio.96.x@gmail.com>
9+
10 This program is free software: you can redistribute it and/or modify it
11 under the terms of the GNU Lesser General Public License version 3, as published
12 by the Free Software Foundation.
13@@ -27,7 +29,8 @@
14
15 public class Preferences : Gtk.Dialog {
16
17- public StaticNotebook main_static_notebook;
18+ private Gtk.Stack main_stack;
19+ private StackSwitcher main_stackswitcher;
20
21 ComboBoxText start;
22 Switch highlight_current_line;
23@@ -41,54 +44,77 @@
24 Switch use_custom_font;
25 FontButton select_font;
26
27- public Preferences (Gtk.Window? parent, PluginsManager plugins) {
28+ public Preferences (Gtk.Window? parent, PluginsManager plugins) {
29+ Object (use_header_bar: 1);
30
31 if (parent != null)
32- this.set_transient_for (parent);
33- this.title = _("Preferences");
34- this.border_width = 5;
35+ set_transient_for (parent);
36+ title = _("Preferences");
37 set_default_size (630, 330);
38 resizable = false;
39
40- main_static_notebook = new StaticNotebook (false);
41-
42+ (get_header_bar () as Gtk.HeaderBar).show_close_button = false;
43+ get_header_bar ().get_style_context ().remove_class ("header-bar");
44+
45+ main_stack = new Gtk.Stack ();
46+ main_stackswitcher = new Gtk.StackSwitcher ();
47+ main_stackswitcher.set_stack (main_stack);
48+ main_stackswitcher.halign = Gtk.Align.CENTER;
49+
50 create_layout (plugins);
51
52+ /*
53+ * Allow moving the window
54+ */
55+ this.button_press_event.connect ( (e) => {
56+ if (e.button == 1) {
57+ this.begin_move_drag ((int) e.button, (int) e.x_root, (int) e.y_root, e.time);
58+ return true;
59+ }
60+ return false;
61+ });
62+
63 }
64
65- private void create_layout (PluginsManager plugins) {
66-
67- //create static notebook Behavior tab
68- var behavior_label = new Label (_("Behavior"));
69- main_static_notebook.append_page (get_general_box (), behavior_label);
70-
71- //create static notebook Interface tab
72- var interface_label = new Label (_("Interface"));
73- main_static_notebook.append_page (get_editor_box (), interface_label);
74+ private void create_layout (PluginsManager plugins) {
75+
76+ //create Behavior tab
77+ this.main_stack.add_titled (get_general_box (), "", _("Behavior"));
78+
79+ //create Interface tab
80+ this.main_stack.add_titled (get_editor_box (), "", _("Interface"));
81
82 // Plugin hook function
83 plugins.hook_preferences_dialog (this);
84
85 if (Peas.Engine.get_default ().get_plugin_list ().length () > 0) {
86- //create static notebook Extensions tab
87- var extensions_label = new Label (_("Extensions"));
88-
89 //var pbox = plugins.get_view ();
90- var pbox = new Box (Orientation.HORIZONTAL, 5);
91- pbox.pack_start (plugins.get_view (), true, true, 5);
92-
93- main_static_notebook.append_page (pbox, extensions_label);
94+ var pbox = new Box (Orientation.HORIZONTAL, 12);
95+ pbox.margin_top = 12;
96+ pbox.margin_bottom = 12;
97+ pbox.pack_start (plugins.get_view (), true, true, 12);
98+
99+ //create Extensions tab
100+ this.main_stack.add_titled (pbox, "", _("Extensions"));
101 }
102
103 // Close button
104- this.response.connect ((response_id) => {
105- this.destroy();
106- });
107- add_button ("_Close", Gtk.ResponseType.CLOSE);
108+ var close_button = new Gtk.Button.with_label (_("Close"));
109+ close_button.clicked.connect (() => {this.destroy ();});
110
111+ var button_box = new Gtk.ButtonBox (Gtk.Orientation.HORIZONTAL);
112+ button_box.set_layout (Gtk.ButtonBoxStyle.END);
113+ button_box.pack_end (close_button);
114+ button_box.margin_right = 12;
115+
116 // Pack everything into the dialog
117- Gtk.Box content = get_content_area () as Gtk.Box;
118- content.pack_start (main_static_notebook, true, true, 0);
119+ Gtk.Grid main_grid = new Gtk.Grid ();
120+ main_grid.attach (this.main_stackswitcher, 0, 0, 1, 1);
121+ main_grid.attach (this.main_stack, 0, 1, 1, 1);
122+ main_grid.attach (button_box, 0, 2, 1, 1);
123+
124+ ((Gtk.Container) get_content_area ()).add (main_grid);
125+
126 }
127
128 void add_section (Gtk.Grid grid, Gtk.Label name, ref int row) {
129@@ -128,10 +154,10 @@
130 var general_grid = new Gtk.Grid ();
131 general_grid.row_spacing = 5;
132 general_grid.column_spacing = 5;
133- general_grid.margin_left = 15;
134- general_grid.margin_right = 5;
135- general_grid.margin_top = 15;
136- general_grid.margin_bottom = 15;
137+ general_grid.margin_left = 12;
138+ general_grid.margin_right = 12;
139+ general_grid.margin_top = 12;
140+ general_grid.margin_bottom = 12;
141
142 int row = 0;
143 // General
144@@ -178,10 +204,10 @@
145 var content = new Gtk.Grid ();
146 content.row_spacing = 5;
147 content.column_spacing = 5;
148- content.margin_left = 15;
149- content.margin_right = 5;
150- content.margin_top = 15;
151- content.margin_bottom = 15;
152+ content.margin_left = 12;
153+ content.margin_right = 12;
154+ content.margin_top = 12;
155+ content.margin_bottom = 12;
156
157 int row = 0;
158
159@@ -280,4 +306,4 @@
160
161 }
162
163-} // Namespace
164+} // Namespace
165\ No newline at end of file

Subscribers

People subscribed via source and target branches