[latexila] Build Tools: move the preferences to its own dialog window
- From: SÃbastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [latexila] Build Tools: move the preferences to its own dialog window
- Date: Mon, 16 Jul 2012 05:13:56 +0000 (UTC)
commit 7a6edba34912a79aed42e0d0edab7adfd954fd3f
Author: SÃbastien Wilmet <swilmet src gnome org>
Date: Mon Jul 16 02:37:47 2012 +0200
Build Tools: move the preferences to its own dialog window
src/build_tools_preferences.vala | 47 ++++++++++++++++++++++---------------
src/main_window.vala | 7 +++++
src/preferences_dialog.vala | 5 ----
src/ui/preferences_dialog.ui | 18 --------------
src/ui/ui.xml | 4 ++-
5 files changed, 38 insertions(+), 43 deletions(-)
---
diff --git a/src/build_tools_preferences.vala b/src/build_tools_preferences.vala
index f397402..fdc3ae0 100644
--- a/src/build_tools_preferences.vala
+++ b/src/build_tools_preferences.vala
@@ -25,7 +25,7 @@
using Gtk;
-public class BuildToolsPreferences : Grid
+public class BuildToolsPreferences : GLib.Object
{
private enum BuildToolColumn
{
@@ -36,16 +36,32 @@ public class BuildToolsPreferences : Grid
N_COLUMNS
}
+ private Dialog _dialog;
private ListStore _list_store;
private TreeView _tree_view;
- public BuildToolsPreferences ()
+ public BuildToolsPreferences (MainWindow main_window)
{
- set_orientation (Orientation.VERTICAL);
-
init_list_store ();
init_tree_view ();
+ _dialog = new Dialog.with_buttons (_("Build Tools"), main_window,
+ DialogFlags.DESTROY_WITH_PARENT,
+ Stock.CLOSE, ResponseType.ACCEPT);
+
+ Box content_area = _dialog.get_content_area ();
+ content_area.pack_start (get_default_build_tools_grid ());
+ content_area.show_all ();
+
+ _dialog.run ();
+ _dialog.destroy ();
+ }
+
+ private Grid get_default_build_tools_grid ()
+ {
+ Grid grid = new Grid ();
+ grid.set_orientation (Orientation.VERTICAL);
+
_tree_view.expand = true;
ScrolledWindow scrolled_window =
Utils.add_scrollbar (_tree_view) as ScrolledWindow;
@@ -71,9 +87,10 @@ public class BuildToolsPreferences : Grid
context.add_class (STYLE_CLASS_INLINE_TOOLBAR);
context.set_junction_sides (JunctionSides.TOP);
- add (scrolled_window);
- add (toolbar);
- show_all ();
+ grid.add (scrolled_window);
+ grid.add (toolbar);
+
+ return grid;
}
private void init_list_store ()
@@ -238,10 +255,8 @@ public class BuildToolsPreferences : Grid
TreeModel model = _list_store as TreeModel;
model.get (iter, BuildToolColumn.LABEL, out label);
- unowned Gtk.Window? window = Utils.get_toplevel_window (this);
- return_if_fail (window != null);
-
- Dialog dialog = new MessageDialog (window, DialogFlags.DESTROY_WITH_PARENT,
+ Dialog dialog = new MessageDialog (_dialog,
+ DialogFlags.DESTROY_WITH_PARENT | DialogFlags.MODAL,
MessageType.QUESTION, ButtonsType.NONE,
_("Do you really want to delete the build tool \"%s\"?"),
label);
@@ -377,10 +392,7 @@ public class BuildToolsPreferences : Grid
reset_button.clicked.connect (() =>
{
- unowned Gtk.Window? window = Utils.get_toplevel_window (this);
- return_if_fail (window != null);
-
- Dialog dialog = Utils.get_reset_all_confirm_dialog (window,
+ Dialog dialog = Utils.get_reset_all_confirm_dialog (_dialog,
_("Do you really want to reset all build tools?"));
if (dialog.run () == ResponseType.YES)
@@ -416,10 +428,7 @@ public class BuildToolsPreferences : Grid
private void show_build_tool_dialog ()
{
- unowned Gtk.Window? window = Utils.get_toplevel_window (this);
- return_if_fail (window != null);
-
- BuildToolDialog.show_me (window.get_transient_for ());
+ BuildToolDialog.show_me (_dialog);
}
private void edit_build_tool (int build_tool_num)
diff --git a/src/main_window.vala b/src/main_window.vala
index 3d8440a..4ba67a5 100644
--- a/src/main_window.vala
+++ b/src/main_window.vala
@@ -104,6 +104,8 @@ public class MainWindow : Window
N_("Stop Execution"), on_build_stop_execution },
{ "BuildViewLog", "view_log", N_("View _Log"), null,
N_("View Log"), on_build_view_log },
+ { "BuildToolsPreferences", Stock.PREFERENCES, N_("_Manage Build Tools"), null,
+ N_("Manage Build Tools"), on_build_tools_preferences },
// Documents
{ "Documents", null, N_("_Documents") },
@@ -1759,6 +1761,11 @@ public class MainWindow : Window
tab.document.readonly = true;
}
+ public void on_build_tools_preferences ()
+ {
+ new BuildToolsPreferences (this);
+ }
+
/* Documents */
public void on_documents_save_all ()
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 61f62cc..937a27d 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -290,11 +290,6 @@ public class PreferencesDialog : Dialog
builder.get_object ("interactive_comp_label") as Label;
set_plural (interactive_comp_label, settings, "interactive-completion-num",
(n) => ngettext ("character", "characters", n));
-
- Grid grid_latex_tab = builder.get_object ("grid_latex_tab") as Grid;
- Grid build_tools_preferences = new BuildToolsPreferences ();
- build_tools_preferences.set_margin_left (12);
- grid_latex_tab.attach (build_tools_preferences, 0, 2, 1, 1);
}
private void init_other_tab (Builder builder)
diff --git a/src/ui/preferences_dialog.ui b/src/ui/preferences_dialog.ui
index 8fe0bc4..d487b15 100644
--- a/src/ui/preferences_dialog.ui
+++ b/src/ui/preferences_dialog.ui
@@ -506,24 +506,6 @@
<property name="height">1</property>
</packing>
</child>
- <child>
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="margin_top">10</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Build Tools</property>
- <attributes>
- <attribute name="weight" value="bold"/>
- </attributes>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- <property name="width">1</property>
- <property name="height">1</property>
- </packing>
- </child>
</object>
<packing>
<property name="position">2</property>
diff --git a/src/ui/ui.xml b/src/ui/ui.xml
index d988e15..a3b89e8 100644
--- a/src/ui/ui.xml
+++ b/src/ui/ui.xml
@@ -1,7 +1,7 @@
<!--
This file is part of LaTeXila.
-Copyright  2010 SÃbastien Wilmet
+Copyright  2010-2012 SÃbastien Wilmet
LaTeXila is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -82,6 +82,8 @@ along with LaTeXila. If not, see <http://www.gnu.org/licenses/>.
<menuitem action="BuildShowDetails" />
<menuitem action="BuildShowWarnings" />
<menuitem action="BuildShowBadBoxes" />
+ <separator />
+ <menuitem action="BuildToolsPreferences" />
</menu>
<menu action="Latex">
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]