[gnome-builder] preferences: use selection mode and simplify languages



commit 56298ca1de85801d3ff1eacf9d3f69f8bcacf0e0
Author: Christian Hergert <chergert redhat com>
Date:   Sat Sep 17 11:44:10 2016 -0700

    preferences: use selection mode and simplify languages
    
    This simplifies the language settings a bit and uses the selection mode
    that was added to determine which list groups get selected styling.

 libide/preferences/ide-preferences-builtin.c |   72 +++++++++++++-------------
 1 files changed, 36 insertions(+), 36 deletions(-)
---
diff --git a/libide/preferences/ide-preferences-builtin.c b/libide/preferences/ide-preferences-builtin.c
index 54c6c5d..366d658 100644
--- a/libide/preferences/ide-preferences-builtin.c
+++ b/libide/preferences/ide-preferences-builtin.c
@@ -44,8 +44,8 @@ ide_preferences_builtin_register_plugins (IdePreferences *preferences)
   list = peas_engine_get_plugin_list (engine);
 
   ide_preferences_add_page (preferences, "plugins", _("Extensions"), 700);
-  ide_preferences_add_list_group (preferences, "plugins", "installed", _("Installed Extensions"), 0);
-  ide_preferences_add_list_group (preferences, "plugins", "builtin", _("Bundled Extensions"), 100);
+  ide_preferences_add_list_group (preferences, "plugins", "installed", _("Installed Extensions"), 
GTK_SELECTION_NONE, 0);
+  ide_preferences_add_list_group (preferences, "plugins", "builtin", _("Bundled Extensions"), 
GTK_SELECTION_NONE, 100);
 
   for (; list; list = list->next, i++)
     {
@@ -84,11 +84,11 @@ ide_preferences_builtin_register_appearance (IdePreferences *preferences)
 
   ide_preferences_add_page (preferences, "appearance", _("Appearance"), 0);
 
-  ide_preferences_add_list_group (preferences, "appearance", "basic", _("Themes"), 0);
+  ide_preferences_add_list_group (preferences, "appearance", "basic", _("Themes"), GTK_SELECTION_NONE, 0);
   dark_mode = ide_preferences_add_switch (preferences, "appearance", "basic", "org.gnome.builder", 
"night-mode", NULL, NULL, _("Dark Theme"), _("Whether Builder should use a dark theme"), _("dark theme"), 0);
   ide_preferences_add_switch (preferences, "appearance", "basic", "org.gnome.builder.editor", 
"show-grid-lines", NULL, NULL, _("Grid Pattern"), _("Display a grid pattern underneath source code"), NULL, 
0);
 
-  ide_preferences_add_list_group (preferences, "appearance", "schemes", NULL, 100);
+  ide_preferences_add_list_group (preferences, "appearance", "schemes", NULL, GTK_SELECTION_NONE, 100);
 
   manager = gtk_source_style_scheme_manager_get_default ();
   scheme_ids = gtk_source_style_scheme_manager_get_scheme_ids (manager);
@@ -106,7 +106,7 @@ ide_preferences_builtin_register_appearance (IdePreferences *preferences)
       ide_preferences_add_radio (preferences, "appearance", "schemes", "org.gnome.builder.editor", 
"style-scheme-name", NULL, variant_str, title, NULL, title, i);
     }
 
