[gnome-terminal] prefs: Integrate various dialogues into one



commit 7c035d93c07ff0e270f64bd4b1399b2a575972f1
Author: Christian Persch <chpe gnome org>
Date:   Mon Jan 28 20:22:43 2013 +0100

    prefs: Integrate various dialogues into one

 po/POTFILES.in               |    1 -
 src/Makefile.am              |    1 -
 src/encodings-dialog.ui      |  237 -------------
 src/preferences.ui           |  473 ++++++++++++++++++++++---
 src/profile-editor.c         |   37 +--
 src/profile-manager.ui       |  224 ------------
 src/terminal-app.c           |  604 +--------------------------------
 src/terminal-app.h           |   12 +-
 src/terminal-encoding.c      |  307 -----------------
 src/terminal-encoding.h      |    2 -
 src/terminal-prefs.c         |  780 +++++++++++++++++++++++++++++++++++++++++-
 src/terminal-prefs.h         |    3 +-
 src/terminal-profile-utils.c |   33 ++
 src/terminal-profile-utils.h |    3 +
 src/terminal-search-dialog.c |    1 +
 src/terminal-util.c          |   50 +++-
 src/terminal-util.h          |    4 +
 src/terminal-window.c        |   13 -
 src/terminal.gresource.xml   |    2 -
 src/terminal.xml             |    1 -
 20 files changed, 1308 insertions(+), 1480 deletions(-)
---
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 42b4cce..bccb928 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -8,7 +8,6 @@ src/profile-editor.c
 src/org.gnome.Terminal.gschema.xml.in
 [type: gettext/glade]src/find-dialog.ui
 [type: gettext/glade]src/preferences.ui
-[type: gettext/glade]src/profile-manager.ui
 [type: gettext/glade]src/profile-preferences.ui
 [type: gettext/glade]src/terminal-appmenu.ui
 src/server.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 100975e..f736f81 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -301,7 +301,6 @@ EXTRA_DIST = \
 	encodings-dialog.ui \
 	find-dialog.ui \
 	preferences.ui \
-	profile-manager.ui \
 	profile-preferences.ui \
 	$(about_DATA) \
 	$(uimanager_DATA) \
diff --git a/src/preferences.ui b/src/preferences.ui
index dc20f7c..967eaef 100644
--- a/src/preferences.ui
+++ b/src/preferences.ui
@@ -58,97 +58,460 @@
           </packing>
         </child>
         <child>
-          <object class="GtkTable" id="table32">
+          <object class="GtkNotebook" id="notebook1">
             <property name="visible">True</property>
-            <property name="can_focus">False</property>
+            <property name="can_focus">True</property>
             <property name="border_width">5</property>
-            <property name="n_rows">5</property>
-            <property name="column_spacing">12</property>
-            <property name="row_spacing">6</property>
             <child>
-              <object class="GtkCheckButton" id="disable-mnemonics-checkbutton">
-                <property name="label" translatable="yes">_Enable menu access keys (such as Alt+F to open the File menu)</property>
+              <object class="GtkBox" id="general">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0.5</property>
-                <property name="draw_indicator">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkCheckButton" id="default-show-menubar-checkbutton">
+                    <property name="label" translatable="yes">Show _menubar by default in new terminals</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label1">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">General</property>
               </object>
               <packing>
-                <property name="top_attach">1</property>
-                <property name="bottom_attach">2</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
-              <object class="GtkScrolledWindow" id="scrolledwindow1">
+              <object class="GtkTable" id="keybindings">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="hscrollbar_policy">never</property>
-                <property name="shadow_type">in</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">4</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">6</property>
                 <child>
-                  <object class="GtkTreeView" id="accelerators-treeview">
+                  <object class="GtkCheckButton" id="disable-mnemonics-checkbutton">
+                    <property name="label" translatable="yes">_Enable menu access keys (such as Alt+F to open the File menu)</property>
                     <property name="visible">True</property>
                     <property name="can_focus">True</property>
-                    <property name="rules_hint">True</property>
-                    <child internal-child="selection">
-                      <object class="GtkTreeSelection" id="treeview-selection1"/>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="accelerators-treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="rules_hint">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection"/>
+                        </child>
+                      </object>
                     </child>
                   </object>
+                  <packing>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="disable-menu-accel-checkbutton">
+                    <property name="label" translatable="yes">Enable the _menu shortcut key (F10 by default)</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label59">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Shortcut keys:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">accelerators-treeview</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="top_attach">4</property>
-                <property name="bottom_attach">5</property>
+                <property name="position">1</property>
               </packing>
             </child>
-            <child>
-              <object class="GtkCheckButton" id="disable-menu-accel-checkbutton">
-                <property name="label" translatable="yes">Enable the _menu shortcut key (F10 by default)</property>
+            <child type="tab">
+              <object class="GtkLabel" id="label2">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0.5</property>
-                <property name="draw_indicator">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Keybindings</property>
               </object>
               <packing>
-                <property name="top_attach">2</property>
-                <property name="bottom_attach">3</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label59">
+              <object class="GtkVBox" id="profiles">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xalign">0</property>
-                <property name="label" translatable="yes">_Shortcut keys:</property>
-                <property name="use_underline">True</property>
-                <property name="mnemonic_widget">accelerators-treeview</property>
+                <property name="border_width">12</property>
+                <property name="spacing">6</property>
+                <child>
+                  <object class="GtkHBox" id="hbox25">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">6</property>
+                    <child>
+                      <object class="GtkScrolledWindow" id="profiles-treeview-container">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <property name="hscrollbar_policy">never</property>
+                        <property name="shadow_type">in</property>
+                        <child>
+                          <placeholder/>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">True</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkVButtonBox" id="vbuttonbox1">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <property name="layout_style">start</property>
+                        <child>
+                          <object class="GtkButton" id="new-profile-button">
+                            <property name="label">gtk-new</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="can_default">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="clone-profile-button">
+                            <property name="label">_Clone</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="can_default">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="edit-profile-button">
+                            <property name="label">gtk-edit</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="can_default">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">2</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="delete-profile-button">
+                            <property name="label">gtk-delete</property>
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="can_default">True</property>
+                            <property name="receives_default">True</property>
+                            <property name="use_stock">True</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">True</property>
+                            <property name="position">3</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">True</property>
+                    <property name="fill">True</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="default-profile-hbox">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkLabel" id="default-profile-label">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="xalign">0</property>
+                        <property name="label" translatable="yes">_Profile used when launching a new terminal:</property>
+                        <property name="use_underline">True</property>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">True</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
-                <property name="top_attach">3</property>
-                <property name="bottom_attach">4</property>
-                <property name="x_options">GTK_FILL</property>
-                <property name="y_options"></property>
+                <property name="position">2</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Profiles</property>
+              </object>
+              <packing>
+                <property name="position">2</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
-              <object class="GtkCheckButton" id="default-show-menubar-checkbutton">
-                <property name="label" translatable="yes">Show _menubar by default in new terminals</property>
+              <object class="GtkTable" id="encodings">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">12</property>
+                <property name="n_rows">2</property>
+                <property name="n_columns">3</property>
+                <property name="column_spacing">12</property>
+                <property name="row_spacing">6</property>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="available-treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <accessibility>
+                          <relation type="labelled-by" target="available-label"/>
+                        </accessibility>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection1"/>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkHBox" id="hbox27">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <child>
+                      <object class="GtkVBox" id="vbox87">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkButton" id="add-button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <child>
+                              <object class="GtkImage" id="image3">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="stock">gtk-go-forward</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkButton" id="remove-button">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="receives_default">True</property>
+                            <child>
+                              <object class="GtkImage" id="image4">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="stock">gtk-go-back</property>
+                              </object>
+                            </child>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">True</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options"></property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="available-label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">A_vailable encodings:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">available-treeview</property>
+                    <accessibility>
+                      <relation type="label-for" target="available-treeview"/>
+                    </accessibility>
+                  </object>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="displayed-label">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">E_ncodings shown in menu:</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">displayed-treeview</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow3">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">never</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="displayed-treeview">
+                        <property name="visible">True</property>
+                        <property name="can_focus">True</property>
+                        <child internal-child="selection">
+                          <object class="GtkTreeSelection" id="treeview-selection2"/>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">3</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label4">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Encodings</property>
               </object>
               <packing>
-                <property name="y_options">GTK_FILL</property>
+                <property name="position">3</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
           </object>
diff --git a/src/profile-editor.c b/src/profile-editor.c
index 1027035..3302cad 100644
--- a/src/profile-editor.c
+++ b/src/profile-editor.c
@@ -548,39 +548,6 @@ scroll_event_cb (GtkWidget      *widget,
   return FALSE;
 }
 
