[latexila] Build Tools: new UI for the preferences



commit ffae9ae0d9a1b740ce3a6c95651deef5b2c0c203
Author: SÃbastien Wilmet <swilmet src gnome org>
Date:   Sat Jul 7 03:30:45 2012 +0200

    Build Tools: new UI for the preferences
    
    Move the UI from the .ui file to a new .vala. Use a more modern,
    GNOMEÂ3-friendly toolbar for the buttons, with symbolic icons.

 src/build_tools_preferences.vala |  360 ++++++++++++++++++++++++++++++++++++++
 src/preferences_dialog.vala      |  255 ++-------------------------
 src/ui/preferences_dialog.ui     |  231 ++----------------------
 src/utils.vala                   |   26 +++
 4 files changed, 420 insertions(+), 452 deletions(-)
---
diff --git a/src/build_tools_preferences.vala b/src/build_tools_preferences.vala
new file mode 100644
index 0000000..6ff2334
--- /dev/null
+++ b/src/build_tools_preferences.vala
@@ -0,0 +1,360 @@
+/*
+ * This file is part of LaTeXila.
+ *
+ * Copyright  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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * LaTeXila is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with LaTeXila.  If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: SÃbastien Wilmet
+ */
+
+// The preferences of the build tools, which is part of the preferences dialog, in the
+// LaTeX tab.
+// For the configuration of a single build tool, see build_tool_dialog.vala.
+
+using Gtk;
+
+public class BuildToolsPreferences : Grid
+{
+    private enum BuildToolColumn
+    {
+        ENABLE,
+        PIXBUF,
+        LABEL,
+        DESCRIPTION,
+        N_COLUMNS
+    }
+
+    private ListStore _list_store;
+    private TreeView _tree_view;
+
+    public BuildToolsPreferences ()
+    {
+        set_orientation (Orientation.VERTICAL);
+
+        init_list_store ();
+        init_tree_view ();
+
+        _tree_view.expand = true;
+        ScrolledWindow scrolled_window =
+            Utils.add_scrollbar (_tree_view) as ScrolledWindow;
+        scrolled_window.set_shadow_type (ShadowType.IN);
+        scrolled_window.set_size_request (350, 200);
+
+        StyleContext context = scrolled_window.get_style_context ();
+        context.set_junction_sides (JunctionSides.BOTTOM);
+
+        Toolbar toolbar = new Toolbar ();
+        toolbar.insert (get_properties_button (), -1);
+        toolbar.insert (get_copy_button (), -1);
+        toolbar.insert (get_add_button (), -1);
+        toolbar.insert (get_remove_button (), -1);
+        toolbar.insert (get_up_button (), -1);
+        toolbar.insert (get_down_button (), -1);
+        toolbar.insert (get_reset_button (), -1);
+
+        toolbar.set_icon_size (IconSize.MENU);
+        toolbar.set_style (ToolbarStyle.ICONS);
+
+        context = toolbar.get_style_context ();
+        context.add_class (STYLE_CLASS_INLINE_TOOLBAR);
+        context.set_junction_sides (JunctionSides.TOP);
+
+        add (scrolled_window);
+        add (toolbar);
+        show_all ();
+    }
+
+    private void init_list_store ()
+    {
+        _list_store = new ListStore (BuildToolColumn.N_COLUMNS,
+            typeof (bool),   // enable
+            typeof (string), // pixbuf (stock-id)
+            typeof (string), // label
+            typeof (string)  // description
+        );
+
+        update_list_store ();
+    }
+
+    private void init_tree_view ()
+    {
+        _tree_view = new TreeView.with_model (_list_store);
+        _tree_view.set_rules_hint (true);
+
+        TreeViewColumn enable_column = new TreeViewColumn ();
+        enable_column.set_title (_("Enable"));
+        _tree_view.append_column (enable_column);
+
+        CellRendererToggle toggle_renderer = new CellRendererToggle ();
+        enable_column.pack_start (toggle_renderer, false);
+        enable_column.set_attributes (toggle_renderer,
+            "active", BuildToolColumn.ENABLE);
+
+        TreeViewColumn label_column = new TreeViewColumn ();
+        label_column.set_title (_("Label"));
+        _tree_view.append_column (label_column);
+
+        CellRendererPixbuf pixbuf_renderer = new CellRendererPixbuf ();
+        label_column.pack_start (pixbuf_renderer, false);
+        label_column.set_attributes (pixbuf_renderer,
+            "stock-id", BuildToolColumn.PIXBUF);
+
+        CellRendererText text_renderer = new CellRendererText ();
+        label_column.pack_start (text_renderer, true);
+        label_column.set_attributes (text_renderer,
+          "text", BuildToolColumn.LABEL);
+
+        _tree_view.set_tooltip_column (BuildToolColumn.DESCRIPTION);
+
+        TreeSelection select = _tree_view.get_selection ();
+        select.set_mode (SelectionMode.SINGLE);
+
+        /* Enable and disable a build tool */
+        toggle_renderer.toggled.connect ((path_string) =>
+        {
+            TreeIter iter;
+            _list_store.get_iter_from_string (out iter, path_string);
+
+            bool enable;
+            TreeModel model = _list_store as TreeModel;
+            model.get (iter, BuildToolColumn.ENABLE, out enable);
+
+            enable = ! enable;
+            _list_store.set (iter, BuildToolColumn.ENABLE, enable);
+
+            int num = int.parse (path_string);
+            BuildTools build_tools = BuildTools.get_default ();
+            BuildTool build_tool = build_tools[num];
+            build_tool.show = enable;
+
+            build_tools.update (num, build_tool);
+        });
+
+        /* Double-click */
+        _tree_view.row_activated.connect ((path, column) =>
+        {
+            if (column == label_column)
+            {
+                int num = path.get_indices ()[0];
+                run_build_tool_dialog (num);
+            }
+        });
+    }
+
+    private ToolButton get_properties_button ()
+    {
+        ToolButton properties_button = new ToolButton (null, null);
+        properties_button.set_icon_name ("document-properties-symbolic");
+        properties_button.set_tooltip_text ("Edit the properties");
+
+        properties_button.clicked.connect (() =>
+        {
+            int num = Utils.get_selected_row (_tree_view);
+            if (0 <= num)
+                run_build_tool_dialog (num);
+        });
+
+        return properties_button;
+    }
+
+    private ToolButton get_copy_button ()
+    {
+        ToolButton copy_button = new ToolButton (null, null);
+        copy_button.set_icon_name ("edit-copy-symbolic");
+        copy_button.set_tooltip_text ("Create a copy");
+
+        copy_button.clicked.connect (() =>
+        {
+            int selected_row = Utils.get_selected_row (_tree_view);
+            if (selected_row < 0)
+                return;
+
+            BuildTools build_tools = BuildTools.get_default ();
+            BuildTool? tool = build_tools[selected_row];
+            return_if_fail (tool != null);
+
+            tool.show = false;
+            tool.label = _("%s [copy]").printf (tool.label);
+            build_tools.insert (selected_row + 1, tool);
+
+            update_list_store ();
+        });
+
+        return copy_button;
+    }
+
+    private ToolButton get_add_button ()
+    {
+        ToolButton add_button = new ToolButton (null, null);
+        add_button.set_icon_name ("list-add-symbolic");
+        add_button.set_tooltip_text (_("Add..."));
+
+        add_button.clicked.connect (() =>
+        {
+            run_build_tool_dialog (-1);
+        });
+
+        return add_button;
+    }
+
+    private ToolButton get_remove_button ()
+    {
+        ToolButton remove_button = new ToolButton (null, null);
+        remove_button.set_icon_name ("list-remove-symbolic");
+        remove_button.set_tooltip_text (_("Remove"));
+
+        remove_button.clicked.connect (() =>
+        {
+            TreeIter iter;
+            int selected_row = Utils.get_selected_row (_tree_view, out iter);
+            if (selected_row == -1)
+                return;
+
+            string label;
+            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,
+                MessageType.QUESTION, ButtonsType.NONE,
+                _("Do you really want to delete the build tool \"%s\"?"),
+                label);
+
+            dialog.add_buttons (Stock.CANCEL, ResponseType.CANCEL,
+                Stock.DELETE, ResponseType.YES);
+
+            if (dialog.run () == ResponseType.YES)
+            {
+                _list_store.remove (iter);
+                BuildTools.get_default ().delete (selected_row);
+            }
+
+            dialog.destroy ();
+        });
+
+        return remove_button;
+    }
+
+    private ToolButton get_up_button ()
+    {
+        ToolButton up_button = new ToolButton (null, null);
+        up_button.set_icon_name ("go-up-symbolic");
+        up_button.set_tooltip_text (_("Move up"));
+
+        up_button.clicked.connect (() =>
+        {
+            TreeIter iter_selected;
+
+            int selected_row = Utils.get_selected_row (_tree_view,
+                out iter_selected);
+
+            if (selected_row > 0)
+            {
+                TreeIter iter_up = iter_selected;
+                if (Utils.tree_model_iter_prev (_list_store, ref iter_up))
+                {
+                    _list_store.swap (iter_selected, iter_up);
+                    BuildTools.get_default ().move_up (selected_row);
+                }
+            }
+        });
+
+        return up_button;
+    }
+
+    private ToolButton get_down_button ()
+    {
+        ToolButton down_button = new ToolButton (null, null);
+        down_button.set_icon_name ("go-down-symbolic");
+        down_button.set_tooltip_text (_("Move down"));
+
+        down_button.clicked.connect (() =>
+        {
+            TreeIter iter_selected;
+
+            int selected_row = Utils.get_selected_row (_tree_view,
+                out iter_selected);
+
+            if (selected_row >= 0)
+            {
+                TreeIter iter_down = iter_selected;
+                if (_list_store.iter_next (ref iter_down))
+                {
+                    _list_store.swap (iter_selected, iter_down);
+                    BuildTools.get_default ().move_down (selected_row);
+                }
+            }
+        });
+
+        return down_button;
+    }
+
+    private ToolButton get_reset_button ()
+    {
+        ToolButton reset_button = new ToolButton (null, null);
+        // TODO use the clear symbolic icon when it is available
+        reset_button.set_icon_name ("edit-delete-symbolic");
+        reset_button.set_tooltip_text (_("Reset all the build tools"));
+
+        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,
+                _("Do you really want to reset all build tools?"));
+
+            if (dialog.run () == ResponseType.YES)
+            {
+                BuildTools.get_default ().reset_all ();
+                update_list_store ();
+            }
+
+            dialog.destroy ();
+        });
+
+        return reset_button;
+    }
+
+    private void update_list_store ()
+    {
+        _list_store.clear ();
+
+        foreach (BuildTool tool in BuildTools.get_default ())
+        {
+            TreeIter iter;
+            _list_store.append (out iter);
+            _list_store.set (iter,
+                BuildToolColumn.ENABLE, tool.show,
+                BuildToolColumn.PIXBUF, tool.icon,
+                BuildToolColumn.LABEL, tool.label,
+                BuildToolColumn.DESCRIPTION, Markup.escape_text (tool.description)
+            );
+        }
+    }
+
+    private void run_build_tool_dialog (int num)
+    {
+        unowned Gtk.Window? window = Utils.get_toplevel_window (this);
+        return_if_fail (window != null);
+
+        bool accepted = BuildToolDialog.show_me (window.get_transient_for (), num);
+
+        if (accepted)
+            update_list_store ();
+    }
+}
diff --git a/src/preferences_dialog.vala b/src/preferences_dialog.vala
index 5e60547..d380fc2 100644
--- a/src/preferences_dialog.vala
+++ b/src/preferences_dialog.vala
@@ -1,7 +1,7 @@
 /*
  * This file is part of LaTeXila.
  *
- * Copyright  2010-2011 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
@@ -22,8 +22,7 @@ using Gee;
 
 public class PreferencesDialog : Dialog
 {
-    private static PreferencesDialog preferences_dialog = null;
-    private ListStore build_tools_store;
+    private static PreferencesDialog _instance = null;
 
     delegate unowned string Plural (ulong n);
 
@@ -94,28 +93,28 @@ public class PreferencesDialog : Dialog
 
     public static void show_me (MainWindow parent)
     {
-        if (preferences_dialog == null)
+        if (_instance == null)
         {
-            preferences_dialog = new PreferencesDialog ();
+            _instance = new PreferencesDialog ();
 
-            preferences_dialog.destroy.connect (() =>
+            _instance.destroy.connect (() =>
             {
-                if (preferences_dialog != null)
-                    preferences_dialog = null;
+                if (_instance != null)
+                    _instance = null;
             });
         }
 
-        if (parent != preferences_dialog.get_transient_for ())
-            preferences_dialog.set_transient_for (parent);
+        if (parent != _instance.get_transient_for ())
+            _instance.set_transient_for (parent);
 
-        preferences_dialog.present ();
+        _instance.present ();
     }
 
     private void reset_all ()
     {
         // build tools are not reset, since there is another button for that
 
-        Dialog dialog = get_reset_all_confirm_dialog (
+        Dialog dialog = Utils.get_reset_all_confirm_dialog (this,
             _("Do you really want to reset all preferences?"));
         int resp = dialog.run ();
         dialog.destroy ();
@@ -300,116 +299,9 @@ public class PreferencesDialog : Dialog
         settings.bind ("latexmk-always-show-all", latexmk_checkbutton, "active",
             SettingsBindFlags.DEFAULT);
 
-        var build_tools_view = builder.get_object ("build_tools_treeview") as TreeView;
-        init_build_tools_treeview (build_tools_view);
-
-        Button bt_properties = builder.get_object ("build_tool_properties") as Button;
-        bt_properties.clicked.connect (() =>
-        {
-            int num = Utils.get_selected_row (build_tools_view);
-            if (0 <= num)
-                run_build_tool_dialog (num);
-        });
-
-        Button bt_new = builder.get_object ("build_tool_new") as Button;
-        bt_new.clicked.connect (() =>
-        {
-            run_build_tool_dialog (-1);
-        });
-
-        Button bt_copy = builder.get_object ("build_tool_copy") as Button;
-        bt_copy.clicked.connect (() =>
-        {
-            int selected_row = Utils.get_selected_row (build_tools_view);
-            if (selected_row < 0)
-                return;
-
-            BuildTools build_tools = BuildTools.get_default ();
-            BuildTool? tool = build_tools.get (selected_row);
-            return_if_fail (tool != null);
-
-            tool.show = false;
-            tool.label = _("%s [copy]").printf (tool.label);
-            build_tools.insert (selected_row + 1, tool);
-
-            update_build_tools_store ();
-        });
-
-        Button bt_up = builder.get_object ("build_tool_up") as Button;
-        bt_up.clicked.connect (() =>
-        {
-            TreeIter iter1, iter2;
-            int i = Utils.get_selected_row (build_tools_view, out iter1);
-            if (i != -1 && i > 0)
-            {
-                iter2 = iter1;
-                if (Utils.tree_model_iter_prev (build_tools_store, ref iter2))
-                {
-                    build_tools_store.swap (iter1, iter2);
-                    BuildTools.get_default ().move_up (i);
-                }
-            }
-        });
-
-        Button bt_down = builder.get_object ("build_tool_down") as Button;
-        bt_down.clicked.connect (() =>
-        {
-            TreeIter iter1, iter2;
-            int i = Utils.get_selected_row (build_tools_view, out iter1);
-            if (i != -1)
-            {
-                iter2 = iter1;
-                if (build_tools_store.iter_next (ref iter2))
-                {
-                    build_tools_store.swap (iter1, iter2);
-                    BuildTools.get_default ().move_down (i);
-                }
-            }
-        });
-
-        Button bt_delete = builder.get_object ("build_tool_delete") as Button;
-        bt_delete.clicked.connect (() =>
-        {
-            TreeIter iter;
-            int selected_row = Utils.get_selected_row (build_tools_view, out iter);
-            if (selected_row == -1)
-                return;
-
-            string label;
-            TreeModel model = (TreeModel) build_tools_store;
-            model.get (iter, BuildToolColumn.LABEL, out label, -1);
-
-            Dialog dialog = new MessageDialog (this, DialogFlags.DESTROY_WITH_PARENT,
-                MessageType.QUESTION, ButtonsType.NONE,
-                _("Do you really want to delete the build tool \"%s\"?"),
-                label);
-
-            dialog.add_buttons (Stock.CANCEL, ResponseType.CANCEL,
-                Stock.DELETE, ResponseType.YES);
-
-            if (dialog.run () == ResponseType.YES)
-            {
-                build_tools_store.remove (iter);
-                BuildTools.get_default ().delete (selected_row);
-            }
-
-            dialog.destroy ();
-        });
-
-        Button bt_reset = builder.get_object ("build_tool_reset") as Button;
-        bt_reset.clicked.connect (() =>
-        {
-            Dialog dialog = get_reset_all_confirm_dialog (
-                _("Do you really want to reset all build tools?"));
-
-            if (dialog.run () == ResponseType.YES)
-            {
-                BuildTools.get_default ().reset_all ();
-                update_build_tools_store ();
-            }
-
-            dialog.destroy ();
-        });
+        Grid grid_latex_tab = builder.get_object ("grid_latex_tab") as Grid;
+        Grid build_tools_preferences = new BuildToolsPreferences ();
+        grid_latex_tab.attach (build_tools_preferences, 0, 4, 1, 1);
     }
 
     private void init_other_tab (Builder builder)
@@ -565,123 +457,4 @@ public class PreferencesDialog : Dialog
                 select.select_iter (iter);
         }
     }
-
-    private enum BuildToolColumn
-    {
-        SHOW,
-        PIXBUF,
-        LABEL,
-        DESCRIPTION,
-        N_COLUMNS
-    }
-
-    private void init_build_tools_treeview (TreeView build_tools_view)
-    {
-        build_tools_store = new ListStore (BuildToolColumn.N_COLUMNS, typeof (bool),
-            typeof (string), typeof (string), typeof (string));
-        build_tools_view.set_model (build_tools_store);
-
-        TreeViewColumn active_column = new TreeViewColumn ();
-        active_column.set_title (_("Active"));
-        build_tools_view.append_column (active_column);
-
-        CellRendererToggle toggle_renderer = new CellRendererToggle ();
-        active_column.pack_start (toggle_renderer, false);
-        active_column.set_attributes (toggle_renderer,
-          "active", BuildToolColumn.SHOW,
-          null);
-
-        TreeViewColumn label_column = new TreeViewColumn ();
-        label_column.set_title (_("Label"));
-        build_tools_view.append_column (label_column);
-
-        CellRendererPixbuf pixbuf_renderer = new CellRendererPixbuf ();
-        label_column.pack_start (pixbuf_renderer, false);
-        label_column.set_attributes (pixbuf_renderer,
-          "stock-id", BuildToolColumn.PIXBUF,
-          null);
-
-        CellRendererText text_renderer = new CellRendererText ();
-        label_column.pack_start (text_renderer, true);
-        label_column.set_attributes (text_renderer,
-          "text", BuildToolColumn.LABEL,
-          null);
-
-        build_tools_view.set_tooltip_column (BuildToolColumn.DESCRIPTION);
-
-        TreeSelection select = build_tools_view.get_selection ();
-        select.set_mode (SelectionMode.SINGLE);
-
-        /* fill list store */
-        update_build_tools_store ();
-
-        /* show/hide build tool */
-        toggle_renderer.toggled.connect ((path_string) =>
-        {
-            TreeIter iter;
-            build_tools_store.get_iter_from_string (out iter, path_string);
-            bool val;
-            TreeModel model = (TreeModel) build_tools_store;
-            model.get (iter, BuildToolColumn.SHOW, out val, -1);
-
-            val = ! val;
-            build_tools_store.set (iter, BuildToolColumn.SHOW, val, -1);
-
-            int num = int.parse (path_string);
-            BuildTools build_tools = BuildTools.get_default ();
-            BuildTool build_tool = build_tools[num];
-            build_tool.show = val;
-
-            build_tools.update (num, build_tool);
-        });
-
-        /* double-click */
-        build_tools_view.row_activated.connect ((path, column) =>
-        {
-            if (column == label_column)
-            {
-                int num = path.get_indices ()[0];
-                run_build_tool_dialog (num);
-            }
-        });
-    }
-
-    private void update_build_tools_store ()
-    {
-        build_tools_store.clear ();
-
-        foreach (BuildTool tool in BuildTools.get_default ())
-        {
-            TreeIter iter;
-            build_tools_store.append (out iter);
-            build_tools_store.set (iter,
-                BuildToolColumn.SHOW, tool.show,
-                BuildToolColumn.PIXBUF, tool.icon,
-                BuildToolColumn.LABEL, tool.label,
-                BuildToolColumn.DESCRIPTION, Markup.escape_text (tool.description),
-                -1);
-        }
-    }
-
-    private Dialog get_reset_all_confirm_dialog (string msg)
-    {
-        Dialog dialog = new MessageDialog (this, DialogFlags.DESTROY_WITH_PARENT,
-            MessageType.QUESTION, ButtonsType.NONE, "%s", msg);
-
-        dialog.add_button (Stock.CANCEL, ResponseType.CANCEL);
-
-        Button button = new Button.with_label (_("Reset All"));
-        Image image = new Image.from_stock (Stock.CLEAR, IconSize.BUTTON);
-        button.set_image (image);
-        button.show_all ();
-        dialog.add_action_widget (button, ResponseType.YES);
-
-        return dialog;
-    }
-
-    private void run_build_tool_dialog (int num)
-    {
-        if (BuildToolDialog.show_me (get_transient_for (), num))
-            update_build_tools_store ();
-    }
 }