-  ide_preferences_add_list_group (preferences, "appearance", "font", _("Font"), 200);
+  ide_preferences_add_list_group (preferences, "appearance", "font", _("Font"), GTK_SELECTION_NONE, 200);
   ide_preferences_add_font_button (preferences, "appearance", "font", "org.gnome.builder.editor", 
"font-name", _("Editor"), C_("Keywords", "editor font monospace"), 0);
   /* XXX: This belongs in terminal addin */
   ide_preferences_add_font_button (preferences, "appearance", "font", "org.gnome.builder.terminal", 
"font-name", _("Terminal"), C_("Keywords", "terminal font monospace"), 0);
@@ -123,12 +123,12 @@ ide_preferences_builtin_register_keyboard (IdePreferences *preferences)
 {
   ide_preferences_add_page (preferences, "keyboard", _("Keyboard"), 400);
 
-  ide_preferences_add_list_group (preferences, "keyboard", "mode", _("Emulation"), 0);
+  ide_preferences_add_list_group (preferences, "keyboard", "mode", _("Emulation"), GTK_SELECTION_NONE, 0);
   ide_preferences_add_radio (preferences, "keyboard", "mode", "org.gnome.builder.editor", "keybindings", 
NULL, "\"default\"", _("Builder"), _("Default keybinding mode which mimics gedit"), NULL, 0);
   ide_preferences_add_radio (preferences, "keyboard", "mode", "org.gnome.builder.editor", "keybindings", 
NULL, "\"emacs\"", _("Emacs"), _("Emulates the Emacs text editor"), NULL, 0);
   ide_preferences_add_radio (preferences, "keyboard", "mode", "org.gnome.builder.editor", "keybindings", 
NULL, "\"vim\"", _("Vim"), _("Emulates the Vim text editor"), NULL, 0);
 
-  ide_preferences_add_list_group (preferences, "keyboard", "movements", _("Movement"), 100);
+  ide_preferences_add_list_group (preferences, "keyboard", "movements", _("Movement"), GTK_SELECTION_NONE, 
100);
   ide_preferences_add_switch (preferences, "keyboard", "movements", "org.gnome.builder.editor", 
"smart-home-end", NULL, NULL, _("Smart Home and End"), _("Home moves to first non-whitespace character"), 
NULL, 0);
   ide_preferences_add_switch (preferences, "keyboard", "movements", "org.gnome.builder.editor", 
"smart-backspace", NULL, NULL, _("Smart Backspace"), _("Backspace will remove extra space to keep you aligned 
with your indentation"), NULL, 100);
 }
@@ -138,24 +138,24 @@ ide_preferences_builtin_register_editor (IdePreferences *preferences)
 {
   ide_preferences_add_page (preferences, "editor", _("Editor"), 100);
 
-  ide_preferences_add_list_group (preferences, "editor", "position", _("Cursor"), 0);
+  ide_preferences_add_list_group (preferences, "editor", "position", _("Cursor"), GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "editor", "position", "org.gnome.builder.editor", 
"restore-insert-mark", NULL, NULL, _("Restore cursor position"), _("Restore cursor position when a file is 
reopened"), NULL, 0);
   ide_preferences_add_spin_button (preferences, "editor", "position", "org.gnome.builder.editor", 
"scroll-offset", NULL, _("Scroll Offset"), _("Minimum number of lines to keep above and below the cursor"), 
NULL, 10);
   ide_preferences_add_spin_button (preferences, "editor", "position", "org.gnome.builder.editor", 
"overscroll", NULL, _("Overscroll"), _("Allow the editor to scroll past the end of the buffer"), NULL, 20);
 
-  ide_preferences_add_list_group (preferences, "editor", "line", _("Line Information"), 50);
+  ide_preferences_add_list_group (preferences, "editor", "line", _("Line Information"), GTK_SELECTION_NONE, 
50);
   ide_preferences_add_switch (preferences, "editor", "line", "org.gnome.builder.editor", 
"show-line-numbers", NULL, NULL, _("Line numbers"), _("Show line number at beginning of each line"), NULL, 0);
   ide_preferences_add_switch (preferences, "editor", "line", "org.gnome.builder.editor", 
"show-line-changes", NULL, NULL, _("Line changes"), _("Show if a line was added or modified next to line 
number"), NULL, 1);
 
-  ide_preferences_add_list_group (preferences, "editor", "highlight", _("Highlight"), 100);
+  ide_preferences_add_list_group (preferences, "editor", "highlight", _("Highlight"), GTK_SELECTION_NONE, 
100);
   ide_preferences_add_switch (preferences, "editor", "highlight", "org.gnome.builder.editor", 
"highlight-current-line", NULL, NULL, _("Current line"), _("Make current line stand out with highlights"), 
NULL, 0);
   ide_preferences_add_switch (preferences, "editor", "highlight", "org.gnome.builder.editor", 
"highlight-matching-brackets", NULL, NULL, _("Matching brackets"), _("Highlight matching brackets based on 
cursor position"), NULL, 1);
 
-  ide_preferences_add_list_group (preferences, "editor", "overview", _("Code Overview"), 100);
+  ide_preferences_add_list_group (preferences, "editor", "overview", _("Code Overview"), GTK_SELECTION_NONE, 
100);
   ide_preferences_add_switch (preferences, "editor", "overview", "org.gnome.builder.editor", "show-map", 
NULL, NULL, _("Show overview map"), _("A zoomed out view to enhance navigating source code"), NULL, 0);
   ide_preferences_add_switch (preferences, "editor", "overview", "org.gnome.builder.editor", 
"auto-hide-map", NULL, NULL, _("Automatically hide overview map"), _("Automatically hide map when editor 
loses focus"), NULL, 1);
 
-  ide_preferences_add_list_group (preferences, "editor", "draw-spaces", _("Whitespace Characters"), 400);
+  ide_preferences_add_list_group (preferences, "editor", "draw-spaces", _("Whitespace Characters"), 
GTK_SELECTION_NONE, 400);
   ide_preferences_add_radio (preferences, "editor", "draw-spaces", "org.gnome.builder.editor", 
"draw-spaces", NULL, "\"space\"", _("Spaces"), NULL, NULL, 0);
   ide_preferences_add_radio (preferences, "editor", "draw-spaces", "org.gnome.builder.editor", 
"draw-spaces", NULL, "\"tab\"", _("Tabs"), NULL, NULL, 1);
   ide_preferences_add_radio (preferences, "editor", "draw-spaces", "org.gnome.builder.editor", 
"draw-spaces", NULL, "\"newline\"", _("New line and carriage return"), NULL, NULL, 2);
@@ -170,15 +170,15 @@ ide_preferences_builtin_register_code_insight (IdePreferences *preferences)
 {
   ide_preferences_add_page (preferences, "code-insight", _("Code Insight"), 300);
 
-  ide_preferences_add_list_group (preferences, "code-insight", "highlighting", _("Highlighting"), 0);
+  ide_preferences_add_list_group (preferences, "code-insight", "highlighting", _("Highlighting"), 
GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "code-insight", "highlighting", "org.gnome.builder.code-insight", 
"semantic-highlighting", NULL, NULL, _("Semantic Highlighting"), _("Use code insight to highlight additional 
information discovered in source file"), NULL, 0);
 
-  ide_preferences_add_list_group (preferences, "code-insight", "completion", _("Completion"), 100);
+  ide_preferences_add_list_group (preferences, "code-insight", "completion", _("Completion"), 
GTK_SELECTION_NONE, 100);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"word-completion", NULL, NULL, _("Suggest words found in open files"), _("Suggests completions as you type 
based on words found in any open document"), NULL, 0);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"ctags-autocompletion", NULL, NULL, _("Suggest completions using Ctags"), _("Create and manages a Ctags 
database for completing class names, functions, and more"), NULL, 10);
   ide_preferences_add_switch (preferences, "code-insight", "completion", "org.gnome.builder.code-insight", 
"clang-autocompletion", NULL, NULL, _("Suggest completions using Clang (Experimental)"), _("Use Clang to 
suggest completions for C and C++ languages"), NULL, 20);
 
-  ide_preferences_add_list_group (preferences, "code-insight", "diagnostics", _("Diagnostics"), 200);
+  ide_preferences_add_list_group (preferences, "code-insight", "diagnostics", _("Diagnostics"), 
GTK_SELECTION_NONE, 200);
 }
 
 static void
@@ -186,7 +186,7 @@ ide_preferences_builtin_register_snippets (IdePreferences *preferences)
 {
   ide_preferences_add_page (preferences, "snippets", _("Snippets"), 350);
 
-  ide_preferences_add_list_group (preferences, "snippets", "completion", NULL, 0);
+  ide_preferences_add_list_group (preferences, "snippets", "completion", NULL, GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "snippets", "completion", "org.gnome.builder.code-insight", 
"snippet-completion", NULL, NULL, _("Code snippets"), _("Use code fragments to increase typing efficiency"), 
NULL, 0);
 }
 
@@ -196,8 +196,7 @@ ide_preferences_builtin_register_languages (IdePreferences *preferences)
   GtkSourceLanguageManager *manager;
   const gchar * const *language_ids;
   g_autoptr(GHashTable) sections = NULL;
-  guint section_count = 0;
-  gint i;
+  GtkSearchEntry *search;
 
   sections = g_hash_table_new (g_str_hash, g_str_equal);
 
@@ -206,46 +205,47 @@ ide_preferences_builtin_register_languages (IdePreferences *preferences)
   manager = gtk_source_language_manager_get_default ();
   language_ids = gtk_source_language_manager_get_language_ids (manager);
 
-  for (i = 0; language_ids [i]; i++)
+  ide_preferences_add_group (preferences, "languages", "search", NULL, 0);
+
+  search = g_object_new (GTK_TYPE_SEARCH_ENTRY,
+                         "placeholder-text", _("Search languages…"),
+                         "visible", TRUE,
+                         NULL);
+  ide_preferences_add_custom (preferences, "languages", "search", GTK_WIDGET (search), NULL, 0);
+
+  ide_preferences_add_list_group (preferences, "languages", "languages", NULL, GTK_SELECTION_SINGLE, 1);
+
+  for (guint i = 0; language_ids [i]; i++)
     {
       IdePreferencesLanguageRow *row;
       GtkSourceLanguage *language;
       const gchar *name;
-      const gchar *section;
 
       if (ide_str_equal0 (language_ids [i], "def"))
         continue;
 
       language = gtk_source_language_manager_get_language (manager, language_ids [i]);
       name = gtk_source_language_get_name (language);
-      section = gtk_source_language_get_section (language);
-
-      if (!g_hash_table_contains (sections, section))
-        {
-          ide_preferences_add_list_group (preferences, "languages",
-                                          section, section, section_count++);
-          g_hash_table_insert (sections, (gchar *)section, NULL);
-        }
 
       row = g_object_new (IDE_TYPE_PREFERENCES_LANGUAGE_ROW,
                           "id", language_ids [i],
                           "title", name,
                           "visible", TRUE,
                           NULL);
-      ide_preferences_add_custom (preferences, "languages", section, GTK_WIDGET (row), NULL, 0);
+      ide_preferences_add_custom (preferences, "languages", "languages", GTK_WIDGET (row), NULL, 0);
     }
 
   ide_preferences_add_page (preferences, "languages.id", NULL, 0);
 
-  ide_preferences_add_list_group (preferences, "languages.id", "basic", NULL, 0);
+  ide_preferences_add_list_group (preferences, "languages.id", "basic", _("General"), GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "languages.id", "basic", "org.gnome.builder.editor.language", 
"trim-trailing-whitespace", "/org/gnome/builder/editor/language/{id}/", NULL, _("Trim trailing whitespace"), 
_("Upon saving, trailing whitespace from modified lines will be trimmed."), NULL, 10);
   ide_preferences_add_switch (preferences, "languages.id", "basic", "org.gnome.builder.editor.language", 
"overwrite-braces", "/org/gnome/builder/editor/language/{id}/", NULL, _("Overwrite Braces"), _("Overwrite 
closing braces"), NULL, 20);
 
-  ide_preferences_add_list_group (preferences, "languages.id", "margin", _("Margins"), 0);
+  ide_preferences_add_list_group (preferences, "languages.id", "margin", _("Margins"), GTK_SELECTION_NONE, 
0);
   ide_preferences_add_radio (preferences, "languages.id", "margin", "org.gnome.builder.editor.language", 
"show-right-margin", "/org/gnome/builder/editor/language/{id}/", NULL, _("Show right margin"), NULL, NULL, 0);
   ide_preferences_add_spin_button (preferences, "languages.id", "margin", 
"org.gnome.builder.editor.language", "right-margin-position", "/org/gnome/builder/editor/language/{id}/", 
_("Right margin position"), _("Position in spaces for the right margin"), NULL, 10);
 
-  ide_preferences_add_list_group (preferences, "languages.id", "indentation", _("Indentation"), 100);
+  ide_preferences_add_list_group (preferences, "languages.id", "indentation", _("Indentation"), 
GTK_SELECTION_NONE, 100);
   ide_preferences_add_spin_button (preferences, "languages.id", "indentation", 
"org.gnome.builder.editor.language", "tab-width", "/org/gnome/builder/editor/language/{id}/", _("Tab width"), 
_("Width of a tab character in spaces"), NULL, 10);
   ide_preferences_add_radio (preferences, "languages.id", "indentation", 
"org.gnome.builder.editor.language", "insert-spaces-instead-of-tabs", 
"/org/gnome/builder/editor/language/{id}/", NULL, _("Insert spaces instead of tabs"), _("Prefer spaces over 
use of tabs"), NULL, 20);
   ide_preferences_add_radio (preferences, "languages.id", "indentation", 
"org.gnome.builder.editor.language", "auto-indent", "/org/gnome/builder/editor/language/{id}/", NULL, 
_("Automatically indent"), _("Indent source code as you type"), NULL, 30);
@@ -298,7 +298,7 @@ ide_preferences_builtin_register_build (IdePreferences *preferences)
 
   ide_preferences_add_page (preferences, "build", _("Build"), 500);
 
-  ide_preferences_add_list_group (preferences, "build", "basic", _("General"), 0);
+  ide_preferences_add_list_group (preferences, "build", "basic", _("General"), GTK_SELECTION_NONE, 0);
   id = ide_preferences_add_spin_button (preferences, "build", "basic", "org.gnome.builder.build", 
"parallel", "/org/gnome/builder/build/", _("Build Workers"), _("Number of parallel build workers"), NULL, 0);
 
   bin = ide_preferences_get_widget (preferences, id);
@@ -313,11 +313,11 @@ ide_preferences_builtin_register_projects (IdePreferences *preferences)
 {
   ide_preferences_add_page (preferences, "projects", _("Projects"), 450);
 
-  ide_preferences_add_list_group (preferences, "projects", "directory", _("Workspace"), 0);
+  ide_preferences_add_list_group (preferences, "projects", "directory", _("Workspace"), GTK_SELECTION_NONE, 
0);
   ide_preferences_add_file_chooser (preferences, "projects", "directory", "org.gnome.builder", 
"projects-directory", NULL, _("Projects directory"), _("A place for all your projects"), 
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, NULL, 0);
   ide_preferences_add_switch (preferences, "projects", "directory", "org.gnome.builder", 
"restore-previous-files", NULL, NULL, _("Restore previously opened files"), _("Open previously opened files 
when loading a project"), NULL, 10);
 
-  ide_preferences_add_list_group (preferences, "projects", "discovery", _("Project Discovery"), 0);
+  ide_preferences_add_list_group (preferences, "projects", "discovery", _("Project Discovery"), 
GTK_SELECTION_NONE, 0);
   ide_preferences_add_switch (preferences, "projects", "discovery", "org.gnome.builder", 
"enable-project-miners", NULL, NULL, _("Discover projects on my computer"), _("Scan your computer for 
existing projects"), NULL, 0);
 }
 
@@ -423,7 +423,7 @@ vcs_configs_foreach_cb (PeasExtensionSet *set,
                            conf,
                            0);
 
-  ide_preferences_add_list_group (preferences, "vcs", id, name, 0);
+  ide_preferences_add_list_group (preferences, "vcs", id, name, GTK_SELECTION_NONE, 0);
   ide_preferences_add_custom (preferences, "vcs", id, fullname, NULL, 0);
   ide_preferences_add_custom (preferences, "vcs", id, email, NULL, 0);
 


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