-static void
-terminal_profile_editor_focus_widget (GtkWidget *editor,
-                                      const char *widget_name)
-{
-  GtkBuilder *builder;
-  GtkWidget *widget, *page, *page_parent;
-
-  if (widget_name == NULL)
-    return;
-
-  builder = g_object_get_data (G_OBJECT (editor), "builder");
-  widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name));
-  if (widget == NULL)
-    return;
-
-  page = widget;
-  while (page != NULL &&
-         (page_parent = gtk_widget_get_parent (page)) != NULL &&
-         !GTK_IS_NOTEBOOK (page_parent))
-    page = page_parent;
-
-  page_parent = gtk_widget_get_parent (page);
-  if (page != NULL && GTK_IS_NOTEBOOK (page_parent)) {
-    GtkNotebook *notebook;
-
-    notebook = GTK_NOTEBOOK (page_parent);
-    gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, page));
-  }
-
-  if (gtk_widget_is_sensitive (widget))
-    gtk_widget_grab_focus (widget);
-}
-
 static gboolean
 string_to_window_title (GValue *value,
                         GVariant *variant,
@@ -716,7 +683,7 @@ terminal_profile_edit (GSettings  *profile,
   editor = g_object_get_data (G_OBJECT (profile), "editor-window");
   if (editor)
     {
-      terminal_profile_editor_focus_widget (editor, widget_name);
+      terminal_util_dialog_focus_widget (editor, widget_name);
 
       gtk_window_set_transient_for (GTK_WINDOW (editor),
                                     GTK_WINDOW (transient_parent));
@@ -1023,7 +990,7 @@ terminal_profile_edit (GSettings  *profile,
 
   terminal_util_bind_mnemonic_label_sensitivity (editor);
 
-  terminal_profile_editor_focus_widget (editor, widget_name);
+  terminal_util_dialog_focus_widget (editor, widget_name);
 
   gtk_window_set_transient_for (GTK_WINDOW (editor),
                                 GTK_WINDOW (transient_parent));
diff --git a/src/terminal-app.c b/src/terminal-app.c
index 5fd8c42..6d51603 100644
--- a/src/terminal-app.c
+++ b/src/terminal-app.c
@@ -76,13 +76,6 @@ struct _TerminalApp
   GDBusObjectManagerServer *object_manager;
 
   GtkWidget *new_profile_dialog;
-  GtkWidget *manage_profiles_dialog;
-  GtkWidget *manage_profiles_list;
-  GtkWidget *manage_profiles_new_button;
-  GtkWidget *manage_profiles_edit_button;
-  GtkWidget *manage_profiles_clone_button;
-  GtkWidget *manage_profiles_delete_button;
-  GtkWidget *manage_profiles_default_menu;
 
   GHashTable *profiles_hash;
 
@@ -104,12 +97,6 @@ enum
 
 static guint signals[LAST_SIGNAL];
 
-enum
-{
-  COL_PROFILE,
-  NUM_COLUMNS
-};
-
 /* Helper functions */
 
 static void
@@ -195,38 +182,6 @@ strv_remove (char **strv,
   return strv;
 }
 
-static int
-profiles_alphabetic_cmp (gconstpointer pa,
-                         gconstpointer pb)
-{
-  GSettings *a = (GSettings *) pa;
-  GSettings *b = (GSettings *) pb;
-  const char *na, *nb;
-  char *patha, *pathb;
-  int result;
-
-  if (pa == pb)
-    return 0;
-  if (pa == NULL)
-    return 1;
-  if (pb == NULL)
-    return -1;
-
-  g_settings_get (a, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &na);
-  g_settings_get (b, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &nb);
-  result =  g_utf8_collate (na, nb);
-  if (result != 0)
-    return result;
-
-  g_object_get (a, "path", &patha, NULL);
-  g_object_get (b, "path", &pathb, NULL);
-  result = strcmp (patha, pathb);
-  g_free (patha);
-  g_free (pathb);
-
-  return result;
-}
-
 static GSettings * /* ref */
 profile_clone (TerminalApp *app,
                GSettings *base_profile)
@@ -357,9 +312,9 @@ profile_clone (TerminalApp *app,
   return g_object_ref (profile);
 }
 
-static void
-profile_remove (TerminalApp *app,
-                GSettings *profile)
+void
+terminal_app_remove_profile (TerminalApp *app,
+                             GSettings *profile)
 {
   char *uuid, *path;
   char **profiles;
@@ -387,421 +342,18 @@ profile_remove (TerminalApp *app,
   g_free (path);
 }
 
-static void
-terminal_app_profile_cell_data_func (GtkTreeViewColumn *tree_column,
-                                     GtkCellRenderer *cell,
-                                     GtkTreeModel *tree_model,
-                                     GtkTreeIter *iter,
-                                     gpointer data)
+gboolean
+terminal_app_can_remove_profile (TerminalApp *app,
+                                 GSettings *profile)
 {
-  GSettings *profile;
-  const char *text;
-  char *uuid;
-  GValue value = { 0, };
-
-  gtk_tree_model_get (tree_model, iter, (int) COL_PROFILE, &profile, (int) -1);
-  g_settings_get (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &text);
-  uuid = terminal_profile_util_get_profile_uuid (profile);
-
-  g_value_init (&value, G_TYPE_STRING);
-  g_value_take_string (&value,
-                       g_markup_printf_escaped ("%s\n<span size=\"small\" font_family=\"monospace\">%s</span>",
-                                                strlen (text) > 0 ? text : _("Unnamed"), 
-                                                uuid));
-  g_free (uuid);
-  g_object_set_property (G_OBJECT (cell), "markup", &value);
-  g_value_unset (&value);
-
-  g_object_unref (profile);
+  return g_hash_table_size (app->profiles_hash) > 1;
 }
 
-static int
-terminal_app_profile_sort_func (GtkTreeModel *model,
-                                GtkTreeIter *a,
-                                GtkTreeIter *b,
-                                gpointer user_data)
-{
-  GSettings *profile_a, *profile_b;
-  int retval;
-
-  gtk_tree_model_get (model, a, (int) COL_PROFILE, &profile_a, (int) -1);
-  gtk_tree_model_get (model, b, (int) COL_PROFILE, &profile_b, (int) -1);
-
-  retval = profiles_alphabetic_cmp (profile_a, profile_b);
-
-  g_object_unref (profile_a);
-  g_object_unref (profile_b);
-
-  return retval;
-}
-
-static /* ref */ GtkTreeModel *
-terminal_app_get_profile_liststore (TerminalApp *app,
-                                    GSettings *selected_profile,
-                                    GtkTreeIter *selected_profile_iter,
-                                    gboolean *selected_profile_iter_set)
-{
-  GtkListStore *store;
-  GtkTreeIter iter;
-  GHashTableIter ht_iter;
-  gpointer value;
-
-  G_STATIC_ASSERT (NUM_COLUMNS == 1);
-  store = gtk_list_store_new (NUM_COLUMNS, G_TYPE_SETTINGS);
-
-  if (selected_profile_iter)
-    *selected_profile_iter_set = FALSE;
-
-  g_hash_table_iter_init (&ht_iter, app->profiles_hash);
-  while (g_hash_table_iter_next (&ht_iter, NULL, &value))
-    {
-      GSettings *profile = (GSettings *) value;
-
-      gtk_list_store_insert_with_values (store, &iter, 0,
-                                         (int) COL_PROFILE, profile,
-                                         (int) -1);
-
-      if (selected_profile_iter && profile == selected_profile)
-        {
-          *selected_profile_iter = iter;
-          *selected_profile_iter_set = TRUE;
-        }
-    }
-
-  /* Now turn on sorting */
-  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
-                                   COL_PROFILE,
-                                   terminal_app_profile_sort_func,
-                                   NULL, NULL);
-  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
-                                        COL_PROFILE, GTK_SORT_ASCENDING);
-
-  return GTK_TREE_MODEL (store);
-}
-
-static /* ref */ GSettings*
-profile_combo_box_ref_selected (GtkWidget *widget)
-{
-  GtkComboBox *combo = GTK_COMBO_BOX (widget);
-  GSettings *profile;
-  GtkTreeIter iter;
-
-  if (gtk_combo_box_get_active_iter (combo, &iter))
-    gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
-                        (int) COL_PROFILE, &profile, (int) -1);
-  else
-    profile = NULL;
-
-  return profile;
-}
-
-static void
-profile_combo_box_refill (TerminalApp *app,
-                          GtkWidget *widget)
-{
-  GtkComboBox *combo = GTK_COMBO_BOX (widget);
-  GtkTreeIter iter;
-  gboolean iter_set;
-  GSettings *selected_profile;
-  GtkTreeModel *model;
-
-  selected_profile = profile_combo_box_ref_selected (widget);
-
-  model = terminal_app_get_profile_liststore (app,
-                                              selected_profile,
-                                              &iter,
-                                              &iter_set);
-  gtk_combo_box_set_model (combo, model);
-  g_object_unref (model);
-
-  if (iter_set)
-    gtk_combo_box_set_active_iter (combo, &iter);
-
-  if (selected_profile)
-    g_object_unref (selected_profile);
-}
-
-static GtkWidget*
-profile_combo_box_new (TerminalApp *app)
-{
-  GtkWidget *combo_widget;
-  GtkComboBox *combo;
-  GtkCellRenderer *renderer;
-  GtkTreeIter iter;
-  gboolean iter_set;
-  GSettings *default_profile;
-  GtkTreeModel *model;
-
-  combo_widget = gtk_combo_box_new ();
-  combo = GTK_COMBO_BOX (combo_widget);
-  terminal_util_set_atk_name_description (combo_widget, NULL, _("Click button to choose profile"));
-
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
-  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer,
-                                      (GtkCellLayoutDataFunc) terminal_app_profile_cell_data_func,
-                                      NULL, NULL);
-
-  default_profile = terminal_app_ref_profile_by_uuid (app, NULL, NULL);
-  model = terminal_app_get_profile_liststore (app,
-                                              default_profile,
-                                              &iter,
-                                              &iter_set);
-  gtk_combo_box_set_model (combo, model);
-  g_object_unref (model);
-
-  if (iter_set)
-    gtk_combo_box_set_active_iter (combo, &iter);
-
-  if (default_profile)
-    g_object_unref (default_profile);
-
-  g_signal_connect (app, "profile-list-changed",
-                    G_CALLBACK (profile_combo_box_refill), combo);
-
-  gtk_widget_show (combo_widget);
-  return combo_widget;
-}
-
-static void
-profile_combo_box_changed_cb (GtkWidget *widget,
-                              TerminalApp *app)
-{
-  GSettings *profile;
-  char *uuid;
-
-  profile = profile_combo_box_ref_selected (widget);
-  if (!profile)
-    return;
-
-  uuid = terminal_profile_util_get_profile_uuid (profile);
-  g_settings_set_string (app->global_settings, TERMINAL_SETTING_DEFAULT_PROFILE_KEY, uuid);
-
-  g_free (uuid);
-  g_object_unref (profile);
-}
-
-static void
-profile_list_treeview_refill (TerminalApp *app,
-                              GtkWidget *widget)
-{
-  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
-  GtkTreeIter iter;
-  gboolean iter_set;
-  GtkTreeSelection *selection;
-  GtkTreeModel *model;
-  GSettings *selected_profile = NULL;
-
-  model = gtk_tree_view_get_model (tree_view);
-
-  selection = gtk_tree_view_get_selection (tree_view);
-  if (gtk_tree_selection_get_selected (selection, NULL, &iter))
-    gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
-
-  model = terminal_app_get_profile_liststore (terminal_app_get (),
-                                              selected_profile,
-                                              &iter,
-                                              &iter_set);
-  gtk_tree_view_set_model (tree_view, model);
-  g_object_unref (model);
-
-  if (!iter_set)
-    iter_set = gtk_tree_model_get_iter_first (model, &iter);
-
-  if (iter_set)
-    gtk_tree_selection_select_iter (selection, &iter);
-
-  if (selected_profile)
-    g_object_unref (selected_profile);
-}
-
-static GtkWidget*
-profile_list_treeview_create (TerminalApp *app)
-{
-  GtkWidget *tree_view;
-  GtkTreeSelection *selection;
-  GtkCellRenderer *renderer;
-  GtkTreeViewColumn *column;
-
-  tree_view = gtk_tree_view_new ();
-  terminal_util_set_atk_name_description (tree_view, _("Profile list"), NULL);
-  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
-  gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
-                               GTK_SELECTION_BROWSE);
-
-  column = gtk_tree_view_column_new ();
-  renderer = gtk_cell_renderer_text_new ();
-  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE);
-  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
-                                      (GtkCellLayoutDataFunc) terminal_app_profile_cell_data_func,
-                                      NULL, NULL);
-  gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
-                               GTK_TREE_VIEW_COLUMN (column));
-
-  return tree_view;
-}
-
-static void
-profile_list_delete_confirm_response_cb (GtkWidget *dialog,
-                                         int response,
-                                         TerminalApp *app)
-{
-  GSettings *profile;
-
-  profile = (GSettings *) g_object_get_data (G_OBJECT (dialog), "profile");
-  g_assert (profile != NULL);
-
-  if (response == GTK_RESPONSE_ACCEPT)
-    profile_remove (app, profile);
-
-  gtk_widget_destroy (dialog);
-}
-
-static void
-profile_list_delete_button_clicked_cb (GtkWidget *button,
-                                       GtkWidget *widget)
-{
-  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
-  TerminalApp *app = terminal_app_get ();
-  GtkTreeSelection *selection;
-  GtkWidget *dialog;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-  GSettings *selected_profile;
-  GtkWidget *transient_parent;
-  const char *name;
-
-  model = gtk_tree_view_get_model (tree_view);
-  selection = gtk_tree_view_get_selection (tree_view);
-
-  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
-    return;
-
-  gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
-
-  transient_parent = gtk_widget_get_toplevel (widget);
-  g_settings_get (selected_profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &name);
-  dialog = gtk_message_dialog_new (GTK_WINDOW (transient_parent),
-                                   GTK_DIALOG_DESTROY_WITH_PARENT,
-                                   GTK_MESSAGE_QUESTION,
-                                   GTK_BUTTONS_NONE,
-                                   _("Delete profile â%sâ?"),
-                                   name);
-
-  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
-                          GTK_STOCK_CANCEL,
-                          GTK_RESPONSE_REJECT,
-                          GTK_STOCK_DELETE,
-                          GTK_RESPONSE_ACCEPT,
-                          NULL);
-  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
-                                           GTK_RESPONSE_ACCEPT,
-                                           GTK_RESPONSE_REJECT,
-                                           -1);
-  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
-                                   GTK_RESPONSE_ACCEPT);
-
-  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Profile"));
-  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
-
-  /* Transfer refcount of |selected_profile|, so no unref below */
-  g_object_set_data_full (G_OBJECT (dialog), "profile", selected_profile, g_object_unref);
-
-  g_signal_connect (dialog, "response",
-                    G_CALLBACK (profile_list_delete_confirm_response_cb),
-                    app);
-
-  gtk_window_present (GTK_WINDOW (dialog));
-}
-
-static void
-profile_list_new_button_clicked_cb (GtkWidget   *button,
-                                    gpointer data)
-{
-  TerminalApp *app;
-
-  app = terminal_app_get ();
-  terminal_app_new_profile (app, NULL, GTK_WINDOW (app->manage_profiles_dialog));
-}
-
-static void
-profile_list_clone_button_clicked_cb (GtkWidget *button,
-                                      GtkWidget *widget)
-{
-  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
-  GtkTreeSelection *selection;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-  GSettings *selected_profile;
-  TerminalApp *app;
-
-  app = terminal_app_get ();
-
-  model = gtk_tree_view_get_model (tree_view);
-  selection = gtk_tree_view_get_selection (tree_view);
-
-  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
-    return;
-
-  gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
-
-  terminal_app_new_profile (app, selected_profile, GTK_WINDOW (app->manage_profiles_dialog));
-  g_object_unref (selected_profile);
-}
-
-static void
-profile_list_edit_button_clicked_cb (GtkWidget *button,
-                                     GtkWidget *widget)
-{
-  GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
-  GtkTreeSelection *selection;
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-  GSettings *selected_profile;
-  TerminalApp *app;
-
-  app = terminal_app_get ();
-
-  model = gtk_tree_view_get_model (tree_view);
-  selection = gtk_tree_view_get_selection (tree_view);
-
-  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
-    return;
-
-  gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
-
-  terminal_app_edit_profile (app, selected_profile,
-                             GTK_WINDOW (app->manage_profiles_dialog),
-                             NULL);
-  g_object_unref (selected_profile);
-}
-
-static void
-profile_list_row_activated_cb (GtkTreeView       *tree_view,
-                               GtkTreePath       *path,
-                               GtkTreeViewColumn *column,
-                               gpointer data)
+void
+terminal_app_get_profiles_iter (TerminalApp *app,
+                                GHashTableIter *iter)
 {
-  GtkTreeIter iter;
-  GtkTreeModel *model;
-  GSettings *selected_profile;
-  TerminalApp *app;
-
-  app = terminal_app_get ();
-
-  model = gtk_tree_view_get_model (tree_view);
-
-  if (!gtk_tree_model_get_iter (model, &iter, path))
-    return;
-
-  gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
-
-  terminal_app_edit_profile (app, selected_profile,
-                             GTK_WINDOW (app->manage_profiles_dialog),
-                             NULL);
-  g_object_unref (selected_profile);
+  g_hash_table_iter_init (iter, app->profiles_hash);
 }
 
 static void