diff --git a/src/ui/preferences_dialog.ui b/src/ui/preferences_dialog.ui
index 4a35b6f..f7c830d 100644
--- a/src/ui/preferences_dialog.ui
+++ b/src/ui/preferences_dialog.ui
@@ -1,11 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <!-- interface-requires gtk+ 3.0 -->
-  <object class="GtkImage" id="image1">
-    <property name="visible">True</property>
-    <property name="can_focus">False</property>
-    <property name="stock">gtk-clear</property>
-  </object>
   <object class="GtkWindow" id="window1">
     <property name="can_focus">False</property>
     <child>
@@ -338,7 +333,7 @@
                         <property name="can_focus">True</property>
                         <property name="receives_default">True</property>
                         <property name="use_action_appearance">False</property>
-                        <property name="preview_text"></property>
+                        <property name="preview_text"/>
                         <property name="show_preview_entry">False</property>
                         <property name="title" translatable="yes">Pick the editor font</property>
                         <property name="font_name">Sans 10</property>
@@ -442,30 +437,12 @@
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid8">
+          <object class="GtkGrid" id="grid_latex_tab">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="border_width">8</property>
             <property name="row_spacing">8</property>
             <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>
-            <child>
               <object class="GtkGrid" id="grid9">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -530,6 +507,24 @@
               </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>