@@ -932,134 +484,6 @@ terminal_app_new_profile (TerminalApp *app,
   g_object_unref (new_profile);
 }
 
-static void
-profile_list_selection_changed_cb (GtkTreeSelection *selection,
-                                   TerminalApp *app)
-{
-  gboolean selected;
-
-  selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
-
-  gtk_widget_set_sensitive (app->manage_profiles_edit_button, selected);
-  gtk_widget_set_sensitive (app->manage_profiles_clone_button, selected);
-  gtk_widget_set_sensitive (app->manage_profiles_delete_button,
-                            selected &&
-                            g_hash_table_size (app->profiles_hash) > 1);
-}
-
-static void
-profile_list_response_cb (GtkWidget *dialog,
-                          int        id,
-                          TerminalApp *app)
-{
-  g_assert (app->manage_profiles_dialog == dialog);
-
-  if (id == GTK_RESPONSE_HELP)
-    {
-      terminal_util_show_help ("gnome-terminal-manage-profiles", GTK_WINDOW (dialog));
-      return;
-    }
-
-  gtk_widget_destroy (dialog);
-}
-
-static void
-profile_list_destroyed_cb (GtkWidget   *manage_profiles_dialog,
-                           TerminalApp *app)
-{
-  g_signal_handlers_disconnect_by_func (app, G_CALLBACK (profile_list_treeview_refill), app->manage_profiles_list);
-  g_signal_handlers_disconnect_by_func (app, G_CALLBACK (profile_combo_box_refill), app->manage_profiles_default_menu);
-
-  app->manage_profiles_dialog = NULL;
-  app->manage_profiles_list = NULL;
-  app->manage_profiles_new_button = NULL;
-  app->manage_profiles_edit_button = NULL;
-  app->manage_profiles_clone_button = NULL;
-  app->manage_profiles_delete_button = NULL;
-  app->manage_profiles_default_menu = NULL;
-}
-
-void
-terminal_app_manage_profiles (TerminalApp     *app,
-                              GtkWindow       *transient_parent)
-{
-  GObject *dialog;
-  GObject *tree_view_container, *new_button, *edit_button, *clone_button, *remove_button;
-  GObject *default_hbox, *default_label;
-  GtkTreeSelection *selection;
-
-  if (app->manage_profiles_dialog)
-    {
-      gtk_window_set_transient_for (GTK_WINDOW (app->manage_profiles_dialog), transient_parent);
-      gtk_window_present (GTK_WINDOW (app->manage_profiles_dialog));
-      return;
-    }
-
-  terminal_util_load_builder_resource ("/org/gnome/terminal/ui/profile-manager.ui",
-                                       "profile-manager", &dialog,
-                                       "profiles-treeview-container", &tree_view_container,
-                                       "new-profile-button", &new_button,
-                                       "edit-profile-button", &edit_button,
-                                       "clone-profile-button", &clone_button,
-                                       "delete-profile-button", &remove_button,
-                                       "default-profile-hbox", &default_hbox,
-                                       "default-profile-label", &default_label,
-                                       NULL);
-
-  app->manage_profiles_dialog = GTK_WIDGET (dialog);
-  app->manage_profiles_new_button = GTK_WIDGET (new_button);
-  app->manage_profiles_edit_button = GTK_WIDGET (edit_button);
-  app->manage_profiles_clone_button = GTK_WIDGET (clone_button);
-  app->manage_profiles_delete_button  = GTK_WIDGET (remove_button);
-
-  g_signal_connect (dialog, "response", G_CALLBACK (profile_list_response_cb), app);
-  g_signal_connect (dialog, "destroy", G_CALLBACK (profile_list_destroyed_cb), app);
-
-  app->manage_profiles_list = profile_list_treeview_create (app);
-
-  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (app->manage_profiles_list));
-  g_signal_connect (selection, "changed", G_CALLBACK (profile_list_selection_changed_cb), app);
-
-  profile_list_treeview_refill (app, app->manage_profiles_list);
-  g_signal_connect (app, "profile-list-changed",
-                    G_CALLBACK (profile_list_treeview_refill), app->manage_profiles_list);
-
-  g_signal_connect (app->manage_profiles_list, "row-activated",
-                    G_CALLBACK (profile_list_row_activated_cb), app);
-
-  gtk_container_add (GTK_CONTAINER (tree_view_container), app->manage_profiles_list);
-  gtk_widget_show (app->manage_profiles_list);
-
-  g_signal_connect (new_button, "clicked",
-                    G_CALLBACK (profile_list_new_button_clicked_cb),
-                    app->manage_profiles_list);
-  g_signal_connect (edit_button, "clicked",
-                    G_CALLBACK (profile_list_edit_button_clicked_cb),
-                    app->manage_profiles_list);
-  g_signal_connect (clone_button, "clicked",
-                    G_CALLBACK (profile_list_clone_button_clicked_cb),
-                    app->manage_profiles_list);
-  g_signal_connect (remove_button, "clicked",
-                    G_CALLBACK (profile_list_delete_button_clicked_cb),
-                    app->manage_profiles_list);
-
-  app->manage_profiles_default_menu = profile_combo_box_new (app);
-  g_signal_connect (app->manage_profiles_default_menu, "changed",
-                    G_CALLBACK (profile_combo_box_changed_cb), app);
-
-  gtk_box_pack_start (GTK_BOX (default_hbox), app->manage_profiles_default_menu, FALSE, FALSE, 0);
-  gtk_widget_show (app->manage_profiles_default_menu);
-
-  gtk_label_set_mnemonic_widget (GTK_LABEL (default_label), app->manage_profiles_default_menu);
-
-  gtk_widget_grab_focus (app->manage_profiles_list);
-
-  gtk_window_set_transient_for (GTK_WINDOW (app->manage_profiles_dialog),
-                                transient_parent);
-
-  gtk_window_present (GTK_WINDOW (app->manage_profiles_dialog));
-}
-
 /* App menu callbacks */
 
 static void