+            <child>
               <object class="GtkCheckButton" id="latexmk_checkbutton">
                 <property name="label" translatable="yes">Always show all information for the Latexmk post processor</property>
                 <property name="use_action_appearance">False</property>
@@ -592,192 +587,6 @@
                 <property name="height">1</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkGrid" id="grid11">
-                <property name="visible">True</property>
-                <property name="can_focus">False</property>
-                <property name="margin_left">12</property>
-                <property name="column_spacing">6</property>
-                <child>
-                  <object class="GtkGrid" id="grid12">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="valign">start</property>
-                    <property name="row_spacing">2</property>
-                    <child>
-                      <object class="GtkButton" id="build_tool_properties">
-                        <property name="label">gtk-properties</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">0</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="build_tool_new">
-                        <property name="label">gtk-new</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </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>
-                    <child>
-                      <object class="GtkButton" id="build_tool_copy">
-                        <property name="label">gtk-copy</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">2</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="build_tool_up">
-                        <property name="label">gtk-go-up</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">3</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="build_tool_down">
-                        <property name="label">gtk-go-down</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">4</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="build_tool_delete">
-                        <property name="label">gtk-delete</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Delete one build tool</property>
-                        <property name="tooltip_text" translatable="yes">Delete one build tool</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="use_stock">True</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">5</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="build_tool_reset">
-                        <property name="label" translatable="yes">Reset</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="receives_default">True</property>
-                        <property name="has_tooltip">True</property>
-                        <property name="tooltip_markup" translatable="yes">Reset all build tools</property>
-                        <property name="tooltip_text" translatable="yes">Reset all build tools</property>
-                        <property name="use_action_appearance">False</property>
-                        <property name="image">image1</property>
-                        <property name="xalign">0</property>
-                      </object>
-                      <packing>
-                        <property name="left_attach">0</property>
-                        <property name="top_attach">6</property>
-                        <property name="width">1</property>
-                        <property name="height">1</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">0</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow2">
-                    <property name="width_request">360</property>
-                    <property name="height_request">300</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <child>
-                      <object class="GtkTreeView" id="build_tools_treeview">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="hexpand">True</property>
-                        <property name="vexpand">True</property>
-                        <property name="rules_hint">True</property>
-                        <child internal-child="selection">
-                          <object class="GtkTreeSelection" id="treeview-selection8"/>
-                        </child>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="left_attach">1</property>
-                    <property name="top_attach">0</property>
-                    <property name="width">1</property>
-                    <property name="height">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">4</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
           </object>
           <packing>
             <property name="position">2</property>
diff --git a/src/utils.vala b/src/utils.vala
index 4cb06b8..4106c52 100644
--- a/src/utils.vala
+++ b/src/utils.vala
@@ -395,6 +395,32 @@ namespace Utils
         return grid;
     }
 
+    public unowned Gtk.Window? get_toplevel_window (Widget widget)
+    {
+        unowned Widget toplevel = widget.get_toplevel ();
+
+        if (toplevel is Gtk.Window)
+            return toplevel as Gtk.Window;
+
+        return null;
+    }
+
+    private Dialog get_reset_all_confirm_dialog (Gtk.Window window, string msg)
+    {
+        Dialog dialog = new MessageDialog (window, DialogFlags.DESTROY_WITH_PARENT,
+            MessageType.QUESTION, ButtonsType.NONE, "%s", msg);
+
+        dialog.add_button (Stock.CANCEL, ResponseType.CANCEL);
+
+        Button button = new Button.with_label (_("Reset All"));
+        Image image = new Image.from_stock (Stock.CLEAR, IconSize.BUTTON);
+        button.set_image (image);
+        button.show_all ();
+        dialog.add_action_widget (button, ResponseType.YES);
+
+        return dialog;
+    }
+
 
     /*************************************************************************/
     // Misc



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