@@ -1357,14 +781,14 @@ void
 terminal_app_edit_preferences (TerminalApp     *app,
                                GtkWindow       *transient_parent)
 {
-  terminal_prefs_show_preferences (transient_parent);
+  terminal_prefs_show_preferences (transient_parent, "general");
 }
 
 void
 terminal_app_edit_encodings (TerminalApp     *app,
                              GtkWindow       *transient_parent)
 {
-  terminal_encoding_dialog_show (transient_parent);
+  terminal_prefs_show_preferences (transient_parent, "encodings");
 }
 
 /**
@@ -1380,7 +804,7 @@ terminal_app_get_profile_list (TerminalApp *app)
 {
   g_return_val_if_fail (TERMINAL_IS_APP (app), NULL);
 
-  return g_list_sort (g_hash_table_get_values (app->profiles_hash), profiles_alphabetic_cmp);
+  return g_list_sort (g_hash_table_get_values (app->profiles_hash), terminal_profile_util_profiles_compare);
 }
 
 /**
diff --git a/src/terminal-app.h b/src/terminal-app.h
index 1820b94..7911695 100644
--- a/src/terminal-app.h
+++ b/src/terminal-app.h
@@ -61,6 +61,12 @@ void terminal_app_new_profile (TerminalApp *app,
                                GSettings   *default_base_profile,
                                GtkWindow   *transient_parent);
 
+gboolean terminal_app_can_remove_profile (TerminalApp *app,
+                                          GSettings *profile);
+
+void terminal_app_remove_profile (TerminalApp *app,
+                                  GSettings *profile);
+
 TerminalWindow * terminal_app_new_window   (TerminalApp *app,
                                             GdkScreen *screen);
 
@@ -73,9 +79,6 @@ TerminalScreen *terminal_app_new_terminal (TerminalApp     *app,
                                            char           **child_env,
                                            double           zoom);
 
-void terminal_app_manage_profiles (TerminalApp     *app,
-                                   GtkWindow       *transient_parent);
-
 void terminal_app_edit_preferences (TerminalApp     *app,
                                     GtkWindow       *transient_parent);
 void terminal_app_edit_encodings   (TerminalApp     *app,
@@ -83,6 +86,9 @@ void terminal_app_edit_encodings   (TerminalApp     *app,
 
 GList* terminal_app_get_profile_list (TerminalApp *app);
 
+void terminal_app_get_profiles_iter (TerminalApp *app,
+                                     GHashTableIter *iter);
+
 GSettings* terminal_app_ref_profile_by_uuid (TerminalApp *app,
                                              const char  *uuid,
                                              GError **error);
diff --git a/src/terminal-encoding.c b/src/terminal-encoding.c
index fe5ba64..37b2c76 100644
--- a/src/terminal-encoding.c
+++ b/src/terminal-encoding.c
@@ -128,21 +128,6 @@ static const struct {
 #endif
 };
 
-typedef struct {
-  GtkWidget *dialog;
-  GtkListStore *base_store;
-  GtkTreeView *available_tree_view;
-  GtkTreeSelection *available_selection;
-  GtkTreeModel *available_model;
-  GtkTreeView *active_tree_view;
-  GtkTreeSelection *active_selection;
-  GtkTreeModel *active_model;
-  GtkWidget *add_button;
-  GtkWidget *remove_button;
-} EncodingDialogData;
-
-static GtkWidget *encoding_dialog = NULL;
-
 TerminalEncoding *
 terminal_encoding_new (const char *charset,
                        const char *display_name,
@@ -270,298 +255,6 @@ G_DEFINE_BOXED_TYPE (TerminalEncoding, terminal_encoding,
                      terminal_encoding_ref,
                      terminal_encoding_unref);
 
-static void
-update_active_encodings_setting (void)
-{
-  TerminalApp *app;
-  GSList *list, *l;
-  GVariantBuilder builder;
-  GSettings *settings;
-
-  app = terminal_app_get ();
-
-  g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
-
-  list = terminal_app_get_active_encodings (app);
-  for (l = list; l != NULL; l = l->next)
-    {
-      TerminalEncoding *encoding = (TerminalEncoding *) l->data;
-
-      g_variant_builder_add (&builder, "s", terminal_encoding_get_id (encoding));
-    }
-  g_slist_foreach (list, (GFunc) terminal_encoding_unref, NULL);
-  g_slist_free (list);
-
-  settings = terminal_app_get_global_settings (app);
-  g_settings_set (settings, TERMINAL_SETTING_ENCODINGS_KEY, "as", &builder);
-}
-
-static void
-response_callback (GtkWidget *window,
-                   int        id,
-                   EncodingDialogData *data)
-{
-  if (id == GTK_RESPONSE_HELP)
-    terminal_util_show_help ("gnome-terminal-encoding-add", GTK_WINDOW (window));
-  else
-    gtk_widget_destroy (GTK_WIDGET (window));
-}
-
-enum
-{
-  COLUMN_NAME,
-  COLUMN_CHARSET,
-  COLUMN_DATA,
-  N_COLUMNS
-};
-
-static void
-selection_changed_cb (GtkTreeSelection *selection,
-                      EncodingDialogData *data)
-{
-  GtkWidget *button;
-  gboolean have_selection;
-
-  if (selection == data->available_selection)
-    button = data->add_button;
-  else if (selection == data->active_selection)
-    button = data->remove_button;
-  else
-    g_assert_not_reached ();
-
-  have_selection = gtk_tree_selection_get_selected (selection, NULL, NULL);
-  gtk_widget_set_sensitive (button, have_selection);
-}
-
-static void
-button_clicked_cb (GtkWidget *button,
-                   EncodingDialogData *data)
-{
-  GtkTreeSelection *selection;
-  GtkTreeModel *model;
-  GtkTreeIter filter_iter, iter;
-  TerminalEncoding *encoding;
-
-  if (button == data->add_button)
-    selection = data->available_selection;
-  else if (button == data->remove_button)
-    selection = data->active_selection;
-  else
-    g_assert_not_reached ();
-
-  if (!gtk_tree_selection_get_selected (selection, &model, &filter_iter))
-    return;
-
-  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
-                                                    &iter,
-                                                    &filter_iter);
-
-  model = GTK_TREE_MODEL (data->base_store);
-  gtk_tree_model_get (model, &iter, COLUMN_DATA, &encoding, -1);
-  g_assert (encoding != NULL);
-
-  if (button == data->add_button)
-    encoding->is_active = TRUE;
-  else if (button == data->remove_button)
-    encoding->is_active = FALSE;
-  else
-    g_assert_not_reached ();
-
-  terminal_encoding_unref (encoding);
-
-  /* We don't need to emit row-changed here, since updating the pref
-   * will update the models.
-   */
-  update_active_encodings_setting ();
-}
-
-static void
-liststore_insert_encoding (gpointer key,
-                           TerminalEncoding *encoding,
-                           GtkListStore *store)
-{
-  GtkTreeIter iter;
-
-  if (!terminal_encoding_is_valid (encoding))
-    return;
-
-  gtk_list_store_insert_with_values (store, &iter, -1,
-                                     COLUMN_CHARSET, terminal_encoding_get_charset (encoding),
-                                     COLUMN_NAME, encoding->name,
-                                     COLUMN_DATA, encoding,
-                                     -1);
-}
-
-static gboolean
-filter_active_encodings (GtkTreeModel *child_model,
-                         GtkTreeIter *child_iter,
-                         gpointer data)
-{
-  TerminalEncoding *encoding;
-  gboolean active = GPOINTER_TO_UINT (data);
-  gboolean visible;
-
-  gtk_tree_model_get (child_model, child_iter, COLUMN_DATA, &encoding, -1);
-  visible = active ? encoding->is_active : !encoding->is_active;
-  terminal_encoding_unref (encoding);
-
-  return visible;
-}
-
-static GtkTreeModel *
-encodings_create_treemodel (GtkListStore *base_store,
-                            gboolean active)
-{
-  GtkTreeModel *model;
-
-  model = gtk_tree_model_filter_new (GTK_TREE_MODEL (base_store), NULL);
-  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
-                                          filter_active_encodings,
-                                          GUINT_TO_POINTER (active), NULL);
-
-  return model;
-}
-
-static void
-encodings_list_changed_cb (TerminalApp *app,
-                           EncodingDialogData *data)
-{
-  gtk_list_store_clear (data->base_store);
-
-  g_hash_table_foreach (terminal_app_get_encodings (app), (GHFunc) liststore_insert_encoding, data->base_store);
-}
-
-static void
-encoding_dialog_data_free (EncodingDialogData *data)
-{
-  g_signal_handlers_disconnect_by_func (terminal_app_get (),
-                                        G_CALLBACK (encodings_list_changed_cb),
-                                        data);
-
-  g_free (data);
-}
-
-void
-terminal_encoding_dialog_show (GtkWindow *transient_parent)
-{
-  TerminalApp *app;
-  GtkCellRenderer *cell_renderer;
-  GtkTreeViewColumn *column;
-  GtkTreeModel *model;
-  EncodingDialogData *data;
-
-  if (encoding_dialog)
-    {
-      gtk_window_set_transient_for (GTK_WINDOW (encoding_dialog), transient_parent);
-      gtk_window_present (GTK_WINDOW (encoding_dialog));
-      return;
-    }
-
-  data = g_new (EncodingDialogData, 1);
-
-  terminal_util_load_builder_resource ("/org/gnome/terminal/ui/encodings-dialog.ui",
-                                       "encodings-dialog", &data->dialog,
-                                       "add-button", &data->add_button,
-                                       "remove-button", &data->remove_button,
-                                       "available-treeview", &data->available_tree_view,
-                                       "displayed-treeview", &data->active_tree_view,
-                                       NULL);
-
-  g_object_set_data_full (G_OBJECT (data->dialog), "GT::Data", data, (GDestroyNotify) encoding_dialog_data_free);
-
-  gtk_window_set_transient_for (GTK_WINDOW (data->dialog), transient_parent);
-  gtk_window_set_role (GTK_WINDOW (data->dialog), "gnome-terminal-encodings");
-  g_signal_connect (data->dialog, "response",
-                    G_CALLBACK (response_callback), data);
-
-  /* buttons */
-  g_signal_connect (data->add_button, "clicked",
-                    G_CALLBACK (button_clicked_cb), data);
-
-  g_signal_connect (data->remove_button, "clicked",
-                    G_CALLBACK (button_clicked_cb), data);
-  
-  /* Tree view of available encodings */
-  /* Column 1 */
-  cell_renderer = gtk_cell_renderer_text_new ();
-  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
-						     cell_renderer,
-						     "text", COLUMN_NAME,
-						     NULL);
-  gtk_tree_view_append_column (data->available_tree_view, column);
-  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
-  
-  /* Column 2 */
-  cell_renderer = gtk_cell_renderer_text_new ();
-  column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
-						     cell_renderer,
-						     "text", COLUMN_CHARSET,
-						     NULL);
-  gtk_tree_view_append_column (data->available_tree_view, column);
-  gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);  
-
-  data->available_selection = gtk_tree_view_get_selection (data->available_tree_view);
-  gtk_tree_selection_set_mode (data->available_selection, GTK_SELECTION_BROWSE);
-
-  g_signal_connect (data->available_selection, "changed",
-                    G_CALLBACK (selection_changed_cb), data);
-
-  /* Tree view of selected encodings */
-  /* Column 1 */
-  cell_renderer = gtk_cell_renderer_text_new ();
-  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
-						     cell_renderer,
-						     "text", COLUMN_NAME,
-						     NULL);
-  gtk_tree_view_append_column (data->active_tree_view, column);
-  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
-  
-  /* Column 2 */
-  cell_renderer = gtk_cell_renderer_text_new ();
-  column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
-						     cell_renderer,
-						     "text", COLUMN_CHARSET,
-						     NULL);
-  gtk_tree_view_append_column (data->active_tree_view, column);
-  gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);  
-
-  /* Add the data */
-
-  data->active_selection = gtk_tree_view_get_selection (data->active_tree_view);
-  gtk_tree_selection_set_mode (data->active_selection, GTK_SELECTION_BROWSE);
-
-  g_signal_connect (data->active_selection, "changed",
-                    G_CALLBACK (selection_changed_cb), data);
-
-  data->base_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, TERMINAL_TYPE_ENCODING);
-
-  app = terminal_app_get ();
-  encodings_list_changed_cb (app, data);
-  g_signal_connect (app, "encoding-list-changed",
-                    G_CALLBACK (encodings_list_changed_cb), data);
-
-  /* Now turn on sorting */
-  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->base_store),
-                                        COLUMN_NAME,
-                                        GTK_SORT_ASCENDING);
-  
-  model = encodings_create_treemodel (data->base_store, FALSE);
-  gtk_tree_view_set_model (data->available_tree_view, model);
-  g_object_unref (model);
-
-  model = encodings_create_treemodel (data->base_store, TRUE);
-  gtk_tree_view_set_model (data->active_tree_view, model);
-  g_object_unref (model);
-
-  g_object_unref (data->base_store);
-
-  gtk_window_present (GTK_WINDOW (data->dialog));
-
-  encoding_dialog = data->dialog;
-  g_signal_connect (data->dialog, "destroy",
-                    G_CALLBACK (gtk_widget_destroyed), &encoding_dialog);
-}
-
 GHashTable *
 terminal_encodings_get_builtins (void)
 {
diff --git a/src/terminal-encoding.h b/src/terminal-encoding.h
index 22e648a..cc686e8 100644
--- a/src/terminal-encoding.h
+++ b/src/terminal-encoding.h
@@ -54,6 +54,4 @@ const char *terminal_encoding_get_charset (TerminalEncoding *encoding);
 
 GHashTable *terminal_encodings_get_builtins (void);
 
-void terminal_encoding_dialog_show (GtkWindow *transient_parent);
-
 #endif /* TERMINAL_ENCODING_H */
diff --git a/src/terminal-prefs.c b/src/terminal-prefs.c
index 86b09bd..71a5285 100644
--- a/src/terminal-prefs.c
+++ b/src/terminal-prefs.c
@@ -20,6 +20,9 @@
 
 #include <string.h>
 
+#include <uuid.h>
+#include <dconf.h>
+
 #include <gtk/gtk.h>
 
 #include "terminal-prefs.h"
@@ -29,51 +32,686 @@
 #include "terminal-intl.h"
 #include "terminal-schemas.h"
 #include "terminal-util.h"
+#include "terminal-profile-utils.h"
+#include "terminal-encoding.h"
+
+typedef struct {
+  GtkWidget *dialog;
+  GtkWindow *parent;
+
+  GtkTreeView *manage_profiles_list;
+  GtkWidget *manage_profiles_new_button;
+  GtkWidget *manage_profiles_edit_button;
+  GtkWidget *manage_profiles_clone_button;
+  GtkWidget *manage_profiles_delete_button;
+  GtkWidget *manage_profiles_default_menu;
+
+  GtkListStore *encoding_base_store;
+  GtkTreeView *encoding_available_tree_view;
+  GtkTreeSelection *encoding_available_selection;
+  GtkTreeModel *encoding_available_model;
+  GtkTreeView *encoding_active_tree_view;
+  GtkTreeSelection *encoding_active_selection;
+  GtkTreeModel *encoding_active_model;
+  GtkWidget *encoding_add_button;
+  GtkWidget *encoding_remove_button;
+} PrefData;
 
 static GtkWidget *prefs_dialog = NULL;
 
 static void
 prefs_dialog_response_cb (GtkWidget *editor,
                           int response,
-                          gpointer use_data)
+                          PrefData *data)
 {
   if (response == GTK_RESPONSE_HELP)
     {
-      terminal_util_show_help ("gnome-terminal-shortcuts", GTK_WINDOW (editor));
+      terminal_util_show_help ("gnome-terminal-shortcuts", GTK_WINDOW (data->dialog));
+      //      terminal_util_show_help ("gnome-terminal-manage-profiles", GTK_WINDOW (data->dialog));
+      //    terminal_util_show_help ("gnome-terminal-encoding-add", GTK_WINDOW (window));
       return;
     }
 
-  gtk_widget_destroy (editor);
+  gtk_widget_destroy (data->dialog);
+}
+
+/* Profiles tab */
+
+enum
+{
+  COL_PROFILE,
+  NUM_PROFILE_COLUMNS
+};
+
+static void
+profile_cell_data_func (GtkTreeViewColumn *tree_column,
+                        GtkCellRenderer *cell,
+                        GtkTreeModel *tree_model,
+                        GtkTreeIter *iter,
+                        gpointer user_data)
+{
+  GSettings *profile;
+  const char *text;
+  char *uuid;
+  GValue value = { 0, };
+
+  gtk_tree_model_get (tree_model, iter, (int) COL_PROFILE, &profile, (int) -1);
+  g_settings_get (profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &text);
+  uuid = terminal_profile_util_get_profile_uuid (profile);
+
+  g_value_init (&value, G_TYPE_STRING);
+  g_value_take_string (&value,
+                       g_markup_printf_escaped ("%s\n<span size=\"small\" font_family=\"monospace\">%s</span>",
+                                                strlen (text) > 0 ? text : _("Unnamed"), 
+                                                uuid));
+  g_free (uuid);
+  g_object_set_property (G_OBJECT (cell), "markup", &value);
+  g_value_unset (&value);
+
+  g_object_unref (profile);
+}
+
+
+static int
+profile_sort_func (GtkTreeModel *model,
+                   GtkTreeIter *a,
+                   GtkTreeIter *b,
+                   gpointer user_data)
+{
+  GSettings *profile_a, *profile_b;
+  int retval;
+
+  gtk_tree_model_get (model, a, (int) COL_PROFILE, &profile_a, (int) -1);
+  gtk_tree_model_get (model, b, (int) COL_PROFILE, &profile_b, (int) -1);
+
+  retval = terminal_profile_util_profiles_compare (profile_a, profile_b);
+
+  g_object_unref (profile_a);
+  g_object_unref (profile_b);
+
+  return retval;
+}
+
+static /* ref */ GtkTreeModel *
+profile_liststore_new (GSettings *selected_profile,
+                       GtkTreeIter *selected_profile_iter,
+                       gboolean *selected_profile_iter_set)
+{
+  GtkListStore *store;
+  GtkTreeIter iter;
+  GHashTableIter ht_iter;
+  gpointer value;
+
+  G_STATIC_ASSERT (NUM_PROFILE_COLUMNS == 1);
+  store = gtk_list_store_new (NUM_PROFILE_COLUMNS, G_TYPE_SETTINGS);
+
+  if (selected_profile_iter)
+    *selected_profile_iter_set = FALSE;
+
+  terminal_app_get_profiles_iter (terminal_app_get (), &ht_iter);
+  while (g_hash_table_iter_next (&ht_iter, NULL, &value))
+    {
+      GSettings *profile = (GSettings *) value;
+
+      gtk_list_store_insert_with_values (store, &iter, 0,
+                                         (int) COL_PROFILE, profile,
+                                         (int) -1);
+
+      if (selected_profile_iter && profile == selected_profile)
+        {
+          *selected_profile_iter = iter;
+          *selected_profile_iter_set = TRUE;
+        }
+    }
+
+  /* Now turn on sorting */
+  gtk_tree_sortable_set_sort_func (GTK_TREE_SORTABLE (store),
+                                   COL_PROFILE,
+                                   profile_sort_func,
+                                   NULL, NULL);
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (store),
+                                        COL_PROFILE, GTK_SORT_ASCENDING);
+
+  return GTK_TREE_MODEL (store);
+}
+
+static /* ref */ GSettings*
+profile_combo_box_ref_selected (GtkWidget *widget)
+{
+  GtkComboBox *combo = GTK_COMBO_BOX (widget);
+  GSettings *profile;
+  GtkTreeIter iter;
+
+  if (gtk_combo_box_get_active_iter (combo, &iter))
+    gtk_tree_model_get (gtk_combo_box_get_model (combo), &iter,
+                        (int) COL_PROFILE, &profile, (int) -1);
+  else
+    profile = NULL;
+
+  return profile;
+}
+
+static void
+profile_combo_box_refill (GtkWidget *combo_widget)
+{
+  GtkComboBox *combo = GTK_COMBO_BOX (combo_widget);
+  GtkTreeIter iter;
+  gboolean iter_set;
+  GSettings *selected_profile;
+  GtkTreeModel *model;
+
+  selected_profile = profile_combo_box_ref_selected (combo_widget);
+
+  model = profile_liststore_new (selected_profile,
+                                 &iter,
+                                 &iter_set);
+  gtk_combo_box_set_model (combo, model);
+  g_object_unref (model);
+
+  if (iter_set)
+    gtk_combo_box_set_active_iter (combo, &iter);
+
+  if (selected_profile)
+    g_object_unref (selected_profile);
+}
+
+static GtkWidget*
+profile_combo_box_new (PrefData *data)
+{
+  GtkWidget *combo_widget;
+  GtkComboBox *combo;
+  GtkCellRenderer *renderer;
+  GtkTreeIter iter;
+  gboolean iter_set;
+  GSettings *default_profile;
+  GtkTreeModel *model;
+
+  combo_widget = gtk_combo_box_new ();
+  combo = GTK_COMBO_BOX (combo_widget);
+  terminal_util_set_atk_name_description (combo_widget, NULL, _("Click button to choose profile"));
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo), renderer,
+                                      (GtkCellLayoutDataFunc) profile_cell_data_func,
+                                      NULL, NULL);
+
+  default_profile = terminal_app_ref_profile_by_uuid (terminal_app_get (), NULL, NULL);
+  model = profile_liststore_new (default_profile,
+                                 &iter,
+                                 &iter_set);
+  gtk_combo_box_set_model (combo, model);
+  g_object_unref (model);
+
+  if (iter_set)
+    gtk_combo_box_set_active_iter (combo, &iter);
+
+  if (default_profile)
+    g_object_unref (default_profile);
+
+  g_signal_connect (terminal_app_get (), "profile-list-changed",
+                    G_CALLBACK (profile_combo_box_refill), combo);
+
+  gtk_widget_show (combo_widget);
+  return combo_widget;
+}
+
+static void
+profile_combo_box_changed_cb (GtkWidget *widget,
+                              PrefData *data)
+{
+  GSettings *profile, *settings;
+  char *uuid;
+
+  profile = profile_combo_box_ref_selected (widget);
+  if (!profile)
+    return;
+
+  uuid = terminal_profile_util_get_profile_uuid (profile);
+  settings = terminal_app_get_global_settings (terminal_app_get ());
+  g_settings_set_string (settings, TERMINAL_SETTING_DEFAULT_PROFILE_KEY, uuid);
+
+  g_free (uuid);
+  g_object_unref (profile);
+}
+
+static GSettings *
+profile_list_ref_selected (PrefData *data)
+{
+  GtkTreeSelection *selection;
+  GtkTreeIter iter;
+  GtkTreeModel *model;
+  GSettings *selected_profile;
+
+  selection = gtk_tree_view_get_selection (data->manage_profiles_list);
+  if (!gtk_tree_selection_get_selected (selection, NULL, &iter))
+    return NULL;
+
+  model = gtk_tree_view_get_model (data->manage_profiles_list);
+  gtk_tree_model_get (model, &iter, (int) COL_PROFILE, &selected_profile, (int) -1);
+  return selected_profile;
+}
+
+static void
+profile_list_treeview_refill (PrefData *data)
+{
+  GtkTreeView *tree_view = data->manage_profiles_list;
+  GtkTreeIter iter;
+  gboolean iter_set;
+  GSettings *selected_profile;
+  GtkTreeModel *model;
+
+  selected_profile = profile_list_ref_selected (data);
+  model = profile_liststore_new (selected_profile,
+                                 &iter,
+                                 &iter_set);
+  gtk_tree_view_set_model (tree_view, model);
+  g_object_unref (model);
+
+  if (!iter_set)
+    iter_set = gtk_tree_model_get_iter_first (model, &iter);
+
+  if (iter_set)
+    gtk_tree_selection_select_iter (gtk_tree_view_get_selection (tree_view), &iter);
+
+  if (selected_profile)
+    g_object_unref (selected_profile);
+}
+
+static void
+profile_list_row_activated_cb (GtkTreeView *tree_view,
+                               GtkTreePath *path,
+                               GtkTreeViewColumn *column,
+                               PrefData *data)
+{
+  GSettings *selected_profile;
+
+  selected_profile = profile_list_ref_selected (data);
+  if (selected_profile == NULL)
+    return;
+
+  terminal_app_edit_profile (terminal_app_get (),
+                             selected_profile, GTK_WINDOW (data->dialog), NULL);
+  g_object_unref (selected_profile);
+}
+
+static GtkTreeView *
+profile_list_treeview_new (PrefData *data)
+{
+  GtkWidget *tree_view;
+  GtkTreeSelection *selection;
+  GtkCellRenderer *renderer;
+  GtkTreeViewColumn *column;
+
+  tree_view = gtk_tree_view_new ();
+  terminal_util_set_atk_name_description (tree_view, _("Profile list"), NULL);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tree_view), FALSE);
+
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tree_view));
+  gtk_tree_selection_set_mode (GTK_TREE_SELECTION (selection),
+                               GTK_SELECTION_BROWSE);
+
+  column = gtk_tree_view_column_new ();
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (column), renderer, TRUE);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (column), renderer,
+                                      (GtkCellLayoutDataFunc) profile_cell_data_func,
+                                      NULL, NULL);
+  gtk_tree_view_append_column (GTK_TREE_VIEW (tree_view),
+                               GTK_TREE_VIEW_COLUMN (column));
+
+  g_signal_connect (tree_view, "row-activated",
+                    G_CALLBACK (profile_list_row_activated_cb), data);
+
+  return GTK_TREE_VIEW (tree_view);
+}
+
+static void
+profile_list_delete_confirm_response_cb (GtkWidget *dialog,
+                                         int response,
+                                         PrefData *data)
+{
+  GSettings *profile;
+
+  profile = (GSettings *) g_object_get_data (G_OBJECT (dialog), "profile");
+  g_assert (profile != NULL);
+
+  if (response == GTK_RESPONSE_ACCEPT)
+    terminal_app_remove_profile (terminal_app_get (), profile);
+
+  gtk_widget_destroy (dialog);
+}
+
+static void
+profile_list_delete_button_clicked_cb (GtkWidget *button,
+                                       PrefData *data)
+{
+  GtkWidget *dialog;
+  GSettings *selected_profile;
+  const char *name;
+
+  selected_profile = profile_list_ref_selected (data);
+  if (selected_profile == NULL)
+    return;
+
+  g_settings_get (selected_profile, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &name);
+  dialog = gtk_message_dialog_new (GTK_WINDOW (data->dialog),
+                                   GTK_DIALOG_DESTROY_WITH_PARENT,
+                                   GTK_MESSAGE_QUESTION,
+                                   GTK_BUTTONS_NONE,
+                                   _("Delete profile â%sâ?"),
+                                   name);
+
+  gtk_dialog_add_buttons (GTK_DIALOG (dialog),
+                          GTK_STOCK_CANCEL,
+                          GTK_RESPONSE_REJECT,
+                          GTK_STOCK_DELETE,
+                          GTK_RESPONSE_ACCEPT,
+                          NULL);
+  gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
+                                           GTK_RESPONSE_ACCEPT,
+                                           GTK_RESPONSE_REJECT,
+                                           -1);
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog),
+                                   GTK_RESPONSE_ACCEPT);
+
+  gtk_window_set_title (GTK_WINDOW (dialog), _("Delete Profile"));
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+
+  /* Transfer refcount of |selected_profile|, so no unref below */
+  g_object_set_data_full (G_OBJECT (dialog), "profile", selected_profile, g_object_unref);
+
+  g_signal_connect (dialog, "response",
+                    G_CALLBACK (profile_list_delete_confirm_response_cb),
+                    data);
+
+  gtk_window_present (GTK_WINDOW (dialog));
+}
+
+static void
+profile_list_new_button_clicked_cb (GtkWidget *button,
+                                    PrefData *data)
+{
+  terminal_app_new_profile (terminal_app_get (), NULL, GTK_WINDOW (data->parent));
+}
+
+static void
+profile_list_clone_button_clicked_cb (GtkWidget *button,
+                                      PrefData *data)
+{
+  GSettings *selected_profile;
+
+  selected_profile = profile_list_ref_selected (data);
+  if (selected_profile == NULL)
+    return;
+
+  terminal_app_new_profile (terminal_app_get (), selected_profile, GTK_WINDOW (data->parent));
+  g_object_unref (selected_profile);
+}
+
+static void
+profile_list_edit_button_clicked_cb (GtkWidget *button,
+                                     PrefData *data)
+{
+  GSettings *selected_profile;
+
+  selected_profile = profile_list_ref_selected (data);
+  if (selected_profile == NULL)
+    return;
+
+  terminal_app_edit_profile (terminal_app_get (), selected_profile,
+                             GTK_WINDOW (data->dialog), NULL);
+  g_object_unref (selected_profile);
+}
+
+static void
+profile_list_selection_changed_cb (GtkTreeSelection *selection,
+                                   PrefData *data)
+{
+  gboolean selected;
+  GSettings *selected_profile;
+
+  selected = gtk_tree_selection_get_selected (selection, NULL, NULL);
+  selected_profile = profile_list_ref_selected (data);
+
+  gtk_widget_set_sensitive (data->manage_profiles_edit_button, selected);
+  gtk_widget_set_sensitive (data->manage_profiles_clone_button, selected);
+  gtk_widget_set_sensitive (data->manage_profiles_delete_button,
+                            selected && 
+                            terminal_app_can_remove_profile (terminal_app_get (), selected_profile));
+
+  if (selected_profile)
+    g_object_unref (selected_profile);
+}
+
+/* Keybindings tab */
+
+/* Encodings tab */
+
+static void
+update_active_encodings_setting (void)
+{
+  TerminalApp *app;
+  GSList *list, *l;
+  GVariantBuilder builder;
+  GSettings *settings;
+
+  app = terminal_app_get ();
+
+  g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
+
+  list = terminal_app_get_active_encodings (app);
+  for (l = list; l != NULL; l = l->next)
+    {
+      TerminalEncoding *encoding = (TerminalEncoding *) l->data;
+
+      g_variant_builder_add (&builder, "s", terminal_encoding_get_id (encoding));
+    }
+  g_slist_foreach (list, (GFunc) terminal_encoding_unref, NULL);
+  g_slist_free (list);
+
+  settings = terminal_app_get_global_settings (app);
+  g_settings_set (settings, TERMINAL_SETTING_ENCODINGS_KEY, "as", &builder);
+}
+
+enum
+{
+  COLUMN_NAME,
+  COLUMN_CHARSET,
+  COLUMN_DATA,
+  N_ENCODING_COLUMNS
+};
+
+static void
+selection_changed_cb (GtkTreeSelection *selection,
+                      PrefData *data)
+{
+  GtkWidget *button;
+  gboolean have_selection;
+
+  if (selection == data->encoding_available_selection)
+    button = data->encoding_add_button;
+  else if (selection == data->encoding_active_selection)
+    button = data->encoding_remove_button;
+  else
+    g_assert_not_reached ();
+
+  have_selection = gtk_tree_selection_get_selected (selection, NULL, NULL);
+  gtk_widget_set_sensitive (button, have_selection);
+}
+
+static void
+button_clicked_cb (GtkWidget *button,
+                   PrefData *data)
+{
+  GtkTreeSelection *selection;
+  GtkTreeModel *model;
+  GtkTreeIter filter_iter, iter;
+  TerminalEncoding *encoding;
+
+  if (button == data->encoding_add_button)
+    selection = data->encoding_available_selection;
+  else if (button == data->encoding_remove_button)
+    selection = data->encoding_active_selection;
+  else
+    g_assert_not_reached ();
+
+  if (!gtk_tree_selection_get_selected (selection, &model, &filter_iter))
+    return;
+
+  gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (model),
+                                                    &iter,
+                                                    &filter_iter);
+
+  model = GTK_TREE_MODEL (data->encoding_base_store);
+  gtk_tree_model_get (model, &iter, COLUMN_DATA, &encoding, -1);
+  g_assert (encoding != NULL);
+
+  if (button == data->encoding_add_button)
+    encoding->is_active = TRUE;
+  else if (button == data->encoding_remove_button)
+    encoding->is_active = FALSE;
+  else
+    g_assert_not_reached ();
+
+  terminal_encoding_unref (encoding);
+
+  /* We don't need to emit row-changed here, since updating the pref
+   * will update the models.
+   */
+  update_active_encodings_setting ();
+}
+
+static void
+liststore_insert_encoding (gpointer key,
+                           TerminalEncoding *encoding,
+                           GtkListStore *store)
+{
+  GtkTreeIter iter;
+
+  if (!terminal_encoding_is_valid (encoding))
+    return;
+
+  gtk_list_store_insert_with_values (store, &iter, -1,
+                                     COLUMN_CHARSET, terminal_encoding_get_charset (encoding),
+                                     COLUMN_NAME, encoding->name,
+                                     COLUMN_DATA, encoding,
+                                     -1);
+}
+
+static gboolean
+filter_active_encodings (GtkTreeModel *child_model,
+                         GtkTreeIter *child_iter,
+                         gpointer data)
+{
+  TerminalEncoding *encoding;
+  gboolean active = GPOINTER_TO_UINT (data);
+  gboolean visible;
+
+  gtk_tree_model_get (child_model, child_iter, COLUMN_DATA, &encoding, -1);
+  visible = active ? encoding->is_active : !encoding->is_active;
+  terminal_encoding_unref (encoding);
+
+  return visible;
+}
+
+static GtkTreeModel *
+encodings_create_treemodel (GtkListStore *base_store,
+                            gboolean active)
+{
+  GtkTreeModel *model;
+
+  model = gtk_tree_model_filter_new (GTK_TREE_MODEL (base_store), NULL);
+  gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (model),
+                                          filter_active_encodings,
+                                          GUINT_TO_POINTER (active), NULL);
+
+  return model;
+}
+
+static void
+encodings_list_changed_cb (PrefData *data)
+{
+  gtk_list_store_clear (data->encoding_base_store);
+
+  g_hash_table_foreach (terminal_app_get_encodings (terminal_app_get ()),
+                        (GHFunc) liststore_insert_encoding, data->encoding_base_store);
+}
+
+/* misc */
+
+static void
+prefs_dialog_destroy_cb (GtkWidget *widget,
+                         PrefData *data)
+{
+  TerminalApp *app = terminal_app_get ();
+
+  g_signal_handlers_disconnect_by_func (app, G_CALLBACK (profile_list_treeview_refill), data);
+  g_signal_handlers_disconnect_by_func (app, G_CALLBACK (profile_combo_box_refill), data);
+  g_signal_handlers_disconnect_by_func (app, G_CALLBACK (encodings_list_changed_cb), data);
+
+  g_signal_handlers_disconnect_by_func (widget, G_CALLBACK (prefs_dialog_destroy_cb), data);
+  g_free (data);
 }
 
 void
-terminal_prefs_show_preferences (GtkWindow *transient_parent)
+terminal_prefs_show_preferences (GtkWindow *transient_parent,
+                                 const char *page)
 {
+  TerminalApp *app = terminal_app_get ();
+  PrefData *data;
   GtkWidget *dialog, *tree_view;
   GtkWidget *show_menubar_button, *disable_mnemonics_button, *disable_menu_accel_button;
+  GtkWidget *tree_view_container, *new_button, *edit_button, *clone_button, *remove_button;
+  GtkWidget *default_hbox, *default_label;
+  GtkTreeSelection *selection;
   GSettings *settings;
+  GtkCellRenderer *cell_renderer;
+  GtkTreeViewColumn *column;
+  GtkTreeModel *model;
 
   if (prefs_dialog != NULL)
     goto done;
 
+  data = g_new0 (PrefData, 1);
+  data->parent = transient_parent;
+
   terminal_util_load_builder_resource ("/org/gnome/terminal/ui/preferences.ui",
+                                       "preferences-dialog",
                                        "preferences-dialog", &dialog,
                                        "default-show-menubar-checkbutton", &show_menubar_button,
                                        "disable-mnemonics-checkbutton", &disable_mnemonics_button,
                                        "disable-menu-accel-checkbutton", &disable_menu_accel_button,
                                        "accelerators-treeview", &tree_view,
+                                       "profiles-treeview-container", &tree_view_container,
+                                       "new-profile-button", &new_button,
+                                       "edit-profile-button", &edit_button,
+                                       "clone-profile-button", &clone_button,
+                                       "delete-profile-button", &remove_button,
+                                       "default-profile-hbox", &default_hbox,
+                                       "default-profile-label", &default_label,
+                                       "add-button", &data->encoding_add_button,
+                                       "remove-button", &data->encoding_remove_button,
+                                       "available-treeview", &data->encoding_available_tree_view,
+                                       "displayed-treeview", &data->encoding_active_tree_view,
                                        NULL);
 
+  data->dialog = dialog;
+
   terminal_util_bind_mnemonic_label_sensitivity (dialog);
 
   settings = terminal_app_get_global_settings (terminal_app_get ());
 
+  /* General tab */
+
   g_settings_bind (settings,
                    TERMINAL_SETTING_DEFAULT_SHOW_MENUBAR_KEY,
                    show_menubar_button,
                    "active",
                    G_SETTINGS_BIND_GET | G_SETTINGS_BIND_SET);
 
+  /* Keybindings tab */
+
   g_settings_bind (settings,
                    TERMINAL_SETTING_ENABLE_MNEMONICS_KEY,
                    disable_mnemonics_button,
@@ -87,10 +725,135 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent)
 
   terminal_accels_fill_treeview (tree_view);
 
+  /* Profiles tab */
 
-  g_signal_connect (dialog, "response",
-                    G_CALLBACK (prefs_dialog_response_cb),
-                    NULL);
+  data->manage_profiles_new_button = GTK_WIDGET (new_button);
+  data->manage_profiles_edit_button = GTK_WIDGET (edit_button);
+  data->manage_profiles_clone_button = GTK_WIDGET (clone_button);
+  data->manage_profiles_delete_button  = GTK_WIDGET (remove_button);
+
+  data->manage_profiles_list = profile_list_treeview_new (data);
+  selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->manage_profiles_list));
+  g_signal_connect (selection, "changed", G_CALLBACK (profile_list_selection_changed_cb), data);
+
+  profile_list_treeview_refill (data);
+  g_signal_connect_swapped (app, "profile-list-changed",
+                            G_CALLBACK (profile_list_treeview_refill), data);
+
+  gtk_container_add (GTK_CONTAINER (tree_view_container), GTK_WIDGET (data->manage_profiles_list));
+  gtk_widget_show (GTK_WIDGET (data->manage_profiles_list));
+
+  g_signal_connect (new_button, "clicked",
+                    G_CALLBACK (profile_list_new_button_clicked_cb),
+                    data);
+  g_signal_connect (edit_button, "clicked",
+                    G_CALLBACK (profile_list_edit_button_clicked_cb),
+                    data);
+  g_signal_connect (clone_button, "clicked",
+                    G_CALLBACK (profile_list_clone_button_clicked_cb),
+                    data);
+  g_signal_connect (remove_button, "clicked",
+                    G_CALLBACK (profile_list_delete_button_clicked_cb),
+                    data);
+
+  data->manage_profiles_default_menu = profile_combo_box_new (data);
+  g_signal_connect (data->manage_profiles_default_menu, "changed",
+                    G_CALLBACK (profile_combo_box_changed_cb), data);
+
+  gtk_box_pack_start (GTK_BOX (default_hbox), data->manage_profiles_default_menu, FALSE, FALSE, 0);
+  gtk_widget_show (data->manage_profiles_default_menu);
+
+  // FIXMEchpe
+  gtk_label_set_mnemonic_widget (GTK_LABEL (default_label), data->manage_profiles_default_menu);
+
+  //  gtk_widget_grab_focus (app->manage_profiles_list);
+
+  /* Encodings tab */
+
+  /* buttons */
+  g_signal_connect (data->encoding_add_button, "clicked",
+                    G_CALLBACK (button_clicked_cb), data);
+
+  g_signal_connect (data->encoding_remove_button, "clicked",
+                    G_CALLBACK (button_clicked_cb), data);
+  
+  /* Tree view of available encodings */
+  /* Column 1 */
+  cell_renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
+						     cell_renderer,
+						     "text", COLUMN_NAME,
+						     NULL);
+  gtk_tree_view_append_column (data->encoding_available_tree_view, column);
+  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
+  
+  /* Column 2 */
+  cell_renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
+						     cell_renderer,
+						     "text", COLUMN_CHARSET,
+						     NULL);
+  gtk_tree_view_append_column (data->encoding_available_tree_view, column);
+  gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);  
+
+  data->encoding_available_selection = gtk_tree_view_get_selection (data->encoding_available_tree_view);
+  gtk_tree_selection_set_mode (data->encoding_available_selection, GTK_SELECTION_BROWSE);
+
+  g_signal_connect (data->encoding_available_selection, "changed",
+                    G_CALLBACK (selection_changed_cb), data);
+
+  /* Tree view of selected encodings */
+  /* Column 1 */
+  cell_renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (_("_Description"),
+						     cell_renderer,
+						     "text", COLUMN_NAME,
+						     NULL);
+  gtk_tree_view_append_column (data->encoding_active_tree_view, column);
+  gtk_tree_view_column_set_sort_column_id (column, COLUMN_NAME);
+  
+  /* Column 2 */
+  cell_renderer = gtk_cell_renderer_text_new ();
+  column = gtk_tree_view_column_new_with_attributes (_("_Encoding"),
+						     cell_renderer,
+						     "text", COLUMN_CHARSET,
+						     NULL);
+  gtk_tree_view_append_column (data->encoding_active_tree_view, column);
+  gtk_tree_view_column_set_sort_column_id (column, COLUMN_CHARSET);  
+
+  /* Add the data */
+
+  data->encoding_active_selection = gtk_tree_view_get_selection (data->encoding_active_tree_view);
+  gtk_tree_selection_set_mode (data->encoding_active_selection, GTK_SELECTION_BROWSE);
+
+  g_signal_connect (data->encoding_active_selection, "changed",
+                    G_CALLBACK (selection_changed_cb), data);
+
+  data->encoding_base_store = gtk_list_store_new (N_ENCODING_COLUMNS, G_TYPE_STRING, G_TYPE_STRING, TERMINAL_TYPE_ENCODING);
+
+  encodings_list_changed_cb (data);
+  g_signal_connect_swapped (app, "encoding-list-changed",
+                            G_CALLBACK (encodings_list_changed_cb), data);
+
+  /* Now turn on sorting */
+  gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (data->encoding_base_store),
+                                        COLUMN_NAME,
+                                        GTK_SORT_ASCENDING);
+  
+  model = encodings_create_treemodel (data->encoding_base_store, FALSE);
+  gtk_tree_view_set_model (data->encoding_available_tree_view, model);
+  g_object_unref (model);
+
+  model = encodings_create_treemodel (data->encoding_base_store, TRUE);
+  gtk_tree_view_set_model (data->encoding_active_tree_view, model);
+  g_object_unref (model);
+
+  g_object_unref (data->encoding_base_store);
+
+  /* misc */
+
+  g_signal_connect (dialog, "response", G_CALLBACK (prefs_dialog_response_cb), data);
+  g_signal_connect (dialog, "destroy", G_CALLBACK (prefs_dialog_destroy_cb), data);
   gtk_window_set_default_size (GTK_WINDOW (dialog), -1, 350);
 
   prefs_dialog = dialog;
@@ -98,5 +861,8 @@ terminal_prefs_show_preferences (GtkWindow *transient_parent)
 
 done:
   gtk_window_set_transient_for (GTK_WINDOW (prefs_dialog), transient_parent);
+
+  terminal_util_dialog_focus_widget (dialog, page);
+
   gtk_window_present (GTK_WINDOW (prefs_dialog));
 }
diff --git a/src/terminal-prefs.h b/src/terminal-prefs.h
index ba7e2ae..82d423b 100644
--- a/src/terminal-prefs.h
+++ b/src/terminal-prefs.h
@@ -22,7 +22,8 @@
 
 G_BEGIN_DECLS
 
-void terminal_prefs_show_preferences (GtkWindow *transient_parent);
+void terminal_prefs_show_preferences (GtkWindow *transient_parent,
+                                      const char *page);
 
 G_END_DECLS
 
diff --git a/src/terminal-profile-utils.c b/src/terminal-profile-utils.c
index 877764c..d496db8 100644
--- a/src/terminal-profile-utils.c
+++ b/src/terminal-profile-utils.c
@@ -241,3 +241,36 @@ terminal_profile_util_get_profile_uuid (GSettings *profile)
   uuid[36] = '\0';
   return uuid;
 }
+
+int 
+terminal_profile_util_profiles_compare (gconstpointer pa,
+                                        gconstpointer pb)
+{
+  GSettings *a = (GSettings *) pa;
+  GSettings *b = (GSettings *) pb;
+  const char *na, *nb;
+  char *patha, *pathb;
+  int result;
+
+  if (pa == pb)
+    return 0;
+  if (pa == NULL)
+    return 1;
+  if (pb == NULL)
+    return -1;
+
+  g_settings_get (a, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &na);
+  g_settings_get (b, TERMINAL_PROFILE_VISIBLE_NAME_KEY, "&s", &nb);
+  result =  g_utf8_collate (na, nb);
+  if (result != 0)
+    return result;
+
+  g_object_get (a, "path", &patha, NULL);
+  g_object_get (b, "path", &pathb, NULL);
+  result = strcmp (patha, pathb);
+  g_free (patha);
+  g_free (pathb);
+
+  return result;
+}
+
diff --git a/src/terminal-profile-utils.h b/src/terminal-profile-utils.h
index df17a44..3403ccb 100644
--- a/src/terminal-profile-utils.h
+++ b/src/terminal-profile-utils.h
@@ -35,6 +35,9 @@ char *terminal_profile_util_get_profile_by_uuid_or_name (const char *uuid_or_nam
 
 char *terminal_profile_util_get_profile_uuid (GSettings *profile);
 
+int terminal_profile_util_profiles_compare (gconstpointer pa,
+                                            gconstpointer pb);
+
 G_END_DECLS
 
 #endif /* TERMINAL_UTIL_UTILS_H */
diff --git a/src/terminal-search-dialog.c b/src/terminal-search-dialog.c
index 3d43a7a..1873e63 100644
--- a/src/terminal-search-dialog.c
+++ b/src/terminal-search-dialog.c
@@ -82,6 +82,7 @@ terminal_search_dialog_new (GtkWindow   *parent)
   priv = g_new0 (TerminalSearchDialogPrivate, 1);
 
   terminal_util_load_builder_resource ("/org/gnome/terminal/ui/find-dialog.ui",
+                                       NULL,
                                        "find-dialog", &dialog,
                                        "search-label", &priv->search_label,
                                        "search-entry", &priv->search_entry,
diff --git a/src/terminal-util.c b/src/terminal-util.c
index 82c7bda..6ffabbd 100644
--- a/src/terminal-util.c
+++ b/src/terminal-util.c
@@ -403,8 +403,15 @@ terminal_util_get_licence_text (void)
   return g_strjoin ("\n\n", _(license[0]), _(license[1]), _(license[2]), NULL);
 }
 
+static void
+main_object_destroy_cb (GtkWidget *widget)
+{
+  g_object_set_data (G_OBJECT (widget), "builder", NULL);
+}
+
 void
 terminal_util_load_builder_resource (const char *path,
+                                     const char *main_object_name,
                                      const char *object_name,
                                      ...)
 {
@@ -431,7 +438,15 @@ terminal_util_load_builder_resource (const char *path,
 
   va_end (args);
 
-  g_object_unref (builder);
+  if (main_object_name) {
+    GObject *main_object;
+
+    main_object = gtk_builder_get_object (builder, main_object_name);
+    g_object_set_data_full (main_object, "builder", builder, (GDestroyNotify) g_object_unref);
+    g_signal_connect (main_object, "destroy", G_CALLBACK (main_object_destroy_cb), NULL);
+  } else {
+    g_object_unref (builder);
+  }
 }
 
 gboolean
@@ -441,6 +456,39 @@ terminal_util_dialog_response_on_delete (GtkWindow *widget)
   return TRUE;
 }
 
+void
+terminal_util_dialog_focus_widget (GtkWidget *dialog,
+                                   const char *widget_name)
+{
+  GtkBuilder *builder;
+  GtkWidget *widget, *page, *page_parent;
+
+  if (widget_name == NULL)
+    return;
+
+  builder = g_object_get_data (G_OBJECT (dialog), "builder");
+  widget = GTK_WIDGET (gtk_builder_get_object (builder, widget_name));
+  if (widget == NULL)
+    return;
+
+  page = widget;
+  while (page != NULL &&
+         (page_parent = gtk_widget_get_parent (page)) != NULL &&
+         !GTK_IS_NOTEBOOK (page_parent))
+    page = page_parent;
+
+  page_parent = gtk_widget_get_parent (page);
+  if (page != NULL && GTK_IS_NOTEBOOK (page_parent)) {
+    GtkNotebook *notebook;
+
+    notebook = GTK_NOTEBOOK (page_parent);
+    gtk_notebook_set_current_page (notebook, gtk_notebook_page_num (notebook, page));
+  }
+
+  if (gtk_widget_is_sensitive (widget))
+    gtk_widget_grab_focus (widget);
+}
+
 /* Like g_key_file_set_string, but escapes characters so that
  * the stored string is ASCII. Use when the input string may not
  * be UTF-8.
diff --git a/src/terminal-util.h b/src/terminal-util.h
index 8d69992..13ce973 100644
--- a/src/terminal-util.h
+++ b/src/terminal-util.h
@@ -56,9 +56,13 @@ char *terminal_util_concat_uris (char **uris,
 char *terminal_util_get_licence_text (void);
 
 void terminal_util_load_builder_resource (const char *path,
+                                          const char *main_object_name,
                                           const char *object_name,
                                           ...);
 
+void terminal_util_dialog_focus_widget (GtkWidget *dialog,
+                                        const char *widget_name);
+
 gboolean terminal_util_dialog_response_on_delete (GtkWindow *widget);
 
 void terminal_util_key_file_set_string_escape    (GKeyFile *key_file,
diff --git a/src/terminal-window.c b/src/terminal-window.c
index 212b354..183fba7 100644
--- a/src/terminal-window.c
+++ b/src/terminal-window.c
@@ -167,8 +167,6 @@ static void edit_select_all_callback          (GtkAction *action,
                                                TerminalWindow *window);
 static void edit_preferences_callback         (GtkAction *action,
                                                TerminalWindow *window);
-static void edit_profiles_callback            (GtkAction *action,
-                                               TerminalWindow *window);
 static void edit_current_profile_callback     (GtkAction *action,
                                                TerminalWindow *window);
 static void view_menubar_toggled_callback     (GtkToggleAction *action,
@@ -1663,9 +1661,6 @@ terminal_window_init (TerminalWindow *window)
       { "EditSelectAll", GTK_STOCK_SELECT_ALL, NULL, NULL,
         NULL,
         G_CALLBACK (edit_select_all_callback) },
-      { "EditProfiles", NULL, N_("P_rofilesâ"), NULL,
-        NULL,
-        G_CALLBACK (edit_profiles_callback) },
       { "EditPreferences", NULL, N_("Pre_ferencesâ"), NULL,
         NULL,
         G_CALLBACK (edit_preferences_callback) },
@@ -3145,14 +3140,6 @@ file_new_profile_callback (GtkAction *action,
 }
 
 static void
-edit_profiles_callback (GtkAction *action,
-                        TerminalWindow *window)
-{
-  terminal_app_manage_profiles (terminal_app_get (),
-                                GTK_WINDOW (window));
-}
-
-static void
 view_menubar_toggled_callback (GtkToggleAction *action,
                                TerminalWindow *window)
 {
diff --git a/src/terminal.gresource.xml b/src/terminal.gresource.xml
index e23f789..ba87a8b 100644
--- a/src/terminal.gresource.xml
+++ b/src/terminal.gresource.xml
@@ -20,10 +20,8 @@
     <file alias="ui/terminal.xml" compressed="true" preprocess="xml-stripblanks">terminal.xml</file>
     <file alias="ui/terminal-appmenu.ui" compressed="true" preprocess="xml-stripblanks">terminal-appmenu.ui</file>
     <file alias="ui/terminal.about" compressed="true">terminal.about</file>
-    <file alias="ui/encodings-dialog.ui" compressed="true" preprocess="xml-stripblanks">encodings-dialog.ui</file>
     <file alias="ui/find-dialog.ui" compressed="true" preprocess="xml-stripblanks">find-dialog.ui</file>
     <file alias="ui/preferences.ui" compressed="true" preprocess="xml-stripblanks">preferences.ui</file>
-    <file alias="ui/profile-manager.ui" compressed="true" preprocess="xml-stripblanks">profile-manager.ui</file>
     <file alias="ui/profile-preferences.ui" compressed="true" preprocess="xml-stripblanks">profile-preferences.ui</file>
   </gresource>
 </gresources>
diff --git a/src/terminal.xml b/src/terminal.xml
index 9fee096..2bff712 100644
--- a/src/terminal.xml
+++ b/src/terminal.xml
@@ -19,7 +19,6 @@
       <separator />
       <menuitem action="EditSelectAll" />
       <separator />
-      <menuitem action="EditProfiles" />
       <menuitem action="EditPreferences" />
       <menuitem action="EditCurrentProfile" />
     </menu>



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